23#include "llvm/Config/llvm-config.h"
31#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
33 if (usesLayout<IEEEFloat>(getSemantics())) \
34 return U.IEEE.METHOD_CALL; \
35 if (usesLayout<DoubleAPFloat>(getSemantics())) \
36 return U.Double.METHOD_CALL; \
37 llvm_unreachable("Unexpected semantics"); \
48#define PackCategoriesIntoKey(_lhs, _rhs) ((_lhs) * 4 + (_rhs))
133constexpr fltSemantics APFloatBase::semIEEEhalf = {15, -14, 11, 16};
134constexpr fltSemantics APFloatBase::semBFloat = {127, -126, 8, 16};
135constexpr fltSemantics APFloatBase::semIEEEsingle = {127, -126, 24, 32};
136constexpr fltSemantics APFloatBase::semIEEEdouble = {1023, -1022, 53, 64};
137constexpr fltSemantics APFloatBase::semIEEEquad = {16383, -16382, 113, 128};
138constexpr fltSemantics APFloatBase::semFloat8E5M2 = {15, -14, 3, 8};
139constexpr fltSemantics APFloatBase::semFloat8E5M2FNUZ = {
141constexpr fltSemantics APFloatBase::semFloat8E4M3 = {7, -6, 4, 8};
144constexpr fltSemantics APFloatBase::semFloat8E4M3FNUZ = {
146constexpr fltSemantics APFloatBase::semFloat8E4M3B11FNUZ = {
148constexpr fltSemantics APFloatBase::semFloat8E3M4 = {3, -2, 5, 8};
149constexpr fltSemantics APFloatBase::semFloatTF32 = {127, -126, 11, 19};
167constexpr fltSemantics APFloatBase::semX87DoubleExtended = {16383, -16382, 64,
169constexpr fltSemantics APFloatBase::semBogus = {0, 0, 0, 0};
170constexpr fltSemantics APFloatBase::semPPCDoubleDouble = {-1, 0, 0, 128};
171constexpr fltSemantics APFloatBase::semPPCDoubleDoubleLegacy = {
172 1023, -1022 + 53, 53 + 53, 128};
268 return A.maxExponent <=
B.maxExponent &&
A.minExponent >=
B.minExponent &&
269 A.precision <=
B.precision;
349 if (Src.maxExponent >= Dst.maxExponent || Src.minExponent <= Dst.minExponent)
357 return Dst.precision >= Src.precision;
397static inline unsigned int
411 unsigned int absExponent;
412 const unsigned int overlargeExponent = 24000;
416 if (p == end || ((*p ==
'-' || *p ==
'+') && (p + 1) == end)) {
420 isNegative = (*p ==
'-');
421 if (*p ==
'-' || *p ==
'+') {
428 if (absExponent >= 10U)
429 return createError(
"Invalid character in exponent");
431 for (; p != end; ++p) {
436 return createError(
"Invalid character in exponent");
438 absExponent = absExponent * 10U + value;
439 if (absExponent >= overlargeExponent) {
440 absExponent = overlargeExponent;
446 return -(int) absExponent;
448 return (
int) absExponent;
455 int exponentAdjustment) {
456 int unsignedExponent;
457 bool negative, overflow;
463 negative = *p ==
'-';
464 if (*p ==
'-' || *p ==
'+') {
470 unsignedExponent = 0;
472 for (; p != end; ++p) {
477 return createError(
"Invalid character in exponent");
479 unsignedExponent = unsignedExponent * 10 + value;
480 if (unsignedExponent > 32767) {
486 if (exponentAdjustment > 32767 || exponentAdjustment < -32768)
490 exponent = unsignedExponent;
492 exponent = -exponent;
493 exponent += exponentAdjustment;
494 if (exponent > 32767 || exponent < -32768)
499 exponent = negative ? -32768: 32767;
509 while (p != end && *p ==
'0')
512 if (p != end && *p ==
'.') {
515 if (end - begin == 1)
518 while (p != end && *p ==
'0')
551 return PtrOrErr.takeError();
554 D->firstSigDigit = p;
556 D->normalizedExponent = 0;
558 for (; p != end; ++p) {
561 return createError(
"String contains multiple dots");
571 if (*p !=
'e' && *p !=
'E')
572 return createError(
"Invalid character in significand");
575 if (dot != end && p - begin == 1)
581 return ExpOrErr.takeError();
582 D->exponent = *ExpOrErr;
590 if (p !=
D->firstSigDigit) {
596 while (p != begin && *p ==
'0');
597 while (p != begin && *p ==
'.');
602 D->normalizedExponent = (
D->exponent +
604 - (dot >
D->firstSigDigit && dot < p)));
616 unsigned int digitValue) {
617 unsigned int hexDigit;
623 else if (digitValue < 8 && digitValue > 0)
627 while (p != end && (*p ==
'0' || *p ==
'.'))
631 return createError(
"Invalid trailing hexadecimal fraction!");
637 if (hexDigit == UINT_MAX)
647 unsigned int partCount,
676 return lost_fraction;
691 return moreSignificant;
702HUerrBound(
bool inexactMultiply,
unsigned int HUerr1,
unsigned int HUerr2)
704 assert(HUerr1 < 2 || HUerr2 < 2 || (HUerr1 + HUerr2 < 8));
706 if (HUerr1 + HUerr2 == 0)
707 return inexactMultiply * 2;
709 return inexactMultiply + 2 * (HUerr1 + HUerr2);
718 unsigned int count, partBits;
735 if (part - boundary <= boundary - part)
736 return part - boundary;
738 return boundary - part;
741 if (part == boundary) {
747 }
else if (part == boundary - 1) {
764 pow5s[0] = 78125 * 5;
766 unsigned int partsCount = 1;
774 *p1 = firstEightPowers[power & 7];
780 for (
unsigned int n = 0; power; power >>= 1, n++) {
784 partsCount, partsCount);
786 if (pow5[partsCount - 1] == 0)
794 result += partsCount;
795 if (p2[result - 1] == 0)
820static const char NaNL[] =
"nan";
821static const char NaNU[] =
"NAN";
828 const char *hexDigitChars)
830 unsigned int result =
count;
836 dst[
count] = hexDigitChars[part & 0xf];
880 switch (
X.getCategory()) {
890 if (
X.isDenormal() ||
X.isSmallestNormalized())
893 if (
X.getExactLog2() != INT_MIN)
901void IEEEFloat::initialize(
const fltSemantics *ourSemantics) {
904 semantics = ourSemantics;
910void IEEEFloat::freeSignificand() {
912 delete [] significand.parts;
915void IEEEFloat::assign(
const IEEEFloat &rhs) {
916 assert(semantics == rhs.semantics);
919 category = rhs.category;
920 exponent = rhs.exponent;
922 copySignificand(rhs);
925void IEEEFloat::copySignificand(
const IEEEFloat &rhs) {
927 assert(rhs.partCount() >= partCount());
940 if (Negative && !semantics->hasSignedRepr)
942 "This floating point format does not support signed values");
946 exponent = exponentNaN();
949 unsigned numParts = partCount();
962 fill = &fill_storage;
966 if (!
fill ||
fill->getNumWords() < numParts)
970 std::min(
fill->getNumWords(), numParts));
973 unsigned bitsToPreserve = semantics->precision - 1;
974 unsigned part = bitsToPreserve / 64;
975 bitsToPreserve %= 64;
976 significand[part] &= ((1ULL << bitsToPreserve) - 1);
977 for (part++; part != numParts; ++part)
978 significand[part] = 0;
982 (semantics->precision >= 2) ? (semantics->precision - 2) : 0;
1004 if (semantics == &APFloatBase::semX87DoubleExtended)
1010 if (semantics != rhs.semantics) {
1012 initialize(rhs.semantics);
1023 semantics = rhs.semantics;
1024 significand = rhs.significand;
1025 exponent = rhs.exponent;
1026 category = rhs.category;
1029 rhs.semantics = &APFloatBase::semBogus;
1036 semantics->precision - 1) == 0);
1044 significandMSB() == 0;
1049 isSignificandAllZerosExceptMSB();
1052unsigned int IEEEFloat::getNumHighBits()
const {
1059 const unsigned int NumHighBits = (semantics->
precision > 1)
1065bool IEEEFloat::isSignificandAllOnes()
const {
1070 for (
unsigned i = 0; i < PartCount - 1; i++)
1075 const unsigned NumHighBits = getNumHighBits();
1076 assert(NumHighBits <= integerPartWidth && NumHighBits > 0 &&
1077 "Can not have more high bits to fill than integerPartWidth");
1080 if ((semantics->
precision <= 1) || (~(Parts[PartCount - 1] | HighBitFill)))
1086bool IEEEFloat::isSignificandAllOnesExceptLSB()
const {
1095 for (
unsigned i = 0; i < PartCount - 1; i++) {
1096 if (~Parts[i] & ~
unsigned{!i})
1101 const unsigned NumHighBits = getNumHighBits();
1102 assert(NumHighBits <= integerPartWidth && NumHighBits > 0 &&
1103 "Can not have more high bits to fill than integerPartWidth");
1106 if (~(Parts[PartCount - 1] | HighBitFill | 0x1))
1112bool IEEEFloat::isSignificandAllZeros()
const {
1118 for (
unsigned i = 0; i < PartCount - 1; i++)
1123 const unsigned NumHighBits = getNumHighBits();
1125 "clear than integerPartWidth");
1126 const integerPart HighBitMask = ~integerPart(0) >> NumHighBits;
1128 if ((semantics->precision > 1) && (Parts[PartCount - 1] & HighBitMask))
1134bool IEEEFloat::isSignificandAllZerosExceptMSB()
const {
1138 for (
unsigned i = 0; i < PartCount - 1; i++) {
1143 const unsigned NumHighBits = getNumHighBits();
1146 return ((semantics->precision <= 1) || (Parts[PartCount - 1] == MSBMask));
1150 bool IsMaxExp =
isFiniteNonZero() && exponent == semantics->maxExponent;
1157 ? isSignificandAllOnesExceptLSB()
1162 return IsMaxExp && isSignificandAllOnes();
1177 if (semantics != rhs.semantics ||
1178 category != rhs.category ||
1187 return std::equal(significandParts(), significandParts() + partCount(),
1188 rhs.significandParts());
1192 initialize(&ourSemantics);
1197 significandParts()[0] =
value;
1202 initialize(&ourSemantics);
1218 initialize(rhs.semantics);
1223 *
this = std::move(rhs);
1228unsigned int IEEEFloat::partCount()
const {
1233 return const_cast<IEEEFloat *
>(
this)->significandParts();
1237 if (partCount() > 1)
1238 return significand.parts;
1240 return &significand.part;
1243void IEEEFloat::zeroSignificand() {
1248void IEEEFloat::incrementSignificand() {
1262 parts = significandParts();
1264 assert(semantics == rhs.semantics);
1265 assert(exponent == rhs.exponent);
1267 return APInt::tcAdd(parts, rhs.significandParts(), 0, partCount());
1276 parts = significandParts();
1278 assert(semantics == rhs.semantics);
1279 assert(exponent == rhs.exponent);
1290 bool ignoreAddend) {
1292 unsigned int partsCount, newPartsCount, precision;
1299 assert(semantics == rhs.semantics);
1301 precision = semantics->precision;
1307 if (newPartsCount > 4)
1310 fullSignificand = scratch;
1312 lhsSignificand = significandParts();
1313 partsCount = partCount();
1316 rhs.significandParts(), partsCount, partsCount);
1319 omsb =
APInt::tcMSB(fullSignificand, newPartsCount) + 1;
1320 exponent += rhs.exponent;
1334 if (!ignoreAddend && addend.isNonZero()) {
1338 Significand savedSignificand = significand;
1339 const fltSemantics *savedSemantics = semantics;
1340 fltSemantics extendedSemantics;
1342 unsigned int extendedPrecision;
1345 extendedPrecision = 2 * precision + 1;
1346 if (omsb != extendedPrecision - 1) {
1347 assert(extendedPrecision > omsb);
1349 (extendedPrecision - 1) - omsb);
1350 exponent -= (extendedPrecision - 1) - omsb;
1354 extendedSemantics = *semantics;
1355 extendedSemantics.
precision = extendedPrecision;
1357 if (newPartsCount == 1)
1358 significand.part = fullSignificand[0];
1360 significand.parts = fullSignificand;
1361 semantics = &extendedSemantics;
1375 lost_fraction = extendedAddend.shiftSignificandRight(1);
1377 "Lost precision while shifting addend for fused-multiply-add.");
1379 lost_fraction = addOrSubtractSignificand(extendedAddend,
false);
1382 if (newPartsCount == 1)
1383 fullSignificand[0] = significand.part;
1384 significand = savedSignificand;
1385 semantics = savedSemantics;
1387 omsb =
APInt::tcMSB(fullSignificand, newPartsCount) + 1;
1394 exponent -= precision + 1;
1403 if (omsb > precision) {
1404 unsigned int bits, significantParts;
1407 bits = omsb - precision;
1409 lf =
shiftRight(fullSignificand, significantParts, bits);
1416 if (newPartsCount > 4)
1417 delete [] fullSignificand;
1419 return lost_fraction;
1428 return multiplySignificand(rhs,
IEEEFloat(*semantics), !semantics->hasZero);
1433 unsigned int bit, i, partsCount;
1439 assert(semantics == rhs.semantics);
1441 lhsSignificand = significandParts();
1442 rhsSignificand = rhs.significandParts();
1443 partsCount = partCount();
1450 divisor = dividend + partsCount;
1453 for (i = 0; i < partsCount; i++) {
1454 dividend[i] = lhsSignificand[i];
1455 divisor[i] = rhsSignificand[i];
1456 lhsSignificand[i] = 0;
1459 exponent -= rhs.exponent;
1461 unsigned int precision = semantics->precision;
1464 bit = precision -
APInt::tcMSB(divisor, partsCount) - 1;
1471 bit = precision -
APInt::tcMSB(dividend, partsCount) - 1;
1487 for (bit = precision; bit; bit -= 1) {
1511 return lost_fraction;
1514unsigned int IEEEFloat::significandMSB()
const {
1518unsigned int IEEEFloat::significandLSB()
const {
1523lostFraction IEEEFloat::shiftSignificandRight(
unsigned int bits) {
1529 return shiftRight(significandParts(), partCount(), bits);
1533void IEEEFloat::shiftSignificandLeft(
unsigned int bits) {
1534 assert(bits < semantics->precision ||
1535 (semantics->precision == 1 && bits <= 1));
1538 unsigned int partsCount = partCount();
1550 assert(semantics == rhs.semantics);
1554 compare = exponent - rhs.exponent;
1606 exponent = semantics->maxExponent;
1608 semantics->precision);
1621bool IEEEFloat::roundAwayFromZero(
roundingMode rounding_mode,
1623 unsigned int bit)
const {
1630 switch (rounding_mode) {
1668 omsb = significandMSB() + 1;
1675 exponentChange = omsb - semantics->precision;
1679 if (exponent + exponentChange > semantics->maxExponent)
1680 return handleOverflow(rounding_mode);
1684 if (exponent + exponentChange < semantics->minExponent)
1685 exponentChange = semantics->minExponent - exponent;
1688 if (exponentChange < 0) {
1691 shiftSignificandLeft(-exponentChange);
1696 if (exponentChange > 0) {
1700 lf = shiftSignificandRight(exponentChange);
1705 if (omsb > (
unsigned) exponentChange)
1706 omsb -= exponentChange;
1716 exponent == semantics->maxExponent && isSignificandAllOnes())
1717 return handleOverflow(rounding_mode);
1730 if (!semantics->hasZero)
1738 if (roundAwayFromZero(rounding_mode, lost_fraction, 0)) {
1740 exponent = semantics->minExponent;
1742 incrementSignificand();
1743 omsb = significandMSB() + 1;
1746 if (omsb == (
unsigned) semantics->precision + 1) {
1750 if (exponent == semantics->maxExponent)
1757 shiftSignificandRight(1);
1766 exponent == semantics->maxExponent && isSignificandAllOnes())
1767 return handleOverflow(rounding_mode);
1772 if (omsb == semantics->precision)
1776 assert(omsb < semantics->precision);
1786 if (!semantics->hasZero)
1859 subtract ^=
static_cast<bool>(sign ^ rhs.sign);
1862 bits = exponent - rhs.exponent;
1866 if ((bits < 0) && !semantics->hasSignedRepr)
1868 "This floating point format does not support signed values");
1871 bool lost_fraction_is_from_rhs =
false;
1875 else if (bits > 0) {
1876 lost_fraction = temp_rhs.shiftSignificandRight(bits - 1);
1877 lost_fraction_is_from_rhs =
true;
1878 shiftSignificandLeft(1);
1880 lost_fraction = shiftSignificandRight(-bits - 1);
1881 temp_rhs.shiftSignificandLeft(1);
1888 lost_fraction !=
lfExactlyZero && !lost_fraction_is_from_rhs;
1897 carry = temp_rhs.subtractSignificand(*
this, borrow);
1898 copySignificand(temp_rhs);
1901 bool borrow = lost_fraction !=
lfExactlyZero && lost_fraction_is_from_rhs;
1910 carry = subtractSignificand(temp_rhs, borrow);
1913 if (lost_fraction !=
lfExactlyZero && lost_fraction_is_from_rhs) {
1927 lost_fraction = temp_rhs.shiftSignificandRight(bits);
1928 carry = addSignificand(temp_rhs);
1930 lost_fraction = shiftSignificandRight(-bits);
1931 carry = addSignificand(rhs);
1939 return lost_fraction;
2134 lost_fraction = addOrSubtractSignificand(rhs,
subtract);
2135 fs = normalize(rounding_mode, lost_fraction);
2144 if (category ==
fcZero) {
2158 return addOrSubtract(rhs, rounding_mode,
false);
2164 return addOrSubtract(rhs, rounding_mode,
true);
2173 fs = multiplySpecials(rhs);
2179 fs = normalize(rounding_mode, lost_fraction);
2193 fs = divideSpecials(rhs);
2199 fs = normalize(rounding_mode, lost_fraction);
2210 unsigned int origSign = sign;
2213 fs = remainderSpecials(rhs);
2320 fs = modSpecials(rhs);
2321 unsigned int origSign = sign;
2342 if (!semantics->hasZero && this->isSmallest())
2362 sign ^= multiplicand.sign;
2371 lost_fraction = multiplySignificand(multiplicand, addend);
2372 fs = normalize(rounding_mode, lost_fraction);
2385 fs = multiplySpecials(multiplicand);
2395 fs = addOrSubtract(addend, rounding_mode,
false);
2469 MagicConstant.sign = sign;
2475 fs =
add(MagicConstant, rounding_mode);
2479 subtract(MagicConstant, rounding_mode);
2492 assert(semantics == rhs.semantics);
2524 if (sign == rhs.sign)
2539 if (sign != rhs.sign) {
2570 unsigned int newPartCount, oldPartCount;
2578 oldPartCount = partCount();
2581 bool X86SpecialNan =
false;
2582 if (&fromSemantics == &APFloatBase::semX87DoubleExtended &&
2583 &toSemantics != &APFloatBase::semX87DoubleExtended && category ==
fcNaN &&
2584 (!(*significandParts() & 0x8000000000000000ULL) ||
2585 !(*significandParts() & 0x4000000000000000ULL))) {
2588 X86SpecialNan =
true;
2599 int omsb = significandMSB() + 1;
2600 int exponentChange = omsb - fromSemantics.
precision;
2601 if (exponent + exponentChange < toSemantics.
minExponent)
2602 exponentChange = toSemantics.
minExponent - exponent;
2603 exponentChange = std::max(exponentChange, shift);
2604 if (exponentChange < 0) {
2605 shift -= exponentChange;
2606 exponent += exponentChange;
2607 }
else if (omsb <= -shift) {
2608 exponentChange = omsb + shift - 1;
2609 shift -= exponentChange;
2610 exponent += exponentChange;
2616 (category ==
fcNaN && semantics->nonFiniteBehavior !=
2621 if (newPartCount > oldPartCount) {
2629 significand.parts = newParts;
2630 }
else if (newPartCount == 1 && oldPartCount != 1) {
2634 newPart = significandParts()[0];
2636 significand.part = newPart;
2640 semantics = &toSemantics;
2649 *losesInfo = (
fs !=
opOK);
2650 }
else if (category ==
fcNaN) {
2668 if (!X86SpecialNan && semantics == &APFloatBase::semX87DoubleExtended)
2685 }
else if (category ==
fcZero &&
2698 if (category ==
fcZero && !semantics->hasZero)
2718 unsigned int dstPartsCount, truncatedBits;
2727 assert(dstPartsCount <= parts.
size() &&
"Integer too big");
2729 if (category ==
fcZero) {
2736 src = significandParts();
2745 truncatedBits = semantics->
precision -1U - exponent;
2749 unsigned int bits = exponent + 1U;
2755 if (bits < semantics->precision) {
2757 truncatedBits = semantics->
precision - bits;
2764 bits - semantics->precision);
2771 if (truncatedBits) {
2775 roundAwayFromZero(rounding_mode, lost_fraction, truncatedBits)) {
2795 if (omsb == width &&
2832 fs = convertToSignExtendedInteger(parts, width,
isSigned, rounding_mode,
2836 unsigned int bits, dstPartsCount;
2839 assert(dstPartsCount <= parts.
size() &&
"Integer too big");
2841 if (category ==
fcNaN)
2861 unsigned int omsb, precision, dstCount;
2867 dst = significandParts();
2868 dstCount = partCount();
2873 if (precision <= omsb) {
2874 exponent = omsb - 1;
2879 exponent = precision - 1;
2884 return normalize(rounding_mode, lost_fraction);
2898 return convertFromUnsignedParts(api.
getRawData(), partCount, rounding_mode);
2902IEEEFloat::convertFromHexadecimalString(
StringRef s,
2911 unsigned partsCount = partCount();
2913 bool computedTrailingFraction =
false;
2921 return PtrOrErr.takeError();
2930 return createError(
"String contains multiple dots");
2936 if (hex_value == UINT_MAX)
2946 }
else if (!computedTrailingFraction) {
2949 return FractOrErr.takeError();
2950 lost_fraction = *FractOrErr;
2951 computedTrailingFraction =
true;
2957 return createError(
"Hex strings require an exponent");
2958 if (*p !=
'p' && *p !=
'P')
2959 return createError(
"Invalid character in significand");
2962 if (dot != end && p - begin == 1)
2966 if (p != firstSignificantDigit) {
2975 expAdjustment =
static_cast<int>(
dot - firstSignificantDigit);
2976 if (expAdjustment < 0)
2978 expAdjustment = expAdjustment * 4 - 1;
2982 expAdjustment += semantics->precision;
2988 return ExpOrErr.takeError();
2989 exponent = *ExpOrErr;
2992 return normalize(rounding_mode, lost_fraction);
2996IEEEFloat::roundSignificandWithExponent(
const integerPart *decSigParts,
2997 unsigned sigPartCount,
int exp,
2999 unsigned int parts, pow5PartCount;
3000 fltSemantics calcSemantics = { 32767, -32767, 0, 0 };
3010 pow5PartCount =
powerOf5(pow5Parts, exp >= 0 ? exp: -exp);
3012 for (;; parts *= 2) {
3014 unsigned int excessPrecision, truncatedBits;
3017 excessPrecision = calcSemantics.
precision - semantics->precision;
3018 truncatedBits = excessPrecision;
3021 decSig.makeZero(sign);
3024 sigStatus = decSig.convertFromUnsignedParts(decSigParts, sigPartCount,
3026 powStatus = pow5.convertFromUnsignedParts(pow5Parts, pow5PartCount,
3029 decSig.exponent += exp;
3033 unsigned int powHUerr;
3037 calcLostFraction = decSig.multiplySignificand(pow5);
3038 powHUerr = powStatus !=
opOK;
3040 calcLostFraction = decSig.divideSignificand(pow5);
3042 if (decSig.exponent < semantics->minExponent) {
3043 excessPrecision += (semantics->minExponent - decSig.exponent);
3044 truncatedBits = excessPrecision;
3045 excessPrecision = std::min(excessPrecision, calcSemantics.
precision);
3054 (decSig.significandParts(), calcSemantics.
precision - 1) == 1);
3059 excessPrecision, isNearest);
3062 if (HUdistance >= HUerr) {
3063 APInt::tcExtract(significandParts(), partCount(), decSig.significandParts(),
3064 calcSemantics.
precision - excessPrecision,
3069 exponent = (decSig.exponent + semantics->precision
3070 - (calcSemantics.
precision - excessPrecision));
3074 return normalize(rounding_mode, calcLostFraction);
3079Expected<APFloat::opStatus>
3080IEEEFloat::convertFromDecimalString(StringRef str,
roundingMode rounding_mode) {
3087 return std::move(Err);
3118 if (!semantics->hasZero)
3123 }
else if (
D.normalizedExponent - 1 > INT_MAX / 42039) {
3124 fs = handleOverflow(rounding_mode);
3130 }
else if (
D.normalizedExponent - 1 < INT_MIN / 42039 ||
3131 (
D.normalizedExponent + 1) * 28738 <=
3132 8651 * (semantics->minExponent - (
int) semantics->precision)) {
3139 }
else if ((
D.normalizedExponent - 1) * 42039
3140 >= 12655 * semantics->maxExponent) {
3142 fs = handleOverflow(rounding_mode);
3145 unsigned int partCount;
3151 partCount =
static_cast<unsigned int>(
D.lastSigDigit -
D.firstSigDigit) + 1;
3169 if (p == str.
end()) {
3174 if (decValue >= 10U) {
3175 delete[] decSignificand;
3176 return createError(
"Invalid character in significand");
3179 val = val * 10 + decValue;
3182 }
while (p <=
D.lastSigDigit && multiplier <= (~ (
integerPart) 0 - 9) / 10);
3186 partCount, partCount + 1,
false);
3190 if (decSignificand[partCount])
3192 }
while (p <=
D.lastSigDigit);
3195 fs = roundSignificandWithExponent(decSignificand, partCount,
3196 D.exponent, rounding_mode);
3198 delete [] decSignificand;
3204bool IEEEFloat::convertFromStringSpecials(StringRef str) {
3205 const size_t MIN_NAME_SIZE = 3;
3207 if (str.
size() < MIN_NAME_SIZE)
3210 if (str ==
"inf" || str ==
"INFINITY" || str ==
"+Inf") {
3217 if (str.
size() < MIN_NAME_SIZE)
3220 if (str ==
"inf" || str ==
"INFINITY" || str ==
"Inf") {
3229 if (str.
size() < MIN_NAME_SIZE)
3236 makeNaN(IsSignaling, IsNegative);
3241 if (str.
front() ==
'(') {
3243 if (str.
size() <= 2 || str.
back() !=
')')
3250 unsigned Radix = 10;
3251 if (str[0] ==
'0') {
3252 if (str.
size() > 1 && tolower(str[1]) ==
'x') {
3263 makeNaN(IsSignaling, IsNegative, &Payload);
3271Expected<APFloat::opStatus>
3277 if (convertFromStringSpecials(str))
3282 size_t slen = str.
size();
3283 sign = *p ==
'-' ? 1 : 0;
3284 if (sign && !semantics->hasSignedRepr)
3286 "This floating point format does not support signed values");
3288 if (*p ==
'-' || *p ==
'+') {
3295 if (slen >= 2 && p[0] ==
'0' && (p[1] ==
'x' || p[1] ==
'X')) {
3298 return convertFromHexadecimalString(
StringRef(p + 2, slen - 2),
3302 return convertFromDecimalString(
StringRef(p, slen), rounding_mode);
3346 dst +=
sizeof NaNU - 1;
3351 *dst++ = upperCase ?
'X':
'x';
3353 if (hexDigits > 1) {
3355 memset (dst,
'0', hexDigits - 1);
3356 dst += hexDigits - 1;
3358 *dst++ = upperCase ?
'P':
'p';
3363 dst = convertNormalToHexString (dst, hexDigits, upperCase, rounding_mode);
3369 return static_cast<unsigned int>(dst - p);
3376char *IEEEFloat::convertNormalToHexString(
char *dst,
unsigned int hexDigits,
3379 unsigned int count, valueBits, shift, partsCount, outputDigits;
3380 const char *hexDigitChars;
3386 *dst++ = upperCase ?
'X':
'x';
3391 significand = significandParts();
3392 partsCount = partCount();
3401 outputDigits = (valueBits - significandLSB () + 3) / 4;
3407 if (hexDigits < outputDigits) {
3413 bits = valueBits - hexDigits * 4;
3415 roundUp = roundAwayFromZero(rounding_mode, fraction, bits);
3417 outputDigits = hexDigits;
3427 while (outputDigits &&
count) {
3431 if (--
count == partsCount)
3434 part = significand[
count] << shift;
3442 curDigits = std::min(curDigits, outputDigits);
3443 dst +=
partAsHex (dst, part, curDigits, hexDigitChars);
3444 outputDigits -= curDigits;
3454 }
while (*q ==
'0');
3458 memset (dst,
'0', outputDigits);
3459 dst += outputDigits;
3472 *dst++ = upperCase ?
'P':
'p';
3488 Arg.significandParts(),
3489 Arg.significandParts() + Arg.partCount()));
3501APInt IEEEFloat::convertF80LongDoubleAPFloatToAPInt()
const {
3506 uint64_t myexponent, mysignificand;
3509 myexponent = exponent+16383;
3510 mysignificand = significandParts()[0];
3511 if (myexponent==1 && !(mysignificand & 0x8000000000000000ULL))
3513 }
else if (category==
fcZero) {
3517 myexponent = 0x7fff;
3518 mysignificand = 0x8000000000000000ULL;
3521 myexponent = 0x7fff;
3522 mysignificand = significandParts()[0];
3526 words[0] = mysignificand;
3527 words[1] = ((uint64_t)(sign & 1) << 15) |
3528 (myexponent & 0x7fffLL);
3529 return APInt(80, words);
3532APInt IEEEFloat::convertPPCDoubleDoubleLegacyAPFloatToAPInt()
const {
3534 (
const llvm::fltSemantics *)&APFloatBase::semPPCDoubleDoubleLegacy);
3547 fltSemantics extendedSemantics = *semantics;
3558 words[0] = *
u.convertDoubleAPFloatToAPInt().getRawData();
3564 if (
u.isFiniteNonZero() && losesInfo) {
3574 words[1] = *
v.convertDoubleAPFloatToAPInt().getRawData();
3579 return APInt(128, words);
3582template <const fltSemantics &S>
3583APInt IEEEFloat::convertIEEEFloatToAPInt()
const {
3585 const int bias = (semantics == &APFloatBase::semFloat8E8M0FNU)
3587 : -(S.minExponent - 1);
3588 constexpr unsigned int trailing_significand_bits = S.precision - 1;
3589 constexpr int integer_bit_part = trailing_significand_bits /
integerPartWidth;
3592 constexpr uint64_t significand_mask = integer_bit - 1;
3593 constexpr unsigned int exponent_bits =
3594 trailing_significand_bits ? (S.sizeInBits - 1 - trailing_significand_bits)
3596 static_assert(exponent_bits < 64);
3597 constexpr uint64_t exponent_mask = (uint64_t{1} << exponent_bits) - 1;
3599 uint64_t myexponent;
3604 myexponent = exponent + bias;
3605 std::copy_n(significandParts(), mysignificand.size(),
3606 mysignificand.begin());
3607 if (myexponent == 1 &&
3608 !(significandParts()[integer_bit_part] & integer_bit))
3610 }
else if (category ==
fcZero) {
3613 myexponent = ::exponentZero(S) + bias;
3614 mysignificand.fill(0);
3619 myexponent = ::exponentInf(S) + bias;
3620 mysignificand.fill(0);
3625 myexponent = ::exponentNaN(S) + bias;
3626 std::copy_n(significandParts(), mysignificand.size(),
3627 mysignificand.begin());
3629 std::array<uint64_t, (S.sizeInBits + 63) / 64> words;
3631 std::copy_n(mysignificand.begin(), mysignificand.size(), words.begin());
3632 if constexpr (significand_mask != 0 || trailing_significand_bits == 0) {
3634 words[mysignificand.size() - 1] &= significand_mask;
3636 std::fill(words_iter, words.end(), uint64_t{0});
3637 constexpr size_t last_word = words.size() - 1;
3638 uint64_t shifted_sign =
static_cast<uint64_t
>(sign & 1)
3639 << ((S.sizeInBits - 1) % 64);
3640 words[last_word] |= shifted_sign;
3641 uint64_t shifted_exponent = (myexponent & exponent_mask)
3642 << (trailing_significand_bits % 64);
3643 words[last_word] |= shifted_exponent;
3644 if constexpr (last_word == 0) {
3645 return APInt(S.sizeInBits, words[0]);
3647 return APInt(S.sizeInBits, words);
3650APInt IEEEFloat::convertQuadrupleAPFloatToAPInt()
const {
3651 assert(partCount() == 2);
3652 return convertIEEEFloatToAPInt<APFloatBase::semIEEEquad>();
3655APInt IEEEFloat::convertDoubleAPFloatToAPInt()
const {
3657 return convertIEEEFloatToAPInt<APFloatBase::semIEEEdouble>();
3660APInt IEEEFloat::convertFloatAPFloatToAPInt()
const {
3662 return convertIEEEFloatToAPInt<APFloatBase::semIEEEsingle>();
3665APInt IEEEFloat::convertBFloatAPFloatToAPInt()
const {
3666 assert(partCount() == 1);
3667 return convertIEEEFloatToAPInt<APFloatBase::semBFloat>();
3670APInt IEEEFloat::convertHalfAPFloatToAPInt()
const {
3672 return convertIEEEFloatToAPInt<APFloatBase::APFloatBase::semIEEEhalf>();
3675APInt IEEEFloat::convertFloat8E5M2APFloatToAPInt()
const {
3676 assert(partCount() == 1);
3677 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E5M2>();
3680APInt IEEEFloat::convertFloat8E5M2FNUZAPFloatToAPInt()
const {
3681 assert(partCount() == 1);
3682 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E5M2FNUZ>();
3685APInt IEEEFloat::convertFloat8E4M3APFloatToAPInt()
const {
3686 assert(partCount() == 1);
3687 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E4M3>();
3690APInt IEEEFloat::convertFloat8E4M3FNAPFloatToAPInt()
const {
3691 assert(partCount() == 1);
3692 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E4M3FN>();
3695APInt IEEEFloat::convertFloat8E4M3FNUZAPFloatToAPInt()
const {
3696 assert(partCount() == 1);
3697 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E4M3FNUZ>();
3700APInt IEEEFloat::convertFloat8E4M3B11FNUZAPFloatToAPInt()
const {
3701 assert(partCount() == 1);
3702 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E4M3B11FNUZ>();
3705APInt IEEEFloat::convertFloat8E3M4APFloatToAPInt()
const {
3706 assert(partCount() == 1);
3707 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E3M4>();
3710APInt IEEEFloat::convertFloatTF32APFloatToAPInt()
const {
3711 assert(partCount() == 1);
3712 return convertIEEEFloatToAPInt<APFloatBase::semFloatTF32>();
3715APInt IEEEFloat::convertFloat8E8M0FNUAPFloatToAPInt()
const {
3716 assert(partCount() == 1);
3717 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E8M0FNU>();
3720APInt IEEEFloat::convertFloat6E3M2FNAPFloatToAPInt()
const {
3721 assert(partCount() == 1);
3722 return convertIEEEFloatToAPInt<APFloatBase::semFloat6E3M2FN>();
3725APInt IEEEFloat::convertFloat6E2M3FNAPFloatToAPInt()
const {
3726 assert(partCount() == 1);
3727 return convertIEEEFloatToAPInt<APFloatBase::semFloat6E2M3FN>();
3730APInt IEEEFloat::convertFloat4E2M1FNAPFloatToAPInt()
const {
3731 assert(partCount() == 1);
3732 return convertIEEEFloatToAPInt<APFloatBase::semFloat4E2M1FN>();
3741 return convertHalfAPFloatToAPInt();
3744 return convertBFloatAPFloatToAPInt();
3747 return convertFloatAPFloatToAPInt();
3750 return convertDoubleAPFloatToAPInt();
3753 return convertQuadrupleAPFloatToAPInt();
3757 return convertPPCDoubleDoubleLegacyAPFloatToAPInt();
3760 return convertFloat8E5M2APFloatToAPInt();
3763 return convertFloat8E5M2FNUZAPFloatToAPInt();
3766 return convertFloat8E4M3APFloatToAPInt();
3769 return convertFloat8E4M3FNAPFloatToAPInt();
3772 return convertFloat8E4M3FNUZAPFloatToAPInt();
3776 return convertFloat8E4M3B11FNUZAPFloatToAPInt();
3779 return convertFloat8E3M4APFloatToAPInt();
3782 return convertFloatTF32APFloatToAPInt();
3785 return convertFloat8E8M0FNUAPFloatToAPInt();
3788 return convertFloat6E3M2FNAPFloatToAPInt();
3791 return convertFloat6E2M3FNAPFloatToAPInt();
3794 return convertFloat4E2M1FNAPFloatToAPInt();
3799 return convertF80LongDoubleAPFloatToAPInt();
3804 "Float semantics are not IEEEsingle");
3811 "Float semantics are not IEEEdouble");
3816#ifdef HAS_IEE754_FLOAT128
3817float128 IEEEFloat::convertToQuad()
const {
3819 "Float semantics are not IEEEquads");
3821 return api.bitsToQuad();
3832void IEEEFloat::initFromF80LongDoubleAPInt(
const APInt &api) {
3835 uint64_t myexponent = (i2 & 0x7fff);
3837 uint8_t myintegerbit = mysignificand >> 63;
3839 initialize(&APFloatBase::semX87DoubleExtended);
3842 sign =
static_cast<unsigned int>(i2>>15);
3843 if (myexponent == 0 && mysignificand == 0) {
3845 }
else if (myexponent==0x7fff && mysignificand==0x8000000000000000ULL) {
3847 }
else if ((myexponent == 0x7fff && mysignificand != 0x8000000000000000ULL) ||
3848 (myexponent != 0x7fff && myexponent != 0 && myintegerbit == 0)) {
3850 exponent = exponentNaN();
3851 significandParts()[0] = mysignificand;
3852 significandParts()[1] = 0;
3855 exponent = myexponent - 16383;
3856 significandParts()[0] = mysignificand;
3857 significandParts()[1] = 0;
3863void IEEEFloat::initFromPPCDoubleDoubleLegacyAPInt(
const APInt &api) {
3870 initFromDoubleAPInt(APInt(64, i1));
3878 IEEEFloat v(APFloatBase::semIEEEdouble, APInt(64, i2));
3893void IEEEFloat::initFromFloat8E8M0FNUAPInt(
const APInt &api) {
3894 const uint64_t exponent_mask = 0xff;
3896 uint64_t myexponent = (val & exponent_mask);
3898 initialize(&APFloatBase::semFloat8E8M0FNU);
3899 assert(partCount() == 1);
3907 uint64_t mysignificand = 1;
3908 significandParts()[0] = mysignificand;
3912 if (val == exponent_mask) {
3914 exponent = exponentNaN();
3919 exponent = myexponent - 127;
3921template <const fltSemantics &S>
3922void IEEEFloat::initFromIEEEAPInt(
const APInt &api) {
3926 constexpr uint64_t significand_mask = integer_bit - 1;
3927 constexpr unsigned int trailing_significand_bits = S.precision - 1;
3928 constexpr unsigned int stored_significand_parts =
3930 constexpr unsigned int exponent_bits =
3931 S.sizeInBits - 1 - trailing_significand_bits;
3932 static_assert(exponent_bits < 64);
3933 constexpr uint64_t exponent_mask = (uint64_t{1} << exponent_bits) - 1;
3934 constexpr int bias = -(S.minExponent - 1);
3938 std::array<integerPart, stored_significand_parts> mysignificand;
3939 std::copy_n(api.
getRawData(), mysignificand.size(), mysignificand.begin());
3940 if constexpr (significand_mask != 0) {
3941 mysignificand[mysignificand.size() - 1] &= significand_mask;
3947 uint64_t myexponent =
3948 (last_word >> (trailing_significand_bits % 64)) & exponent_mask;
3951 assert(partCount() == mysignificand.size());
3953 sign =
static_cast<unsigned int>(last_word >> ((S.sizeInBits - 1) % 64));
3955 bool all_zero_significand =
3958 bool is_zero = myexponent == 0 && all_zero_significand;
3961 if (myexponent - bias == ::exponentInf(S) && all_zero_significand) {
3967 bool is_nan =
false;
3970 is_nan = myexponent - bias == ::exponentNaN(S) && !all_zero_significand;
3972 bool all_ones_significand =
3973 std::all_of(mysignificand.begin(), mysignificand.end() - 1,
3974 [](
integerPart bits) { return bits == ~integerPart{0}; }) &&
3975 (!significand_mask ||
3976 mysignificand[mysignificand.size() - 1] == significand_mask);
3977 is_nan = myexponent - bias == ::exponentNaN(S) && all_ones_significand;
3979 is_nan = is_zero && sign;
3985 std::copy_n(mysignificand.begin(), mysignificand.size(),
3986 significandParts());
3996 exponent = myexponent - bias;
3997 std::copy_n(mysignificand.begin(), mysignificand.size(), significandParts());
3998 if (myexponent == 0)
3999 exponent = S.minExponent;
4001 significandParts()[mysignificand.size()-1] |= integer_bit;
4004void IEEEFloat::initFromQuadrupleAPInt(
const APInt &api) {
4005 initFromIEEEAPInt<APFloatBase::semIEEEquad>(api);
4008void IEEEFloat::initFromDoubleAPInt(
const APInt &api) {
4009 initFromIEEEAPInt<APFloatBase::semIEEEdouble>(api);
4012void IEEEFloat::initFromFloatAPInt(
const APInt &api) {
4013 initFromIEEEAPInt<APFloatBase::semIEEEsingle>(api);
4016void IEEEFloat::initFromBFloatAPInt(
const APInt &api) {
4017 initFromIEEEAPInt<APFloatBase::semBFloat>(api);
4020void IEEEFloat::initFromHalfAPInt(
const APInt &api) {
4021 initFromIEEEAPInt<APFloatBase::semIEEEhalf>(api);
4024void IEEEFloat::initFromFloat8E5M2APInt(
const APInt &api) {
4025 initFromIEEEAPInt<APFloatBase::semFloat8E5M2>(api);
4028void IEEEFloat::initFromFloat8E5M2FNUZAPInt(
const APInt &api) {
4029 initFromIEEEAPInt<APFloatBase::semFloat8E5M2FNUZ>(api);
4032void IEEEFloat::initFromFloat8E4M3APInt(
const APInt &api) {
4033 initFromIEEEAPInt<APFloatBase::semFloat8E4M3>(api);
4036void IEEEFloat::initFromFloat8E4M3FNAPInt(
const APInt &api) {
4037 initFromIEEEAPInt<APFloatBase::semFloat8E4M3FN>(api);
4040void IEEEFloat::initFromFloat8E4M3FNUZAPInt(
const APInt &api) {
4041 initFromIEEEAPInt<APFloatBase::semFloat8E4M3FNUZ>(api);
4044void IEEEFloat::initFromFloat8E4M3B11FNUZAPInt(
const APInt &api) {
4045 initFromIEEEAPInt<APFloatBase::semFloat8E4M3B11FNUZ>(api);
4048void IEEEFloat::initFromFloat8E3M4APInt(
const APInt &api) {
4049 initFromIEEEAPInt<APFloatBase::semFloat8E3M4>(api);
4052void IEEEFloat::initFromFloatTF32APInt(
const APInt &api) {
4053 initFromIEEEAPInt<APFloatBase::semFloatTF32>(api);
4056void IEEEFloat::initFromFloat6E3M2FNAPInt(
const APInt &api) {
4057 initFromIEEEAPInt<APFloatBase::semFloat6E3M2FN>(api);
4060void IEEEFloat::initFromFloat6E2M3FNAPInt(
const APInt &api) {
4061 initFromIEEEAPInt<APFloatBase::semFloat6E2M3FN>(api);
4064void IEEEFloat::initFromFloat4E2M1FNAPInt(
const APInt &api) {
4065 initFromIEEEAPInt<APFloatBase::semFloat4E2M1FN>(api);
4071 if (Sem == &APFloatBase::semIEEEhalf)
4072 return initFromHalfAPInt(api);
4073 if (Sem == &APFloatBase::semBFloat)
4074 return initFromBFloatAPInt(api);
4075 if (Sem == &APFloatBase::semIEEEsingle)
4076 return initFromFloatAPInt(api);
4077 if (Sem == &APFloatBase::semIEEEdouble)
4078 return initFromDoubleAPInt(api);
4079 if (Sem == &APFloatBase::semX87DoubleExtended)
4080 return initFromF80LongDoubleAPInt(api);
4081 if (Sem == &APFloatBase::semIEEEquad)
4082 return initFromQuadrupleAPInt(api);
4083 if (Sem == &APFloatBase::semPPCDoubleDoubleLegacy)
4084 return initFromPPCDoubleDoubleLegacyAPInt(api);
4085 if (Sem == &APFloatBase::semFloat8E5M2)
4086 return initFromFloat8E5M2APInt(api);
4087 if (Sem == &APFloatBase::semFloat8E5M2FNUZ)
4088 return initFromFloat8E5M2FNUZAPInt(api);
4089 if (Sem == &APFloatBase::semFloat8E4M3)
4090 return initFromFloat8E4M3APInt(api);
4091 if (Sem == &APFloatBase::semFloat8E4M3FN)
4092 return initFromFloat8E4M3FNAPInt(api);
4093 if (Sem == &APFloatBase::semFloat8E4M3FNUZ)
4094 return initFromFloat8E4M3FNUZAPInt(api);
4095 if (Sem == &APFloatBase::semFloat8E4M3B11FNUZ)
4096 return initFromFloat8E4M3B11FNUZAPInt(api);
4097 if (Sem == &APFloatBase::semFloat8E3M4)
4098 return initFromFloat8E3M4APInt(api);
4099 if (Sem == &APFloatBase::semFloatTF32)
4100 return initFromFloatTF32APInt(api);
4101 if (Sem == &APFloatBase::semFloat8E8M0FNU)
4102 return initFromFloat8E8M0FNUAPInt(api);
4103 if (Sem == &APFloatBase::semFloat6E3M2FN)
4104 return initFromFloat6E3M2FNAPInt(api);
4105 if (Sem == &APFloatBase::semFloat6E2M3FN)
4106 return initFromFloat6E2M3FNAPInt(api);
4107 if (Sem == &APFloatBase::semFloat4E2M1FN)
4108 return initFromFloat4E2M1FNAPInt(api);
4116 if (Negative && !semantics->hasSignedRepr)
4118 "This floating point format does not support signed values");
4125 exponent = semantics->maxExponent;
4129 unsigned PartCount = partCount();
4130 memset(significand, 0xFF,
sizeof(
integerPart)*(PartCount - 1));
4134 const unsigned NumUnusedHighBits =
4141 (semantics->precision > 1))
4148 if (Negative && !semantics->hasSignedRepr)
4150 "This floating point format does not support signed values");
4157 exponent = semantics->minExponent;
4162 if (Negative && !semantics->hasSignedRepr)
4164 "This floating point format does not support signed values");
4173 exponent = semantics->minExponent;
4178 initFromAPInt(&Sem, API);
4191 Buffer.
append(Str.begin(), Str.end());
4196 void AdjustToPrecision(
APInt &significand,
4197 int &exp,
unsigned FormatPrecision) {
4201 unsigned bitsRequired = (FormatPrecision * 196 + 58) / 59;
4203 if (bits <= bitsRequired)
return;
4205 unsigned tensRemovable = (bits - bitsRequired) * 59 / 196;
4206 if (!tensRemovable)
return;
4208 exp += tensRemovable;
4213 if (tensRemovable & 1)
4215 tensRemovable >>= 1;
4216 if (!tensRemovable)
break;
4220 significand = significand.
udiv(divisor);
4228 int &exp,
unsigned FormatPrecision) {
4229 unsigned N = buffer.
size();
4230 if (
N <= FormatPrecision)
return;
4233 unsigned FirstSignificant =
N - FormatPrecision;
4240 if (buffer[FirstSignificant - 1] <
'5') {
4241 while (FirstSignificant <
N && buffer[FirstSignificant] ==
'0')
4244 exp += FirstSignificant;
4245 buffer.
erase(&buffer[0], &buffer[FirstSignificant]);
4251 for (
unsigned I = FirstSignificant;
I !=
N; ++
I) {
4252 if (buffer[
I] ==
'9') {
4261 if (FirstSignificant ==
N) {
4262 exp += FirstSignificant;
4268 exp += FirstSignificant;
4269 buffer.
erase(&buffer[0], &buffer[FirstSignificant]);
4273 APInt significand,
unsigned FormatPrecision,
4274 unsigned FormatMaxPadding,
bool TruncateZero) {
4275 const int semanticsPrecision = significand.
getBitWidth();
4282 if (!FormatPrecision) {
4290 FormatPrecision = 2 + semanticsPrecision * 59 / 196;
4295 exp += trailingZeros;
4301 }
else if (exp > 0) {
4303 significand = significand.
zext(semanticsPrecision + exp);
4304 significand <<= exp;
4318 unsigned precision = semanticsPrecision + (137 * texp + 136) / 59;
4322 significand = significand.
zext(precision);
4323 APInt five_to_the_i(precision, 5);
4326 significand *= five_to_the_i;
4331 five_to_the_i *= five_to_the_i;
4335 AdjustToPrecision(significand, exp, FormatPrecision);
4340 unsigned precision = significand.getBitWidth();
4341 if (precision < 4) {
4344 significand = significand.zext(precision);
4346 APInt ten(precision, 10);
4347 APInt digit(precision, 0);
4349 bool inTrail =
true;
4350 while (significand != 0) {
4355 unsigned d = digit.getZExtValue();
4366 assert(!buffer.
empty() &&
"no characters in buffer!");
4370 AdjustToPrecision(buffer, exp, FormatPrecision);
4372 unsigned NDigits = buffer.
size();
4375 bool FormatScientific;
4376 if (!FormatMaxPadding)
4377 FormatScientific =
true;
4383 FormatScientific = ((unsigned) exp > FormatMaxPadding ||
4384 NDigits + (unsigned) exp > FormatPrecision);
4387 int MSD = exp + (int) (NDigits - 1);
4390 FormatScientific =
false;
4394 FormatScientific = ((unsigned) -MSD) > FormatMaxPadding;
4400 if (FormatScientific) {
4401 exp += (NDigits - 1);
4403 Str.push_back(buffer[NDigits-1]);
4405 if (NDigits == 1 && TruncateZero)
4408 for (
unsigned I = 1;
I != NDigits; ++
I)
4409 Str.push_back(buffer[NDigits-1-
I]);
4411 if (!TruncateZero && FormatPrecision > NDigits - 1)
4412 Str.append(FormatPrecision - NDigits + 1,
'0');
4414 Str.push_back(TruncateZero ?
'E' :
'e');
4416 Str.push_back(exp >= 0 ?
'+' :
'-');
4421 expbuf.
push_back((
char) (
'0' + (exp % 10)));
4425 if (!TruncateZero && expbuf.
size() < 2)
4427 for (
unsigned I = 0,
E = expbuf.
size();
I !=
E; ++
I)
4428 Str.push_back(expbuf[
E-1-
I]);
4434 for (
unsigned I = 0;
I != NDigits; ++
I)
4435 Str.push_back(buffer[NDigits-1-
I]);
4436 for (
unsigned I = 0;
I != (unsigned) exp; ++
I)
4444 int NWholeDigits = exp + (int) NDigits;
4447 if (NWholeDigits > 0) {
4448 for (;
I != (unsigned) NWholeDigits; ++
I)
4449 Str.push_back(buffer[NDigits-
I-1]);
4452 unsigned NZeros = 1 + (unsigned) -NWholeDigits;
4456 for (
unsigned Z = 1;
Z != NZeros; ++
Z)
4460 for (;
I != NDigits; ++
I)
4461 Str.push_back(buffer[NDigits-
I-1]);
4467 unsigned FormatMaxPadding,
bool TruncateZero)
const {
4471 return append(Str,
"-Inf");
4473 return append(Str,
"+Inf");
4475 case fcNaN:
return append(Str,
"NaN");
4481 if (!FormatMaxPadding) {
4483 append(Str,
"0.0E+0");
4486 if (FormatPrecision > 1)
4487 Str.append(FormatPrecision - 1,
'0');
4488 append(Str,
"e+00");
4500 int exp = exponent - ((int) semantics->precision - 1);
4502 semantics->precision,
4505 toStringImpl(Str,
isNegative(), exp, significand, FormatPrecision,
4506 FormatMaxPadding, TruncateZero);
4518 for (
int i = 0; i < PartCount; ++i) {
4524 if (exponent != semantics->minExponent)
4527 int CountrParts = 0;
4528 for (
int i = 0; i < PartCount;
4530 if (Parts[i] != 0) {
4531 return exponent - semantics->precision + CountrParts +
4594 if (!semantics->hasZero)
4604 }
else if (semantics->nonFiniteBehavior ==
4612 exponent = semantics->maxExponent + 1;
4626 bool WillCrossBinadeBoundary =
4627 exponent != semantics->minExponent && isSignificandAllZeros();
4645 if (WillCrossBinadeBoundary) {
4666 if (WillCrossBinadeBoundary) {
4670 assert(exponent != semantics->maxExponent &&
4671 "We can not increment an exponent beyond the maxExponent allowed"
4672 " by the given floating point semantics.");
4675 incrementSignificand();
4689 return ::exponentNaN(*semantics);
4693 return ::exponentInf(*semantics);
4697 return ::exponentZero(*semantics);
4716 if (!semantics->hasZero)
4743 return Arg.exponent;
4748 Normalized.exponent += SignificandBits;
4750 return Normalized.exponent - SignificandBits;
4754 auto MaxExp =
X.getSemantics().maxExponent;
4755 auto MinExp =
X.getSemantics().minExponent;
4763 int SignificandBits =
X.getSemantics().precision - 1;
4764 int MaxIncrement = MaxExp - (MinExp - SignificandBits) + 1;
4767 X.exponent += std::clamp(Exp, -MaxIncrement - 1, MaxIncrement);
4790 return scalbn(Val, -Exp, RM);
4796 APFloat(APFloatBase::semIEEEdouble)}) {
4797 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4801 : Semantics(&S), Floats(new
APFloat[2]{
4804 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4810 APFloat(APFloatBase::semIEEEdouble)}) {
4811 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4817 APFloat(APFloatBase::semIEEEdouble,
APInt(64,
I.getRawData()[0])),
4818 APFloat(APFloatBase::semIEEEdouble,
APInt(64,
I.getRawData()[1]))}) {
4819 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4825 Floats(new
APFloat[2]{std::move(
First), std::move(Second)}) {
4826 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4827 assert(&Floats[0].getSemantics() == &APFloatBase::semIEEEdouble);
4828 assert(&Floats[1].getSemantics() == &APFloatBase::semIEEEdouble);
4832 : Semantics(RHS.Semantics),
4836 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4840 : Semantics(RHS.Semantics), Floats(RHS.Floats) {
4841 RHS.Semantics = &APFloatBase::semBogus;
4842 RHS.Floats =
nullptr;
4843 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4847 if (Semantics == RHS.Semantics && RHS.Floats) {
4848 Floats[0] = RHS.Floats[0];
4849 Floats[1] = RHS.Floats[1];
4850 }
else if (
this != &RHS) {
4883 Floats[0] = std::move(z);
4884 Floats[1].makeZero(
false);
4888 auto AComparedToC = a.compareAbsoluteValue(c);
4897 Status |= z.
add(a, RM);
4898 Status |= z.
add(c, RM);
4901 Floats[0] = std::move(z);
4902 Floats[1].makeZero(
false);
4907 Status |= zz.
add(cc, RM);
4911 Status |= Floats[1].subtract(z, RM);
4912 Status |= Floats[1].add(c, RM);
4913 Status |= Floats[1].add(zz, RM);
4917 Status |= Floats[1].subtract(z, RM);
4918 Status |= Floats[1].add(a, RM);
4919 Status |= Floats[1].add(zz, RM);
4924 Status |=
q.subtract(z, RM);
4929 Status |= zz.
add(c, RM);
4930 Status |=
q.add(z, RM);
4931 Status |=
q.subtract(a, RM);
4933 Status |= zz.
add(q, RM);
4934 Status |= zz.
add(
aa, RM);
4935 Status |= zz.
add(cc, RM);
4937 Floats[0] = std::move(z);
4938 Floats[1].makeZero(
false);
4942 Status |= Floats[0].add(zz, RM);
4944 Floats[1].makeZero(
false);
4947 Floats[1] = std::move(z);
4948 Status |= Floats[1].subtract(Floats[0], RM);
4949 Status |= Floats[1].add(zz, RM);
4975 LHS.isNegative() !=
RHS.isNegative()) {
4976 Out.makeNaN(
false, Out.isNegative(),
nullptr);
4991 assert(&
A.getSemantics() == &APFloatBase::semIEEEdouble);
4992 assert(&AA.getSemantics() == &APFloatBase::semIEEEdouble);
4993 assert(&
C.getSemantics() == &APFloatBase::semIEEEdouble);
4994 assert(&CC.getSemantics() == &APFloatBase::semIEEEdouble);
4995 assert(&Out.Floats[0].getSemantics() == &APFloatBase::semIEEEdouble);
4996 assert(&Out.Floats[1].getSemantics() == &APFloatBase::semIEEEdouble);
4997 return Out.addImpl(
A, AA,
C, CC, RM);
5002 return addWithSpecial(*
this, RHS, *
this, RM);
5008 auto Ret =
add(RHS, RM);
5015 const auto &LHS = *
this;
5032 if (LHS.getCategory() ==
fcNaN) {
5036 if (RHS.getCategory() ==
fcNaN) {
5042 Out.makeNaN(
false,
false,
nullptr);
5054 "Special cases not handled exhaustively");
5057 APFloat A = Floats[0],
B = Floats[1],
C = RHS.Floats[0],
D = RHS.Floats[1];
5061 if (!
T.isFiniteNonZero()) {
5063 Floats[1].makeZero(
false);
5085 Status |= U.add(Tau, RM);
5088 if (!U.isFinite()) {
5089 Floats[1].makeZero(
false);
5101 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5102 "Unexpected Semantics");
5105 APFloat(APFloatBase::semPPCDoubleDoubleLegacy, RHS.bitcastToAPInt()), RM);
5111 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5112 "Unexpected Semantics");
5115 APFloat(APFloatBase::semPPCDoubleDoubleLegacy, RHS.bitcastToAPInt()));
5121 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5122 "Unexpected Semantics");
5125 APFloat(APFloatBase::semPPCDoubleDoubleLegacy, RHS.bitcastToAPInt()));
5134 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5135 "Unexpected Semantics");
5138 APFloat(APFloatBase::semPPCDoubleDoubleLegacy,
5147 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5148 "Unexpected Semantics");
5158 if (!
Hi.isFiniteNonZero() ||
Lo.isZero()) {
5159 Floats[0] = std::move(RoundedHi);
5160 Floats[1].makeZero(
false);
5172 const APFloat RoundingError = Rounded - ToRound;
5173 if (TieBreaker.isNonZero() &&
5174 TieBreaker.isNegative() != RoundingError.
isNegative() &&
5175 abs(RoundingError).isExactlyValue(0.5))
5184 if (RoundedHi !=
Hi) {
5189 RoundedHi = RoundToNearestHelper(
Hi, RoundedHi,
Lo);
5191 Floats[0] = std::move(RoundedHi);
5192 Floats[1].makeZero(
false);
5205 LoRoundingMode = RM;
5213 RoundedLo = RoundToNearestHelper(
Lo, RoundedLo,
Hi);
5216 std::tie(RoundedHi, RoundedLo) =
fastTwoSum(RoundedHi, RoundedLo);
5218 Floats[0] = std::move(RoundedHi);
5219 Floats[1] = std::move(RoundedLo);
5224 Floats[0].changeSign();
5225 Floats[1].changeSign();
5231 const cmpResult HiPartCmp = Floats[0].compareAbsoluteValue(RHS.Floats[0]);
5236 if (Floats[1].
isZero() && RHS.Floats[1].isZero())
5242 const bool ThisIsSubtractive =
5243 Floats[0].isNegative() != Floats[1].isNegative();
5244 const bool RHSIsSubtractive =
5245 RHS.Floats[0].isNegative() != RHS.Floats[1].isNegative();
5255 if (RHS.Floats[1].isZero())
5262 if (ThisIsSubtractive != RHSIsSubtractive)
5267 const cmpResult LoPartCmp = Floats[1].compareAbsoluteValue(RHS.Floats[1]);
5269 if (ThisIsSubtractive) {
5283 return Floats[0].getCategory();
5289 Floats[0].makeInf(Neg);
5290 Floats[1].makeZero(
false);
5294 Floats[0].makeZero(Neg);
5295 Floats[1].makeZero(
false);
5299 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5300 "Unexpected Semantics");
5302 APFloat(APFloatBase::semIEEEdouble,
APInt(64, 0x7fefffffffffffffull));
5304 APFloat(APFloatBase::semIEEEdouble,
APInt(64, 0x7c8ffffffffffffeull));
5310 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5311 "Unexpected Semantics");
5312 Floats[0].makeSmallest(Neg);
5313 Floats[1].makeZero(
false);
5317 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5318 "Unexpected Semantics");
5320 APFloat(APFloatBase::semIEEEdouble,
APInt(64, 0x0360000000000000ull));
5322 Floats[0].changeSign();
5323 Floats[1].makeZero(
false);
5327 Floats[0].makeNaN(SNaN, Neg,
fill);
5328 Floats[1].makeZero(
false);
5332 auto Result = Floats[0].compare(RHS.Floats[0]);
5335 return Floats[1].compare(RHS.Floats[1]);
5340 return Floats[0].bitwiseIsEqual(RHS.Floats[0]) &&
5341 Floats[1].bitwiseIsEqual(RHS.Floats[1]);
5351 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5352 "Unexpected Semantics");
5354 Floats[0].bitcastToAPInt().getRawData()[0],
5355 Floats[1].bitcastToAPInt().getRawData()[0],
5362 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5363 "Unexpected Semantics");
5364 APFloat Tmp(APFloatBase::semPPCDoubleDoubleLegacy);
5377 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5378 "Unexpected Semantics");
5428 if (InLattice(HiOld, NextLo)) {
5430 Floats[1] = std::move(NextLo);
5467 if (!InLattice(NextHi, NextLo))
5471 Floats[0] = std::move(NextHi);
5472 Floats[1] = std::move(NextLo);
5480 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5481 "Unexpected Semantics");
5523 const unsigned PositiveOverflowWidth = IsSigned ? Width - 1 : Width;
5524 if (HiExactLog2 >= 0 &&
5525 static_cast<unsigned>(HiExactLog2) == PositiveOverflowWidth) {
5535 Input, Width,
true, RM, &LoIsExact);
5548 *IsExact = RoundStatus ==
opOK;
5560 APSInt LoResult{Width, !IsSigned};
5572 *IsExact = RoundStatus ==
opOK;
5578 unsigned int Width,
bool IsSigned,
5581 convertToSignExtendedInteger(
Input, Width, IsSigned, RM, IsExact);
5585 assert(DstPartsCount <=
Input.size() &&
"Integer too big");
5593 Bits = Width - IsSigned;
5638 if (SrcMSB == UINT_MAX) {
5645 const unsigned SrcBitWidth = SrcMSB + 1;
5661 return handleOverflow(RM);
5667 bool HiAsIntIsExact;
5684 if (
Error.isNegative()) {
5692 const unsigned ErrorActiveBits =
Error.getSignificantBits() - 1;
5694 if (ErrorActiveBits > LoPrecision) {
5695 const unsigned RoundingBoundary = ErrorActiveBits - LoPrecision;
5699 if (
Error.countTrailingZeros() == RoundingBoundary - 1)
5718 Floats[0] = std::move(
Hi);
5719 Floats[1] = std::move(
Lo);
5724 return handleOverflow(RM);
5730 Largest.makeLargest(
false);
5732 return handleOverflow(RM);
5744 const bool NegateInput = IsSigned &&
Input.isNegative();
5757 unsigned int HexDigits,
5760 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5761 "Unexpected Semantics");
5768 (Floats[0].isDenormal() || Floats[1].
isDenormal() ||
5770 Floats[0] != Floats[0] + Floats[1]);
5799 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5800 "Unexpected Semantics");
5801 return Floats[0].isInteger() && Floats[1].isInteger();
5805 unsigned FormatPrecision,
5806 unsigned FormatMaxPadding,
5807 bool TruncateZero)
const {
5808 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5809 "Unexpected Semantics");
5811 .
toString(Str, FormatPrecision, FormatMaxPadding, TruncateZero);
5831 if (
Lo.isZero() ||
Hi.isNegative() ==
Lo.isNegative())
5833 if (
Hi.getExactLog2Abs() == INT_MIN)
5837 return IlogbResult - 1;
5843 "Unexpected Semantics");
5845 scalbn(Arg.Floats[0], Exp, RM),
5846 scalbn(Arg.Floats[1], Exp, RM));
5852 "Unexpected Semantics");
5862 Quiet.getFirst() =
Quiet.getFirst().makeQuiet();
5884 const bool SignsDisagree =
Hi.isNegative() !=
Lo.isNegative();
5901 LoRoundingMode = RM;
5902 Second =
scalbn(
Lo, -Exp, LoRoundingMode);
5910 if (RecomposedLo !=
Lo) {
5914 const APFloat RoundingError = RecomposedLo -
Lo;
5919 const APFloat ScaledUlpOfSecond =
5921 const bool IsMidpoint =
abs(RoundingError) == ScaledUlpOfSecond;
5922 const bool RoundedLoAway =
5927 if (IsMidpoint && RoundedLoAway)
5943 if (Second.
isZero() && SignsDisagree &&
Hi.getExactLog2Abs() != INT_MIN)
5954APFloat::Storage::Storage(IEEEFloat
F,
const fltSemantics &Semantics) {
5959 if (usesLayout<DoubleAPFloat>(
Semantics)) {
5960 const fltSemantics& S =
F.getSemantics();
5974 if (APFloat::usesLayout<detail::IEEEFloat>(Arg.
getSemantics()))
5976 if (APFloat::usesLayout<detail::DoubleAPFloat>(Arg.
getSemantics()))
5984 assert(StatusOrErr &&
"Invalid floating point representation");
6036 APFloat Reciprocal =
6054 *Inv = std::move(Reciprocal);
6066 usesLayout<IEEEFloat>(ToSemantics))
6067 return U.IEEE.convert(ToSemantics, RM, losesInfo);
6069 usesLayout<DoubleAPFloat>(ToSemantics)) {
6070 assert(&ToSemantics == &APFloatBase::semPPCDoubleDouble);
6072 U.IEEE.convert(APFloatBase::semPPCDoubleDoubleLegacy, RM, losesInfo);
6073 *
this =
APFloat(ToSemantics, U.IEEE.bitcastToAPInt());
6077 usesLayout<IEEEFloat>(ToSemantics)) {
6078 auto Ret = getIEEE().convert(ToSemantics, RM, losesInfo);
6079 *
this =
APFloat(std::move(getIEEE()), ToSemantics);
6095#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
6108 bool *isExact)
const {
6112 rounding_mode, isExact);
6114 result =
APInt(bitWidth, parts);
6121 return getIEEE().convertToDouble();
6123 "Float semantics is not representable by IEEEdouble");
6124 APFloat Temp = *
this;
6133#ifdef HAS_IEE754_FLOAT128
6134float128 APFloat::convertToQuad()
const {
6136 return getIEEE().convertToQuad();
6138 "Float semantics is not representable by IEEEquad");
6145 return Temp.getIEEE().convertToQuad();
6152 return getIEEE().convertToFloat();
6154 "Float semantics is not representable by IEEEsingle");
6155 APFloat Temp = *
this;
6164APFloat::Storage::~Storage() {
6165 if (usesLayout<IEEEFloat>(*semantics)) {
6169 if (usesLayout<DoubleAPFloat>(*semantics)) {
6176APFloat::Storage::Storage(
const APFloat::Storage &
RHS) {
6177 if (usesLayout<IEEEFloat>(*
RHS.semantics)) {
6181 if (usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
6188APFloat::Storage::Storage(APFloat::Storage &&
RHS) {
6189 if (usesLayout<IEEEFloat>(*
RHS.semantics)) {
6193 if (usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
6200APFloat::Storage &APFloat::Storage::operator=(
const APFloat::Storage &
RHS) {
6201 if (usesLayout<IEEEFloat>(*semantics) &&
6202 usesLayout<IEEEFloat>(*
RHS.semantics)) {
6204 }
else if (usesLayout<DoubleAPFloat>(*semantics) &&
6205 usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
6207 }
else if (
this != &
RHS) {
6209 new (
this) Storage(
RHS);
6214APFloat::Storage &APFloat::Storage::operator=(APFloat::Storage &&
RHS) {
6215 if (usesLayout<IEEEFloat>(*semantics) &&
6216 usesLayout<IEEEFloat>(*
RHS.semantics)) {
6218 }
else if (usesLayout<DoubleAPFloat>(*semantics) &&
6219 usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
6221 }
else if (
this != &
RHS) {
6223 new (
this) Storage(std::move(
RHS));
6230#undef APFLOAT_DISPATCH_ON_SEMANTICS
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define PackCategoriesIntoKey(_lhs, _rhs)
A macro used to combine two fcCategory enums into one key which can be used in a switch statement to ...
This file declares a class to represent arbitrary precision floating point values and provide a varie...
#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL)
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
Function Alias Analysis false
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
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.
static bool isNeg(Value *V)
Returns true if the operation is a negation of V, and it works for both integers and floats.
static bool isSigned(unsigned int Opcode)
Utilities for dealing with flags related to floating point properties and mode controls.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
static const fltSemantics & IEEEsingle()
static const fltSemantics & Float8E4M3FN()
static LLVM_ABI const llvm::fltSemantics & EnumToSemantics(Semantics S)
static LLVM_ABI bool semanticsHasInf(const fltSemantics &)
static constexpr roundingMode rmNearestTiesToAway
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
static constexpr roundingMode rmTowardNegative
static LLVM_ABI ExponentType semanticsMinExponent(const fltSemantics &)
llvm::RoundingMode roundingMode
IEEE-754R 4.3: Rounding-direction attributes.
static const fltSemantics & BFloat()
static constexpr roundingMode rmNearestTiesToEven
static const fltSemantics & IEEEquad()
static LLVM_ABI unsigned int semanticsSizeInBits(const fltSemantics &)
static const fltSemantics & Float8E8M0FNU()
static LLVM_ABI bool semanticsHasSignedRepr(const fltSemantics &)
static const fltSemantics & IEEEdouble()
static LLVM_ABI unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
static const fltSemantics & x87DoubleExtended()
static constexpr roundingMode rmTowardZero
static LLVM_ABI bool hasSignBitInMSB(const fltSemantics &)
static LLVM_ABI ExponentType semanticsMaxExponent(const fltSemantics &)
static LLVM_ABI unsigned int semanticsPrecision(const fltSemantics &)
static LLVM_ABI bool semanticsHasNaN(const fltSemantics &)
static LLVM_ABI Semantics SemanticsToEnum(const llvm::fltSemantics &Sem)
static constexpr unsigned integerPartWidth
static const fltSemantics & PPCDoubleDoubleLegacy()
APInt::WordType integerPart
static constexpr roundingMode rmTowardPositive
static LLVM_ABI bool semanticsHasZero(const fltSemantics &)
static LLVM_ABI bool isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst)
static const fltSemantics & Float8E5M2FNUZ()
static const fltSemantics & Float8E4M3FNUZ()
static const fltSemantics & IEEEhalf()
static const fltSemantics & Float4E2M1FN()
static const fltSemantics & Float6E2M3FN()
static const fltSemantics & Float8E4M3()
static const fltSemantics & Float8E4M3B11FNUZ()
static LLVM_ABI bool isRepresentableBy(const fltSemantics &A, const fltSemantics &B)
static const fltSemantics & Float8E3M4()
static LLVM_ABI bool isIEEELikeFP(const fltSemantics &)
static const fltSemantics & Float8E5M2()
fltCategory
Category of internally-represented number.
static const fltSemantics & PPCDoubleDouble()
@ S_PPCDoubleDoubleLegacy
static const fltSemantics & Float6E3M2FN()
opStatus
IEEE-754R 7: Default exception handling.
static const fltSemantics & FloatTF32()
int32_t ExponentType
A signed type to represent a floating point numbers unbiased exponent.
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.
LLVM_ABI void Profile(FoldingSetNodeID &NID) const
Used to insert APFloat objects, or objects that contain APFloat objects, into FoldingSets.
opStatus divide(const APFloat &RHS, roundingMode RM)
bool isFiniteNonZero() const
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
LLVM_READONLY int getExactLog2Abs() const
bool getExactInverse(APFloat *Inv) const
If this value is normal and has an exact, normal, multiplicative inverse, store it in inv and return ...
LLVM_ABI double convertToDouble() const
Converts this APFloat to host double value.
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const
opStatus add(const APFloat &RHS, roundingMode RM)
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.
const fltSemantics & getSemantics() const
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
LLVM_ABI float convertToFloat() const
Converts this APFloat to host float value.
opStatus fusedMultiplyAdd(const APFloat &Multiplicand, const APFloat &Addend, roundingMode RM)
opStatus remainder(const APFloat &RHS)
APInt bitcastToAPInt() const
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)
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.
opStatus mod(const APFloat &RHS)
LLVM_ABI Expected< opStatus > convertFromString(StringRef, roundingMode)
LLVM_DUMP_METHOD void dump() const
LLVM_ABI void print(raw_ostream &) const
opStatus roundToIntegral(roundingMode RM)
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.
Class for arbitrary precision integers.
LLVM_ABI APInt udiv(const APInt &RHS) const
Unsigned division operation.
static LLVM_ABI void tcSetBit(WordType *, unsigned bit)
Set the given bit of a bignum. Zero-based.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
static LLVM_ABI void tcSet(WordType *, WordType, unsigned)
Sets the least significant part of a bignum to the input value, and zeroes out higher parts.
static LLVM_ABI void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
static LLVM_ABI int tcExtractBit(const WordType *, unsigned bit)
Extract the given bit of a bignum; returns 0 or 1. Zero-based.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
static LLVM_ABI WordType tcAdd(WordType *, const WordType *, WordType carry, unsigned)
DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
static LLVM_ABI void tcExtract(WordType *, unsigned dstCount, const WordType *, unsigned srcBits, unsigned srcLSB)
Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to DST, of dstCOUNT parts,...
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static LLVM_ABI int tcCompare(const WordType *, const WordType *, unsigned)
Comparison (unsigned) of two bignums.
static APInt floatToBits(float V)
Converts a float to APInt bits.
static LLVM_ABI void tcAssign(WordType *, const WordType *, unsigned)
Assign one bignum to another.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static LLVM_ABI void tcShiftRight(WordType *, unsigned Words, unsigned Count)
Shift a bignum right Count bits.
static LLVM_ABI void tcFullMultiply(WordType *, const WordType *, const WordType *, unsigned, unsigned)
DST = LHS * RHS, where DST has width the sum of the widths of the operands.
unsigned getNumWords() const
Get the number of words.
bool isNegative() const
Determine sign of this APInt.
static LLVM_ABI void tcClearBit(WordType *, unsigned bit)
Clear the given bit of a bignum. Zero-based.
void negate()
Negate this APInt in place.
static WordType tcDecrement(WordType *dst, unsigned parts)
Decrement a bignum in-place. Return the borrow flag.
unsigned countr_zero() const
Count the number of trailing zero bits.
static LLVM_ABI unsigned tcLSB(const WordType *, unsigned n)
Returns the bit number of the least or most significant set bit of a number.
static LLVM_ABI void tcShiftLeft(WordType *, unsigned Words, unsigned Count)
Shift a bignum left Count bits.
static LLVM_ABI bool tcIsZero(const WordType *, unsigned)
Returns true if a bignum is zero, false otherwise.
static LLVM_ABI unsigned tcMSB(const WordType *parts, unsigned n)
Returns the bit number of the most significant set bit of a number.
float bitsToFloat() const
Converts APInt bits to a float.
static LLVM_ABI int tcMultiplyPart(WordType *dst, const WordType *src, WordType multiplier, WordType carry, unsigned srcParts, unsigned dstParts, bool add)
DST += SRC * MULTIPLIER + PART if add is true DST = SRC * MULTIPLIER + PART if add is false.
static constexpr unsigned APINT_BITS_PER_WORD
Bits in a word.
static LLVM_ABI WordType tcSubtract(WordType *, const WordType *, WordType carry, unsigned)
DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag.
static LLVM_ABI void tcNegate(WordType *, unsigned)
Negate a bignum in-place.
static APInt doubleToBits(double V)
Converts a double to APInt bits.
static WordType tcIncrement(WordType *dst, unsigned parts)
Increment a bignum in-place. Return the carry flag.
double bitsToDouble() const
Converts APInt bits to a double.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
An arbitrary precision integer that knows its signedness.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
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...
iterator erase(const_iterator CI)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
char back() const
back - Get the last character in the string.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
size - Get the string size.
char front() const
front - Get the first character in the string.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
bool consume_front_insensitive(StringRef Prefix)
Returns true if this StringRef has the given prefix, ignoring case, and removes that prefix.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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 unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const
LLVM_ABI bool isNegative() const
LLVM_ABI opStatus add(const DoubleAPFloat &RHS, roundingMode RM)
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)
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)
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)
LLVM_ABI bool isSmallestNormalized() const
Returns true if this is the smallest (by magnitude) normalized finite number in the given semantics.
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.
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.
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 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.
@ C
The default llvm calling convention, compatible with C.
static constexpr opStatus opInexact
LLVM_ABI SlowDynamicAPInt abs(const SlowDynamicAPInt &X)
Redeclarations of friend declarations above to make it discoverable by lookups.
static constexpr fltCategory fcNaN
static constexpr opStatus opDivByZero
static constexpr opStatus opOverflow
static constexpr cmpResult cmpLessThan
const char unit< Period >::value[]
static void tcSetLeastSignificantBits(APInt::WordType *dst, unsigned parts, unsigned bits)
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
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)
static std::pair< APFloat, APFloat > fastTwoSum(APFloat X, APFloat Y)
APFloatBase::integerPart integerPart
LLVM_ABI std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
This is an optimization pass for GlobalISel generic memory operations.
static unsigned int partAsHex(char *dst, APFloatBase::integerPart part, unsigned int count, const char *hexDigitChars)
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
static const char infinityL[]
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static constexpr unsigned int partCountForBits(unsigned int bits)
static unsigned int HUerrBound(bool inexactMultiply, unsigned int HUerr1, unsigned int HUerr2)
static unsigned int powerOf5(APFloatBase::integerPart *dst, unsigned int power)
unsigned hexDigitValue(char C)
Interpret the given character C as a hexadecimal digit and return its value.
static APFloat harrisonUlp(const APFloat &X)
static constexpr APFloatBase::ExponentType exponentZero(const fltSemantics &semantics)
static Expected< int > totalExponent(StringRef::iterator p, StringRef::iterator end, int exponentAdjustment)
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
const unsigned int maxPowerOfFiveExponent
int ilogb(const APFloat &Arg)
Returns the exponent of the internal representation of the APFloat.
static char * writeUnsignedDecimal(char *dst, unsigned int n)
constexpr int popcount(T Value) noexcept
Count the number of set bits in a value.
const unsigned int maxPrecision
APFloat frexp(const APFloat &X, int &Exp, APFloat::roundingMode RM)
Equivalent of C standard library function.
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
static const char infinityU[]
lostFraction
Enum that represents what fraction of the LSB truncated bits of an fp number represent.
static Error interpretDecimal(StringRef::iterator begin, StringRef::iterator end, decimalInfo *D)
LLVM_ABI bool isFinite(const Loop *L)
Return true if this loop can be assumed to run for a finite number of iterations.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
const unsigned int maxPowerOfFiveParts
APFloat scalbn(APFloat X, int Exp, APFloat::roundingMode RM)
Returns: X * 2^Exp for integral exponents.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static constexpr APFloatBase::ExponentType exponentNaN(const fltSemantics &semantics)
static Error createError(const Twine &Err)
static lostFraction shiftRight(APFloatBase::integerPart *dst, unsigned int parts, unsigned int bits)
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
static const char hexDigitsUpper[]
FunctionAddr VTableAddr uintptr_t uintptr_t Data
const unsigned int maxExponent
static unsigned int decDigitValue(unsigned int c)
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
static lostFraction combineLostFractions(lostFraction moreSignificant, lostFraction lessSignificant)
static Expected< StringRef::iterator > skipLeadingZeroesAndAnyDot(StringRef::iterator begin, StringRef::iterator end, StringRef::iterator *dot)
RoundingMode
Rounding mode.
ArrayRef(const T &OneElt) -> ArrayRef< T >
static constexpr APFloatBase::ExponentType exponentInf(const fltSemantics &semantics)
static lostFraction lostFractionThroughTruncation(const APFloatBase::integerPart *parts, unsigned int partCount, unsigned int bits)
APFloat neg(APFloat X)
Returns the negated value of the argument.
static APFloatBase::integerPart ulpsFromBoundary(const APFloatBase::integerPart *parts, unsigned int bits, bool isNearest)
static char * writeSignedDecimal(char *dst, int value)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
static Expected< lostFraction > trailingHexadecimalFraction(StringRef::iterator p, StringRef::iterator end, unsigned int digitValue)
void consumeError(Error Err)
Consume a Error without doing anything.
static Expected< int > readExponent(StringRef::iterator begin, StringRef::iterator end)
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
constexpr uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
static const char hexDigitsLower[]
const char * lastSigDigit
const char * firstSigDigit
APFloatBase::ExponentType maxExponent
fltNonfiniteBehavior nonFiniteBehavior
APFloatBase::ExponentType minExponent
fltNanEncoding nanEncoding