From 343e770983dcf53a1ea2dfca4e04d28ebc41138a Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Fri, 24 Aug 2007 00:56:33 +0000 Subject: 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 --- include/llvm/Constants.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include/llvm/Constants.h') 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 -- cgit v1.2.3