15#ifndef LLVM_ADT_APFLOAT_H
16#define LLVM_ADT_APFLOAT_H
25#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
27 if (usesLayout<IEEEFloat>(getSemantics())) \
28 return U.IEEE.METHOD_CALL; \
29 if (usesLayout<DoubleAPFloat>(getSemantics())) \
30 return U.Double.METHOD_CALL; \
31 llvm_unreachable("Unexpected semantics"); \
42template <
typename T>
class Expected;
43template <
typename T>
class SmallVectorImpl;
381#ifdef HAS_IEE754_FLOAT128
382 float128 convertToQuad()
const;
513 unsigned FormatMaxPadding = 3,
bool TruncateZero =
true)
const;
552 void makeNaN(
bool SNaN =
false,
bool Neg =
false,
553 const APInt *fill =
nullptr);
554 void makeInf(
bool Neg =
false);
574 unsigned int partCount()
const;
587 void incrementSignificand();
589 void shiftSignificandLeft(
unsigned int);
591 unsigned int significandLSB()
const;
592 unsigned int significandMSB()
const;
593 void zeroSignificand();
595 bool isSignificandAllOnes()
const;
596 bool isSignificandAllOnesExceptLSB()
const;
598 bool isSignificandAllZeros()
const;
599 bool isSignificandAllZerosExceptMSB()
const;
617 bool convertFromStringSpecials(
StringRef str);
629 char *convertNormalToHexString(
char *,
unsigned int,
bool,
639 template <const fltSemantics &S>
APInt convertIEEEFloatToAPInt()
const;
640 APInt convertHalfAPFloatToAPInt()
const;
641 APInt convertBFloatAPFloatToAPInt()
const;
642 APInt convertFloatAPFloatToAPInt()
const;
643 APInt convertDoubleAPFloatToAPInt()
const;
644 APInt convertQuadrupleAPFloatToAPInt()
const;
645 APInt convertF80LongDoubleAPFloatToAPInt()
const;
646 APInt convertPPCDoubleDoubleAPFloatToAPInt()
const;
647 APInt convertFloat8E5M2APFloatToAPInt()
const;
648 APInt convertFloat8E5M2FNUZAPFloatToAPInt()
const;
649 APInt convertFloat8E4M3APFloatToAPInt()
const;
650 APInt convertFloat8E4M3FNAPFloatToAPInt()
const;
651 APInt convertFloat8E4M3FNUZAPFloatToAPInt()
const;
652 APInt convertFloat8E4M3B11FNUZAPFloatToAPInt()
const;
653 APInt convertFloat8E3M4APFloatToAPInt()
const;
654 APInt convertFloatTF32APFloatToAPInt()
const;
655 APInt convertFloat6E3M2FNAPFloatToAPInt()
const;
656 APInt convertFloat6E2M3FNAPFloatToAPInt()
const;
657 APInt convertFloat4E2M1FNAPFloatToAPInt()
const;
659 template <const fltSemantics &S>
void initFromIEEEAPInt(
const APInt &api);
660 void initFromHalfAPInt(
const APInt &api);
661 void initFromBFloatAPInt(
const APInt &api);
662 void initFromFloatAPInt(
const APInt &api);
663 void initFromDoubleAPInt(
const APInt &api);
664 void initFromQuadrupleAPInt(
const APInt &api);
665 void initFromF80LongDoubleAPInt(
const APInt &api);
666 void initFromPPCDoubleDoubleAPInt(
const APInt &api);
667 void initFromFloat8E5M2APInt(
const APInt &api);
668 void initFromFloat8E5M2FNUZAPInt(
const APInt &api);
669 void initFromFloat8E4M3APInt(
const APInt &api);
670 void initFromFloat8E4M3FNAPInt(
const APInt &api);
671 void initFromFloat8E4M3FNUZAPInt(
const APInt &api);
672 void initFromFloat8E4M3B11FNUZAPInt(
const APInt &api);
673 void initFromFloat8E3M4APInt(
const APInt &api);
674 void initFromFloatTF32APInt(
const APInt &api);
675 void initFromFloat6E3M2FNAPInt(
const APInt &api);
676 void initFromFloat6E2M3FNAPInt(
const APInt &api);
677 void initFromFloat4E2M1FNAPInt(
const APInt &api);
681 void freeSignificand();
705 unsigned int sign : 1;
709int ilogb(
const IEEEFloat &Arg);
720 std::unique_ptr<APFloat[]> Floats;
777 bool *IsExact)
const;
780 unsigned int InputSize,
bool IsSigned,
783 unsigned int InputSize,
bool IsSigned,
795 unsigned FormatMaxPadding,
bool TruncateZero =
true)
const;
821 static_assert(std::is_standard_layout<IEEEFloat>::value);
830 : Double(std::move(
F)) {
834 template <
typename... ArgTypes>
840 if (usesLayout<DoubleAPFloat>(
Semantics)) {
848 if (usesLayout<IEEEFloat>(*semantics)) {
852 if (usesLayout<DoubleAPFloat>(*semantics)) {
853 Double.~DoubleAPFloat();
859 Storage(
const Storage &
RHS) {
860 if (usesLayout<IEEEFloat>(*
RHS.semantics)) {
864 if (usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
871 Storage(Storage &&
RHS) {
872 if (usesLayout<IEEEFloat>(*
RHS.semantics)) {
876 if (usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
883 Storage &operator=(
const Storage &
RHS) {
884 if (usesLayout<IEEEFloat>(*semantics) &&
885 usesLayout<IEEEFloat>(*
RHS.semantics)) {
887 }
else if (usesLayout<DoubleAPFloat>(*semantics) &&
888 usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
890 }
else if (
this != &
RHS) {
892 new (
this) Storage(
RHS);
897 Storage &operator=(Storage &&
RHS) {
898 if (usesLayout<IEEEFloat>(*semantics) &&
899 usesLayout<IEEEFloat>(*
RHS.semantics)) {
901 }
else if (usesLayout<DoubleAPFloat>(*semantics) &&
902 usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
903 Double = std::move(
RHS.Double);
904 }
else if (
this != &
RHS) {
906 new (
this) Storage(std::move(
RHS));
913 static_assert(std::is_same<T, IEEEFloat>::value ||
914 std::is_same<T, DoubleAPFloat>::value);
915 if (std::is_same<T, DoubleAPFloat>::value) {
922 if (usesLayout<IEEEFloat>(*U.semantics))
924 if (usesLayout<DoubleAPFloat>(*U.semantics))
925 return U.Double.getFirst().U.IEEE;
930 if (usesLayout<IEEEFloat>(*U.semantics))
932 if (usesLayout<DoubleAPFloat>(*U.semantics))
933 return U.Double.getFirst().U.IEEE;
941 void makeNaN(
bool SNaN,
bool Neg,
const APInt *fill) {
945 void makeLargest(
bool Neg) {
949 void makeSmallest(
bool Neg) {
953 void makeSmallestNormalized(
bool Neg) {
959 : U(std::move(
F), S) {}
963 "Should only compare APFloats with the same semantics");
965 return U.IEEE.compareAbsoluteValue(
RHS.U.IEEE);
967 return U.Double.compareAbsoluteValue(
RHS.U.Double);
975 template <
typename T,
976 typename = std::enable_if_t<std::is_floating_point<T>::value>>
996 Val.makeZero(Negative);
1004 return APFloat(Sem, Negative ? -1 : 1);
1012 Val.makeInf(Negative);
1024 APInt intPayload(64, payload);
1025 return getQNaN(Sem, Negative, &intPayload);
1027 return getQNaN(Sem, Negative,
nullptr);
1033 const APInt *payload =
nullptr) {
1035 Val.makeNaN(
false, Negative, payload);
1041 const APInt *payload =
nullptr) {
1043 Val.makeNaN(
true, Negative, payload);
1052 Val.makeLargest(Negative);
1062 Val.makeSmallest(Negative);
1071 bool Negative =
false) {
1073 Val.makeSmallestNormalized(Negative);
1100 "Should only call on two APFloats with the same semantics");
1102 return U.IEEE.add(
RHS.U.IEEE, RM);
1104 return U.Double.add(
RHS.U.Double, RM);
1109 "Should only call on two APFloats with the same semantics");
1111 return U.IEEE.subtract(
RHS.U.IEEE, RM);
1113 return U.Double.subtract(
RHS.U.Double, RM);
1118 "Should only call on two APFloats with the same semantics");
1120 return U.IEEE.multiply(
RHS.U.IEEE, RM);
1122 return U.Double.multiply(
RHS.U.Double, RM);
1127 "Should only call on two APFloats with the same semantics");
1129 return U.IEEE.divide(
RHS.U.IEEE, RM);
1131 return U.Double.divide(
RHS.U.Double, RM);
1136 "Should only call on two APFloats with the same semantics");
1138 return U.IEEE.remainder(
RHS.U.IEEE);
1140 return U.Double.remainder(
RHS.U.Double);
1145 "Should only call on two APFloats with the same semantics");
1147 return U.IEEE.mod(
RHS.U.IEEE);
1149 return U.Double.mod(
RHS.U.Double);
1155 "Should only call on APFloats with the same semantics");
1157 "Should only call on APFloats with the same semantics");
1159 return U.IEEE.fusedMultiplyAdd(Multiplicand.U.IEEE, Addend.U.IEEE, RM);
1161 return U.Double.fusedMultiplyAdd(Multiplicand.U.Double, Addend.U.Double,
1178 Result.changeSign();
1227 Value.copySign(Sign);
1235 Result.getIEEE().makeQuiet();
1243 bool *IsExact)
const {
1248 bool *IsExact)
const;
1254 unsigned int InputSize,
bool IsSigned,
1260 unsigned int InputSize,
bool IsSigned,
1282#ifdef HAS_IEE754_FLOAT128
1283 float128 convertToQuad()
const;
1317 "Should only compare APFloats with the same semantics");
1319 return U.IEEE.compare(
RHS.U.IEEE);
1321 return U.Double.compare(
RHS.U.Double);
1329 return U.IEEE.bitwiseIsEqual(
RHS.U.IEEE);
1331 return U.Double.bitwiseIsEqual(
RHS.U.Double);
1391 unsigned FormatMaxPadding = 3,
bool TruncateZero =
true)
const {
1393 toString(Str, FormatPrecision, FormatMaxPadding, TruncateZero));
1427 if (APFloat::usesLayout<detail::IEEEFloat>(
X.getSemantics()))
1429 if (APFloat::usesLayout<detail::DoubleAPFloat>(
X.getSemantics()))
1439 if (APFloat::usesLayout<detail::IEEEFloat>(
X.getSemantics()))
1441 if (APFloat::usesLayout<detail::DoubleAPFloat>(
X.getSemantics()))
1466 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1467 return A.isNegative() ?
A :
B;
1468 return B <
A ?
B :
A;
1480 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1481 return A.isNegative() ?
B :
A;
1482 return A <
B ?
B :
A;
1493 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1494 return A.isNegative() ?
A :
B;
1495 return B <
A ?
B :
A;
1503 return B.isNaN() ?
B.makeQuiet() :
B;
1506 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1507 return A.isNegative() ?
A :
B;
1508 return B <
A ?
B :
A;
1519 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1520 return A.isNegative() ?
B :
A;
1521 return A <
B ?
B :
A;
1529 return B.isNaN() ?
B.makeQuiet() :
B;
1532 if (
A.isZero() &&
B.isZero() && (
A.isNegative() !=
B.isNegative()))
1533 return A.isNegative() ?
B :
A;
1534 return A <
B ?
B :
A;
1560#undef APFLOAT_DISPATCH_ON_SEMANTICS
#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL)
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is MaybeLiveUses might be modified but its content should be ignored(since it might not be complete). DeadArgumentEliminationPass
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
Utilities for dealing with flags related to floating point properties and mode controls.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
opStatus divide(const APFloat &RHS, roundingMode RM)
bool getExactInverse(APFloat *inv) const
APFloat & operator=(APFloat &&RHS)=default
bool isFiniteNonZero() const
static bool hasNanOrInf(const fltSemantics &Sem)
APFloat(const APFloat &RHS)=default
void copySign(const APFloat &RHS)
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
APFloat operator+(const APFloat &RHS) const
Add two APFloats, rounding ties to the nearest even.
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
static APFloat getAllOnesValue(const fltSemantics &Semantics)
Returns a float which is bitcasted from an all one value int.
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)
opStatus convertFromSignExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
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)
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.
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.
FPClassTest classify() const
Return the FPClassTest which will return true for the value.
bool operator==(const APFloat &RHS) const
opStatus mod(const APFloat &RHS)
friend int ilogb(const APFloat &Arg)
Expected< opStatus > convertFromString(StringRef, roundingMode)
fltCategory getCategory() const
APFloat(const fltSemantics &Semantics, uninitializedTag)
bool isNegInfinity() const
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.
opStatus roundToIntegral(roundingMode RM)
friend hash_code hash_value(const APFloat &Arg)
See friend declarations above.
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
cmpResult compare(const APFloat &RHS) const
opStatus convertFromZeroExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
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.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
void makeSmallestNormalized(bool Neg)
DoubleAPFloat & operator=(const DoubleAPFloat &RHS)
LLVM_READONLY int getExactLog2() const
opStatus remainder(const DoubleAPFloat &RHS)
opStatus multiply(const DoubleAPFloat &RHS, roundingMode RM)
fltCategory getCategory() const
bool bitwiseIsEqual(const DoubleAPFloat &RHS) const
LLVM_READONLY int getExactLog2Abs() const
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
opStatus convertFromZeroExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
APInt bitcastToAPInt() const
bool getExactInverse(APFloat *inv) const
Expected< opStatus > convertFromString(StringRef, roundingMode)
opStatus subtract(const DoubleAPFloat &RHS, roundingMode RM)
cmpResult compareAbsoluteValue(const DoubleAPFloat &RHS) const
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
void makeSmallest(bool Neg)
opStatus next(bool nextDown)
friend DoubleAPFloat scalbn(const DoubleAPFloat &X, int Exp, roundingMode)
opStatus divide(const DoubleAPFloat &RHS, roundingMode RM)
friend hash_code hash_value(const DoubleAPFloat &Arg)
bool isSmallestNormalized() const
opStatus mod(const DoubleAPFloat &RHS)
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision, unsigned FormatMaxPadding, bool TruncateZero=true) const
void makeLargest(bool Neg)
cmpResult compare(const DoubleAPFloat &RHS) const
opStatus roundToIntegral(roundingMode RM)
opStatus convertFromSignExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
opStatus fusedMultiplyAdd(const DoubleAPFloat &Multiplicand, const DoubleAPFloat &Addend, roundingMode RM)
unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const
bool needsCleanup() const
opStatus add(const DoubleAPFloat &RHS, roundingMode RM)
friend DoubleAPFloat frexp(const DoubleAPFloat &X, int &Exp, roundingMode)
void makeNaN(bool SNaN, bool Neg, const APInt *fill)
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...
fltCategory getCategory() const
bool isFiniteNonZero() const
opStatus add(const IEEEFloat &, roundingMode)
bool getExactInverse(APFloat *inv) const
If this value has an exact multiplicative inverse, store it in inv and return true.
bool needsCleanup() const
Returns whether this instance allocated memory.
void makeLargest(bool Neg=false)
Make this number the largest magnitude normal number in the given semantics.
LLVM_READONLY int getExactLog2Abs() const
opStatus next(bool nextDown)
IEEE-754R 5.3.1: nextUp/nextDown.
APInt bitcastToAPInt() const
bool isNegative() const
IEEE-754R isSignMinus: Returns true if and only if the current value is negative.
opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)
bool isNaN() const
Returns true if and only if the float is a quiet or signaling NaN.
opStatus convertFromAPInt(const APInt &, bool, roundingMode)
opStatus roundToIntegral(roundingMode)
double convertToDouble() const
float convertToFloat() const
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const
Converts this value into a decimal string.
cmpResult compareAbsoluteValue(const IEEEFloat &) const
opStatus fusedMultiplyAdd(const IEEEFloat &, const IEEEFloat &, roundingMode)
void makeSmallest(bool Neg=false)
Make this number the smallest magnitude denormal number in the given semantics.
void makeInf(bool Neg=false)
bool isNormal() const
IEEE-754R isNormal: Returns true if and only if the current value is normal.
friend IEEEFloat frexp(const IEEEFloat &X, int &Exp, roundingMode)
Expected< opStatus > convertFromString(StringRef, roundingMode)
bool isSmallestNormalized() const
Returns true if this is the smallest (by magnitude) normalized finite number 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 isFinite() const
Returns true if and only if the current value is zero, subnormal, or normal.
void makeNaN(bool SNaN=false, bool Neg=false, const APInt *fill=nullptr)
opStatus convertToInteger(MutableArrayRef< integerPart >, unsigned int, bool, roundingMode, bool *) const
friend int ilogb(const IEEEFloat &Arg)
Returns the exponent of the internal representation of the APFloat.
opStatus remainder(const IEEEFloat &)
IEEE remainder.
friend hash_code hash_value(const IEEEFloat &Arg)
Overload to compute a hash code for an APFloat value.
IEEEFloat & operator=(const IEEEFloat &)
opStatus divide(const IEEEFloat &, roundingMode)
friend IEEEFloat scalbn(IEEEFloat X, int Exp, roundingMode)
Returns: X * 2^Exp for integral exponents.
bool bitwiseIsEqual(const IEEEFloat &) const
Bitwise comparison for equality (QNaNs compare equal, 0!=-0).
void makeSmallestNormalized(bool Negative=false)
Returns the smallest (by magnitude) normalized finite number in the given semantics.
bool isInteger() const
Returns true if and only if the number is an exact integer.
cmpResult compare(const IEEEFloat &) const
IEEE comparison with another floating point number (NaNs compare unordered, 0==-0).
opStatus subtract(const IEEEFloat &, roundingMode)
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.
bool isSignaling() const
Returns true if and only if the float is a signaling NaN.
opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)
bool operator==(const IEEEFloat &) const =delete
The definition of equality is not straightforward for floating point, so we won't use operator==.
void makeZero(bool Neg=false)
LLVM_READONLY int getExactLog2() const
bool isDenormal() const
IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal.
bool isSmallest() const
Returns true if and only if the number has the smallest possible non-zero magnitude in the current se...
opStatus mod(const IEEEFloat &)
C fmod, or llvm frem.
opStatus multiply(const IEEEFloat &, roundingMode)
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.
IEEEFloat scalbn(IEEEFloat X, int Exp, IEEEFloat::roundingMode)
hash_code hash_value(const IEEEFloat &Arg)
IEEEFloat frexp(const IEEEFloat &Val, int &Exp, IEEEFloat::roundingMode RM)
int ilogb(const IEEEFloat &Arg)
This is an optimization pass for GlobalISel generic memory operations.
hash_code hash_value(const FixedPointSemantics &Val)
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.
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 2019 maximumNumber semantics.
lostFraction
Enum that represents what fraction of the LSB truncated bits of an fp number represent.
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)
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE-754 2019 minimumNumber semantics.
RoundingMode
Rounding mode.
@ TowardZero
roundTowardZero.
@ NearestTiesToEven
roundTiesToEven.
@ TowardPositive
roundTowardPositive.
@ NearestTiesToAway
roundTiesToAway.
@ TowardNegative
roundTowardNegative.
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.
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
static const llvm::fltSemantics & EnumToSemantics(Semantics S)
static const fltSemantics & IEEEsingle() LLVM_READNONE
static const fltSemantics & Float6E3M2FN() LLVM_READNONE
static constexpr roundingMode rmNearestTiesToAway
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
static constexpr roundingMode rmTowardNegative
static ExponentType semanticsMinExponent(const fltSemantics &)
llvm::RoundingMode roundingMode
IEEE-754R 4.3: Rounding-direction attributes.
static constexpr roundingMode rmNearestTiesToEven
static unsigned int semanticsSizeInBits(const fltSemantics &)
static const fltSemantics & Float8E4M3() LLVM_READNONE
static unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
static const fltSemantics & Float8E4M3FN() LLVM_READNONE
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
static constexpr roundingMode rmTowardZero
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
uninitializedTag
Convenience enum used to construct an uninitialized APFloat.
static const fltSemantics & IEEEquad() LLVM_READNONE
static const fltSemantics & Float4E2M1FN() LLVM_READNONE
static const fltSemantics & Float8E4M3B11FNUZ() LLVM_READNONE
static const fltSemantics & Bogus() LLVM_READNONE
A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real.
static ExponentType semanticsMaxExponent(const fltSemantics &)
static unsigned int semanticsPrecision(const fltSemantics &)
static const fltSemantics & IEEEdouble() LLVM_READNONE
static const fltSemantics & Float8E5M2() LLVM_READNONE
static Semantics SemanticsToEnum(const llvm::fltSemantics &Sem)
static constexpr unsigned integerPartWidth
static const fltSemantics & IEEEhalf() LLVM_READNONE
APInt::WordType integerPart
static constexpr roundingMode rmTowardPositive
static bool isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst)
static const fltSemantics & Float8E4M3FNUZ() LLVM_READNONE
IlogbErrorKinds
Enumeration of ilogb error results.
static const fltSemantics & BFloat() LLVM_READNONE
static const fltSemantics & FloatTF32() LLVM_READNONE
static const fltSemantics & Float8E5M2FNUZ() LLVM_READNONE
static const fltSemantics & Float6E2M3FN() LLVM_READNONE
fltCategory
Category of internally-represented number.
static const fltSemantics & Float8E3M4() LLVM_READNONE
opStatus
IEEE-754R 7: Default exception handling.
int32_t ExponentType
A signed type to represent a floating point numbers unbiased exponent.
static unsigned int semanticsIntSizeInBits(const fltSemantics &, bool)