LLVM: llvm::DynamicAPInt Class Reference (original) (raw)

This class provides support for dynamic arbitrary-precision arithmetic. More...

#include "[llvm/ADT/DynamicAPInt.h](DynamicAPInt%5F8h%5Fsource.html)"

Public Member Functions
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt (int64_t Val)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt (const APInt &Val)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt ()
LLVM_ATTRIBUTE_ALWAYS_INLINE ~DynamicAPInt ()
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt (const DynamicAPInt &O)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator= (const DynamicAPInt &O)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator= (int X)
LLVM_ATTRIBUTE_ALWAYS_INLINE operator int64_t () const
bool operator== (const DynamicAPInt &O) const
We define the operations here in the header to facilitate inlining.
bool operator!= (const DynamicAPInt &O) const
bool operator> (const DynamicAPInt &O) const
bool operator< (const DynamicAPInt &O) const
bool operator<= (const DynamicAPInt &O) const
bool operator>= (const DynamicAPInt &O) const
DynamicAPInt operator+ (const DynamicAPInt &O) const
DynamicAPInt operator- (const DynamicAPInt &O) const
DynamicAPInt operator* (const DynamicAPInt &O) const
DynamicAPInt operator/ (const DynamicAPInt &O) const
DynamicAPInt operator% (const DynamicAPInt &O) const
This operation cannot overflow.
DynamicAPInt & operator+= (const DynamicAPInt &O)
DynamicAPInt & operator-= (const DynamicAPInt &O)
DynamicAPInt & operator*= (const DynamicAPInt &O)
DynamicAPInt & operator/= (const DynamicAPInt &O)
DynamicAPInt & operator%= (const DynamicAPInt &O)
DynamicAPInt operator- () const
DynamicAPInt & operator++ ()
DynamicAPInt & operator-- ()
DynamicAPInt divByPositive (const DynamicAPInt &O) const
DynamicAPInt & divByPositiveInPlace (const DynamicAPInt &O)
LLVM_ABI void static_assert_layout ()
LLVM_ABI raw_ostream & print (raw_ostream &OS) const
LLVM_DUMP_METHOD void dump () const
Friends
DynamicAPInt abs (const DynamicAPInt &X)
DynamicAPInt ceilDiv (const DynamicAPInt &LHS, const DynamicAPInt &RHS)
DynamicAPInt floorDiv (const DynamicAPInt &LHS, const DynamicAPInt &RHS)
DynamicAPInt gcd (const DynamicAPInt &A, const DynamicAPInt &B)
DynamicAPInt lcm (const DynamicAPInt &A, const DynamicAPInt &B)
Returns the least common multiple of A and B.
DynamicAPInt mod (const DynamicAPInt &LHS, const DynamicAPInt &RHS)
is always non-negative.
DynamicAPInt & operator+= (DynamicAPInt &A, int64_t B)
DynamicAPInt & operator-= (DynamicAPInt &A, int64_t B)
DynamicAPInt & operator*= (DynamicAPInt &A, int64_t B)
DynamicAPInt & operator/= (DynamicAPInt &A, int64_t B)
DynamicAPInt & operator%= (DynamicAPInt &A, int64_t B)
bool operator== (const DynamicAPInt &A, int64_t B)
We provide special implementations of the comparison operators rather than calling through as above, as this would result in a 1.2x slowdown.
bool operator!= (const DynamicAPInt &A, int64_t B)
bool operator> (const DynamicAPInt &A, int64_t B)
bool operator< (const DynamicAPInt &A, int64_t B)
bool operator<= (const DynamicAPInt &A, int64_t B)
bool operator>= (const DynamicAPInt &A, int64_t B)
DynamicAPInt operator+ (const DynamicAPInt &A, int64_t B)
DynamicAPInt operator- (const DynamicAPInt &A, int64_t B)
DynamicAPInt operator* (const DynamicAPInt &A, int64_t B)
DynamicAPInt operator/ (const DynamicAPInt &A, int64_t B)
DynamicAPInt operator% (const DynamicAPInt &A, int64_t B)
bool operator== (int64_t A, const DynamicAPInt &B)
bool operator!= (int64_t A, const DynamicAPInt &B)
bool operator> (int64_t A, const DynamicAPInt &B)
bool operator< (int64_t A, const DynamicAPInt &B)
bool operator<= (int64_t A, const DynamicAPInt &B)
bool operator>= (int64_t A, const DynamicAPInt &B)
DynamicAPInt operator+ (int64_t A, const DynamicAPInt &B)
DynamicAPInt operator- (int64_t A, const DynamicAPInt &B)
DynamicAPInt operator* (int64_t A, const DynamicAPInt &B)
DynamicAPInt operator/ (int64_t A, const DynamicAPInt &B)
DynamicAPInt operator% (int64_t A, const DynamicAPInt &B)
LLVM_ABI friend hash_code hash_value (const DynamicAPInt &x)
Redeclarations of friend declaration above to make it discoverable by lookups.

This class provides support for dynamic arbitrary-precision arithmetic.

Unlike APInt, this extends the precision as necessary to prevent overflows and supports operations between objects with differing internal precisions.

This is optimized for small-values by providing fast-paths for the cases when the value stored fits in 64-bits. We annotate all fastpaths by using the LLVM_LIKELY/LLVM_UNLIKELY annotations. Removing these would result in a 1.2x performance slowdown.

We always_inline all operations; removing these results in a 1.5x performance slowdown.

When isLarge returns true, a SlowMPInt is held in the union. If isSmall returns true, the int64_t is held. We don't have a separate field for indicating this, and instead "steal" memory from ValLarge when it is not in use because we know that the memory layout of APInt is such that BitWidth doesn't overlap with ValSmall (see static_assert_layout). Using std::variant instead would lead to significantly worse performance.

Definition at line 48 of file DynamicAPInt.h.

DynamicAPInt() [2/4]

DynamicAPInt() [3/4]

Definition at line 128 of file DynamicAPInt.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE.

Referenced by divByPositive(), divByPositiveInPlace(), operator%(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), and operator/=().

~DynamicAPInt()

DynamicAPInt() [4/4]

divByPositive()

divByPositiveInPlace()

dump()

operator int64_t()

operator!=()

operator%()

operator%=()

operator*()

operator*=()

operator+()

operator++()

operator+=()

operator-() [1/2]

operator-() [2/2]

operator--()

operator-=()

operator/()

operator/=()

operator<()

operator<=()

operator=() [1/2]

operator=() [2/2]

operator==()

We define the operations here in the header to facilitate inlining.


Comparison operators.

Definition at line 265 of file DynamicAPInt.h.

References LLVM_LIKELY.

operator>()

operator>=()

print()

static_assert_layout()

void DynamicAPInt::static_assert_layout ( )

abs

ceilDiv

floorDiv

gcd

hash_value

Redeclarations of friend declaration above to make it discoverable by lookups.

References LLVM_ABI, and LLVM_DUMP_METHOD.

lcm

mod

operator!= [1/2]

operator!= [2/2]

operator% [1/2]

operator% [2/2]

operator%=

operator* [1/2]

operator* [2/2]

operator*=

operator+ [1/2]

operator+ [2/2]

operator+=

operator- [1/2]

operator- [2/2]

operator-=

operator/ [1/2]

operator/ [2/2]

operator/=

operator< [1/2]

operator< [2/2]

operator<= [1/2]

operator<= [2/2]

operator== [1/2]

operator== [2/2]

operator> [1/2]

operator> [2/2]

operator>= [1/2]

operator>= [2/2]

ValLarge

ValSmall

int64_t llvm::DynamicAPInt::ValSmall


The documentation for this class was generated from the following files: