@@ -42,11 +42,11 @@ 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 ,
49+ TargetCommon , // Index stores the section index
5050 };
5151
5252 // Special sentinel value for the absolute pseudo fragment.
@@ -65,9 +65,9 @@ class MCSymbol {
6565 // / relative to, if any.
6666 mutable MCFragment *Fragment = nullptr ;
6767
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 ;
68+ // / The symbol kind. Use an unsigned bitfield to achieve better bitpacking
69+ // / with MSVC.
70+ unsigned kind : 2 ;
7171
7272 // / True if this symbol is named. A named symbol will have a pointer to the
7373 // / name allocated in the bytes immediately prior to the MCSymbol.
@@ -145,10 +145,10 @@ class MCSymbol {
145145 };
146146
147147 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 ) {
148+ : kind(Kind::Regular ), IsTemporary(isTemporary), IsRedefinable( false ),
149+ IsRegistered (false ), IsExternal (false ), IsPrivateExtern (false ),
150+ IsWeakExternal (false ), IsUsedInReloc (false ), IsResolving( 0 ),
151+ CommonAlignLog2(0 ), Flags(0 ) {
152152 Offset = 0 ;
153153 HasName = !!Name;
154154 if (Name)
@@ -212,9 +212,9 @@ class MCSymbol {
212212 // / Prepare this symbol to be redefined.
213213 void redefineIfPossible () {
214214 if (IsRedefinable) {
215- if (SymbolContents == SymContentsVariable ) {
215+ if (kind == Kind::Equated ) {
216216 Value = nullptr ;
217- SymbolContents = SymContentsUnset ;
217+ kind = Kind::Regular ;
218218 }
219219 setUndefined ();
220220 IsRedefinable = false ;
@@ -268,9 +268,7 @@ class MCSymbol {
268268 // / @{
269269
270270 // / isVariable - Check if this is a variable symbol.
271- bool isVariable () const {
272- return SymbolContents == SymContentsVariable;
273- }
271+ bool isVariable () const { return kind == Equated; }
274272
275273 // / Get the expression of the variable symbol.
276274 const MCExpr *getVariableValue () const {
@@ -293,12 +291,12 @@ class MCSymbol {
293291 }
294292
295293 uint64_t getOffset () const {
296- assert (SymbolContents == SymContentsUnset &&
294+ assert (kind == Kind::Regular &&
297295 " Cannot get offset for a common/variable symbol" );
298296 return Offset;
299297 }
300298 void setOffset (uint64_t Value) {
301- assert (SymbolContents == SymContentsUnset &&
299+ assert (kind == Kind::Regular &&
302300 " Cannot set offset for a common/variable symbol" );
303301 Offset = Value;
304302 }
@@ -317,7 +315,7 @@ class MCSymbol {
317315 void setCommon (uint64_t Size, Align Alignment, bool Target = false ) {
318316 assert (getOffset () == 0 );
319317 CommonSize = Size;
320- SymbolContents = Target ? SymContentsTargetCommon : SymContentsCommon ;
318+ kind = Target ? Kind::TargetCommon : Kind::Common ;
321319
322320 unsigned Log2Align = encode (Alignment);
323321 assert (Log2Align < (1U << NumCommonAlignmentBits) &&
@@ -350,14 +348,12 @@ class MCSymbol {
350348
351349 // / Is this a 'common' symbol.
352350 bool isCommon () const {
353- return SymbolContents == SymContentsCommon ||
354- SymbolContents == SymContentsTargetCommon;
351+ return kind == Kind::Common || kind == Kind::TargetCommon;
355352 }
356353
357- // / Is this a target-specific common-like symbol.
358- bool isTargetCommon () const {
359- return SymbolContents == SymContentsTargetCommon;
360- }
354+ // / Used by AMDGPU to indicate a common-like symbol of section index
355+ // / SHN_AMDGPU_LDS.
356+ bool isTargetCommon () const { return kind == Kind::TargetCommon; }
361357
362358 MCFragment *getFragment () const {
363359 if (Fragment || !isVariable () || isWeakExternal ())
0 commit comments