[llvm] r184712 - [APFloat] Added make{Zero, Inf} methods and implemented get{Zero, Inf} on top of them.
Michael Gottesman
mgottesman at apple.com
Mon Jun 24 02:58:02 PDT 2013
Author: mgottesman
Date: Mon Jun 24 04:58:02 2013
New Revision: 184712
URL: http://llvm.org/viewvc/llvm-project?rev=184712&view=rev
Log:
[APFloat] Added make{Zero,Inf} methods and implemented get{Zero,Inf} on top of them.
Modified:
llvm/trunk/include/llvm/ADT/APFloat.h
llvm/trunk/lib/Support/APFloat.cpp
Modified: llvm/trunk/include/llvm/ADT/APFloat.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APFloat.h?rev=184712&r1=184711&r2=184712&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APFloat.h (original)
+++ llvm/trunk/include/llvm/ADT/APFloat.h Mon Jun 24 04:58:02 2013
@@ -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);
/// @}
Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=184712&r1=184711&r2=184712&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Mon Jun 24 04:58:02 2013
@@ -3827,3 +3827,19 @@ APFloat::opStatus APFloat::next(bool nex
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());
+}
More information about the llvm-commits
mailing list