LegalizeTypes support for FP_ROUND and FP_EXTEND
authorDuncan Sands <baldrick@free.fr>
Tue, 8 Jul 2008 10:50:55 +0000 (10:50 +0000)
committerDuncan Sands <baldrick@free.fr>
Tue, 8 Jul 2008 10:50:55 +0000 (10:50 +0000)
soft float.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53231 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
lib/CodeGen/SelectionDAG/LegalizeTypes.h

index 4b0d572cd0f76fe9dc1a2900722b13f0be23fc40..f8340ccc1f686e4a78df0b2cefd897d1873d9921 100644 (file)
@@ -66,7 +66,7 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
     cerr << "SoftenFloatResult #" << ResNo << ": ";
     N->dump(&DAG); cerr << "\n";
 #endif
-    assert(0 && "Do not know how to convert the result of this operator!");
+    assert(0 && "Do not know how to soften the result of this operator!");
     abort();
 
     case ISD::BIT_CONVERT: R = SoftenFloatRes_BIT_CONVERT(N); break;
@@ -75,6 +75,8 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
       R = SoftenFloatRes_ConstantFP(cast<ConstantFPSDNode>(N));
       break;
     case ISD::FCOPYSIGN:   R = SoftenFloatRes_FCOPYSIGN(N); break;
+    case ISD::FP_EXTEND:   R = SoftenFloatRes_FP_EXTEND(N); break;
+    case ISD::FP_ROUND:    R = SoftenFloatRes_FP_ROUND(N); break;
     case ISD::LOAD:        R = SoftenFloatRes_LOAD(N); break;
     case ISD::SINT_TO_FP:
     case ISD::UINT_TO_FP:  R = SoftenFloatRes_XINT_TO_FP(N); break;
@@ -169,6 +171,46 @@ SDOperand DAGTypeLegalizer::SoftenFloatRes_FMUL(SDNode *N) {
                      NVT, Ops, 2, false);
 }
 
+SDOperand DAGTypeLegalizer::SoftenFloatRes_FP_EXTEND(SDNode *N) {
+  MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+  SDOperand Op = N->getOperand(0);
+
+  RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
+  switch (Op.getValueType().getSimpleVT()) {
+  default:
+    assert(false && "Unsupported FP_EXTEND!");
+  case MVT::f32:
+    switch (N->getValueType(0).getSimpleVT()) {
+    default:
+      assert(false && "Unsupported FP_EXTEND!");
+    case MVT::f64:
+      LC = RTLIB::FPEXT_F32_F64;
+    }
+  }
+
+  return MakeLibCall(LC, NVT, &Op, 1, false);
+}
+
+SDOperand DAGTypeLegalizer::SoftenFloatRes_FP_ROUND(SDNode *N) {
+  MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+  SDOperand Op = N->getOperand(0);
+
+  RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
+  switch (Op.getValueType().getSimpleVT()) {
+  default:
+    assert(false && "Unsupported FP_ROUND!");
+  case MVT::f64:
+    switch (N->getValueType(0).getSimpleVT()) {
+    default:
+      assert(false && "Unsupported FP_ROUND!");
+    case MVT::f32:
+      LC = RTLIB::FPROUND_F64_F32;
+    }
+  }
+
+  return MakeLibCall(LC, NVT, &Op, 1, false);
+}
+
 SDOperand DAGTypeLegalizer::SoftenFloatRes_FSUB(SDNode *N) {
   MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
   SDOperand Ops[2] = { GetSoftenedFloat(N->getOperand(0)),
@@ -323,7 +365,7 @@ bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
       cerr << "SoftenFloatOperand Op #" << OpNo << ": ";
       N->dump(&DAG); cerr << "\n";
 #endif
-      assert(0 && "Do not know how to convert this operator's operand!");
+      assert(0 && "Do not know how to soften this operator's operand!");
       abort();
 
     case ISD::BIT_CONVERT: Res = SoftenFloatOp_BIT_CONVERT(N); break;
index 3eba15beb3dcb48d39b79b42e4d6669612f13057..22c4f63e3a8b11364867ab94e6d0b47dcaed9517 100644 (file)
@@ -334,6 +334,8 @@ private:
   SDOperand SoftenFloatRes_FADD(SDNode *N);
   SDOperand SoftenFloatRes_FCOPYSIGN(SDNode *N);
   SDOperand SoftenFloatRes_FMUL(SDNode *N);
+  SDOperand SoftenFloatRes_FP_EXTEND(SDNode *N);
+  SDOperand SoftenFloatRes_FP_ROUND(SDNode *N);
   SDOperand SoftenFloatRes_FSUB(SDNode *N);
   SDOperand SoftenFloatRes_LOAD(SDNode *N);
   SDOperand SoftenFloatRes_XINT_TO_FP(SDNode *N);