@@ -42,11 +42,11 @@ class raw_ostream;
42
42
class MCSymbol {
43
43
protected:
44
44
// 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
50
50
};
51
51
52
52
// Special sentinel value for the absolute pseudo fragment.
@@ -65,9 +65,9 @@ class MCSymbol {
65
65
// / relative to, if any.
66
66
mutable MCFragment *Fragment = nullptr ;
67
67
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 ;
71
71
72
72
// / True if this symbol is named. A named symbol will have a pointer to the
73
73
// / name allocated in the bytes immediately prior to the MCSymbol.
@@ -145,10 +145,10 @@ class MCSymbol {
145
145
};
146
146
147
147
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 ) {
152
152
Offset = 0 ;
153
153
HasName = !!Name;
154
154
if (Name)
@@ -212,9 +212,9 @@ class MCSymbol {
212
212
// / Prepare this symbol to be redefined.
213
213
void redefineIfPossible () {
214
214
if (IsRedefinable) {
215
- if (SymbolContents == SymContentsVariable ) {
215
+ if (kind == Kind::Equated ) {
216
216
Value = nullptr ;
217
- SymbolContents = SymContentsUnset ;
217
+ kind = Kind::Regular ;
218
218
}
219
219
setUndefined ();
220
220
IsRedefinable = false ;
@@ -268,9 +268,7 @@ class MCSymbol {
268
268
// / @{
269
269
270
270
// / isVariable - Check if this is a variable symbol.
271
- bool isVariable () const {
272
- return SymbolContents == SymContentsVariable;
273
- }
271
+ bool isVariable () const { return kind == Equated; }
274
272
275
273
// / Get the expression of the variable symbol.
276
274
const MCExpr *getVariableValue () const {
@@ -293,12 +291,12 @@ class MCSymbol {
293
291
}
294
292
295
293
uint64_t getOffset () const {
296
- assert (SymbolContents == SymContentsUnset &&
294
+ assert (kind == Kind::Regular &&
297
295
" Cannot get offset for a common/variable symbol" );
298
296
return Offset;
299
297
}
300
298
void setOffset (uint64_t Value) {
301
- assert (SymbolContents == SymContentsUnset &&
299
+ assert (kind == Kind::Regular &&
302
300
" Cannot set offset for a common/variable symbol" );
303
301
Offset = Value;
304
302
}
@@ -317,7 +315,7 @@ class MCSymbol {
317
315
void setCommon (uint64_t Size, Align Alignment, bool Target = false ) {
318
316
assert (getOffset () == 0 );
319
317
CommonSize = Size;
320
- SymbolContents = Target ? SymContentsTargetCommon : SymContentsCommon ;
318
+ kind = Target ? Kind::TargetCommon : Kind::Common ;
321
319
322
320
unsigned Log2Align = encode (Alignment);
323
321
assert (Log2Align < (1U << NumCommonAlignmentBits) &&
@@ -350,14 +348,12 @@ class MCSymbol {
350
348
351
349
// / Is this a 'common' symbol.
352
350
bool isCommon () const {
353
- return SymbolContents == SymContentsCommon ||
354
- SymbolContents == SymContentsTargetCommon;
351
+ return kind == Kind::Common || kind == Kind::TargetCommon;
355
352
}
356
353
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; }
361
357
362
358
MCFragment *getFragment () const {
363
359
if (Fragment || !isVariable () || isWeakExternal ())
0 commit comments