#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/bit.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <cmath>
#include <optional>
usingnamespacellvm;
#define DEBUG_TYPE …
inline static uint64_t* getClearedMemory(unsigned numWords) { … }
inline static uint64_t* getMemory(unsigned numWords) { … }
inline static unsigned getDigit(char cdigit, uint8_t radix) { … }
void APInt::initSlowCase(uint64_t val, bool isSigned) { … }
void APInt::initSlowCase(const APInt& that) { … }
void APInt::initFromArray(ArrayRef<uint64_t> bigVal) { … }
APInt::APInt(unsigned numBits, ArrayRef<uint64_t> bigVal) : … { … }
APInt::APInt(unsigned numBits, unsigned numWords, const uint64_t bigVal[])
: … { … }
APInt::APInt(unsigned numbits, StringRef Str, uint8_t radix)
: … { … }
void APInt::reallocate(unsigned NewBitWidth) { … }
void APInt::assignSlowCase(const APInt &RHS) { … }
void APInt::Profile(FoldingSetNodeID& ID) const { … }
bool APInt::isAligned(Align A) const { … }
APInt& APInt::operator++() { … }
APInt& APInt::operator--() { … }
APInt& APInt::operator+=(const APInt& RHS) { … }
APInt& APInt::operator+=(uint64_t RHS) { … }
APInt& APInt::operator-=(const APInt& RHS) { … }
APInt& APInt::operator-=(uint64_t RHS) { … }
APInt APInt::operator*(const APInt& RHS) const { … }
void APInt::andAssignSlowCase(const APInt &RHS) { … }
void APInt::orAssignSlowCase(const APInt &RHS) { … }
void APInt::xorAssignSlowCase(const APInt &RHS) { … }
APInt &APInt::operator*=(const APInt &RHS) { … }
APInt& APInt::operator*=(uint64_t RHS) { … }
bool APInt::equalSlowCase(const APInt &RHS) const { … }
int APInt::compare(const APInt& RHS) const { … }
int APInt::compareSigned(const APInt& RHS) const { … }
void APInt::setBitsSlowCase(unsigned loBit, unsigned hiBit) { … }
static void tcComplement(APInt::WordType *dst, unsigned parts) { … }
void APInt::flipAllBitsSlowCase() { … }
APInt APInt::concatSlowCase(const APInt &NewLSB) const { … }
void APInt::flipBit(unsigned bitPosition) { … }
void APInt::insertBits(const APInt &subBits, unsigned bitPosition) { … }
void APInt::insertBits(uint64_t subBits, unsigned bitPosition, unsigned numBits) { … }
APInt APInt::extractBits(unsigned numBits, unsigned bitPosition) const { … }
uint64_t APInt::extractBitsAsZExtValue(unsigned numBits,
unsigned bitPosition) const { … }
unsigned APInt::getSufficientBitsNeeded(StringRef Str, uint8_t Radix) { … }
unsigned APInt::getBitsNeeded(StringRef str, uint8_t radix) { … }
hash_code llvm::hash_value(const APInt &Arg) { … }
unsigned DenseMapInfo<APInt, void>::getHashValue(const APInt &Key) { … }
bool APInt::isSplat(unsigned SplatSizeInBits) const { … }
APInt APInt::getHiBits(unsigned numBits) const { … }
APInt APInt::getLoBits(unsigned numBits) const { … }
APInt APInt::getSplat(unsigned NewLen, const APInt &V) { … }
unsigned APInt::countLeadingZerosSlowCase() const { … }
unsigned APInt::countLeadingOnesSlowCase() const { … }
unsigned APInt::countTrailingZerosSlowCase() const { … }
unsigned APInt::countTrailingOnesSlowCase() const { … }
unsigned APInt::countPopulationSlowCase() const { … }
bool APInt::intersectsSlowCase(const APInt &RHS) const { … }
bool APInt::isSubsetOfSlowCase(const APInt &RHS) const { … }
APInt APInt::byteSwap() const { … }
APInt APInt::reverseBits() const { … }
APInt llvm::APIntOps::GreatestCommonDivisor(APInt A, APInt B) { … }
APInt llvm::APIntOps::RoundDoubleToAPInt(double Double, unsigned width) { … }
double APInt::roundToDouble(bool isSigned) const { … }
APInt APInt::trunc(unsigned width) const { … }
APInt APInt::truncUSat(unsigned width) const { … }
APInt APInt::truncSSat(unsigned width) const { … }
APInt APInt::sext(unsigned Width) const { … }
APInt APInt::zext(unsigned width) const { … }
APInt APInt::zextOrTrunc(unsigned width) const { … }
APInt APInt::sextOrTrunc(unsigned width) const { … }
void APInt::ashrInPlace(const APInt &shiftAmt) { … }
void APInt::ashrSlowCase(unsigned ShiftAmt) { … }
void APInt::lshrInPlace(const APInt &shiftAmt) { … }
void APInt::lshrSlowCase(unsigned ShiftAmt) { … }
APInt &APInt::operator<<=(const APInt &shiftAmt) { … }
void APInt::shlSlowCase(unsigned ShiftAmt) { … }
static unsigned rotateModulo(unsigned BitWidth, const APInt &rotateAmt) { … }
APInt APInt::rotl(const APInt &rotateAmt) const { … }
APInt APInt::rotl(unsigned rotateAmt) const { … }
APInt APInt::rotr(const APInt &rotateAmt) const { … }
APInt APInt::rotr(unsigned rotateAmt) const { … }
unsigned APInt::nearestLogBase2() const { … }
APInt APInt::sqrt() const { … }
APInt APInt::multiplicativeInverse() const { … }
static void KnuthDiv(uint32_t *u, uint32_t *v, uint32_t *q, uint32_t* r,
unsigned m, unsigned n) { … }
void APInt::divide(const WordType *LHS, unsigned lhsWords, const WordType *RHS,
unsigned rhsWords, WordType *Quotient, WordType *Remainder) { … }
APInt APInt::udiv(const APInt &RHS) const { … }
APInt APInt::udiv(uint64_t RHS) const { … }
APInt APInt::sdiv(const APInt &RHS) const { … }
APInt APInt::sdiv(int64_t RHS) const { … }
APInt APInt::urem(const APInt &RHS) const { … }
uint64_t APInt::urem(uint64_t RHS) const { … }
APInt APInt::srem(const APInt &RHS) const { … }
int64_t APInt::srem(int64_t RHS) const { … }
void APInt::udivrem(const APInt &LHS, const APInt &RHS,
APInt &Quotient, APInt &Remainder) { … }
void APInt::udivrem(const APInt &LHS, uint64_t RHS, APInt &Quotient,
uint64_t &Remainder) { … }
void APInt::sdivrem(const APInt &LHS, const APInt &RHS,
APInt &Quotient, APInt &Remainder) { … }
void APInt::sdivrem(const APInt &LHS, int64_t RHS,
APInt &Quotient, int64_t &Remainder) { … }
APInt APInt::sadd_ov(const APInt &RHS, bool &Overflow) const { … }
APInt APInt::uadd_ov(const APInt &RHS, bool &Overflow) const { … }
APInt APInt::ssub_ov(const APInt &RHS, bool &Overflow) const { … }
APInt APInt::usub_ov(const APInt &RHS, bool &Overflow) const { … }
APInt APInt::sdiv_ov(const APInt &RHS, bool &Overflow) const { … }
APInt APInt::smul_ov(const APInt &RHS, bool &Overflow) const { … }
APInt APInt::umul_ov(const APInt &RHS, bool &Overflow) const { … }
APInt APInt::sshl_ov(const APInt &ShAmt, bool &Overflow) const { … }
APInt APInt::sshl_ov(unsigned ShAmt, bool &Overflow) const { … }
APInt APInt::ushl_ov(const APInt &ShAmt, bool &Overflow) const { … }
APInt APInt::ushl_ov(unsigned ShAmt, bool &Overflow) const { … }
APInt APInt::sfloordiv_ov(const APInt &RHS, bool &Overflow) const { … }
APInt APInt::sadd_sat(const APInt &RHS) const { … }
APInt APInt::uadd_sat(const APInt &RHS) const { … }
APInt APInt::ssub_sat(const APInt &RHS) const { … }
APInt APInt::usub_sat(const APInt &RHS) const { … }
APInt APInt::smul_sat(const APInt &RHS) const { … }
APInt APInt::umul_sat(const APInt &RHS) const { … }
APInt APInt::sshl_sat(const APInt &RHS) const { … }
APInt APInt::sshl_sat(unsigned RHS) const { … }
APInt APInt::ushl_sat(const APInt &RHS) const { … }
APInt APInt::ushl_sat(unsigned RHS) const { … }
void APInt::fromString(unsigned numbits, StringRef str, uint8_t radix) { … }
void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix, bool Signed,
bool formatAsCLiteral, bool UpperCase,
bool InsertSeparators) const { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void APInt::dump() const {
SmallString<40> S, U;
this->toStringUnsigned(U);
this->toStringSigned(S);
dbgs() << "APInt(" << BitWidth << "b, "
<< U << "u " << S << "s)\n";
}
#endif
void APInt::print(raw_ostream &OS, bool isSigned) const { … }
static_assert …;
static inline APInt::WordType lowBitMask(unsigned bits) { … }
static inline APInt::WordType lowHalf(APInt::WordType part) { … }
static inline APInt::WordType highHalf(APInt::WordType part) { … }
void APInt::tcSet(WordType *dst, WordType part, unsigned parts) { … }
void APInt::tcAssign(WordType *dst, const WordType *src, unsigned parts) { … }
bool APInt::tcIsZero(const WordType *src, unsigned parts) { … }
int APInt::tcExtractBit(const WordType *parts, unsigned bit) { … }
void APInt::tcSetBit(WordType *parts, unsigned bit) { … }
void APInt::tcClearBit(WordType *parts, unsigned bit) { … }
unsigned APInt::tcLSB(const WordType *parts, unsigned n) { … }
unsigned APInt::tcMSB(const WordType *parts, unsigned n) { … }
void
APInt::tcExtract(WordType *dst, unsigned dstCount, const WordType *src,
unsigned srcBits, unsigned srcLSB) { … }
APInt::WordType APInt::tcAdd(WordType *dst, const WordType *rhs,
WordType c, unsigned parts) { … }
APInt::WordType APInt::tcAddPart(WordType *dst, WordType src,
unsigned parts) { … }
APInt::WordType APInt::tcSubtract(WordType *dst, const WordType *rhs,
WordType c, unsigned parts) { … }
APInt::WordType APInt::tcSubtractPart(WordType *dst, WordType src,
unsigned parts) { … }
void APInt::tcNegate(WordType *dst, unsigned parts) { … }
int APInt::tcMultiplyPart(WordType *dst, const WordType *src,
WordType multiplier, WordType carry,
unsigned srcParts, unsigned dstParts,
bool add) { … }
int APInt::tcMultiply(WordType *dst, const WordType *lhs,
const WordType *rhs, unsigned parts) { … }
void APInt::tcFullMultiply(WordType *dst, const WordType *lhs,
const WordType *rhs, unsigned lhsParts,
unsigned rhsParts) { … }
int APInt::tcDivide(WordType *lhs, const WordType *rhs,
WordType *remainder, WordType *srhs,
unsigned parts) { … }
void APInt::tcShiftLeft(WordType *Dst, unsigned Words, unsigned Count) { … }
void APInt::tcShiftRight(WordType *Dst, unsigned Words, unsigned Count) { … }
int APInt::tcCompare(const WordType *lhs, const WordType *rhs,
unsigned parts) { … }
APInt llvm::APIntOps::RoundingUDiv(const APInt &A, const APInt &B,
APInt::Rounding RM) { … }
APInt llvm::APIntOps::RoundingSDiv(const APInt &A, const APInt &B,
APInt::Rounding RM) { … }
std::optional<APInt>
llvm::APIntOps::SolveQuadraticEquationWrap(APInt A, APInt B, APInt C,
unsigned RangeWidth) { … }
std::optional<unsigned>
llvm::APIntOps::GetMostSignificantDifferentBit(const APInt &A, const APInt &B) { … }
APInt llvm::APIntOps::ScaleBitMask(const APInt &A, unsigned NewBitWidth,
bool MatchAllBits) { … }
void llvm::StoreIntToMemory(const APInt &IntVal, uint8_t *Dst,
unsigned StoreBytes) { … }
void llvm::LoadIntFromMemory(APInt &IntVal, const uint8_t *Src,
unsigned LoadBytes) { … }
APInt APIntOps::avgFloorS(const APInt &C1, const APInt &C2) { … }
APInt APIntOps::avgFloorU(const APInt &C1, const APInt &C2) { … }
APInt APIntOps::avgCeilS(const APInt &C1, const APInt &C2) { … }
APInt APIntOps::avgCeilU(const APInt &C1, const APInt &C2) { … }
APInt APIntOps::mulhs(const APInt &C1, const APInt &C2) { … }
APInt APIntOps::mulhu(const APInt &C1, const APInt &C2) { … }