Use a linked data structure for the uses lists of an SDNode, just like
[oota-llvm.git] / lib / CodeGen / SelectionDAG / LegalizeTypes.h
index 1c20969b9dca6eaa55aca8b32649bcfe527417f4..48d4b391fb5a5d80f7d689e975cb093bf73e2d09 100644 (file)
@@ -62,6 +62,7 @@ private:
     Legal,      // The target natively supports this type.
     Promote,    // This type should be executed in a larger type.
     Expand,     // This type should be split into two types of half the size.
+    FloatToInt, // Convert a floating point type to an integer of the same size.
     Scalarize,  // Replace this one-element vector type with its element type.
     Split       // This vector type should be split into smaller vectors.
   };
@@ -85,14 +86,20 @@ private:
     case TargetLowering::Promote:
       return Promote;
     case TargetLowering::Expand:
-      // Expand can mean 1) split integer in half 2) scalarize single-element
-      // vector 3) split vector in two.
-      if (!MVT::isVector(VT))
-        return Expand;
-      else if (MVT::getVectorNumElements(VT) == 1)
+      // Expand can mean
+      // 1) split scalar in half, 2) convert a float to an integer,
+      // 3) scalarize a single-element vector, 4) split a vector in two.
+      if (!MVT::isVector(VT)) {
+        if (MVT::getSizeInBits(VT) ==
+            MVT::getSizeInBits(TLI.getTypeToTransformTo(VT)))
+          return FloatToInt;
+        else
+          return Expand;
+      } else if (MVT::getVectorNumElements(VT) == 1) {
         return Scalarize;
-      else
+      } else {
         return Split;
+      }
     }
   }
 
@@ -103,23 +110,27 @@ private:
 
   /// PromotedNodes - For nodes that are below legal width, this map indicates
   /// what promoted value to use.
-  DenseMap<SDOperand, SDOperand> PromotedNodes;
+  DenseMap<SDOperandImpl, SDOperand> PromotedNodes;
   
   /// ExpandedNodes - For nodes that need to be expanded this map indicates
   /// which operands are the expanded version of the input.
-  DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedNodes;
+  DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> > ExpandedNodes;
+
+  /// FloatToIntedNodes - For floating point nodes converted to integers of
+  /// the same size, this map indicates the converted value to use.
+  DenseMap<SDOperandImpl, SDOperand> FloatToIntedNodes;
 
   /// ScalarizedNodes - For nodes that are <1 x ty>, this map indicates the
   /// scalar value of type 'ty' to use.
-  DenseMap<SDOperand, SDOperand> ScalarizedNodes;
+  DenseMap<SDOperandImpl, SDOperand> ScalarizedNodes;
 
   /// SplitNodes - For nodes that need to be split this map indicates
   /// which operands are the expanded version of the input.
-  DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > SplitNodes;
+  DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> > SplitNodes;
   
   /// ReplacedNodes - For nodes that have been replaced with another,
   /// indicates the replacement node to use.
-  DenseMap<SDOperand, SDOperand> ReplacedNodes;
+  DenseMap<SDOperandImpl, SDOperand> ReplacedNodes;
 
   /// Worklist - This defines a worklist of nodes to process.  In order to be
   /// pushed onto this worklist, all operands of a node must have already been
@@ -152,9 +163,13 @@ private:
   void RemapNode(SDOperand &N);
 
   // Common routines.
+  SDOperand BitConvertToInteger(SDOperand Op);
   SDOperand CreateStackStoreLoad(SDOperand Op, MVT::ValueType DestVT);
   SDOperand HandleMemIntrinsic(SDNode *N);
-  void SplitOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi);
+  SDOperand JoinIntegers(SDOperand Lo, SDOperand Hi);
+  void SplitInteger(SDOperand Op, SDOperand &Lo, SDOperand &Hi);
+  void SplitInteger(SDOperand Op, MVT::ValueType LoVT, MVT::ValueType HiVT,
+                    SDOperand &Lo, SDOperand &Hi);
 
   //===--------------------------------------------------------------------===//
   // Promotion Support: LegalizeTypesPromote.cpp
@@ -278,6 +293,28 @@ private:
   void ExpandSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS,
                            ISD::CondCode &CCCode);
   
+  //===--------------------------------------------------------------------===//
+  // Float to Integer Conversion Support: LegalizeTypesFloatToInt.cpp
+  //===--------------------------------------------------------------------===//
+
+  SDOperand GetIntegerOp(SDOperand Op) {
+    SDOperand &IntegerOp = FloatToIntedNodes[Op];
+    RemapNode(IntegerOp);
+    assert(IntegerOp.Val && "Operand wasn't converted to integer?");
+    return IntegerOp;
+  }
+  void SetIntegerOp(SDOperand Op, SDOperand Result);
+
+  // Result Float to Integer Conversion.
+  void FloatToIntResult(SDNode *N, unsigned OpNo);
+  SDOperand FloatToIntRes_BIT_CONVERT(SDNode *N);
+  SDOperand FloatToIntRes_BUILD_PAIR(SDNode *N);
+  SDOperand FloatToIntRes_FCOPYSIGN(SDNode *N);
+
+  // Operand Float to Integer Conversion.
+  bool FloatToIntOperand(SDNode *N, unsigned OpNo);
+  SDOperand FloatToIntOp_BIT_CONVERT(SDNode *N);
+
   //===--------------------------------------------------------------------===//
   // Scalarization Support: LegalizeTypesScalarize.cpp
   //===--------------------------------------------------------------------===//
@@ -333,7 +370,7 @@ private:
   void SplitRes_FPOWI(SDNode *N, SDOperand &Lo, SDOperand &Hi);
   void SplitRes_SELECT(SDNode *N, SDOperand &Lo, SDOperand &Hi);
   
-  // Operand Vector Scalarization: <128 x ty> -> 2 x <64 x ty>.
+  // Operand Vector Splitting: <128 x ty> -> 2 x <64 x ty>.
   bool SplitOperand(SDNode *N, unsigned OpNo);
 
   SDOperand SplitOp_BIT_CONVERT(SDNode *N);