Revert "Refactor ARM subarchitecture parsing"
[oota-llvm.git] / include / llvm / ADT / APFloat.h
index 712cf91f6d8447727390dba8e6a4b72466787410..50f1463d7eaa65a226092c090da1d18ef63c1f9f 100644 (file)
@@ -1,4 +1,4 @@
-//== llvm/Support/APFloat.h - Arbitrary Precision Floating Point -*- C++ -*-==//
+//===- llvm/ADT/APFloat.h - Arbitrary Precision Floating Point ---*- C++ -*-==//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -21,9 +21,6 @@
 
 namespace llvm {
 
-/// A signed type to represent a floating point numbers unbiased exponent.
-typedef signed short exponent_t;
-
 struct fltSemantics;
 class APSInt;
 class StringRef;
@@ -120,11 +117,14 @@ enum lostFraction { // Example of truncated bits:
 /// New formats: x87 in single and double precision mode (IEEE apart from
 /// extended exponent range) (hard).
 ///
-/// New operations: sqrt, IEEE remainder, C90 fmod, nextafter, nexttoward.
+/// New operations: sqrt, IEEE remainder, C90 fmod, nexttoward.
 ///
 class APFloat {
 public:
 
+  /// A signed type to represent a floating point numbers unbiased exponent.
+  typedef signed short ExponentType;
+
   /// \name Floating Point Semantics.
   /// @{
 
@@ -191,12 +191,12 @@ public:
   APFloat(const fltSemantics &); // Default construct to 0.0
   APFloat(const fltSemantics &, StringRef);
   APFloat(const fltSemantics &, integerPart);
-  APFloat(const fltSemantics &, fltCategory, bool negative);
   APFloat(const fltSemantics &, uninitializedTag);
   APFloat(const fltSemantics &, const APInt &);
   explicit APFloat(double d);
   explicit APFloat(float f);
   APFloat(const APFloat &);
+  APFloat(APFloat &&);
   ~APFloat();
 
   /// @}
@@ -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.
@@ -232,19 +236,19 @@ public:
       APInt fill(64, type);
       return getQNaN(Sem, Negative, &fill);
     } else {
-      return getQNaN(Sem, Negative, 0);
+      return getQNaN(Sem, Negative, nullptr);
     }
   }
 
   /// Factory for QNaN values.
   static APFloat getQNaN(const fltSemantics &Sem, bool Negative = false,
-                         const APInt *payload = 0) {
+                         const APInt *payload = nullptr) {
     return makeNaN(Sem, false, Negative, payload);
   }
 
   /// Factory for SNaN values.
   static APFloat getSNaN(const fltSemantics &Sem, bool Negative = false,
-                         const APInt *payload = 0) {
+                         const APInt *payload = nullptr) {
     return makeNaN(Sem, true, Negative, payload);
   }
 
@@ -300,6 +304,8 @@ public:
   /// IEEE-754R 5.3.1: nextUp/nextDown.
   opStatus next(bool nextDown);
 
+  /// @}
+
   /// \name Sign operations.
   /// @{
 
@@ -359,10 +365,7 @@ public:
   ///
   /// This implies that the current value of the float is not zero, subnormal,
   /// infinite, or NaN following the definition of normality from IEEE-754R.
-  ///
-  /// The current implementation of isNormal() differs from this by treating
-  /// subnormal values as normal values.
-  bool isIEEENormal() const { return !isDenormal() && isNormal(); }
+  bool isNormal() const { return !isDenormal() && isFiniteNonZero(); }
 
   /// Returns true if and only if the current value is zero, subnormal, or
   /// normal.
@@ -394,7 +397,7 @@ public:
   fltCategory getCategory() const { return category; }
   const fltSemantics &getSemantics() const { return *semantics; }
   bool isNonZero() const { return category != fcZero; }
-  bool isNormal() const { return category == fcNormal; }
+  bool isFiniteNonZero() const { return isFinite() && !isZero(); }
   bool isPosZero() const { return isZero() && !isNegative(); }
   bool isNegZero() const { return isZero() && isNegative(); }
 
@@ -409,6 +412,7 @@ public:
   /// @}
 
   APFloat &operator=(const APFloat &);
+  APFloat &operator=(APFloat &&);
 
   /// \brief Overload to compute a hash code for an APFloat value.
   ///
@@ -496,15 +500,19 @@ private:
 
   void makeLargest(bool Neg = false);
   void makeSmallest(bool Neg = false);
-  void makeNaN(bool SNaN = false, bool Neg = false, const APInt *fill = 0);
+  void makeNaN(bool SNaN = false, bool Neg = false,
+               const APInt *fill = nullptr);
   static APFloat makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative,
                          const APInt *fill);
+  void makeInf(bool Neg = false);
+  void makeZero(bool Neg = false);
 
   /// @}
 
   /// \name Miscellany
   /// @{
 
+  bool convertFromStringSpecials(StringRef str);
   opStatus normalize(roundingMode, lostFraction);
   opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract);
   cmpResult compareAbsoluteValue(const APFloat &) const;
@@ -553,7 +561,7 @@ private:
   } significand;
 
   /// The signed unbiased exponent of the value.
-  exponent_t exponent;
+  ExponentType exponent;
 
   /// What kind of floating point number this is.
   ///