LegalizeTypes soft-float support for stores of a
authorDuncan Sands <baldrick@free.fr>
Mon, 7 Jul 2008 00:08:12 +0000 (00:08 +0000)
committerDuncan Sands <baldrick@free.fr>
Mon, 7 Jul 2008 00:08:12 +0000 (00:08 +0000)
float value.

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

include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
lib/CodeGen/SelectionDAG/LegalizeTypes.h

index caa077d00363ff3c71d46d09c1cc28696d58d992..0831d43f5d6928b68a39dbd1105c6d51da458eb5 100644 (file)
@@ -2150,8 +2150,10 @@ public:
 ///
 class StoreSDNode : public LSBaseSDNode {
   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
-    
-  // IsTruncStore - True if the op does a truncation before store.
+
+  // IsTruncStore - True if the op does a truncation before store.  For
+  // integers this is the same as doing a TRUNCATE and storing the result.
+  // For floats, it is the same as doing an FP_ROUND and storing the result.
   bool IsTruncStore;
 protected:
   friend class SelectionDAG;
index bfe2ce6d8832dedb395c4ba124b6bfbc2b17b09c..4b0d572cd0f76fe9dc1a2900722b13f0be23fc40 100644 (file)
@@ -331,6 +331,7 @@ bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
     case ISD::BR_CC:     Res = SoftenFloatOp_BR_CC(N); break;
     case ISD::SELECT_CC: Res = SoftenFloatOp_SELECT_CC(N); break;
     case ISD::SETCC:     Res = SoftenFloatOp_SETCC(N); break;
+    case ISD::STORE:     Res = SoftenFloatOp_STORE(N, OpNo); break;
     }
   }
 
@@ -496,6 +497,24 @@ SDOperand DAGTypeLegalizer::SoftenFloatOp_SETCC(SDNode *N) {
                                 DAG.getCondCode(CCCode));
 }
 
+SDOperand DAGTypeLegalizer::SoftenFloatOp_STORE(SDNode *N, unsigned OpNo) {
+  assert(ISD::isUNINDEXEDStore(N) && "Indexed store during type legalization!");
+  assert(OpNo == 1 && "Can only soften the stored value!");
+  StoreSDNode *ST = cast<StoreSDNode>(N);
+  SDOperand Val = ST->getValue();
+
+  if (ST->isTruncatingStore())
+    // Do an FP_ROUND followed by a non-truncating store.
+    Val = BitConvertToInteger(DAG.getNode(ISD::FP_ROUND, ST->getMemoryVT(),
+                                          Val, DAG.getIntPtrConstant(0)));
+  else
+    Val = GetSoftenedFloat(Val);
+
+  return DAG.getStore(ST->getChain(), Val, ST->getBasePtr(),
+                      ST->getSrcValue(), ST->getSrcValueOffset(),
+                      ST->isVolatile(), ST->getAlignment());
+}
+
 
 //===----------------------------------------------------------------------===//
 //  Float Result Expansion
index 041b25813727d9a7502947c5a92311912bd05e05..3eba15beb3dcb48d39b79b42e4d6669612f13057 100644 (file)
@@ -344,6 +344,7 @@ private:
   SDOperand SoftenFloatOp_BR_CC(SDNode *N);
   SDOperand SoftenFloatOp_SELECT_CC(SDNode *N);
   SDOperand SoftenFloatOp_SETCC(SDNode *N);
+  SDOperand SoftenFloatOp_STORE(SDNode *N, unsigned OpNo);
 
   void SoftenSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS,
                            ISD::CondCode &CCCode);