X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2FAPFloat.h;h=928ecc0c3cf579e3df588f8c1cdcd9823deec403;hb=aafa94260d5b1b6422258ed3db7244fe4449f217;hp=65cb1e56bb859518a2df29f9a06e9dd50d69f07e;hpb=e85fe660e4e99d30ca9292b706b8ffe6d0367dca;p=oota-llvm.git diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index 65cb1e56bb8..928ecc0c3cf 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -129,7 +129,7 @@ namespace llvm { static const fltSemantics IEEEquad; static const fltSemantics PPCDoubleDouble; static const fltSemantics x87DoubleExtended; - /* And this psuedo, used to construct APFloats that cannot + /* And this pseudo, used to construct APFloats that cannot conflict with anything real. */ static const fltSemantics Bogus; @@ -152,8 +152,8 @@ namespace llvm { rmNearestTiesToAway }; - /* Operation status. opUnderflow or opOverflow are always returned - or-ed with opInexact. */ + // Operation status. opUnderflow or opOverflow are always returned + // or-ed with opInexact. enum opStatus { opOK = 0x00, opInvalidOp = 0x01, @@ -163,7 +163,7 @@ namespace llvm { opInexact = 0x10 }; - /* Category of internally-represented number. */ + // Category of internally-represented number. enum fltCategory { fcInfinity, fcNaN, @@ -171,23 +171,40 @@ namespace llvm { fcZero }; - /* Constructors. */ + // Constructors. APFloat(const fltSemantics &, const char *); APFloat(const fltSemantics &, integerPart); - APFloat(const fltSemantics &, fltCategory, bool negative); + APFloat(const fltSemantics &, fltCategory, bool negative, unsigned type=0); explicit APFloat(double d); explicit APFloat(float f); explicit APFloat(const APInt &, bool isIEEE = false); APFloat(const APFloat &); ~APFloat(); - + + // Convenience "constructors" + static APFloat getZero(const fltSemantics &Sem, bool Negative = false) { + return APFloat(Sem, fcZero, Negative); + } + static APFloat getInf(const fltSemantics &Sem, bool Negative = false) { + return APFloat(Sem, fcInfinity, Negative); + } + /// getNaN - Factory for QNaN values. + /// + /// \param Negative - True iff 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, + unsigned type = 0) { + return APFloat(Sem, fcNaN, Negative, type); + } + /// Profile - Used to insert APFloat objects, or objects that contain /// APFloat objects, into FoldingSets. void Profile(FoldingSetNodeID& NID) const; - + /// @brief Used by the Bitcode serializer to emit APInts to Bitcode. void Emit(Serializer& S) const; - + /// @brief Used by the Bitcode deserializer to deserialize APInts. static APFloat ReadVal(Deserializer& D); @@ -196,6 +213,9 @@ namespace llvm { opStatus subtract(const APFloat &, roundingMode); opStatus multiply(const APFloat &, roundingMode); opStatus divide(const APFloat &, roundingMode); + /* IEEE remainder. */ + opStatus remainder(const APFloat &); + /* C fmod, or llvm frem. */ opStatus mod(const APFloat &, roundingMode); opStatus fusedMultiplyAdd(const APFloat &, const APFloat &, roundingMode); @@ -205,15 +225,17 @@ namespace llvm { void copySign(const APFloat &); /* Conversions. */ - opStatus convert(const fltSemantics &, roundingMode); + opStatus convert(const fltSemantics &, roundingMode, bool *); opStatus convertToInteger(integerPart *, unsigned int, bool, - roundingMode) const; + roundingMode, bool *) const; + opStatus convertFromAPInt(const APInt &, + bool, roundingMode); opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int, bool, roundingMode); opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int, bool, roundingMode); opStatus convertFromString(const char *, roundingMode); - APInt convertToAPInt() const; + APInt bitcastToAPInt() const; double convertToDouble() const; float convertToFloat() const; @@ -226,6 +248,9 @@ namespace llvm { compare unordered, 0==-0). */ cmpResult compare(const APFloat &) const; + /* Bitwise comparison for equality (QNaNs compare equal, 0!=-0). */ + bool bitwiseIsEqual(const APFloat &) const; + /* Write out a hexadecimal representation of the floating point value to DST, which must be of sufficient size, in the C99 form [-]0xh.hhhhp[+-]d. Return the number of characters written, @@ -233,15 +258,13 @@ namespace llvm { unsigned int convertToHexString(char *dst, unsigned int hexDigits, bool upperCase, roundingMode) const; - /* Bitwise comparison for equality (QNaNs compare equal, 0!=-0). */ - bool bitwiseIsEqual(const APFloat &) const; - /* Simple queries. */ fltCategory getCategory() const { return category; } const fltSemantics &getSemantics() const { return *semantics; } bool isZero() const { return category == fcZero; } bool isNonZero() const { return category != fcZero; } bool isNaN() const { return category == fcNaN; } + bool isInfinity() const { return category == fcInfinity; } bool isNegative() const { return sign; } bool isPosZero() const { return isZero() && !isNegative(); } bool isNegZero() const { return isZero() && isNegative(); } @@ -276,16 +299,17 @@ namespace llvm { opStatus addOrSubtractSpecials(const APFloat &, bool subtract); opStatus divideSpecials(const APFloat &); opStatus multiplySpecials(const APFloat &); + opStatus modSpecials(const APFloat &); /* Miscellany. */ - void makeNaN(void); + void makeNaN(unsigned = 0); opStatus normalize(roundingMode, lostFraction); opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract); cmpResult compareAbsoluteValue(const APFloat &) const; opStatus handleOverflow(roundingMode); bool roundAwayFromZero(roundingMode, lostFraction, unsigned int) const; opStatus convertToSignExtendedInteger(integerPart *, unsigned int, bool, - roundingMode) const; + roundingMode, bool *) const; opStatus convertFromUnsignedParts(const integerPart *, unsigned int, roundingMode); opStatus convertFromHexadecimalString(const char *, roundingMode);