Add a second ValueType argument to isFPImmLegal.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 28 Oct 2009 01:43:28 +0000 (01:43 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 28 Oct 2009 01:43:28 +0000 (01:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85361 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/Target/Alpha/AlphaISelLowering.cpp
lib/Target/Alpha/AlphaISelLowering.h
lib/Target/Mips/MipsISelLowering.cpp
lib/Target/Mips/MipsISelLowering.h
lib/Target/SystemZ/SystemZISelLowering.cpp
lib/Target/SystemZ/SystemZISelLowering.h
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h

index 286651e9900a7f89cd5cc1de602dc35e312bf150..84662d2eac2e2e3e39a61e13ffa317c50ef26644 100644 (file)
@@ -328,7 +328,7 @@ public:
   /// isFPImmLegal - Returns true if the target can instruction select the
   /// specified FP immediate natively. If false, the legalizer will materialize
   /// the FP immediate as a load from a constant pool.
-  virtual bool isFPImmLegal(const APFloat &Imm) const {
+  virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const {
     return false;
   }
   
index e41175623aee94b6ebcc7445630b2f7998d4e49e..f389f7f0c9df5c6e0688a3f44edec70e2a2d7055 100644 (file)
@@ -2574,7 +2574,7 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node,
     ConstantFPSDNode *CFP = cast<ConstantFPSDNode>(Node);
     // Check to see if this FP immediate is already legal.
     // If this is a legal constant, turn it into a TargetConstantFP node.
-    if (TLI.isFPImmLegal(CFP->getValueAPF()))
+    if (TLI.isFPImmLegal(CFP->getValueAPF(), Node->getValueType(0)))
       Results.push_back(SDValue(Node, 0));
     else
       Results.push_back(ExpandConstantFP(CFP, true, DAG, TLI));
index b2b738db2eb2bdbd336944bd9a8d104543fd85f0..cb03a6fa2027dd5d95cb23ff56cbf0feba472b0d 100644 (file)
@@ -915,7 +915,9 @@ AlphaTargetLowering::isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
   return false;
 }
 
-bool AlphaTargetLowering::isFPImmLegal(const APFloat &Imm) const {
+bool AlphaTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
+  if (VT != MVT::f32 && VT != MVT::f64)
+    return false;
   // +0.0   F31
   // +0.0f  F31
   // -0.0  -F31
index fbffbed939a0afd74c4b57b805d1b56cc352061d..b204faf8cff10d8f3a2f8c8d3275e64e58303096 100644 (file)
@@ -105,7 +105,7 @@ namespace llvm {
     /// isFPImmLegal - Returns true if the target can instruction select the
     /// specified FP immediate natively. If false, the legalizer will
     /// materialize the FP immediate as a load from a constant pool.
-    virtual bool isFPImmLegal(const APFloat &Imm) const;
+    virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
 
   private:
     // Helpers for custom lowering.
index 48d1cdc08af000e39aeb68bdd339e404315ab1cb..61da8f84c61f97be190028212807674f9170c976 100644 (file)
@@ -1222,6 +1222,8 @@ MipsTargetLowering::isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
   return false;
 }
 
-bool MipsTargetLowering::isFPImmLegal(const APFloat &Imm) const {
+bool MipsTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
+  if (VT != MVT::f32 && VT != MVT::f64)
+    return false;
   return Imm.isZero();
 }
index 2765295528f8068362d5f6fe58191d0a0037b2ab..cacf4b59fcb7eb5f84560a76500685210a86da6d 100644 (file)
@@ -150,7 +150,7 @@ namespace llvm {
     /// isFPImmLegal - Returns true if the target can instruction select the
     /// specified FP immediate natively. If false, the legalizer will
     /// materialize the FP immediate as a load from a constant pool.
-    virtual bool isFPImmLegal(const APFloat &Imm) const;
+    virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
   };
 }
 
index 3a91df06bde7dd948f24eb98e7498a63cce4af01..5c8cae0cd763f639b4acfd3592f4aee4e1519953 100644 (file)
@@ -170,8 +170,8 @@ SDValue SystemZTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) {
   }
 }
 
-bool SystemZTargetLowering::isFPImmLegal(const APFloat &Imm) const {
-  if (UseSoftFloat)
+bool SystemZTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
+  if (UseSoftFloat || (VT != MVT::f32 && VT != MVT::f64))
     return false;
 
   // +0.0  lzer
index 76af03de0ad5e55176b67b2dacfc1f94ea8dcaea..5bf1ed68c4c7859d6f7fd5099cc5efbb67fdc407 100644 (file)
@@ -92,7 +92,7 @@ namespace llvm {
     /// isFPImmLegal - Returns true if the target can instruction select the
     /// specified FP immediate natively. If false, the legalizer will
     /// materialize the FP immediate as a load from a constant pool.
-    virtual bool isFPImmLegal(const APFloat &Imm) const;
+    virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
 
   private:
     SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
index 83ede5dd4aa6c50f0101de0bfe8168c749709b7f..22eff5e77457a5601d708c521607044263a4cf1a 100644 (file)
@@ -2313,7 +2313,7 @@ static bool hasFPCMov(unsigned X86CC) {
 /// isFPImmLegal - Returns true if the target can instruction select the
 /// specified FP immediate natively. If false, the legalizer will
 /// materialize the FP immediate as a load from a constant pool.
-bool X86TargetLowering::isFPImmLegal(const APFloat &Imm) const {
+bool X86TargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
   for (unsigned i = 0, e = LegalFPImmediates.size(); i != e; ++i) {
     if (Imm.bitwiseIsEqual(LegalFPImmediates[i]))
       return true;
index 3d334a064b29aef8a927bfdb1be11698a09d9e6e..a02a3a5d6c2b11b9bba8ee02ed1719b5a262e766 100644 (file)
@@ -502,7 +502,7 @@ namespace llvm {
     /// isFPImmLegal - Returns true if the target can instruction select the
     /// specified FP immediate natively. If false, the legalizer will
     /// materialize the FP immediate as a load from a constant pool.
-    virtual bool isFPImmLegal(const APFloat &Imm) const;
+    virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
 
     /// isShuffleMaskLegal - Targets can use this to indicate that they only
     /// support *some* VECTOR_SHUFFLE operations, those with specific masks.