Changes in directory llvm/lib/CodeGen/SelectionDAG:
LegalizeDAG.cpp updated: 1.260 -> 1.261 SelectionDAGISel.cpp updated: 1.122 -> 1.123 --- Log message: Compile llvm.stacksave/restore into STACKSAVE/STACKRESTORE nodes, and allow targets to custom expand them as they desire. --- Diffs of the changes: (+72 -4) LegalizeDAG.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ SelectionDAGISel.cpp | 18 ++++++++++++--- 2 files changed, 72 insertions(+), 4 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.260 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.261 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.260 Wed Jan 11 16:14:47 2006 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu Jan 12 20:50:02 2006 @@ -1425,6 +1425,64 @@ if (Tmp1 != Node->getOperand(0)) Result = DAG.getNode(ISD::PCMARKER, MVT::Other, Tmp1,Node->getOperand(1)); break; + case ISD::STACKSAVE: + Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. + if (Tmp1 != Node->getOperand(0)) { + std::vector<MVT::ValueType> VTs; + VTs.push_back(Node->getValueType(0)); + VTs.push_back(MVT::Other); + std::vector<SDOperand> Ops; + Ops.push_back(Tmp1); + Result = DAG.getNode(ISD::STACKSAVE, VTs, Ops); + } + + switch (TLI.getOperationAction(ISD::STACKSAVE, MVT::Other)) { + default: assert(0 && "This action is not supported yet!"); + case TargetLowering::Custom: { + SDOperand Tmp = TLI.LowerOperation(Result, DAG); + if (Tmp.Val) { + Result = LegalizeOp(Tmp); + break; + } + // FALLTHROUGH if the target thinks it is legal. + } + case TargetLowering::Legal: + // Since stacksave produce two values, make sure to remember that we + // legalized both of them. + AddLegalizedOperand(SDOperand(Node, 0), Result); + AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); + return Result.getValue(Op.ResNo); + case TargetLowering::Expand: + Tmp1 = DAG.getNode(ISD::UNDEF, Node->getValueType(0)); + AddLegalizedOperand(SDOperand(Node, 0), Tmp1); + AddLegalizedOperand(SDOperand(Node, 1), Node->getOperand(0)); + return Op.ResNo ? Node->getOperand(0) : Tmp1; + } + + case ISD::STACKRESTORE: + Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. + Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer. + if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1)) + Result = DAG.getNode(ISD::STACKRESTORE, MVT::Other, Tmp1, Tmp2); + + switch (TLI.getOperationAction(ISD::STACKRESTORE, MVT::Other)) { + default: assert(0 && "This action is not supported yet!"); + case TargetLowering::Custom: { + SDOperand Tmp = TLI.LowerOperation(Result, DAG); + if (Tmp.Val) { + Result = LegalizeOp(Tmp); + break; + } + // FALLTHROUGH if the target thinks it is legal. + } + case TargetLowering::Legal: + break; + case TargetLowering::Expand: + Result = Tmp1; + break; + } + break; + case ISD::READCYCLECOUNTER: Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain if (Tmp1 != Node->getOperand(0)) { Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.122 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.123 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.122 Thu Jan 12 20:24:42 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Jan 12 20:50:02 2006 @@ -1004,11 +1004,21 @@ getValue(I.getOperand(1)).getValueType(), getValue(I.getOperand(1)))); return 0; - case Intrinsic::stacksave: - setValue(&I, DAG.getNode(ISD::UNDEF, TLI.getValueType(I.getType()))); - return 0; // FIXME: discard stacksave/restore + case Intrinsic::stacksave: { + std::vector<MVT::ValueType> VTs; + VTs.push_back(TLI.getPointerTy()); + VTs.push_back(MVT::Other); + std::vector<SDOperand> Ops; + Ops.push_back(getRoot()); + SDOperand Tmp = DAG.getNode(ISD::STACKSAVE, VTs, Ops); + setValue(&I, Tmp); + DAG.setRoot(Tmp.getValue(1)); + return 0; + } case Intrinsic::stackrestore: - return 0; // FIXME: discard stacksave/restore + DAG.setRoot(DAG.getNode(ISD::STACKRESTORE, MVT::Other, DAG.getRoot(), + getValue(I.getOperand(1)))); + return 0; case Intrinsic::prefetch: // FIXME: Currently discarding prefetches. return 0; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits