15#ifndef LLVM_ADT_APFLOAT_H
16#define LLVM_ADT_APFLOAT_H
27#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
29 if (usesLayout<IEEEFloat>(getSemantics())) \
30 return U.IEEE.METHOD_CALL; \
31 if (usesLayout<DoubleAPFloat>(getSemantics())) \
32 return U.Double.METHOD_CALL; \
33 llvm_unreachable("Unexpected semantics"); \
45template <
typename T>
class Expected;
46template <
typename T>
class SmallVectorImpl;
309 return semX87DoubleExtended;
312 return semPPCDoubleDouble;
315 return semPPCDoubleDoubleLegacy;
319 return semFloat8E5M2FNUZ;
323 return semFloat8E4M3FN;
326 return semFloat8E4M3FNUZ;
329 return semFloat8E4M3B11FNUZ;
334 return semFloat8E8M0FNU;
337 return semFloat8E5M3FNU;
340 return semFloat6E3M2FN;
343 return semFloat6E2M3FN;
346 return semFloat4E2M1FN;
365 bool IgnoreNaNs =
false);
557#ifdef HAS_IEE754_FLOAT128
558 LLVM_ABI float128 convertToQuad()
const;
604 bool isZero()
const {
return category == fltCategory::fcZero; }
626 bool isNonZero()
const {
return category != fltCategory::fcZero; }
689 unsigned FormatPrecision = 0,
690 unsigned FormatMaxPadding = 3,
691 bool TruncateZero =
true)
const;
730 LLVM_ABI unsigned int partCount()
const;
744 bool ignoreAddend =
false);
747 void incrementSignificand();
749 void shiftSignificandLeft(
unsigned int);
751 unsigned int significandLSB()
const;
752 unsigned int significandMSB()
const;
753 void zeroSignificand();
754 unsigned int getNumHighBits()
const;
756 bool isSignificandAllOnes()
const;
757 bool isSignificandAllOnesExceptLSB()
const;
759 bool isSignificandAllZeros()
const;
760 bool isSignificandAllZerosExceptMSB()
const;
778 bool convertFromStringSpecials(
StringRef str);
790 char *convertNormalToHexString(
char *,
unsigned int,
bool,
802 template <APFloatBase::Semantics S>
805 template <APFloatBase::Semantics E>
APInt convertIEEEFloatToAPInt()
const;
807 template <APFloatBase::Semantics S>
811 template <APFloatBase::Semantics E>
void initFromIEEEAPInt(
const APInt &api);
815 void freeSignificand();
836 fltCategory category : 3;
839 unsigned int sign : 1;
865 unsigned int Width,
bool IsSigned,
929 unsigned int Width,
bool IsSigned,
946 unsigned FormatMaxPadding,
947 bool TruncateZero =
true)
const;
1107 static_assert(std::is_standard_layout<IEEEFloat>::value);
1112 DoubleAPFloat Double;
1116 : Double(std::move(
F)) {
1120 template <
typename... ArgTypes>
1126 if (usesLayout<DoubleAPFloat>(
Semantics)) {
1141 static_assert(std::is_same<T, IEEEFloat>::value ||
1142 std::is_same<T, DoubleAPFloat>::value);
1143 if (std::is_same<T, DoubleAPFloat>::value) {
1149 IEEEFloat &getIEEE() {
1150 if (usesLayout<IEEEFloat>(*U.semantics))
1152 if (usesLayout<DoubleAPFloat>(*U.semantics))
1153 return U.Double.getFirst().U.IEEE;
1157 const IEEEFloat &getIEEE()
const {
1158 if (usesLayout<IEEEFloat>(*U.semantics))
1160 if (usesLayout<DoubleAPFloat>(*U.semantics))
1161 return U.Double.getFirst().U.IEEE;
1169 void makeNaN(
bool SNaN,
bool Neg,
const APInt *
fill) {
1173 void makeLargest(
bool Neg) {
1177 void makeSmallest(
bool Neg) {
1181 void makeSmallestNormalized(
bool Neg) {
1187 : U(std::move(
F), S) {}
1193 template <
typename T,
1194 typename = std::enable_if_t<std::is_floating_point<T>::value>>
1214 Val.makeZero(Negative);
1222 APFloat Val(Sem, 1U);
1233 Val.makeInf(Negative);
1245 APInt intPayload(64, payload);
1246 return getQNaN(Sem, Negative, &intPayload);
1248 return getQNaN(Sem, Negative,
nullptr);
1254 const APInt *payload =
nullptr) {
1256 Val.makeNaN(
false, Negative, payload);
1262 const APInt *payload =
nullptr) {
1264 Val.makeNaN(
true, Negative, payload);
1273 Val.makeLargest(Negative);
1283 Val.makeSmallest(Negative);
1292 bool Negative =
false) {
1294 Val.makeSmallestNormalized(Negative);
1316 "Should only call on two APFloats with the same semantics");
1318 return U.IEEE.add(
RHS.U.IEEE, RM);
1320 return U.Double.add(
RHS.U.Double, RM);
1325 "Should only call on two APFloats with the same semantics");
1327 return U.IEEE.subtract(
RHS.U.IEEE, RM);
1329 return U.Double.subtract(
RHS.U.Double, RM);
1334 "Should only call on two APFloats with the same semantics");
1336 return U.IEEE.multiply(
RHS.U.IEEE, RM);
1338 return U.Double.multiply(
RHS.U.Double, RM);
1343 "Should only call on two APFloats with the same semantics");
1345 return U.IEEE.divide(
RHS.U.IEEE, RM);
1347 return U.Double.divide(
RHS.U.Double, RM);
1352 "Should only call on two APFloats with the same semantics");
1354 return U.IEEE.remainder(
RHS.U.IEEE);
1356 return U.Double.remainder(
RHS.U.Double);
1361 "Should only call on two APFloats with the same semantics");
1363 return U.IEEE.mod(
RHS.U.IEEE);
1365 return U.Double.mod(
RHS.U.Double);
1371 "Should only call on APFloats with the same semantics");
1373 "Should only call on APFloats with the same semantics");
1375 return U.IEEE.fusedMultiplyAdd(Multiplicand.U.IEEE, Addend.U.IEEE, RM);
1377 return U.Double.fusedMultiplyAdd(Multiplicand.U.Double, Addend.U.Double,
1393 APFloat Result(*
this);
1394 Result.changeSign();
1401 APFloat Result(*
this);
1409 APFloat Result(*
this);
1417 APFloat Result(*
this);
1425 APFloat Result(*
this);
1450 APFloat Result(*
this);
1451 Result.getIEEE().makeQuiet();
1467 bool *IsExact)
const {
1475 bool *IsExact)
const;
1520#ifdef HAS_IEE754_FLOAT128
1521 LLVM_ABI float128 convertToQuad()
const;
1557 "Should only compare APFloats with the same semantics");
1559 return U.IEEE.compare(
RHS.U.IEEE);
1561 return U.Double.compare(
RHS.U.Double);
1569 "Should only compare APFloats with the same semantics");
1571 return U.IEEE.compareAbsoluteValue(
RHS.U.IEEE);
1573 return U.Double.compareAbsoluteValue(
RHS.U.Double);
1581 return U.IEEE.bitwiseIsEqual(
RHS.U.IEEE);
1583 return U.Double.bitwiseIsEqual(
RHS.U.Double);
1639 assert(
isNaN() &&
"Can only call this on a NaN value");
1650 unsigned FormatMaxPadding = 3,
bool TruncateZero =
true)
const {
1652 toString(Str, FormatPrecision, FormatMaxPadding, TruncateZero));
1659 unsigned FormatPrecision = 0,
1660 unsigned FormatMaxPadding = 3,
1661 bool TruncateZero =
true)
const;
1667 unsigned FormatMaxPadding = 3,
1668 bool TruncateZero =
true)
const;
1672#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1715 friend DoubleAPFloat;
1719 "Empty base class optimization is not performed.");
1737 if (APFloat::usesLayout<detail::IEEEFloat>(Arg.
getSemantics()))
1738 return ilogb(Arg.U.IEEE);
1739 if (APFloat::usesLayout<detail::DoubleAPFloat>(Arg.
getSemantics()))
1740 return ilogb(Arg.U.Double);
1746 if (APFloat::usesLayout<detail::IEEEFloat>(
X.getSemantics()))
1748 if (APFloat::usesLayout<detail::DoubleAPFloat>(
X.getSemantics()))
1758 if (APFloat::usesLayout<detail::IEEEFloat>(
X.getSemantics()))
1760 if (APFloat::usesLayout<detail::DoubleAPFloat>(
X.getSemantics()))
1782 if (
A.isSignaling())
1783 return A.makeQuiet();
1784 if (
B.isSignaling())
1785 return B.makeQuiet();
1790 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1791 return A.isNegative() ?
A :
B;
1792 return B <
A ?
B :
A;
1801 if (
A.isSignaling())
1802 return A.makeQuiet();
1803 if (
B.isSignaling())
1804 return B.makeQuiet();
1809 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1810 return A.isNegative() ?
B :
A;
1811 return A <
B ?
B :
A;
1820 return A.makeQuiet();
1822 return B.makeQuiet();
1823 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1824 return A.isNegative() ?
A :
B;
1825 return B <
A ?
B :
A;
1833 return B.isNaN() ?
B.makeQuiet() :
B;
1836 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1837 return A.isNegative() ?
A :
B;
1838 return B <
A ?
B :
A;
1847 return A.makeQuiet();
1849 return B.makeQuiet();
1850 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1851 return A.isNegative() ?
B :
A;
1852 return A <
B ?
B :
A;
1860 return B.isNaN() ?
B.makeQuiet() :
B;
1863 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1864 return A.isNegative() ?
B :
A;
1865 return A <
B ?
B :
A;
1904#undef APFLOAT_DISPATCH_ON_SEMANTICS
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL)
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Utilities for dealing with flags related to floating point properties and mode controls.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, const llvm::StringTable &StandardNames, VectorLibrary VecLib)
Initialize the set of available library functions based on the specified target triple.
static constexpr const fltSemantics & Float8E4M3()
static LLVM_ABI const llvm::fltSemantics & EnumToSemantics(Semantics S)
static LLVM_ABI bool semanticsHasInf(const fltSemantics &)
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
static constexpr const fltSemantics & Float8E5M2FNUZ()
static constexpr roundingMode rmTowardZero
static LLVM_ABI ExponentType semanticsMinExponent(const fltSemantics &)
llvm::RoundingMode roundingMode
IEEE-754R 4.3: Rounding-direction attributes.
static constexpr const fltSemantics & Float8E3M4()
static constexpr const fltSemantics & PPCDoubleDouble()
static LLVM_ABI unsigned int semanticsSizeInBits(const fltSemantics &)
static LLVM_ABI bool semanticsHasSignedRepr(const fltSemantics &)
static LLVM_ABI unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
static constexpr const fltSemantics & Float8E8M0FNU()
static constexpr const fltSemantics & Float8E4M3FNUZ()
static constexpr roundingMode rmTowardNegative
uninitializedTag
Convenience enum used to construct an uninitialized APFloat.
static constexpr const fltSemantics & FloatTF32()
static constexpr roundingMode rmNearestTiesToEven
static LLVM_ABI bool isValidArbitraryFPFormat(StringRef Format)
Returns true if the given string is a valid arbitrary floating-point format interpretation for llvm....
static LLVM_ABI bool hasSignBitInMSB(const fltSemantics &)
static constexpr const fltSemantics & IEEEhalf()
static LLVM_ABI ExponentType semanticsMaxExponent(const fltSemantics &)
static LLVM_ABI unsigned int semanticsPrecision(const fltSemantics &)
static constexpr const fltSemantics & Bogus()
A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real.
static LLVM_ABI bool semanticsHasNaN(const fltSemantics &)
static constexpr const fltSemantics & IEEEsingle()
static LLVM_ABI Semantics SemanticsToEnum(const llvm::fltSemantics &Sem)
int32_t ExponentType
A signed type to represent a floating point numbers unbiased exponent.
static constexpr const fltSemantics & Float6E2M3FN()
static constexpr unsigned integerPartWidth
static LLVM_ABI bool isLosslesslyConvertibleTo(const fltSemantics &From, const fltSemantics &To, bool IgnoreNaNs=false)
Returns whether converting a value from From to To is known to preserve all information.
APInt::WordType integerPart
static LLVM_ABI bool semanticsHasZero(const fltSemantics &)
static LLVM_ABI bool isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst)
static constexpr roundingMode rmTowardPositive
static constexpr const fltSemantics & PPCDoubleDoubleLegacy()
static constexpr const fltSemantics & BFloat()
static constexpr const fltSemantics & Float6E3M2FN()
IlogbErrorKinds
Enumeration of ilogb error results.
static constexpr const fltSemantics & IEEEdouble()
static LLVM_ABI bool isRepresentableBy(const fltSemantics &A, const fltSemantics &B)
static constexpr const fltSemantics & Float8E5M2()
static LLVM_ABI bool isIEEELikeFP(const fltSemantics &)
fltCategory
Category of internally-represented number.
static constexpr const fltSemantics & Float8E5M3FNU()
static constexpr roundingMode rmNearestTiesToAway
@ S_PPCDoubleDoubleLegacy
static constexpr const fltSemantics & IEEEquad()
static constexpr const fltSemantics & Float4E2M1FN()
opStatus
IEEE-754R 7: Default exception handling.
static constexpr const fltSemantics & Float8E4M3B11FNUZ()
static constexpr const fltSemantics & Float8E4M3FN()
static LLVM_ABI unsigned getArbitraryFPFormatSizeInBits(StringRef Format)
Returns the size in bits of a valid arbitrary floating-point format string, or 0 if the string is not...
static LLVM_ABI const fltSemantics * getArbitraryFPSemantics(StringRef Format)
Returns the fltSemantics for a given arbitrary FP format string, or nullptr if invalid.
static constexpr const fltSemantics & x87DoubleExtended()
static LLVM_ABI unsigned int semanticsIntSizeInBits(const fltSemantics &, bool)
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
static APFloat getSNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for SNaN values.
LLVM_READONLY bool isNegPowerOf2(int N) const
opStatus divide(const APFloat &RHS, roundingMode RM)
APFloat & operator=(APFloat &&RHS)=default
bool isFiniteNonZero() const
APFloat(const APFloat &RHS)=default
void copySign(const APFloat &RHS)
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
LLVM_READONLY int getExactLog2Abs() const
opStatus subtract(const APFloat &RHS, roundingMode RM)
bool bitwiseIsEqual(const APFloat &RHS) const
LLVM_ABI bool getExactInverse(APFloat *Inv) const
If this value is normal and has an exact, normal, multiplicative inverse, store it in inv and return ...
cmpResult compareAbsoluteValue(const APFloat &RHS) const
APFloat operator+(const APFloat &RHS) const
Add two APFloats, rounding ties to the nearest even.
LLVM_ABI double convertToDouble() const
Converts this APFloat to host double value.
bool isPosInfinity() const
APFloat(APFloat &&RHS)=default
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const
bool isExactlyValue(double V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
opStatus add(const APFloat &RHS, roundingMode RM)
LLVM_READONLY int getExactLog2() const
APFloat & operator=(const APFloat &RHS)=default
LLVM_READONLY bool isPowerOf2(int N) const
static LLVM_ABI APFloat getAllOnesValue(const fltSemantics &Semantics)
Returns a float which is bitcasted from an all one value int.
LLVM_ABI friend hash_code hash_value(const APFloat &Arg)
See friend declarations above.
APFloat(const fltSemantics &Semantics, integerPart I)
bool operator!=(const APFloat &RHS) const
APFloat(const fltSemantics &Semantics, T V)=delete
const fltSemantics & getSemantics() const
APFloat operator-(const APFloat &RHS) const
Subtract two APFloats, rounding ties to the nearest even.
APFloat operator*(const APFloat &RHS) const
Multiply two APFloats, rounding ties to the nearest even.
APFloat(const fltSemantics &Semantics)
bool operator<(const APFloat &RHS) const
APFloat makeQuiet() const
Assuming this is an IEEE-754 NaN value, quiet its signaling bit.
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
static APFloat getOne(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative One.
unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const
opStatus multiply(const APFloat &RHS, roundingMode RM)
LLVM_ABI float convertToFloat() const
Converts this APFloat to host float value.
bool operator>(const APFloat &RHS) const
opStatus fusedMultiplyAdd(const APFloat &Multiplicand, const APFloat &Addend, roundingMode RM)
APFloat operator/(const APFloat &RHS) const
Divide the first APFloat by the second, rounding ties to the nearest even.
opStatus remainder(const APFloat &RHS)
APFloat operator-() const
Negate an APFloat.
LLVM_READONLY bool isOne() const
static APFloat getSmallestNormalized(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) normalized finite number in the given semantics.
APInt bitcastToAPInt() const
friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM)
static APFloat getLargest(const fltSemantics &Sem, bool Negative=false)
Returns the largest finite number in the given semantics.
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
opStatus next(bool nextDown)
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
friend APFloat scalbn(APFloat X, int Exp, roundingMode RM)
bool operator>=(const APFloat &RHS) const
bool needsCleanup() const
static APFloat getSmallest(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) finite number in the given semantics.
LLVM_ABI FPClassTest classify() const
Return the FPClassTest which will return true for the value.
bool operator==(const APFloat &RHS) const
opStatus mod(const APFloat &RHS)
LLVM_ABI void toStringShortest(SmallVectorImpl< char > &Str, unsigned FormatMaxPadding=3, bool TruncateZero=true) const
Like toString, but picks the smallest FormatPrecision whose output parses back bitwise equal: "3....
APInt getNaNPayload() const
If the value is a NaN value, return an integer containing the payload of this value.
friend int ilogb(const APFloat &Arg)
Returns the exponent of the internal representation of the APFloat.
LLVM_ABI Expected< opStatus > convertFromString(StringRef, roundingMode)
Fill this APFloat with the result of a string conversion.
fltCategory getCategory() const
APFloat(const fltSemantics &Semantics, uninitializedTag)
bool isNegInfinity() const
LLVM_DUMP_METHOD void dump() const
LLVM_ABI bool toStringRoundTrip(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const
Format the value as toString does and return true if the string parses back bitwise equal.
LLVM_ABI void print(raw_ostream &) const
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.
LLVM_READONLY bool isMinusOne() const
opStatus roundToIntegral(roundingMode RM)
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
static bool hasSignificand(const fltSemantics &Sem)
Returns true if the given semantics has actual significand.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
cmpResult compare(const APFloat &RHS) const
bool isSmallestNormalized() const
APFloat(const fltSemantics &Semantics, const APInt &I)
bool operator<=(const APFloat &RHS) const
Class for arbitrary precision integers.
static constexpr unsigned APINT_BITS_PER_WORD
Bits in a word.
An arbitrary precision integer that knows its signedness.
Tagged union holding either a T or a Error.
Interface for fltSemantics callbacks to access the internal data of APFloat/IEEEFloat.
LLVM_ABI void setNegative(bool Negative)
LLVM_ABI bool isNegative() const
LLVM_ABI void initialize(const fltSemantics &Sem)
Set the semantics and allocate storage for the significand.
LLVM_ABI APFloatBase::fltCategory getCategory() const
LLVM_ABI void setExponent(APFloatBase::ExponentType Exponent)
LLVM_ABI APInt getSignificand() const
LLVM_ABI const fltSemantics & getSemantics() const
LLVM_ABI void setCategory(APFloatBase::fltCategory Category)
Exponent and significand are only meaningful for fcNormal and fcNaN.
LLVM_ABI void setSignificand(const APInt &Significand)
The significand is precision bits wide and includes the integer bit.
LLVM_ABI APFloatBase::ExponentType getExponent() const
This class is used to gather all the unique data bits of a node.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Represent a constant reference to a string, i.e.
LLVM Value Representation.
LLVM_ABI void makeSmallestNormalized(bool Neg)
LLVM_ABI DoubleAPFloat & operator=(const DoubleAPFloat &RHS)
LLVM_ABI void changeSign()
LLVM_ABI bool isLargest() const
LLVM_ABI opStatus remainder(const DoubleAPFloat &RHS)
LLVM_ABI opStatus multiply(const DoubleAPFloat &RHS, roundingMode RM)
LLVM_ABI fltCategory getCategory() const
LLVM_ABI bool bitwiseIsEqual(const DoubleAPFloat &RHS) const
LLVM_ABI LLVM_READONLY int getExactLog2Abs() const
LLVM_ABI opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
LLVM_ABI APInt bitcastToAPInt() const
LLVM_ABI Expected< opStatus > convertFromString(StringRef, roundingMode)
LLVM_ABI bool isSmallest() const
LLVM_ABI opStatus subtract(const DoubleAPFloat &RHS, roundingMode RM)
LLVM_ABI friend hash_code hash_value(const DoubleAPFloat &Arg)
LLVM_ABI cmpResult compareAbsoluteValue(const DoubleAPFloat &RHS) const
LLVM_ABI bool isDenormal() const
LLVM_ABI opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
LLVM_ABI void makeSmallest(bool Neg)
LLVM_ABI friend int ilogb(const DoubleAPFloat &X)
LLVM_ABI opStatus next(bool nextDown)
LLVM_ABI void makeInf(bool Neg)
LLVM_ABI bool isInteger() const
LLVM_ABI void makeZero(bool Neg)
LLVM_ABI opStatus divide(const DoubleAPFloat &RHS, roundingMode RM)
LLVM_ABI bool isSmallestNormalized() const
LLVM_ABI opStatus mod(const DoubleAPFloat &RHS)
LLVM_ABI DoubleAPFloat(const fltSemantics &S)
LLVM_ABI void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision, unsigned FormatMaxPadding, bool TruncateZero=true) const
LLVM_ABI void makeLargest(bool Neg)
LLVM_ABI cmpResult compare(const DoubleAPFloat &RHS) const
LLVM_ABI friend DoubleAPFloat scalbn(const DoubleAPFloat &X, int Exp, roundingMode)
LLVM_ABI opStatus roundToIntegral(roundingMode RM)
LLVM_ABI opStatus fusedMultiplyAdd(const DoubleAPFloat &Multiplicand, const DoubleAPFloat &Addend, roundingMode RM)
LLVM_ABI APInt getNaNPayload() const
LLVM_ABI unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const
bool needsCleanup() const
LLVM_ABI bool isNegative() const
LLVM_ABI opStatus add(const DoubleAPFloat &RHS, roundingMode RM)
LLVM_ABI friend DoubleAPFloat frexp(const DoubleAPFloat &X, int &Exp, roundingMode)
LLVM_ABI void makeNaN(bool SNaN, bool Neg, const APInt *fill)
LLVM_ABI 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...
LLVM_ABI cmpResult compareAbsoluteValue(const IEEEFloat &) const
LLVM_ABI opStatus mod(const IEEEFloat &)
C fmod, or llvm frem.
fltCategory getCategory() const
LLVM_ABI opStatus convertFromAPInt(const APInt &, bool, roundingMode)
LLVM_ABI APInt getNaNPayload() const
bool isFiniteNonZero() const
bool needsCleanup() const
Returns whether this instance allocated memory.
LLVM_ABI void makeLargest(bool Neg=false)
Make this number the largest magnitude normal number in the given semantics.
LLVM_ABI LLVM_READONLY int getExactLog2Abs() const
LLVM_ABI APInt bitcastToAPInt() const
LLVM_ABI friend IEEEFloat scalbn(IEEEFloat X, int Exp, roundingMode)
LLVM_ABI cmpResult compare(const IEEEFloat &) const
IEEE comparison with another floating point number (NaNs compare unordered, 0==-0).
bool isNegative() const
IEEE-754R isSignMinus: Returns true if and only if the current value is negative.
LLVM_ABI opStatus divide(const IEEEFloat &, roundingMode)
LLVM_ABI friend hash_code hash_value(const IEEEFloat &Arg)
Overload to compute a hash code for an APFloat value.
bool isNaN() const
Returns true if and only if the float is a quiet or signaling NaN.
LLVM_ABI opStatus remainder(const IEEEFloat &)
IEEE remainder.
LLVM_ABI double convertToDouble() const
LLVM_ABI float convertToFloat() const
LLVM_ABI opStatus subtract(const IEEEFloat &, roundingMode)
LLVM_ABI void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const
Converts this value into a decimal string.
LLVM_ABI void makeSmallest(bool Neg=false)
Make this number the smallest magnitude denormal number in the given semantics.
LLVM_ABI void makeInf(bool Neg=false)
bool isNormal() const
IEEE-754R isNormal: Returns true if and only if the current value is normal.
LLVM_ABI bool isSmallestNormalized() const
Returns true if this is the smallest (by magnitude) normalized finite number in the given semantics.
friend class IEEEFloatUnitTestHelper
friend void initFromAPIntForSemantics(FloatRepr &, const APInt &)
LLVM_ABI void makeQuiet()
LLVM_ABI bool isLargest() const
Returns true if and only if the number has the largest possible finite magnitude in the current seman...
LLVM_ABI opStatus add(const IEEEFloat &, roundingMode)
bool isFinite() const
Returns true if and only if the current value is zero, subnormal, or normal.
friend APInt bitcastForSemantics(const FloatRepr &R)
LLVM_ABI Expected< opStatus > convertFromString(StringRef, roundingMode)
LLVM_ABI void makeNaN(bool SNaN=false, bool Neg=false, const APInt *fill=nullptr)
LLVM_ABI opStatus multiply(const IEEEFloat &, roundingMode)
LLVM_ABI opStatus roundToIntegral(roundingMode)
LLVM_ABI IEEEFloat & operator=(const IEEEFloat &)
LLVM_ABI bool bitwiseIsEqual(const IEEEFloat &) const
Bitwise comparison for equality (QNaNs compare equal, 0!=-0).
LLVM_ABI void makeSmallestNormalized(bool Negative=false)
Returns the smallest (by magnitude) normalized finite number in the given semantics.
LLVM_ABI bool isInteger() const
Returns true if and only if the number is an exact integer.
LLVM_ABI IEEEFloat(const fltSemantics &)
LLVM_ABI opStatus fusedMultiplyAdd(const IEEEFloat &, const IEEEFloat &, roundingMode)
LLVM_ABI friend int ilogb(const IEEEFloat &Arg)
LLVM_ABI opStatus next(bool nextDown)
IEEE-754R 5.3.1: nextUp/nextDown.
bool isInfinity() const
IEEE-754R isInfinite(): Returns true if and only if the float is infinity.
const fltSemantics & getSemantics() const
bool isZero() const
Returns true if and only if the float is plus or minus zero.
LLVM_ABI bool isSignaling() const
Returns true if and only if the float is a signaling NaN.
bool operator==(const IEEEFloat &) const =delete
The definition of equality is not straightforward for floating point, so we won't use operator==.
LLVM_ABI void makeZero(bool Neg=false)
LLVM_ABI opStatus convert(const fltSemantics &, roundingMode, bool *)
IEEEFloat::convert - convert a value of one floating point type to another.
LLVM_ABI void changeSign()
LLVM_ABI bool isDenormal() const
IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal.
LLVM_ABI opStatus convertToInteger(MutableArrayRef< integerPart >, unsigned int, bool, roundingMode, bool *) const
LLVM_ABI friend IEEEFloat frexp(const IEEEFloat &X, int &Exp, roundingMode)
LLVM_ABI bool isSmallest() const
Returns true if and only if the number has the smallest possible non-zero magnitude in the current se...
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static constexpr opStatus opInexact
static constexpr fltCategory fcNaN
static constexpr opStatus opDivByZero
static constexpr opStatus opOverflow
static constexpr cmpResult cmpLessThan
static constexpr roundingMode rmTowardPositive
static constexpr uninitializedTag uninitialized
static constexpr fltCategory fcZero
static constexpr opStatus opOK
static constexpr cmpResult cmpGreaterThan
static constexpr unsigned integerPartWidth
LLVM_ABI hash_code hash_value(const IEEEFloat &Arg)
APFloatBase::ExponentType ExponentType
APFloatBase::fltCategory fltCategory
static constexpr fltCategory fcNormal
static constexpr opStatus opInvalidOp
APFloatBase::opStatus opStatus
LLVM_ABI IEEEFloat frexp(const IEEEFloat &Val, int &Exp, roundingMode RM)
APFloatBase::uninitializedTag uninitializedTag
static constexpr cmpResult cmpUnordered
static constexpr roundingMode rmTowardNegative
APFloatBase::roundingMode roundingMode
APFloatBase::cmpResult cmpResult
static constexpr fltCategory fcInfinity
static constexpr roundingMode rmNearestTiesToAway
static constexpr roundingMode rmTowardZero
static constexpr opStatus opUnderflow
static constexpr roundingMode rmNearestTiesToEven
LLVM_ABI int ilogb(const IEEEFloat &Arg)
static constexpr cmpResult cmpEqual
LLVM_ABI IEEEFloat scalbn(IEEEFloat X, int Exp, roundingMode)
APFloatBase::integerPart integerPart
This is an optimization pass for GlobalISel generic memory operations.
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
hash_code hash_value(const FixedPointSemantics &Val)
static constexpr APFloatBase::ExponentType exponentZero(const fltSemantics &semantics)
APFloat abs(APFloat X)
Returns the absolute value of the argument.
LLVM_READONLY APFloat maximum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2019 maximum semantics.
static void assign(DXContainerYAML::SourceInfo::SectionHeader &Dst, const dxbc::SourceInfo::SectionHeader &Src)
int ilogb(const APFloat &Arg)
Returns the exponent of the internal representation of the APFloat.
APFloat frexp(const APFloat &X, int &Exp, APFloat::roundingMode RM)
Equivalent of C standard library function.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE-754 2008 maxNum semantics.
lostFraction
Enum that represents what fraction of the LSB truncated bits of an fp number represent.
LLVM_READONLY LLVM_ABI std::optional< APFloat > exp(const APFloat &X, RoundingMode RM=APFloat::rmNearestTiesToEven, APFloat::opStatus *Status=nullptr)
Implement IEEE 754-2019 exp functions.
LLVM_READONLY APFloat minimumnum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2019 minimumNumber semantics.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
APFloat scalbn(APFloat X, int Exp, APFloat::roundingMode RM)
Returns: X * 2^Exp for integral exponents.
static constexpr APFloatBase::ExponentType exponentNaN(const fltSemantics &semantics)
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE-754 2008 minNum semantics.
RoundingMode
Rounding mode.
@ TowardZero
roundTowardZero.
@ NearestTiesToEven
roundTiesToEven.
@ TowardPositive
roundTowardPositive.
@ NearestTiesToAway
roundTiesToAway.
@ TowardNegative
roundTowardNegative.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
static constexpr APFloatBase::ExponentType exponentInf(const fltSemantics &semantics)
APFloat neg(APFloat X)
Returns the negated value of the argument.
LLVM_READONLY APFloat minimum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2019 minimum semantics.
LLVM_READONLY APFloat maximumnum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2019 maximumNumber semantics.
APFloatBase::ExponentType maxExponent
fltNonfiniteBehavior nonFiniteBehavior
APFloatBase::ExponentType minExponent
APInt(* bitcastToAPInt)(const FloatRepr &)
fltNanEncoding nanEncoding
bool hasExplicitIntegerBit
void(* initFromAPInt)(FloatRepr &, const APInt &)