summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-17 06:57:26 +0000
committerChris Lattner <sabre@nondot.org>2007-02-17 06:57:26 +0000
commit1f7d60262e9923ff18b2955d8d7e5520d41c3bc0 (patch)
treea78707cc05438d781ba8f6d1905e183a64f2db0e /llvm/lib
parent3723c90455e7ae2f1a53c3c7f9a2c52caec48250 (diff)
downloadbcm5719-llvm-1f7d60262e9923ff18b2955d8d7e5520d41c3bc0.tar.gz
bcm5719-llvm-1f7d60262e9923ff18b2955d8d7e5520d41c3bc0.zip
Fix ixaddrs as well, allowing ppc64 to compile to:
_test2: li r2, 0 lis r3, 1 std r2, 9024(r3) blr instead of: _test2: lis r2, 1 li r3, 0 ori r2, r2, 9024 std r3, 0(r2) blr This implements CodeGen/PowerPC/LargeAbsoluteAddr.ll:test2 llvm-svn: 34373
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/PowerPC/PPCISelLowering.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 56f5d11f955..f8c970e88da 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -841,25 +841,30 @@ bool PPCTargetLowering::SelectAddressRegImmShift(SDOperand N, SDOperand &Disp,
}
}
} else if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N)) {
- // Loading from a constant address.
-
- // If this address fits entirely in a 14-bit sext immediate field, codegen
- // this as "d, 0"
- short Imm;
- if (isIntS16Immediate(CN, Imm)) {
- Disp = DAG.getTargetConstant((unsigned short)Imm >> 2, getPointerTy());
- Base = DAG.getRegister(PPC::R0, CN->getValueType(0));
- return true;
- }
+ // Loading from a constant address. Verify low two bits are clear.
+ if ((CN->getValue() & 3) == 0) {
+ // If this address fits entirely in a 14-bit sext immediate field, codegen
+ // this as "d, 0"
+ short Imm;
+ if (isIntS16Immediate(CN, Imm)) {
+ Disp = DAG.getTargetConstant((unsigned short)Imm >> 2, getPointerTy());
+ Base = DAG.getRegister(PPC::R0, CN->getValueType(0));
+ return true;
+ }
- // FIXME: Handle small sext constant offsets in PPC64 mode also!
- if (CN->getValueType(0) == MVT::i32) {
- int Addr = (int)CN->getValue();
+ // Fold the low-part of 32-bit absolute addresses into addr mode.
+ if (CN->getValueType(0) == MVT::i32 ||
+ (int64_t)CN->getValue() == (int)CN->getValue()) {
+ int Addr = (int)CN->getValue();
- // Otherwise, break this down into an LIS + disp.
- Disp = DAG.getTargetConstant((short)Addr >> 2, MVT::i32);
- Base = DAG.getConstant(Addr - (signed short)Addr, MVT::i32);
- return true;
+ // Otherwise, break this down into an LIS + disp.
+ Disp = DAG.getTargetConstant((short)Addr >> 2, MVT::i32);
+
+ Base = DAG.getTargetConstant((Addr-(signed short)Addr) >> 16, MVT::i32);
+ unsigned Opc = CN->getValueType(0) == MVT::i32 ? PPC::LIS : PPC::LIS8;
+ Base = SDOperand(DAG.getTargetNode(Opc, CN->getValueType(0), Base), 0);
+ return true;
+ }
}
}
OpenPOWER on IntegriCloud