diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-10-11 17:57:27 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-10-11 17:57:27 +0000 |
commit | dd13643b971b58188012d1d82d17ac78651dbbce (patch) | |
tree | a37ac525e298807be9ed7b443f299176d6926e19 /llvm/lib/MC/MCExpr.cpp | |
parent | 3e67db92bca12dd33c15f7416a98485d841acc15 (diff) | |
download | bcm5719-llvm-dd13643b971b58188012d1d82d17ac78651dbbce.tar.gz bcm5719-llvm-dd13643b971b58188012d1d82d17ac78651dbbce.zip |
MC: Shrink MCSymbolRefExpr by only storing the bits we need.
32 -> 16 bytes on x86_64. NFC.
llvm-svn: 219574
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index c0396233c27..83a245602ce 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -49,12 +49,8 @@ void MCExpr::print(raw_ostream &OS) const { else OS << Sym; - if (SRE.getKind() != MCSymbolRefExpr::VK_None) { - if (SRE.getMCAsmInfo().useParensForSymbolVariant()) - OS << '(' << MCSymbolRefExpr::getVariantKindName(SRE.getKind()) << ')'; - else - OS << '@' << MCSymbolRefExpr::getVariantKindName(SRE.getKind()); - } + if (SRE.getKind() != MCSymbolRefExpr::VK_None) + SRE.printVariantKind(OS); return; } @@ -150,6 +146,15 @@ const MCConstantExpr *MCConstantExpr::Create(int64_t Value, MCContext &Ctx) { /* *** */ +MCSymbolRefExpr::MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind, + const MCAsmInfo *MAI) + : MCExpr(MCExpr::SymbolRef), Kind(Kind), + UseParensForSymbolVariant(MAI->useParensForSymbolVariant()), + HasSubsectionsViaSymbols(MAI->hasSubsectionsViaSymbols()), + Symbol(Symbol) { + assert(Symbol); +} + const MCSymbolRefExpr *MCSymbolRefExpr::Create(const MCSymbol *Sym, VariantKind Kind, MCContext &Ctx) { @@ -442,6 +447,13 @@ 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() {} @@ -679,7 +691,6 @@ bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, case SymbolRef: { const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(this); const MCSymbol &Sym = SRE->getSymbol(); - const MCAsmInfo &MCAsmInfo = SRE->getMCAsmInfo(); // Evaluate recursively if this is a variable. if (Sym.isVariable() && SRE->getKind() == MCSymbolRefExpr::VK_None) { @@ -688,7 +699,7 @@ bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCSymbolRefExpr *A = Res.getSymA(); const MCSymbolRefExpr *B = Res.getSymB(); - if (MCAsmInfo.hasSubsectionsViaSymbols()) { + if (SRE->hasSubsectionsViaSymbols()) { // FIXME: This is small hack. Given // a = b + 4 // .long a |