@@ -42,11 +42,10 @@ class raw_ostream;
4242class MCSymbol {
4343protected:
4444 // A symbol can be regular, equated to an expression, or a common symbol.
45- enum Contents : uint8_t {
46- SymContentsUnset,
47- SymContentsVariable,
48- SymContentsCommon,
49- SymContentsTargetCommon, // Index stores the section index
45+ enum Kind : uint8_t {
46+ Regular,
47+ Equated,
48+ Common,
5049 };
5150
5251 // Special sentinel value for the absolute pseudo fragment.
@@ -65,9 +64,9 @@ class MCSymbol {
6564 /// relative to, if any.
6665 mutable MCFragment *Fragment = nullptr;
6766
68- /// This is actually a Contents enumerator, but is unsigned to avoid sign
69- /// extension and achieve better bitpacking with MSVC.
70- unsigned SymbolContents : 2;
67+ /// The symbol kind. Use an unsigned bitfield to achieve better bitpacking
68+ /// with MSVC.
69+ unsigned kind : 2;
7170
7271 /// True if this symbol is named. A named symbol will have a pointer to the
7372 /// name allocated in the bytes immediately prior to the MCSymbol.
@@ -145,10 +144,10 @@ class MCSymbol {
145144 };
146145
147146 MCSymbol(const MCSymbolTableEntry *Name, bool isTemporary)
148- : SymbolContents(SymContentsUnset ), IsTemporary(isTemporary),
149- IsRedefinable (false), IsRegistered (false), IsExternal (false),
150- IsPrivateExtern (false), IsWeakExternal (false), IsUsedInReloc(false ),
151- IsResolving(0), CommonAlignLog2(0), Flags(0) {
147+ : kind(Kind::Regular ), IsTemporary(isTemporary), IsRedefinable(false ),
148+ IsRegistered (false), IsExternal (false), IsPrivateExtern (false),
149+ IsWeakExternal (false), IsUsedInReloc (false), IsResolving(0 ),
150+ CommonAlignLog2(0), Flags(0) {
152151 Offset = 0;
153152 HasName = !!Name;
154153 if (Name)
@@ -212,9 +211,9 @@ class MCSymbol {
212211 /// Prepare this symbol to be redefined.
213212 void redefineIfPossible() {
214213 if (IsRedefinable) {
215- if (SymbolContents == SymContentsVariable ) {
214+ if (kind == Kind::Equated ) {
216215 Value = nullptr;
217- SymbolContents = SymContentsUnset ;
216+ kind = Kind::Regular ;
218217 }
219218 setUndefined();
220219 IsRedefinable = false;
@@ -268,9 +267,7 @@ class MCSymbol {
268267 /// @{
269268
270269 /// isVariable - Check if this is a variable symbol.
271- bool isVariable() const {
272- return SymbolContents == SymContentsVariable;
273- }
270+ bool isVariable() const { return kind == Equated; }
274271
275272 /// Get the expression of the variable symbol.
276273 const MCExpr *getVariableValue() const {
@@ -293,12 +290,12 @@ class MCSymbol {
293290 }
294291
295292 uint64_t getOffset() const {
296- assert(SymbolContents == SymContentsUnset &&
293+ assert(kind == Kind::Regular &&
297294 "Cannot get offset for a common/variable symbol");
298295 return Offset;
299296 }
300297 void setOffset(uint64_t Value) {
301- assert(SymbolContents == SymContentsUnset &&
298+ assert(kind == Kind::Regular &&
302299 "Cannot set offset for a common/variable symbol");
303300 Offset = Value;
304301 }
@@ -314,10 +311,10 @@ class MCSymbol {
314311 /// \param Size - The size of the symbol.
315312 /// \param Alignment - The alignment of the symbol.
316313 /// \param Target - Is the symbol a target-specific common-like symbol.
317- void setCommon(uint64_t Size, Align Alignment, bool Target = false ) {
314+ void setCommon(uint64_t Size, Align Alignment) {
318315 assert(getOffset() == 0);
319316 CommonSize = Size;
320- SymbolContents = Target ? SymContentsTargetCommon : SymContentsCommon ;
317+ kind = Kind::Common ;
321318
322319 unsigned Log2Align = encode(Alignment);
323320 assert(Log2Align < (1U << NumCommonAlignmentBits) &&
@@ -335,29 +332,19 @@ class MCSymbol {
335332 ///
336333 /// \param Size - The size of the symbol.
337334 /// \param Alignment - The alignment of the symbol.
338- /// \param Target - Is the symbol a target-specific common-like symbol.
339335 /// \return True if symbol was already declared as a different type
340- bool declareCommon(uint64_t Size, Align Alignment, bool Target = false ) {
336+ bool declareCommon(uint64_t Size, Align Alignment) {
341337 assert(isCommon() || getOffset() == 0);
342338 if(isCommon()) {
343- if (CommonSize != Size || getCommonAlignment() != Alignment ||
344- isTargetCommon() != Target)
339+ if (CommonSize != Size || getCommonAlignment() != Alignment)
345340 return true;
346341 } else
347- setCommon(Size, Alignment, Target );
342+ setCommon(Size, Alignment);
348343 return false;
349344 }
350345
351346 /// Is this a 'common' symbol.
352- bool isCommon() const {
353- return SymbolContents == SymContentsCommon ||
354- SymbolContents == SymContentsTargetCommon;
355- }
356-
357- /// Is this a target-specific common-like symbol.
358- bool isTargetCommon() const {
359- return SymbolContents == SymContentsTargetCommon;
360- }
347+ bool isCommon() const { return kind == Kind::Common; }
361348
362349 MCFragment *getFragment() const {
363350 if (Fragment || !isVariable() || isWeakExternal())
0 commit comments