Lines Matching refs:APInt
78 void APInt::initSlowCase(uint64_t val, bool isSigned) { in initSlowCase()
87 void APInt::initSlowCase(const APInt& that) { in initSlowCase()
92 void APInt::initFromArray(ArrayRef<uint64_t> bigVal) { in initFromArray()
109 APInt::APInt(unsigned numBits, ArrayRef<uint64_t> bigVal) in APInt() function in APInt
114 APInt::APInt(unsigned numBits, unsigned numWords, const uint64_t bigVal[]) in APInt() function in APInt
119 APInt::APInt(unsigned numbits, StringRef Str, uint8_t radix) in APInt() function in APInt
125 void APInt::reallocate(unsigned NewBitWidth) { in reallocate()
144 void APInt::AssignSlowCase(const APInt& RHS) { in AssignSlowCase()
160 void APInt::Profile(FoldingSetNodeID& ID) const { in Profile()
174 APInt& APInt::operator++() { in operator ++()
183 APInt& APInt::operator--() { in operator --()
194 APInt& APInt::operator+=(const APInt& RHS) { in operator +=()
203 APInt& APInt::operator+=(uint64_t RHS) { in operator +=()
214 APInt& APInt::operator-=(const APInt& RHS) { in operator -=()
223 APInt& APInt::operator-=(uint64_t RHS) { in operator -=()
231 APInt APInt::operator*(const APInt& RHS) const { in operator *()
234 return APInt(BitWidth, U.VAL * RHS.U.VAL); in operator *()
236 APInt Result(getMemory(getNumWords()), getBitWidth()); in operator *()
244 void APInt::AndAssignSlowCase(const APInt& RHS) { in AndAssignSlowCase()
248 void APInt::OrAssignSlowCase(const APInt& RHS) { in OrAssignSlowCase()
252 void APInt::XorAssignSlowCase(const APInt& RHS) { in XorAssignSlowCase()
256 APInt& APInt::operator*=(const APInt& RHS) { in operator *=()
262 APInt& APInt::operator*=(uint64_t RHS) { in operator *=()
272 bool APInt::EqualSlowCase(const APInt& RHS) const { in EqualSlowCase()
276 int APInt::compare(const APInt& RHS) const { in compare()
284 int APInt::compareSigned(const APInt& RHS) const { in compareSigned()
304 void APInt::setBitsSlowCase(unsigned loBit, unsigned hiBit) { in setBitsSlowCase()
332 void APInt::flipAllBitsSlowCase() { in flipAllBitsSlowCase()
340 void APInt::flipBit(unsigned bitPosition) { in flipBit()
346 void APInt::insertBits(const APInt &subBits, unsigned bitPosition) { in insertBits()
405 APInt APInt::extractBits(unsigned numBits, unsigned bitPosition) const { in extractBits()
411 return APInt(numBits, U.VAL >> bitPosition); in extractBits()
419 return APInt(numBits, U.pVal[loWord] >> loBit); in extractBits()
424 return APInt(numBits, makeArrayRef(U.pVal + loWord, 1 + hiWord - loWord)); in extractBits()
427 APInt Result(numBits, 0); in extractBits()
442 unsigned APInt::getBitsNeeded(StringRef str, uint8_t radix) { in getBitsNeeded()
483 APInt tmp(sufficient, StringRef(p, slen), radix); in getBitsNeeded()
495 hash_code llvm::hash_value(const APInt &Arg) { in hash_value()
502 bool APInt::isSplat(unsigned SplatSizeInBits) const { in isSplat()
511 APInt APInt::getHiBits(unsigned numBits) const { in getHiBits()
516 APInt APInt::getLoBits(unsigned numBits) const { in getLoBits()
517 APInt Result(getLowBitsSet(BitWidth, numBits)); in getLoBits()
523 APInt APInt::getSplat(unsigned NewLen, const APInt &V) { in getSplat()
526 APInt Val = V.zextOrSelf(NewLen); in getSplat()
533 unsigned APInt::countLeadingZerosSlowCase() const { in countLeadingZerosSlowCase()
550 unsigned APInt::countLeadingOnesSlowCase() const { in countLeadingOnesSlowCase()
574 unsigned APInt::countTrailingZerosSlowCase() const { in countTrailingZerosSlowCase()
584 unsigned APInt::countTrailingOnesSlowCase() const { in countTrailingOnesSlowCase()
595 unsigned APInt::countPopulationSlowCase() const { in countPopulationSlowCase()
602 bool APInt::intersectsSlowCase(const APInt &RHS) const { in intersectsSlowCase()
610 bool APInt::isSubsetOfSlowCase(const APInt &RHS) const { in isSubsetOfSlowCase()
618 APInt APInt::byteSwap() const { in byteSwap()
621 return APInt(BitWidth, ByteSwap_16(uint16_t(U.VAL))); in byteSwap()
623 return APInt(BitWidth, ByteSwap_32(unsigned(U.VAL))); in byteSwap()
629 return APInt(BitWidth, (uint64_t(Tmp2) << 32) | Tmp1); in byteSwap()
632 return APInt(BitWidth, ByteSwap_64(U.VAL)); in byteSwap()
634 APInt Result(getNumWords() * APINT_BITS_PER_WORD, 0); in byteSwap()
644 APInt APInt::reverseBits() const { in reverseBits()
647 return APInt(BitWidth, llvm::reverseBits<uint64_t>(U.VAL)); in reverseBits()
649 return APInt(BitWidth, llvm::reverseBits<uint32_t>(U.VAL)); in reverseBits()
651 return APInt(BitWidth, llvm::reverseBits<uint16_t>(U.VAL)); in reverseBits()
653 return APInt(BitWidth, llvm::reverseBits<uint8_t>(U.VAL)); in reverseBits()
658 APInt Val(*this); in reverseBits()
659 APInt Reversed(BitWidth, 0); in reverseBits()
672 APInt llvm::APIntOps::GreatestCommonDivisor(APInt A, APInt B) { in GreatestCommonDivisor()
715 APInt llvm::APIntOps::RoundDoubleToAPInt(double Double, unsigned width) { in RoundDoubleToAPInt()
726 return APInt(width, 0u); in RoundDoubleToAPInt()
733 return isNeg ? -APInt(width, mantissa >> (52 - exp)) : in RoundDoubleToAPInt()
734 APInt(width, mantissa >> (52 - exp)); in RoundDoubleToAPInt()
739 return APInt(width, 0); in RoundDoubleToAPInt()
742 APInt Tmp(width, mantissa); in RoundDoubleToAPInt()
754 double APInt::roundToDouble(bool isSigned) const { in roundToDouble()
770 APInt Tmp(isNeg ? -(*this) : (*this)); in roundToDouble()
811 APInt APInt::trunc(unsigned width) const { in trunc()
816 return APInt(width, getRawData()[0]); in trunc()
818 APInt Result(getMemory(getNumWords(width)), width); in trunc()
834 APInt APInt::sext(unsigned Width) const { in sext()
838 return APInt(Width, SignExtend64(U.VAL, BitWidth)); in sext()
840 APInt Result(getMemory(getNumWords(Width)), Width); in sext()
858 APInt APInt::zext(unsigned width) const { in zext()
862 return APInt(width, U.VAL); in zext()
864 APInt Result(getMemory(getNumWords(width)), width); in zext()
876 APInt APInt::zextOrTrunc(unsigned width) const { in zextOrTrunc()
884 APInt APInt::sextOrTrunc(unsigned width) const { in sextOrTrunc()
892 APInt APInt::zextOrSelf(unsigned width) const { in zextOrSelf()
898 APInt APInt::sextOrSelf(unsigned width) const { in sextOrSelf()
906 void APInt::ashrInPlace(const APInt &shiftAmt) { in ashrInPlace()
912 void APInt::ashrSlowCase(unsigned ShiftAmt) { in ashrSlowCase()
955 void APInt::lshrInPlace(const APInt &shiftAmt) { in lshrInPlace()
961 void APInt::lshrSlowCase(unsigned ShiftAmt) { in lshrSlowCase()
967 APInt &APInt::operator<<=(const APInt &shiftAmt) { in operator <<=()
973 void APInt::shlSlowCase(unsigned ShiftAmt) { in shlSlowCase()
979 static unsigned rotateModulo(unsigned BitWidth, const APInt &rotateAmt) { in rotateModulo()
981 APInt rot = rotateAmt; in rotateModulo()
987 rot = rot.urem(APInt(rot.getBitWidth(), BitWidth)); in rotateModulo()
991 APInt APInt::rotl(const APInt &rotateAmt) const { in rotl()
995 APInt APInt::rotl(unsigned rotateAmt) const { in rotl()
1002 APInt APInt::rotr(const APInt &rotateAmt) const { in rotr()
1006 APInt APInt::rotr(unsigned rotateAmt) const { in rotr()
1020 APInt APInt::sqrt() const { in sqrt()
1037 return APInt(BitWidth, results[ (isSingleWord() ? U.VAL : U.pVal[0]) ]); in sqrt()
1045 return APInt(BitWidth, in sqrt()
1056 APInt testy(BitWidth, 16); in sqrt()
1057 APInt x_old(BitWidth, 1); in sqrt()
1058 APInt x_new(BitWidth, 0); in sqrt()
1059 APInt two(BitWidth, 2); in sqrt()
1082 APInt square(x_old * x_old); in sqrt()
1083 APInt nextSquare((x_old + 1) * (x_old +1)); in sqrt()
1087 APInt midpoint((nextSquare - square).udiv(two)); in sqrt()
1088 APInt offset(*this - square); in sqrt()
1099 APInt APInt::multiplicativeInverse(const APInt& modulo) const { in multiplicativeInverse()
1110 APInt r[2] = { modulo, *this }; in multiplicativeInverse()
1111 APInt t[2] = { APInt(BitWidth, 0), APInt(BitWidth, 1) }; in multiplicativeInverse()
1112 APInt q(BitWidth, 0); in multiplicativeInverse()
1129 return APInt(BitWidth, 0); in multiplicativeInverse()
1145 APInt::ms APInt::magic() const { in magic()
1146 const APInt& d = *this; in magic()
1148 APInt ad, anc, delta, q1, r1, q2, r2, t; in magic()
1149 APInt signedMin = APInt::getSignedMinValue(d.getBitWidth()); in magic()
1189 APInt::mu APInt::magicu(unsigned LeadingZeros) const { in magicu()
1190 const APInt& d = *this; in magicu()
1192 APInt nc, delta, q1, r1, q2, r2; in magicu()
1195 APInt allOnes = APInt::getAllOnesValue(d.getBitWidth()).lshr(LeadingZeros); in magicu()
1196 APInt signedMin = APInt::getSignedMinValue(d.getBitWidth()); in magicu()
1197 APInt signedMax = APInt::getSignedMaxValue(d.getBitWidth()); in magicu()
1397 void APInt::divide(const WordType *LHS, unsigned lhsWords, const WordType *RHS, in divide()
1520 APInt APInt::udiv(const APInt &RHS) const { in udiv()
1526 return APInt(BitWidth, U.VAL / RHS.U.VAL); in udiv()
1538 return APInt(BitWidth, 0); in udiv()
1544 return APInt(BitWidth, 0); in udiv()
1547 return APInt(BitWidth, 1); in udiv()
1550 return APInt(BitWidth, this->U.pVal[0] / RHS.U.pVal[0]); in udiv()
1553 APInt Quotient(BitWidth, 0); // to hold result. in udiv()
1558 APInt APInt::udiv(uint64_t RHS) const { in udiv()
1563 return APInt(BitWidth, U.VAL / RHS); in udiv()
1571 return APInt(BitWidth, 0); in udiv()
1577 return APInt(BitWidth, 0); in udiv()
1580 return APInt(BitWidth, 1); in udiv()
1583 return APInt(BitWidth, this->U.pVal[0] / RHS); in udiv()
1586 APInt Quotient(BitWidth, 0); // to hold result. in udiv()
1591 APInt APInt::sdiv(const APInt &RHS) const { in sdiv()
1602 APInt APInt::sdiv(int64_t RHS) const { in sdiv()
1613 APInt APInt::urem(const APInt &RHS) const { in urem()
1617 return APInt(BitWidth, U.VAL % RHS.U.VAL); in urem()
1631 return APInt(BitWidth, 0); in urem()
1634 return APInt(BitWidth, 0); in urem()
1640 return APInt(BitWidth, 0); in urem()
1643 return APInt(BitWidth, U.pVal[0] % RHS.U.pVal[0]); in urem()
1646 APInt Remainder(BitWidth, 0); in urem()
1651 uint64_t APInt::urem(uint64_t RHS) const { in urem()
1683 APInt APInt::srem(const APInt &RHS) const { in srem()
1694 int64_t APInt::srem(int64_t RHS) const { in srem()
1705 void APInt::udivrem(const APInt &LHS, const APInt &RHS, in udivrem()
1706 APInt &Quotient, APInt &Remainder) { in udivrem()
1715 Quotient = APInt(BitWidth, QuotVal); in udivrem()
1716 Remainder = APInt(BitWidth, RemVal); in udivrem()
1728 Quotient = APInt(BitWidth, 0); // 0 / Y ===> 0 in udivrem()
1729 Remainder = APInt(BitWidth, 0); // 0 % Y ===> 0 in udivrem()
1735 Remainder = APInt(BitWidth, 0); // X % 1 ===> 0 in udivrem()
1740 Quotient = APInt(BitWidth, 0); // X / Y ===> 0, iff X < Y in udivrem()
1745 Quotient = APInt(BitWidth, 1); // X / X ===> 1 in udivrem()
1746 Remainder = APInt(BitWidth, 0); // X % X ===> 0; in udivrem()
1776 void APInt::udivrem(const APInt &LHS, uint64_t RHS, APInt &Quotient, in udivrem()
1785 Quotient = APInt(BitWidth, QuotVal); in udivrem()
1794 Quotient = APInt(BitWidth, 0); // 0 / Y ===> 0 in udivrem()
1807 Quotient = APInt(BitWidth, 0); // X / Y ===> 0, iff X < Y in udivrem()
1812 Quotient = APInt(BitWidth, 1); // X / X ===> 1 in udivrem()
1837 void APInt::sdivrem(const APInt &LHS, const APInt &RHS, in sdivrem()
1838 APInt &Quotient, APInt &Remainder) { in sdivrem()
1841 APInt::udivrem(-LHS, -RHS, Quotient, Remainder); in sdivrem()
1843 APInt::udivrem(-LHS, RHS, Quotient, Remainder); in sdivrem()
1848 APInt::udivrem(LHS, -RHS, Quotient, Remainder); in sdivrem()
1851 APInt::udivrem(LHS, RHS, Quotient, Remainder); in sdivrem()
1855 void APInt::sdivrem(const APInt &LHS, int64_t RHS, in sdivrem()
1856 APInt &Quotient, int64_t &Remainder) { in sdivrem()
1860 APInt::udivrem(-LHS, -RHS, Quotient, R); in sdivrem()
1862 APInt::udivrem(-LHS, RHS, Quotient, R); in sdivrem()
1867 APInt::udivrem(LHS, -RHS, Quotient, R); in sdivrem()
1870 APInt::udivrem(LHS, RHS, Quotient, R); in sdivrem()
1875 APInt APInt::sadd_ov(const APInt &RHS, bool &Overflow) const { in sadd_ov()
1876 APInt Res = *this+RHS; in sadd_ov()
1882 APInt APInt::uadd_ov(const APInt &RHS, bool &Overflow) const { in uadd_ov()
1883 APInt Res = *this+RHS; in uadd_ov()
1888 APInt APInt::ssub_ov(const APInt &RHS, bool &Overflow) const { in ssub_ov()
1889 APInt Res = *this - RHS; in ssub_ov()
1895 APInt APInt::usub_ov(const APInt &RHS, bool &Overflow) const { in usub_ov()
1896 APInt Res = *this-RHS; in usub_ov()
1901 APInt APInt::sdiv_ov(const APInt &RHS, bool &Overflow) const { in sdiv_ov()
1907 APInt APInt::smul_ov(const APInt &RHS, bool &Overflow) const { in smul_ov()
1908 APInt Res = *this * RHS; in smul_ov()
1917 APInt APInt::umul_ov(const APInt &RHS, bool &Overflow) const { in umul_ov()
1918 APInt Res = *this * RHS; in umul_ov()
1927 APInt APInt::sshl_ov(const APInt &ShAmt, bool &Overflow) const { in sshl_ov()
1930 return APInt(BitWidth, 0); in sshl_ov()
1940 APInt APInt::ushl_ov(const APInt &ShAmt, bool &Overflow) const { in ushl_ov()
1943 return APInt(BitWidth, 0); in ushl_ov()
1950 APInt APInt::sadd_sat(const APInt &RHS) const { in sadd_sat()
1952 APInt Res = sadd_ov(RHS, Overflow); in sadd_sat()
1956 return isNegative() ? APInt::getSignedMinValue(BitWidth) in sadd_sat()
1957 : APInt::getSignedMaxValue(BitWidth); in sadd_sat()
1960 APInt APInt::uadd_sat(const APInt &RHS) const { in uadd_sat()
1962 APInt Res = uadd_ov(RHS, Overflow); in uadd_sat()
1966 return APInt::getMaxValue(BitWidth); in uadd_sat()
1969 APInt APInt::ssub_sat(const APInt &RHS) const { in ssub_sat()
1971 APInt Res = ssub_ov(RHS, Overflow); in ssub_sat()
1975 return isNegative() ? APInt::getSignedMinValue(BitWidth) in ssub_sat()
1976 : APInt::getSignedMaxValue(BitWidth); in ssub_sat()
1979 APInt APInt::usub_sat(const APInt &RHS) const { in usub_sat()
1981 APInt Res = usub_ov(RHS, Overflow); in usub_sat()
1985 return APInt(BitWidth, 0); in usub_sat()
1989 void APInt::fromString(unsigned numbits, StringRef str, uint8_t radix) { in fromString()
2040 void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix, in toString()
2109 APInt Tmp(*this); in toString()
2155 std::string APInt::toString(unsigned Radix = 10, bool Signed = true) const { in toString()
2162 LLVM_DUMP_METHOD void APInt::dump() const { in dump()
2171 void APInt::print(raw_ostream &OS, bool isSigned) const { in print()
2182 static_assert(APInt::APINT_BITS_PER_WORD % 2 == 0,
2189 static inline APInt::WordType lowBitMask(unsigned bits) { in lowBitMask()
2190 assert(bits != 0 && bits <= APInt::APINT_BITS_PER_WORD); in lowBitMask()
2192 return ~(APInt::WordType) 0 >> (APInt::APINT_BITS_PER_WORD - bits); in lowBitMask()
2196 static inline APInt::WordType lowHalf(APInt::WordType part) { in lowHalf()
2197 return part & lowBitMask(APInt::APINT_BITS_PER_WORD / 2); in lowHalf()
2201 static inline APInt::WordType highHalf(APInt::WordType part) { in highHalf()
2202 return part >> (APInt::APINT_BITS_PER_WORD / 2); in highHalf()
2207 static unsigned partMSB(APInt::WordType value) { in partMSB()
2213 static unsigned partLSB(APInt::WordType value) { in partLSB()
2219 void APInt::tcSet(WordType *dst, WordType part, unsigned parts) { in tcSet()
2228 void APInt::tcAssign(WordType *dst, const WordType *src, unsigned parts) { in tcAssign()
2234 bool APInt::tcIsZero(const WordType *src, unsigned parts) { in tcIsZero()
2243 int APInt::tcExtractBit(const WordType *parts, unsigned bit) { in tcExtractBit()
2248 void APInt::tcSetBit(WordType *parts, unsigned bit) { in tcSetBit()
2253 void APInt::tcClearBit(WordType *parts, unsigned bit) { in tcClearBit()
2259 unsigned APInt::tcLSB(const WordType *parts, unsigned n) { in tcLSB()
2273 unsigned APInt::tcMSB(const WordType *parts, unsigned n) { in tcMSB()
2292 APInt::tcExtract(WordType *dst, unsigned dstCount, const WordType *src, in tcExtract()
2322 APInt::WordType APInt::tcAdd(WordType *dst, const WordType *rhs, in tcAdd()
2344 APInt::WordType APInt::tcAddPart(WordType *dst, WordType src, in tcAddPart()
2357 APInt::WordType APInt::tcSubtract(WordType *dst, const WordType *rhs, in tcSubtract()
2382 APInt::WordType APInt::tcSubtractPart(WordType *dst, WordType src, in tcSubtractPart()
2396 void APInt::tcNegate(WordType *dst, unsigned parts) { in tcNegate()
2412 int APInt::tcMultiplyPart(WordType *dst, const WordType *src, in tcMultiplyPart()
2501 int APInt::tcMultiply(WordType *dst, const WordType *lhs, in tcMultiply()
2517 void APInt::tcFullMultiply(WordType *dst, const WordType *lhs, in tcFullMultiply()
2542 int APInt::tcDivide(WordType *lhs, const WordType *rhs, in tcDivide()
2584 void APInt::tcShiftLeft(WordType *Dst, unsigned Words, unsigned Count) { in tcShiftLeft()
2611 void APInt::tcShiftRight(WordType *Dst, unsigned Words, unsigned Count) { in tcShiftRight()
2637 void APInt::tcAnd(WordType *dst, const WordType *rhs, unsigned parts) { in tcAnd()
2643 void APInt::tcOr(WordType *dst, const WordType *rhs, unsigned parts) { in tcOr()
2649 void APInt::tcXor(WordType *dst, const WordType *rhs, unsigned parts) { in tcXor()
2655 void APInt::tcComplement(WordType *dst, unsigned parts) { in tcComplement()
2661 int APInt::tcCompare(const WordType *lhs, const WordType *rhs, in tcCompare()
2674 void APInt::tcSetLeastSignificantBits(WordType *dst, unsigned parts, in tcSetLeastSignificantBits()
2689 APInt llvm::APIntOps::RoundingUDiv(const APInt &A, const APInt &B, in RoundingUDiv()
2690 APInt::Rounding RM) { in RoundingUDiv()
2693 case APInt::Rounding::DOWN: in RoundingUDiv()
2694 case APInt::Rounding::TOWARD_ZERO: in RoundingUDiv()
2696 case APInt::Rounding::UP: { in RoundingUDiv()
2697 APInt Quo, Rem; in RoundingUDiv()
2698 APInt::udivrem(A, B, Quo, Rem); in RoundingUDiv()
2707 APInt llvm::APIntOps::RoundingSDiv(const APInt &A, const APInt &B, in RoundingSDiv()
2708 APInt::Rounding RM) { in RoundingSDiv()
2710 case APInt::Rounding::DOWN: in RoundingSDiv()
2711 case APInt::Rounding::UP: { in RoundingSDiv()
2712 APInt Quo, Rem; in RoundingSDiv()
2713 APInt::sdivrem(A, B, Quo, Rem); in RoundingSDiv()
2721 if (RM == APInt::Rounding::DOWN) { in RoundingSDiv()
2731 case APInt::Rounding::TOWARD_ZERO: in RoundingSDiv()
2737 Optional<APInt>
2738 llvm::APIntOps::SolveQuadraticEquationWrap(APInt A, APInt B, APInt C, in SolveQuadraticEquationWrap()
2752 return APInt(CoeffWidth, 0); in SolveQuadraticEquationWrap()
2804 APInt R = APInt::getOneBitSet(CoeffWidth, RangeWidth); in SolveQuadraticEquationWrap()
2805 APInt TwoA = 2 * A; in SolveQuadraticEquationWrap()
2806 APInt SqrB = B * B; in SolveQuadraticEquationWrap()
2809 auto RoundUp = [] (const APInt &V, const APInt &A) -> APInt { in SolveQuadraticEquationWrap()
2811 APInt T = V.abs().urem(A); in SolveQuadraticEquationWrap()
2834 APInt LowkR = C - SqrB.udiv(2*TwoA); // udiv because all values > 0. in SolveQuadraticEquationWrap()
2866 APInt D = SqrB - 4*A*C; in SolveQuadraticEquationWrap()
2868 APInt SQ = D.sqrt(); in SolveQuadraticEquationWrap()
2870 APInt Q = SQ * SQ; in SolveQuadraticEquationWrap()
2877 APInt X; in SolveQuadraticEquationWrap()
2878 APInt Rem; in SolveQuadraticEquationWrap()
2887 APInt::sdivrem(-B - (SQ+InexactSQ), TwoA, X, Rem); in SolveQuadraticEquationWrap()
2889 APInt::sdivrem(-B + SQ, TwoA, X, Rem); in SolveQuadraticEquationWrap()
2910 APInt VX = (A*X + B)*X + C; in SolveQuadraticEquationWrap()
2911 APInt VY = VX + TwoA*X + A + B; in SolveQuadraticEquationWrap()