mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 06:00:28 +00:00
[APInt] Reformat tc functions to put opening curly braces on the end of the previous line. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298900 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b68e2b67cc
commit
cc9aca6616
@ -2362,49 +2362,37 @@ static_assert(integerPartWidth % 2 == 0, "Part width must be divisible by 2!");
|
||||
|
||||
/* Returns the integer part with the least significant BITS set.
|
||||
BITS cannot be zero. */
|
||||
static inline integerPart
|
||||
lowBitMask(unsigned bits)
|
||||
{
|
||||
static inline integerPart lowBitMask(unsigned bits) {
|
||||
assert(bits != 0 && bits <= integerPartWidth);
|
||||
|
||||
return ~(integerPart) 0 >> (integerPartWidth - bits);
|
||||
}
|
||||
|
||||
/* Returns the value of the lower half of PART. */
|
||||
static inline integerPart
|
||||
lowHalf(integerPart part)
|
||||
{
|
||||
static inline integerPart lowHalf(integerPart part) {
|
||||
return part & lowBitMask(integerPartWidth / 2);
|
||||
}
|
||||
|
||||
/* Returns the value of the upper half of PART. */
|
||||
static inline integerPart
|
||||
highHalf(integerPart part)
|
||||
{
|
||||
static inline integerPart highHalf(integerPart part) {
|
||||
return part >> (integerPartWidth / 2);
|
||||
}
|
||||
|
||||
/* Returns the bit number of the most significant set bit of a part.
|
||||
If the input number has no bits set -1U is returned. */
|
||||
static unsigned
|
||||
partMSB(integerPart value)
|
||||
{
|
||||
static unsigned partMSB(integerPart value) {
|
||||
return findLastSet(value, ZB_Max);
|
||||
}
|
||||
|
||||
/* Returns the bit number of the least significant set bit of a
|
||||
part. If the input number has no bits set -1U is returned. */
|
||||
static unsigned
|
||||
partLSB(integerPart value)
|
||||
{
|
||||
static unsigned partLSB(integerPart value) {
|
||||
return findFirstSet(value, ZB_Max);
|
||||
}
|
||||
|
||||
/* Sets the least significant part of a bignum to the input value, and
|
||||
zeroes out higher parts. */
|
||||
void
|
||||
APInt::tcSet(integerPart *dst, integerPart part, unsigned parts)
|
||||
{
|
||||
void APInt::tcSet(integerPart *dst, integerPart part, unsigned parts) {
|
||||
assert(parts > 0);
|
||||
|
||||
dst[0] = part;
|
||||
@ -2413,17 +2401,13 @@ APInt::tcSet(integerPart *dst, integerPart part, unsigned parts)
|
||||
}
|
||||
|
||||
/* Assign one bignum to another. */
|
||||
void
|
||||
APInt::tcAssign(integerPart *dst, const integerPart *src, unsigned parts)
|
||||
{
|
||||
void APInt::tcAssign(integerPart *dst, const integerPart *src, unsigned parts) {
|
||||
for (unsigned i = 0; i < parts; i++)
|
||||
dst[i] = src[i];
|
||||
}
|
||||
|
||||
/* Returns true if a bignum is zero, false otherwise. */
|
||||
bool
|
||||
APInt::tcIsZero(const integerPart *src, unsigned parts)
|
||||
{
|
||||
bool APInt::tcIsZero(const integerPart *src, unsigned parts) {
|
||||
for (unsigned i = 0; i < parts; i++)
|
||||
if (src[i])
|
||||
return false;
|
||||
@ -2432,33 +2416,25 @@ APInt::tcIsZero(const integerPart *src, unsigned parts)
|
||||
}
|
||||
|
||||
/* Extract the given bit of a bignum; returns 0 or 1. */
|
||||
int
|
||||
APInt::tcExtractBit(const integerPart *parts, unsigned bit)
|
||||
{
|
||||
int APInt::tcExtractBit(const integerPart *parts, unsigned bit) {
|
||||
return (parts[bit / integerPartWidth] &
|
||||
((integerPart) 1 << bit % integerPartWidth)) != 0;
|
||||
}
|
||||
|
||||
/* Set the given bit of a bignum. */
|
||||
void
|
||||
APInt::tcSetBit(integerPart *parts, unsigned bit)
|
||||
{
|
||||
void APInt::tcSetBit(integerPart *parts, unsigned bit) {
|
||||
parts[bit / integerPartWidth] |= (integerPart) 1 << (bit % integerPartWidth);
|
||||
}
|
||||
|
||||
/* Clears the given bit of a bignum. */
|
||||
void
|
||||
APInt::tcClearBit(integerPart *parts, unsigned bit)
|
||||
{
|
||||
void APInt::tcClearBit(integerPart *parts, unsigned bit) {
|
||||
parts[bit / integerPartWidth] &=
|
||||
~((integerPart) 1 << (bit % integerPartWidth));
|
||||
}
|
||||
|
||||
/* Returns the bit number of the least significant set bit of a
|
||||
number. If the input number has no bits set -1U is returned. */
|
||||
unsigned
|
||||
APInt::tcLSB(const integerPart *parts, unsigned n)
|
||||
{
|
||||
unsigned APInt::tcLSB(const integerPart *parts, unsigned n) {
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
if (parts[i] != 0) {
|
||||
unsigned lsb = partLSB(parts[i]);
|
||||
@ -2472,9 +2448,7 @@ APInt::tcLSB(const integerPart *parts, unsigned n)
|
||||
|
||||
/* Returns the bit number of the most significant set bit of a number.
|
||||
If the input number has no bits set -1U is returned. */
|
||||
unsigned
|
||||
APInt::tcMSB(const integerPart *parts, unsigned n)
|
||||
{
|
||||
unsigned APInt::tcMSB(const integerPart *parts, unsigned n) {
|
||||
do {
|
||||
--n;
|
||||
|
||||
@ -2493,9 +2467,8 @@ APInt::tcMSB(const integerPart *parts, unsigned n)
|
||||
the least significant bit of DST. All high bits above srcBITS in
|
||||
DST are zero-filled. */
|
||||
void
|
||||
APInt::tcExtract(integerPart *dst, unsigned dstCount,const integerPart *src,
|
||||
unsigned srcBits, unsigned srcLSB)
|
||||
{
|
||||
APInt::tcExtract(integerPart *dst, unsigned dstCount, const integerPart *src,
|
||||
unsigned srcBits, unsigned srcLSB) {
|
||||
unsigned dstParts = (srcBits + integerPartWidth - 1) / integerPartWidth;
|
||||
assert(dstParts <= dstCount);
|
||||
|
||||
@ -2524,10 +2497,8 @@ APInt::tcExtract(integerPart *dst, unsigned dstCount,const integerPart *src,
|
||||
}
|
||||
|
||||
/* DST += RHS + C where C is zero or one. Returns the carry flag. */
|
||||
integerPart
|
||||
APInt::tcAdd(integerPart *dst, const integerPart *rhs,
|
||||
integerPart c, unsigned parts)
|
||||
{
|
||||
integerPart APInt::tcAdd(integerPart *dst, const integerPart *rhs,
|
||||
integerPart c, unsigned parts) {
|
||||
assert(c <= 1);
|
||||
|
||||
for (unsigned i = 0; i < parts; i++) {
|
||||
@ -2547,9 +2518,8 @@ APInt::tcAdd(integerPart *dst, const integerPart *rhs,
|
||||
}
|
||||
|
||||
/* DST -= RHS + C where C is zero or one. Returns the carry flag. */
|
||||
integerPart
|
||||
APInt::tcSubtract(integerPart *dst, const integerPart *rhs,
|
||||
integerPart c, unsigned parts)
|
||||
integerPart APInt::tcSubtract(integerPart *dst, const integerPart *rhs,
|
||||
integerPart c, unsigned parts)
|
||||
{
|
||||
assert(c <= 1);
|
||||
|
||||
@ -2570,9 +2540,7 @@ APInt::tcSubtract(integerPart *dst, const integerPart *rhs,
|
||||
}
|
||||
|
||||
/* Negate a bignum in-place. */
|
||||
void
|
||||
APInt::tcNegate(integerPart *dst, unsigned parts)
|
||||
{
|
||||
void APInt::tcNegate(integerPart *dst, unsigned parts) {
|
||||
tcComplement(dst, parts);
|
||||
tcIncrement(dst, parts);
|
||||
}
|
||||
@ -2588,12 +2556,10 @@ APInt::tcNegate(integerPart *dst, unsigned parts)
|
||||
DSTPARTS parts of the result, and if all of the omitted higher
|
||||
parts were zero return zero, otherwise overflow occurred and
|
||||
return one. */
|
||||
int
|
||||
APInt::tcMultiplyPart(integerPart *dst, const integerPart *src,
|
||||
integerPart multiplier, integerPart carry,
|
||||
unsigned srcParts, unsigned dstParts,
|
||||
bool add)
|
||||
{
|
||||
int APInt::tcMultiplyPart(integerPart *dst, const integerPart *src,
|
||||
integerPart multiplier, integerPart carry,
|
||||
unsigned srcParts, unsigned dstParts,
|
||||
bool add) {
|
||||
/* Otherwise our writes of DST kill our later reads of SRC. */
|
||||
assert(dst <= src || dst >= src + srcParts);
|
||||
assert(dstParts <= srcParts + 1);
|
||||
@ -2615,7 +2581,7 @@ APInt::tcMultiplyPart(integerPart *dst, const integerPart *src,
|
||||
|
||||
srcPart = src[i];
|
||||
|
||||
if (multiplier == 0 || srcPart == 0) {
|
||||
if (multiplier == 0 || srcPart == 0) {
|
||||
low = carry;
|
||||
high = 0;
|
||||
} else {
|
||||
@ -2680,10 +2646,8 @@ APInt::tcMultiplyPart(integerPart *dst, const integerPart *src,
|
||||
is filled with the least significant parts of the result. Returns
|
||||
one if overflow occurred, otherwise zero. DST must be disjoint
|
||||
from both operands. */
|
||||
int
|
||||
APInt::tcMultiply(integerPart *dst, const integerPart *lhs,
|
||||
const integerPart *rhs, unsigned parts)
|
||||
{
|
||||
int APInt::tcMultiply(integerPart *dst, const integerPart *lhs,
|
||||
const integerPart *rhs, unsigned parts) {
|
||||
assert(dst != lhs && dst != rhs);
|
||||
|
||||
int overflow = 0;
|
||||
@ -2700,11 +2664,9 @@ APInt::tcMultiply(integerPart *dst, const integerPart *lhs,
|
||||
operands. No overflow occurs. DST must be disjoint from both
|
||||
operands. Returns the number of parts required to hold the
|
||||
result. */
|
||||
unsigned
|
||||
APInt::tcFullMultiply(integerPart *dst, const integerPart *lhs,
|
||||
const integerPart *rhs, unsigned lhsParts,
|
||||
unsigned rhsParts)
|
||||
{
|
||||
unsigned APInt::tcFullMultiply(integerPart *dst, const integerPart *lhs,
|
||||
const integerPart *rhs, unsigned lhsParts,
|
||||
unsigned rhsParts) {
|
||||
/* Put the narrower number on the LHS for less loops below. */
|
||||
if (lhsParts > rhsParts) {
|
||||
return tcFullMultiply (dst, rhs, lhs, rhsParts, lhsParts);
|
||||
@ -2732,11 +2694,9 @@ APInt::tcFullMultiply(integerPart *dst, const integerPart *lhs,
|
||||
use by the routine; its contents need not be initialized and are
|
||||
destroyed. LHS, REMAINDER and SCRATCH must be distinct.
|
||||
*/
|
||||
int
|
||||
APInt::tcDivide(integerPart *lhs, const integerPart *rhs,
|
||||
integerPart *remainder, integerPart *srhs,
|
||||
unsigned parts)
|
||||
{
|
||||
int APInt::tcDivide(integerPart *lhs, const integerPart *rhs,
|
||||
integerPart *remainder, integerPart *srhs,
|
||||
unsigned parts) {
|
||||
assert(lhs != remainder && lhs != srhs && remainder != srhs);
|
||||
|
||||
unsigned shiftCount = tcMSB(rhs, parts) + 1;
|
||||
@ -2778,9 +2738,7 @@ APInt::tcDivide(integerPart *lhs, const integerPart *rhs,
|
||||
|
||||
/* Shift a bignum left COUNT bits in-place. Shifted in bits are zero.
|
||||
There are no restrictions on COUNT. */
|
||||
void
|
||||
APInt::tcShiftLeft(integerPart *dst, unsigned parts, unsigned count)
|
||||
{
|
||||
void APInt::tcShiftLeft(integerPart *dst, unsigned parts, unsigned count) {
|
||||
if (count) {
|
||||
/* Jump is the inter-part jump; shift is is intra-part shift. */
|
||||
unsigned jump = count / integerPartWidth;
|
||||
@ -2810,9 +2768,7 @@ APInt::tcShiftLeft(integerPart *dst, unsigned parts, unsigned count)
|
||||
|
||||
/* Shift a bignum right COUNT bits in-place. Shifted in bits are
|
||||
zero. There are no restrictions on COUNT. */
|
||||
void
|
||||
APInt::tcShiftRight(integerPart *dst, unsigned parts, unsigned count)
|
||||
{
|
||||
void APInt::tcShiftRight(integerPart *dst, unsigned parts, unsigned count) {
|
||||
if (count) {
|
||||
/* Jump is the inter-part jump; shift is is intra-part shift. */
|
||||
unsigned jump = count / integerPartWidth;
|
||||
@ -2840,42 +2796,32 @@ APInt::tcShiftRight(integerPart *dst, unsigned parts, unsigned count)
|
||||
}
|
||||
|
||||
/* Bitwise and of two bignums. */
|
||||
void
|
||||
APInt::tcAnd(integerPart *dst, const integerPart *rhs, unsigned parts)
|
||||
{
|
||||
void APInt::tcAnd(integerPart *dst, const integerPart *rhs, unsigned parts) {
|
||||
for (unsigned i = 0; i < parts; i++)
|
||||
dst[i] &= rhs[i];
|
||||
}
|
||||
|
||||
/* Bitwise inclusive or of two bignums. */
|
||||
void
|
||||
APInt::tcOr(integerPart *dst, const integerPart *rhs, unsigned parts)
|
||||
{
|
||||
void APInt::tcOr(integerPart *dst, const integerPart *rhs, unsigned parts) {
|
||||
for (unsigned i = 0; i < parts; i++)
|
||||
dst[i] |= rhs[i];
|
||||
}
|
||||
|
||||
/* Bitwise exclusive or of two bignums. */
|
||||
void
|
||||
APInt::tcXor(integerPart *dst, const integerPart *rhs, unsigned parts)
|
||||
{
|
||||
void APInt::tcXor(integerPart *dst, const integerPart *rhs, unsigned parts) {
|
||||
for (unsigned i = 0; i < parts; i++)
|
||||
dst[i] ^= rhs[i];
|
||||
}
|
||||
|
||||
/* Complement a bignum in-place. */
|
||||
void
|
||||
APInt::tcComplement(integerPart *dst, unsigned parts)
|
||||
{
|
||||
void APInt::tcComplement(integerPart *dst, unsigned parts) {
|
||||
for (unsigned i = 0; i < parts; i++)
|
||||
dst[i] = ~dst[i];
|
||||
}
|
||||
|
||||
/* Comparison (unsigned) of two bignums. */
|
||||
int
|
||||
APInt::tcCompare(const integerPart *lhs, const integerPart *rhs,
|
||||
unsigned parts)
|
||||
{
|
||||
int APInt::tcCompare(const integerPart *lhs, const integerPart *rhs,
|
||||
unsigned parts) {
|
||||
while (parts) {
|
||||
parts--;
|
||||
if (lhs[parts] == rhs[parts])
|
||||
@ -2891,9 +2837,7 @@ APInt::tcCompare(const integerPart *lhs, const integerPart *rhs,
|
||||
}
|
||||
|
||||
/* Increment a bignum in-place, return the carry flag. */
|
||||
integerPart
|
||||
APInt::tcIncrement(integerPart *dst, unsigned parts)
|
||||
{
|
||||
integerPart APInt::tcIncrement(integerPart *dst, unsigned parts) {
|
||||
unsigned i;
|
||||
for (i = 0; i < parts; i++)
|
||||
if (++dst[i] != 0)
|
||||
@ -2903,8 +2847,7 @@ APInt::tcIncrement(integerPart *dst, unsigned parts)
|
||||
}
|
||||
|
||||
/* Decrement a bignum in-place, return the borrow flag. */
|
||||
integerPart
|
||||
APInt::tcDecrement(integerPart *dst, unsigned parts) {
|
||||
integerPart APInt::tcDecrement(integerPart *dst, unsigned parts) {
|
||||
for (unsigned i = 0; i < parts; i++) {
|
||||
// If the current word is non-zero, then the decrement has no effect on the
|
||||
// higher-order words of the integer and no borrow can occur. Exit early.
|
||||
@ -2918,10 +2861,8 @@ APInt::tcDecrement(integerPart *dst, unsigned parts) {
|
||||
|
||||
/* Set the least significant BITS bits of a bignum, clear the
|
||||
rest. */
|
||||
void
|
||||
APInt::tcSetLeastSignificantBits(integerPart *dst, unsigned parts,
|
||||
unsigned bits)
|
||||
{
|
||||
void APInt::tcSetLeastSignificantBits(integerPart *dst, unsigned parts,
|
||||
unsigned bits) {
|
||||
unsigned i = 0;
|
||||
while (bits > integerPartWidth) {
|
||||
dst[i++] = ~(integerPart) 0;
|
||||
|
Loading…
Reference in New Issue
Block a user