long double 9 of N.  This finishes up the X86-32 bits
(constants are still not handled).  Adds ConvertActions
to control fp-to-fp conversions (these are currently
defaulted for all other targets, so no changes there).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40958 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 5c8c9e3..8187b3c 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3194,33 +3194,58 @@
     }
     break;
 
-  case ISD::FP_ROUND:
-    if (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0)) == 
-        TargetLowering::Expand) {
-      // The only way we can lower this is to turn it into a TRUNCSTORE,
-      // EXTLOAD pair, targetting a temporary location (a stack slot).
+  case ISD::FP_EXTEND: {
+      MVT::ValueType newVT = Op.getValueType();
+      MVT::ValueType oldVT = Op.getOperand(0).getValueType();
+      if (TLI.getConvertAction(oldVT, newVT) == TargetLowering::Expand) {
+        // The only way we can lower this is to turn it into a STORE,
+        // EXTLOAD pair, targetting a temporary location (a stack slot).
 
-      // NOTE: there is a choice here between constantly creating new stack
-      // slots and always reusing the same one.  We currently always create
-      // new ones, as reuse may inhibit scheduling.
-      MVT::ValueType VT = Op.getValueType();    // 32
-      const Type *Ty = MVT::getTypeForValueType(VT);
-      uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
-      unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
-      MachineFunction &MF = DAG.getMachineFunction();
-      int SSFI =
-        MF.getFrameInfo()->CreateStackObject(TySize, Align);
-      SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
-      Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0),
-                                 StackSlot, NULL, 0, VT);
-      Result = DAG.getLoad(VT, Result, StackSlot, NULL, 0, VT);
-      break;
+        // NOTE: there is a choice here between constantly creating new stack
+        // slots and always reusing the same one.  We currently always create
+        // new ones, as reuse may inhibit scheduling.
+        const Type *Ty = MVT::getTypeForValueType(oldVT);
+        uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+        unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
+        MachineFunction &MF = DAG.getMachineFunction();
+        int SSFI =
+          MF.getFrameInfo()->CreateStackObject(TySize, Align);
+        SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
+        Result = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0),
+                                   StackSlot, NULL, 0);
+        Result = DAG.getExtLoad(ISD::EXTLOAD, newVT,
+                                   Result, StackSlot, NULL, 0, oldVT);
+        break;
+      }
+    }
+    // FALL THROUGH (to ANY_EXTEND case)
+  case ISD::FP_ROUND: {
+      MVT::ValueType newVT = Op.getValueType();
+      MVT::ValueType oldVT = Op.getOperand(0).getValueType();
+      if (TLI.getConvertAction(oldVT, newVT) == TargetLowering::Expand) {
+        // The only way we can lower this is to turn it into a TRUNCSTORE,
+        // LOAD pair, targetting a temporary location (a stack slot).
+
+        // NOTE: there is a choice here between constantly creating new stack
+        // slots and always reusing the same one.  We currently always create
+        // new ones, as reuse may inhibit scheduling.
+        const Type *Ty = MVT::getTypeForValueType(newVT);
+        uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+        unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
+        MachineFunction &MF = DAG.getMachineFunction();
+        int SSFI =
+          MF.getFrameInfo()->CreateStackObject(TySize, Align);
+        SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
+        Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0),
+                                   StackSlot, NULL, 0, newVT);
+        Result = DAG.getLoad(newVT, Result, StackSlot, NULL, 0, newVT);
+        break;
+      }
     }
     // FALL THROUGH
   case ISD::ANY_EXTEND:
   case ISD::ZERO_EXTEND:
   case ISD::SIGN_EXTEND:
-  case ISD::FP_EXTEND:
     switch (getTypeAction(Node->getOperand(0).getValueType())) {
     case Expand: assert(0 && "Shouldn't need to expand other operators here!");
     case Legal:
diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 1b7b436..2e91359 100644
--- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -129,6 +129,7 @@
   memset(LoadXActions, 0, sizeof(LoadXActions));
   memset(&StoreXActions, 0, sizeof(StoreXActions));
   memset(&IndexedModeActions, 0, sizeof(IndexedModeActions));
+  memset(&ConvertActions, 0, sizeof(ConvertActions));
 
   // Set all indexed load / store to expand.
   for (unsigned VT = 0; VT != (unsigned)MVT::LAST_VALUETYPE; ++VT) {