Skip to content

Commit 768ccf6

Browse files
committed
MCSymbolRefExpr: Remove HasSubsectionsViaSymbolsBit
This information is only needed assembly time and we can get it with Asm->getContext().getAsmInfo()->hasSubsectionsViaSymbols().
1 parent 12a377e commit 768ccf6

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

llvm/include/llvm/MC/MCExpr.h

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,6 @@ class MCSymbolRefExpr : public MCExpr {
217217
/// The symbol being referenced.
218218
const MCSymbol *Symbol;
219219

220-
// Subclass data stores VariantKind in bits 0..15 and HasSubsectionsViaSymbols
221-
// in bit 16.
222-
static const unsigned VariantKindBits = 16;
223-
static const unsigned VariantKindMask = (1 << VariantKindBits) - 1;
224-
225-
// FIXME: Remove this bit.
226-
static const unsigned HasSubsectionsViaSymbolsBit = 1 << VariantKindBits;
227-
228-
static unsigned encodeSubclassData(VariantKind Kind,
229-
bool HasSubsectionsViaSymbols) {
230-
return (unsigned)Kind |
231-
(HasSubsectionsViaSymbols ? HasSubsectionsViaSymbolsBit : 0);
232-
}
233-
234220
explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
235221
const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
236222

@@ -259,16 +245,8 @@ class MCSymbolRefExpr : public MCExpr {
259245
// Some targets encode the relocation specifier within SymA using
260246
// MCSymbolRefExpr::SubclassData, which is copied to MCValue::Specifier,
261247
// though this method is now deprecated.
262-
VariantKind getKind() const {
263-
return (VariantKind)(getSubclassData() & VariantKindMask);
264-
}
265-
uint16_t getSpecifier() const {
266-
return (getSubclassData() & VariantKindMask);
267-
}
268-
269-
bool hasSubsectionsViaSymbols() const {
270-
return (getSubclassData() & HasSubsectionsViaSymbolsBit) != 0;
271-
}
248+
VariantKind getKind() const { return VariantKind(getSubclassData()); }
249+
uint16_t getSpecifier() const { return getSubclassData(); }
272250

273251
/// @}
274252

llvm/lib/MC/MCExpr.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx,
235235

236236
MCSymbolRefExpr::MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
237237
const MCAsmInfo *MAI, SMLoc Loc)
238-
: MCExpr(MCExpr::SymbolRef, Loc,
239-
encodeSubclassData(Kind, MAI->hasSubsectionsViaSymbols())),
240-
Symbol(Symbol) {
238+
: MCExpr(MCExpr::SymbolRef, Loc, Kind), Symbol(Symbol) {
241239
assert(Symbol);
242240
}
243241

@@ -507,7 +505,8 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
507505
// Evaluate recursively if this is a variable.
508506
if (Sym.isVariable() && (Kind == MCSymbolRefExpr::VK_None || Layout) &&
509507
canExpand(Sym, InSet)) {
510-
bool IsMachO = SRE->hasSubsectionsViaSymbols();
508+
bool IsMachO =
509+
Asm && Asm->getContext().getAsmInfo()->hasSubsectionsViaSymbols();
511510
if (Sym.getVariableValue()->evaluateAsRelocatableImpl(Res, Asm,
512511
InSet || IsMachO)) {
513512
if (Kind != MCSymbolRefExpr::VK_None) {

0 commit comments

Comments
 (0)