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))
320 if (Src.maxExponent >= Dst.maxExponent || Src.minExponent <= Dst.minExponent)
328 return Dst.precision >= Src.precision;
366static inline unsigned int
380 unsigned int absExponent;
381 const unsigned int overlargeExponent = 24000;
385 if (p == end || ((*p ==
'-' || *p ==
'+') && (p + 1) == end)) {
389 isNegative = (*p ==
'-');
390 if (*p ==
'-' || *p ==
'+') {
397 if (absExponent >= 10U)
398 return createError(
"Invalid character in exponent");
400 for (; p != end; ++p) {
405 return createError(
"Invalid character in exponent");
407 absExponent = absExponent * 10U +
value;
408 if (absExponent >= overlargeExponent) {
409 absExponent = overlargeExponent;
415 return -(int) absExponent;
417 return (
int) absExponent;
424 int exponentAdjustment) {
425 int unsignedExponent;
426 bool negative, overflow;
432 negative = *p ==
'-';
433 if (*p ==
'-' || *p ==
'+') {
439 unsignedExponent = 0;
441 for (; p != end; ++p) {
446 return createError(
"Invalid character in exponent");
448 unsignedExponent = unsignedExponent * 10 +
value;
449 if (unsignedExponent > 32767) {
455 if (exponentAdjustment > 32767 || exponentAdjustment < -32768)
459 exponent = unsignedExponent;
461 exponent = -exponent;
462 exponent += exponentAdjustment;
463 if (exponent > 32767 || exponent < -32768)
468 exponent = negative ? -32768: 32767;
478 while (p != end && *p ==
'0')
481 if (p != end && *p ==
'.') {
484 if (end - begin == 1)
487 while (p != end && *p ==
'0')
520 return PtrOrErr.takeError();
523 D->firstSigDigit = p;
525 D->normalizedExponent = 0;
527 for (; p != end; ++p) {
530 return createError(
"String contains multiple dots");
540 if (*p !=
'e' && *p !=
'E')
541 return createError(
"Invalid character in significand");
544 if (dot != end && p - begin == 1)
550 return ExpOrErr.takeError();
551 D->exponent = *ExpOrErr;
559 if (p !=
D->firstSigDigit) {
565 while (p != begin && *p ==
'0');
566 while (p != begin && *p ==
'.');
571 D->normalizedExponent = (
D->exponent +
573 - (dot >
D->firstSigDigit && dot < p)));
585 unsigned int digitValue) {
586 unsigned int hexDigit;
592 else if (digitValue < 8 && digitValue > 0)
596 while (p != end && (*p ==
'0' || *p ==
'.'))
600 return createError(
"Invalid trailing hexadecimal fraction!");
602 hexDigit = hexDigitValue(*p);
606 if (hexDigit == UINT_MAX)
616 unsigned int partCount,
645 return lost_fraction;
660 return moreSignificant;
671HUerrBound(
bool inexactMultiply,
unsigned int HUerr1,
unsigned int HUerr2)
673 assert(HUerr1 < 2 || HUerr2 < 2 || (HUerr1 + HUerr2 < 8));
675 if (HUerr1 + HUerr2 == 0)
676 return inexactMultiply * 2;
678 return inexactMultiply + 2 * (HUerr1 + HUerr2);
687 unsigned int count, partBits;
704 if (part - boundary <= boundary - part)
705 return part - boundary;
707 return boundary - part;
710 if (part == boundary) {
716 }
else if (part == boundary - 1) {
733 pow5s[0] = 78125 * 5;
735 unsigned int partsCount = 1;
743 *p1 = firstEightPowers[power & 7];
749 for (
unsigned int n = 0; power; power >>= 1, n++) {
753 partsCount, partsCount);
755 if (pow5[partsCount - 1] == 0)
763 result += partsCount;
764 if (p2[result - 1] == 0)
789static const char NaNL[] =
"nan";
790static const char NaNU[] =
"NAN";
797 const char *hexDigitChars)
799 unsigned int result =
count;
805 dst[
count] = hexDigitChars[part & 0xf];
845void IEEEFloat::initialize(
const fltSemantics *ourSemantics) {
848 semantics = ourSemantics;
854void IEEEFloat::freeSignificand() {
856 delete [] significand.parts;
859void IEEEFloat::assign(
const IEEEFloat &rhs) {
860 assert(semantics == rhs.semantics);
863 category = rhs.category;
864 exponent = rhs.exponent;
866 copySignificand(rhs);
869void IEEEFloat::copySignificand(
const IEEEFloat &rhs) {
871 assert(rhs.partCount() >= partCount());
883 exponent = exponentNaN();
886 unsigned numParts = partCount();
899 fill = &fill_storage;
910 unsigned bitsToPreserve = semantics->
precision - 1;
911 unsigned part = bitsToPreserve / 64;
912 bitsToPreserve %= 64;
913 significand[part] &= ((1ULL << bitsToPreserve) - 1);
914 for (part++; part != numParts; ++part)
915 significand[part] = 0;
918 unsigned QNaNBit = semantics->
precision - 2;
946 if (semantics != rhs.semantics) {
948 initialize(rhs.semantics);
959 semantics = rhs.semantics;
960 significand = rhs.significand;
961 exponent = rhs.exponent;
962 category = rhs.category;
980 significandMSB() == 0;
985 isSignificandAllZerosExceptMSB();
988bool IEEEFloat::isSignificandAllOnes()
const {
993 for (
unsigned i = 0; i < PartCount - 1; i++)
998 const unsigned NumHighBits =
1000 assert(NumHighBits <= integerPartWidth && NumHighBits > 0 &&
1001 "Can not have more high bits to fill than integerPartWidth");
1004 if (~(Parts[PartCount - 1] | HighBitFill))
1010bool IEEEFloat::isSignificandAllOnesExceptLSB()
const {
1019 for (
unsigned i = 0; i < PartCount - 1; i++) {
1020 if (~Parts[i] & ~
unsigned{!i})
1025 const unsigned NumHighBits =
1027 assert(NumHighBits <= integerPartWidth && NumHighBits > 0 &&
1028 "Can not have more high bits to fill than integerPartWidth");
1031 if (~(Parts[PartCount - 1] | HighBitFill | 0x1))
1037bool IEEEFloat::isSignificandAllZeros()
const {
1043 for (
unsigned i = 0; i < PartCount - 1; i++)
1048 const unsigned NumHighBits =
1051 "clear than integerPartWidth");
1052 const integerPart HighBitMask = ~integerPart(0) >> NumHighBits;
1054 if (Parts[PartCount - 1] & HighBitMask)
1060bool IEEEFloat::isSignificandAllZerosExceptMSB()
const {
1064 for (
unsigned i = 0; i < PartCount - 1; i++) {
1069 const unsigned NumHighBits =
1082 isSignificandAllOnesExceptLSB();
1087 isSignificandAllOnes();
1102 if (semantics != rhs.semantics ||
1103 category != rhs.category ||
1112 return std::equal(significandParts(), significandParts() + partCount(),
1113 rhs.significandParts());
1117 initialize(&ourSemantics);
1122 significandParts()[0] =
value;
1127 initialize(&ourSemantics);
1137 initialize(rhs.semantics);
1142 *
this = std::move(rhs);
1147unsigned int IEEEFloat::partCount()
const {
1152 return const_cast<IEEEFloat *
>(
this)->significandParts();
1156 if (partCount() > 1)
1157 return significand.parts;
1159 return &significand.part;
1162void IEEEFloat::zeroSignificand() {
1167void IEEEFloat::incrementSignificand() {
1181 parts = significandParts();
1183 assert(semantics == rhs.semantics);
1184 assert(exponent == rhs.exponent);
1186 return APInt::tcAdd(parts, rhs.significandParts(), 0, partCount());
1192 integerPart borrow) {
1195 parts = significandParts();
1197 assert(semantics == rhs.semantics);
1198 assert(exponent == rhs.exponent);
1207lostFraction IEEEFloat::multiplySignificand(
const IEEEFloat &rhs,
1210 unsigned int partsCount, newPartsCount, precision;
1217 assert(semantics == rhs.semantics);
1225 if (newPartsCount > 4)
1228 fullSignificand = scratch;
1230 lhsSignificand = significandParts();
1231 partsCount = partCount();
1234 rhs.significandParts(), partsCount, partsCount);
1237 omsb =
APInt::tcMSB(fullSignificand, newPartsCount) + 1;
1238 exponent += rhs.exponent;
1252 if (addend.isNonZero()) {
1256 Significand savedSignificand = significand;
1260 unsigned int extendedPrecision;
1263 extendedPrecision = 2 * precision + 1;
1264 if (omsb != extendedPrecision - 1) {
1265 assert(extendedPrecision > omsb);
1267 (extendedPrecision - 1) - omsb);
1268 exponent -= (extendedPrecision - 1) - omsb;
1272 extendedSemantics = *semantics;
1273 extendedSemantics.
precision = extendedPrecision;
1275 if (newPartsCount == 1)
1276 significand.part = fullSignificand[0];
1278 significand.parts = fullSignificand;
1279 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;
1339lostFraction IEEEFloat::multiplySignificand(
const IEEEFloat &rhs) {
1340 return multiplySignificand(rhs,
IEEEFloat(*semantics));
1344lostFraction IEEEFloat::divideSignificand(
const IEEEFloat &rhs) {
1345 unsigned int bit, i, partsCount;
1351 assert(semantics == rhs.semantics);
1353 lhsSignificand = significandParts();
1354 rhsSignificand = rhs.significandParts();
1355 partsCount = partCount();
1362 divisor = dividend + partsCount;
1365 for (i = 0; i < partsCount; i++) {
1366 dividend[i] = lhsSignificand[i];
1367 divisor[i] = rhsSignificand[i];
1368 lhsSignificand[i] = 0;
1371 exponent -= rhs.exponent;
1373 unsigned int precision = semantics->
precision;
1376 bit = precision -
APInt::tcMSB(divisor, partsCount) - 1;
1383 bit = precision -
APInt::tcMSB(dividend, partsCount) - 1;
1399 for (bit = precision; bit; bit -= 1) {
1423 return lost_fraction;
1426unsigned int IEEEFloat::significandMSB()
const {
1430unsigned int IEEEFloat::significandLSB()
const {
1435lostFraction IEEEFloat::shiftSignificandRight(
unsigned int bits) {
1441 return shiftRight(significandParts(), partCount(), bits);
1445void IEEEFloat::shiftSignificandLeft(
unsigned int bits) {
1446 assert(bits < semantics->precision);
1449 unsigned int partsCount = partCount();
1462 assert(semantics == rhs.semantics);
1466 compare = exponent - rhs.exponent;
1531bool IEEEFloat::roundAwayFromZero(roundingMode rounding_mode,
1533 unsigned int bit)
const {
1540 switch (rounding_mode) {
1578 omsb = significandMSB() + 1;
1584 exponentChange = omsb - semantics->
precision;
1588 if (exponent + exponentChange > semantics->
maxExponent)
1589 return handleOverflow(rounding_mode);
1593 if (exponent + exponentChange < semantics->minExponent)
1594 exponentChange = semantics->
minExponent - exponent;
1597 if (exponentChange < 0) {
1600 shiftSignificandLeft(-exponentChange);
1605 if (exponentChange > 0) {
1609 lf = shiftSignificandRight(exponentChange);
1614 if (omsb > (
unsigned) exponentChange)
1615 omsb -= exponentChange;
1625 exponent == semantics->
maxExponent && isSignificandAllOnes())
1626 return handleOverflow(rounding_mode);
1645 if (roundAwayFromZero(rounding_mode, lost_fraction, 0)) {
1649 incrementSignificand();
1650 omsb = significandMSB() + 1;
1653 if (omsb == (
unsigned) semantics->
precision + 1) {
1664 shiftSignificandRight(1);
1673 exponent == semantics->
maxExponent && isSignificandAllOnes())
1674 return handleOverflow(rounding_mode);
1683 assert(omsb < semantics->precision);
1753lostFraction IEEEFloat::addOrSubtractSignificand(
const IEEEFloat &rhs,
1761 subtract ^=
static_cast<bool>(sign ^ rhs.sign);
1764 bits = exponent - rhs.exponent;
1772 else if (bits > 0) {
1773 lost_fraction = temp_rhs.shiftSignificandRight(bits - 1);
1774 shiftSignificandLeft(1);
1776 lost_fraction = shiftSignificandRight(-bits - 1);
1777 temp_rhs.shiftSignificandLeft(1);
1782 carry = temp_rhs.subtractSignificand
1784 copySignificand(temp_rhs);
1787 carry = subtractSignificand
1806 lost_fraction = temp_rhs.shiftSignificandRight(bits);
1807 carry = addSignificand(temp_rhs);
1809 lost_fraction = shiftSignificandRight(-bits);
1810 carry = addSignificand(rhs);
1818 return lost_fraction;
2003 roundingMode rounding_mode,
2007 fs = addOrSubtractSpecials(rhs,
subtract);
2013 lost_fraction = addOrSubtractSignificand(rhs,
subtract);
2014 fs = normalize(rounding_mode, lost_fraction);
2023 if (category ==
fcZero) {
2037 return addOrSubtract(rhs, rounding_mode,
false);
2043 return addOrSubtract(rhs, rounding_mode,
true);
2052 fs = multiplySpecials(rhs);
2058 fs = normalize(rounding_mode, lost_fraction);
2072 fs = divideSpecials(rhs);
2078 fs = normalize(rounding_mode, lost_fraction);
2089 unsigned int origSign = sign;
2092 fs = remainderSpecials(rhs);
2199 fs = modSpecials(rhs);
2200 unsigned int origSign = sign;
2230 sign ^= multiplicand.sign;
2239 lost_fraction = multiplySignificand(multiplicand, addend);
2240 fs = normalize(rounding_mode, lost_fraction);
2253 fs = multiplySpecials(multiplicand);
2263 fs = addOrSubtract(addend, rounding_mode,
false);
2336 MagicConstant.sign = sign;
2342 fs =
add(MagicConstant, rounding_mode);
2346 subtract(MagicConstant, rounding_mode);
2360 assert(semantics == rhs.semantics);
2392 if (sign == rhs.sign)
2407 if (sign != rhs.sign) {
2438 unsigned int newPartCount, oldPartCount;
2446 oldPartCount = partCount();
2449 bool X86SpecialNan =
false;
2452 (!(*significandParts() & 0x8000000000000000ULL) ||
2453 !(*significandParts() & 0x4000000000000000ULL))) {
2456 X86SpecialNan =
true;
2467 int omsb = significandMSB() + 1;
2468 int exponentChange = omsb - fromSemantics.
precision;
2469 if (exponent + exponentChange < toSemantics.
minExponent)
2470 exponentChange = toSemantics.
minExponent - exponent;
2471 if (exponentChange < shift)
2472 exponentChange = shift;
2473 if (exponentChange < 0) {
2474 shift -= exponentChange;
2475 exponent += exponentChange;
2476 }
else if (omsb <= -shift) {
2477 exponentChange = omsb + shift - 1;
2478 shift -= exponentChange;
2479 exponent += exponentChange;
2490 if (newPartCount > oldPartCount) {
2498 significand.parts = newParts;
2499 }
else if (newPartCount == 1 && oldPartCount != 1) {
2503 newPart = significandParts()[0];
2505 significand.part = newPart;
2509 semantics = &toSemantics;
2518 *losesInfo = (fs !=
opOK);
2519 }
else if (category ==
fcNaN) {
2554 }
else if (category ==
fcZero &&
2582 roundingMode rounding_mode,
bool *isExact)
const {
2585 unsigned int dstPartsCount, truncatedBits;
2594 assert(dstPartsCount <= parts.
size() &&
"Integer too big");
2596 if (category ==
fcZero) {
2603 src = significandParts();
2612 truncatedBits = semantics->
precision -1U - exponent;
2616 unsigned int bits = exponent + 1U;
2622 if (bits < semantics->precision) {
2624 truncatedBits = semantics->
precision - bits;
2638 if (truncatedBits) {
2642 roundAwayFromZero(rounding_mode, lost_fraction, truncatedBits)) {
2662 if (omsb == width &&
2699 fs = convertToSignExtendedInteger(parts, width,
isSigned, rounding_mode,
2703 unsigned int bits, dstPartsCount;
2706 assert(dstPartsCount <= parts.
size() &&
"Integer too big");
2708 if (category ==
fcNaN)
2727 const integerPart *src,
unsigned int srcCount, roundingMode rounding_mode) {
2728 unsigned int omsb, precision, dstCount;
2734 dst = significandParts();
2735 dstCount = partCount();
2740 if (precision <= omsb) {
2741 exponent = omsb - 1;
2746 exponent = precision - 1;
2751 return normalize(rounding_mode, lost_fraction);
2765 return convertFromUnsignedParts(api.
getRawData(), partCount, rounding_mode);
2773 unsigned int srcCount,
bool isSigned,
2786 status = convertFromUnsignedParts(
copy, srcCount, rounding_mode);
2790 status = convertFromUnsignedParts(src, srcCount, rounding_mode);
2810 return convertFromUnsignedParts(api.
getRawData(), partCount, rounding_mode);
2814IEEEFloat::convertFromHexadecimalString(
StringRef s,
2815 roundingMode rounding_mode) {
2823 unsigned partsCount = partCount();
2825 bool computedTrailingFraction =
false;
2833 return PtrOrErr.takeError();
2842 return createError(
"String contains multiple dots");
2847 hex_value = hexDigitValue(*p);
2848 if (hex_value == UINT_MAX)
2858 }
else if (!computedTrailingFraction) {
2861 return FractOrErr.takeError();
2862 lost_fraction = *FractOrErr;
2863 computedTrailingFraction =
true;
2869 return createError(
"Hex strings require an exponent");
2870 if (*p !=
'p' && *p !=
'P')
2871 return createError(
"Invalid character in significand");
2874 if (dot != end && p - begin == 1)
2878 if (p != firstSignificantDigit) {
2887 expAdjustment =
static_cast<int>(
dot - firstSignificantDigit);
2888 if (expAdjustment < 0)
2890 expAdjustment = expAdjustment * 4 - 1;
2900 return ExpOrErr.takeError();
2901 exponent = *ExpOrErr;
2904 return normalize(rounding_mode, lost_fraction);
2908IEEEFloat::roundSignificandWithExponent(
const integerPart *decSigParts,
2909 unsigned sigPartCount,
int exp,
2910 roundingMode rounding_mode) {
2911 unsigned int parts, pow5PartCount;
2922 pow5PartCount =
powerOf5(pow5Parts, exp >= 0 ? exp: -exp);
2924 for (;; parts *= 2) {
2926 unsigned int excessPrecision, truncatedBits;
2930 truncatedBits = excessPrecision;
2933 decSig.makeZero(sign);
2936 sigStatus = decSig.convertFromUnsignedParts(decSigParts, sigPartCount,
2938 powStatus = pow5.convertFromUnsignedParts(pow5Parts, pow5PartCount,
2941 decSig.exponent += exp;
2945 unsigned int powHUerr;
2949 calcLostFraction = decSig.multiplySignificand(pow5);
2950 powHUerr = powStatus !=
opOK;
2952 calcLostFraction = decSig.divideSignificand(pow5);
2955 excessPrecision += (semantics->
minExponent - decSig.exponent);
2956 truncatedBits = excessPrecision;
2957 if (excessPrecision > calcSemantics.
precision)
2958 excessPrecision = calcSemantics.
precision;
2967 (decSig.significandParts(), calcSemantics.
precision - 1) == 1);
2972 excessPrecision, isNearest);
2975 if (HUdistance >= HUerr) {
2976 APInt::tcExtract(significandParts(), partCount(), decSig.significandParts(),
2977 calcSemantics.
precision - excessPrecision,
2982 exponent = (decSig.exponent + semantics->
precision
2983 - (calcSemantics.
precision - excessPrecision));
2987 return normalize(rounding_mode, calcLostFraction);
2993IEEEFloat::convertFromDecimalString(
StringRef str, roundingMode rounding_mode) {
3000 return std::move(Err);
3034 }
else if (
D.normalizedExponent - 1 > INT_MAX / 42039) {
3035 fs = handleOverflow(rounding_mode);
3041 }
else if (
D.normalizedExponent - 1 < INT_MIN / 42039 ||
3042 (
D.normalizedExponent + 1) * 28738 <=
3050 }
else if ((
D.normalizedExponent - 1) * 42039
3053 fs = handleOverflow(rounding_mode);
3056 unsigned int partCount;
3062 partCount =
static_cast<unsigned int>(
D.lastSigDigit -
D.firstSigDigit) + 1;
3080 if (p == str.
end()) {
3085 if (decValue >= 10U) {
3086 delete[] decSignificand;
3087 return createError(
"Invalid character in significand");
3090 val = val * 10 + decValue;
3093 }
while (p <=
D.lastSigDigit && multiplier <= (~ (
integerPart) 0 - 9) / 10);
3097 partCount, partCount + 1,
false);
3101 if (decSignificand[partCount])
3103 }
while (p <=
D.lastSigDigit);
3106 fs = roundSignificandWithExponent(decSignificand, partCount,
3107 D.exponent, rounding_mode);
3109 delete [] decSignificand;
3115bool IEEEFloat::convertFromStringSpecials(
StringRef str) {
3116 const size_t MIN_NAME_SIZE = 3;
3118 if (str.
size() < MIN_NAME_SIZE)
3121 if (str ==
"inf" || str ==
"INFINITY" || str ==
"+Inf") {
3126 bool IsNegative = str.
front() ==
'-';
3129 if (str.
size() < MIN_NAME_SIZE)
3132 if (str ==
"inf" || str ==
"INFINITY" || str ==
"Inf") {
3139 bool IsSignaling = str.
front() ==
's' || str.
front() ==
'S';
3142 if (str.
size() < MIN_NAME_SIZE)
3151 makeNaN(IsSignaling, IsNegative);
3156 if (str.
front() ==
'(') {
3158 if (str.
size() <= 2 || str.
back() !=
')')
3165 unsigned Radix = 10;
3166 if (str[0] ==
'0') {
3167 if (str.
size() > 1 && tolower(str[1]) ==
'x') {
3177 makeNaN(IsSignaling, IsNegative, &Payload);
3191 if (convertFromStringSpecials(str))
3196 size_t slen = str.
size();
3197 sign = *p ==
'-' ? 1 : 0;
3198 if (*p ==
'-' || *p ==
'+') {
3205 if (slen >= 2 && p[0] ==
'0' && (p[1] ==
'x' || p[1] ==
'X')) {
3208 return convertFromHexadecimalString(
StringRef(p + 2, slen - 2),
3212 return convertFromDecimalString(
StringRef(p, slen), rounding_mode);
3256 dst +=
sizeof NaNU - 1;
3261 *dst++ = upperCase ?
'X':
'x';
3263 if (hexDigits > 1) {
3265 memset (dst,
'0', hexDigits - 1);
3266 dst += hexDigits - 1;
3268 *dst++ = upperCase ?
'P':
'p';
3273 dst = convertNormalToHexString (dst, hexDigits, upperCase, rounding_mode);
3279 return static_cast<unsigned int>(dst - p);
3286char *IEEEFloat::convertNormalToHexString(
char *dst,
unsigned int hexDigits,
3288 roundingMode rounding_mode)
const {
3289 unsigned int count, valueBits, shift, partsCount, outputDigits;
3290 const char *hexDigitChars;
3296 *dst++ = upperCase ?
'X':
'x';
3301 significand = significandParts();
3302 partsCount = partCount();
3311 outputDigits = (valueBits - significandLSB () + 3) / 4;
3317 if (hexDigits < outputDigits) {
3323 bits = valueBits - hexDigits * 4;
3325 roundUp = roundAwayFromZero(rounding_mode, fraction, bits);
3327 outputDigits = hexDigits;
3337 while (outputDigits &&
count) {
3341 if (--
count == partsCount)
3344 part = significand[
count] << shift;
3352 if (curDigits > outputDigits)
3353 curDigits = outputDigits;
3354 dst +=
partAsHex (dst, part, curDigits, hexDigitChars);
3355 outputDigits -= curDigits;
3364 *
q = hexDigitChars[hexDigitValue (*q) + 1];
3365 }
while (*q ==
'0');
3369 memset (dst,
'0', outputDigits);
3370 dst += outputDigits;
3383 *dst++ = upperCase ?
'P':
'p';
3392 Arg.
isNaN() ? (uint8_t)0 : (uint8_t)Arg.sign,
3396 return hash_combine((uint8_t)Arg.category, (uint8_t)Arg.sign,
3399 Arg.significandParts(),
3400 Arg.significandParts() + Arg.partCount()));
3412APInt IEEEFloat::convertF80LongDoubleAPFloatToAPInt()
const {
3416 uint64_t myexponent, mysignificand;
3419 myexponent = exponent+16383;
3420 mysignificand = significandParts()[0];
3421 if (myexponent==1 && !(mysignificand & 0x8000000000000000ULL))
3423 }
else if (category==
fcZero) {
3427 myexponent = 0x7fff;
3428 mysignificand = 0x8000000000000000ULL;
3431 myexponent = 0x7fff;
3432 mysignificand = significandParts()[0];
3436 words[0] = mysignificand;
3437 words[1] = ((
uint64_t)(sign & 1) << 15) |
3438 (myexponent & 0x7fffLL);
3439 return APInt(80, words);
3442APInt IEEEFloat::convertPPCDoubleDoubleAPFloatToAPInt()
const {
3467 words[0] = *
u.convertDoubleAPFloatToAPInt().getRawData();
3473 if (
u.isFiniteNonZero() && losesInfo) {
3483 words[1] = *
v.convertDoubleAPFloatToAPInt().getRawData();
3488 return APInt(128, words);
3491template <const fltSemantics &S>
3492APInt IEEEFloat::convertIEEEFloatToAPInt()
const {
3495 constexpr int bias = -(S.minExponent - 1);
3496 constexpr unsigned int trailing_significand_bits = S.precision - 1;
3497 constexpr int integer_bit_part = trailing_significand_bits /
integerPartWidth;
3500 constexpr uint64_t significand_mask = integer_bit - 1;
3501 constexpr unsigned int exponent_bits =
3502 S.sizeInBits - 1 - trailing_significand_bits;
3503 static_assert(exponent_bits < 64);
3511 myexponent = exponent + bias;
3512 std::copy_n(significandParts(), mysignificand.size(),
3513 mysignificand.begin());
3514 if (myexponent == 1 &&
3515 !(significandParts()[integer_bit_part] & integer_bit))
3517 }
else if (category ==
fcZero) {
3518 myexponent = ::exponentZero(S) + bias;
3519 mysignificand.fill(0);
3524 myexponent = ::exponentInf(S) + bias;
3525 mysignificand.fill(0);
3528 myexponent = ::exponentNaN(S) + bias;
3529 std::copy_n(significandParts(), mysignificand.size(),
3530 mysignificand.begin());
3532 std::array<
uint64_t, (S.sizeInBits + 63) / 64> words;
3534 std::copy_n(mysignificand.begin(), mysignificand.size(), words.begin());
3535 if constexpr (significand_mask != 0) {
3537 words[mysignificand.size() - 1] &= significand_mask;
3539 std::fill(words_iter, words.end(),
uint64_t{0});
3540 constexpr size_t last_word = words.size() - 1;
3542 << ((S.sizeInBits - 1) % 64);
3543 words[last_word] |= shifted_sign;
3544 uint64_t shifted_exponent = (myexponent & exponent_mask)
3545 << (trailing_significand_bits % 64);
3546 words[last_word] |= shifted_exponent;
3547 if constexpr (last_word == 0) {
3548 return APInt(S.sizeInBits, words[0]);
3550 return APInt(S.sizeInBits, words);
3553APInt IEEEFloat::convertQuadrupleAPFloatToAPInt()
const {
3554 assert(partCount() == 2);
3555 return convertIEEEFloatToAPInt<semIEEEquad>();
3558APInt IEEEFloat::convertDoubleAPFloatToAPInt()
const {
3560 return convertIEEEFloatToAPInt<semIEEEdouble>();
3563APInt IEEEFloat::convertFloatAPFloatToAPInt()
const {
3565 return convertIEEEFloatToAPInt<semIEEEsingle>();
3568APInt IEEEFloat::convertBFloatAPFloatToAPInt()
const {
3569 assert(partCount() == 1);
3570 return convertIEEEFloatToAPInt<semBFloat>();
3573APInt IEEEFloat::convertHalfAPFloatToAPInt()
const {
3575 return convertIEEEFloatToAPInt<semIEEEhalf>();
3578APInt IEEEFloat::convertFloat8E5M2APFloatToAPInt()
const {
3579 assert(partCount() == 1);
3580 return convertIEEEFloatToAPInt<semFloat8E5M2>();
3583APInt IEEEFloat::convertFloat8E5M2FNUZAPFloatToAPInt()
const {
3584 assert(partCount() == 1);
3585 return convertIEEEFloatToAPInt<semFloat8E5M2FNUZ>();
3588APInt IEEEFloat::convertFloat8E4M3FNAPFloatToAPInt()
const {
3589 assert(partCount() == 1);
3590 return convertIEEEFloatToAPInt<semFloat8E4M3FN>();
3593APInt IEEEFloat::convertFloat8E4M3FNUZAPFloatToAPInt()
const {
3594 assert(partCount() == 1);
3595 return convertIEEEFloatToAPInt<semFloat8E4M3FNUZ>();
3598APInt IEEEFloat::convertFloat8E4M3B11FNUZAPFloatToAPInt()
const {
3599 assert(partCount() == 1);
3600 return convertIEEEFloatToAPInt<semFloat8E4M3B11FNUZ>();
3603APInt IEEEFloat::convertFloatTF32APFloatToAPInt()
const {
3604 assert(partCount() == 1);
3605 return convertIEEEFloatToAPInt<semFloatTF32>();
3614 return convertHalfAPFloatToAPInt();
3617 return convertBFloatAPFloatToAPInt();
3620 return convertFloatAPFloatToAPInt();
3623 return convertDoubleAPFloatToAPInt();
3626 return convertQuadrupleAPFloatToAPInt();
3629 return convertPPCDoubleDoubleAPFloatToAPInt();
3632 return convertFloat8E5M2APFloatToAPInt();
3635 return convertFloat8E5M2FNUZAPFloatToAPInt();
3638 return convertFloat8E4M3FNAPFloatToAPInt();
3641 return convertFloat8E4M3FNUZAPFloatToAPInt();
3644 return convertFloat8E4M3B11FNUZAPFloatToAPInt();
3647 return convertFloatTF32APFloatToAPInt();
3651 return convertF80LongDoubleAPFloatToAPInt();
3656 "Float semantics are not IEEEsingle");
3663 "Float semantics are not IEEEdouble");
3675void IEEEFloat::initFromF80LongDoubleAPInt(
const APInt &api) {
3678 uint64_t myexponent = (i2 & 0x7fff);
3680 uint8_t myintegerbit = mysignificand >> 63;
3685 sign =
static_cast<unsigned int>(i2>>15);
3686 if (myexponent == 0 && mysignificand == 0) {
3688 }
else if (myexponent==0x7fff && mysignificand==0x8000000000000000ULL) {
3690 }
else if ((myexponent == 0x7fff && mysignificand != 0x8000000000000000ULL) ||
3691 (myexponent != 0x7fff && myexponent != 0 && myintegerbit == 0)) {
3693 exponent = exponentNaN();
3694 significandParts()[0] = mysignificand;
3695 significandParts()[1] = 0;
3698 exponent = myexponent - 16383;
3699 significandParts()[0] = mysignificand;
3700 significandParts()[1] = 0;
3706void IEEEFloat::initFromPPCDoubleDoubleAPInt(
const APInt &api) {
3713 initFromDoubleAPInt(
APInt(64, i1));
3729template <const fltSemantics &S>
3730void IEEEFloat::initFromIEEEAPInt(
const APInt &api) {
3734 constexpr uint64_t significand_mask = integer_bit - 1;
3735 constexpr unsigned int trailing_significand_bits = S.precision - 1;
3736 constexpr unsigned int stored_significand_parts =
3738 constexpr unsigned int exponent_bits =
3739 S.sizeInBits - 1 - trailing_significand_bits;
3740 static_assert(exponent_bits < 64);
3742 constexpr int bias = -(S.minExponent - 1);
3746 std::array<integerPart, stored_significand_parts> mysignificand;
3747 std::copy_n(api.
getRawData(), mysignificand.size(), mysignificand.begin());
3748 if constexpr (significand_mask != 0) {
3749 mysignificand[mysignificand.size() - 1] &= significand_mask;
3756 (last_word >> (trailing_significand_bits % 64)) & exponent_mask;
3759 assert(partCount() == mysignificand.size());
3761 sign =
static_cast<unsigned int>(last_word >> ((S.sizeInBits - 1) % 64));
3763 bool all_zero_significand =
3766 bool is_zero = myexponent == 0 && all_zero_significand;
3769 if (myexponent - bias == ::exponentInf(S) && all_zero_significand) {
3778 is_nan = myexponent - bias == ::exponentNaN(S) && !all_zero_significand;
3780 bool all_ones_significand =
3781 std::all_of(mysignificand.begin(), mysignificand.end() - 1,
3782 [](
integerPart bits) { return bits == ~integerPart{0}; }) &&
3783 (!significand_mask ||
3784 mysignificand[mysignificand.size() - 1] == significand_mask);
3785 is_nan = myexponent - bias == ::exponentNaN(S) && all_ones_significand;
3793 std::copy_n(mysignificand.begin(), mysignificand.size(),
3794 significandParts());
3804 exponent = myexponent - bias;
3805 std::copy_n(mysignificand.begin(), mysignificand.size(), significandParts());
3806 if (myexponent == 0)
3807 exponent = S.minExponent;
3809 significandParts()[mysignificand.size()-1] |= integer_bit;
3812void IEEEFloat::initFromQuadrupleAPInt(
const APInt &api) {
3813 initFromIEEEAPInt<semIEEEquad>(api);
3816void IEEEFloat::initFromDoubleAPInt(
const APInt &api) {
3817 initFromIEEEAPInt<semIEEEdouble>(api);
3820void IEEEFloat::initFromFloatAPInt(
const APInt &api) {
3821 initFromIEEEAPInt<semIEEEsingle>(api);
3824void IEEEFloat::initFromBFloatAPInt(
const APInt &api) {
3825 initFromIEEEAPInt<semBFloat>(api);
3828void IEEEFloat::initFromHalfAPInt(
const APInt &api) {
3829 initFromIEEEAPInt<semIEEEhalf>(api);
3832void IEEEFloat::initFromFloat8E5M2APInt(
const APInt &api) {
3833 initFromIEEEAPInt<semFloat8E5M2>(api);
3836void IEEEFloat::initFromFloat8E5M2FNUZAPInt(
const APInt &api) {
3837 initFromIEEEAPInt<semFloat8E5M2FNUZ>(api);
3840void IEEEFloat::initFromFloat8E4M3FNAPInt(
const APInt &api) {
3841 initFromIEEEAPInt<semFloat8E4M3FN>(api);
3844void IEEEFloat::initFromFloat8E4M3FNUZAPInt(
const APInt &api) {
3845 initFromIEEEAPInt<semFloat8E4M3FNUZ>(api);
3848void IEEEFloat::initFromFloat8E4M3B11FNUZAPInt(
const APInt &api) {
3849 initFromIEEEAPInt<semFloat8E4M3B11FNUZ>(api);
3852void IEEEFloat::initFromFloatTF32APInt(
const APInt &api) {
3853 initFromIEEEAPInt<semFloatTF32>(api);
3860 return initFromHalfAPInt(api);
3862 return initFromBFloatAPInt(api);
3864 return initFromFloatAPInt(api);
3866 return initFromDoubleAPInt(api);
3868 return initFromF80LongDoubleAPInt(api);
3870 return initFromQuadrupleAPInt(api);
3872 return initFromPPCDoubleDoubleAPInt(api);
3874 return initFromFloat8E5M2APInt(api);
3876 return initFromFloat8E5M2FNUZAPInt(api);
3878 return initFromFloat8E4M3FNAPInt(api);
3880 return initFromFloat8E4M3FNUZAPInt(api);
3882 return initFromFloat8E4M3B11FNUZAPInt(api);
3884 return initFromFloatTF32APInt(api);
3891void IEEEFloat::makeLargest(
bool Negative) {
3898 exponent = semantics->maxExponent;
3902 unsigned PartCount = partCount();
3903 memset(significand, 0xFF,
sizeof(
integerPart)*(PartCount - 1));
3907 const unsigned NumUnusedHighBits =
3908 PartCount*integerPartWidth - semantics->precision;
3909 significand[PartCount - 1] = (NumUnusedHighBits < integerPartWidth)
3920void IEEEFloat::makeSmallest(
bool Negative) {
3927 exponent = semantics->minExponent;
3931void IEEEFloat::makeSmallestNormalized(
bool Negative) {
3940 exponent = semantics->minExponent;
3945 initFromAPInt(&Sem, API);
3948IEEEFloat::IEEEFloat(
float f) {
3952IEEEFloat::IEEEFloat(
double d) {
3958 Buffer.
append(Str.begin(), Str.end());
3963 void AdjustToPrecision(
APInt &significand,
3964 int &exp,
unsigned FormatPrecision) {
3968 unsigned bitsRequired = (FormatPrecision * 196 + 58) / 59;
3970 if (bits <= bitsRequired)
return;
3972 unsigned tensRemovable = (bits - bitsRequired) * 59 / 196;
3973 if (!tensRemovable)
return;
3975 exp += tensRemovable;
3980 if (tensRemovable & 1)
3982 tensRemovable >>= 1;
3983 if (!tensRemovable)
break;
3987 significand = significand.
udiv(divisor);
3995 int &exp,
unsigned FormatPrecision) {
3996 unsigned N = buffer.
size();
3997 if (
N <= FormatPrecision)
return;
4000 unsigned FirstSignificant =
N - FormatPrecision;
4007 if (buffer[FirstSignificant - 1] <
'5') {
4008 while (FirstSignificant <
N && buffer[FirstSignificant] ==
'0')
4011 exp += FirstSignificant;
4012 buffer.
erase(&buffer[0], &buffer[FirstSignificant]);
4018 for (
unsigned I = FirstSignificant;
I !=
N; ++
I) {
4019 if (buffer[
I] ==
'9') {
4028 if (FirstSignificant ==
N) {
4029 exp += FirstSignificant;
4035 exp += FirstSignificant;
4036 buffer.
erase(&buffer[0], &buffer[FirstSignificant]);
4041 unsigned FormatMaxPadding,
bool TruncateZero)
const {
4045 return append(Str,
"-Inf");
4047 return append(Str,
"+Inf");
4049 case fcNaN:
return append(Str,
"NaN");
4055 if (!FormatMaxPadding) {
4057 append(Str,
"0.0E+0");
4060 if (FormatPrecision > 1)
4061 Str.append(FormatPrecision - 1,
'0');
4062 append(Str,
"e+00");
4076 int exp = exponent - ((int) semantics->precision - 1);
4078 semantics->precision,
4083 if (!FormatPrecision) {
4091 FormatPrecision = 2 + semantics->precision * 59 / 196;
4096 exp += trailingZeros;
4102 }
else if (exp > 0) {
4104 significand = significand.
zext(semantics->precision + exp);
4105 significand <<= exp;
4119 unsigned precision = semantics->precision + (137 * texp + 136) / 59;
4123 significand = significand.
zext(precision);
4124 APInt five_to_the_i(precision, 5);
4126 if (texp & 1) significand *= five_to_the_i;
4130 five_to_the_i *= five_to_the_i;
4134 AdjustToPrecision(significand, exp, FormatPrecision);
4140 if (precision < 4) {
4143 significand = significand.
zext(precision);
4145 APInt ten(precision, 10);
4146 APInt digit(precision, 0);
4148 bool inTrail =
true;
4149 while (significand != 0) {
4157 if (inTrail && !d) exp++;
4164 assert(!buffer.
empty() &&
"no characters in buffer!");
4168 AdjustToPrecision(buffer, exp, FormatPrecision);
4170 unsigned NDigits = buffer.
size();
4173 bool FormatScientific;
4174 if (!FormatMaxPadding)
4175 FormatScientific =
true;
4181 FormatScientific = ((
unsigned) exp > FormatMaxPadding ||
4182 NDigits + (
unsigned) exp > FormatPrecision);
4185 int MSD = exp + (int) (NDigits - 1);
4188 FormatScientific =
false;
4192 FormatScientific = ((
unsigned) -MSD) > FormatMaxPadding;
4198 if (FormatScientific) {
4199 exp += (NDigits - 1);
4201 Str.push_back(buffer[NDigits-1]);
4203 if (NDigits == 1 && TruncateZero)
4206 for (
unsigned I = 1;
I != NDigits; ++
I)
4207 Str.push_back(buffer[NDigits-1-
I]);
4209 if (!TruncateZero && FormatPrecision > NDigits - 1)
4210 Str.append(FormatPrecision - NDigits + 1,
'0');
4212 Str.push_back(TruncateZero ?
'E' :
'e');
4214 Str.push_back(exp >= 0 ?
'+' :
'-');
4215 if (exp < 0) exp = -exp;
4218 expbuf.
push_back((
char) (
'0' + (exp % 10)));
4222 if (!TruncateZero && expbuf.
size() < 2)
4224 for (
unsigned I = 0, E = expbuf.
size();
I != E; ++
I)
4225 Str.push_back(expbuf[E-1-
I]);
4231 for (
unsigned I = 0;
I != NDigits; ++
I)
4232 Str.push_back(buffer[NDigits-1-
I]);
4241 int NWholeDigits = exp + (int) NDigits;
4244 if (NWholeDigits > 0) {
4246 Str.push_back(buffer[NDigits-
I-1]);
4249 unsigned NZeros = 1 + (
unsigned) -NWholeDigits;
4253 for (
unsigned Z = 1; Z != NZeros; ++Z)
4257 for (;
I != NDigits; ++
I)
4258 Str.push_back(buffer[NDigits-
I-1]);
4261bool IEEEFloat::getExactInverse(
APFloat *inv)
const {
4263 if (!isFiniteNonZero())
4268 if (significandLSB() != semantics->precision - 1)
4273 if (reciprocal.
divide(*
this, rmNearestTiesToEven) != opOK)
4282 reciprocal.significandLSB() == reciprocal.semantics->
precision - 1);
4285 *inv =
APFloat(reciprocal, *semantics);
4290int IEEEFloat::getExactLog2Abs()
const {
4298 for (
int i = 0; i < PartCount; ++i) {
4304 if (exponent != semantics->minExponent)
4307 int CountrParts = 0;
4308 for (
int i = 0; i < PartCount;
4310 if (Parts[i] != 0) {
4311 return exponent - semantics->precision + CountrParts +
4319bool IEEEFloat::isSignaling()
const {
4355 if (isSignaling()) {
4356 result = opInvalidOp;
4358 makeNaN(
false, isNegative(),
nullptr);
4363 makeSmallest(
false);
4367 if (isSmallest() && isNegative()) {
4376 if (isLargest() && !isNegative()) {
4384 category = fcInfinity;
4385 exponent = semantics->maxExponent + 1;
4399 bool WillCrossBinadeBoundary =
4400 exponent != semantics->minExponent && isSignificandAllZeros();
4418 if (WillCrossBinadeBoundary) {
4434 bool WillCrossBinadeBoundary = !isDenormal() && isSignificandAllOnes();
4436 if (WillCrossBinadeBoundary) {
4440 assert(exponent != semantics->maxExponent &&
4441 "We can not increment an exponent beyond the maxExponent allowed"
4442 " by the given floating point semantics.");
4445 incrementSignificand();
4459 return ::exponentNaN(*semantics);
4463 return ::exponentInf(*semantics);
4467 return ::exponentZero(*semantics);
4470void IEEEFloat::makeInf(
bool Negative) {
4473 makeNaN(
false, Negative);
4476 category = fcInfinity;
4482void IEEEFloat::makeZero(
bool Negative) {
4493void IEEEFloat::makeQuiet() {
4501 return IEEEFloat::IEK_NaN;
4503 return IEEEFloat::IEK_Zero;
4505 return IEEEFloat::IEK_Inf;
4507 return Arg.exponent;
4512 Normalized.exponent += SignificandBits;
4513 Normalized.normalize(IEEEFloat::rmNearestTiesToEven,
lfExactlyZero);
4514 return Normalized.exponent - SignificandBits;
4518 auto MaxExp =
X.getSemantics().maxExponent;
4519 auto MinExp =
X.getSemantics().minExponent;
4527 int SignificandBits =
X.getSemantics().precision - 1;
4528 int MaxIncrement = MaxExp - (MinExp - SignificandBits) + 1;
4531 X.exponent += std::clamp(Exp, -MaxIncrement - 1, MaxIncrement);
4542 if (Exp == IEEEFloat::IEK_NaN) {
4548 if (Exp == IEEEFloat::IEK_Inf)
4553 Exp = Exp == IEEEFloat::IEK_Zero ? 0 : Exp + 1;
4554 return scalbn(Val, -Exp, RM);
4587 Floats(new
APFloat[2]{std::move(
First), std::move(Second)}) {
4609 Floats[0] =
RHS.Floats[0];
4610 Floats[1] =
RHS.Floats[1];
4611 }
else if (
this != &
RHS) {
4629 Floats[0] = std::move(z);
4630 Floats[1].makeZero(
false);
4634 auto AComparedToC = a.compareAbsoluteValue(c);
4647 Floats[0] = std::move(z);
4648 Floats[1].makeZero(
false);
4657 Status |= Floats[1].subtract(z, RM);
4658 Status |= Floats[1].add(c, RM);
4659 Status |= Floats[1].add(zz, RM);
4663 Status |= Floats[1].subtract(z, RM);
4664 Status |= Floats[1].add(a, RM);
4665 Status |= Floats[1].add(zz, RM);
4683 Floats[0] = std::move(z);
4684 Floats[1].makeZero(
false);
4688 Status |= Floats[0].add(zz, RM);
4690 Floats[1].makeZero(
false);
4693 Floats[1] = std::move(z);
4694 Status |= Floats[1].subtract(Floats[0], RM);
4695 Status |= Floats[1].add(zz, RM);
4701 const DoubleAPFloat &RHS,
4721 LHS.isNegative() !=
RHS.isNegative()) {
4722 Out.makeNaN(
false, Out.isNegative(),
nullptr);
4743 return Out.addImpl(
A, AA,
C,
CC, RM);
4748 return addWithSpecial(*
this,
RHS, *
this, RM);
4761 const auto &
LHS = *
this;
4788 Out.makeNaN(
false,
false,
nullptr);
4800 "Special cases not handled exhaustively");
4807 if (!
T.isFiniteNonZero()) {
4809 Floats[1].makeZero(
false);
4831 Status |= U.add(Tau, RM);
4834 if (!U.isFinite()) {
4835 Floats[1].makeZero(
false);
4894 Floats[0].changeSign();
4895 Floats[1].changeSign();
4900 auto Result = Floats[0].compareAbsoluteValue(
RHS.Floats[0]);
4903 Result = Floats[1].compareAbsoluteValue(
RHS.Floats[1]);
4905 auto Against = Floats[0].isNegative() ^ Floats[1].isNegative();
4906 auto RHSAgainst =
RHS.Floats[0].isNegative() ^
RHS.Floats[1].isNegative();
4907 if (Against && !RHSAgainst)
4909 if (!Against && RHSAgainst)
4911 if (!Against && !RHSAgainst)
4913 if (Against && RHSAgainst)
4920 return Floats[0].getCategory();
4926 Floats[0].makeInf(Neg);
4927 Floats[1].makeZero(
false);
4931 Floats[0].makeZero(Neg);
4932 Floats[1].makeZero(
false);
4945 Floats[0].makeSmallest(Neg);
4946 Floats[1].makeZero(
false);
4953 Floats[0].changeSign();
4954 Floats[1].makeZero(
false);
4958 Floats[0].makeNaN(SNaN, Neg, fill);
4959 Floats[1].makeZero(
false);
4963 auto Result = Floats[0].compare(
RHS.Floats[0]);
4966 return Floats[1].compare(
RHS.Floats[1]);
4971 return Floats[0].bitwiseIsEqual(
RHS.Floats[0]) &&
4972 Floats[1].bitwiseIsEqual(
RHS.Floats[1]);
4984 Floats[0].bitcastToAPInt().getRawData()[0],
4985 Floats[1].bitcastToAPInt().getRawData()[0],
5002 auto Ret = Tmp.
next(nextDown);
5009 unsigned int Width,
bool IsSigned,
5028 unsigned int InputSize,
5039 unsigned int InputSize,
5049 unsigned int HexDigits,
5059 (Floats[0].isDenormal() || Floats[1].isDenormal() ||
5061 Floats[0] != Floats[0] + Floats[1]);
5091 return Floats[0].isInteger() && Floats[1].isInteger();
5095 unsigned FormatPrecision,
5096 unsigned FormatMaxPadding,
5097 bool TruncateZero)
const {
5100 .
toString(Str, FormatPrecision, FormatMaxPadding, TruncateZero);
5128 scalbn(Arg.Floats[1], Exp, RM));
5135 APFloat Second = Arg.Floats[1];
5137 Second =
scalbn(Second, -Exp, RM);
5143APFloat::Storage::Storage(IEEEFloat
F,
const fltSemantics &Semantics) {
5144 if (usesLayout<IEEEFloat>(Semantics)) {
5145 new (&
IEEE) IEEEFloat(std::move(
F));
5148 if (usesLayout<DoubleAPFloat>(Semantics)) {
5151 DoubleAPFloat(Semantics,
APFloat(std::move(
F), S),
5164 if (APFloat::usesLayout<detail::IEEEFloat>(Arg.
getSemantics()))
5166 if (APFloat::usesLayout<detail::DoubleAPFloat>(Arg.
getSemantics()))
5174 assert(StatusOrErr &&
"Invalid floating point representation");
5198 usesLayout<IEEEFloat>(ToSemantics))
5199 return U.IEEE.convert(ToSemantics, RM, losesInfo);
5201 usesLayout<DoubleAPFloat>(ToSemantics)) {
5204 *
this =
APFloat(ToSemantics, U.IEEE.bitcastToAPInt());
5208 usesLayout<IEEEFloat>(ToSemantics)) {
5209 auto Ret = getIEEE().
convert(ToSemantics, RM, losesInfo);
5210 *
this =
APFloat(std::move(getIEEE()), ToSemantics);
5223 OS << Buffer <<
"\n";
5226#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
5240 bool *isExact)
const {
5244 rounding_mode, isExact);
5246 result =
APInt(bitWidth, parts);
5254 "Float semantics is not representable by IEEEdouble");
5267 "Float semantics is not representable by IEEEsingle");
5278#undef APFLOAT_DISPATCH_ON_SEMANTICS
#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...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is MaybeLiveUses might be modified but its content should be ignored(since it might not be complete). DeadArgumentEliminationPass
Given that RA is a live value
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 getExactInverse(APFloat *inv) const
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
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 APFloat getAllOnesValue(const fltSemantics &Semantics)
Returns a float which is bitcasted from an all one value int.
const fltSemantics & getSemantics() const
opStatus convertFromSignExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const
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)
FPClassTest classify() const
Return the FPClassTest which will return true for the value.
opStatus mod(const APFloat &RHS)
Expected< opStatus > convertFromString(StringRef, roundingMode)
void print(raw_ostream &) const
opStatus roundToIntegral(roundingMode RM)
opStatus convertFromZeroExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
Class for arbitrary precision integers.
APInt udiv(const APInt &RHS) const
Unsigned division operation.
static 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 void tcSet(WordType *, WordType, unsigned)
Sets the least significant part of a bignum to the input value, and zeroes out higher parts.
static void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
static int tcExtractBit(const WordType *, unsigned bit)
Extract the given bit of a bignum; returns 0 or 1. Zero-based.
APInt zext(unsigned width) const
Zero extend to a new width.
uint64_t getZExtValue() const
Get zero extended value.
static WordType tcAdd(WordType *, const WordType *, WordType carry, unsigned)
DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
static 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.
APInt trunc(unsigned width) const
Truncate to new width.
static int tcCompare(const WordType *, const WordType *, unsigned)
Comparison (unsigned) of two bignums.
static APInt floatToBits(float V)
Converts a float to APInt bits.
static void tcAssign(WordType *, const WordType *, unsigned)
Assign one bignum to another.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static void tcShiftRight(WordType *, unsigned Words, unsigned Count)
Shift a bignum right Count bits.
static 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.
@ APINT_BITS_PER_WORD
Bits in a word.
static void tcClearBit(WordType *, unsigned bit)
Clear the given bit of a bignum. Zero-based.
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 unsigned tcLSB(const WordType *, unsigned n)
Returns the bit number of the least or most significant set bit of a number.
static void tcShiftLeft(WordType *, unsigned Words, unsigned Count)
Shift a bignum left Count bits.
static bool tcIsZero(const WordType *, unsigned)
Returns true if a bignum is zero, false otherwise.
static 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 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 WordType tcSubtract(WordType *, const WordType *, WordType carry, unsigned)
DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag.
static 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.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void makeSmallestNormalized(bool Neg)
DoubleAPFloat & operator=(const DoubleAPFloat &RHS)
LLVM_READONLY int getExactLog2() const
opStatus remainder(const DoubleAPFloat &RHS)
opStatus multiply(const DoubleAPFloat &RHS, roundingMode RM)
fltCategory getCategory() const
bool bitwiseIsEqual(const DoubleAPFloat &RHS) const
LLVM_READONLY int getExactLog2Abs() const
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
opStatus convertFromZeroExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
APInt bitcastToAPInt() const
bool getExactInverse(APFloat *inv) const
Expected< opStatus > convertFromString(StringRef, roundingMode)
opStatus subtract(const DoubleAPFloat &RHS, roundingMode RM)
cmpResult compareAbsoluteValue(const DoubleAPFloat &RHS) const
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
void makeSmallest(bool Neg)
opStatus next(bool nextDown)
opStatus divide(const DoubleAPFloat &RHS, roundingMode RM)
bool isSmallestNormalized() const
opStatus mod(const DoubleAPFloat &RHS)
DoubleAPFloat(const fltSemantics &S)
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision, unsigned FormatMaxPadding, bool TruncateZero=true) const
void makeLargest(bool Neg)
cmpResult compare(const DoubleAPFloat &RHS) const
opStatus roundToIntegral(roundingMode RM)
opStatus convertFromSignExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
opStatus fusedMultiplyAdd(const DoubleAPFloat &Multiplicand, const DoubleAPFloat &Addend, roundingMode RM)
unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const
opStatus add(const DoubleAPFloat &RHS, roundingMode RM)
void makeNaN(bool SNaN, bool Neg, const APInt *fill)
unsigned int convertToHexString(char *dst, unsigned int hexDigits, bool upperCase, roundingMode) const
Write out a hexadecimal representation of the floating point value to DST, which must be of sufficien...
fltCategory getCategory() const
bool isFiniteNonZero() const
opStatus add(const IEEEFloat &, roundingMode)
bool needsCleanup() const
Returns whether this instance allocated memory.
APInt bitcastToAPInt() const
bool isNegative() const
IEEE-754R isSignMinus: Returns true if and only if the current value is negative.
opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)
bool isNaN() const
Returns true if and only if the float is a quiet or signaling NaN.
opStatus convertFromAPInt(const APInt &, bool, roundingMode)
opStatus roundToIntegral(roundingMode)
double convertToDouble() const
float convertToFloat() const
cmpResult compareAbsoluteValue(const IEEEFloat &) const
opStatus fusedMultiplyAdd(const IEEEFloat &, const IEEEFloat &, roundingMode)
void makeInf(bool Neg=false)
Expected< opStatus > convertFromString(StringRef, roundingMode)
bool isSmallestNormalized() const
Returns true if this is the smallest (by magnitude) normalized finite number in the given semantics.
bool isLargest() const
Returns true if and only if the number has the largest possible finite magnitude in the current seman...
bool isFinite() const
Returns true if and only if the current value is zero, subnormal, or normal.
void makeNaN(bool SNaN=false, bool Neg=false, const APInt *fill=nullptr)
opStatus convertToInteger(MutableArrayRef< integerPart >, unsigned int, bool, roundingMode, bool *) const
friend int ilogb(const IEEEFloat &Arg)
Returns the exponent of the internal representation of the APFloat.
opStatus remainder(const IEEEFloat &)
IEEE remainder.
IEEEFloat & operator=(const IEEEFloat &)
opStatus divide(const IEEEFloat &, roundingMode)
friend IEEEFloat scalbn(IEEEFloat X, int Exp, roundingMode)
Returns: X * 2^Exp for integral exponents.
bool bitwiseIsEqual(const IEEEFloat &) const
Bitwise comparison for equality (QNaNs compare equal, 0!=-0).
bool isInteger() const
Returns true if and only if the number is an exact integer.
IEEEFloat(const fltSemantics &)
cmpResult compare(const IEEEFloat &) const
IEEE comparison with another floating point number (NaNs compare unordered, 0==-0).
opStatus subtract(const IEEEFloat &, roundingMode)
bool isInfinity() const
IEEE-754R isInfinite(): Returns true if and only if the float is infinity.
const fltSemantics & getSemantics() const
bool isZero() const
Returns true if and only if the float is plus or minus zero.
bool isSignaling() const
Returns true if and only if the float is a signaling NaN.
opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)
opStatus convert(const fltSemantics &, roundingMode, bool *)
IEEEFloat::convert - convert a value of one floating point type to another.
void makeZero(bool Neg=false)
bool isDenormal() const
IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal.
bool isSmallest() const
Returns true if and only if the number has the smallest possible non-zero magnitude in the current se...
opStatus mod(const IEEEFloat &)
C fmod, or llvm frem.
opStatus multiply(const IEEEFloat &, roundingMode)
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
IEEEFloat scalbn(IEEEFloat X, int Exp, IEEEFloat::roundingMode)
static void tcSetLeastSignificantBits(APInt::WordType *dst, unsigned parts, unsigned bits)
hash_code hash_value(const IEEEFloat &Arg)
IEEEFloat frexp(const IEEEFloat &Val, int &Exp, IEEEFloat::roundingMode RM)
int ilogb(const IEEEFloat &Arg)
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)
static constexpr fltSemantics semBogus
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.
hash_code hash_value(const FixedPointSemantics &Val)
int popcount(T Value) noexcept
Count the number of set bits in a value.
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)
static constexpr APFloatBase::ExponentType exponentZero(const fltSemantics &semantics)
static Expected< int > totalExponent(StringRef::iterator p, StringRef::iterator end, int exponentAdjustment)
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
static constexpr fltSemantics semIEEEquad
const unsigned int maxPowerOfFiveExponent
static char * writeUnsignedDecimal(char *dst, unsigned int n)
static constexpr fltSemantics semFloat8E4M3FNUZ
const unsigned int maxPrecision
static constexpr fltSemantics semIEEEdouble
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 constexpr fltSemantics semFloat8E4M3FN
static const char infinityU[]
lostFraction
Enum that represents what fraction of the LSB truncated bits of an fp number represent.
static constexpr fltSemantics semPPCDoubleDouble
static Error interpretDecimal(StringRef::iterator begin, StringRef::iterator end, decimalInfo *D)
static constexpr fltSemantics semFloat8E5M2FNUZ
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
static constexpr fltSemantics semIEEEsingle
APFloat scalbn(APFloat X, int Exp, APFloat::roundingMode RM)
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 constexpr fltSemantics semIEEEhalf
static constexpr fltSemantics semPPCDoubleDoubleLegacy
static lostFraction shiftRight(APFloatBase::integerPart *dst, unsigned int parts, unsigned int bits)
static constexpr fltSemantics semFloat8E5M2
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
static const char hexDigitsUpper[]
const unsigned int maxExponent
static unsigned int decDigitValue(unsigned int c)
static constexpr fltSemantics semFloat8E4M3B11FNUZ
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.
OutputIt copy(R &&Range, OutputIt Out)
static constexpr fltSemantics semX87DoubleExtended
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
static constexpr fltSemantics semFloatTF32
static constexpr APFloatBase::ExponentType exponentInf(const fltSemantics &semantics)
static lostFraction lostFractionThroughTruncation(const APFloatBase::integerPart *parts, unsigned int partCount, unsigned int bits)
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 constexpr fltSemantics semBFloat
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[]
Implement std::hash so that hash_code can be used in STL containers.
static const llvm::fltSemantics & EnumToSemantics(Semantics S)
static const fltSemantics & IEEEsingle() LLVM_READNONE
static constexpr roundingMode rmNearestTiesToAway
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
static constexpr roundingMode rmTowardNegative
static ExponentType semanticsMinExponent(const fltSemantics &)
static constexpr roundingMode rmNearestTiesToEven
static unsigned int semanticsSizeInBits(const fltSemantics &)
static unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
static const fltSemantics & Float8E4M3FN() LLVM_READNONE
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
static constexpr roundingMode rmTowardZero
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
uninitializedTag
Convenience enum used to construct an uninitialized APFloat.
static const fltSemantics & IEEEquad() LLVM_READNONE
static const fltSemantics & Float8E4M3B11FNUZ() LLVM_READNONE
static const fltSemantics & Bogus() LLVM_READNONE
A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real.
static ExponentType semanticsMaxExponent(const fltSemantics &)
static unsigned int semanticsPrecision(const fltSemantics &)
static const fltSemantics & IEEEdouble() LLVM_READNONE
static const fltSemantics & Float8E5M2() LLVM_READNONE
static Semantics SemanticsToEnum(const llvm::fltSemantics &Sem)
static constexpr unsigned integerPartWidth
static const fltSemantics & IEEEhalf() LLVM_READNONE
APInt::WordType integerPart
static constexpr roundingMode rmTowardPositive
static bool isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst)
static const fltSemantics & Float8E4M3FNUZ() LLVM_READNONE
static const fltSemantics & BFloat() LLVM_READNONE
static const fltSemantics & FloatTF32() LLVM_READNONE
static const fltSemantics & Float8E5M2FNUZ() LLVM_READNONE
fltCategory
Category of internally-represented number.
opStatus
IEEE-754R 7: Default exception handling.
int32_t ExponentType
A signed type to represent a floating point numbers unbiased exponent.
static unsigned int semanticsIntSizeInBits(const fltSemantics &, bool)
const char * lastSigDigit
const char * firstSigDigit
bool isRepresentableBy(const fltSemantics &S) const
APFloatBase::ExponentType maxExponent
fltNonfiniteBehavior nonFiniteBehavior
APFloatBase::ExponentType minExponent
fltNanEncoding nanEncoding