/// The symbol being referenced.
const MCSymbol *Symbol;
- // Subclass data stores VariantKind in bits 0..15, UseParensForSymbolVariant
- // in bit 16 and HasSubsectionsViaSymbols in bit 17.
+ // Subclass data stores VariantKind in bits 0..15 and HasSubsectionsViaSymbols
+ // in bit 16.
static const unsigned VariantKindBits = 16;
static const unsigned VariantKindMask = (1 << VariantKindBits) - 1;
- /// Specifies how the variant kind should be printed.
- static const unsigned UseParensForSymbolVariantBit = 1 << VariantKindBits;
-
// FIXME: Remove this bit.
- static const unsigned HasSubsectionsViaSymbolsBit =
- 1 << (VariantKindBits + 1);
+ static const unsigned HasSubsectionsViaSymbolsBit = 1 << VariantKindBits;
static unsigned encodeSubclassData(VariantKind Kind,
- bool UseParensForSymbolVariant,
- bool HasSubsectionsViaSymbols) {
+ bool HasSubsectionsViaSymbols) {
return (unsigned)Kind |
- (UseParensForSymbolVariant ? UseParensForSymbolVariantBit : 0) |
(HasSubsectionsViaSymbols ? HasSubsectionsViaSymbolsBit : 0);
}
- bool useParensForSymbolVariant() const {
- return (getSubclassData() & UseParensForSymbolVariantBit) != 0;
- }
-
explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
return (VariantKind)(getSubclassData() & VariantKindMask);
}
- void printVariantKind(raw_ostream &OS) const;
-
bool hasSubsectionsViaSymbols() const {
return (getSubclassData() & HasSubsectionsViaSymbolsBit) != 0;
}
} else
Sym.print(OS, MAI);
- if (SRE.getKind() != MCSymbolRefExpr::VK_None)
- SRE.printVariantKind(OS);
+ const MCSymbolRefExpr::VariantKind Kind = SRE.getKind();
+ if (Kind != MCSymbolRefExpr::VK_None) {
+ if (MAI && MAI->useParensForSymbolVariant()) // ARM
+ OS << '(' << MCSymbolRefExpr::getVariantKindName(Kind) << ')';
+ else
+ OS << '@' << MCSymbolRefExpr::getVariantKindName(Kind);
+ }
return;
}
MCSymbolRefExpr::MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
const MCAsmInfo *MAI, SMLoc Loc)
: MCExpr(MCExpr::SymbolRef, Loc,
- encodeSubclassData(Kind, MAI->useParensForSymbolVariant(),
- MAI->hasSubsectionsViaSymbols())),
+ encodeSubclassData(Kind, MAI->hasSubsectionsViaSymbols())),
Symbol(Symbol) {
assert(Symbol);
}
.Default(VK_Invalid);
}
-void MCSymbolRefExpr::printVariantKind(raw_ostream &OS) const {
- if (useParensForSymbolVariant())
- OS << '(' << MCSymbolRefExpr::getVariantKindName(getKind()) << ')';
- else
- OS << '@' << MCSymbolRefExpr::getVariantKindName(getKind());
-}
-
/* *** */
void MCTargetExpr::anchor() {}