[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp

Nate Begeman natebegeman at mac.com
Mon Jan 29 14:59:26 PST 2007



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.461 -> 1.462
SelectionDAG.cpp updated: 1.378 -> 1.379
SelectionDAGISel.cpp updated: 1.349 -> 1.350
---
Log message:

Finish off bug 680: http://llvm.org/PR680 , allowing targets to custom lower frame and return
address nodes.


---
Diffs of the changes:  (+20 -24)

 LegalizeDAG.cpp      |   10 ++++++++++
 SelectionDAG.cpp     |    2 ++
 SelectionDAGISel.cpp |   32 ++++++++------------------------
 3 files changed, 20 insertions(+), 24 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.461 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.462
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.461	Sun Jan 28 10:04:40 2007
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Mon Jan 29 16:58:52 2007
@@ -652,6 +652,16 @@
       break;
     }
     break;
+  case ISD::FRAMEADDR:
+  case ISD::RETURNADDR:
+    // The only option for these nodes is to custom lower them.  If the target
+    // does not custom lower them, then return zero.
+    Tmp1 = TLI.LowerOperation(Op, DAG);
+    if (Tmp1.Val) 
+      Result = Tmp1;
+    else
+      Result = DAG.getConstant(0, TLI.getPointerTy());
+    break;
   case ISD::AssertSext:
   case ISD::AssertZext:
     Tmp1 = LegalizeOp(Node->getOperand(0));


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.378 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.379
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.378	Fri Jan 26 08:34:51 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Mon Jan 29 16:58:52 2007
@@ -2665,6 +2665,8 @@
   case ISD::FrameIndex:    return "FrameIndex";
   case ISD::JumpTable:     return "JumpTable";
   case ISD::GLOBAL_OFFSET_TABLE: return "GLOBAL_OFFSET_TABLE";
+  case ISD::RETURNADDR: return "RETURNADDR";
+  case ISD::FRAMEADDR: return "FRAMEADDR";
   case ISD::ConstantPool:  return "ConstantPool";
   case ISD::ExternalSymbol: return "ExternalSymbol";
   case ISD::INTRINSIC_WO_CHAIN: {


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.349 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.350
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.349	Sun Jan 28 12:01:49 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Mon Jan 29 16:58:52 2007
@@ -570,7 +570,6 @@
   void visitVAArg(VAArgInst &I);
   void visitVAEnd(CallInst &I);
   void visitVACopy(CallInst &I);
-  void visitFrameReturnAddress(CallInst &I, bool isFrameAddress);
 
   void visitMemIntrinsic(CallInst &I, unsigned Op);
 
@@ -1932,8 +1931,14 @@
   case Intrinsic::vastart:  visitVAStart(I); return 0;
   case Intrinsic::vaend:    visitVAEnd(I); return 0;
   case Intrinsic::vacopy:   visitVACopy(I); return 0;
-  case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return 0;
-  case Intrinsic::frameaddress:  visitFrameReturnAddress(I, true); return 0;
+  case Intrinsic::returnaddress:
+    setValue(&I, DAG.getNode(ISD::RETURNADDR, TLI.getPointerTy(),
+                             getValue(I.getOperand(1))));
+    return 0;
+  case Intrinsic::frameaddress:
+    setValue(&I, DAG.getNode(ISD::FRAMEADDR, TLI.getPointerTy(),
+                             getValue(I.getOperand(1))));
+    return 0;
   case Intrinsic::setjmp:
     return "_setjmp"+!TLI.usesUnderscoreSetJmp();
     break;
@@ -3207,19 +3212,6 @@
   return std::make_pair(ResVal, Res.getValue(Res.Val->getNumValues()-1));
 }
 
-
-
-// It is always conservatively correct for llvm.returnaddress and
-// llvm.frameaddress to return 0.
-//
-// FIXME: Change this to insert a FRAMEADDR/RETURNADDR node, and have that be
-// expanded to 0 if the target wants.
-std::pair<SDOperand, SDOperand>
-TargetLowering::LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain,
-                                        unsigned Depth, SelectionDAG &DAG) {
-  return std::make_pair(DAG.getConstant(0, getPointerTy()), Chain);
-}
-
 SDOperand TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
   assert(0 && "LowerOperation not implemented for this target!");
   abort();
@@ -3233,14 +3225,6 @@
   return SDOperand();
 }
 
-void SelectionDAGLowering::visitFrameReturnAddress(CallInst &I, bool isFrame) {
-  unsigned Depth = (unsigned)cast<ConstantInt>(I.getOperand(1))->getZExtValue();
-  std::pair<SDOperand,SDOperand> Result =
-    TLI.LowerFrameReturnAddress(isFrame, getRoot(), Depth, DAG);
-  setValue(&I, Result.first);
-  DAG.setRoot(Result.second);
-}
-
 /// getMemsetValue - Vectorized representation of the memset value
 /// operand.
 static SDOperand getMemsetValue(SDOperand Value, MVT::ValueType VT,






More information about the llvm-commits mailing list