16#ifndef LLVM_ADT_DYNAMICAPINT_H
17#define LLVM_ADT_DYNAMICAPINT_H
56 ValLarge.detail::SlowDynamicAPInt::~SlowDynamicAPInt();
61 initLarge(
const detail::SlowDynamicAPInt &O) {
68 new (&
ValLarge) detail::SlowDynamicAPInt(O);
78 const detail::SlowDynamicAPInt &Val)
90 "getSmall should only be called when the value stored is small!");
95 "getSmall should only be called when the value stored is small!");
101 "getLarge should only be called when the value stored is large!");
106 "getLarge should only be called when the value stored is large!");
109 explicit operator detail::SlowDynamicAPInt()
const {
111 return detail::SlowDynamicAPInt(getSmall());
131 ValLarge.detail::SlowDynamicAPInt::~SlowDynamicAPInt();
137 initLarge(O.ValLarge);
141 initSmall(O.ValSmall);
144 initLarge(O.ValLarge);
154 return static_cast<int64_t
>(getLarge());
230#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
257 const DynamicAPInt &
RHS);
267 return getSmall() == O.getSmall();
273 return getSmall() != O.getSmall();
279 return getSmall() > O.getSmall();
285 return getSmall() < O.getSmall();
291 return getSmall() <= O.getSmall();
297 return getSmall() >= O.getSmall();
309 bool Overflow =
AddOverflow(getSmall(), O.getSmall(), Result.getSmall());
322 bool Overflow =
SubOverflow(getSmall(), O.getSmall(), Result.getSmall());
335 bool Overflow =
MulOverflow(getSmall(), O.getSmall(), Result.getSmall());
405 assert(
A >= 0 &&
B >= 0 &&
"operands must be non-negative!");
431 if (
LLVM_LIKELY(getSmall() != std::numeric_limits<int64_t>::min()))
444 int64_t Result = getSmall();
445 bool Overflow =
AddOverflow(getSmall(), O.getSmall(), Result);
461 int64_t Result = getSmall();
462 bool Overflow =
SubOverflow(getSmall(), O.getSmall(), Result);
478 int64_t Result = getSmall();
479 bool Overflow =
MulOverflow(getSmall(), O.getSmall(), Result);
497 return *
this = -*
this;
498 getSmall() /= O.getSmall();
510 getSmall() /= O.getSmall();
519 return *
this = *
this % O;
596 return A.getSmall() ==
B;
597 return A.getLarge() ==
B;
601 return A.getSmall() !=
B;
602 return A.getLarge() !=
B;
606 return A.getSmall() >
B;
607 return A.getLarge() >
B;
611 return A.getSmall() <
B;
612 return A.getLarge() <
B;
616 return A.getSmall() <=
B;
617 return A.getLarge() <=
B;
621 return A.getSmall() >=
B;
622 return A.getLarge() >=
B;
626 return A ==
B.getSmall();
627 return A ==
B.getLarge();
631 return A !=
B.getSmall();
632 return A !=
B.getLarge();
636 return A >
B.getSmall();
637 return A >
B.getLarge();
641 return A <
B.getSmall();
642 return A <
B.getLarge();
646 return A <=
B.getSmall();
647 return A <=
B.getLarge();
651 return A >=
B.getSmall();
652 return A >=
B.getLarge();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_UNLIKELY(EXPR)
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
#define LLVM_LIKELY(EXPR)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
Class for arbitrary precision integers.
unsigned getBitWidth() const
Return the number of bits in the APInt.
int64_t getSExtValue() const
Get sign extended value.
This class provides support for dynamic arbitrary-precision arithmetic.
friend DynamicAPInt & operator%=(DynamicAPInt &A, int64_t B)
LLVM_ABI raw_ostream & print(raw_ostream &OS) const
friend bool operator>=(const DynamicAPInt &A, int64_t B)
friend bool operator>(const DynamicAPInt &A, int64_t B)
friend DynamicAPInt ceilDiv(const DynamicAPInt &LHS, const DynamicAPInt &RHS)
friend bool operator!=(const DynamicAPInt &A, int64_t B)
DynamicAPInt & operator--()
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator=(const DynamicAPInt &O)
friend DynamicAPInt abs(const DynamicAPInt &X)
friend DynamicAPInt gcd(const DynamicAPInt &A, const DynamicAPInt &B)
friend DynamicAPInt lcm(const DynamicAPInt &A, const DynamicAPInt &B)
Returns the least common multiple of A and B.
friend DynamicAPInt operator+(const DynamicAPInt &A, int64_t B)
friend DynamicAPInt & operator+=(DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt()
friend DynamicAPInt operator/(const DynamicAPInt &A, int64_t B)
friend DynamicAPInt & operator*=(DynamicAPInt &A, int64_t B)
friend DynamicAPInt operator%(const DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator=(int X)
detail::SlowDynamicAPInt ValLarge
friend bool operator<(const DynamicAPInt &A, int64_t B)
LLVM_ABI void static_assert_layout()
DynamicAPInt divByPositive(const DynamicAPInt &O) const
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt(const DynamicAPInt &O)
friend DynamicAPInt & operator/=(DynamicAPInt &A, int64_t B)
LLVM_ABI friend hash_code hash_value(const DynamicAPInt &x)
Redeclarations of friend declaration above to make it discoverable by lookups.
DynamicAPInt operator-() const
LLVM_DUMP_METHOD void dump() const
DynamicAPInt & operator++()
friend bool operator<=(const DynamicAPInt &A, int64_t B)
friend DynamicAPInt mod(const DynamicAPInt &LHS, const DynamicAPInt &RHS)
is always non-negative.
friend bool operator==(const DynamicAPInt &A, int64_t B)
We provide special implementations of the comparison operators rather than calling through as above,...
LLVM_ATTRIBUTE_ALWAYS_INLINE ~DynamicAPInt()
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt(const APInt &Val)
friend DynamicAPInt floorDiv(const DynamicAPInt &LHS, const DynamicAPInt &RHS)
friend DynamicAPInt operator*(const DynamicAPInt &A, int64_t B)
friend DynamicAPInt & operator-=(DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt(int64_t Val)
DynamicAPInt & divByPositiveInPlace(const DynamicAPInt &O)
A simple class providing dynamic arbitrary-precision arithmetic.
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt gcd(const DynamicAPInt &A, const DynamicAPInt &B)
std::enable_if_t< std::is_signed_v< T >, T > MulOverflow(T X, T Y, T &Result)
Multiply two signed integers, computing the two's complement truncated result, returning true if an o...
constexpr bool divideSignedWouldOverflow(U Numerator, V Denominator)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt mod(const DynamicAPInt &LHS, const DynamicAPInt &RHS)
is always non-negative.
hash_code hash_value(const FixedPointSemantics &Val)
APInt operator*(APInt a, uint64_t RHS)
APFloat abs(APFloat X)
Returns the absolute value of the argument.
constexpr T divideFloorSigned(U Numerator, V Denominator)
Returns the integer floor(Numerator / Denominator).
bool operator!=(uint64_t V1, const APInt &V2)
bool operator>=(int64_t V1, const APSInt &V2)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator+=(DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator-=(DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt floorDiv(const DynamicAPInt &LHS, const DynamicAPInt &RHS)
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt operator%(const DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator*=(DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator/=(DynamicAPInt &A, int64_t B)
bool operator>(int64_t V1, const APSInt &V2)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt ceilDiv(const DynamicAPInt &LHS, const DynamicAPInt &RHS)
static int64_t int64fromDynamicAPInt(const DynamicAPInt &X)
This just calls through to the operator int64_t, but it's useful when a function pointer is required.
constexpr T divideCeilSigned(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt lcm(const DynamicAPInt &A, const DynamicAPInt &B)
Returns the least common multiple of A and B.
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt dynamicAPIntFromInt64(int64_t X)
std::enable_if_t< std::is_signed_v< T >, T > AddOverflow(T X, T Y, T &Result)
Add two signed integers, computing the two's complement truncated result, returning true if overflow ...
APInt operator+(APInt a, const APInt &b)
std::enable_if_t< std::is_signed_v< T >, T > SubOverflow(T X, T Y, T &Result)
Subtract two signed integers, computing the two's complement truncated result, returning true if an o...
bool operator<=(int64_t V1, const APSInt &V2)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator%=(DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt operator/(const DynamicAPInt &A, int64_t B)