diff options
| author | Mike Stump <mrs@apple.com> | 2009-05-30 03:49:43 +0000 |
|---|---|---|
| committer | Mike Stump <mrs@apple.com> | 2009-05-30 03:49:43 +0000 |
| commit | 799bf5855ef35d141e7e688eae779e12f6d2c0e2 (patch) | |
| tree | 10a6dd488e3a6e3627663e8d8e80bd7374928f27 /llvm/lib/Support/APFloat.cpp | |
| parent | 258ffef5b54cf680474080b3b4d86c9a9053c42c (diff) | |
| download | llvm-799bf5855ef35d141e7e688eae779e12f6d2c0e2.zip llvm-799bf5855ef35d141e7e688eae779e12f6d2c0e2.tar.gz llvm-799bf5855ef35d141e7e688eae779e12f6d2c0e2.tar.bz2 | |
Add support for letting the client choose different flavors of NaNs. Testcase to be
added in clang.
llvm-svn: 72606
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
| -rw-r--r-- | llvm/lib/Support/APFloat.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 4c79ba6..3b03c54 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -598,12 +598,18 @@ APFloat::copySignificand(const APFloat &rhs) /* Make this number a NaN, with an arbitrary but deterministic value for the significand. If double or longer, this is a signalling NaN, - which may not be ideal. */ + which may not be ideal. If float, this is QNaN(0). */ void -APFloat::makeNaN(void) +APFloat::makeNaN(unsigned type) { category = fcNaN; - APInt::tcSet(significandParts(), ~0U, partCount()); + // FIXME: Add double and long double support for QNaN(0). + if (semantics->precision == 24 && semantics->maxExponent == 127) { + type |= 0x7fc00000U; + type &= ~0x80000000U; + } else + type = ~0U; + APInt::tcSet(significandParts(), type, partCount()); } APFloat & @@ -662,16 +668,16 @@ APFloat::APFloat(const fltSemantics &ourSemantics, integerPart value) } APFloat::APFloat(const fltSemantics &ourSemantics, - fltCategory ourCategory, bool negative) + fltCategory ourCategory, bool negative, unsigned type) { assertArithmeticOK(ourSemantics); initialize(&ourSemantics); category = ourCategory; sign = negative; - if(category == fcNormal) + if (category == fcNormal) category = fcZero; else if (ourCategory == fcNaN) - makeNaN(); + makeNaN(type); } APFloat::APFloat(const fltSemantics &ourSemantics, const char *text) |
