Skip to content

Commit d1ee636

Browse files
committed
MCSymbol: Remove Kind
The object file format specific derived classes are used in context where the type is statically known. We don't use isa/dyn_cast and we want to discourage dynamic dispatching on the type.
1 parent 5b528a1 commit d1ee636

File tree

8 files changed

+11
-29
lines changed

8 files changed

+11
-29
lines changed

llvm/include/llvm/MC/MCSymbol.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ class raw_ostream;
4141
/// it is a reference to an external entity, it has a null section.
4242
class MCSymbol {
4343
protected:
44-
/// The kind of the symbol. If it is any value other than unset then this
45-
/// class is actually one of the appropriate subclasses of MCSymbol.
46-
enum SymbolKind {
47-
SymbolKindUnset,
48-
SymbolKindCOFF,
49-
SymbolKindELF,
50-
SymbolKindGOFF,
51-
SymbolKindMachO,
52-
SymbolKindWasm,
53-
SymbolKindXCOFF,
54-
};
55-
5644
/// A symbol can contain an Offset, or Value, or be Common, but never more
5745
/// than one of these.
5846
enum Contents : uint8_t {
@@ -103,10 +91,6 @@ class MCSymbol {
10391
/// This symbol is weak external.
10492
mutable unsigned IsWeakExternal : 1;
10593

106-
/// LLVM RTTI discriminator. This is actually a SymbolKind enumerator, but is
107-
/// unsigned to avoid sign extension and achieve better bitpacking with MSVC.
108-
unsigned Kind : 3;
109-
11094
/// True if we have created a relocation that uses this symbol.
11195
mutable unsigned IsUsedInReloc : 1;
11296

@@ -162,11 +146,11 @@ class MCSymbol {
162146
uint64_t AlignmentPadding;
163147
};
164148

165-
MCSymbol(SymbolKind Kind, const MCSymbolTableEntry *Name, bool isTemporary)
149+
MCSymbol(const MCSymbolTableEntry *Name, bool isTemporary)
166150
: IsTemporary(isTemporary), IsRedefinable(false), IsRegistered(false),
167151
IsExternal(false), IsPrivateExtern(false), IsWeakExternal(false),
168-
Kind(Kind), IsUsedInReloc(false), IsResolving(0),
169-
SymbolContents(SymContentsUnset), CommonAlignLog2(0), Flags(0) {
152+
IsUsedInReloc(false), IsResolving(0), SymbolContents(SymContentsUnset),
153+
CommonAlignLog2(0), Flags(0) {
170154
Offset = 0;
171155
HasName = !!Name;
172156
if (Name)

llvm/include/llvm/MC/MCSymbolCOFF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class MCSymbolCOFF : public MCSymbol {
3131

3232
public:
3333
MCSymbolCOFF(const MCSymbolTableEntry *Name, bool isTemporary)
34-
: MCSymbol(SymbolKindCOFF, Name, isTemporary) {}
34+
: MCSymbol(Name, isTemporary) {}
3535

3636
uint16_t getType() const {
3737
return Type;

llvm/include/llvm/MC/MCSymbolELF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class MCSymbolELF : public MCSymbol {
2020

2121
public:
2222
MCSymbolELF(const MCSymbolTableEntry *Name, bool isTemporary)
23-
: MCSymbol(SymbolKindELF, Name, isTemporary) {}
23+
: MCSymbol(Name, isTemporary) {}
2424
void setSize(const MCExpr *SS) { SymbolSize = SS; }
2525

2626
const MCExpr *getSize() const { return SymbolSize; }

llvm/include/llvm/MC/MCSymbolGOFF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MCSymbolGOFF : public MCSymbol {
3333

3434
public:
3535
MCSymbolGOFF(const MCSymbolTableEntry *Name, bool IsTemporary)
36-
: MCSymbol(SymbolKindGOFF, Name, IsTemporary) {}
36+
: MCSymbol(Name, IsTemporary) {}
3737

3838
void setLDAttributes(GOFF::LDAttr Attr) {
3939
modifyFlags(SF_LD, SF_LD);

llvm/include/llvm/MC/MCSymbolMachO.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class MCSymbolMachO : public MCSymbol {
4444

4545
public:
4646
MCSymbolMachO(const MCSymbolTableEntry *Name, bool isTemporary)
47-
: MCSymbol(SymbolKindMachO, Name, isTemporary) {}
47+
: MCSymbol(Name, isTemporary) {}
4848

4949
bool isPrivateExtern() const { return IsPrivateExtern; }
5050
void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }

llvm/include/llvm/MC/MCSymbolWasm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MCSymbolWasm : public MCSymbol {
3535

3636
public:
3737
MCSymbolWasm(const MCSymbolTableEntry *Name, bool isTemporary)
38-
: MCSymbol(SymbolKindWasm, Name, isTemporary) {}
38+
: MCSymbol(Name, isTemporary) {}
3939

4040
const MCExpr *getSize() const { return SymbolSize; }
4141
void setSize(const MCExpr *SS) { SymbolSize = SS; }

llvm/include/llvm/MC/MCSymbolXCOFF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MCSymbolXCOFF : public MCSymbol {
2323

2424
public:
2525
MCSymbolXCOFF(const MCSymbolTableEntry *Name, bool isTemporary)
26-
: MCSymbol(SymbolKindXCOFF, Name, isTemporary) {}
26+
: MCSymbol(Name, isTemporary) {}
2727

2828
enum CodeModel : uint8_t { CM_Small, CM_Large };
2929

llvm/lib/MC/MCContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,9 @@ MCSymbol *MCContext::createSymbolImpl(const MCSymbolTableEntry *Name,
294294
case MCContext::IsDXContainer:
295295
break;
296296
case MCContext::IsSPIRV:
297-
return new (Name, *this)
298-
MCSymbol(MCSymbol::SymbolKindUnset, Name, IsTemporary);
297+
return new (Name, *this) MCSymbol(Name, IsTemporary);
299298
}
300-
return new (Name, *this)
301-
MCSymbol(MCSymbol::SymbolKindUnset, Name, IsTemporary);
299+
return new (Name, *this) MCSymbol(Name, IsTemporary);
302300
}
303301

304302
MCSymbol *MCContext::cloneSymbol(MCSymbol &Sym) {

0 commit comments

Comments
 (0)