Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
8.8 KiB

  1. //===-- llvm/Target/TargetLoweringObjectFile.h - Object Info ----*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file implements classes used to handle lowerings specific to common
  11. // object file formats.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_MC_SECTIONKIND_H
  15. #define LLVM_MC_SECTIONKIND_H
  16. namespace llvm {
  17. /// SectionKind - This is a simple POD value that classifies the properties of
  18. /// a section. A section is classified into the deepest possible
  19. /// classification, and then the target maps them onto their sections based on
  20. /// what capabilities they have.
  21. ///
  22. /// The comments below describe these as if they were an inheritance hierarchy
  23. /// in order to explain the predicates below.
  24. ///
  25. class SectionKind {
  26. enum Kind {
  27. /// Metadata - Debug info sections or other metadata.
  28. Metadata,
  29. /// Text - Text section, used for functions and other executable code.
  30. Text,
  31. /// ReadOnly - Data that is never written to at program runtime by the
  32. /// program or the dynamic linker. Things in the top-level readonly
  33. /// SectionKind are not mergeable.
  34. ReadOnly,
  35. /// MergableCString - Any null-terminated string which allows merging.
  36. /// These values are known to end in a nul value of the specified size,
  37. /// not otherwise contain a nul value, and be mergable. This allows the
  38. /// linker to unique the strings if it so desires.
  39. /// Mergeable1ByteCString - 1 byte mergable, null terminated, string.
  40. Mergeable1ByteCString,
  41. /// Mergeable2ByteCString - 2 byte mergable, null terminated, string.
  42. Mergeable2ByteCString,
  43. /// Mergeable4ByteCString - 4 byte mergable, null terminated, string.
  44. Mergeable4ByteCString,
  45. /// MergeableConst - These are sections for merging fixed-length
  46. /// constants together. For example, this can be used to unique
  47. /// constant pool entries etc.
  48. MergeableConst,
  49. /// MergeableConst4 - This is a section used by 4-byte constants,
  50. /// for example, floats.
  51. MergeableConst4,
  52. /// MergeableConst8 - This is a section used by 8-byte constants,
  53. /// for example, doubles.
  54. MergeableConst8,
  55. /// MergeableConst16 - This is a section used by 16-byte constants,
  56. /// for example, vectors.
  57. MergeableConst16,
  58. /// Writeable - This is the base of all segments that need to be written
  59. /// to during program runtime.
  60. /// ThreadLocal - This is the base of all TLS segments. All TLS
  61. /// objects must be writeable, otherwise there is no reason for them to
  62. /// be thread local!
  63. /// ThreadBSS - Zero-initialized TLS data objects.
  64. ThreadBSS,
  65. /// ThreadData - Initialized TLS data objects.
  66. ThreadData,
  67. /// GlobalWriteableData - Writeable data that is global (not thread
  68. /// local).
  69. /// BSS - Zero initialized writeable data.
  70. BSS,
  71. /// BSSLocal - This is BSS (zero initialized and writable) data
  72. /// which has local linkage.
  73. BSSLocal,
  74. /// BSSExtern - This is BSS data with normal external linkage.
  75. BSSExtern,
  76. /// Common - Data with common linkage. These represent tentative
  77. /// definitions, which always have a zero initializer and are never
  78. /// marked 'constant'.
  79. Common,
  80. /// DataRel - This is the most general form of data that is written
  81. /// to by the program, it can have random relocations to arbitrary
  82. /// globals.
  83. DataRel,
  84. /// DataRelLocal - This is writeable data that has a non-zero
  85. /// initializer and has relocations in it, but all of the
  86. /// relocations are known to be within the final linked image
  87. /// the global is linked into.
  88. DataRelLocal,
  89. /// DataNoRel - This is writeable data that has a non-zero
  90. /// initializer, but whose initializer is known to have no
  91. /// relocations.
  92. DataNoRel,
  93. /// ReadOnlyWithRel - These are global variables that are never
  94. /// written to by the program, but that have relocations, so they
  95. /// must be stuck in a writeable section so that the dynamic linker
  96. /// can write to them. If it chooses to, the dynamic linker can
  97. /// mark the pages these globals end up on as read-only after it is
  98. /// done with its relocation phase.
  99. ReadOnlyWithRel,
  100. /// ReadOnlyWithRelLocal - This is data that is readonly by the
  101. /// program, but must be writeable so that the dynamic linker
  102. /// can perform relocations in it. This is used when we know
  103. /// that all the relocations are to globals in this final
  104. /// linked image.
  105. ReadOnlyWithRelLocal
  106. } K : 8;
  107. public:
  108. bool isMetadata() const { return K == Metadata; }
  109. bool isText() const { return K == Text; }
  110. bool isReadOnly() const {
  111. return K == ReadOnly || isMergeableCString() ||
  112. isMergeableConst();
  113. }
  114. bool isMergeableCString() const {
  115. return K == Mergeable1ByteCString || K == Mergeable2ByteCString ||
  116. K == Mergeable4ByteCString;
  117. }
  118. bool isMergeable1ByteCString() const { return K == Mergeable1ByteCString; }
  119. bool isMergeable2ByteCString() const { return K == Mergeable2ByteCString; }
  120. bool isMergeable4ByteCString() const { return K == Mergeable4ByteCString; }
  121. bool isMergeableConst() const {
  122. return K == MergeableConst || K == MergeableConst4 ||
  123. K == MergeableConst8 || K == MergeableConst16;
  124. }
  125. bool isMergeableConst4() const { return K == MergeableConst4; }
  126. bool isMergeableConst8() const { return K == MergeableConst8; }
  127. bool isMergeableConst16() const { return K == MergeableConst16; }
  128. bool isWriteable() const {
  129. return isThreadLocal() || isGlobalWriteableData();
  130. }
  131. bool isThreadLocal() const {
  132. return K == ThreadData || K == ThreadBSS;
  133. }
  134. bool isThreadBSS() const { return K == ThreadBSS; }
  135. bool isThreadData() const { return K == ThreadData; }
  136. bool isGlobalWriteableData() const {
  137. return isBSS() || isCommon() || isDataRel() || isReadOnlyWithRel();
  138. }
  139. bool isBSS() const { return K == BSS || K == BSSLocal || K == BSSExtern; }
  140. bool isBSSLocal() const { return K == BSSLocal; }
  141. bool isBSSExtern() const { return K == BSSExtern; }
  142. bool isCommon() const { return K == Common; }
  143. bool isDataRel() const {
  144. return K == DataRel || K == DataRelLocal || K == DataNoRel;
  145. }
  146. bool isDataRelLocal() const {
  147. return K == DataRelLocal || K == DataNoRel;
  148. }
  149. bool isDataNoRel() const { return K == DataNoRel; }
  150. bool isReadOnlyWithRel() const {
  151. return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal;
  152. }
  153. bool isReadOnlyWithRelLocal() const {
  154. return K == ReadOnlyWithRelLocal;
  155. }
  156. private:
  157. static SectionKind get(Kind K) {
  158. SectionKind Res;
  159. Res.K = K;
  160. return Res;
  161. }
  162. public:
  163. static SectionKind getMetadata() { return get(Metadata); }
  164. static SectionKind getText() { return get(Text); }
  165. static SectionKind getReadOnly() { return get(ReadOnly); }
  166. static SectionKind getMergeable1ByteCString() {
  167. return get(Mergeable1ByteCString);
  168. }
  169. static SectionKind getMergeable2ByteCString() {
  170. return get(Mergeable2ByteCString);
  171. }
  172. static SectionKind getMergeable4ByteCString() {
  173. return get(Mergeable4ByteCString);
  174. }
  175. static SectionKind getMergeableConst() { return get(MergeableConst); }
  176. static SectionKind getMergeableConst4() { return get(MergeableConst4); }
  177. static SectionKind getMergeableConst8() { return get(MergeableConst8); }
  178. static SectionKind getMergeableConst16() { return get(MergeableConst16); }
  179. static SectionKind getThreadBSS() { return get(ThreadBSS); }
  180. static SectionKind getThreadData() { return get(ThreadData); }
  181. static SectionKind getBSS() { return get(BSS); }
  182. static SectionKind getBSSLocal() { return get(BSSLocal); }
  183. static SectionKind getBSSExtern() { return get(BSSExtern); }
  184. static SectionKind getCommon() { return get(Common); }
  185. static SectionKind getDataRel() { return get(DataRel); }
  186. static SectionKind getDataRelLocal() { return get(DataRelLocal); }
  187. static SectionKind getDataNoRel() { return get(DataNoRel); }
  188. static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); }
  189. static SectionKind getReadOnlyWithRelLocal(){
  190. return get(ReadOnlyWithRelLocal);
  191. }
  192. };
  193. } // end namespace llvm
  194. #endif