diff options
author | Chris Lattner <sabre@nondot.org> | 2010-11-15 02:46:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-11-15 02:46:57 +0000 |
commit | 1e61e69d401045c54b15815f15a0fdb3ca56a9b5 (patch) | |
tree | ece661c4c7b88ccde11f44e0ef5de5c1b1bdd82d /lib/Target/PowerPC/PPCMCInstLower.cpp | |
parent | dd57417c08d3fbb52935b70cf14edef34535d045 (diff) |
add targetoperand flags for jump tables, constant pool and block address
nodes to indicate when ha16/lo16 modifiers should be used. This lets
us pass PowerPC/indirectbr.ll.
The one annoying thing about this patch is that the MCSymbolExpr isn't
expressive enough to represent ha16(label1-label2) which we need on
PowerPC. I have a terrible hack in the meantime, but this will have
to be revisited at some point.
Last major conversion item left is global variable references.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119105 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCMCInstLower.cpp')
-rw-r--r-- | lib/Target/PowerPC/PPCMCInstLower.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp index f7a9ba9cdf..ca43ef5be6 100644 --- a/lib/Target/PowerPC/PPCMCInstLower.cpp +++ b/lib/Target/PowerPC/PPCMCInstLower.cpp @@ -14,7 +14,7 @@ #include "PPC.h" #include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCExpr.h" @@ -124,23 +124,32 @@ static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol, case PPCII::MO_DARWIN_STUB: break; -#if 0 - case PPCII::MO_LO16: - Expr = MCSymbolRefExpr::Create(Symbol, MCSymbolRefExpr::VK_ARM_LO16, Ctx); - break; -#endif + case PPCII::MO_LO16: RefKind = MCSymbolRefExpr::VK_PPC_LO16; break; + case PPCII::MO_HA16: RefKind = MCSymbolRefExpr::VK_PPC_HA16; break; + case PPCII::MO_LO16_PIC: break; + case PPCII::MO_HA16_PIC: break; } if (Expr == 0) Expr = MCSymbolRefExpr::Create(Symbol, RefKind, Ctx); - if (!MO.isJTI() && MO.getOffset()) Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(MO.getOffset(), Ctx), Ctx); - return MCOperand::CreateExpr(Expr); + + // Subtract off the PIC base. + if (MO.getTargetFlags() == PPCII::MO_LO16_PIC || + MO.getTargetFlags() == PPCII::MO_HA16_PIC) { + const MachineFunction *MF = MO.getParent()->getParent()->getParent(); + + const MCExpr *PB = MCSymbolRefExpr::Create(MF->getPICBaseSymbol(), Ctx); + Expr = MCBinaryExpr::CreateSub(Expr, PB, Ctx); + // FIXME: We have no way to make the result be VK_PPC_LO16/VK_PPC_HA16, + // since it is not a symbol! + } + return MCOperand::CreateExpr(Expr); } void llvm::LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, |