mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 04:33:40 +00:00
Use APInt::tcExtract. It's cleaner, and works :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
68e53ad6cb
commit
5477f8593d
@ -1556,32 +1556,27 @@ APFloat::convertFromUnsignedParts(const integerPart *src,
|
|||||||
unsigned int srcCount,
|
unsigned int srcCount,
|
||||||
roundingMode rounding_mode)
|
roundingMode rounding_mode)
|
||||||
{
|
{
|
||||||
unsigned int dstCount;
|
unsigned int omsb, precision, dstCount;
|
||||||
lostFraction lost_fraction;
|
|
||||||
integerPart *dst;
|
integerPart *dst;
|
||||||
|
lostFraction lost_fraction;
|
||||||
|
|
||||||
category = fcNormal;
|
category = fcNormal;
|
||||||
exponent = semantics->precision - 1;
|
omsb = APInt::tcMSB(src, srcCount) + 1;
|
||||||
|
|
||||||
dst = significandParts();
|
dst = significandParts();
|
||||||
dstCount = partCount();
|
dstCount = partCount();
|
||||||
|
precision = semantics->precision;
|
||||||
|
|
||||||
/* We need to capture the non-zero most significant parts. */
|
/* We want the most significant PRECISON bits of SRC. There may not
|
||||||
while (srcCount > dstCount && src[srcCount - 1] == 0)
|
be that many; extract what we can. */
|
||||||
srcCount--;
|
if (precision <= omsb) {
|
||||||
|
exponent = omsb - 1;
|
||||||
/* Copy the bit image of as many parts as we can. If we are wider,
|
|
||||||
zero-out remaining parts. */
|
|
||||||
if (dstCount >= srcCount) {
|
|
||||||
APInt::tcAssign(dst, src, srcCount);
|
|
||||||
while (srcCount < dstCount)
|
|
||||||
dst[srcCount++] = 0;
|
|
||||||
lost_fraction = lfExactlyZero;
|
|
||||||
} else {
|
|
||||||
exponent += (srcCount - dstCount) * integerPartWidth;
|
|
||||||
APInt::tcAssign(dst, src + (srcCount - dstCount), dstCount);
|
|
||||||
lost_fraction = lostFractionThroughTruncation(src, srcCount,
|
lost_fraction = lostFractionThroughTruncation(src, srcCount,
|
||||||
dstCount * integerPartWidth);
|
omsb - precision);
|
||||||
|
APInt::tcExtract(dst, dstCount, src, precision, omsb - precision);
|
||||||
|
} else {
|
||||||
|
exponent = precision - 1;
|
||||||
|
lost_fraction = lfExactlyZero;
|
||||||
|
APInt::tcExtract(dst, dstCount, src, omsb, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return normalize(rounding_mode, lost_fraction);
|
return normalize(rounding_mode, lost_fraction);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user