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

Chris Lattner lattner at cs.uiuc.edu
Sun Jan 16 11:47:03 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.37 -> 1.38
---
Log message:

Implement legalize of call nodes.


---
Diffs of the changes:  (+17 -3)

Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.37 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.38
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.37	Sun Jan 16 01:29:19 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Sun Jan 16 13:46:48 2005
@@ -907,9 +907,6 @@
     std::cerr << "NODE: "; Node->dump(); std::cerr << "\n";
     assert(0 && "Do not know how to promote this operator!");
     abort();
-  case ISD::CALL:
-    assert(0 && "Target's LowerCallTo implementation is buggy, returning value"
-           " types that are not supported by the target!");
   case ISD::Constant:
     Result = DAG.getNode(ISD::ZERO_EXTEND, NVT, Op);
     assert(isa<ConstantSDNode>(Result) && "Didn't constant fold zext?");
@@ -1092,6 +1089,23 @@
     Tmp3 = PromoteOp(Node->getOperand(2));   // Legalize the op1
     Result = DAG.getNode(ISD::SELECT, NVT, Tmp1, Tmp2, Tmp3);
     break;
+  case ISD::CALL: {
+    Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
+    Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the callee.
+
+    assert(Node->getNumValues() == 2 && Op.ResNo == 0 &&
+           "Can only promote single result calls");
+    std::vector<MVT::ValueType> RetTyVTs;
+    RetTyVTs.reserve(2);
+    RetTyVTs.push_back(NVT);
+    RetTyVTs.push_back(MVT::Other);
+    SDNode *NC = DAG.getCall(RetTyVTs, Tmp1, Tmp2);
+    Result = SDOperand(NC, 0);
+
+    // Insert the new chain mapping.
+    AddLegalizedOperand(Op.getValue(1), Result.getValue(1));
+    break;
+  } 
   }
 
   assert(Result.Val && "Didn't set a result!");






More information about the llvm-commits mailing list