aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-08-30 00:23:21 +0000
committerDale Johannesen <dalej@apple.com>2007-08-30 00:23:21 +0000
commitbbe2b709480f1b89d9ac4d42c2c29e7c29dca3bc (patch)
treedf18d3207060fa0327a208f95cf643e386a3de7d /include
parente3d7f93f9f90611f886deb045b5aaf4ca9e99bb2 (diff)
downloadexternal_llvm-bbe2b709480f1b89d9ac4d42c2c29e7c29dca3bc.zip
external_llvm-bbe2b709480f1b89d9ac4d42c2c29e7c29dca3bc.tar.gz
external_llvm-bbe2b709480f1b89d9ac4d42c2c29e7c29dca3bc.tar.bz2
Change LegalFPImmediates to use APFloat.
Add APFloat interfaces to ConstantFP, SelectionDAG. Fix integer bit in double->APFloat conversion. Convert LegalizeDAG to use APFloat interface in ConstantFPSDNode uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41587 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/SelectionDAG.h5
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h2
-rw-r--r--include/llvm/Constants.h22
-rw-r--r--include/llvm/Target/TargetLowering.h17
4 files changed, 40 insertions, 6 deletions
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 9388df1..ccda26f 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -174,9 +174,14 @@ public:
return getConstant(Val, VT, true);
}
SDOperand getConstantFP(double Val, MVT::ValueType VT, bool isTarget = false);
+ SDOperand getConstantFP(const APFloat& Val, MVT::ValueType VT,
+ bool isTarget = false);
SDOperand getTargetConstantFP(double Val, MVT::ValueType VT) {
return getConstantFP(Val, VT, true);
}
+ SDOperand getTargetConstantFP(const APFloat& Val, MVT::ValueType VT) {
+ return getConstantFP(Val, VT, true);
+ }
SDOperand getGlobalAddress(const GlobalValue *GV, MVT::ValueType VT,
int offset = 0, bool isTargetGA = false);
SDOperand getTargetGlobalAddress(const GlobalValue *GV, MVT::ValueType VT,
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index fed77a5..d2c2fa2 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -1182,6 +1182,8 @@ public:
}
bool isExactlyValue(const APFloat& V) const;
+ bool isValueValidForType(MVT::ValueType VT, const APFloat& Val);
+
static bool classof(const ConstantFPSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::ConstantFP ||
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 4aa5afb..86b4daa 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -218,12 +218,20 @@ class ConstantFP : public Constant {
ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
protected:
ConstantFP(const Type *Ty, double V);
+ ConstantFP(const Type *Ty, const APFloat& V);
public:
/// get() - Static factory methods - Return objects of the specified value
static ConstantFP *get(const Type *Ty, double V);
+ static ConstantFP *get(const Type *Ty, const APFloat& V);
/// isValueValidForType - return true if Ty is big enough to represent V.
- static bool isValueValidForType(const Type *Ty, double V);
+ static bool isValueValidForType(const Type *Ty, const APFloat& V);
+ static bool isValueValidForType(const Type *Ty, double V) {
+ if (Ty == Type::FloatTy)
+ return isValueValidForType(Ty, APFloat((float)V));
+ else
+ return isValueValidForType(Ty, APFloat(V));
+ }
inline double getValue() const {
if (&Val.getSemantics() == &APFloat::IEEEdouble)
return Val.convertToDouble();
@@ -232,6 +240,7 @@ public:
else
assert(0);
}
+ inline const APFloat& getValueAPF() const { return Val; }
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue. Don't depend on == for doubles to tell us it's zero, it
@@ -242,8 +251,15 @@ public:
/// it returns true for things that are clearly not equal, like -0.0 and 0.0.
/// As such, this method can be used to do an exact bit-for-bit comparison of
/// two floating point values.
- bool isExactlyValue(double V) const;
-
+ bool isExactlyValue(const APFloat& V) const;
+ bool isExactlyValue(double V) const {
+ if (&Val.getSemantics() == &APFloat::IEEEdouble)
+ return isExactlyValue(APFloat(V));
+ else if (&Val.getSemantics() == &APFloat::IEEEsingle)
+ return isExactlyValue(APFloat((float)V));
+ else
+ assert(0);
+ }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantFP *) { return true; }
static bool classof(const Value *V) {
diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h
index ed97a93..f2f5bba 100644
--- a/include/llvm/Target/TargetLowering.h
+++ b/include/llvm/Target/TargetLowering.h
@@ -24,6 +24,7 @@
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/RuntimeLibcalls.h"
+#include "llvm/ADT/APFloat.h"
#include <map>
#include <vector>
@@ -220,7 +221,7 @@ public:
unsigned &NumIntermediates,
MVT::ValueType &RegisterVT) const;
- typedef std::vector<double>::const_iterator legal_fpimm_iterator;
+ typedef std::vector<APFloat>::const_iterator legal_fpimm_iterator;
legal_fpimm_iterator legal_fpimm_begin() const {
return LegalFPImmediates.begin();
}
@@ -781,8 +782,18 @@ protected:
/// addLegalFPImmediate - Indicate that this target can instruction select
/// the specified FP immediate natively.
- void addLegalFPImmediate(double Imm) {
+ void addLegalFPImmediate(const APFloat& Imm) {
+ // Incoming constants are expected to be double. We also add
+ // the float version. It is expected that all constants are exactly
+ // representable as floats.
+ assert(&Imm.getSemantics() == &APFloat::IEEEdouble);
+ APFloat Immf = APFloat(Imm);
+ // Rounding mode is not supposed to matter here...
+ if (Immf.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven) !=
+ APFloat::opOK)
+ assert(0);
LegalFPImmediates.push_back(Imm);
+ LegalFPImmediates.push_back(Immf);
}
/// setTargetDAGCombine - Targets should invoke this method for each target
@@ -1118,7 +1129,7 @@ private:
ValueTypeActionImpl ValueTypeActions;
- std::vector<double> LegalFPImmediates;
+ std::vector<APFloat> LegalFPImmediates;
std::vector<std::pair<MVT::ValueType,
TargetRegisterClass*> > AvailableRegClasses;