BitstreamRemarkContainer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //===-- BitstreamRemarkContainer.h - Container for remarks --------------*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file provides declarations for things used in the various types of
  10. // remark containers.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_REMARKS_BITSTREAMREMARKCONTAINER_H
  14. #define LLVM_REMARKS_BITSTREAMREMARKCONTAINER_H
  15. #include "llvm/ADT/StringRef.h"
  16. #include "llvm/Bitstream/BitCodes.h"
  17. #include <cstdint>
  18. namespace llvm {
  19. namespace remarks {
  20. /// The current version of the remark container.
  21. /// Note: this is different from the version of the remark entry.
  22. constexpr uint64_t CurrentContainerVersion = 0;
  23. /// The magic number used for identifying remark blocks.
  24. constexpr StringLiteral ContainerMagic("RMRK");
  25. /// Type of the remark container.
  26. /// The remark container has two modes:
  27. /// * separate: the metadata is separate from the remarks and points to the
  28. /// auxiliary file that contains the remarks.
  29. /// * standalone: the metadata and the remarks are emitted together.
  30. enum class BitstreamRemarkContainerType {
  31. /// The metadata emitted separately.
  32. /// This will contain the following:
  33. /// * Container version and type
  34. /// * String table
  35. /// * External file
  36. SeparateRemarksMeta,
  37. /// The remarks emitted separately.
  38. /// This will contain the following:
  39. /// * Container version and type
  40. /// * Remark version
  41. SeparateRemarksFile,
  42. /// Everything is emitted together.
  43. /// This will contain the following:
  44. /// * Container version and type
  45. /// * Remark version
  46. /// * String table
  47. Standalone,
  48. First = SeparateRemarksMeta,
  49. Last = Standalone,
  50. };
  51. /// The possible blocks that will be encountered in a bitstream remark
  52. /// container.
  53. enum BlockIDs {
  54. /// The metadata block is mandatory. It should always come after the
  55. /// BLOCKINFO_BLOCK, and contains metadata that should be used when parsing
  56. /// REMARK_BLOCKs.
  57. /// There should always be only one META_BLOCK.
  58. META_BLOCK_ID = bitc::FIRST_APPLICATION_BLOCKID,
  59. /// One remark entry is represented using a REMARK_BLOCK. There can be
  60. /// multiple REMARK_BLOCKs in the same file.
  61. REMARK_BLOCK_ID
  62. };
  63. constexpr StringRef MetaBlockName = StringRef("Meta", 4);
  64. constexpr StringRef RemarkBlockName = StringRef("Remark", 6);
  65. /// The possible records that can be encountered in the previously described
  66. /// blocks.
  67. enum RecordIDs {
  68. // Meta block records.
  69. RECORD_META_CONTAINER_INFO = 1,
  70. RECORD_META_REMARK_VERSION,
  71. RECORD_META_STRTAB,
  72. RECORD_META_EXTERNAL_FILE,
  73. // Remark block records.
  74. RECORD_REMARK_HEADER,
  75. RECORD_REMARK_DEBUG_LOC,
  76. RECORD_REMARK_HOTNESS,
  77. RECORD_REMARK_ARG_WITH_DEBUGLOC,
  78. RECORD_REMARK_ARG_WITHOUT_DEBUGLOC,
  79. // Helpers.
  80. RECORD_FIRST = RECORD_META_CONTAINER_INFO,
  81. RECORD_LAST = RECORD_REMARK_ARG_WITHOUT_DEBUGLOC
  82. };
  83. constexpr StringRef MetaContainerInfoName = StringRef("Container info", 14);
  84. constexpr StringRef MetaRemarkVersionName = StringRef("Remark version", 14);
  85. constexpr StringRef MetaStrTabName = StringRef("String table", 12);
  86. constexpr StringRef MetaExternalFileName = StringRef("External File", 13);
  87. constexpr StringRef RemarkHeaderName = StringRef("Remark header", 13);
  88. constexpr StringRef RemarkDebugLocName = StringRef("Remark debug location", 21);
  89. constexpr StringRef RemarkHotnessName = StringRef("Remark hotness", 14);
  90. constexpr StringRef RemarkArgWithDebugLocName =
  91. StringRef("Argument with debug location", 28);
  92. constexpr StringRef RemarkArgWithoutDebugLocName = StringRef("Argument", 8);
  93. } // end namespace remarks
  94. } // end namespace llvm
  95. #endif // LLVM_REMARKS_BITSTREAMREMARKCONTAINER_H