From d71c04199c447de39a2cab240c2fb7f717973e20 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 13 May 2005 18:43:43 +0000 Subject: [PATCH] Handle TAILCALL node git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21957 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 12 +++++++++--- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 793037930c0..14b4c5a4b23 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -361,6 +361,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); return Result.getValue(Op.ResNo); + case ISD::TAILCALL: case ISD::CALL: { Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the callee. @@ -377,7 +378,8 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { RetTyVTs.reserve(Node->getNumValues()); for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i) RetTyVTs.push_back(Node->getValueType(i)); - Result = SDOperand(DAG.getCall(RetTyVTs, Tmp1, Tmp2, Ops), 0); + Result = SDOperand(DAG.getCall(RetTyVTs, Tmp1, Tmp2, Ops, + Node->getOpcode() == ISD::TAILCALL), 0); } else { Result = Result.getValue(0); } @@ -1689,6 +1691,7 @@ SDOperand SelectionDAGLegalize::PromoteOp(SDOperand Op) { Tmp3 = PromoteOp(Node->getOperand(2)); // Legalize the op1 Result = DAG.getNode(ISD::SELECT, NVT, Tmp1, Tmp2, Tmp3); break; + case ISD::TAILCALL: case ISD::CALL: { Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the callee. @@ -1703,7 +1706,8 @@ SDOperand SelectionDAGLegalize::PromoteOp(SDOperand Op) { RetTyVTs.reserve(2); RetTyVTs.push_back(NVT); RetTyVTs.push_back(MVT::Other); - SDNode *NC = DAG.getCall(RetTyVTs, Tmp1, Tmp2, Ops); + SDNode *NC = DAG.getCall(RetTyVTs, Tmp1, Tmp2, Ops, + Node->getOpcode() == ISD::TAILCALL); Result = SDOperand(NC, 0); // Insert the new chain mapping. @@ -2341,6 +2345,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ std::swap(Lo, Hi); break; } + case ISD::TAILCALL: case ISD::CALL: { SDOperand Chain = LegalizeOp(Node->getOperand(0)); // Legalize the chain. SDOperand Callee = LegalizeOp(Node->getOperand(1)); // Legalize the callee. @@ -2360,7 +2365,8 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ RetTyVTs.push_back(NVT); RetTyVTs.push_back(NVT); RetTyVTs.push_back(MVT::Other); - SDNode *NC = DAG.getCall(RetTyVTs, Chain, Callee, Ops); + SDNode *NC = DAG.getCall(RetTyVTs, Chain, Callee, Ops, + Node->getOpcode() == ISD::TAILCALL); Lo = SDOperand(NC, 0); Hi = SDOperand(NC, 1); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 79d41fca2a3..160afec63c5 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1690,6 +1690,7 @@ const char *SDNode::getOperationName() const { case ISD::BRCONDTWOWAY: return "brcondtwoway"; case ISD::RET: return "ret"; case ISD::CALL: return "call"; + case ISD::TAILCALL:return "tailcall"; case ISD::CALLSEQ_START: return "callseq_start"; case ISD::CALLSEQ_END: return "callseq_end";