summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-17 18:55:48 +0000
committerChris Lattner <sabre@nondot.org>2005-11-17 18:55:48 +0000
commit3570cf456b31ac08cb91106f0d8b41f1619f41c5 (patch)
tree7c2bc57e53cef4c9d8969156fc171d94e3329a94 /llvm/lib/Target/PowerPC/PPCISelLowering.cpp
parent8f8ed28a64583fcf3a0ab81c1f175cb349666852 (diff)
downloadbcm5719-llvm-3570cf456b31ac08cb91106f0d8b41f1619f41c5.tar.gz
bcm5719-llvm-3570cf456b31ac08cb91106f0d8b41f1619f41c5.zip
add an option to generate completely non-pic code, corresponding to what
gcc -static produces on PPC. This is used for building kexts and other things. With this, materializing the address of a global looks like: lis r2, ha16(L_H$non_lazy_ptr) la r3, lo16(L_H$non_lazy_ptr)(r2) we're still emitting stubs for functions, which is wrong. That is next. llvm-svn: 24399
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCISelLowering.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCISelLowering.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 6ea688d020e..6f798c38ed8 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -333,12 +333,20 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
return DAG.getNode(ISD::BUILD_PAIR, MVT::i64, OutLo, OutHi);
}
case ISD::GlobalAddress: {
- // Only lower GlobalAddress on Darwin.
- if (!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) break;
GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
SDOperand GA = DAG.getTargetGlobalAddress(GV, MVT::i32);
SDOperand Zero = DAG.getConstant(0, MVT::i32);
+
+ if (PPCGenerateStaticCode) {
+ // Generate non-pic code that has direct accesses to globals. To do this
+ // the address of the global is just (hi(&g)+lo(&g)).
+ SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, GA, Zero);
+ SDOperand Lo = DAG.getNode(PPCISD::Lo, MVT::i32, GA, Zero);
+ return DAG.getNode(ISD::ADD, MVT::i32, Hi, Lo);
+ }
+ // Only lower GlobalAddress on Darwin.
+ if (!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) break;
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, GA, Zero);
if (PICEnabled) {
// With PIC, the first instruction is actually "GR+hi(&G)".
OpenPOWER on IntegriCloud