Add constpool lowering / printing

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76016 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov
2009-07-16 14:19:35 +00:00
parent 0e31d5cf80
commit ae53567de1
4 changed files with 35 additions and 2 deletions

View File

@@ -144,6 +144,9 @@ bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
SetupMachineFunction(MF); SetupMachineFunction(MF);
O << "\n\n"; O << "\n\n";
// Print out constants referenced by the function
EmitConstantPool(MF.getConstantPool());
// Print the 'header' of function // Print the 'header' of function
emitFunctionHeader(MF); emitFunctionHeader(MF);
@@ -258,6 +261,12 @@ void SystemZAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
<< MO.getIndex(); << MO.getIndex();
return; return;
case MachineOperand::MO_ConstantPoolIndex:
O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
<< MO.getIndex();
printOffset(MO.getOffset());
break;
case MachineOperand::MO_GlobalAddress: { case MachineOperand::MO_GlobalAddress: {
const GlobalValue *GV = MO.getGlobal(); const GlobalValue *GV = MO.getGlobal();
std::string Name = Mang->getValueName(GV); std::string Name = Mang->getValueName(GV);

View File

@@ -74,6 +74,10 @@ SystemZTargetLowering::SystemZTargetLowering(SystemZTargetMachine &tm) :
setOperationAction(ISD::BRCOND, MVT::Other, Expand); setOperationAction(ISD::BRCOND, MVT::Other, Expand);
setOperationAction(ISD::BR_CC, MVT::i32, Custom); setOperationAction(ISD::BR_CC, MVT::i32, Custom);
setOperationAction(ISD::BR_CC, MVT::i64, Custom); setOperationAction(ISD::BR_CC, MVT::i64, Custom);
setOperationAction(ISD::BR_CC, MVT::f32, Custom);
setOperationAction(ISD::BR_CC, MVT::f64, Custom);
setOperationAction(ISD::ConstantPool, MVT::i32, Custom);
setOperationAction(ISD::ConstantPool, MVT::i64, Custom);
setOperationAction(ISD::GlobalAddress, MVT::i64, Custom); setOperationAction(ISD::GlobalAddress, MVT::i64, Custom);
setOperationAction(ISD::JumpTable, MVT::i64, Custom); setOperationAction(ISD::JumpTable, MVT::i64, Custom);
setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Expand); setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Expand);
@@ -94,6 +98,8 @@ SystemZTargetLowering::SystemZTargetLowering(SystemZTargetMachine &tm) :
setOperationAction(ISD::SELECT, MVT::i64, Expand); setOperationAction(ISD::SELECT, MVT::i64, Expand);
setOperationAction(ISD::SELECT_CC, MVT::i32, Custom); setOperationAction(ISD::SELECT_CC, MVT::i32, Custom);
setOperationAction(ISD::SELECT_CC, MVT::i64, Custom); setOperationAction(ISD::SELECT_CC, MVT::i64, Custom);
setOperationAction(ISD::SELECT_CC, MVT::f32, Custom);
setOperationAction(ISD::SELECT_CC, MVT::f64, Custom);
// Funny enough: we don't have 64-bit signed versions of these stuff, but have // Funny enough: we don't have 64-bit signed versions of these stuff, but have
// unsigned. // unsigned.
@@ -110,6 +116,7 @@ SDValue SystemZTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) {
case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG); case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG);
case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG); case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG);
case ISD::JumpTable: return LowerJumpTable(Op, DAG); case ISD::JumpTable: return LowerJumpTable(Op, DAG);
case ISD::ConstantPool: return LowerConstantPool(Op, DAG);
default: default:
assert(0 && "unimplemented operand"); assert(0 && "unimplemented operand");
return SDValue(); return SDValue();
@@ -594,7 +601,7 @@ SDValue SystemZTargetLowering::LowerGlobalAddress(SDValue Op,
return Result; return Result;
} }
// FIXME: PIC here
SDValue SystemZTargetLowering::LowerJumpTable(SDValue Op, SDValue SystemZTargetLowering::LowerJumpTable(SDValue Op,
SelectionDAG &DAG) { SelectionDAG &DAG) {
DebugLoc dl = Op.getDebugLoc(); DebugLoc dl = Op.getDebugLoc();
@@ -604,6 +611,21 @@ SDValue SystemZTargetLowering::LowerJumpTable(SDValue Op,
return DAG.getNode(SystemZISD::PCRelativeWrapper, dl, getPointerTy(), Result); return DAG.getNode(SystemZISD::PCRelativeWrapper, dl, getPointerTy(), Result);
} }
// FIXME: PIC here
// FIXME: This is just dirty hack. We need to lower cpool properly
SDValue SystemZTargetLowering::LowerConstantPool(SDValue Op,
SelectionDAG &DAG) {
DebugLoc dl = Op.getDebugLoc();
ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op);
SDValue Result = DAG.getTargetConstantPool(CP->getConstVal(), getPointerTy(),
CP->getAlignment(),
CP->getOffset());
return DAG.getNode(SystemZISD::PCRelativeWrapper, dl, getPointerTy(), Result);
}
const char *SystemZTargetLowering::getTargetNodeName(unsigned Opcode) const { const char *SystemZTargetLowering::getTargetNodeName(unsigned Opcode) const {
switch (Opcode) { switch (Opcode) {
case SystemZISD::RET_FLAG: return "SystemZISD::RET_FLAG"; case SystemZISD::RET_FLAG: return "SystemZISD::RET_FLAG";

View File

@@ -71,6 +71,7 @@ namespace llvm {
SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG); SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG);
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG); SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG); SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG);
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG);
SDValue LowerCCCArguments(SDValue Op, SelectionDAG &DAG); SDValue LowerCCCArguments(SDValue Op, SelectionDAG &DAG);
SDValue LowerCCCCallTo(SDValue Op, SelectionDAG &DAG, unsigned CC); SDValue LowerCCCCallTo(SDValue Op, SelectionDAG &DAG, unsigned CC);

View File

@@ -744,8 +744,9 @@ def UCMPZX64rm32 : Pseudo<(outs), (ins GR64:$src1, rriaddr:$src2),
// Non-Instruction Patterns. // Non-Instruction Patterns.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// JumpTable // ConstPools, JumpTables
def : Pat<(SystemZpcrelwrapper tjumptable:$src), (LA64rm tjumptable:$src)>; def : Pat<(SystemZpcrelwrapper tjumptable:$src), (LA64rm tjumptable:$src)>;
def : Pat<(SystemZpcrelwrapper tconstpool:$src), (LA64rm tconstpool:$src)>;
// anyext // anyext
def : Pat<(i64 (anyext GR32:$src)), def : Pat<(i64 (anyext GR32:$src)),