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 | edb9d84dcc4824865e86f963e52d67eb50dde7f5 (patch) | |
tree | 30482808686a63895173c1da6b5d9953e31c8988 /llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | |
parent | e75bb3496323f1e1f86acf5522c499a1a54ff95f (diff) | |
download | llvm-edb9d84dcc4824865e86f963e52d67eb50dde7f5.zip llvm-edb9d84dcc4824865e86f963e52d67eb50dde7f5.tar.gz llvm-edb9d84dcc4824865e86f963e52d67eb50dde7f5.tar.bz2 |
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.
llvm-svn: 119105
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCMCInstLower.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp b/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp index f7a9ba9..ca43ef5 100644 --- a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp +++ b/llvm/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, |