Expand f32 / f64 to i32 / i64 conversion to soft-fp library calls.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 13 Dec 2006 01:57:55 +0000 (01:57 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 13 Dec 2006 01:57:55 +0000 (01:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32523 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

index 2079259a5fa1d9ce2e531101e40ce20417cc8d2e..695e1970ff99672b876bf5cc59529fdcbc5d9db1 100644 (file)
@@ -2860,8 +2860,29 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
         break;
       }
       break;
-    case Expand:
-      assert(0 && "Shouldn't need to expand other operators here!");
+    case Expand: {
+      // Convert f32 / f64 to i32 / i64.
+      MVT::ValueType VT = Op.getValueType();
+      const char *FnName = 0;
+      switch (Node->getOpcode()) {
+      case ISD::FP_TO_SINT:
+        if (Node->getOperand(0).getValueType() == MVT::f32)
+          FnName = (VT == MVT::i32) ? "__fixsfsi" : "__fixsfdi";
+        else
+          FnName = (VT == MVT::i32) ? "__fixdfsi" : "__fixdfdi";
+        break;
+      case ISD::FP_TO_UINT:
+        if (Node->getOperand(0).getValueType() == MVT::f32)
+          FnName = (VT == MVT::i32) ? "__fixunssfsi" : "__fixunssfdi";
+        else
+          FnName = (VT == MVT::i32) ? "__fixunsdfsi" : "__fixunsdfdi";
+        break;
+      default: assert(0 && "Unreachable!");
+      }
+      SDOperand Dummy;
+      Result = ExpandLibCall(FnName, Node, Dummy);
+      break;
+    }
     case Promote:
       Tmp1 = PromoteOp(Node->getOperand(0));
       Result = DAG.UpdateNodeOperands(Result, LegalizeOp(Tmp1));