Remove integer promotion support for FP_EXTEND
[oota-llvm.git] / lib / CodeGen / SelectionDAG / LegalizeTypes.cpp
index 0461634b748d2b2c0df5f70e5b04d5649b2e09a2..6876e9f94f81f167a5740fed34857a9a28fdc505 100644 (file)
@@ -31,7 +31,7 @@ void DAGTypeLegalizer::run() {
   // done.  Set it to null to avoid confusion.
   DAG.setRoot(SDValue());
 
-  // Walk all nodes in the graph, assigning them a NodeID of 'ReadyToProcess'
+  // Walk all nodes in the graph, assigning them a NodeId of 'ReadyToProcess'
   // (and remembering them) if they are leaves and assigning 'NewNode' if
   // non-leaves.
   for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(),
@@ -140,25 +140,25 @@ NodeDone:
     for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end();
          UI != E; ++UI) {
       SDNode *User = *UI;
-      int NodeID = User->getNodeId();
-      assert(NodeID != ReadyToProcess && NodeID != Processed &&
+      int NodeId = User->getNodeId();
+      assert(NodeId != ReadyToProcess && NodeId != Processed &&
              "Invalid node id for user of unprocessed node!");
 
       // This node has two options: it can either be a new node or its Node ID
       // may be a count of the number of operands it has that are not ready.
-      if (NodeID > 0) {
-        User->setNodeId(NodeID-1);
+      if (NodeId > 0) {
+        User->setNodeId(NodeId-1);
 
         // If this was the last use it was waiting on, add it to the ready list.
-        if (NodeID-1 == ReadyToProcess)
+        if (NodeId-1 == ReadyToProcess)
           Worklist.push_back(User);
         continue;
       }
 
       // Otherwise, this node is new: this is the first operand of it that
-      // became ready.  Its new NodeID is the number of operands it has minus 1
+      // became ready.  Its new NodeId is the number of operands it has minus 1
       // (as this node is now processed).
-      assert(NodeID == NewNode && "Unknown node ID!");
+      assert(NodeId == NewNode && "Unknown node ID!");
       User->setNodeId(User->getNumOperands()-1);
 
       // If the node only has a single operand, it is now ready.
@@ -340,7 +340,7 @@ namespace {
 
 
 /// ReplaceValueWith - The specified value was legalized to the specified other
-/// value.  If they are different, update the DAG and NodeIDs replacing any uses
+/// value.  If they are different, update the DAG and NodeIds replacing any uses
 /// of From to use To instead.
 void DAGTypeLegalizer::ReplaceValueWith(SDValue From, SDValue To) {
   if (From == To) return;
@@ -656,7 +656,7 @@ SDValue DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, MVT RetVT,
     Args.push_back(Entry);
   }
   SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
-                                           TLI.getPointerTy());
+                                         TLI.getPointerTy());
 
   const Type *RetTy = RetVT.getTypeForMVT();
   std::pair<SDValue,SDValue> CallInfo =
@@ -665,6 +665,26 @@ SDValue DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, MVT RetVT,
   return CallInfo.first;
 }
 
+/// LibCallify - Convert the node into a libcall with the same prototype.
+SDValue DAGTypeLegalizer::LibCallify(RTLIB::Libcall LC, SDNode *N,
+                                     bool isSigned) {
+  unsigned NumOps = N->getNumOperands();
+  if (NumOps == 0) {
+    return MakeLibCall(LC, N->getValueType(0), 0, 0, isSigned);
+  } else if (NumOps == 1) {
+    SDValue Op = N->getOperand(0);
+    return MakeLibCall(LC, N->getValueType(0), &Op, 1, isSigned);
+  } else if (NumOps == 2) {
+    SDValue Ops[2] = { N->getOperand(0), N->getOperand(1) };
+    return MakeLibCall(LC, N->getValueType(0), Ops, 2, isSigned);
+  }
+  SmallVector<SDValue, 8> Ops(NumOps);
+  for (unsigned i = 0; i < NumOps; ++i)
+    Ops[i] = N->getOperand(i);
+
+  return MakeLibCall(LC, N->getValueType(0), &Ops[0], NumOps, isSigned);
+}
+
 SDValue DAGTypeLegalizer::GetVectorElementPointer(SDValue VecPtr, MVT EltVT,
                                                   SDValue Index) {
   // Make sure the index type is big enough to compute in.