diff options
| author | John McCall <rjmccall@apple.com> | 2010-02-28 02:51:25 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-02-28 02:51:25 +0000 |
| commit | e12b73816b50bbe2cc54b8005d86c95413b4f465 (patch) | |
| tree | 167c037c24ea67c3d1d116f1ac9df701eb863a0e /include | |
| parent | 6281cda6737bcda0e924318ddcce28392001691e (diff) | |
| download | external_llvm-e12b73816b50bbe2cc54b8005d86c95413b4f465.zip external_llvm-e12b73816b50bbe2cc54b8005d86c95413b4f465.tar.gz external_llvm-e12b73816b50bbe2cc54b8005d86c95413b4f465.tar.bz2 | |
Teach APFloat how to create both QNaNs and SNaNs and with arbitrary-width
payloads. APFloat's internal folding routines always make QNaNs now,
instead of sometimes making QNaNs and sometimes SNaNs depending on the
type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97364 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
| -rw-r--r-- | include/llvm/ADT/APFloat.h | 32 | ||||
| -rw-r--r-- | include/llvm/ADT/APInt.h | 3 |
2 files changed, 32 insertions, 3 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index f81109a..861b7b9 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -173,11 +173,16 @@ namespace llvm { fcZero }; + enum uninitializedTag { + uninitialized + }; + // Constructors. APFloat(const fltSemantics &); // Default construct to 0.0 APFloat(const fltSemantics &, const StringRef &); APFloat(const fltSemantics &, integerPart); - APFloat(const fltSemantics &, fltCategory, bool negative, unsigned type=0); + APFloat(const fltSemantics &, fltCategory, bool negative); + APFloat(const fltSemantics &, uninitializedTag); explicit APFloat(double d); explicit APFloat(float f); explicit APFloat(const APInt &, bool isIEEE = false); @@ -199,7 +204,26 @@ namespace llvm { /// default. The value is truncated as necessary. static APFloat getNaN(const fltSemantics &Sem, bool Negative = false, unsigned type = 0) { - return APFloat(Sem, fcNaN, Negative, type); + if (type) { + APInt fill(64, type); + return getQNaN(Sem, Negative, &fill); + } else { + return getQNaN(Sem, Negative, 0); + } + } + + /// getQNan - Factory for QNaN values. + static APFloat getQNaN(const fltSemantics &Sem, + bool Negative = false, + const APInt *payload = 0) { + return makeNaN(Sem, false, Negative, payload); + } + + /// getSNan - Factory for SNaN values. + static APFloat getSNaN(const fltSemantics &Sem, + bool Negative = false, + const APInt *payload = 0) { + return makeNaN(Sem, true, Negative, payload); } /// getLargest - Returns the largest finite number in the given @@ -350,7 +374,9 @@ namespace llvm { opStatus modSpecials(const APFloat &); /* Miscellany. */ - void makeNaN(unsigned = 0); + static APFloat makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative, + const APInt *fill); + void makeNaN(bool SNaN = false, bool Neg = false, const APInt *fill = 0); opStatus normalize(roundingMode, lostFraction); opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract); cmpResult compareAbsoluteValue(const APFloat &) const; diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 88aa995..ea940ad 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -1308,6 +1308,9 @@ public: /// Set the given bit of a bignum. Zero-based. static void tcSetBit(integerPart *, unsigned int bit); + /// Clear the given bit of a bignum. Zero-based. + static void tcClearBit(integerPart *, unsigned int bit); + /// Returns the bit number of the least or most significant set bit /// of a number. If the input number has no bits set -1U is /// returned. |
