forked from OSchip/llvm-project
[MC] Inline MCExpr::printVariantKind & remove UseParensForSymbolVariantBit
Note, MAI may be nullptr in -show-encoding.
This commit is contained in:
parent
da11479fd1
commit
1e8fbb3b74
|
@ -355,30 +355,20 @@ private:
|
|||
/// 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());
|
||||
|
||||
|
@ -405,8 +395,6 @@ public:
|
|||
return (VariantKind)(getSubclassData() & VariantKindMask);
|
||||
}
|
||||
|
||||
void printVariantKind(raw_ostream &OS) const;
|
||||
|
||||
bool hasSubsectionsViaSymbols() const {
|
||||
return (getSubclassData() & HasSubsectionsViaSymbolsBit) != 0;
|
||||
}
|
||||
|
|
|
@ -85,8 +85,13 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens) const {
|
|||
} 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;
|
||||
}
|
||||
|
@ -197,8 +202,7 @@ const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx,
|
|||
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);
|
||||
}
|
||||
|
@ -510,13 +514,6 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) {
|
|||
.Default(VK_Invalid);
|
||||
}
|
||||
|
||||
void MCSymbolRefExpr::printVariantKind(raw_ostream &OS) const {
|
||||
if (useParensForSymbolVariant())
|
||||
OS << '(' << MCSymbolRefExpr::getVariantKindName(getKind()) << ')';
|
||||
else
|
||||
OS << '@' << MCSymbolRefExpr::getVariantKindName(getKind());
|
||||
}
|
||||
|
||||
/* *** */
|
||||
|
||||
void MCTargetExpr::anchor() {}
|
||||
|
|
Loading…
Reference in New Issue