diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-03 07:30:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-03 07:30:56 +0000 |
commit | 975d7e039260a9888050dfb6da865348d67fbb27 (patch) | |
tree | 5210a011eee8834d1ec54d9631436da82da51ef0 | |
parent | 63476a80404125e5196b6c09113c1d4796da0604 (diff) | |
download | external_llvm-975d7e039260a9888050dfb6da865348d67fbb27.zip external_llvm-975d7e039260a9888050dfb6da865348d67fbb27.tar.gz external_llvm-975d7e039260a9888050dfb6da865348d67fbb27.tar.bz2 |
Implement support for X86II::MO_GOT_ABSOLUTE_ADDRESS. We get very
different formatting from the old asmprinter, but it should be
semantically the same. We used to get:
popl %eax
addl $_GLOBAL_OFFSET_TABLE_ + [.-.Lllvm$6.$piclabel], %eax
...
Now we get:
popl %eax
.Lpicbaseref6:
addl $(_GLOBAL_OFFSET_TABLE_ + (.Lpicbaseref6 - .Lllvm$6.$piclabel)), %eax
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80905 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/AsmPrinter/X86MCInstLower.cpp | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp index 89fac7a..3636ecb 100644 --- a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp +++ b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp @@ -160,7 +160,10 @@ GetConstantPoolIndexSymbol(const MachineOperand &MO) { MCOperand X86ATTAsmPrinter::LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) { - MCSymbol *NegatedSymbol = 0; + // FIXME: We would like an efficient form for this, so we don't have to do a + // lot of extra uniquing. + const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, OutContext); + switch (MO.getTargetFlags()) { default: llvm_unreachable("Unknown target flag on GV operand"); case X86II::MO_NO_FLAG: // No flag. @@ -183,24 +186,32 @@ MCOperand X86ATTAsmPrinter::LowerSymbolOperand(const MachineOperand &MO, case X86II::MO_DARWIN_NONLAZY_PIC_BASE: case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: // Subtract the pic base. - NegatedSymbol = GetPICBaseSymbol(); + Expr = MCBinaryExpr::CreateSub(Expr, + MCSymbolRefExpr::Create(GetPICBaseSymbol(), + OutContext), + OutContext); break; - case X86II::MO_GOT_ABSOLUTE_ADDRESS: - assert(0 && "Reloc mode unimp!"); - //O << " + [.-"; - //PrintPICBaseSymbol(); - //O << ']'; + case X86II::MO_GOT_ABSOLUTE_ADDRESS: { + // For this, we want to print something like: + // MYSYMBOL + (. - PICBASE) + // However, we can't generate a ".", so just emit a new label here and refer + // to it. We know that this operand flag occurs at most once per function. + SmallString<64> Name; + raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "picbaseref" + << getFunctionNumber(); + MCSymbol *DotSym = OutContext.GetOrCreateSymbol(Name.str()); + OutStreamer.EmitLabel(DotSym); + + const MCExpr *DotExpr = MCSymbolRefExpr::Create(DotSym, OutContext); + const MCExpr *PICBase = MCSymbolRefExpr::Create(GetPICBaseSymbol(), + OutContext); + DotExpr = MCBinaryExpr::CreateSub(DotExpr, PICBase, OutContext); + Expr = MCBinaryExpr::CreateAdd(Expr, DotExpr, OutContext); break; } + } - // FIXME: We would like an efficient form for this, so we don't have to do a - // lot of extra uniquing. - const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, OutContext); - if (NegatedSymbol) - Expr = MCBinaryExpr::CreateSub(Expr, MCSymbolRefExpr::Create(NegatedSymbol, - OutContext), - OutContext); - if (!MO.isSymbol() && MO.getOffset()) + if (MO.getOffset()) Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(MO.getOffset(), OutContext), OutContext); |