[APFloat] Added make{Zero,Inf} methods and implemented get{Zero,Inf} on top of them.
authorMichael Gottesman <mgottesman@apple.com>
Mon, 24 Jun 2013 09:58:02 +0000 (09:58 +0000)
committerMichael Gottesman <mgottesman@apple.com>
Mon, 24 Jun 2013 09:58:02 +0000 (09:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184712 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APFloat.h
lib/Support/APFloat.cpp

index e3b26f6ca13cbc3535f717001a7306095d8fa6af..3d4a632e5314d2f2d2d251f52d4eb2c83efff0f7 100644 (file)
@@ -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);
 
   /// @}
 
index db1d61c2813621b8194e6085b67fec8a04d1f0df..ec50064f42fef13f7905d98432fdcd14c6040fbf 100644 (file)
@@ -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());  
+}