diff options
author | Chris Lattner <sabre@nondot.org> | 2005-12-18 02:37:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-12-18 02:37:35 +0000 |
commit | 76acc872b3c63c26a83c2832ece6fa9b04786f24 (patch) | |
tree | 48c7cad83c9e69b2815f68f12bc3cb17ce3bab38 /lib/Target/Sparc | |
parent | e1389ad43afa6b4f7449013fec7ad37fe8ca2bbd (diff) | |
download | external_llvm-76acc872b3c63c26a83c2832ece6fa9b04786f24.zip external_llvm-76acc872b3c63c26a83c2832ece6fa9b04786f24.tar.gz external_llvm-76acc872b3c63c26a83c2832ece6fa9b04786f24.tar.bz2 |
Add constant pool support, including folding into addresses.
Pretty print addresses a bit, to not print [%r1+%g0]: just print [%r1]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Sparc')
-rw-r--r-- | lib/Target/Sparc/SparcAsmPrinter.cpp | 14 | ||||
-rw-r--r-- | lib/Target/Sparc/SparcISelDAGToDAG.cpp | 8 | ||||
-rw-r--r-- | lib/Target/Sparc/SparcInstrInfo.td | 4 |
3 files changed, 24 insertions, 2 deletions
diff --git a/lib/Target/Sparc/SparcAsmPrinter.cpp b/lib/Target/Sparc/SparcAsmPrinter.cpp index ea4971c..f64bd7e 100644 --- a/lib/Target/Sparc/SparcAsmPrinter.cpp +++ b/lib/Target/Sparc/SparcAsmPrinter.cpp @@ -185,8 +185,20 @@ void SparcV8AsmPrinter::printOperand(const MachineInstr *MI, int opNum) { void SparcV8AsmPrinter::printMemOperand(const MachineInstr *MI, int opNum) { printOperand(MI, opNum); + MachineOperand::MachineOperandType OpTy = MI->getOperand(opNum+1).getType(); + + if ((OpTy == MachineOperand::MO_VirtualRegister || + OpTy == MachineOperand::MO_MachineRegister) && + MI->getOperand(opNum+1).getReg() == V8::G0) + return; // don't print "+%g0" + if ((OpTy == MachineOperand::MO_SignExtendedImmed || + OpTy == MachineOperand::MO_UnextendedImmed) && + MI->getOperand(opNum+1).getImmedValue() == 0) + return; // don't print "+0" + O << "+"; - if (MI->getOperand(opNum+1).getType() == MachineOperand::MO_GlobalAddress) { + if (OpTy == MachineOperand::MO_GlobalAddress || + OpTy == MachineOperand::MO_ConstantPoolIndex) { O << "%lo("; printOperand(MI, opNum+1); O << ")"; diff --git a/lib/Target/Sparc/SparcISelDAGToDAG.cpp b/lib/Target/Sparc/SparcISelDAGToDAG.cpp index aa558d1..860c76f 100644 --- a/lib/Target/Sparc/SparcISelDAGToDAG.cpp +++ b/lib/Target/Sparc/SparcISelDAGToDAG.cpp @@ -75,6 +75,7 @@ SparcV8TargetLowering::SparcV8TargetLowering(TargetMachine &TM) // Custom legalize GlobalAddress nodes into LO/HI parts. setOperationAction(ISD::GlobalAddress, MVT::i32, Custom); + setOperationAction(ISD::ConstantPool , MVT::i32, Custom); // Sparc doesn't have sext_inreg, replace them with shl/sra setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16 , Expand); @@ -251,6 +252,13 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) { SDOperand Lo = DAG.getNode(V8ISD::Lo, MVT::i32, GA); return DAG.getNode(ISD::ADD, MVT::i32, Lo, Hi); } + case ISD::ConstantPool: { + Constant *C = cast<ConstantPoolSDNode>(Op)->get(); + SDOperand CP = DAG.getTargetConstantPool(C, MVT::i32); + SDOperand Hi = DAG.getNode(V8ISD::Hi, MVT::i32, CP); + SDOperand Lo = DAG.getNode(V8ISD::Lo, MVT::i32, CP); + return DAG.getNode(ISD::ADD, MVT::i32, Lo, Hi); + } } } diff --git a/lib/Target/Sparc/SparcInstrInfo.td b/lib/Target/Sparc/SparcInstrInfo.td index eaa6691..22ed241 100644 --- a/lib/Target/Sparc/SparcInstrInfo.td +++ b/lib/Target/Sparc/SparcInstrInfo.td @@ -660,6 +660,8 @@ def : Pat<(i32 simm13:$val), def : Pat<(i32 imm:$val), (ORri (SETHIi (HI22 imm:$val)), (LO10 imm:$val))>; -// Global addresses +// Global addresses, constant pool entries def : Pat<(V8hi tglobaladdr:$in), (SETHIi tglobaladdr:$in)>; def : Pat<(V8lo tglobaladdr:$in), (ORri G0, tglobaladdr:$in)>; +def : Pat<(V8hi tconstpool:$in), (SETHIi tconstpool:$in)>; +def : Pat<(V8lo tconstpool:$in), (ORri G0, tconstpool:$in)>; |