SectionKind.h (208954) | SectionKind.h (210299) |
---|---|
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//===----------------------------------------------------------------------===// --- 15 unchanged lines hidden (view full) --- 24/// 25/// The comments below describe these as if they were an inheritance hierarchy 26/// in order to explain the predicates below. 27/// 28class SectionKind { 29 enum Kind { 30 /// Metadata - Debug info sections or other metadata. 31 Metadata, | 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//===----------------------------------------------------------------------===// --- 15 unchanged lines hidden (view full) --- 24/// 25/// The comments below describe these as if they were an inheritance hierarchy 26/// in order to explain the predicates below. 27/// 28class SectionKind { 29 enum Kind { 30 /// Metadata - Debug info sections or other metadata. 31 Metadata, |
32 | 32 |
33 /// Text - Text section, used for functions and other executable code. 34 Text, | 33 /// Text - Text section, used for functions and other executable code. 34 Text, |
35 | 35 |
36 /// ReadOnly - Data that is never written to at program runtime by the 37 /// program or the dynamic linker. Things in the top-level readonly 38 /// SectionKind are not mergeable. 39 ReadOnly, 40 41 /// MergableCString - Any null-terminated string which allows merging. 42 /// These values are known to end in a nul value of the specified size, 43 /// not otherwise contain a nul value, and be mergable. This allows the 44 /// linker to unique the strings if it so desires. 45 46 /// Mergeable1ByteCString - 1 byte mergable, null terminated, string. 47 Mergeable1ByteCString, | 36 /// ReadOnly - Data that is never written to at program runtime by the 37 /// program or the dynamic linker. Things in the top-level readonly 38 /// SectionKind are not mergeable. 39 ReadOnly, 40 41 /// MergableCString - Any null-terminated string which allows merging. 42 /// These values are known to end in a nul value of the specified size, 43 /// not otherwise contain a nul value, and be mergable. This allows the 44 /// linker to unique the strings if it so desires. 45 46 /// Mergeable1ByteCString - 1 byte mergable, null terminated, string. 47 Mergeable1ByteCString, |
48 | 48 |
49 /// Mergeable2ByteCString - 2 byte mergable, null terminated, string. 50 Mergeable2ByteCString, 51 52 /// Mergeable4ByteCString - 4 byte mergable, null terminated, string. 53 Mergeable4ByteCString, 54 55 /// MergeableConst - These are sections for merging fixed-length 56 /// constants together. For example, this can be used to unique 57 /// constant pool entries etc. 58 MergeableConst, | 49 /// Mergeable2ByteCString - 2 byte mergable, null terminated, string. 50 Mergeable2ByteCString, 51 52 /// Mergeable4ByteCString - 4 byte mergable, null terminated, string. 53 Mergeable4ByteCString, 54 55 /// MergeableConst - These are sections for merging fixed-length 56 /// constants together. For example, this can be used to unique 57 /// constant pool entries etc. 58 MergeableConst, |
59 | 59 |
60 /// MergeableConst4 - This is a section used by 4-byte constants, 61 /// for example, floats. 62 MergeableConst4, | 60 /// MergeableConst4 - This is a section used by 4-byte constants, 61 /// for example, floats. 62 MergeableConst4, |
63 | 63 |
64 /// MergeableConst8 - This is a section used by 8-byte constants, 65 /// for example, doubles. 66 MergeableConst8, 67 68 /// MergeableConst16 - This is a section used by 16-byte constants, 69 /// for example, vectors. 70 MergeableConst16, | 64 /// MergeableConst8 - This is a section used by 8-byte constants, 65 /// for example, doubles. 66 MergeableConst8, 67 68 /// MergeableConst16 - This is a section used by 16-byte constants, 69 /// for example, vectors. 70 MergeableConst16, |
71 | 71 |
72 /// Writeable - This is the base of all segments that need to be written 73 /// to during program runtime. | 72 /// Writeable - This is the base of all segments that need to be written 73 /// to during program runtime. |
74 | 74 |
75 /// ThreadLocal - This is the base of all TLS segments. All TLS 76 /// objects must be writeable, otherwise there is no reason for them to 77 /// be thread local! | 75 /// ThreadLocal - This is the base of all TLS segments. All TLS 76 /// objects must be writeable, otherwise there is no reason for them to 77 /// be thread local! |
78 | 78 |
79 /// ThreadBSS - Zero-initialized TLS data objects. 80 ThreadBSS, | 79 /// ThreadBSS - Zero-initialized TLS data objects. 80 ThreadBSS, |
81 | 81 |
82 /// ThreadData - Initialized TLS data objects. 83 ThreadData, | 82 /// ThreadData - Initialized TLS data objects. 83 ThreadData, |
84 | 84 |
85 /// GlobalWriteableData - Writeable data that is global (not thread 86 /// local). | 85 /// GlobalWriteableData - Writeable data that is global (not thread 86 /// local). |
87 | 87 |
88 /// BSS - Zero initialized writeable data. 89 BSS, | 88 /// BSS - Zero initialized writeable data. 89 BSS, |
90 | 90 |
91 /// BSSLocal - This is BSS (zero initialized and writable) data 92 /// which has local linkage. 93 BSSLocal, | 91 /// BSSLocal - This is BSS (zero initialized and writable) data 92 /// which has local linkage. 93 BSSLocal, |
94 | 94 |
95 /// BSSExtern - This is BSS data with normal external linkage. 96 BSSExtern, | 95 /// BSSExtern - This is BSS data with normal external linkage. 96 BSSExtern, |
97 | 97 |
98 /// Common - Data with common linkage. These represent tentative 99 /// definitions, which always have a zero initializer and are never 100 /// marked 'constant'. 101 Common, 102 103 /// DataRel - This is the most general form of data that is written 104 /// to by the program, it can have random relocations to arbitrary 105 /// globals. --- 12 unchanged lines hidden (view full) --- 118 119 /// ReadOnlyWithRel - These are global variables that are never 120 /// written to by the program, but that have relocations, so they 121 /// must be stuck in a writeable section so that the dynamic linker 122 /// can write to them. If it chooses to, the dynamic linker can 123 /// mark the pages these globals end up on as read-only after it is 124 /// done with its relocation phase. 125 ReadOnlyWithRel, | 98 /// Common - Data with common linkage. These represent tentative 99 /// definitions, which always have a zero initializer and are never 100 /// marked 'constant'. 101 Common, 102 103 /// DataRel - This is the most general form of data that is written 104 /// to by the program, it can have random relocations to arbitrary 105 /// globals. --- 12 unchanged lines hidden (view full) --- 118 119 /// ReadOnlyWithRel - These are global variables that are never 120 /// written to by the program, but that have relocations, so they 121 /// must be stuck in a writeable section so that the dynamic linker 122 /// can write to them. If it chooses to, the dynamic linker can 123 /// mark the pages these globals end up on as read-only after it is 124 /// done with its relocation phase. 125 ReadOnlyWithRel, |
126 | 126 |
127 /// ReadOnlyWithRelLocal - This is data that is readonly by the 128 /// program, but must be writeable so that the dynamic linker 129 /// can perform relocations in it. This is used when we know 130 /// that all the relocations are to globals in this final 131 /// linked image. 132 ReadOnlyWithRelLocal | 127 /// ReadOnlyWithRelLocal - This is data that is readonly by the 128 /// program, but must be writeable so that the dynamic linker 129 /// can perform relocations in it. This is used when we know 130 /// that all the relocations are to globals in this final 131 /// linked image. 132 ReadOnlyWithRelLocal |
133 | 133 |
134 } K : 8; 135public: | 134 } K : 8; 135public: |
136 | 136 |
137 bool isMetadata() const { return K == Metadata; } 138 bool isText() const { return K == Text; } | 137 bool isMetadata() const { return K == Metadata; } 138 bool isText() const { return K == Text; } |
139 | 139 |
140 bool isReadOnly() const { 141 return K == ReadOnly || isMergeableCString() || 142 isMergeableConst(); 143 } 144 145 bool isMergeableCString() const { 146 return K == Mergeable1ByteCString || K == Mergeable2ByteCString || 147 K == Mergeable4ByteCString; 148 } 149 bool isMergeable1ByteCString() const { return K == Mergeable1ByteCString; } 150 bool isMergeable2ByteCString() const { return K == Mergeable2ByteCString; } 151 bool isMergeable4ByteCString() const { return K == Mergeable4ByteCString; } | 140 bool isReadOnly() const { 141 return K == ReadOnly || isMergeableCString() || 142 isMergeableConst(); 143 } 144 145 bool isMergeableCString() const { 146 return K == Mergeable1ByteCString || K == Mergeable2ByteCString || 147 K == Mergeable4ByteCString; 148 } 149 bool isMergeable1ByteCString() const { return K == Mergeable1ByteCString; } 150 bool isMergeable2ByteCString() const { return K == Mergeable2ByteCString; } 151 bool isMergeable4ByteCString() const { return K == Mergeable4ByteCString; } |
152 | 152 |
153 bool isMergeableConst() const { 154 return K == MergeableConst || K == MergeableConst4 || 155 K == MergeableConst8 || K == MergeableConst16; 156 } 157 bool isMergeableConst4() const { return K == MergeableConst4; } 158 bool isMergeableConst8() const { return K == MergeableConst8; } 159 bool isMergeableConst16() const { return K == MergeableConst16; } | 153 bool isMergeableConst() const { 154 return K == MergeableConst || K == MergeableConst4 || 155 K == MergeableConst8 || K == MergeableConst16; 156 } 157 bool isMergeableConst4() const { return K == MergeableConst4; } 158 bool isMergeableConst8() const { return K == MergeableConst8; } 159 bool isMergeableConst16() const { return K == MergeableConst16; } |
160 | 160 |
161 bool isWriteable() const { 162 return isThreadLocal() || isGlobalWriteableData(); 163 } | 161 bool isWriteable() const { 162 return isThreadLocal() || isGlobalWriteableData(); 163 } |
164 | 164 |
165 bool isThreadLocal() const { 166 return K == ThreadData || K == ThreadBSS; 167 } | 165 bool isThreadLocal() const { 166 return K == ThreadData || K == ThreadBSS; 167 } |
168 169 bool isThreadBSS() const { return K == ThreadBSS; } 170 bool isThreadData() const { return K == ThreadData; } | |
171 | 168 |
169 bool isThreadBSS() const { return K == ThreadBSS; } 170 bool isThreadData() const { return K == ThreadData; } 171 |
|
172 bool isGlobalWriteableData() const { 173 return isBSS() || isCommon() || isDataRel() || isReadOnlyWithRel(); 174 } | 172 bool isGlobalWriteableData() const { 173 return isBSS() || isCommon() || isDataRel() || isReadOnlyWithRel(); 174 } |
175 | 175 |
176 bool isBSS() const { return K == BSS || K == BSSLocal || K == BSSExtern; } 177 bool isBSSLocal() const { return K == BSSLocal; } 178 bool isBSSExtern() const { return K == BSSExtern; } | 176 bool isBSS() const { return K == BSS || K == BSSLocal || K == BSSExtern; } 177 bool isBSSLocal() const { return K == BSSLocal; } 178 bool isBSSExtern() const { return K == BSSExtern; } |
179 | 179 |
180 bool isCommon() const { return K == Common; } | 180 bool isCommon() const { return K == Common; } |
181 | 181 |
182 bool isDataRel() const { 183 return K == DataRel || K == DataRelLocal || K == DataNoRel; 184 } | 182 bool isDataRel() const { 183 return K == DataRel || K == DataRelLocal || K == DataNoRel; 184 } |
185 | 185 |
186 bool isDataRelLocal() const { 187 return K == DataRelLocal || K == DataNoRel; 188 } 189 190 bool isDataNoRel() const { return K == DataNoRel; } | 186 bool isDataRelLocal() const { 187 return K == DataRelLocal || K == DataNoRel; 188 } 189 190 bool isDataNoRel() const { return K == DataNoRel; } |
191 | 191 |
192 bool isReadOnlyWithRel() const { 193 return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal; 194 } 195 196 bool isReadOnlyWithRelLocal() const { 197 return K == ReadOnlyWithRelLocal; 198 } | 192 bool isReadOnlyWithRel() const { 193 return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal; 194 } 195 196 bool isReadOnlyWithRelLocal() const { 197 return K == ReadOnlyWithRelLocal; 198 } |
199private: | 199private: |
200 static SectionKind get(Kind K) { 201 SectionKind Res; 202 Res.K = K; 203 return Res; 204 } 205public: | 200 static SectionKind get(Kind K) { 201 SectionKind Res; 202 Res.K = K; 203 return Res; 204 } 205public: |
206 | 206 |
207 static SectionKind getMetadata() { return get(Metadata); } 208 static SectionKind getText() { return get(Text); } 209 static SectionKind getReadOnly() { return get(ReadOnly); } 210 static SectionKind getMergeable1ByteCString() { 211 return get(Mergeable1ByteCString); 212 } 213 static SectionKind getMergeable2ByteCString() { 214 return get(Mergeable2ByteCString); --- 14 unchanged lines hidden (view full) --- 229 static SectionKind getDataRel() { return get(DataRel); } 230 static SectionKind getDataRelLocal() { return get(DataRelLocal); } 231 static SectionKind getDataNoRel() { return get(DataNoRel); } 232 static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); } 233 static SectionKind getReadOnlyWithRelLocal(){ 234 return get(ReadOnlyWithRelLocal); 235 } 236}; | 207 static SectionKind getMetadata() { return get(Metadata); } 208 static SectionKind getText() { return get(Text); } 209 static SectionKind getReadOnly() { return get(ReadOnly); } 210 static SectionKind getMergeable1ByteCString() { 211 return get(Mergeable1ByteCString); 212 } 213 static SectionKind getMergeable2ByteCString() { 214 return get(Mergeable2ByteCString); --- 14 unchanged lines hidden (view full) --- 229 static SectionKind getDataRel() { return get(DataRel); } 230 static SectionKind getDataRelLocal() { return get(DataRelLocal); } 231 static SectionKind getDataNoRel() { return get(DataNoRel); } 232 static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); } 233 static SectionKind getReadOnlyWithRelLocal(){ 234 return get(ReadOnlyWithRelLocal); 235 } 236}; |
237 | 237 |
238} // end namespace llvm 239 240#endif | 238} // end namespace llvm 239 240#endif |