[llvm-commits] [llvm] r59025 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h

Mon P Wang wangmp at apple.com
Mon Nov 10 21:40:07 PST 2008


Author: wangmp
Date: Mon Nov 10 23:40:06 2008
New Revision: 59025

URL: http://llvm.org/viewvc/llvm-project?rev=59025&view=rev
Log:
Cleaned up and fix bugs in convert_rndsat node

Modified:
    llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=59025&r1=59024&r2=59025&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon Nov 10 23:40:06 2008
@@ -432,9 +432,10 @@
     BIT_CONVERT,
     
     // CONVERT_RNDSAT - This operator is used to support various conversions
-    // between various types (float, signed, unsigned) with rounding and
-    // saturation. NOTE: Avoid using this operator as most target don't support
-    // it and they might be removed. It takes the following arguments:
+    // between various types (float, signed, unsigned and vectors of those
+    // types) with rounding and saturation. NOTE: Avoid using this operator as
+    // most target don't support it and the operator might be removed in the
+    // future. It takes the following arguments:
     //   0) value
     //   1) dest type (type to convert to)
     //   2) src type (type to convert from)

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=59025&r1=59024&r2=59025&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Mon Nov 10 23:40:06 2008
@@ -59,6 +59,8 @@
   case ISD::BSWAP:       Result = PromoteIntRes_BSWAP(N); break;
   case ISD::BUILD_PAIR:  Result = PromoteIntRes_BUILD_PAIR(N); break;
   case ISD::Constant:    Result = PromoteIntRes_Constant(N); break;
+  case ISD::CONVERT_RNDSAT:
+                         Result = PromoteIntRes_CONVERT_RNDSAT(N); break;
   case ISD::CTLZ:        Result = PromoteIntRes_CTLZ(N); break;
   case ISD::CTPOP:       Result = PromoteIntRes_CTPOP(N); break;
   case ISD::CTTZ:        Result = PromoteIntRes_CTTZ(N); break;
@@ -272,6 +274,41 @@
   return Result;
 }
 
+SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_RNDSAT(SDNode *N) {
+  ISD::CvtCode CvtCode = cast<CvtRndSatSDNode>(N)->getCvtCode();
+  assert ((CvtCode == ISD::CVT_SS || CvtCode == ISD::CVT_SU ||
+           CvtCode == ISD::CVT_US || CvtCode == ISD::CVT_UU ||
+           CvtCode == ISD::CVT_SF || CvtCode == ISD::CVT_UF) &&
+          "can only promote integers");
+  SDValue InOp = N->getOperand(0);
+
+  MVT InVT = InOp.getValueType();
+  MVT OutVT = TLI.getTypeToTransformTo(N->getValueType(0));
+  switch (getTypeAction(InVT)) {
+  default:
+    assert(false && "Unknown type action!");
+    break;
+  case Legal:
+    break;
+  case PromoteInteger:
+    return DAG.getConvertRndSat(OutVT, GetPromotedInteger(InOp),
+                                N->getOperand(1), N->getOperand(2),
+                                N->getOperand(3), N->getOperand(4), CvtCode);
+    break;
+  case SoftenFloat:
+  case ExpandInteger:
+  case ExpandFloat:
+    break;
+  case ScalarizeVector:
+  case SplitVector:
+    assert(false && "can not convert a vector to a scalar!");
+  }
+  return DAG.getConvertRndSat(OutVT, InOp,
+                              N->getOperand(1), N->getOperand(2),
+                              N->getOperand(3), N->getOperand(4), CvtCode);
+}
+
+
 SDValue DAGTypeLegalizer::PromoteIntRes_CTLZ(SDNode *N) {
   SDValue Op = GetPromotedInteger(N->getOperand(0));
   MVT OVT = N->getValueType(0);
@@ -610,8 +647,7 @@
     case ISD::ZERO_EXTEND:  Res = PromoteIntOp_ZERO_EXTEND(N); break;
 
     case ISD::SINT_TO_FP:
-    case ISD::UINT_TO_FP:      Res = PromoteIntOp_INT_TO_FP(N); break;
-    case ISD::CONVERT_RNDSAT:  Res = PromoteIntOp_CONVERT_RNDSAT(N); break;
+    case ISD::UINT_TO_FP:     Res = PromoteIntOp_INT_TO_FP(N); break;
     }
   }
 
@@ -814,21 +850,6 @@
   return DAG.UpdateNodeOperands(SDValue(N, 0), In);
 }
 
-SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_RNDSAT(SDNode *N) {
-  MVT OutVT = TLI.getTypeToTransformTo(N->getValueType(0));
-  ISD::CvtCode CvtCode = cast<CvtRndSatSDNode>(N)->getCvtCode();
-  assert ((CvtCode == ISD::CVT_SS || CvtCode == ISD::CVT_SU ||
-           CvtCode == ISD::CVT_US || CvtCode == ISD::CVT_UU ||
-           CvtCode == ISD::CVT_SF || CvtCode == ISD::CVT_UF) &&
-          "can only promote integers");
-  SDValue In = DAG.getConvertRndSat(OutVT,N->getOperand(0),
-                                    N->getOperand(1), N->getOperand(2),
-                                    N->getOperand(3), N->getOperand(4), CvtCode);
-  return DAG.UpdateNodeOperands(SDValue(N, 0), In);
-}
-
-
-
 SDValue DAGTypeLegalizer::PromoteIntOp_MEMBARRIER(SDNode *N) {
   SDValue NewOps[6];
   NewOps[0] = N->getOperand(0);

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=59025&r1=59024&r2=59025&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Mon Nov 10 23:40:06 2008
@@ -231,6 +231,7 @@
   SDValue PromoteIntRes_BSWAP(SDNode *N);
   SDValue PromoteIntRes_BUILD_PAIR(SDNode *N);
   SDValue PromoteIntRes_Constant(SDNode *N);
+  SDValue PromoteIntRes_CONVERT_RNDSAT(SDNode *N);
   SDValue PromoteIntRes_CTLZ(SDNode *N);
   SDValue PromoteIntRes_CTPOP(SDNode *N);
   SDValue PromoteIntRes_CTTZ(SDNode *N);
@@ -259,7 +260,6 @@
   SDValue PromoteIntOp_BR_CC(SDNode *N, unsigned OpNo);
   SDValue PromoteIntOp_BRCOND(SDNode *N, unsigned OpNo);
   SDValue PromoteIntOp_BUILD_VECTOR(SDNode *N);
-  SDValue PromoteIntOp_CONVERT_RNDSAT(SDNode *N);
   SDValue PromoteIntOp_FP_EXTEND(SDNode *N);
   SDValue PromoteIntOp_FP_ROUND(SDNode *N);
   SDValue PromoteIntOp_INT_TO_FP(SDNode *N);





More information about the llvm-commits mailing list