17 #ifndef LLVM_ADT_APFLOAT_H
18 #define LLVM_ADT_APFLOAT_H
215 Val.makeZero(Negative);
224 Val.makeInf(Negative);
236 APInt fill(64, type);
237 return getQNaN(Sem, Negative, &fill);
239 return getQNaN(Sem, Negative,
nullptr);
245 const APInt *payload =
nullptr) {
246 return makeNaN(Sem,
false, Negative, payload);
251 const APInt *payload =
nullptr) {
252 return makeNaN(Sem,
true, Negative, payload);
271 bool Negative =
false);
486 unsigned FormatMaxPadding = 3)
const;
529 unsigned int partCount()
const;
541 void incrementSignificand();
543 void shiftSignificandLeft(
unsigned int);
545 unsigned int significandLSB()
const;
546 unsigned int significandMSB()
const;
547 void zeroSignificand();
549 bool isSignificandAllOnes()
const;
551 bool isSignificandAllZeros()
const;
568 void makeLargest(
bool Neg =
false);
569 void makeSmallest(
bool Neg =
false);
570 void makeNaN(
bool SNaN =
false,
bool Neg =
false,
571 const APInt *fill =
nullptr);
574 void makeInf(
bool Neg =
false);
575 void makeZero(
bool Neg =
false);
582 bool convertFromStringSpecials(
StringRef str);
594 char *convertNormalToHexString(
char *,
unsigned int,
bool,
601 APInt convertHalfAPFloatToAPInt()
const;
602 APInt convertFloatAPFloatToAPInt()
const;
603 APInt convertDoubleAPFloatToAPInt()
const;
604 APInt convertQuadrupleAPFloatToAPInt()
const;
605 APInt convertF80LongDoubleAPFloatToAPInt()
const;
606 APInt convertPPCDoubleDoubleAPFloatToAPInt()
const;
608 void initFromHalfAPInt(
const APInt &api);
609 void initFromFloatAPInt(
const APInt &api);
610 void initFromDoubleAPInt(
const APInt &api);
611 void initFromQuadrupleAPInt(
const APInt &api);
612 void initFromF80LongDoubleAPInt(
const APInt &api);
613 void initFromPPCDoubleDoubleAPInt(
const APInt &api);
616 void copySignificand(
const APFloat &);
617 void freeSignificand();
640 unsigned int sign : 1;
680 #endif // LLVM_ADT_APFLOAT_H
friend int ilogb(const APFloat &Arg)
Returns the exponent of the internal representation of the APFloat.
opStatus divide(const APFloat &, roundingMode)
bool isNaN() const
Returns true if and only if the float is a quiet or signaling NaN.
APFloat & operator=(const APFloat &)
void Profile(FoldingSetNodeID &NID) const
Used to insert APFloat objects, or objects that contain APFloat objects, into FoldingSets.
static const fltSemantics IEEEdouble
APFloat(const fltSemantics &)
opStatus
IEEE-754R 7: Default exception handling.
friend APFloat scalbn(APFloat X, int Exp)
Returns: X * 2^Exp for integral exponents.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
static const fltSemantics Bogus
A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real...
bool isSignaling() const
Returns true if and only if the float is a signaling NaN.
bool isFiniteNonZero() const
opStatus convertFromString(StringRef, roundingMode)
bool bitwiseIsEqual(const APFloat &) const
Bitwise comparison for equality (QNaNs compare equal, 0!=-0).
static const fltSemantics x87DoubleExtended
signed short ExponentType
A signed type to represent a floating point numbers unbiased exponent.
opStatus convertToInteger(integerPart *, unsigned int, bool, roundingMode, bool *) const
static const fltSemantics IEEEquad
APFloat operator+(const APFloat &RHS) const
Operator+ overload which provides the default nmNearestTiesToEven rounding mode and no error checking...
void copySign(const APFloat &)
This file implements a class to represent arbitrary precision integral constant values and operations...
uninitializedTag
Convenience enum used to construct an uninitialized APFloat.
opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)
bool isFinite() const
Returns true if and only if the current value is zero, subnormal, or normal.
static APFloat getSmallest(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) finite number in the given semantics.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
static unsigned int semanticsPrecision(const fltSemantics &)
double convertToDouble() const
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
unsigned int convertToHexString(char *dst, unsigned int hexDigits, bool upperCase, roundingMode) const
Write out a hexadecimal representation of the floating point value to DST, which must be of sufficien...
opStatus mod(const APFloat &, roundingMode)
C fmod, or llvm frem.
static APFloat copySign(APFloat Value, const APFloat &Sign)
A static helper to produce a copy of an APFloat value with its sign copied from some other APFloat...
opStatus convertFromAPInt(const APInt &, bool, roundingMode)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
friend hash_code hash_value(const APFloat &Arg)
Overload to compute a hash code for an APFloat value.
static APFloat getSmallestNormalized(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) normalized finite number in the given semantics.
cmpResult compare(const APFloat &) const
IEEE comparison with another floating point number (NaNs compare unordered, 0==-0).
bool operator==(const APFloat &) const =delete
The definition of equality is not straightforward for floating point, so we won't use operator==...
fltCategory
Category of internally-represented number.
opStatus fusedMultiplyAdd(const APFloat &, const APFloat &, roundingMode)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
opStatus convert(const fltSemantics &, roundingMode, bool *)
APFloat::convert - convert a value of one floating point type to another.
IlogbErrorKinds
Enumeration of ilogb error results.
APFloat operator/(const APFloat &RHS) const
Operator/ overload which provides the default nmNearestTiesToEven rounding mode and no error checking...
APFloat scalbn(APFloat X, int Exp)
fltCategory getCategory() const
static const fltSemantics IEEEhalf
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
bool needsCleanup() const
Returns whether this instance allocated memory.
opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)
static const fltSemantics PPCDoubleDouble
roundingMode
IEEE-754R 4.3: Rounding-direction attributes.
lostFraction
Enum that represents what fraction of the LSB truncated bits of an fp number represent.
bool isNegative() const
IEEE-754R isSignMinus: Returns true if and only if the current value is negative. ...
opStatus add(const APFloat &, roundingMode)
bool isDenormal() const
IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal.
opStatus multiply(const APFloat &, roundingMode)
static APFloat getAllOnesValue(unsigned BitWidth, bool isIEEE=false)
Returns a float which is bitcasted from an all one value int.
Class for arbitrary precision integers.
static APFloat getSNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for SNaN values.
APInt bitcastToAPInt() const
static APFloat getLargest(const fltSemantics &Sem, bool Negative=false)
Returns the largest finite number in the given semantics.
An opaque object representing a hash code.
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, unsigned type=0)
Factory for QNaN values.
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3) const
Converts this value into a decimal string.
static const fltSemantics IEEEsingle
APFloat operator*(const APFloat &RHS) const
Operator* overload which provides the default nmNearestTiesToEven rounding mode and no error checking...
opStatus roundToIntegral(roundingMode)
APFloat abs(APFloat X)
Returns the absolute value of the argument.
float convertToFloat() const
bool isSmallest() const
Returns true if and only if the number has the smallest possible non-zero magnitude in the current se...
APFloat operator-(const APFloat &RHS) const
Operator- overload which provides the default nmNearestTiesToEven rounding mode and no error checking...
LLVM Value Representation.
bool isZero() const
Returns true if and only if the float is plus or minus zero.
static unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
bool isLargest() const
Returns true if and only if the number has the largest possible finite magnitude in the current seman...
bool isInfinity() const
IEEE-754R isInfinite(): Returns true if and only if the float is infinity.
StringRef - Represent a constant reference to a string, i.e.
opStatus next(bool nextDown)
IEEE-754R 5.3.1: nextUp/nextDown.
opStatus remainder(const APFloat &)
IEEE remainder.
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
bool getExactInverse(APFloat *inv) const
If this value has an exact multiplicative inverse, store it in inv and return true.
const fltSemantics & getSemantics() const
opStatus subtract(const APFloat &, roundingMode)
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
bool isNormal() const
IEEE-754R isNormal: Returns true if and only if the current value is normal.