diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-06-24 09:58:02 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-06-24 09:58:02 +0000 |
commit | c4facdf390745c92ac9eb79f1d247d6b41db54eb (patch) | |
tree | e0e9850e386ea06d993614285611f1301b77ae42 | |
parent | f0e8cd1a7f606fb5953f2eac4d2521c0e33c83b0 (diff) | |
download | bcm5719-llvm-c4facdf390745c92ac9eb79f1d247d6b41db54eb.tar.gz bcm5719-llvm-c4facdf390745c92ac9eb79f1d247d6b41db54eb.zip |
[APFloat] Added make{Zero,Inf} methods and implemented get{Zero,Inf} on top of them.
llvm-svn: 184712
-rw-r--r-- | llvm/include/llvm/ADT/APFloat.h | 10 | ||||
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 16 |
2 files changed, 24 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index e3b26f6ca13..3d4a632e531 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -211,14 +211,18 @@ public: /// /// \param Negative True iff the number should be negative. static APFloat getZero(const fltSemantics &Sem, bool Negative = false) { - return APFloat(Sem, fcZero, Negative); + APFloat Val(Sem, uninitialized); + Val.makeZero(Negative); + return Val; } /// Factory for Positive and Negative Infinity. /// /// \param Negative True iff the number should be negative. static APFloat getInf(const fltSemantics &Sem, bool Negative = false) { - return APFloat(Sem, fcInfinity, Negative); + APFloat Val(Sem, uninitialized); + Val.makeInf(Negative); + return Val; } /// Factory for QNaN values. @@ -498,6 +502,8 @@ private: 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 makeInf(bool Neg = false); + void makeZero(bool Neg = false); /// @} diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index db1d61c2813..ec50064f42f 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -3827,3 +3827,19 @@ APFloat::opStatus APFloat::next(bool nextDown) { return result; } + +void +APFloat::makeInf(bool Negative) { + category = fcInfinity; + sign = Negative; + exponent = semantics->maxExponent + 1; + APInt::tcSet(significandParts(), 0, partCount()); +} + +void +APFloat::makeZero(bool Negative) { + category = fcZero; + sign = Negative; + exponent = semantics->minExponent-1; + APInt::tcSet(significandParts(), 0, partCount()); +} |