llvm.org GIT mirror llvm / 0bdb158
[APInt] Use 'unsigned' instead of 'unsigned int' in the interface to the APInt tc functions. This is more consistent with the rest of the codebase. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298897 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 3 years ago
2 changed file(s) with 62 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
16421642
16431643 /// Sets the least significant part of a bignum to the input value, and zeroes
16441644 /// out higher parts.
1645 static void tcSet(integerPart *, integerPart, unsigned int);
1645 static void tcSet(integerPart *, integerPart, unsigned);
16461646
16471647 /// Assign one bignum to another.
1648 static void tcAssign(integerPart *, const integerPart *, unsigned int);
1648 static void tcAssign(integerPart *, const integerPart *, unsigned);
16491649
16501650 /// Returns true if a bignum is zero, false otherwise.
1651 static bool tcIsZero(const integerPart *, unsigned int);
1651 static bool tcIsZero(const integerPart *, unsigned);
16521652
16531653 /// Extract the given bit of a bignum; returns 0 or 1. Zero-based.
1654 static int tcExtractBit(const integerPart *, unsigned int bit);
1654 static int tcExtractBit(const integerPart *, unsigned bit);
16551655
16561656 /// Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to
16571657 /// DST, of dstCOUNT parts, such that the bit srcLSB becomes the least
16581658 /// significant bit of DST. All high bits above srcBITS in DST are
16591659 /// zero-filled.
1660 static void tcExtract(integerPart *, unsigned int dstCount,
1661 const integerPart *, unsigned int srcBits,
1662 unsigned int srcLSB);
1660 static void tcExtract(integerPart *, unsigned dstCount,
1661 const integerPart *, unsigned srcBits,
1662 unsigned srcLSB);
16631663
16641664 /// Set the given bit of a bignum. Zero-based.
1665 static void tcSetBit(integerPart *, unsigned int bit);
1665 static void tcSetBit(integerPart *, unsigned bit);
16661666
16671667 /// Clear the given bit of a bignum. Zero-based.
1668 static void tcClearBit(integerPart *, unsigned int bit);
1668 static void tcClearBit(integerPart *, unsigned bit);
16691669
16701670 /// Returns the bit number of the least or most significant set bit of a
16711671 /// number. If the input number has no bits set -1U is returned.
1672 static unsigned int tcLSB(const integerPart *, unsigned int);
1673 static unsigned int tcMSB(const integerPart *parts, unsigned int n);
1672 static unsigned tcLSB(const integerPart *, unsigned n);
1673 static unsigned tcMSB(const integerPart *parts, unsigned n);
16741674
16751675 /// Negate a bignum in-place.
1676 static void tcNegate(integerPart *, unsigned int);
1676 static void tcNegate(integerPart *, unsigned);
16771677
16781678 /// DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
16791679 static integerPart tcAdd(integerPart *, const integerPart *,
16951695 /// otherwise overflow occurred and return one.
16961696 static int tcMultiplyPart(integerPart *dst, const integerPart *src,
16971697 integerPart multiplier, integerPart carry,
1698 unsigned int srcParts, unsigned int dstParts,
1698 unsigned srcParts, unsigned dstParts,
16991699 bool add);
17001700
17011701 /// DST = LHS * RHS, where DST has the same width as the operands and is
17081708 /// DST = LHS * RHS, where DST has width the sum of the widths of the
17091709 /// operands. No overflow occurs. DST must be disjoint from both
17101710 /// operands. Returns the number of parts required to hold the result.
1711 static unsigned int tcFullMultiply(integerPart *, const integerPart *,
1712 const integerPart *, unsigned, unsigned);
1711 static unsigned tcFullMultiply(integerPart *, const integerPart *,
1712 const integerPart *, unsigned, unsigned);
17131713
17141714 /// If RHS is zero LHS and REMAINDER are left unchanged, return one.
17151715 /// Otherwise set LHS to LHS / RHS with the fractional part discarded, set
17221722 /// REMAINDER and SCRATCH must be distinct.
17231723 static int tcDivide(integerPart *lhs, const integerPart *rhs,
17241724 integerPart *remainder, integerPart *scratch,
1725 unsigned int parts);
1725 unsigned parts);
17261726
17271727 /// Shift a bignum left COUNT bits. Shifted in bits are zero. There are no
17281728 /// restrictions on COUNT.
1729 static void tcShiftLeft(integerPart *, unsigned int parts,
1730 unsigned int count);
1729 static void tcShiftLeft(integerPart *, unsigned parts, unsigned count);
17311730
17321731 /// Shift a bignum right COUNT bits. Shifted in bits are zero. There are no
17331732 /// restrictions on COUNT.
1734 static void tcShiftRight(integerPart *, unsigned int parts,
1735 unsigned int count);
1733 static void tcShiftRight(integerPart *, unsigned parts, unsigned count);
17361734
17371735 /// The obvious AND, OR and XOR and complement operations.
1738 static void tcAnd(integerPart *, const integerPart *, unsigned int);
1739 static void tcOr(integerPart *, const integerPart *, unsigned int);
1740 static void tcXor(integerPart *, const integerPart *, unsigned int);
1741 static void tcComplement(integerPart *, unsigned int);
1736 static void tcAnd(integerPart *, const integerPart *, unsigned);
1737 static void tcOr(integerPart *, const integerPart *, unsigned);
1738 static void tcXor(integerPart *, const integerPart *, unsigned);
1739 static void tcComplement(integerPart *, unsigned);
17421740
17431741 /// Comparison (unsigned) of two bignums.
1744 static int tcCompare(const integerPart *, const integerPart *, unsigned int);
1742 static int tcCompare(const integerPart *, const integerPart *, unsigned);
17451743
17461744 /// Increment a bignum in-place. Return the carry flag.
1747 static integerPart tcIncrement(integerPart *, unsigned int);
1745 static integerPart tcIncrement(integerPart *, unsigned);
17481746
17491747 /// Decrement a bignum in-place. Return the borrow flag.
1750 static integerPart tcDecrement(integerPart *, unsigned int);
1748 static integerPart tcDecrement(integerPart *, unsigned);
17511749
17521750 /// Set the least significant BITS and clear the rest.
1753 static void tcSetLeastSignificantBits(integerPart *, unsigned int,
1754 unsigned int bits);
1751 static void tcSetLeastSignificantBits(integerPart *, unsigned, unsigned bits);
17551752
17561753 /// \brief debug method
17571754 void dump() const;
23632363 /* Returns the integer part with the least significant BITS set.
23642364 BITS cannot be zero. */
23652365 static inline integerPart
2366 lowBitMask(unsigned int bits)
2366 lowBitMask(unsigned bits)
23672367 {
23682368 assert(bits != 0 && bits <= integerPartWidth);
23692369
23862386
23872387 /* Returns the bit number of the most significant set bit of a part.
23882388 If the input number has no bits set -1U is returned. */
2389 static unsigned int
2389 static unsigned
23902390 partMSB(integerPart value)
23912391 {
23922392 return findLastSet(value, ZB_Max);
23942394
23952395 /* Returns the bit number of the least significant set bit of a
23962396 part. If the input number has no bits set -1U is returned. */
2397 static unsigned int
2397 static unsigned
23982398 partLSB(integerPart value)
23992399 {
24002400 return findFirstSet(value, ZB_Max);
24042404 /* Sets the least significant part of a bignum to the input value, and
24052405 zeroes out higher parts. */
24062406 void
2407 APInt::tcSet(integerPart *dst, integerPart part, unsigned int parts)
2407 APInt::tcSet(integerPart *dst, integerPart part, unsigned parts)
24082408 {
24092409 unsigned int i;
24102410
24172417
24182418 /* Assign one bignum to another. */
24192419 void
2420 APInt::tcAssign(integerPart *dst, const integerPart *src, unsigned int parts)
2420 APInt::tcAssign(integerPart *dst, const integerPart *src, unsigned parts)
24212421 {
24222422 unsigned int i;
24232423
24272427
24282428 /* Returns true if a bignum is zero, false otherwise. */
24292429 bool
2430 APInt::tcIsZero(const integerPart *src, unsigned int parts)
2430 APInt::tcIsZero(const integerPart *src, unsigned parts)
24312431 {
24322432 unsigned int i;
24332433
24402440
24412441 /* Extract the given bit of a bignum; returns 0 or 1. */
24422442 int
2443 APInt::tcExtractBit(const integerPart *parts, unsigned int bit)
2443 APInt::tcExtractBit(const integerPart *parts, unsigned bit)
24442444 {
24452445 return (parts[bit / integerPartWidth] &
24462446 ((integerPart) 1 << bit % integerPartWidth)) != 0;
24482448
24492449 /* Set the given bit of a bignum. */
24502450 void
2451 APInt::tcSetBit(integerPart *parts, unsigned int bit)
2451 APInt::tcSetBit(integerPart *parts, unsigned bit)
24522452 {
24532453 parts[bit / integerPartWidth] |= (integerPart) 1 << (bit % integerPartWidth);
24542454 }
24552455
24562456 /* Clears the given bit of a bignum. */
24572457 void
2458 APInt::tcClearBit(integerPart *parts, unsigned int bit)
2458 APInt::tcClearBit(integerPart *parts, unsigned bit)
24592459 {
24602460 parts[bit / integerPartWidth] &=
24612461 ~((integerPart) 1 << (bit % integerPartWidth));
24632463
24642464 /* Returns the bit number of the least significant set bit of a
24652465 number. If the input number has no bits set -1U is returned. */
2466 unsigned int
2467 APInt::tcLSB(const integerPart *parts, unsigned int n)
2466 unsigned
2467 APInt::tcLSB(const integerPart *parts, unsigned n)
24682468 {
24692469 unsigned int i, lsb;
24702470
24812481
24822482 /* Returns the bit number of the most significant set bit of a number.
24832483 If the input number has no bits set -1U is returned. */
2484 unsigned int
2485 APInt::tcMSB(const integerPart *parts, unsigned int n)
2484 unsigned
2485 APInt::tcMSB(const integerPart *parts, unsigned n)
24862486 {
24872487 unsigned int msb;
24882488
25042504 the least significant bit of DST. All high bits above srcBITS in
25052505 DST are zero-filled. */
25062506 void
2507 APInt::tcExtract(integerPart *dst, unsigned int dstCount,const integerPart *src,
2508 unsigned int srcBits, unsigned int srcLSB)
2507 APInt::tcExtract(integerPart *dst, unsigned dstCount,const integerPart *src,
2508 unsigned srcBits, unsigned srcLSB)
25092509 {
25102510 unsigned int firstSrcPart, dstParts, shift, n;
25112511
25392539 /* DST += RHS + C where C is zero or one. Returns the carry flag. */
25402540 integerPart
25412541 APInt::tcAdd(integerPart *dst, const integerPart *rhs,
2542 integerPart c, unsigned int parts)
2542 integerPart c, unsigned parts)
25432543 {
25442544 unsigned int i;
25452545
25642564 /* DST -= RHS + C where C is zero or one. Returns the carry flag. */
25652565 integerPart
25662566 APInt::tcSubtract(integerPart *dst, const integerPart *rhs,
2567 integerPart c, unsigned int parts)
2567 integerPart c, unsigned parts)
25682568 {
25692569 unsigned int i;
25702570
25882588
25892589 /* Negate a bignum in-place. */
25902590 void
2591 APInt::tcNegate(integerPart *dst, unsigned int parts)
2591 APInt::tcNegate(integerPart *dst, unsigned parts)
25922592 {
25932593 tcComplement(dst, parts);
25942594 tcIncrement(dst, parts);
26082608 int
26092609 APInt::tcMultiplyPart(integerPart *dst, const integerPart *src,
26102610 integerPart multiplier, integerPart carry,
2611 unsigned int srcParts, unsigned int dstParts,
2611 unsigned srcParts, unsigned dstParts,
26122612 bool add)
26132613 {
26142614 unsigned int i, n;
27002700 from both operands. */
27012701 int
27022702 APInt::tcMultiply(integerPart *dst, const integerPart *lhs,
2703 const integerPart *rhs, unsigned int parts)
2703 const integerPart *rhs, unsigned parts)
27042704 {
27052705 unsigned int i;
27062706 int overflow;
27212721 operands. No overflow occurs. DST must be disjoint from both
27222722 operands. Returns the number of parts required to hold the
27232723 result. */
2724 unsigned int
2724 unsigned
27252725 APInt::tcFullMultiply(integerPart *dst, const integerPart *lhs,
2726 const integerPart *rhs, unsigned int lhsParts,
2727 unsigned int rhsParts)
2726 const integerPart *rhs, unsigned lhsParts,
2727 unsigned rhsParts)
27282728 {
27292729 /* Put the narrower number on the LHS for less loops below. */
27302730 if (lhsParts > rhsParts) {
27582758 int
27592759 APInt::tcDivide(integerPart *lhs, const integerPart *rhs,
27602760 integerPart *remainder, integerPart *srhs,
2761 unsigned int parts)
2761 unsigned parts)
27622762 {
27632763 unsigned int n, shiftCount;
27642764 integerPart mask;
28052805 /* Shift a bignum left COUNT bits in-place. Shifted in bits are zero.
28062806 There are no restrictions on COUNT. */
28072807 void
2808 APInt::tcShiftLeft(integerPart *dst, unsigned int parts, unsigned int count)
2808 APInt::tcShiftLeft(integerPart *dst, unsigned parts, unsigned count)
28092809 {
28102810 if (count) {
28112811 unsigned int jump, shift;
28392839 /* Shift a bignum right COUNT bits in-place. Shifted in bits are
28402840 zero. There are no restrictions on COUNT. */
28412841 void
2842 APInt::tcShiftRight(integerPart *dst, unsigned int parts, unsigned int count)
2842 APInt::tcShiftRight(integerPart *dst, unsigned parts, unsigned count)
28432843 {
28442844 if (count) {
28452845 unsigned int i, jump, shift;
28712871
28722872 /* Bitwise and of two bignums. */
28732873 void
2874 APInt::tcAnd(integerPart *dst, const integerPart *rhs, unsigned int parts)
2874 APInt::tcAnd(integerPart *dst, const integerPart *rhs, unsigned parts)
28752875 {
28762876 unsigned int i;
28772877
28812881
28822882 /* Bitwise inclusive or of two bignums. */
28832883 void
2884 APInt::tcOr(integerPart *dst, const integerPart *rhs, unsigned int parts)
2884 APInt::tcOr(integerPart *dst, const integerPart *rhs, unsigned parts)
28852885 {
28862886 unsigned int i;
28872887
28912891
28922892 /* Bitwise exclusive or of two bignums. */
28932893 void
2894 APInt::tcXor(integerPart *dst, const integerPart *rhs, unsigned int parts)
2894 APInt::tcXor(integerPart *dst, const integerPart *rhs, unsigned parts)
28952895 {
28962896 unsigned int i;
28972897
29012901
29022902 /* Complement a bignum in-place. */
29032903 void
2904 APInt::tcComplement(integerPart *dst, unsigned int parts)
2904 APInt::tcComplement(integerPart *dst, unsigned parts)
29052905 {
29062906 unsigned int i;
29072907
29122912 /* Comparison (unsigned) of two bignums. */
29132913 int
29142914 APInt::tcCompare(const integerPart *lhs, const integerPart *rhs,
2915 unsigned int parts)
2915 unsigned parts)
29162916 {
29172917 while (parts) {
29182918 parts--;
29302930
29312931 /* Increment a bignum in-place, return the carry flag. */
29322932 integerPart
2933 APInt::tcIncrement(integerPart *dst, unsigned int parts)
2933 APInt::tcIncrement(integerPart *dst, unsigned parts)
29342934 {
29352935 unsigned int i;
29362936
29432943
29442944 /* Decrement a bignum in-place, return the borrow flag. */
29452945 integerPart
2946 APInt::tcDecrement(integerPart *dst, unsigned int parts) {
2947 for (unsigned int i = 0; i < parts; i++) {
2946 APInt::tcDecrement(integerPart *dst, unsigned parts) {
2947 for (unsigned i = 0; i < parts; i++) {
29482948 // If the current word is non-zero, then the decrement has no effect on the
29492949 // higher-order words of the integer and no borrow can occur. Exit early.
29502950 if (dst[i]--)
29582958 /* Set the least significant BITS bits of a bignum, clear the
29592959 rest. */
29602960 void
2961 APInt::tcSetLeastSignificantBits(integerPart *dst, unsigned int parts,
2962 unsigned int bits)
2961 APInt::tcSetLeastSignificantBits(integerPart *dst, unsigned parts,
2962 unsigned bits)
29632963 {
29642964 unsigned int i;
29652965