BitstreamRemarkContainer.h 4.0 KB

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