diff options
author | Chris Lattner <sabre@nondot.org> | 2010-11-14 21:20:46 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-11-14 21:20:46 +0000 |
commit | 1520fd60950c1c347457b225dbbd72224d4fcd19 (patch) | |
tree | 19b6c74df4a3c1f6997806735a026aa4d485309d /lib/Target/PowerPC/PPCMCInstLower.cpp | |
parent | db2c50907f9423767b423aca313e2182ee7b71c4 (diff) | |
download | external_llvm-1520fd60950c1c347457b225dbbd72224d4fcd19.zip external_llvm-1520fd60950c1c347457b225dbbd72224d4fcd19.tar.gz external_llvm-1520fd60950c1c347457b225dbbd72224d4fcd19.tar.bz2 |
implement basic support for symbol operand lowering,
and printing support for call operands. Down to 77 failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCMCInstLower.cpp')
-rw-r--r-- | lib/Target/PowerPC/PPCMCInstLower.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp index 2e94030..6a753cf 100644 --- a/lib/Target/PowerPC/PPCMCInstLower.cpp +++ b/lib/Target/PowerPC/PPCMCInstLower.cpp @@ -17,10 +17,35 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" +#include "llvm/Target/Mangler.h" using namespace llvm; +static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol, + AsmPrinter &Printer) { + MCContext &Ctx = Printer.OutContext; + const MCExpr *Expr; + switch (MO.getTargetFlags()) { + default: assert(0 && "Unknown target flag on symbol operand"); + case 0: + Expr = MCSymbolRefExpr::Create(Symbol, MCSymbolRefExpr::VK_None, Ctx); + break; +#if 0 + case ARMII::MO_LO16: + Expr = MCSymbolRefExpr::Create(Symbol, MCSymbolRefExpr::VK_ARM_LO16, Ctx); + break; +#endif + } + + if (!MO.isJTI() && MO.getOffset()) + Expr = MCBinaryExpr::CreateAdd(Expr, + MCConstantExpr::Create(MO.getOffset(), Ctx), + Ctx); + return MCOperand::CreateExpr(Expr); + +} + void llvm::LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, - AsmPrinter &Printer) { + AsmPrinter &AP) { OutMI.setOpcode(MI->getOpcode()); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { @@ -38,6 +63,26 @@ void llvm::LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, case MachineOperand::MO_Immediate: MCOp = MCOperand::CreateImm(MO.getImm()); break; + case MachineOperand::MO_MachineBasicBlock: + MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create( + MO.getMBB()->getSymbol(), AP.OutContext)); + break; + case MachineOperand::MO_GlobalAddress: + MCOp = GetSymbolRef(MO, AP.Mang->getSymbol(MO.getGlobal()), AP); + break; + case MachineOperand::MO_ExternalSymbol: + MCOp = GetSymbolRef(MO, + AP.GetExternalSymbolSymbol(MO.getSymbolName()), AP); + break; + case MachineOperand::MO_JumpTableIndex: + MCOp = GetSymbolRef(MO, AP.GetJTISymbol(MO.getIndex()), AP); + break; + case MachineOperand::MO_ConstantPoolIndex: + MCOp = GetSymbolRef(MO, AP.GetCPISymbol(MO.getIndex()), AP); + break; + case MachineOperand::MO_BlockAddress: + MCOp = GetSymbolRef(MO,AP.GetBlockAddressSymbol(MO.getBlockAddress()),AP); + break; } OutMI.addOperand(MCOp); |