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
This commit is contained in:
Chris Lattner
2010-11-15 02:46:57 +00:00
parent dd57417c08
commit 1e61e69d40
9 changed files with 154 additions and 131 deletions

View File

@@ -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,