Implemented the frameaddress intrinsic for PPC.
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>
Thu, 1 Mar 2007 13:11:38 +0000 (13:11 +0000)
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>
Thu, 1 Mar 2007 13:11:38 +0000 (13:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34787 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.h

index c29364c82f6dafa00c43e72b4957042ee1a6060f..38f3974d9a4a600aa8095fc9fa93d6f6eab9f0b5 100644 (file)
@@ -2700,7 +2700,7 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
   
   // Frame & Return address.  Currently unimplemented
   case ISD::RETURNADDR:         break;
-  case ISD::FRAMEADDR:          break;
+  case ISD::FRAMEADDR:          return LowerFRAMEADDR(Op, DAG);
   }
   return SDOperand();
 }
@@ -3171,3 +3171,25 @@ bool PPCTargetLowering::isLegalAddressImmediate(int64_t V) const {
 bool PPCTargetLowering::isLegalAddressImmediate(llvm::GlobalValue* GV) const {
   return TargetLowering::isLegalAddressImmediate(GV); 
 }
+
+SDOperand PPCTargetLowering::LowerFRAMEADDR(SDOperand Op, SelectionDAG &DAG)
+{
+  // Depths > 0 not supported yet! 
+  if (cast<ConstantSDNode>(Op.getOperand(0))->getValue() > 0)
+    return SDOperand();
+  
+  MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
+  bool isPPC64 = PtrVT == MVT::i64;
+  
+  MachineFunction &MF = DAG.getMachineFunction();
+  MachineFrameInfo *MFI = MF.getFrameInfo();
+  bool is31 = (NoFramePointerElim || MFI->hasVarSizedObjects()) 
+                  && MFI->getStackSize();
+
+  if (isPPC64)
+    return DAG.getCopyFromReg(DAG.getEntryNode(), is31 ? PPC::X31 : PPC::X1,
+      MVT::i32);
+  else
+    return DAG.getCopyFromReg(DAG.getEntryNode(), is31 ? PPC::R31 : PPC::R1,
+      MVT::i32);
+}
index 676e0bc6fc8d22593c0e2a13c0c9da12114dbf87..009ceb0d9666412879d9f055adc1454be6d55cfb 100644 (file)
@@ -240,6 +240,8 @@ namespace llvm {
     /// as the offset of the target addressing mode.
     virtual bool isLegalAddressImmediate(int64_t V) const;
     virtual bool isLegalAddressImmediate(llvm::GlobalValue*) const;
+
+    SDOperand LowerFRAMEADDR(SDOperand Op, SelectionDAG &DAG);
   };
 }