16#ifndef LLVM_ADT_DYNAMICAPINT_H
17#define LLVM_ADT_DYNAMICAPINT_H
52 ValLarge.detail::SlowDynamicAPInt::~SlowDynamicAPInt();
57 initLarge(
const detail::SlowDynamicAPInt &O) {
64 new (&
ValLarge) detail::SlowDynamicAPInt(O);
74 const detail::SlowDynamicAPInt &Val)
86 "getSmall should only be called when the value stored is small!");
91 "getSmall should only be called when the value stored is small!");
97 "getLarge should only be called when the value stored is large!");
102 "getLarge should only be called when the value stored is large!");
105 explicit operator detail::SlowDynamicAPInt()
const {
107 return detail::SlowDynamicAPInt(getSmall());
119 ValLarge.detail::SlowDynamicAPInt::~SlowDynamicAPInt();
125 initLarge(O.ValLarge);
129 initSmall(O.ValSmall);
132 initLarge(O.ValLarge);
142 return static_cast<int64_t
>(getLarge());
242 const DynamicAPInt &
RHS);
252 return getSmall() == O.getSmall();
258 return getSmall() != O.getSmall();
264 return getSmall() > O.getSmall();
270 return getSmall() < O.getSmall();
276 return getSmall() <= O.getSmall();
282 return getSmall() >= O.getSmall();
294 bool Overflow =
AddOverflow(getSmall(), O.getSmall(), Result.getSmall());
307 bool Overflow =
SubOverflow(getSmall(), O.getSmall(), Result.getSmall());
320 bool Overflow =
MulOverflow(getSmall(), O.getSmall(), Result.getSmall());
390 assert(
A >= 0 &&
B >= 0 &&
"operands must be non-negative!");
416 if (
LLVM_LIKELY(getSmall() != std::numeric_limits<int64_t>::min()))
429 int64_t Result = getSmall();
430 bool Overflow =
AddOverflow(getSmall(), O.getSmall(), Result);
446 int64_t Result = getSmall();
447 bool Overflow =
SubOverflow(getSmall(), O.getSmall(), Result);
463 int64_t Result = getSmall();
464 bool Overflow =
MulOverflow(getSmall(), O.getSmall(), Result);
482 return *
this = -*
this;
483 getSmall() /= O.getSmall();
495 getSmall() /= O.getSmall();
504 return *
this = *
this % O;
581 return A.getSmall() ==
B;
582 return A.getLarge() ==
B;
586 return A.getSmall() !=
B;
587 return A.getLarge() !=
B;
591 return A.getSmall() >
B;
592 return A.getLarge() >
B;
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 ==
B.getSmall();
612 return A ==
B.getLarge();
616 return A !=
B.getSmall();
617 return A !=
B.getLarge();
621 return A >
B.getSmall();
622 return A >
B.getLarge();
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();
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")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class provides support for dynamic arbitrary-precision arithmetic.
friend DynamicAPInt & operator%=(DynamicAPInt &A, int64_t B)
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)
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)
DynamicAPInt operator-() const
LLVM_DUMP_METHOD void dump() const
friend hash_code hash_value(const DynamicAPInt &x)
Redeclarations of friend declaration above to make it discoverable by lookups.
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()
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)