File indexing completed on 2026-05-10 08:44:16
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_MC_SECTIONKIND_H
0010 #define LLVM_MC_SECTIONKIND_H
0011
0012 namespace llvm {
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 class SectionKind {
0023 enum Kind {
0024
0025 Metadata,
0026
0027
0028
0029 Exclude,
0030
0031
0032 Text,
0033
0034
0035 ExecuteOnly,
0036
0037
0038
0039
0040 ReadOnly,
0041
0042
0043
0044
0045
0046
0047
0048 Mergeable1ByteCString,
0049
0050
0051 Mergeable2ByteCString,
0052
0053
0054 Mergeable4ByteCString,
0055
0056
0057
0058
0059
0060
0061
0062 MergeableConst4,
0063
0064
0065
0066 MergeableConst8,
0067
0068
0069
0070 MergeableConst16,
0071
0072
0073
0074 MergeableConst32,
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 ThreadBSS,
0085
0086
0087 ThreadData,
0088
0089
0090 ThreadBSSLocal,
0091
0092
0093
0094
0095
0096 BSS,
0097
0098
0099
0100 BSSLocal,
0101
0102
0103 BSSExtern,
0104
0105
0106
0107
0108 Common,
0109
0110
0111 Data,
0112
0113
0114
0115
0116
0117
0118
0119 ReadOnlyWithRel
0120 } K : 8;
0121 public:
0122
0123 bool isMetadata() const { return K == Metadata; }
0124
0125 bool isExclude() const { return K == Exclude; }
0126
0127 bool isText() const { return K == Text || K == ExecuteOnly; }
0128
0129 bool isExecuteOnly() const { return K == ExecuteOnly; }
0130
0131 bool isReadOnly() const {
0132 return K == ReadOnly || isMergeableCString() ||
0133 isMergeableConst();
0134 }
0135
0136 bool isMergeableCString() const {
0137 return K == Mergeable1ByteCString || K == Mergeable2ByteCString ||
0138 K == Mergeable4ByteCString;
0139 }
0140 bool isMergeable1ByteCString() const { return K == Mergeable1ByteCString; }
0141 bool isMergeable2ByteCString() const { return K == Mergeable2ByteCString; }
0142 bool isMergeable4ByteCString() const { return K == Mergeable4ByteCString; }
0143
0144 bool isMergeableConst() const {
0145 return K == MergeableConst4 || K == MergeableConst8 ||
0146 K == MergeableConst16 || K == MergeableConst32;
0147 }
0148 bool isMergeableConst4() const { return K == MergeableConst4; }
0149 bool isMergeableConst8() const { return K == MergeableConst8; }
0150 bool isMergeableConst16() const { return K == MergeableConst16; }
0151 bool isMergeableConst32() const { return K == MergeableConst32; }
0152
0153 bool isWriteable() const {
0154 return isThreadLocal() || isGlobalWriteableData();
0155 }
0156
0157 bool isThreadLocal() const {
0158 return K == ThreadData || K == ThreadBSS || K == ThreadBSSLocal;
0159 }
0160
0161 bool isThreadBSS() const { return K == ThreadBSS || K == ThreadBSSLocal; }
0162 bool isThreadData() const { return K == ThreadData; }
0163 bool isThreadBSSLocal() const { return K == ThreadBSSLocal; }
0164
0165 bool isGlobalWriteableData() const {
0166 return isBSS() || isCommon() || isData() || isReadOnlyWithRel();
0167 }
0168
0169 bool isBSS() const { return K == BSS || K == BSSLocal || K == BSSExtern; }
0170 bool isBSSLocal() const { return K == BSSLocal; }
0171 bool isBSSExtern() const { return K == BSSExtern; }
0172
0173 bool isCommon() const { return K == Common; }
0174
0175 bool isData() const { return K == Data; }
0176
0177 bool isReadOnlyWithRel() const {
0178 return K == ReadOnlyWithRel;
0179 }
0180 private:
0181 static SectionKind get(Kind K) {
0182 SectionKind Res;
0183 Res.K = K;
0184 return Res;
0185 }
0186 public:
0187
0188 static SectionKind getMetadata() { return get(Metadata); }
0189 static SectionKind getExclude() { return get(Exclude); }
0190 static SectionKind getText() { return get(Text); }
0191 static SectionKind getExecuteOnly() { return get(ExecuteOnly); }
0192 static SectionKind getReadOnly() { return get(ReadOnly); }
0193 static SectionKind getMergeable1ByteCString() {
0194 return get(Mergeable1ByteCString);
0195 }
0196 static SectionKind getMergeable2ByteCString() {
0197 return get(Mergeable2ByteCString);
0198 }
0199 static SectionKind getMergeable4ByteCString() {
0200 return get(Mergeable4ByteCString);
0201 }
0202 static SectionKind getMergeableConst4() { return get(MergeableConst4); }
0203 static SectionKind getMergeableConst8() { return get(MergeableConst8); }
0204 static SectionKind getMergeableConst16() { return get(MergeableConst16); }
0205 static SectionKind getMergeableConst32() { return get(MergeableConst32); }
0206 static SectionKind getThreadBSS() { return get(ThreadBSS); }
0207 static SectionKind getThreadData() { return get(ThreadData); }
0208 static SectionKind getThreadBSSLocal() { return get(ThreadBSSLocal); }
0209 static SectionKind getBSS() { return get(BSS); }
0210 static SectionKind getBSSLocal() { return get(BSSLocal); }
0211 static SectionKind getBSSExtern() { return get(BSSExtern); }
0212 static SectionKind getCommon() { return get(Common); }
0213 static SectionKind getData() { return get(Data); }
0214 static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); }
0215 };
0216
0217 }
0218
0219 #endif