diff options
author | Dale Johannesen <dalej@apple.com> | 2007-08-24 00:56:33 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2007-08-24 00:56:33 +0000 |
commit | 343e770983dcf53a1ea2dfca4e04d28ebc41138a (patch) | |
tree | 7a47d5e48fde4a3990a915df06776a2122625610 /include/llvm/Constants.h | |
parent | 57e4785123d830cfaa827474485596c9943cd2ae (diff) | |
download | llvm-343e770983dcf53a1ea2dfca4e04d28ebc41138a.tar.gz llvm-343e770983dcf53a1ea2dfca4e04d28ebc41138a.tar.bz2 llvm-343e770983dcf53a1ea2dfca4e04d28ebc41138a.tar.xz |
Change internal representation of ConstantFP to use APFloat.
Interface to rest of the compiler unchanged, as yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r-- | include/llvm/Constants.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index bb32a1b730..4aa5afbcf9 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -23,6 +23,7 @@ #include "llvm/Constant.h" #include "llvm/Type.h" #include "llvm/ADT/APInt.h" +#include "llvm/ADT/APFloat.h" namespace llvm { @@ -213,7 +214,7 @@ private: /// ConstantFP - Floating Point Values [float, double] /// class ConstantFP : public Constant { - double Val; + APFloat Val; ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT protected: ConstantFP(const Type *Ty, double V); @@ -223,7 +224,14 @@ public: /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, double V); - inline double getValue() const { return Val; } + inline double getValue() const { + if (&Val.getSemantics() == &APFloat::IEEEdouble) + return Val.convertToDouble(); + else if (&Val.getSemantics() == &APFloat::IEEEsingle) + return (double)Val.convertToFloat(); + else + assert(0); + } /// 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 |