[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Evan Cheng evan.cheng at apple.com
Tue Dec 12 17:58:10 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.436 -> 1.437
---
Log message:

Expand f32 / f64 to i32 / i64 conversion to soft-fp library calls.

---
Diffs of the changes:  (+23 -2)

 LegalizeDAG.cpp |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.436 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.437
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.436	Tue Dec 12 16:19:28 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Tue Dec 12 19:57:55 2006
@@ -2860,8 +2860,29 @@
         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));






More information about the llvm-commits mailing list