Fix a typo 'iff' => 'if'
[oota-llvm.git] / include / llvm / ADT / APFloat.h
index dfe4e0f49adb2836f7202fcd2d551e662691495b..ea15fd6e29156203a631635ac34508fcc6bd527f 100644 (file)
@@ -109,6 +109,7 @@ namespace llvm {
   typedef signed short exponent_t;
 
   struct fltSemantics;
+  class APSInt;
   class StringRef;
 
   /* When bits of a floating point number are truncated, this enum is
@@ -199,7 +200,7 @@ namespace llvm {
 
     /// getNaN - Factory for QNaN values.
     ///
-    /// \param Negative - True iff the NaN generated should be negative.
+    /// \param Negative - True if the NaN generated should be negative.
     /// \param type - The unspecified fill bits for creating the NaN, 0 by
     /// default.  The value is truncated as necessary.
     static APFloat getNaN(const fltSemantics &Sem, bool Negative = false,
@@ -229,23 +230,30 @@ namespace llvm {
     /// getLargest - Returns the largest finite number in the given
     /// semantics.
     ///
-    /// \param Negative - True iff the number should be negative
+    /// \param Negative - True if the number should be negative
     static APFloat getLargest(const fltSemantics &Sem, bool Negative = false);
 
     /// getSmallest - Returns the smallest (by magnitude) finite number
     /// in the given semantics.  Might be denormalized, which implies a
     /// relative loss of precision.
     ///
-    /// \param Negative - True iff the number should be negative
+    /// \param Negative - True if the number should be negative
     static APFloat getSmallest(const fltSemantics &Sem, bool Negative = false);
 
     /// getSmallestNormalized - Returns the smallest (by magnitude)
     /// normalized finite number in the given semantics.
     ///
-    /// \param Negative - True iff the number should be negative
+    /// \param Negative - True if the number should be negative
     static APFloat getSmallestNormalized(const fltSemantics &Sem,
                                          bool Negative = false);
 
+    /// getAllOnesValue - Returns a float which is bitcasted from
+    /// an all one value int.
+    ///
+    /// \param BitWidth - Select float type
+    /// \param isIEEE   - If 128 bit number, select between PPC and IEEE
+    static APFloat getAllOnesValue(unsigned BitWidth, bool isIEEE = false);
+
     /// Profile - Used to insert APFloat objects, or objects that contain
     ///  APFloat objects, into FoldingSets.
     void Profile(FoldingSetNodeID& NID) const;
@@ -266,6 +274,7 @@ namespace llvm {
     /* C fmod, or llvm frem. */
     opStatus mod(const APFloat &, roundingMode);
     opStatus fusedMultiplyAdd(const APFloat &, const APFloat &, roundingMode);
+    opStatus roundToIntegral(roundingMode);
 
     /* Sign operations.  */
     void changeSign();
@@ -276,6 +285,7 @@ namespace llvm {
     opStatus convert(const fltSemantics &, roundingMode, bool *);
     opStatus convertToInteger(integerPart *, unsigned int, bool,
                               roundingMode, bool *) const;
+    opStatus convertToInteger(APSInt&, roundingMode, bool *) const;
     opStatus convertFromAPInt(const APInt &,
                               bool, roundingMode);
     opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int,
@@ -311,6 +321,7 @@ namespace llvm {
     const fltSemantics &getSemantics() const { return *semantics; }
     bool isZero() const { return category == fcZero; }
     bool isNonZero() const { return category != fcZero; }
+    bool isNormal() const { return category == fcNormal; }
     bool isNaN() const { return category == fcNaN; }
     bool isInfinity() const { return category == fcInfinity; }
     bool isNegative() const { return sign; }
@@ -319,8 +330,16 @@ namespace llvm {
 
     APFloat& operator=(const APFloat &);
 
-    /* Return an arbitrary integer value usable for hashing. */
-    uint32_t getHashValue() const;
+    /// \brief Overload to compute a hash code for an APFloat value.
+    ///
+    /// Note that the use of hash codes for floating point values is in general
+    /// frought with peril. Equality is hard to define for these values. For
+    /// example, should negative and positive zero hash to different codes? Are
+    /// they equal or not? This hash value implementation specifically
+    /// emphasizes producing different codes for different inputs in order to
+    /// be used in canonicalization and memoization. As such, equality is
+    /// bitwiseIsEqual, and 0 != -0.
+    friend hash_code hash_value(const APFloat &Arg);
 
     /// Converts this value into a decimal string.
     ///
@@ -346,6 +365,10 @@ namespace llvm {
                   unsigned FormatPrecision = 0,
                   unsigned FormatMaxPadding = 3) const;
 
+    /// getExactInverse - If this value has an exact multiplicative inverse,
+    /// store it in inv and return true.
+    bool getExactInverse(APFloat *inv) const;
+
   private:
 
     /* Trivial queries.  */