Fix minor style issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99414 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-03-24 19:38:02 +00:00
parent 34b96f4fb3
commit 16e02097d2
6 changed files with 206 additions and 211 deletions

View File

@ -100,15 +100,15 @@ hexDigitValue(unsigned int c)
unsigned int r; unsigned int r;
r = c - '0'; r = c - '0';
if(r <= 9) if (r <= 9)
return r; return r;
r = c - 'A'; r = c - 'A';
if(r <= 5) if (r <= 5)
return r + 10; return r + 10;
r = c - 'a'; r = c - 'a';
if(r <= 5) if (r <= 5)
return r + 10; return r + 10;
return -1U; return -1U;
@ -116,8 +116,8 @@ hexDigitValue(unsigned int c)
static inline void static inline void
assertArithmeticOK(const llvm::fltSemantics &semantics) { assertArithmeticOK(const llvm::fltSemantics &semantics) {
assert(semantics.arithmeticOK assert(semantics.arithmeticOK &&
&& "Compile-time arithmetic does not support these semantics"); "Compile-time arithmetic does not support these semantics");
} }
/* Return the value of a decimal exponent of the form /* Return the value of a decimal exponent of the form
@ -179,37 +179,37 @@ totalExponent(StringRef::iterator p, StringRef::iterator end,
assert(p != end && "Exponent has no digits"); assert(p != end && "Exponent has no digits");
negative = *p == '-'; negative = *p == '-';
if(*p == '-' || *p == '+') { if (*p == '-' || *p == '+') {
p++; p++;
assert(p != end && "Exponent has no digits"); assert(p != end && "Exponent has no digits");
} }
unsignedExponent = 0; unsignedExponent = 0;
overflow = false; overflow = false;
for(; p != end; ++p) { for (; p != end; ++p) {
unsigned int value; unsigned int value;
value = decDigitValue(*p); value = decDigitValue(*p);
assert(value < 10U && "Invalid character in exponent"); assert(value < 10U && "Invalid character in exponent");
unsignedExponent = unsignedExponent * 10 + value; unsignedExponent = unsignedExponent * 10 + value;
if(unsignedExponent > 65535) if (unsignedExponent > 65535)
overflow = true; overflow = true;
} }
if(exponentAdjustment > 65535 || exponentAdjustment < -65536) if (exponentAdjustment > 65535 || exponentAdjustment < -65536)
overflow = true; overflow = true;
if(!overflow) { if (!overflow) {
exponent = unsignedExponent; exponent = unsignedExponent;
if(negative) if (negative)
exponent = -exponent; exponent = -exponent;
exponent += exponentAdjustment; exponent += exponentAdjustment;
if(exponent > 65535 || exponent < -65536) if (exponent > 65535 || exponent < -65536)
overflow = true; overflow = true;
} }
if(overflow) if (overflow)
exponent = negative ? -65536: 65535; exponent = negative ? -65536: 65535;
return exponent; return exponent;
@ -221,15 +221,15 @@ skipLeadingZeroesAndAnyDot(StringRef::iterator begin, StringRef::iterator end,
{ {
StringRef::iterator p = begin; StringRef::iterator p = begin;
*dot = end; *dot = end;
while(*p == '0' && p != end) while (*p == '0' && p != end)
p++; p++;
if(*p == '.') { if (*p == '.') {
*dot = p++; *dot = p++;
assert(end - begin != 1 && "Significand has no digits"); assert(end - begin != 1 && "Significand has no digits");
while(*p == '0' && p != end) while (*p == '0' && p != end)
p++; p++;
} }
@ -323,13 +323,13 @@ trailingHexadecimalFraction(StringRef::iterator p, StringRef::iterator end,
/* If the first trailing digit isn't 0 or 8 we can work out the /* If the first trailing digit isn't 0 or 8 we can work out the
fraction immediately. */ fraction immediately. */
if(digitValue > 8) if (digitValue > 8)
return lfMoreThanHalf; return lfMoreThanHalf;
else if(digitValue < 8 && digitValue > 0) else if (digitValue < 8 && digitValue > 0)
return lfLessThanHalf; return lfLessThanHalf;
/* Otherwise we need to find the first non-zero digit. */ /* Otherwise we need to find the first non-zero digit. */
while(*p == '0') while (*p == '0')
p++; p++;
assert(p != end && "Invalid trailing hexadecimal fraction!"); assert(p != end && "Invalid trailing hexadecimal fraction!");
@ -338,7 +338,7 @@ trailingHexadecimalFraction(StringRef::iterator p, StringRef::iterator end,
/* If we ran off the end it is exactly zero or one-half, otherwise /* If we ran off the end it is exactly zero or one-half, otherwise
a little more. */ a little more. */
if(hexDigit == -1U) if (hexDigit == -1U)
return digitValue == 0 ? lfExactlyZero: lfExactlyHalf; return digitValue == 0 ? lfExactlyZero: lfExactlyHalf;
else else
return digitValue == 0 ? lfLessThanHalf: lfMoreThanHalf; return digitValue == 0 ? lfLessThanHalf: lfMoreThanHalf;
@ -356,12 +356,12 @@ lostFractionThroughTruncation(const integerPart *parts,
lsb = APInt::tcLSB(parts, partCount); lsb = APInt::tcLSB(parts, partCount);
/* Note this is guaranteed true if bits == 0, or LSB == -1U. */ /* Note this is guaranteed true if bits == 0, or LSB == -1U. */
if(bits <= lsb) if (bits <= lsb)
return lfExactlyZero; return lfExactlyZero;
if(bits == lsb + 1) if (bits == lsb + 1)
return lfExactlyHalf; return lfExactlyHalf;
if(bits <= partCount * integerPartWidth if (bits <= partCount * integerPartWidth &&
&& APInt::tcExtractBit(parts, bits - 1)) APInt::tcExtractBit(parts, bits - 1))
return lfMoreThanHalf; return lfMoreThanHalf;
return lfLessThanHalf; return lfLessThanHalf;
@ -385,10 +385,10 @@ static lostFraction
combineLostFractions(lostFraction moreSignificant, combineLostFractions(lostFraction moreSignificant,
lostFraction lessSignificant) lostFraction lessSignificant)
{ {
if(lessSignificant != lfExactlyZero) { if (lessSignificant != lfExactlyZero) {
if(moreSignificant == lfExactlyZero) if (moreSignificant == lfExactlyZero)
moreSignificant = lfLessThanHalf; moreSignificant = lfLessThanHalf;
else if(moreSignificant == lfExactlyHalf) else if (moreSignificant == lfExactlyHalf)
moreSignificant = lfMoreThanHalf; moreSignificant = lfMoreThanHalf;
} }
@ -588,14 +588,14 @@ APFloat::initialize(const fltSemantics *ourSemantics)
semantics = ourSemantics; semantics = ourSemantics;
count = partCount(); count = partCount();
if(count > 1) if (count > 1)
significand.parts = new integerPart[count]; significand.parts = new integerPart[count];
} }
void void
APFloat::freeSignificand() APFloat::freeSignificand()
{ {
if(partCount() > 1) if (partCount() > 1)
delete [] significand.parts; delete [] significand.parts;
} }
@ -609,7 +609,7 @@ APFloat::assign(const APFloat &rhs)
exponent = rhs.exponent; exponent = rhs.exponent;
sign2 = rhs.sign2; sign2 = rhs.sign2;
exponent2 = rhs.exponent2; exponent2 = rhs.exponent2;
if(category == fcNormal || category == fcNaN) if (category == fcNormal || category == fcNaN)
copySignificand(rhs); copySignificand(rhs);
} }
@ -683,8 +683,8 @@ APFloat APFloat::makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative,
APFloat & APFloat &
APFloat::operator=(const APFloat &rhs) APFloat::operator=(const APFloat &rhs)
{ {
if(this != &rhs) { if (this != &rhs) {
if(semantics != rhs.semantics) { if (semantics != rhs.semantics) {
freeSignificand(); freeSignificand();
initialize(rhs.semantics); initialize(rhs.semantics);
} }
@ -881,7 +881,7 @@ APFloat::multiplySignificand(const APFloat &rhs, const APFloat *addend)
precision = semantics->precision; precision = semantics->precision;
newPartsCount = partCountForBits(precision * 2); newPartsCount = partCountForBits(precision * 2);
if(newPartsCount > 4) if (newPartsCount > 4)
fullSignificand = new integerPart[newPartsCount]; fullSignificand = new integerPart[newPartsCount];
else else
fullSignificand = scratch; fullSignificand = scratch;
@ -896,7 +896,7 @@ APFloat::multiplySignificand(const APFloat &rhs, const APFloat *addend)
omsb = APInt::tcMSB(fullSignificand, newPartsCount) + 1; omsb = APInt::tcMSB(fullSignificand, newPartsCount) + 1;
exponent += rhs.exponent; exponent += rhs.exponent;
if(addend) { if (addend) {
Significand savedSignificand = significand; Significand savedSignificand = significand;
const fltSemantics *savedSemantics = semantics; const fltSemantics *savedSemantics = semantics;
fltSemantics extendedSemantics; fltSemantics extendedSemantics;
@ -905,18 +905,17 @@ APFloat::multiplySignificand(const APFloat &rhs, const APFloat *addend)
/* Normalize our MSB. */ /* Normalize our MSB. */
extendedPrecision = precision + precision - 1; extendedPrecision = precision + precision - 1;
if(omsb != extendedPrecision) if (omsb != extendedPrecision) {
{ APInt::tcShiftLeft(fullSignificand, newPartsCount,
APInt::tcShiftLeft(fullSignificand, newPartsCount, extendedPrecision - omsb);
extendedPrecision - omsb); exponent -= extendedPrecision - omsb;
exponent -= extendedPrecision - omsb; }
}
/* Create new semantics. */ /* Create new semantics. */
extendedSemantics = *semantics; extendedSemantics = *semantics;
extendedSemantics.precision = extendedPrecision; extendedSemantics.precision = extendedPrecision;
if(newPartsCount == 1) if (newPartsCount == 1)
significand.part = fullSignificand[0]; significand.part = fullSignificand[0];
else else
significand.parts = fullSignificand; significand.parts = fullSignificand;
@ -928,7 +927,7 @@ APFloat::multiplySignificand(const APFloat &rhs, const APFloat *addend)
lost_fraction = addOrSubtractSignificand(extendedAddend, false); lost_fraction = addOrSubtractSignificand(extendedAddend, false);
/* Restore our state. */ /* Restore our state. */
if(newPartsCount == 1) if (newPartsCount == 1)
fullSignificand[0] = significand.part; fullSignificand[0] = significand.part;
significand = savedSignificand; significand = savedSignificand;
semantics = savedSemantics; semantics = savedSemantics;
@ -938,7 +937,7 @@ APFloat::multiplySignificand(const APFloat &rhs, const APFloat *addend)
exponent -= (precision - 1); exponent -= (precision - 1);
if(omsb > precision) { if (omsb > precision) {
unsigned int bits, significantParts; unsigned int bits, significantParts;
lostFraction lf; lostFraction lf;
@ -951,7 +950,7 @@ APFloat::multiplySignificand(const APFloat &rhs, const APFloat *addend)
APInt::tcAssign(lhsSignificand, fullSignificand, partsCount); APInt::tcAssign(lhsSignificand, fullSignificand, partsCount);
if(newPartsCount > 4) if (newPartsCount > 4)
delete [] fullSignificand; delete [] fullSignificand;
return lost_fraction; return lost_fraction;
@ -973,7 +972,7 @@ APFloat::divideSignificand(const APFloat &rhs)
rhsSignificand = rhs.significandParts(); rhsSignificand = rhs.significandParts();
partsCount = partCount(); partsCount = partCount();
if(partsCount > 2) if (partsCount > 2)
dividend = new integerPart[partsCount * 2]; dividend = new integerPart[partsCount * 2];
else else
dividend = scratch; dividend = scratch;
@ -981,7 +980,7 @@ APFloat::divideSignificand(const APFloat &rhs)
divisor = dividend + partsCount; divisor = dividend + partsCount;
/* Copy the dividend and divisor as they will be modified in-place. */ /* Copy the dividend and divisor as they will be modified in-place. */
for(i = 0; i < partsCount; i++) { for (i = 0; i < partsCount; i++) {
dividend[i] = lhsSignificand[i]; dividend[i] = lhsSignificand[i];
divisor[i] = rhsSignificand[i]; divisor[i] = rhsSignificand[i];
lhsSignificand[i] = 0; lhsSignificand[i] = 0;
@ -993,14 +992,14 @@ APFloat::divideSignificand(const APFloat &rhs)
/* Normalize the divisor. */ /* Normalize the divisor. */
bit = precision - APInt::tcMSB(divisor, partsCount) - 1; bit = precision - APInt::tcMSB(divisor, partsCount) - 1;
if(bit) { if (bit) {
exponent += bit; exponent += bit;
APInt::tcShiftLeft(divisor, partsCount, bit); APInt::tcShiftLeft(divisor, partsCount, bit);
} }
/* Normalize the dividend. */ /* Normalize the dividend. */
bit = precision - APInt::tcMSB(dividend, partsCount) - 1; bit = precision - APInt::tcMSB(dividend, partsCount) - 1;
if(bit) { if (bit) {
exponent -= bit; exponent -= bit;
APInt::tcShiftLeft(dividend, partsCount, bit); APInt::tcShiftLeft(dividend, partsCount, bit);
} }
@ -1008,15 +1007,15 @@ APFloat::divideSignificand(const APFloat &rhs)
/* Ensure the dividend >= divisor initially for the loop below. /* Ensure the dividend >= divisor initially for the loop below.
Incidentally, this means that the division loop below is Incidentally, this means that the division loop below is
guaranteed to set the integer bit to one. */ guaranteed to set the integer bit to one. */
if(APInt::tcCompare(dividend, divisor, partsCount) < 0) { if (APInt::tcCompare(dividend, divisor, partsCount) < 0) {
exponent--; exponent--;
APInt::tcShiftLeft(dividend, partsCount, 1); APInt::tcShiftLeft(dividend, partsCount, 1);
assert(APInt::tcCompare(dividend, divisor, partsCount) >= 0); assert(APInt::tcCompare(dividend, divisor, partsCount) >= 0);
} }
/* Long division. */ /* Long division. */
for(bit = precision; bit; bit -= 1) { for (bit = precision; bit; bit -= 1) {
if(APInt::tcCompare(dividend, divisor, partsCount) >= 0) { if (APInt::tcCompare(dividend, divisor, partsCount) >= 0) {
APInt::tcSubtract(dividend, divisor, 0, partsCount); APInt::tcSubtract(dividend, divisor, 0, partsCount);
APInt::tcSetBit(lhsSignificand, bit - 1); APInt::tcSetBit(lhsSignificand, bit - 1);
} }
@ -1027,16 +1026,16 @@ APFloat::divideSignificand(const APFloat &rhs)
/* Figure out the lost fraction. */ /* Figure out the lost fraction. */
int cmp = APInt::tcCompare(dividend, divisor, partsCount); int cmp = APInt::tcCompare(dividend, divisor, partsCount);
if(cmp > 0) if (cmp > 0)
lost_fraction = lfMoreThanHalf; lost_fraction = lfMoreThanHalf;
else if(cmp == 0) else if (cmp == 0)
lost_fraction = lfExactlyHalf; lost_fraction = lfExactlyHalf;
else if(APInt::tcIsZero(dividend, partsCount)) else if (APInt::tcIsZero(dividend, partsCount))
lost_fraction = lfExactlyZero; lost_fraction = lfExactlyZero;
else else
lost_fraction = lfLessThanHalf; lost_fraction = lfLessThanHalf;
if(partsCount > 2) if (partsCount > 2)
delete [] dividend; delete [] dividend;
return lost_fraction; return lost_fraction;
@ -1072,7 +1071,7 @@ APFloat::shiftSignificandLeft(unsigned int bits)
{ {
assert(bits < semantics->precision); assert(bits < semantics->precision);
if(bits) { if (bits) {
unsigned int partsCount = partCount(); unsigned int partsCount = partCount();
APInt::tcShiftLeft(significandParts(), partsCount, bits); APInt::tcShiftLeft(significandParts(), partsCount, bits);
@ -1095,13 +1094,13 @@ APFloat::compareAbsoluteValue(const APFloat &rhs) const
/* If exponents are equal, do an unsigned bignum comparison of the /* If exponents are equal, do an unsigned bignum comparison of the
significands. */ significands. */
if(compare == 0) if (compare == 0)
compare = APInt::tcCompare(significandParts(), rhs.significandParts(), compare = APInt::tcCompare(significandParts(), rhs.significandParts(),
partCount()); partCount());
if(compare > 0) if (compare > 0)
return cmpGreaterThan; return cmpGreaterThan;
else if(compare < 0) else if (compare < 0)
return cmpLessThan; return cmpLessThan;
else else
return cmpEqual; return cmpEqual;
@ -1113,14 +1112,13 @@ APFloat::opStatus
APFloat::handleOverflow(roundingMode rounding_mode) APFloat::handleOverflow(roundingMode rounding_mode)
{ {
/* Infinity? */ /* Infinity? */
if(rounding_mode == rmNearestTiesToEven if (rounding_mode == rmNearestTiesToEven ||
|| rounding_mode == rmNearestTiesToAway rounding_mode == rmNearestTiesToAway ||
|| (rounding_mode == rmTowardPositive && !sign) (rounding_mode == rmTowardPositive && !sign) ||
|| (rounding_mode == rmTowardNegative && sign)) (rounding_mode == rmTowardNegative && sign)) {
{ category = fcInfinity;
category = fcInfinity; return (opStatus) (opOverflow | opInexact);
return (opStatus) (opOverflow | opInexact); }
}
/* Otherwise we become the largest finite number. */ /* Otherwise we become the largest finite number. */
category = fcNormal; category = fcNormal;
@ -1155,11 +1153,11 @@ APFloat::roundAwayFromZero(roundingMode rounding_mode,
return lost_fraction == lfExactlyHalf || lost_fraction == lfMoreThanHalf; return lost_fraction == lfExactlyHalf || lost_fraction == lfMoreThanHalf;
case rmNearestTiesToEven: case rmNearestTiesToEven:
if(lost_fraction == lfMoreThanHalf) if (lost_fraction == lfMoreThanHalf)
return true; return true;
/* 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 APInt::tcExtractBit(significandParts(), bit); return APInt::tcExtractBit(significandParts(), bit);
return false; return false;
@ -1182,13 +1180,13 @@ APFloat::normalize(roundingMode rounding_mode,
unsigned int omsb; /* One, not zero, based MSB. */ unsigned int omsb; /* One, not zero, based MSB. */
int exponentChange; int exponentChange;
if(category != fcNormal) if (category != fcNormal)
return opOK; return opOK;
/* Before rounding normalize the exponent of fcNormal numbers. */ /* Before rounding normalize the exponent of fcNormal numbers. */
omsb = significandMSB() + 1; omsb = significandMSB() + 1;
if(omsb) { if (omsb) {
/* OMSB is numbered from 1. We want to place it in the integer /* OMSB is numbered from 1. We want to place it in the integer
bit numbered PRECISON if possible, with a compensating change in bit numbered PRECISON if possible, with a compensating change in
the exponent. */ the exponent. */
@ -1196,16 +1194,16 @@ APFloat::normalize(roundingMode rounding_mode,
/* If the resulting exponent is too high, overflow according to /* If the resulting exponent is too high, overflow according to
the rounding mode. */ the rounding mode. */
if(exponent + exponentChange > semantics->maxExponent) if (exponent + exponentChange > semantics->maxExponent)
return handleOverflow(rounding_mode); return handleOverflow(rounding_mode);
/* Subnormal numbers have exponent minExponent, and their MSB /* Subnormal numbers have exponent minExponent, and their MSB
is forced based on that. */ is forced based on that. */
if(exponent + exponentChange < semantics->minExponent) if (exponent + exponentChange < semantics->minExponent)
exponentChange = semantics->minExponent - exponent; exponentChange = semantics->minExponent - exponent;
/* Shifting left is easy as we don't lose precision. */ /* Shifting left is easy as we don't lose precision. */
if(exponentChange < 0) { if (exponentChange < 0) {
assert(lost_fraction == lfExactlyZero); assert(lost_fraction == lfExactlyZero);
shiftSignificandLeft(-exponentChange); shiftSignificandLeft(-exponentChange);
@ -1213,7 +1211,7 @@ APFloat::normalize(roundingMode rounding_mode,
return opOK; return opOK;
} }
if(exponentChange > 0) { if (exponentChange > 0) {
lostFraction lf; lostFraction lf;
/* Shift right and capture any new lost fraction. */ /* Shift right and capture any new lost fraction. */
@ -1222,7 +1220,7 @@ APFloat::normalize(roundingMode rounding_mode,
lost_fraction = combineLostFractions(lf, lost_fraction); lost_fraction = combineLostFractions(lf, lost_fraction);
/* Keep OMSB up-to-date. */ /* Keep OMSB up-to-date. */
if(omsb > (unsigned) exponentChange) if (omsb > (unsigned) exponentChange)
omsb -= exponentChange; omsb -= exponentChange;
else else
omsb = 0; omsb = 0;
@ -1234,28 +1232,28 @@ APFloat::normalize(roundingMode rounding_mode,
/* As specified in IEEE 754, since we do not trap we do not report /* As specified in IEEE 754, since we do not trap we do not report
underflow for exact results. */ underflow for exact results. */
if(lost_fraction == lfExactlyZero) { if (lost_fraction == lfExactlyZero) {
/* Canonicalize zeroes. */ /* Canonicalize zeroes. */
if(omsb == 0) if (omsb == 0)
category = fcZero; category = fcZero;
return opOK; return opOK;
} }
/* 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, 0)) { if (roundAwayFromZero(rounding_mode, lost_fraction, 0)) {
if(omsb == 0) if (omsb == 0)
exponent = semantics->minExponent; exponent = semantics->minExponent;
incrementSignificand(); incrementSignificand();
omsb = significandMSB() + 1; omsb = significandMSB() + 1;
/* Did the significand increment overflow? */ /* Did the significand increment overflow? */
if(omsb == (unsigned) semantics->precision + 1) { if (omsb == (unsigned) semantics->precision + 1) {
/* Renormalize by incrementing the exponent and shifting our /* Renormalize by incrementing the exponent and shifting our
significand right one. However if we already have the significand right one. However if we already have the
maximum exponent we overflow to infinity. */ maximum exponent we overflow to infinity. */
if(exponent == semantics->maxExponent) { if (exponent == semantics->maxExponent) {
category = fcInfinity; category = fcInfinity;
return (opStatus) (opOverflow | opInexact); return (opStatus) (opOverflow | opInexact);
@ -1269,14 +1267,14 @@ APFloat::normalize(roundingMode rounding_mode,
/* The normal case - we were and are not denormal, and any /* The normal case - we were and are not denormal, and any
significand increment above didn't overflow. */ significand increment above didn't overflow. */
if(omsb == semantics->precision) if (omsb == semantics->precision)
return opInexact; return opInexact;
/* We have a non-zero denormal. */ /* We have a non-zero denormal. */
assert(omsb < semantics->precision); assert(omsb < semantics->precision);
/* Canonicalize zeroes. */ /* Canonicalize zeroes. */
if(omsb == 0) if (omsb == 0)
category = fcZero; category = fcZero;
/* The fcZero case is a denormal that underflowed to zero. */ /* The fcZero case is a denormal that underflowed to zero. */
@ -1324,7 +1322,7 @@ APFloat::addOrSubtractSpecials(const APFloat &rhs, bool subtract)
case convolve(fcInfinity, fcInfinity): case convolve(fcInfinity, fcInfinity):
/* Differently signed infinities can only be validly /* Differently signed infinities can only be validly
subtracted. */ subtracted. */
if(((sign ^ rhs.sign)!=0) != subtract) { if (((sign ^ rhs.sign)!=0) != subtract) {
makeNaN(); makeNaN();
return opInvalidOp; return opInvalidOp;
} }
@ -1352,7 +1350,7 @@ APFloat::addOrSubtractSignificand(const APFloat &rhs, bool subtract)
bits = exponent - rhs.exponent; bits = exponent - rhs.exponent;
/* Subtraction is more subtle than one might naively expect. */ /* Subtraction is more subtle than one might naively expect. */
if(subtract) { if (subtract) {
APFloat temp_rhs(rhs); APFloat temp_rhs(rhs);
bool reverse; bool reverse;
@ -1381,16 +1379,16 @@ APFloat::addOrSubtractSignificand(const APFloat &rhs, bool subtract)
/* Invert the lost fraction - it was on the RHS and /* Invert the lost fraction - it was on the RHS and
subtracted. */ subtracted. */
if(lost_fraction == lfLessThanHalf) if (lost_fraction == lfLessThanHalf)
lost_fraction = lfMoreThanHalf; lost_fraction = lfMoreThanHalf;
else if(lost_fraction == lfMoreThanHalf) else if (lost_fraction == lfMoreThanHalf)
lost_fraction = lfLessThanHalf; lost_fraction = lfLessThanHalf;
/* The code above is intended to ensure that no borrow is /* The code above is intended to ensure that no borrow is
necessary. */ necessary. */
assert(!carry); assert(!carry);
} else { } else {
if(bits > 0) { if (bits > 0) {
APFloat temp_rhs(rhs); APFloat temp_rhs(rhs);
lost_fraction = temp_rhs.shiftSignificandRight(bits); lost_fraction = temp_rhs.shiftSignificandRight(bits);
@ -1561,7 +1559,7 @@ APFloat::addOrSubtract(const APFloat &rhs, roundingMode rounding_mode,
fs = addOrSubtractSpecials(rhs, subtract); fs = addOrSubtractSpecials(rhs, subtract);
/* This return code means it was not a simple case. */ /* This return code means it was not a simple case. */
if(fs == opDivByZero) { if (fs == opDivByZero) {
lostFraction lost_fraction; lostFraction lost_fraction;
lost_fraction = addOrSubtractSignificand(rhs, subtract); lost_fraction = addOrSubtractSignificand(rhs, subtract);
@ -1574,8 +1572,8 @@ APFloat::addOrSubtract(const APFloat &rhs, roundingMode rounding_mode,
/* If two numbers add (exactly) to zero, IEEE 754 decrees it is a /* If two numbers add (exactly) to zero, IEEE 754 decrees it is a
positive zero unless rounding to minus infinity, except that positive zero unless rounding to minus infinity, except that
adding two like-signed zeroes gives that zero. */ adding two like-signed zeroes gives that zero. */
if(category == fcZero) { if (category == fcZero) {
if(rhs.category != fcZero || (sign == rhs.sign) == subtract) if (rhs.category != fcZero || (sign == rhs.sign) == subtract)
sign = (rounding_mode == rmTowardNegative); sign = (rounding_mode == rmTowardNegative);
} }
@ -1606,10 +1604,10 @@ APFloat::multiply(const APFloat &rhs, roundingMode rounding_mode)
sign ^= rhs.sign; sign ^= rhs.sign;
fs = multiplySpecials(rhs); fs = multiplySpecials(rhs);
if(category == fcNormal) { if (category == fcNormal) {
lostFraction lost_fraction = multiplySignificand(rhs, 0); lostFraction lost_fraction = multiplySignificand(rhs, 0);
fs = normalize(rounding_mode, lost_fraction); fs = normalize(rounding_mode, lost_fraction);
if(lost_fraction != lfExactlyZero) if (lost_fraction != lfExactlyZero)
fs = (opStatus) (fs | opInexact); fs = (opStatus) (fs | opInexact);
} }
@ -1626,10 +1624,10 @@ APFloat::divide(const APFloat &rhs, roundingMode rounding_mode)
sign ^= rhs.sign; sign ^= rhs.sign;
fs = divideSpecials(rhs); fs = divideSpecials(rhs);
if(category == fcNormal) { if (category == fcNormal) {
lostFraction lost_fraction = divideSignificand(rhs); lostFraction lost_fraction = divideSignificand(rhs);
fs = normalize(rounding_mode, lost_fraction); fs = normalize(rounding_mode, lost_fraction);
if(lost_fraction != lfExactlyZero) if (lost_fraction != lfExactlyZero)
fs = (opStatus) (fs | opInexact); fs = (opStatus) (fs | opInexact);
} }
@ -1730,20 +1728,20 @@ APFloat::fusedMultiplyAdd(const APFloat &multiplicand,
/* If and only if all arguments are normal do we need to do an /* If and only if all arguments are normal do we need to do an
extended-precision calculation. */ extended-precision calculation. */
if(category == fcNormal if (category == fcNormal &&
&& multiplicand.category == fcNormal multiplicand.category == fcNormal &&
&& addend.category == fcNormal) { addend.category == fcNormal) {
lostFraction lost_fraction; lostFraction lost_fraction;
lost_fraction = multiplySignificand(multiplicand, &addend); lost_fraction = multiplySignificand(multiplicand, &addend);
fs = normalize(rounding_mode, lost_fraction); fs = normalize(rounding_mode, lost_fraction);
if(lost_fraction != lfExactlyZero) if (lost_fraction != lfExactlyZero)
fs = (opStatus) (fs | opInexact); fs = (opStatus) (fs | opInexact);
/* If two numbers add (exactly) to zero, IEEE 754 decrees it is a /* If two numbers add (exactly) to zero, IEEE 754 decrees it is a
positive zero unless rounding to minus infinity, except that positive zero unless rounding to minus infinity, except that
adding two like-signed zeroes gives that zero. */ adding two like-signed zeroes gives that zero. */
if(category == fcZero && sign != addend.sign) if (category == fcZero && sign != addend.sign)
sign = (rounding_mode == rmTowardNegative); sign = (rounding_mode == rmTowardNegative);
} else { } else {
fs = multiplySpecials(multiplicand); fs = multiplySpecials(multiplicand);
@ -1755,7 +1753,7 @@ APFloat::fusedMultiplyAdd(const APFloat &multiplicand,
If we need to do the addition we can do so with normal If we need to do the addition we can do so with normal
precision. */ precision. */
if(fs == opOK) if (fs == opOK)
fs = addOrSubtract(addend, rounding_mode, false); fs = addOrSubtract(addend, rounding_mode, false);
} }
@ -1787,7 +1785,7 @@ APFloat::compare(const APFloat &rhs) const
case convolve(fcInfinity, fcNormal): case convolve(fcInfinity, fcNormal):
case convolve(fcInfinity, fcZero): case convolve(fcInfinity, fcZero):
case convolve(fcNormal, fcZero): case convolve(fcNormal, fcZero):
if(sign) if (sign)
return cmpLessThan; return cmpLessThan;
else else
return cmpGreaterThan; return cmpGreaterThan;
@ -1795,15 +1793,15 @@ APFloat::compare(const APFloat &rhs) const
case convolve(fcNormal, fcInfinity): case convolve(fcNormal, fcInfinity):
case convolve(fcZero, fcInfinity): case convolve(fcZero, fcInfinity):
case convolve(fcZero, fcNormal): case convolve(fcZero, fcNormal):
if(rhs.sign) if (rhs.sign)
return cmpGreaterThan; return cmpGreaterThan;
else else
return cmpLessThan; return cmpLessThan;
case convolve(fcInfinity, fcInfinity): case convolve(fcInfinity, fcInfinity):
if(sign == rhs.sign) if (sign == rhs.sign)
return cmpEqual; return cmpEqual;
else if(sign) else if (sign)
return cmpLessThan; return cmpLessThan;
else else
return cmpGreaterThan; return cmpGreaterThan;
@ -1816,8 +1814,8 @@ APFloat::compare(const APFloat &rhs) const
} }
/* Two normal numbers. Do they have the same sign? */ /* Two normal numbers. Do they have the same sign? */
if(sign != rhs.sign) { if (sign != rhs.sign) {
if(sign) if (sign)
result = cmpLessThan; result = cmpLessThan;
else else
result = cmpGreaterThan; result = cmpGreaterThan;
@ -1825,10 +1823,10 @@ APFloat::compare(const APFloat &rhs) const
/* Compare absolute values; invert result if negative. */ /* Compare absolute values; invert result if negative. */
result = compareAbsoluteValue(rhs); result = compareAbsoluteValue(rhs);
if(sign) { if (sign) {
if(result == cmpLessThan) if (result == cmpLessThan)
result = cmpGreaterThan; result = cmpGreaterThan;
else if(result == cmpGreaterThan) else if (result == cmpGreaterThan)
result = cmpLessThan; result = cmpLessThan;
} }
} }
@ -1886,7 +1884,7 @@ APFloat::convert(const fltSemantics &toSemantics,
} }
} }
if(category == fcNormal) { if (category == fcNormal) {
/* Re-interpret our bit-pattern. */ /* Re-interpret our bit-pattern. */
exponent += toSemantics.precision - semantics->precision; exponent += toSemantics.precision - semantics->precision;
semantics = &toSemantics; semantics = &toSemantics;
@ -1956,12 +1954,12 @@ APFloat::convertToSignExtendedInteger(integerPart *parts, unsigned int width,
*isExact = false; *isExact = false;
/* Handle the three special cases first. */ /* Handle the three special cases first. */
if(category == fcInfinity || category == fcNaN) if (category == fcInfinity || category == fcNaN)
return opInvalidOp; return opInvalidOp;
dstPartsCount = partCountForBits(width); dstPartsCount = partCountForBits(width);
if(category == fcZero) { if (category == fcZero) {
APInt::tcSet(parts, 0, dstPartsCount); APInt::tcSet(parts, 0, dstPartsCount);
// Negative zero can't be represented as an int. // Negative zero can't be represented as an int.
*isExact = !sign; *isExact = !sign;
@ -2004,8 +2002,8 @@ APFloat::convertToSignExtendedInteger(integerPart *parts, unsigned int width,
if (truncatedBits) { if (truncatedBits) {
lost_fraction = lostFractionThroughTruncation(src, partCount(), lost_fraction = lostFractionThroughTruncation(src, partCount(),
truncatedBits); truncatedBits);
if (lost_fraction != lfExactlyZero if (lost_fraction != lfExactlyZero &&
&& roundAwayFromZero(rounding_mode, lost_fraction, truncatedBits)) { roundAwayFromZero(rounding_mode, lost_fraction, truncatedBits)) {
if (APInt::tcIncrement(parts, dstPartsCount)) if (APInt::tcIncrement(parts, dstPartsCount))
return opInvalidOp; /* Overflow. */ return opInvalidOp; /* Overflow. */
} }
@ -2149,8 +2147,8 @@ APFloat::convertFromSignExtendedInteger(const integerPart *src,
opStatus status; opStatus status;
assertArithmeticOK(*semantics); assertArithmeticOK(*semantics);
if (isSigned if (isSigned &&
&& APInt::tcExtractBit(src, srcCount * integerPartWidth - 1)) { APInt::tcExtractBit(src, srcCount * integerPartWidth - 1)) {
integerPart *copy; integerPart *copy;
/* If we're signed and negative negate a copy. */ /* If we're signed and negative negate a copy. */
@ -2178,7 +2176,7 @@ APFloat::convertFromZeroExtendedInteger(const integerPart *parts,
APInt api = APInt(width, partCount, parts); APInt api = APInt(width, partCount, parts);
sign = false; sign = false;
if(isSigned && APInt::tcExtractBit(parts, width - 1)) { if (isSigned && APInt::tcExtractBit(parts, width - 1)) {
sign = true; sign = true;
api = -api; api = -api;
} }
@ -2209,10 +2207,10 @@ APFloat::convertFromHexadecimalString(const StringRef &s,
StringRef::iterator p = skipLeadingZeroesAndAnyDot(begin, end, &dot); StringRef::iterator p = skipLeadingZeroesAndAnyDot(begin, end, &dot);
firstSignificantDigit = p; firstSignificantDigit = p;
for(; p != end;) { for (; p != end;) {
integerPart hex_value; integerPart hex_value;
if(*p == '.') { if (*p == '.') {
assert(dot == end && "String contains multiple dots"); assert(dot == end && "String contains multiple dots");
dot = p++; dot = p++;
if (p == end) { if (p == end) {
@ -2221,7 +2219,7 @@ APFloat::convertFromHexadecimalString(const StringRef &s,
} }
hex_value = hexDigitValue(*p); hex_value = hexDigitValue(*p);
if(hex_value == -1U) { if (hex_value == -1U) {
break; break;
} }
@ -2231,13 +2229,13 @@ APFloat::convertFromHexadecimalString(const StringRef &s,
break; break;
} else { } else {
/* Store the number whilst 4-bit nibbles remain. */ /* Store the number whilst 4-bit nibbles remain. */
if(bitPos) { if (bitPos) {
bitPos -= 4; bitPos -= 4;
hex_value <<= bitPos % integerPartWidth; hex_value <<= bitPos % integerPartWidth;
significand[bitPos / integerPartWidth] |= hex_value; significand[bitPos / integerPartWidth] |= hex_value;
} else { } else {
lost_fraction = trailingHexadecimalFraction(p, end, hex_value); lost_fraction = trailingHexadecimalFraction(p, end, hex_value);
while(p != end && hexDigitValue(*p) != -1U) while (p != end && hexDigitValue(*p) != -1U)
p++; p++;
break; break;
} }
@ -2251,7 +2249,7 @@ APFloat::convertFromHexadecimalString(const StringRef &s,
assert((dot == end || p - begin != 1) && "Significand has no digits"); assert((dot == end || p - begin != 1) && "Significand has no digits");
/* Ignore the exponent if we are zero. */ /* Ignore the exponent if we are zero. */
if(p != firstSignificantDigit) { if (p != firstSignificantDigit) {
int expAdjustment; int expAdjustment;
/* Implicit hexadecimal point? */ /* Implicit hexadecimal point? */
@ -2261,7 +2259,7 @@ APFloat::convertFromHexadecimalString(const StringRef &s,
/* Calculate the exponent adjustment implicit in the number of /* Calculate the exponent adjustment implicit in the number of
significant digits. */ significant digits. */
expAdjustment = static_cast<int>(dot - firstSignificantDigit); expAdjustment = static_cast<int>(dot - firstSignificantDigit);
if(expAdjustment < 0) if (expAdjustment < 0)
expAdjustment++; expAdjustment++;
expAdjustment = expAdjustment * 4 - 1; expAdjustment = expAdjustment * 4 - 1;
@ -2287,8 +2285,8 @@ APFloat::roundSignificandWithExponent(const integerPart *decSigParts,
integerPart pow5Parts[maxPowerOfFiveParts]; integerPart pow5Parts[maxPowerOfFiveParts];
bool isNearest; bool isNearest;
isNearest = (rounding_mode == rmNearestTiesToEven isNearest = (rounding_mode == rmNearestTiesToEven ||
|| rounding_mode == rmNearestTiesToAway); rounding_mode == rmNearestTiesToAway);
parts = partCountForBits(semantics->precision + 11); parts = partCountForBits(semantics->precision + 11);
@ -2482,13 +2480,13 @@ APFloat::convertFromString(const StringRef &str, roundingMode rounding_mode)
StringRef::iterator p = str.begin(); StringRef::iterator p = str.begin();
size_t slen = str.size(); size_t slen = str.size();
sign = *p == '-' ? 1 : 0; sign = *p == '-' ? 1 : 0;
if(*p == '-' || *p == '+') { if (*p == '-' || *p == '+') {
p++; p++;
slen--; slen--;
assert(slen && "String has no digits"); assert(slen && "String has no digits");
} }
if(slen >= 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) { if (slen >= 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
assert(slen - 2 && "Invalid string"); assert(slen - 2 && "Invalid string");
return convertFromHexadecimalString(StringRef(p + 2, slen - 2), return convertFromHexadecimalString(StringRef(p + 2, slen - 2),
rounding_mode); rounding_mode);
@ -3217,8 +3215,8 @@ APFloat APFloat::getLargest(const fltSemantics &Sem, bool Negative) {
significand[i] = ~((integerPart) 0); significand[i] = ~((integerPart) 0);
// ...and then clear the top bits for internal consistency. // ...and then clear the top bits for internal consistency.
significand[N-1] significand[N-1] &=
&= (((integerPart) 1) << ((Sem.precision % integerPartWidth) - 1)) - 1; (((integerPart) 1) << ((Sem.precision % integerPartWidth) - 1)) - 1;
return Val; return Val;
} }
@ -3247,8 +3245,8 @@ APFloat APFloat::getSmallestNormalized(const fltSemantics &Sem, bool Negative) {
Val.exponent = Sem.minExponent; Val.exponent = Sem.minExponent;
Val.zeroSignificand(); Val.zeroSignificand();
Val.significandParts()[partCountForBits(Sem.precision)-1] Val.significandParts()[partCountForBits(Sem.precision)-1] |=
|= (((integerPart) 1) << ((Sem.precision % integerPartWidth) - 1)); (((integerPart) 1) << ((Sem.precision % integerPartWidth) - 1));
return Val; return Val;
} }

View File

@ -702,15 +702,14 @@ static inline uint32_t hashword(const uint64_t *k64, size_t length)
a = b = c = 0xdeadbeef + (((uint32_t)length)<<2); a = b = c = 0xdeadbeef + (((uint32_t)length)<<2);
/*------------------------------------------------- handle most of the key */ /*------------------------------------------------- handle most of the key */
while (length > 3) while (length > 3) {
{ a += k[0];
a += k[0]; b += k[1];
b += k[1]; c += k[2];
c += k[2]; mix(a,b,c);
mix(a,b,c); length -= 3;
length -= 3; k += 3;
k += 3; }
}
/*------------------------------------------- handle the last 3 uint32_t's */ /*------------------------------------------- handle the last 3 uint32_t's */
switch (length) { /* all the case statements fall through */ switch (length) { /* all the case statements fall through */
@ -2065,8 +2064,8 @@ void APInt::fromString(unsigned numbits, const StringRef& str, uint8_t radix) {
assert((slen <= numbits || radix != 2) && "Insufficient bit width"); assert((slen <= numbits || radix != 2) && "Insufficient bit width");
assert(((slen-1)*3 <= numbits || radix != 8) && "Insufficient bit width"); assert(((slen-1)*3 <= numbits || radix != 8) && "Insufficient bit width");
assert(((slen-1)*4 <= numbits || radix != 16) && "Insufficient bit width"); assert(((slen-1)*4 <= numbits || radix != 16) && "Insufficient bit width");
assert((((slen-1)*64)/22 <= numbits || radix != 10) assert((((slen-1)*64)/22 <= numbits || radix != 10) &&
&& "Insufficient bit width"); "Insufficient bit width");
// Allocate memory // Allocate memory
if (!isSingleWord()) if (!isSingleWord())
@ -2229,7 +2228,7 @@ namespace {
static inline integerPart static inline integerPart
lowBitMask(unsigned int bits) lowBitMask(unsigned int bits)
{ {
assert (bits != 0 && bits <= integerPartWidth); assert(bits != 0 && bits <= integerPartWidth);
return ~(integerPart) 0 >> (integerPartWidth - bits); return ~(integerPart) 0 >> (integerPartWidth - bits);
} }
@ -2306,10 +2305,10 @@ APInt::tcSet(integerPart *dst, integerPart part, unsigned int parts)
{ {
unsigned int i; unsigned int i;
assert (parts > 0); assert(parts > 0);
dst[0] = part; dst[0] = part;
for(i = 1; i < parts; i++) for (i = 1; i < parts; i++)
dst[i] = 0; dst[i] = 0;
} }
@ -2319,7 +2318,7 @@ APInt::tcAssign(integerPart *dst, const integerPart *src, unsigned int parts)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < parts; i++) for (i = 0; i < parts; i++)
dst[i] = src[i]; dst[i] = src[i];
} }
@ -2329,7 +2328,7 @@ APInt::tcIsZero(const integerPart *src, unsigned int parts)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < parts; i++) for (i = 0; i < parts; i++)
if (src[i]) if (src[i])
return false; return false;
@ -2340,8 +2339,8 @@ APInt::tcIsZero(const integerPart *src, unsigned int parts)
int int
APInt::tcExtractBit(const integerPart *parts, unsigned int bit) APInt::tcExtractBit(const integerPart *parts, unsigned int bit)
{ {
return(parts[bit / integerPartWidth] return (parts[bit / integerPartWidth] &
& ((integerPart) 1 << bit % integerPartWidth)) != 0; ((integerPart) 1 << bit % integerPartWidth)) != 0;
} }
/* Set the given bit of a bignum. */ /* Set the given bit of a bignum. */
@ -2366,7 +2365,7 @@ APInt::tcLSB(const integerPart *parts, unsigned int n)
{ {
unsigned int i, lsb; unsigned int i, lsb;
for(i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (parts[i] != 0) { if (parts[i] != 0) {
lsb = partLSB(parts[i]); lsb = partLSB(parts[i]);
@ -2385,13 +2384,13 @@ APInt::tcMSB(const integerPart *parts, unsigned int n)
unsigned int msb; unsigned int msb;
do { do {
--n; --n;
if (parts[n] != 0) { if (parts[n] != 0) {
msb = partMSB(parts[n]); msb = partMSB(parts[n]);
return msb + n * integerPartWidth; return msb + n * integerPartWidth;
} }
} while (n); } while (n);
return -1U; return -1U;
@ -2408,7 +2407,7 @@ APInt::tcExtract(integerPart *dst, unsigned int dstCount,const integerPart *src,
unsigned int firstSrcPart, dstParts, shift, n; unsigned int firstSrcPart, dstParts, shift, n;
dstParts = (srcBits + integerPartWidth - 1) / integerPartWidth; dstParts = (srcBits + integerPartWidth - 1) / integerPartWidth;
assert (dstParts <= dstCount); assert(dstParts <= dstCount);
firstSrcPart = srcLSB / integerPartWidth; firstSrcPart = srcLSB / integerPartWidth;
tcAssign (dst, src + firstSrcPart, dstParts); tcAssign (dst, src + firstSrcPart, dstParts);
@ -2443,7 +2442,7 @@ APInt::tcAdd(integerPart *dst, const integerPart *rhs,
assert(c <= 1); assert(c <= 1);
for(i = 0; i < parts; i++) { for (i = 0; i < parts; i++) {
integerPart l; integerPart l;
l = dst[i]; l = dst[i];
@ -2468,7 +2467,7 @@ APInt::tcSubtract(integerPart *dst, const integerPart *rhs,
assert(c <= 1); assert(c <= 1);
for(i = 0; i < parts; i++) { for (i = 0; i < parts; i++) {
integerPart l; integerPart l;
l = dst[i]; l = dst[i];
@ -2518,7 +2517,7 @@ APInt::tcMultiplyPart(integerPart *dst, const integerPart *src,
/* N loops; minimum of dstParts and srcParts. */ /* N loops; minimum of dstParts and srcParts. */
n = dstParts < srcParts ? dstParts: srcParts; n = dstParts < srcParts ? dstParts: srcParts;
for(i = 0; i < n; i++) { for (i = 0; i < n; i++) {
integerPart low, mid, high, srcPart; integerPart low, mid, high, srcPart;
/* [ LOW, HIGH ] = MULTIPLIER * SRC[i] + DST[i] + CARRY. /* [ LOW, HIGH ] = MULTIPLIER * SRC[i] + DST[i] + CARRY.
@ -2583,7 +2582,7 @@ APInt::tcMultiplyPart(integerPart *dst, const integerPart *src,
non-zero. This is true if any remaining src parts are non-zero non-zero. This is true if any remaining src parts are non-zero
and the multiplier is non-zero. */ and the multiplier is non-zero. */
if (multiplier) if (multiplier)
for(; i < srcParts; i++) for (; i < srcParts; i++)
if (src[i]) if (src[i])
return 1; return 1;
@ -2608,7 +2607,7 @@ APInt::tcMultiply(integerPart *dst, const integerPart *lhs,
overflow = 0; overflow = 0;
tcSet(dst, 0, parts); tcSet(dst, 0, parts);
for(i = 0; i < parts; i++) for (i = 0; i < parts; i++)
overflow |= tcMultiplyPart(&dst[i], lhs, rhs[i], 0, parts, overflow |= tcMultiplyPart(&dst[i], lhs, rhs[i], 0, parts,
parts - i, true); parts - i, true);
@ -2634,7 +2633,7 @@ APInt::tcFullMultiply(integerPart *dst, const integerPart *lhs,
tcSet(dst, 0, rhsParts); tcSet(dst, 0, rhsParts);
for(n = 0; n < lhsParts; n++) for (n = 0; n < lhsParts; n++)
tcMultiplyPart(&dst[n], rhs, lhs[n], 0, rhsParts, rhsParts + 1, true); tcMultiplyPart(&dst[n], rhs, lhs[n], 0, rhsParts, rhsParts + 1, true);
n = lhsParts + rhsParts; n = lhsParts + rhsParts;
@ -2678,7 +2677,7 @@ APInt::tcDivide(integerPart *lhs, const integerPart *rhs,
/* Loop, subtracting SRHS if REMAINDER is greater and adding that to /* Loop, subtracting SRHS if REMAINDER is greater and adding that to
the total. */ the total. */
for(;;) { for (;;) {
int compare; int compare;
compare = tcCompare(remainder, srhs, parts); compare = tcCompare(remainder, srhs, parts);
@ -2746,7 +2745,7 @@ APInt::tcShiftRight(integerPart *dst, unsigned int parts, unsigned int count)
/* Perform the shift. This leaves the most significant COUNT bits /* Perform the shift. This leaves the most significant COUNT bits
of the result at zero. */ of the result at zero. */
for(i = 0; i < parts; i++) { for (i = 0; i < parts; i++) {
integerPart part; integerPart part;
if (i + jump >= parts) { if (i + jump >= parts) {
@ -2771,7 +2770,7 @@ APInt::tcAnd(integerPart *dst, const integerPart *rhs, unsigned int parts)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < parts; i++) for (i = 0; i < parts; i++)
dst[i] &= rhs[i]; dst[i] &= rhs[i];
} }
@ -2781,7 +2780,7 @@ APInt::tcOr(integerPart *dst, const integerPart *rhs, unsigned int parts)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < parts; i++) for (i = 0; i < parts; i++)
dst[i] |= rhs[i]; dst[i] |= rhs[i];
} }
@ -2791,7 +2790,7 @@ APInt::tcXor(integerPart *dst, const integerPart *rhs, unsigned int parts)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < parts; i++) for (i = 0; i < parts; i++)
dst[i] ^= rhs[i]; dst[i] ^= rhs[i];
} }
@ -2801,7 +2800,7 @@ APInt::tcComplement(integerPart *dst, unsigned int parts)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < parts; i++) for (i = 0; i < parts; i++)
dst[i] = ~dst[i]; dst[i] = ~dst[i];
} }
@ -2830,7 +2829,7 @@ APInt::tcIncrement(integerPart *dst, unsigned int parts)
{ {
unsigned int i; unsigned int i;
for(i = 0; i < parts; i++) for (i = 0; i < parts; i++)
if (++dst[i] != 0) if (++dst[i] != 0)
break; break;

View File

@ -676,8 +676,8 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
<< " positional arguments: See: " << argv[0] << " -help\n"; << " positional arguments: See: " << argv[0] << " -help\n";
ErrorParsing = true; ErrorParsing = true;
} else if (!HasUnlimitedPositionals } else if (!HasUnlimitedPositionals &&
&& PositionalVals.size() > PositionalOpts.size()) { PositionalVals.size() > PositionalOpts.size()) {
errs() << ProgramName errs() << ProgramName
<< ": Too many positional arguments specified!\n" << ": Too many positional arguments specified!\n"
<< "Can specify at most " << PositionalOpts.size() << "Can specify at most " << PositionalOpts.size()

View File

@ -64,8 +64,7 @@ DebugOnly("debug-only", cl::desc("Enable a specific type of debug output"),
cl::location(DebugOnlyOptLoc), cl::ValueRequired); cl::location(DebugOnlyOptLoc), cl::ValueRequired);
// Signal handlers - dump debug output on termination. // Signal handlers - dump debug output on termination.
static void debug_user_sig_handler(void *Cookie) static void debug_user_sig_handler(void *Cookie) {
{
// This is a bit sneaky. Since this is under #ifndef NDEBUG, we // This is a bit sneaky. Since this is under #ifndef NDEBUG, we
// know that debug mode is enabled and dbgs() really is a // know that debug mode is enabled and dbgs() really is a
// circular_raw_ostream. If NDEBUG is defined, then dbgs() == // circular_raw_ostream. If NDEBUG is defined, then dbgs() ==

View File

@ -71,4 +71,3 @@ void llvm_unreachable_internal(const char *msg, const char *file,
abort(); abort();
} }
} }

View File

@ -418,14 +418,14 @@ raw_fd_ostream::~raw_fd_ostream() {
void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
assert (FD >= 0 && "File already closed."); assert(FD >= 0 && "File already closed.");
pos += Size; pos += Size;
if (::write(FD, Ptr, Size) != (ssize_t) Size) if (::write(FD, Ptr, Size) != (ssize_t) Size)
error_detected(); error_detected();
} }
void raw_fd_ostream::close() { void raw_fd_ostream::close() {
assert (ShouldClose); assert(ShouldClose);
ShouldClose = false; ShouldClose = false;
flush(); flush();
if (::close(FD) != 0) if (::close(FD) != 0)