aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-05-30 18:07:13 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-05-30 18:07:13 +0000
commit964722ca40f48c65605e459e3a732bb8783b92f6 (patch)
treed42e6fb3956498fc772b908faa161d34663d83a4 /include
parent26266a1ecedaa6a965c1171cea73c447656611b6 (diff)
downloadexternal_llvm-964722ca40f48c65605e459e3a732bb8783b92f6.tar.gz
external_llvm-964722ca40f48c65605e459e3a732bb8783b92f6.tar.bz2
external_llvm-964722ca40f48c65605e459e3a732bb8783b92f6.zip
Implement IEEE-754R 2008 nextUp/nextDown functions in the guise of the function APFloat::next(bool nextDown).
rdar://13852078 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182945 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/APFloat.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h
index 872bad36bc..6ba3e8ff7c 100644
--- a/include/llvm/ADT/APFloat.h
+++ b/include/llvm/ADT/APFloat.h
@@ -81,6 +81,11 @@
although not really meaningful, and preserved in non-conversion
operations. The exponent is implicitly all 1 bits.
+ APFloat does not provide any exception handling beyond default exception
+ handling. We represent Signaling NaNs via IEEE-754R 2008 6.2.1 should clause
+ by encoding Signaling NaNs with the first bit of its trailing significand as
+ 0.
+
TODO
====
@@ -273,6 +278,8 @@ public:
opStatus mod(const APFloat &, roundingMode);
opStatus fusedMultiplyAdd(const APFloat &, const APFloat &, roundingMode);
opStatus roundToIntegral(roundingMode);
+ /// IEEE-754R 5.3.1: nextUp/nextDown.
+ opStatus next(bool nextDown);
/* Sign operations. */
void changeSign();
@@ -325,6 +332,8 @@ public:
bool isPosZero() const { return isZero() && !isNegative(); }
bool isNegZero() const { return isZero() && isNegative(); }
bool isDenormal() const;
+ /// IEEE-754R 5.7.2: isSignaling. Returns true if this is a signaling NaN.
+ bool isSignaling() const;
APFloat &operator=(const APFloat &);
@@ -386,6 +395,10 @@ private:
unsigned int significandLSB() const;
unsigned int significandMSB() const;
void zeroSignificand();
+ /// Return true if the significand excluding the integral bit is all ones.
+ bool isSignificandAllOnes() const;
+ /// Return true if the significand excluding the integral bit is all zeros.
+ bool isSignificandAllZeros() const;
/* Arithmetic on special values. */
opStatus addOrSubtractSpecials(const APFloat &, bool subtract);
@@ -393,10 +406,26 @@ private:
opStatus multiplySpecials(const APFloat &);
opStatus modSpecials(const APFloat &);
- /* Miscellany. */
+ /* Set to special values. */
+ void makeLargest(bool Neg = false);
+ void makeSmallest(bool Neg = false);
+ void makeNaN(bool SNaN = false, bool Neg = false, const APInt *fill = 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);
+
+ /// \name Special value queries only useful internally to APFloat
+ /// @{
+
+ /// Returns true if and only if the number has the smallest possible non-zero
+ /// magnitude in the current semantics.
+ bool isSmallest() const;
+ /// Returns true if and only if the number has the largest possible finite
+ /// magnitude in the current semantics.
+ bool isLargest() const;
+
+ /// @}
+
+ /* Miscellany. */
opStatus normalize(roundingMode, lostFraction);
opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract);
cmpResult compareAbsoluteValue(const APFloat &) const;