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))
56constexpr fltSemantics APFloatBase::semIEEEhalf = {15, -14, 11, 16};
57constexpr fltSemantics APFloatBase::semBFloat = {127, -126, 8, 16};
58constexpr fltSemantics APFloatBase::semIEEEsingle = {127, -126, 24, 32};
59constexpr fltSemantics APFloatBase::semIEEEdouble = {1023, -1022, 53, 64};
60constexpr fltSemantics APFloatBase::semIEEEquad = {16383, -16382, 113, 128};
61constexpr fltSemantics APFloatBase::semFloat8E5M2 = {15, -14, 3, 8};
64constexpr fltSemantics APFloatBase::semFloat8E4M3 = {7, -6, 4, 8};
69constexpr fltSemantics APFloatBase::semFloat8E4M3B11FNUZ = {
71constexpr fltSemantics APFloatBase::semFloat8E3M4 = {3, -2, 5, 8};
72constexpr fltSemantics APFloatBase::semFloatTF32 = {127, -126, 11, 19};
90constexpr fltSemantics APFloatBase::semX87DoubleExtended = {16383, -16382, 64,
92constexpr fltSemantics APFloatBase::semBogus = {0, 0, 0, 0};
93constexpr fltSemantics APFloatBase::semPPCDoubleDouble = {-1, 0, 0, 128};
94constexpr fltSemantics APFloatBase::semPPCDoubleDoubleLegacy = {
95 1023, -1022 + 53, 53 + 53, 128};
191 return A.maxExponent <=
B.maxExponent &&
A.minExponent >=
B.minExponent &&
192 A.precision <=
B.precision;
266 if (Src.maxExponent >= Dst.maxExponent || Src.minExponent <= Dst.minExponent)
274 return Dst.precision >= Src.precision;
314static inline unsigned int
328 unsigned int absExponent;
329 const unsigned int overlargeExponent = 24000;
333 if (p == end || ((*p ==
'-' || *p ==
'+') && (p + 1) == end)) {
337 isNegative = (*p ==
'-');
338 if (*p ==
'-' || *p ==
'+') {
345 if (absExponent >= 10U)
346 return createError(
"Invalid character in exponent");
348 for (; p != end; ++p) {
353 return createError(
"Invalid character in exponent");
355 absExponent = absExponent * 10U + value;
356 if (absExponent >= overlargeExponent) {
357 absExponent = overlargeExponent;
363 return -(int) absExponent;
365 return (
int) absExponent;
372 int exponentAdjustment) {
373 int unsignedExponent;
374 bool negative, overflow;
380 negative = *p ==
'-';
381 if (*p ==
'-' || *p ==
'+') {
387 unsignedExponent = 0;
389 for (; p != end; ++p) {
394 return createError(
"Invalid character in exponent");
396 unsignedExponent = unsignedExponent * 10 + value;
397 if (unsignedExponent > 32767) {
403 if (exponentAdjustment > 32767 || exponentAdjustment < -32768)
407 exponent = unsignedExponent;
409 exponent = -exponent;
410 exponent += exponentAdjustment;
411 if (exponent > 32767 || exponent < -32768)
416 exponent = negative ? -32768: 32767;
426 while (p != end && *p ==
'0')
429 if (p != end && *p ==
'.') {
432 if (end - begin == 1)
435 while (p != end && *p ==
'0')
468 return PtrOrErr.takeError();
471 D->firstSigDigit = p;
473 D->normalizedExponent = 0;
475 for (; p != end; ++p) {
478 return createError(
"String contains multiple dots");
488 if (*p !=
'e' && *p !=
'E')
489 return createError(
"Invalid character in significand");
492 if (dot != end && p - begin == 1)
498 return ExpOrErr.takeError();
499 D->exponent = *ExpOrErr;
507 if (p !=
D->firstSigDigit) {
513 while (p != begin && *p ==
'0');
514 while (p != begin && *p ==
'.');
519 D->normalizedExponent = (
D->exponent +
521 - (dot >
D->firstSigDigit && dot < p)));
533 unsigned int digitValue) {
534 unsigned int hexDigit;
540 else if (digitValue < 8 && digitValue > 0)
544 while (p != end && (*p ==
'0' || *p ==
'.'))
548 return createError(
"Invalid trailing hexadecimal fraction!");
554 if (hexDigit == UINT_MAX)
564 unsigned int partCount,
593 return lost_fraction;
608 return moreSignificant;
619HUerrBound(
bool inexactMultiply,
unsigned int HUerr1,
unsigned int HUerr2)
621 assert(HUerr1 < 2 || HUerr2 < 2 || (HUerr1 + HUerr2 < 8));
623 if (HUerr1 + HUerr2 == 0)
624 return inexactMultiply * 2;
626 return inexactMultiply + 2 * (HUerr1 + HUerr2);
635 unsigned int count, partBits;
652 if (part - boundary <= boundary - part)
653 return part - boundary;
655 return boundary - part;
658 if (part == boundary) {
664 }
else if (part == boundary - 1) {
681 pow5s[0] = 78125 * 5;
683 unsigned int partsCount = 1;
691 *p1 = firstEightPowers[power & 7];
697 for (
unsigned int n = 0; power; power >>= 1, n++) {
701 partsCount, partsCount);
703 if (pow5[partsCount - 1] == 0)
711 result += partsCount;
712 if (p2[result - 1] == 0)
737static const char NaNL[] =
"nan";
738static const char NaNU[] =
"NAN";
745 const char *hexDigitChars)
747 unsigned int result =
count;
753 dst[
count] = hexDigitChars[part & 0xf];
797 switch (
X.getCategory()) {
807 if (
X.isDenormal() ||
X.isSmallestNormalized())
810 if (
X.getExactLog2() != INT_MIN)
818void IEEEFloat::initialize(
const fltSemantics *ourSemantics) {
821 semantics = ourSemantics;
827void IEEEFloat::freeSignificand() {
829 delete [] significand.parts;
832void IEEEFloat::assign(
const IEEEFloat &rhs) {
833 assert(semantics == rhs.semantics);
836 category = rhs.category;
837 exponent = rhs.exponent;
839 copySignificand(rhs);
842void IEEEFloat::copySignificand(
const IEEEFloat &rhs) {
844 assert(rhs.partCount() >= partCount());
857 if (Negative && !semantics->hasSignedRepr)
859 "This floating point format does not support signed values");
863 exponent = exponentNaN();
866 unsigned numParts = partCount();
879 fill = &fill_storage;
883 if (!
fill ||
fill->getNumWords() < numParts)
887 std::min(
fill->getNumWords(), numParts));
890 unsigned bitsToPreserve = semantics->precision - 1;
891 unsigned part = bitsToPreserve / 64;
892 bitsToPreserve %= 64;
893 significand[part] &= ((1ULL << bitsToPreserve) - 1);
894 for (part++; part != numParts; ++part)
895 significand[part] = 0;
899 (semantics->precision >= 2) ? (semantics->precision - 2) : 0;
921 if (semantics == &APFloatBase::semX87DoubleExtended)
927 if (semantics != rhs.semantics) {
929 initialize(rhs.semantics);
940 semantics = rhs.semantics;
941 significand = rhs.significand;
942 exponent = rhs.exponent;
943 category = rhs.category;
946 rhs.semantics = &APFloatBase::semBogus;
953 semantics->precision - 1) == 0);
961 significandMSB() == 0;
966 isSignificandAllZerosExceptMSB();
969unsigned int IEEEFloat::getNumHighBits()
const {
976 const unsigned int NumHighBits = (semantics->
precision > 1)
982bool IEEEFloat::isSignificandAllOnes()
const {
987 for (
unsigned i = 0; i < PartCount - 1; i++)
992 const unsigned NumHighBits = getNumHighBits();
993 assert(NumHighBits <= integerPartWidth && NumHighBits > 0 &&
994 "Can not have more high bits to fill than integerPartWidth");
997 if ((semantics->
precision <= 1) || (~(Parts[PartCount - 1] | HighBitFill)))
1003bool IEEEFloat::isSignificandAllOnesExceptLSB()
const {
1012 for (
unsigned i = 0; i < PartCount - 1; i++) {
1013 if (~Parts[i] & ~
unsigned{!i})
1018 const unsigned NumHighBits = getNumHighBits();
1019 assert(NumHighBits <= integerPartWidth && NumHighBits > 0 &&
1020 "Can not have more high bits to fill than integerPartWidth");
1023 if (~(Parts[PartCount - 1] | HighBitFill | 0x1))
1029bool IEEEFloat::isSignificandAllZeros()
const {
1035 for (
unsigned i = 0; i < PartCount - 1; i++)
1040 const unsigned NumHighBits = getNumHighBits();
1042 "clear than integerPartWidth");
1043 const integerPart HighBitMask = ~integerPart(0) >> NumHighBits;
1045 if ((semantics->precision > 1) && (Parts[PartCount - 1] & HighBitMask))
1051bool IEEEFloat::isSignificandAllZerosExceptMSB()
const {
1055 for (
unsigned i = 0; i < PartCount - 1; i++) {
1060 const unsigned NumHighBits = getNumHighBits();
1063 return ((semantics->precision <= 1) || (Parts[PartCount - 1] == MSBMask));
1067 bool IsMaxExp =
isFiniteNonZero() && exponent == semantics->maxExponent;
1074 ? isSignificandAllOnesExceptLSB()
1079 return IsMaxExp && isSignificandAllOnes();
1094 if (semantics != rhs.semantics ||
1095 category != rhs.category ||
1104 return std::equal(significandParts(), significandParts() + partCount(),
1105 rhs.significandParts());
1109 initialize(&ourSemantics);
1114 significandParts()[0] =
value;
1119 initialize(&ourSemantics);
1135 initialize(rhs.semantics);
1140 *
this = std::move(rhs);
1145unsigned int IEEEFloat::partCount()
const {
1150 return const_cast<IEEEFloat *
>(
this)->significandParts();
1154 if (partCount() > 1)
1155 return significand.parts;
1157 return &significand.part;
1160void IEEEFloat::zeroSignificand() {
1165void IEEEFloat::incrementSignificand() {
1179 parts = significandParts();
1181 assert(semantics == rhs.semantics);
1182 assert(exponent == rhs.exponent);
1184 return APInt::tcAdd(parts, rhs.significandParts(), 0, partCount());
1193 parts = significandParts();
1195 assert(semantics == rhs.semantics);
1196 assert(exponent == rhs.exponent);
1207 bool ignoreAddend) {
1209 unsigned int partsCount, newPartsCount, precision;
1216 assert(semantics == rhs.semantics);
1218 precision = semantics->precision;
1224 if (newPartsCount > 4)
1227 fullSignificand = scratch;
1229 lhsSignificand = significandParts();
1230 partsCount = partCount();
1233 rhs.significandParts(), partsCount, partsCount);
1236 omsb =
APInt::tcMSB(fullSignificand, newPartsCount) + 1;
1237 exponent += rhs.exponent;
1251 if (!ignoreAddend && addend.isNonZero()) {
1255 Significand savedSignificand = significand;
1256 const fltSemantics *savedSemantics = semantics;
1257 fltSemantics extendedSemantics;
1259 unsigned int extendedPrecision;
1262 extendedPrecision = 2 * precision + 1;
1263 if (omsb != extendedPrecision - 1) {
1264 assert(extendedPrecision > omsb);
1266 (extendedPrecision - 1) - omsb);
1267 exponent -= (extendedPrecision - 1) - omsb;
1271 extendedSemantics = *semantics;
1272 extendedSemantics.
precision = extendedPrecision;
1274 if (newPartsCount == 1)
1275 significand.part = fullSignificand[0];
1277 significand.parts = fullSignificand;
1278 semantics = &extendedSemantics;
1292 lost_fraction = extendedAddend.shiftSignificandRight(1);
1294 "Lost precision while shifting addend for fused-multiply-add.");
1296 lost_fraction = addOrSubtractSignificand(extendedAddend,
false);
1299 if (newPartsCount == 1)
1300 fullSignificand[0] = significand.part;
1301 significand = savedSignificand;
1302 semantics = savedSemantics;
1304 omsb =
APInt::tcMSB(fullSignificand, newPartsCount) + 1;
1311 exponent -= precision + 1;
1320 if (omsb > precision) {
1321 unsigned int bits, significantParts;
1324 bits = omsb - precision;
1326 lf =
shiftRight(fullSignificand, significantParts, bits);
1333 if (newPartsCount > 4)
1334 delete [] fullSignificand;
1336 return lost_fraction;
1345 return multiplySignificand(rhs,
IEEEFloat(*semantics), !semantics->hasZero);
1350 unsigned int bit, i, partsCount;
1356 assert(semantics == rhs.semantics);
1358 lhsSignificand = significandParts();
1359 rhsSignificand = rhs.significandParts();
1360 partsCount = partCount();
1367 divisor = dividend + partsCount;
1370 for (i = 0; i < partsCount; i++) {
1371 dividend[i] = lhsSignificand[i];
1372 divisor[i] = rhsSignificand[i];
1373 lhsSignificand[i] = 0;
1376 exponent -= rhs.exponent;
1378 unsigned int precision = semantics->precision;
1381 bit = precision -
APInt::tcMSB(divisor, partsCount) - 1;
1388 bit = precision -
APInt::tcMSB(dividend, partsCount) - 1;
1404 for (bit = precision; bit; bit -= 1) {
1428 return lost_fraction;
1431unsigned int IEEEFloat::significandMSB()
const {
1435unsigned int IEEEFloat::significandLSB()
const {
1440lostFraction IEEEFloat::shiftSignificandRight(
unsigned int bits) {
1446 return shiftRight(significandParts(), partCount(), bits);
1450void IEEEFloat::shiftSignificandLeft(
unsigned int bits) {
1451 assert(bits < semantics->precision ||
1452 (semantics->precision == 1 && bits <= 1));
1455 unsigned int partsCount = partCount();
1467 assert(semantics == rhs.semantics);
1471 compare = exponent - rhs.exponent;
1523 exponent = semantics->maxExponent;
1525 semantics->precision);
1538bool IEEEFloat::roundAwayFromZero(
roundingMode rounding_mode,
1540 unsigned int bit)
const {
1547 switch (rounding_mode) {
1585 omsb = significandMSB() + 1;
1592 exponentChange = omsb - semantics->precision;
1596 if (exponent + exponentChange > semantics->maxExponent)
1597 return handleOverflow(rounding_mode);
1601 if (exponent + exponentChange < semantics->minExponent)
1602 exponentChange = semantics->minExponent - exponent;
1605 if (exponentChange < 0) {
1608 shiftSignificandLeft(-exponentChange);
1613 if (exponentChange > 0) {
1617 lf = shiftSignificandRight(exponentChange);
1622 if (omsb > (
unsigned) exponentChange)
1623 omsb -= exponentChange;
1633 exponent == semantics->maxExponent && isSignificandAllOnes())
1634 return handleOverflow(rounding_mode);
1647 if (!semantics->hasZero)
1655 if (roundAwayFromZero(rounding_mode, lost_fraction, 0)) {
1657 exponent = semantics->minExponent;
1659 incrementSignificand();
1660 omsb = significandMSB() + 1;
1663 if (omsb == (
unsigned) semantics->precision + 1) {
1667 if (exponent == semantics->maxExponent)
1674 shiftSignificandRight(1);
1683 exponent == semantics->maxExponent && isSignificandAllOnes())
1684 return handleOverflow(rounding_mode);
1689 if (omsb == semantics->precision)
1693 assert(omsb < semantics->precision);
1703 if (!semantics->hasZero)
1776 subtract ^=
static_cast<bool>(sign ^ rhs.sign);
1779 bits = exponent - rhs.exponent;
1783 if ((bits < 0) && !semantics->hasSignedRepr)
1785 "This floating point format does not support signed values");
1788 bool lost_fraction_is_from_rhs =
false;
1792 else if (bits > 0) {
1793 lost_fraction = temp_rhs.shiftSignificandRight(bits - 1);
1794 lost_fraction_is_from_rhs =
true;
1795 shiftSignificandLeft(1);
1797 lost_fraction = shiftSignificandRight(-bits - 1);
1798 temp_rhs.shiftSignificandLeft(1);
1805 lost_fraction !=
lfExactlyZero && !lost_fraction_is_from_rhs;
1814 carry = temp_rhs.subtractSignificand(*
this, borrow);
1815 copySignificand(temp_rhs);
1818 bool borrow = lost_fraction !=
lfExactlyZero && lost_fraction_is_from_rhs;
1827 carry = subtractSignificand(temp_rhs, borrow);
1830 if (lost_fraction !=
lfExactlyZero && lost_fraction_is_from_rhs) {
1844 lost_fraction = temp_rhs.shiftSignificandRight(bits);
1845 carry = addSignificand(temp_rhs);
1847 lost_fraction = shiftSignificandRight(-bits);
1848 carry = addSignificand(rhs);
1856 return lost_fraction;
2051 lost_fraction = addOrSubtractSignificand(rhs,
subtract);
2052 fs = normalize(rounding_mode, lost_fraction);
2061 if (category ==
fcZero) {
2075 return addOrSubtract(rhs, rounding_mode,
false);
2081 return addOrSubtract(rhs, rounding_mode,
true);
2090 fs = multiplySpecials(rhs);
2096 fs = normalize(rounding_mode, lost_fraction);
2110 fs = divideSpecials(rhs);
2116 fs = normalize(rounding_mode, lost_fraction);
2127 unsigned int origSign = sign;
2130 fs = remainderSpecials(rhs);
2237 fs = modSpecials(rhs);
2238 unsigned int origSign = sign;
2259 if (!semantics->hasZero && this->isSmallest())
2279 sign ^= multiplicand.sign;
2288 lost_fraction = multiplySignificand(multiplicand, addend);
2289 fs = normalize(rounding_mode, lost_fraction);
2302 fs = multiplySpecials(multiplicand);
2312 fs = addOrSubtract(addend, rounding_mode,
false);
2386 MagicConstant.sign = sign;
2392 fs =
add(MagicConstant, rounding_mode);
2396 subtract(MagicConstant, rounding_mode);
2409 assert(semantics == rhs.semantics);
2441 if (sign == rhs.sign)
2456 if (sign != rhs.sign) {
2487 unsigned int newPartCount, oldPartCount;
2495 oldPartCount = partCount();
2498 bool X86SpecialNan =
false;
2499 if (&fromSemantics == &APFloatBase::semX87DoubleExtended &&
2500 &toSemantics != &APFloatBase::semX87DoubleExtended && category ==
fcNaN &&
2501 (!(*significandParts() & 0x8000000000000000ULL) ||
2502 !(*significandParts() & 0x4000000000000000ULL))) {
2505 X86SpecialNan =
true;
2516 int omsb = significandMSB() + 1;
2517 int exponentChange = omsb - fromSemantics.
precision;
2518 if (exponent + exponentChange < toSemantics.
minExponent)
2519 exponentChange = toSemantics.
minExponent - exponent;
2520 exponentChange = std::max(exponentChange, shift);
2521 if (exponentChange < 0) {
2522 shift -= exponentChange;
2523 exponent += exponentChange;
2524 }
else if (omsb <= -shift) {
2525 exponentChange = omsb + shift - 1;
2526 shift -= exponentChange;
2527 exponent += exponentChange;
2533 (category ==
fcNaN && semantics->nonFiniteBehavior !=
2538 if (newPartCount > oldPartCount) {
2546 significand.parts = newParts;
2547 }
else if (newPartCount == 1 && oldPartCount != 1) {
2551 newPart = significandParts()[0];
2553 significand.part = newPart;
2557 semantics = &toSemantics;
2566 *losesInfo = (
fs !=
opOK);
2567 }
else if (category ==
fcNaN) {
2585 if (!X86SpecialNan && semantics == &APFloatBase::semX87DoubleExtended)
2602 }
else if (category ==
fcZero &&
2615 if (category ==
fcZero && !semantics->hasZero)
2635 unsigned int dstPartsCount, truncatedBits;
2644 assert(dstPartsCount <= parts.
size() &&
"Integer too big");
2646 if (category ==
fcZero) {
2653 src = significandParts();
2662 truncatedBits = semantics->
precision -1U - exponent;
2666 unsigned int bits = exponent + 1U;
2672 if (bits < semantics->precision) {
2674 truncatedBits = semantics->
precision - bits;
2681 bits - semantics->precision);
2688 if (truncatedBits) {
2692 roundAwayFromZero(rounding_mode, lost_fraction, truncatedBits)) {
2712 if (omsb == width &&
2723 if (omsb >= width + !isSigned)
2745 unsigned int width,
bool isSigned,
2749 fs = convertToSignExtendedInteger(parts, width, isSigned, rounding_mode,
2753 unsigned int bits, dstPartsCount;
2756 assert(dstPartsCount <= parts.
size() &&
"Integer too big");
2758 if (category ==
fcNaN)
2763 bits = width - isSigned;
2766 if (sign && isSigned)
2778 unsigned int omsb, precision, dstCount;
2784 dst = significandParts();
2785 dstCount = partCount();
2790 if (precision <= omsb) {
2791 exponent = omsb - 1;
2796 exponent = precision - 1;
2801 return normalize(rounding_mode, lost_fraction);
2815 return convertFromUnsignedParts(api.
getRawData(), partCount, rounding_mode);
2819IEEEFloat::convertFromHexadecimalString(
StringRef s,
2828 unsigned partsCount = partCount();
2830 bool computedTrailingFraction =
false;
2838 return PtrOrErr.takeError();
2847 return createError(
"String contains multiple dots");
2853 if (hex_value == UINT_MAX)
2863 }
else if (!computedTrailingFraction) {
2866 return FractOrErr.takeError();
2867 lost_fraction = *FractOrErr;
2868 computedTrailingFraction =
true;
2874 return createError(
"Hex strings require an exponent");
2875 if (*p !=
'p' && *p !=
'P')
2876 return createError(
"Invalid character in significand");
2879 if (dot != end && p - begin == 1)
2883 if (p != firstSignificantDigit) {
2892 expAdjustment =
static_cast<int>(
dot - firstSignificantDigit);
2893 if (expAdjustment < 0)
2895 expAdjustment = expAdjustment * 4 - 1;
2899 expAdjustment += semantics->precision;
2905 return ExpOrErr.takeError();
2906 exponent = *ExpOrErr;
2909 return normalize(rounding_mode, lost_fraction);
2913IEEEFloat::roundSignificandWithExponent(
const integerPart *decSigParts,
2914 unsigned sigPartCount,
int exp,
2916 unsigned int parts, pow5PartCount;
2917 fltSemantics calcSemantics = { 32767, -32767, 0, 0 };
2927 pow5PartCount =
powerOf5(pow5Parts, exp >= 0 ? exp: -exp);
2929 for (;; parts *= 2) {
2931 unsigned int excessPrecision, truncatedBits;
2934 excessPrecision = calcSemantics.
precision - semantics->precision;
2935 truncatedBits = excessPrecision;
2938 decSig.makeZero(sign);
2941 sigStatus = decSig.convertFromUnsignedParts(decSigParts, sigPartCount,
2943 powStatus = pow5.convertFromUnsignedParts(pow5Parts, pow5PartCount,
2946 decSig.exponent += exp;
2950 unsigned int powHUerr;
2954 calcLostFraction = decSig.multiplySignificand(pow5);
2955 powHUerr = powStatus !=
opOK;
2957 calcLostFraction = decSig.divideSignificand(pow5);
2959 if (decSig.exponent < semantics->minExponent) {
2960 excessPrecision += (semantics->minExponent - decSig.exponent);
2961 truncatedBits = excessPrecision;
2962 excessPrecision = std::min(excessPrecision, calcSemantics.
precision);
2971 (decSig.significandParts(), calcSemantics.
precision - 1) == 1);
2976 excessPrecision, isNearest);
2979 if (HUdistance >= HUerr) {
2980 APInt::tcExtract(significandParts(), partCount(), decSig.significandParts(),
2981 calcSemantics.
precision - excessPrecision,
2986 exponent = (decSig.exponent + semantics->precision
2987 - (calcSemantics.
precision - excessPrecision));
2991 return normalize(rounding_mode, calcLostFraction);
2996Expected<APFloat::opStatus>
2997IEEEFloat::convertFromDecimalString(StringRef str,
roundingMode rounding_mode) {
3004 return std::move(Err);
3035 if (!semantics->hasZero)
3040 }
else if (
D.normalizedExponent - 1 > INT_MAX / 42039) {
3041 fs = handleOverflow(rounding_mode);
3047 }
else if (
D.normalizedExponent - 1 < INT_MIN / 42039 ||
3048 (
D.normalizedExponent + 1) * 28738 <=
3049 8651 * (semantics->minExponent - (
int) semantics->precision)) {
3056 }
else if ((
D.normalizedExponent - 1) * 42039
3057 >= 12655 * semantics->maxExponent) {
3059 fs = handleOverflow(rounding_mode);
3062 unsigned int partCount;
3068 partCount =
static_cast<unsigned int>(
D.lastSigDigit -
D.firstSigDigit) + 1;
3086 if (p == str.
end()) {
3091 if (decValue >= 10U) {
3092 delete[] decSignificand;
3093 return createError(
"Invalid character in significand");
3096 val = val * 10 + decValue;
3099 }
while (p <=
D.lastSigDigit && multiplier <= (~ (
integerPart) 0 - 9) / 10);
3103 partCount, partCount + 1,
false);
3107 if (decSignificand[partCount])
3109 }
while (p <=
D.lastSigDigit);
3112 fs = roundSignificandWithExponent(decSignificand, partCount,
3113 D.exponent, rounding_mode);
3115 delete [] decSignificand;
3121bool IEEEFloat::convertFromStringSpecials(StringRef str) {
3122 const size_t MIN_NAME_SIZE = 3;
3124 if (str.
size() < MIN_NAME_SIZE)
3127 if (str ==
"inf" || str ==
"INFINITY" || str ==
"+Inf") {
3134 if (str.
size() < MIN_NAME_SIZE)
3137 if (str ==
"inf" || str ==
"INFINITY" || str ==
"Inf") {
3146 if (str.
size() < MIN_NAME_SIZE)
3153 makeNaN(IsSignaling, IsNegative);
3158 if (str.
front() ==
'(') {
3160 if (str.
size() <= 2 || str.
back() !=
')')
3167 unsigned Radix = 10;
3168 if (str[0] ==
'0') {
3169 if (str.
size() > 1 && tolower(str[1]) ==
'x') {
3180 makeNaN(IsSignaling, IsNegative, &Payload);
3188Expected<APFloat::opStatus>
3194 if (convertFromStringSpecials(str))
3199 size_t slen = str.
size();
3200 sign = *p ==
'-' ? 1 : 0;
3201 if (sign && !semantics->hasSignedRepr)
3203 "This floating point format does not support signed values");
3205 if (*p ==
'-' || *p ==
'+') {
3212 if (slen >= 2 && p[0] ==
'0' && (p[1] ==
'x' || p[1] ==
'X')) {
3215 return convertFromHexadecimalString(
StringRef(p + 2, slen - 2),
3219 return convertFromDecimalString(
StringRef(p, slen), rounding_mode);
3263 dst +=
sizeof NaNU - 1;
3268 *dst++ = upperCase ?
'X':
'x';
3270 if (hexDigits > 1) {
3272 memset (dst,
'0', hexDigits - 1);
3273 dst += hexDigits - 1;
3275 *dst++ = upperCase ?
'P':
'p';
3280 dst = convertNormalToHexString (dst, hexDigits, upperCase, rounding_mode);
3286 return static_cast<unsigned int>(dst - p);
3293char *IEEEFloat::convertNormalToHexString(
char *dst,
unsigned int hexDigits,
3296 unsigned int count, valueBits, shift, partsCount, outputDigits;
3297 const char *hexDigitChars;
3303 *dst++ = upperCase ?
'X':
'x';
3308 significand = significandParts();
3309 partsCount = partCount();
3318 outputDigits = (valueBits - significandLSB () + 3) / 4;
3324 if (hexDigits < outputDigits) {
3330 bits = valueBits - hexDigits * 4;
3332 roundUp = roundAwayFromZero(rounding_mode, fraction, bits);
3334 outputDigits = hexDigits;
3344 while (outputDigits &&
count) {
3348 if (--
count == partsCount)
3351 part = significand[
count] << shift;
3359 curDigits = std::min(curDigits, outputDigits);
3360 dst +=
partAsHex (dst, part, curDigits, hexDigitChars);
3361 outputDigits -= curDigits;
3371 }
while (*q ==
'0');
3375 memset (dst,
'0', outputDigits);
3376 dst += outputDigits;
3389 *dst++ = upperCase ?
'P':
'p';
3405 Arg.significandParts(),
3406 Arg.significandParts() + Arg.partCount()));
3418APInt IEEEFloat::convertF80LongDoubleAPFloatToAPInt()
const {
3423 uint64_t myexponent, mysignificand;
3426 myexponent = exponent+16383;
3427 mysignificand = significandParts()[0];
3428 if (myexponent==1 && !(mysignificand & 0x8000000000000000ULL))
3430 }
else if (category==
fcZero) {
3434 myexponent = 0x7fff;
3435 mysignificand = 0x8000000000000000ULL;
3438 myexponent = 0x7fff;
3439 mysignificand = significandParts()[0];
3443 words[0] = mysignificand;
3444 words[1] = ((uint64_t)(sign & 1) << 15) |
3445 (myexponent & 0x7fffLL);
3446 return APInt(80, words);
3449APInt IEEEFloat::convertPPCDoubleDoubleLegacyAPFloatToAPInt()
const {
3451 (
const llvm::fltSemantics *)&APFloatBase::semPPCDoubleDoubleLegacy);
3464 fltSemantics extendedSemantics = *semantics;
3475 words[0] = *
u.convertDoubleAPFloatToAPInt().getRawData();
3481 if (
u.isFiniteNonZero() && losesInfo) {
3491 words[1] = *
v.convertDoubleAPFloatToAPInt().getRawData();
3496 return APInt(128, words);
3499template <const fltSemantics &S>
3500APInt IEEEFloat::convertIEEEFloatToAPInt()
const {
3502 const int bias = (semantics == &APFloatBase::semFloat8E8M0FNU)
3504 : -(S.minExponent - 1);
3505 constexpr unsigned int trailing_significand_bits = S.precision - 1;
3506 constexpr int integer_bit_part = trailing_significand_bits /
integerPartWidth;
3509 constexpr uint64_t significand_mask = integer_bit - 1;
3510 constexpr unsigned int exponent_bits =
3511 trailing_significand_bits ? (S.sizeInBits - 1 - trailing_significand_bits)
3513 static_assert(exponent_bits < 64);
3514 constexpr uint64_t exponent_mask = (uint64_t{1} << exponent_bits) - 1;
3516 uint64_t myexponent;
3521 myexponent = exponent + bias;
3522 std::copy_n(significandParts(), mysignificand.size(),
3523 mysignificand.begin());
3524 if (myexponent == 1 &&
3525 !(significandParts()[integer_bit_part] & integer_bit))
3527 }
else if (category ==
fcZero) {
3530 myexponent = ::exponentZero(S) + bias;
3531 mysignificand.fill(0);
3536 myexponent = ::exponentInf(S) + bias;
3537 mysignificand.fill(0);
3542 myexponent = ::exponentNaN(S) + bias;
3543 std::copy_n(significandParts(), mysignificand.size(),
3544 mysignificand.begin());
3546 std::array<uint64_t, (S.sizeInBits + 63) / 64> words;
3548 std::copy_n(mysignificand.begin(), mysignificand.size(), words.begin());
3549 if constexpr (significand_mask != 0 || trailing_significand_bits == 0) {
3551 words[mysignificand.size() - 1] &= significand_mask;
3553 std::fill(words_iter, words.end(), uint64_t{0});
3554 constexpr size_t last_word = words.size() - 1;
3555 uint64_t shifted_sign =
static_cast<uint64_t
>(sign & 1)
3556 << ((S.sizeInBits - 1) % 64);
3557 words[last_word] |= shifted_sign;
3558 uint64_t shifted_exponent = (myexponent & exponent_mask)
3559 << (trailing_significand_bits % 64);
3560 words[last_word] |= shifted_exponent;
3561 if constexpr (last_word == 0) {
3562 return APInt(S.sizeInBits, words[0]);
3564 return APInt(S.sizeInBits, words);
3567APInt IEEEFloat::convertQuadrupleAPFloatToAPInt()
const {
3568 assert(partCount() == 2);
3569 return convertIEEEFloatToAPInt<APFloatBase::semIEEEquad>();
3572APInt IEEEFloat::convertDoubleAPFloatToAPInt()
const {
3574 return convertIEEEFloatToAPInt<APFloatBase::semIEEEdouble>();
3577APInt IEEEFloat::convertFloatAPFloatToAPInt()
const {
3579 return convertIEEEFloatToAPInt<APFloatBase::semIEEEsingle>();
3582APInt IEEEFloat::convertBFloatAPFloatToAPInt()
const {
3583 assert(partCount() == 1);
3584 return convertIEEEFloatToAPInt<APFloatBase::semBFloat>();
3587APInt IEEEFloat::convertHalfAPFloatToAPInt()
const {
3589 return convertIEEEFloatToAPInt<APFloatBase::APFloatBase::semIEEEhalf>();
3592APInt IEEEFloat::convertFloat8E5M2APFloatToAPInt()
const {
3593 assert(partCount() == 1);
3594 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E5M2>();
3597APInt IEEEFloat::convertFloat8E5M2FNUZAPFloatToAPInt()
const {
3598 assert(partCount() == 1);
3599 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E5M2FNUZ>();
3602APInt IEEEFloat::convertFloat8E4M3APFloatToAPInt()
const {
3603 assert(partCount() == 1);
3604 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E4M3>();
3607APInt IEEEFloat::convertFloat8E4M3FNAPFloatToAPInt()
const {
3608 assert(partCount() == 1);
3609 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E4M3FN>();
3612APInt IEEEFloat::convertFloat8E4M3FNUZAPFloatToAPInt()
const {
3613 assert(partCount() == 1);
3614 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E4M3FNUZ>();
3617APInt IEEEFloat::convertFloat8E4M3B11FNUZAPFloatToAPInt()
const {
3618 assert(partCount() == 1);
3619 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E4M3B11FNUZ>();
3622APInt IEEEFloat::convertFloat8E3M4APFloatToAPInt()
const {
3623 assert(partCount() == 1);
3624 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E3M4>();
3627APInt IEEEFloat::convertFloatTF32APFloatToAPInt()
const {
3628 assert(partCount() == 1);
3629 return convertIEEEFloatToAPInt<APFloatBase::semFloatTF32>();
3632APInt IEEEFloat::convertFloat8E8M0FNUAPFloatToAPInt()
const {
3633 assert(partCount() == 1);
3634 return convertIEEEFloatToAPInt<APFloatBase::semFloat8E8M0FNU>();
3637APInt IEEEFloat::convertFloat6E3M2FNAPFloatToAPInt()
const {
3638 assert(partCount() == 1);
3639 return convertIEEEFloatToAPInt<APFloatBase::semFloat6E3M2FN>();
3642APInt IEEEFloat::convertFloat6E2M3FNAPFloatToAPInt()
const {
3643 assert(partCount() == 1);
3644 return convertIEEEFloatToAPInt<APFloatBase::semFloat6E2M3FN>();
3647APInt IEEEFloat::convertFloat4E2M1FNAPFloatToAPInt()
const {
3648 assert(partCount() == 1);
3649 return convertIEEEFloatToAPInt<APFloatBase::semFloat4E2M1FN>();
3658 return convertHalfAPFloatToAPInt();
3661 return convertBFloatAPFloatToAPInt();
3664 return convertFloatAPFloatToAPInt();
3667 return convertDoubleAPFloatToAPInt();
3670 return convertQuadrupleAPFloatToAPInt();
3674 return convertPPCDoubleDoubleLegacyAPFloatToAPInt();
3677 return convertFloat8E5M2APFloatToAPInt();
3680 return convertFloat8E5M2FNUZAPFloatToAPInt();
3683 return convertFloat8E4M3APFloatToAPInt();
3686 return convertFloat8E4M3FNAPFloatToAPInt();
3689 return convertFloat8E4M3FNUZAPFloatToAPInt();
3693 return convertFloat8E4M3B11FNUZAPFloatToAPInt();
3696 return convertFloat8E3M4APFloatToAPInt();
3699 return convertFloatTF32APFloatToAPInt();
3702 return convertFloat8E8M0FNUAPFloatToAPInt();
3705 return convertFloat6E3M2FNAPFloatToAPInt();
3708 return convertFloat6E2M3FNAPFloatToAPInt();
3711 return convertFloat4E2M1FNAPFloatToAPInt();
3716 return convertF80LongDoubleAPFloatToAPInt();
3721 "Float semantics are not IEEEsingle");
3728 "Float semantics are not IEEEdouble");
3733#ifdef HAS_IEE754_FLOAT128
3734float128 IEEEFloat::convertToQuad()
const {
3736 "Float semantics are not IEEEquads");
3738 return api.bitsToQuad();
3749void IEEEFloat::initFromF80LongDoubleAPInt(
const APInt &api) {
3752 uint64_t myexponent = (i2 & 0x7fff);
3754 uint8_t myintegerbit = mysignificand >> 63;
3756 initialize(&APFloatBase::semX87DoubleExtended);
3759 sign =
static_cast<unsigned int>(i2>>15);
3760 if (myexponent == 0 && mysignificand == 0) {
3762 }
else if (myexponent==0x7fff && mysignificand==0x8000000000000000ULL) {
3764 }
else if ((myexponent == 0x7fff && mysignificand != 0x8000000000000000ULL) ||
3765 (myexponent != 0x7fff && myexponent != 0 && myintegerbit == 0)) {
3767 exponent = exponentNaN();
3768 significandParts()[0] = mysignificand;
3769 significandParts()[1] = 0;
3772 exponent = myexponent - 16383;
3773 significandParts()[0] = mysignificand;
3774 significandParts()[1] = 0;
3780void IEEEFloat::initFromPPCDoubleDoubleLegacyAPInt(
const APInt &api) {
3787 initFromDoubleAPInt(APInt(64, i1));
3795 IEEEFloat v(APFloatBase::semIEEEdouble, APInt(64, i2));
3810void IEEEFloat::initFromFloat8E8M0FNUAPInt(
const APInt &api) {
3811 const uint64_t exponent_mask = 0xff;
3813 uint64_t myexponent = (val & exponent_mask);
3815 initialize(&APFloatBase::semFloat8E8M0FNU);
3816 assert(partCount() == 1);
3824 uint64_t mysignificand = 1;
3825 significandParts()[0] = mysignificand;
3829 if (val == exponent_mask) {
3831 exponent = exponentNaN();
3836 exponent = myexponent - 127;
3838template <const fltSemantics &S>
3839void IEEEFloat::initFromIEEEAPInt(
const APInt &api) {
3843 constexpr uint64_t significand_mask = integer_bit - 1;
3844 constexpr unsigned int trailing_significand_bits = S.precision - 1;
3845 constexpr unsigned int stored_significand_parts =
3847 constexpr unsigned int exponent_bits =
3848 S.sizeInBits - 1 - trailing_significand_bits;
3849 static_assert(exponent_bits < 64);
3850 constexpr uint64_t exponent_mask = (uint64_t{1} << exponent_bits) - 1;
3851 constexpr int bias = -(S.minExponent - 1);
3855 std::array<integerPart, stored_significand_parts> mysignificand;
3856 std::copy_n(api.
getRawData(), mysignificand.size(), mysignificand.begin());
3857 if constexpr (significand_mask != 0) {
3858 mysignificand[mysignificand.size() - 1] &= significand_mask;
3864 uint64_t myexponent =
3865 (last_word >> (trailing_significand_bits % 64)) & exponent_mask;
3868 assert(partCount() == mysignificand.size());
3870 sign =
static_cast<unsigned int>(last_word >> ((S.sizeInBits - 1) % 64));
3874 bool is_zero = myexponent == 0 && all_zero_significand;
3877 if (myexponent - bias == ::exponentInf(S) && all_zero_significand) {
3883 bool is_nan =
false;
3886 is_nan = myexponent - bias == ::exponentNaN(S) && !all_zero_significand;
3888 bool all_ones_significand =
3889 std::all_of(mysignificand.begin(), mysignificand.end() - 1,
3890 [](
integerPart bits) { return bits == ~integerPart{0}; }) &&
3891 (!significand_mask ||
3892 mysignificand[mysignificand.size() - 1] == significand_mask);
3893 is_nan = myexponent - bias == ::exponentNaN(S) && all_ones_significand;
3895 is_nan = is_zero && sign;
3901 std::copy_n(mysignificand.begin(), mysignificand.size(),
3902 significandParts());
3912 exponent = myexponent - bias;
3913 std::copy_n(mysignificand.begin(), mysignificand.size(), significandParts());
3914 if (myexponent == 0)
3915 exponent = S.minExponent;
3917 significandParts()[mysignificand.size()-1] |= integer_bit;
3920void IEEEFloat::initFromQuadrupleAPInt(
const APInt &api) {
3921 initFromIEEEAPInt<APFloatBase::semIEEEquad>(api);
3924void IEEEFloat::initFromDoubleAPInt(
const APInt &api) {
3925 initFromIEEEAPInt<APFloatBase::semIEEEdouble>(api);
3928void IEEEFloat::initFromFloatAPInt(
const APInt &api) {
3929 initFromIEEEAPInt<APFloatBase::semIEEEsingle>(api);
3932void IEEEFloat::initFromBFloatAPInt(
const APInt &api) {
3933 initFromIEEEAPInt<APFloatBase::semBFloat>(api);
3936void IEEEFloat::initFromHalfAPInt(
const APInt &api) {
3937 initFromIEEEAPInt<APFloatBase::semIEEEhalf>(api);
3940void IEEEFloat::initFromFloat8E5M2APInt(
const APInt &api) {
3941 initFromIEEEAPInt<APFloatBase::semFloat8E5M2>(api);
3944void IEEEFloat::initFromFloat8E5M2FNUZAPInt(
const APInt &api) {
3945 initFromIEEEAPInt<APFloatBase::semFloat8E5M2FNUZ>(api);
3948void IEEEFloat::initFromFloat8E4M3APInt(
const APInt &api) {
3949 initFromIEEEAPInt<APFloatBase::semFloat8E4M3>(api);
3952void IEEEFloat::initFromFloat8E4M3FNAPInt(
const APInt &api) {
3953 initFromIEEEAPInt<APFloatBase::semFloat8E4M3FN>(api);
3956void IEEEFloat::initFromFloat8E4M3FNUZAPInt(
const APInt &api) {
3957 initFromIEEEAPInt<APFloatBase::semFloat8E4M3FNUZ>(api);
3960void IEEEFloat::initFromFloat8E4M3B11FNUZAPInt(
const APInt &api) {
3961 initFromIEEEAPInt<APFloatBase::semFloat8E4M3B11FNUZ>(api);
3964void IEEEFloat::initFromFloat8E3M4APInt(
const APInt &api) {
3965 initFromIEEEAPInt<APFloatBase::semFloat8E3M4>(api);
3968void IEEEFloat::initFromFloatTF32APInt(
const APInt &api) {
3969 initFromIEEEAPInt<APFloatBase::semFloatTF32>(api);
3972void IEEEFloat::initFromFloat6E3M2FNAPInt(
const APInt &api) {
3973 initFromIEEEAPInt<APFloatBase::semFloat6E3M2FN>(api);
3976void IEEEFloat::initFromFloat6E2M3FNAPInt(
const APInt &api) {
3977 initFromIEEEAPInt<APFloatBase::semFloat6E2M3FN>(api);
3980void IEEEFloat::initFromFloat4E2M1FNAPInt(
const APInt &api) {
3981 initFromIEEEAPInt<APFloatBase::semFloat4E2M1FN>(api);
3987 if (Sem == &APFloatBase::semIEEEhalf)
3988 return initFromHalfAPInt(api);
3989 if (Sem == &APFloatBase::semBFloat)
3990 return initFromBFloatAPInt(api);
3991 if (Sem == &APFloatBase::semIEEEsingle)
3992 return initFromFloatAPInt(api);
3993 if (Sem == &APFloatBase::semIEEEdouble)
3994 return initFromDoubleAPInt(api);
3995 if (Sem == &APFloatBase::semX87DoubleExtended)
3996 return initFromF80LongDoubleAPInt(api);
3997 if (Sem == &APFloatBase::semIEEEquad)
3998 return initFromQuadrupleAPInt(api);
3999 if (Sem == &APFloatBase::semPPCDoubleDoubleLegacy)
4000 return initFromPPCDoubleDoubleLegacyAPInt(api);
4001 if (Sem == &APFloatBase::semFloat8E5M2)
4002 return initFromFloat8E5M2APInt(api);
4003 if (Sem == &APFloatBase::semFloat8E5M2FNUZ)
4004 return initFromFloat8E5M2FNUZAPInt(api);
4005 if (Sem == &APFloatBase::semFloat8E4M3)
4006 return initFromFloat8E4M3APInt(api);
4007 if (Sem == &APFloatBase::semFloat8E4M3FN)
4008 return initFromFloat8E4M3FNAPInt(api);
4009 if (Sem == &APFloatBase::semFloat8E4M3FNUZ)
4010 return initFromFloat8E4M3FNUZAPInt(api);
4011 if (Sem == &APFloatBase::semFloat8E4M3B11FNUZ)
4012 return initFromFloat8E4M3B11FNUZAPInt(api);
4013 if (Sem == &APFloatBase::semFloat8E3M4)
4014 return initFromFloat8E3M4APInt(api);
4015 if (Sem == &APFloatBase::semFloatTF32)
4016 return initFromFloatTF32APInt(api);
4017 if (Sem == &APFloatBase::semFloat8E8M0FNU)
4018 return initFromFloat8E8M0FNUAPInt(api);
4019 if (Sem == &APFloatBase::semFloat6E3M2FN)
4020 return initFromFloat6E3M2FNAPInt(api);
4021 if (Sem == &APFloatBase::semFloat6E2M3FN)
4022 return initFromFloat6E2M3FNAPInt(api);
4023 if (Sem == &APFloatBase::semFloat4E2M1FN)
4024 return initFromFloat4E2M1FNAPInt(api);
4032 if (Negative && !semantics->hasSignedRepr)
4034 "This floating point format does not support signed values");
4041 exponent = semantics->maxExponent;
4045 unsigned PartCount = partCount();
4046 memset(significand, 0xFF,
sizeof(
integerPart)*(PartCount - 1));
4050 const unsigned NumUnusedHighBits =
4057 (semantics->precision > 1))
4064 if (Negative && !semantics->hasSignedRepr)
4066 "This floating point format does not support signed values");
4073 exponent = semantics->minExponent;
4078 if (Negative && !semantics->hasSignedRepr)
4080 "This floating point format does not support signed values");
4089 exponent = semantics->minExponent;
4094 initFromAPInt(&Sem, API);
4107 Buffer.
append(Str.begin(), Str.end());
4112 void AdjustToPrecision(
APInt &significand,
4113 int &exp,
unsigned FormatPrecision) {
4117 unsigned bitsRequired = (FormatPrecision * 196 + 58) / 59;
4119 if (bits <= bitsRequired)
return;
4121 unsigned tensRemovable = (bits - bitsRequired) * 59 / 196;
4122 if (!tensRemovable)
return;
4124 exp += tensRemovable;
4129 if (tensRemovable & 1)
4131 tensRemovable >>= 1;
4132 if (!tensRemovable)
break;
4136 significand = significand.
udiv(divisor);
4144 int &exp,
unsigned FormatPrecision) {
4145 unsigned N = buffer.
size();
4146 if (
N <= FormatPrecision)
return;
4149 unsigned FirstSignificant =
N - FormatPrecision;
4156 if (buffer[FirstSignificant - 1] <
'5') {
4157 while (FirstSignificant <
N && buffer[FirstSignificant] ==
'0')
4160 exp += FirstSignificant;
4161 buffer.
erase(&buffer[0], &buffer[FirstSignificant]);
4167 for (
unsigned I = FirstSignificant;
I !=
N; ++
I) {
4168 if (buffer[
I] ==
'9') {
4177 if (FirstSignificant ==
N) {
4178 exp += FirstSignificant;
4184 exp += FirstSignificant;
4185 buffer.
erase(&buffer[0], &buffer[FirstSignificant]);
4189 APInt significand,
unsigned FormatPrecision,
4190 unsigned FormatMaxPadding,
bool TruncateZero) {
4191 const int semanticsPrecision = significand.
getBitWidth();
4198 if (!FormatPrecision) {
4206 FormatPrecision = 2 + semanticsPrecision * 59 / 196;
4211 exp += trailingZeros;
4217 }
else if (exp > 0) {
4219 significand = significand.
zext(semanticsPrecision + exp);
4220 significand <<= exp;
4234 unsigned precision = semanticsPrecision + (137 * texp + 136) / 59;
4238 significand = significand.
zext(precision);
4239 APInt five_to_the_i(precision, 5);
4242 significand *= five_to_the_i;
4247 five_to_the_i *= five_to_the_i;
4251 AdjustToPrecision(significand, exp, FormatPrecision);
4256 unsigned precision = significand.getBitWidth();
4257 if (precision < 4) {
4260 significand = significand.zext(precision);
4262 APInt ten(precision, 10);
4263 APInt digit(precision, 0);
4265 bool inTrail =
true;
4266 while (significand != 0) {
4271 unsigned d = digit.getZExtValue();
4282 assert(!buffer.
empty() &&
"no characters in buffer!");
4286 AdjustToPrecision(buffer, exp, FormatPrecision);
4288 unsigned NDigits = buffer.
size();
4291 bool FormatScientific;
4292 if (!FormatMaxPadding)
4293 FormatScientific =
true;
4299 FormatScientific = ((unsigned) exp > FormatMaxPadding ||
4300 NDigits + (unsigned) exp > FormatPrecision);
4303 int MSD = exp + (int) (NDigits - 1);
4306 FormatScientific =
false;
4310 FormatScientific = ((unsigned) -MSD) > FormatMaxPadding;
4316 if (FormatScientific) {
4317 exp += (NDigits - 1);
4319 Str.push_back(buffer[NDigits-1]);
4321 if (NDigits == 1 && TruncateZero)
4324 for (
unsigned I = 1;
I != NDigits; ++
I)
4325 Str.push_back(buffer[NDigits-1-
I]);
4327 if (!TruncateZero && FormatPrecision > NDigits - 1)
4328 Str.append(FormatPrecision - NDigits + 1,
'0');
4330 Str.push_back(TruncateZero ?
'E' :
'e');
4332 Str.push_back(exp >= 0 ?
'+' :
'-');
4337 expbuf.
push_back((
char) (
'0' + (exp % 10)));
4341 if (!TruncateZero && expbuf.
size() < 2)
4343 for (
unsigned I = 0,
E = expbuf.
size();
I !=
E; ++
I)
4344 Str.push_back(expbuf[
E-1-
I]);
4350 for (
unsigned I = 0;
I != NDigits; ++
I)
4351 Str.push_back(buffer[NDigits-1-
I]);
4352 for (
unsigned I = 0;
I != (unsigned) exp; ++
I)
4360 int NWholeDigits = exp + (int) NDigits;
4363 if (NWholeDigits > 0) {
4364 for (;
I != (unsigned) NWholeDigits; ++
I)
4365 Str.push_back(buffer[NDigits-
I-1]);
4368 unsigned NZeros = 1 + (unsigned) -NWholeDigits;
4372 for (
unsigned Z = 1;
Z != NZeros; ++
Z)
4376 for (;
I != NDigits; ++
I)
4377 Str.push_back(buffer[NDigits-
I-1]);
4383 unsigned FormatMaxPadding,
bool TruncateZero)
const {
4387 return append(Str,
"-Inf");
4389 return append(Str,
"+Inf");
4391 case fcNaN:
return append(Str,
"NaN");
4397 if (!FormatMaxPadding) {
4399 append(Str,
"0.0E+0");
4402 if (FormatPrecision > 1)
4403 Str.append(FormatPrecision - 1,
'0');
4404 append(Str,
"e+00");
4416 int exp = exponent - ((int) semantics->precision - 1);
4418 semantics->precision,
4421 toStringImpl(Str,
isNegative(), exp, significand, FormatPrecision,
4422 FormatMaxPadding, TruncateZero);
4434 for (
int i = 0; i < PartCount; ++i) {
4440 if (exponent != semantics->minExponent)
4443 int CountrParts = 0;
4444 for (
int i = 0; i < PartCount;
4446 if (Parts[i] != 0) {
4447 return exponent - semantics->precision + CountrParts +
4510 if (!semantics->hasZero)
4520 }
else if (semantics->nonFiniteBehavior ==
4528 exponent = semantics->maxExponent + 1;
4542 bool WillCrossBinadeBoundary =
4543 exponent != semantics->minExponent && isSignificandAllZeros();
4561 if (WillCrossBinadeBoundary) {
4582 if (WillCrossBinadeBoundary) {
4586 assert(exponent != semantics->maxExponent &&
4587 "We can not increment an exponent beyond the maxExponent allowed"
4588 " by the given floating point semantics.");
4591 incrementSignificand();
4605 return ::exponentNaN(*semantics);
4609 return ::exponentInf(*semantics);
4613 return ::exponentZero(*semantics);
4632 if (!semantics->hasZero)
4659 return Arg.exponent;
4664 Normalized.exponent += SignificandBits;
4666 return Normalized.exponent - SignificandBits;
4670 auto MaxExp =
X.getSemantics().maxExponent;
4671 auto MinExp =
X.getSemantics().minExponent;
4679 int SignificandBits =
X.getSemantics().precision - 1;
4680 int MaxIncrement = MaxExp - (MinExp - SignificandBits) + 1;
4683 X.exponent += std::clamp(Exp, -MaxIncrement - 1, MaxIncrement);
4706 return scalbn(Val, -Exp, RM);
4712 APFloat(APFloatBase::semIEEEdouble)}) {
4713 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4717 : Semantics(&S), Floats(new
APFloat[2]{
4720 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4726 APFloat(APFloatBase::semIEEEdouble)}) {
4727 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4733 APFloat(APFloatBase::semIEEEdouble,
APInt(64,
I.getRawData()[0])),
4734 APFloat(APFloatBase::semIEEEdouble,
APInt(64,
I.getRawData()[1]))}) {
4735 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4741 Floats(new
APFloat[2]{std::move(
First), std::move(Second)}) {
4742 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4743 assert(&Floats[0].getSemantics() == &APFloatBase::semIEEEdouble);
4744 assert(&Floats[1].getSemantics() == &APFloatBase::semIEEEdouble);
4748 : Semantics(RHS.Semantics),
4752 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4756 : Semantics(RHS.Semantics), Floats(RHS.Floats) {
4757 RHS.Semantics = &APFloatBase::semBogus;
4758 RHS.Floats =
nullptr;
4759 assert(Semantics == &APFloatBase::semPPCDoubleDouble);
4763 if (Semantics == RHS.Semantics && RHS.Floats) {
4764 Floats[0] = RHS.Floats[0];
4765 Floats[1] = RHS.Floats[1];
4766 }
else if (
this != &RHS) {
4799 Floats[0] = std::move(z);
4800 Floats[1].makeZero(
false);
4804 auto AComparedToC = a.compareAbsoluteValue(c);
4813 Status |= z.
add(a, RM);
4814 Status |= z.
add(c, RM);
4817 Floats[0] = std::move(z);
4818 Floats[1].makeZero(
false);
4823 Status |= zz.
add(cc, RM);
4827 Status |= Floats[1].subtract(z, RM);
4828 Status |= Floats[1].add(c, RM);
4829 Status |= Floats[1].add(zz, RM);
4833 Status |= Floats[1].subtract(z, RM);
4834 Status |= Floats[1].add(a, RM);
4835 Status |= Floats[1].add(zz, RM);
4840 Status |=
q.subtract(z, RM);
4845 Status |= zz.
add(c, RM);
4846 Status |=
q.add(z, RM);
4847 Status |=
q.subtract(a, RM);
4849 Status |= zz.
add(q, RM);
4850 Status |= zz.
add(
aa, RM);
4851 Status |= zz.
add(cc, RM);
4853 Floats[0] = std::move(z);
4854 Floats[1].makeZero(
false);
4858 Status |= Floats[0].add(zz, RM);
4860 Floats[1].makeZero(
false);
4863 Floats[1] = std::move(z);
4864 Status |= Floats[1].subtract(Floats[0], RM);
4865 Status |= Floats[1].add(zz, RM);
4891 LHS.isNegative() !=
RHS.isNegative()) {
4892 Out.makeNaN(
false, Out.isNegative(),
nullptr);
4907 assert(&
A.getSemantics() == &APFloatBase::semIEEEdouble);
4908 assert(&AA.getSemantics() == &APFloatBase::semIEEEdouble);
4909 assert(&
C.getSemantics() == &APFloatBase::semIEEEdouble);
4910 assert(&CC.getSemantics() == &APFloatBase::semIEEEdouble);
4911 assert(&Out.Floats[0].getSemantics() == &APFloatBase::semIEEEdouble);
4912 assert(&Out.Floats[1].getSemantics() == &APFloatBase::semIEEEdouble);
4913 return Out.addImpl(
A, AA,
C, CC, RM);
4918 return addWithSpecial(*
this, RHS, *
this, RM);
4924 auto Ret =
add(RHS, RM);
4931 const auto &LHS = *
this;
4948 if (LHS.getCategory() ==
fcNaN) {
4952 if (RHS.getCategory() ==
fcNaN) {
4958 Out.makeNaN(
false,
false,
nullptr);
4970 "Special cases not handled exhaustively");
4973 APFloat A = Floats[0],
B = Floats[1],
C = RHS.Floats[0],
D = RHS.Floats[1];
4977 if (!
T.isFiniteNonZero()) {
4979 Floats[1].makeZero(
false);
5001 Status |= U.add(Tau, RM);
5004 if (!U.isFinite()) {
5005 Floats[1].makeZero(
false);
5017 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5018 "Unexpected Semantics");
5021 APFloat(APFloatBase::semPPCDoubleDoubleLegacy, RHS.bitcastToAPInt()), RM);
5027 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5028 "Unexpected Semantics");
5031 APFloat(APFloatBase::semPPCDoubleDoubleLegacy, RHS.bitcastToAPInt()));
5037 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5038 "Unexpected Semantics");
5041 APFloat(APFloatBase::semPPCDoubleDoubleLegacy, RHS.bitcastToAPInt()));
5050 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5051 "Unexpected Semantics");
5054 APFloat(APFloatBase::semPPCDoubleDoubleLegacy,
5063 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5064 "Unexpected Semantics");
5074 if (!
Hi.isFiniteNonZero() ||
Lo.isZero()) {
5075 Floats[0] = std::move(RoundedHi);
5076 Floats[1].makeZero(
false);
5088 const APFloat RoundingError = Rounded - ToRound;
5089 if (TieBreaker.isNonZero() &&
5090 TieBreaker.isNegative() != RoundingError.
isNegative() &&
5091 abs(RoundingError).isExactlyValue(0.5))
5100 if (RoundedHi !=
Hi) {
5105 RoundedHi = RoundToNearestHelper(
Hi, RoundedHi,
Lo);
5107 Floats[0] = std::move(RoundedHi);
5108 Floats[1].makeZero(
false);
5121 LoRoundingMode = RM;
5129 RoundedLo = RoundToNearestHelper(
Lo, RoundedLo,
Hi);
5132 std::tie(RoundedHi, RoundedLo) =
fastTwoSum(RoundedHi, RoundedLo);
5134 Floats[0] = std::move(RoundedHi);
5135 Floats[1] = std::move(RoundedLo);
5140 Floats[0].changeSign();
5141 Floats[1].changeSign();
5147 const cmpResult HiPartCmp = Floats[0].compareAbsoluteValue(RHS.Floats[0]);
5152 if (Floats[1].
isZero() && RHS.Floats[1].isZero())
5158 const bool ThisIsSubtractive =
5159 Floats[0].isNegative() != Floats[1].isNegative();
5160 const bool RHSIsSubtractive =
5161 RHS.Floats[0].isNegative() != RHS.Floats[1].isNegative();
5171 if (RHS.Floats[1].isZero())
5178 if (ThisIsSubtractive != RHSIsSubtractive)
5183 const cmpResult LoPartCmp = Floats[1].compareAbsoluteValue(RHS.Floats[1]);
5185 if (ThisIsSubtractive) {
5199 return Floats[0].getCategory();
5205 Floats[0].makeInf(Neg);
5206 Floats[1].makeZero(
false);
5210 Floats[0].makeZero(Neg);
5211 Floats[1].makeZero(
false);
5215 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5216 "Unexpected Semantics");
5218 APFloat(APFloatBase::semIEEEdouble,
APInt(64, 0x7fefffffffffffffull));
5220 APFloat(APFloatBase::semIEEEdouble,
APInt(64, 0x7c8ffffffffffffeull));
5226 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5227 "Unexpected Semantics");
5228 Floats[0].makeSmallest(Neg);
5229 Floats[1].makeZero(
false);
5233 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5234 "Unexpected Semantics");
5236 APFloat(APFloatBase::semIEEEdouble,
APInt(64, 0x0360000000000000ull));
5238 Floats[0].changeSign();
5239 Floats[1].makeZero(
false);
5243 Floats[0].makeNaN(SNaN, Neg,
fill);
5244 Floats[1].makeZero(
false);
5248 auto Result = Floats[0].compare(RHS.Floats[0]);
5251 return Floats[1].compare(RHS.Floats[1]);
5256 return Floats[0].bitwiseIsEqual(RHS.Floats[0]) &&
5257 Floats[1].bitwiseIsEqual(RHS.Floats[1]);
5267 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5268 "Unexpected Semantics");
5270 Floats[0].bitcastToAPInt().getRawData()[0],
5271 Floats[1].bitcastToAPInt().getRawData()[0],
5278 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5279 "Unexpected Semantics");
5280 APFloat Tmp(APFloatBase::semPPCDoubleDoubleLegacy);
5293 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5294 "Unexpected Semantics");
5344 if (InLattice(HiOld, NextLo)) {
5346 Floats[1] = std::move(NextLo);
5383 if (!InLattice(NextHi, NextLo))
5387 Floats[0] = std::move(NextHi);
5388 Floats[1] = std::move(NextLo);
5396 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5397 "Unexpected Semantics");
5439 const unsigned PositiveOverflowWidth = IsSigned ? Width - 1 : Width;
5440 if (HiExactLog2 >= 0 &&
5441 static_cast<unsigned>(HiExactLog2) == PositiveOverflowWidth) {
5451 Input, Width,
true, RM, &LoIsExact);
5464 *IsExact = RoundStatus ==
opOK;
5476 APSInt LoResult{Width, !IsSigned};
5488 *IsExact = RoundStatus ==
opOK;
5494 unsigned int Width,
bool IsSigned,
5497 convertToSignExtendedInteger(
Input, Width, IsSigned, RM, IsExact);
5501 assert(DstPartsCount <=
Input.size() &&
"Integer too big");
5509 Bits = Width - IsSigned;
5554 if (SrcMSB == UINT_MAX) {
5561 const unsigned SrcBitWidth = SrcMSB + 1;
5577 return handleOverflow(RM);
5583 bool HiAsIntIsExact;
5600 if (
Error.isNegative()) {
5608 const unsigned ErrorActiveBits =
Error.getSignificantBits() - 1;
5610 if (ErrorActiveBits > LoPrecision) {
5611 const unsigned RoundingBoundary = ErrorActiveBits - LoPrecision;
5615 if (
Error.countTrailingZeros() == RoundingBoundary - 1)
5634 Floats[0] = std::move(
Hi);
5635 Floats[1] = std::move(
Lo);
5640 return handleOverflow(RM);
5646 Largest.makeLargest(
false);
5648 return handleOverflow(RM);
5660 const bool NegateInput = IsSigned &&
Input.isNegative();
5673 unsigned int HexDigits,
5676 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5677 "Unexpected Semantics");
5684 (Floats[0].isDenormal() || Floats[1].
isDenormal() ||
5686 Floats[0] != Floats[0] + Floats[1]);
5715 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5716 "Unexpected Semantics");
5717 return Floats[0].isInteger() && Floats[1].isInteger();
5721 unsigned FormatPrecision,
5722 unsigned FormatMaxPadding,
5723 bool TruncateZero)
const {
5724 assert(Semantics == &APFloatBase::semPPCDoubleDouble &&
5725 "Unexpected Semantics");
5727 .
toString(Str, FormatPrecision, FormatMaxPadding, TruncateZero);
5747 if (
Lo.isZero() ||
Hi.isNegative() ==
Lo.isNegative())
5749 if (
Hi.getExactLog2Abs() == INT_MIN)
5753 return IlogbResult - 1;
5759 "Unexpected Semantics");
5761 scalbn(Arg.Floats[0], Exp, RM),
5762 scalbn(Arg.Floats[1], Exp, RM));
5768 "Unexpected Semantics");
5778 Quiet.getFirst() =
Quiet.getFirst().makeQuiet();
5800 const bool SignsDisagree =
Hi.isNegative() !=
Lo.isNegative();
5817 LoRoundingMode = RM;
5818 Second =
scalbn(
Lo, -Exp, LoRoundingMode);
5826 if (RecomposedLo !=
Lo) {
5830 const APFloat RoundingError = RecomposedLo -
Lo;
5835 const APFloat ScaledUlpOfSecond =
5837 const bool IsMidpoint =
abs(RoundingError) == ScaledUlpOfSecond;
5838 const bool RoundedLoAway =
5843 if (IsMidpoint && RoundedLoAway)
5859 if (Second.
isZero() && SignsDisagree &&
Hi.getExactLog2Abs() != INT_MIN)
5870APFloat::Storage::Storage(IEEEFloat
F,
const fltSemantics &Semantics) {
5875 if (usesLayout<DoubleAPFloat>(
Semantics)) {
5876 const fltSemantics& S =
F.getSemantics();
5890 if (APFloat::usesLayout<detail::IEEEFloat>(Arg.
getSemantics()))
5892 if (APFloat::usesLayout<detail::DoubleAPFloat>(Arg.
getSemantics()))
5900 assert(StatusOrErr &&
"Invalid floating point representation");
5952 APFloat Reciprocal =
5970 *Inv = std::move(Reciprocal);
5982 usesLayout<IEEEFloat>(ToSemantics))
5983 return U.IEEE.convert(ToSemantics, RM, losesInfo);
5985 usesLayout<DoubleAPFloat>(ToSemantics)) {
5986 assert(&ToSemantics == &APFloatBase::semPPCDoubleDouble);
5988 U.IEEE.convert(APFloatBase::semPPCDoubleDoubleLegacy, RM, losesInfo);
5989 *
this =
APFloat(ToSemantics, U.IEEE.bitcastToAPInt());
5993 usesLayout<IEEEFloat>(ToSemantics)) {
5994 auto Ret = getIEEE().convert(ToSemantics, RM, losesInfo);
5995 *
this =
APFloat(std::move(getIEEE()), ToSemantics);
6011#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
6024 bool *isExact)
const {
6028 rounding_mode, isExact);
6030 result =
APInt(bitWidth, parts);
6037 return getIEEE().convertToDouble();
6039 "Float semantics is not representable by IEEEdouble");
6040 APFloat Temp = *
this;
6049#ifdef HAS_IEE754_FLOAT128
6050float128 APFloat::convertToQuad()
const {
6052 return getIEEE().convertToQuad();
6054 "Float semantics is not representable by IEEEquad");
6061 return Temp.getIEEE().convertToQuad();
6068 return getIEEE().convertToFloat();
6070 "Float semantics is not representable by IEEEsingle");
6071 APFloat Temp = *
this;
6080APFloat::Storage::~Storage() {
6081 if (usesLayout<IEEEFloat>(*semantics)) {
6085 if (usesLayout<DoubleAPFloat>(*semantics)) {
6092APFloat::Storage::Storage(
const APFloat::Storage &
RHS) {
6093 if (usesLayout<IEEEFloat>(*
RHS.semantics)) {
6097 if (usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
6104APFloat::Storage::Storage(APFloat::Storage &&
RHS) {
6105 if (usesLayout<IEEEFloat>(*
RHS.semantics)) {
6109 if (usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
6116APFloat::Storage &APFloat::Storage::operator=(
const APFloat::Storage &
RHS) {
6117 if (usesLayout<IEEEFloat>(*semantics) &&
6118 usesLayout<IEEEFloat>(*
RHS.semantics)) {
6120 }
else if (usesLayout<DoubleAPFloat>(*semantics) &&
6121 usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
6123 }
else if (
this != &
RHS) {
6125 new (
this) Storage(
RHS);
6130APFloat::Storage &APFloat::Storage::operator=(APFloat::Storage &&
RHS) {
6131 if (usesLayout<IEEEFloat>(*semantics) &&
6132 usesLayout<IEEEFloat>(*
RHS.semantics)) {
6134 }
else if (usesLayout<DoubleAPFloat>(*semantics) &&
6135 usesLayout<DoubleAPFloat>(*
RHS.semantics)) {
6137 }
else if (
this != &
RHS) {
6139 new (
this) Storage(std::move(
RHS));
6146#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.
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, const llvm::StringTable &StandardNames, VectorLibrary VecLib)
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 &)
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
static constexpr roundingMode rmTowardZero
static LLVM_ABI ExponentType semanticsMinExponent(const fltSemantics &)
llvm::RoundingMode roundingMode
IEEE-754R 4.3: Rounding-direction attributes.
static const fltSemantics & BFloat()
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 rmTowardNegative
static constexpr roundingMode rmNearestTiesToEven
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)
int32_t ExponentType
A signed type to represent a floating point numbers unbiased exponent.
static constexpr unsigned integerPartWidth
static const fltSemantics & PPCDoubleDoubleLegacy()
APInt::WordType integerPart
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 constexpr roundingMode rmTowardPositive
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 constexpr roundingMode rmNearestTiesToAway
static const fltSemantics & PPCDoubleDouble()
@ S_PPCDoubleDoubleLegacy
static const fltSemantics & Float6E3M2FN()
opStatus
IEEE-754R 7: Default exception handling.
static const fltSemantics & FloatTF32()
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
LLVM_ABI bool getExactInverse(APFloat *Inv) const
If this value is normal and has an exact, normal, multiplicative inverse, store it in inv and return ...
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(char 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 auto equal_to(T &&Arg)
Functor variant of std::equal_to that can be used as a UnaryPredicate in functional algorithms like a...
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