fold fp_round(fp_round(x)) -> fp_round(x).
[oota-llvm.git] / lib / CodeGen / SelectionDAG / LegalizeTypes.cpp
index f843957fd2170c3f6a225b7af124139e040e79f1..70d07ebf428ed0f6ec05b7ca8c4347a321387fd2 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Chris Lattner and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -68,8 +68,8 @@ void DAGTypeLegalizer::run() {
           ExpandResult(N, i);
         else if (MVT::getVectorNumElements(ResultVT) == 1)
           ScalarizeResult(N, i);     // Scalarize the single-element vector.
-        else         // Split the vector in half.
-          assert(0 && "Vector splitting not implemented");
+        else
+          SplitResult(N, i);         // Split the vector in half.
         goto NodeDone;
       } else {
         assert(Action == Legal && "Unknown action!");
@@ -96,8 +96,7 @@ void DAGTypeLegalizer::run() {
           // Scalarize the single-element vector.
           NeedsRevisit = ScalarizeOperand(N, i);
         } else {
-          // Split the vector in half.
-          assert(0 && "Vector splitting not implemented");
+          NeedsRevisit = SplitOperand(N, i); // Split the vector in half.
         }
         break;
       } else {
@@ -321,8 +320,7 @@ void DAGTypeLegalizer::GetExpandedOp(SDOperand Op, SDOperand &Lo,
   Hi = Entry.second;
 }
 
-void DAGTypeLegalizer::SetExpandedOp(SDOperand Op, SDOperand Lo, 
-                                     SDOperand Hi) {
+void DAGTypeLegalizer::SetExpandedOp(SDOperand Op, SDOperand Lo, SDOperand Hi) {
   // Remember that this is the result of the node.
   std::pair<SDOperand, SDOperand> &Entry = ExpandedNodes[Op];
   assert(Entry.first.Val == 0 && "Node already expanded");
@@ -336,6 +334,30 @@ void DAGTypeLegalizer::SetExpandedOp(SDOperand Op, SDOperand Lo,
     MarkNewNodes(Hi.Val);
 }
 
+void DAGTypeLegalizer::GetSplitOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi) {
+  std::pair<SDOperand, SDOperand> &Entry = SplitNodes[Op];
+  RemapNode(Entry.first);
+  RemapNode(Entry.second);
+  assert(Entry.first.Val && "Operand isn't split");
+  Lo = Entry.first;
+  Hi = Entry.second;
+}
+
+void DAGTypeLegalizer::SetSplitOp(SDOperand Op, SDOperand Lo, SDOperand Hi) {
+  // Remember that this is the result of the node.
+  std::pair<SDOperand, SDOperand> &Entry = SplitNodes[Op];
+  assert(Entry.first.Val == 0 && "Node already split");
+  Entry.first = Lo;
+  Entry.second = Hi;
+  
+  // Lo/Hi may have been newly allocated, if so, add nodeid's as relevant.
+  if (Lo.Val->getNodeId() == NewNode) 
+    MarkNewNodes(Lo.Val);
+  if (Hi.Val->getNodeId() == NewNode) 
+    MarkNewNodes(Hi.Val);
+}
+
+
 SDOperand DAGTypeLegalizer::CreateStackStoreLoad(SDOperand Op, 
                                                  MVT::ValueType DestVT) {
   // Create the stack frame object.