mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Tweak RoundAwayFromZero the bit number below which is truncated, and make
it const. Preparation for APFloat -> hexadecimal string conversion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42576 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0abe116022
commit
b7dea4cb36
@ -253,7 +253,7 @@ namespace llvm {
|
|||||||
opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract);
|
opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract);
|
||||||
cmpResult compareAbsoluteValue(const APFloat &) const;
|
cmpResult compareAbsoluteValue(const APFloat &) const;
|
||||||
opStatus handleOverflow(roundingMode);
|
opStatus handleOverflow(roundingMode);
|
||||||
bool roundAwayFromZero(roundingMode, lostFraction);
|
bool roundAwayFromZero(roundingMode, lostFraction, unsigned int) const;
|
||||||
opStatus convertFromUnsignedInteger(integerPart *, unsigned int,
|
opStatus convertFromUnsignedInteger(integerPart *, unsigned int,
|
||||||
roundingMode);
|
roundingMode);
|
||||||
lostFraction combineLostFractions(lostFraction, lostFraction);
|
lostFraction combineLostFractions(lostFraction, lostFraction);
|
||||||
|
@ -184,7 +184,8 @@ namespace {
|
|||||||
return digitValue == 0 ? lfLessThanHalf: lfMoreThanHalf;
|
return digitValue == 0 ? lfLessThanHalf: lfMoreThanHalf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the fraction lost were a bignum truncated. */
|
/* Return the fraction lost were a bignum truncated losing the least
|
||||||
|
significant BITS bits. */
|
||||||
lostFraction
|
lostFraction
|
||||||
lostFractionThroughTruncation(integerPart *parts,
|
lostFractionThroughTruncation(integerPart *parts,
|
||||||
unsigned int partCount,
|
unsigned int partCount,
|
||||||
@ -694,16 +695,20 @@ APFloat::handleOverflow(roundingMode rounding_mode)
|
|||||||
return opInexact;
|
return opInexact;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This routine must work for fcZero of both signs, and fcNormal
|
/* Returns TRUE if, when truncating the current number, with BIT the
|
||||||
numbers. */
|
new LSB, with the given lost fraction and rounding mode, the result
|
||||||
|
would need to be rounded away from zero (i.e., by increasing the
|
||||||
|
signficand). This routine must work for fcZero of both signs, and
|
||||||
|
fcNormal numbers. */
|
||||||
bool
|
bool
|
||||||
APFloat::roundAwayFromZero(roundingMode rounding_mode,
|
APFloat::roundAwayFromZero(roundingMode rounding_mode,
|
||||||
lostFraction lost_fraction)
|
lostFraction lost_fraction,
|
||||||
|
unsigned int bit) const
|
||||||
{
|
{
|
||||||
/* NaNs and infinities should not have lost fractions. */
|
/* NaNs and infinities should not have lost fractions. */
|
||||||
assert(category == fcNormal || category == fcZero);
|
assert(category == fcNormal || category == fcZero);
|
||||||
|
|
||||||
/* Our caller has already handled this case. */
|
/* Current callers never pass this so we don't handle it. */
|
||||||
assert(lost_fraction != lfExactlyZero);
|
assert(lost_fraction != lfExactlyZero);
|
||||||
|
|
||||||
switch(rounding_mode) {
|
switch(rounding_mode) {
|
||||||
@ -719,7 +724,7 @@ APFloat::roundAwayFromZero(roundingMode rounding_mode,
|
|||||||
|
|
||||||
/* Our zeroes don't have a significand to test. */
|
/* Our zeroes don't have a significand to test. */
|
||||||
if(lost_fraction == lfExactlyHalf && category != fcZero)
|
if(lost_fraction == lfExactlyHalf && category != fcZero)
|
||||||
return significandParts()[0] & 1;
|
return APInt::tcExtractBit(significandParts(), bit);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -802,7 +807,7 @@ APFloat::normalize(roundingMode rounding_mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Increment the significand if we're rounding away from zero. */
|
/* Increment the significand if we're rounding away from zero. */
|
||||||
if(roundAwayFromZero(rounding_mode, lost_fraction)) {
|
if(roundAwayFromZero(rounding_mode, lost_fraction, 0)) {
|
||||||
if(omsb == 0)
|
if(omsb == 0)
|
||||||
exponent = semantics->minExponent;
|
exponent = semantics->minExponent;
|
||||||
|
|
||||||
@ -1451,7 +1456,7 @@ APFloat::convertToInteger(integerPart *parts, unsigned int width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(lost_fraction != lfExactlyZero
|
if(lost_fraction != lfExactlyZero
|
||||||
&& tmp.roundAwayFromZero(rounding_mode, lost_fraction))
|
&& tmp.roundAwayFromZero(rounding_mode, lost_fraction, 0))
|
||||||
tmp.incrementSignificand();
|
tmp.incrementSignificand();
|
||||||
|
|
||||||
msb = tmp.significandMSB();
|
msb = tmp.significandMSB();
|
||||||
|
Loading…
Reference in New Issue
Block a user