MLIR
17.0.0git
|
This class provides support for multi-precision arithmetic. More...
#include "mlir/Analysis/Presburger/MPInt.h"
Public Member Functions | |
LLVM_ATTRIBUTE_ALWAYS_INLINE | MPInt (int64_t val) |
LLVM_ATTRIBUTE_ALWAYS_INLINE | MPInt () |
LLVM_ATTRIBUTE_ALWAYS_INLINE | ~MPInt () |
LLVM_ATTRIBUTE_ALWAYS_INLINE | MPInt (const MPInt &o) |
LLVM_ATTRIBUTE_ALWAYS_INLINE MPInt & | operator= (const MPInt &o) |
LLVM_ATTRIBUTE_ALWAYS_INLINE MPInt & | operator= (int x) |
LLVM_ATTRIBUTE_ALWAYS_INLINE | operator int64_t () const |
bool | operator== (const MPInt &o) const |
We define the operations here in the header to facilitate inlining. More... | |
bool | operator!= (const MPInt &o) const |
bool | operator> (const MPInt &o) const |
bool | operator< (const MPInt &o) const |
bool | operator<= (const MPInt &o) const |
bool | operator>= (const MPInt &o) const |
MPInt | operator+ (const MPInt &o) const |
MPInt | operator- (const MPInt &o) const |
MPInt | operator* (const MPInt &o) const |
MPInt | operator/ (const MPInt &o) const |
MPInt | operator% (const MPInt &o) const |
This operation cannot overflow. More... | |
MPInt & | operator+= (const MPInt &o) |
MPInt & | operator-= (const MPInt &o) |
MPInt & | operator*= (const MPInt &o) |
MPInt & | operator/= (const MPInt &o) |
MPInt & | operator%= (const MPInt &o) |
MPInt | operator- () const |
MPInt & | operator++ () |
MPInt & | operator-- () |
MPInt | divByPositive (const MPInt &o) const |
MPInt & | divByPositiveInPlace (const MPInt &o) |
llvm::raw_ostream & | print (llvm::raw_ostream &os) const |
void | dump () const |
Friends | |
MPInt | abs (const MPInt &x) |
MPInt | gcdRange (ArrayRef< MPInt > range) |
Compute the gcd of the range. More... | |
MPInt | ceilDiv (const MPInt &lhs, const MPInt &rhs) |
MPInt | floorDiv (const MPInt &lhs, const MPInt &rhs) |
MPInt | gcd (const MPInt &a, const MPInt &b) |
MPInt | lcm (const MPInt &a, const MPInt &b) |
Returns the least common multiple of 'a' and 'b'. More... | |
MPInt | mod (const MPInt &lhs, const MPInt &rhs) |
is always non-negative. More... | |
MPInt & | operator+= (MPInt &a, int64_t b) |
MPInt & | operator-= (MPInt &a, int64_t b) |
MPInt & | operator*= (MPInt &a, int64_t b) |
MPInt & | operator/= (MPInt &a, int64_t b) |
MPInt & | operator%= (MPInt &a, int64_t b) |
bool | operator== (const MPInt &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. More... | |
bool | operator!= (const MPInt &a, int64_t b) |
bool | operator> (const MPInt &a, int64_t b) |
bool | operator< (const MPInt &a, int64_t b) |
bool | operator<= (const MPInt &a, int64_t b) |
bool | operator>= (const MPInt &a, int64_t b) |
MPInt | operator+ (const MPInt &a, int64_t b) |
MPInt | operator- (const MPInt &a, int64_t b) |
MPInt | operator* (const MPInt &a, int64_t b) |
MPInt | operator/ (const MPInt &a, int64_t b) |
MPInt | operator% (const MPInt &a, int64_t b) |
bool | operator== (int64_t a, const MPInt &b) |
bool | operator!= (int64_t a, const MPInt &b) |
bool | operator> (int64_t a, const MPInt &b) |
bool | operator< (int64_t a, const MPInt &b) |
bool | operator<= (int64_t a, const MPInt &b) |
bool | operator>= (int64_t a, const MPInt &b) |
MPInt | operator+ (int64_t a, const MPInt &b) |
MPInt | operator- (int64_t a, const MPInt &b) |
MPInt | operator* (int64_t a, const MPInt &b) |
MPInt | operator/ (int64_t a, const MPInt &b) |
MPInt | operator% (int64_t a, const MPInt &b) |
llvm::hash_code | hash_value (const MPInt &x) |
Redeclarations of friend declaration above to make it discoverable by lookups. More... | |
This class provides support for multi-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 holdsLarge is true, a SlowMPInt is held in the union. If it is false, the int64_t is held. Using std::variant instead would lead to significantly worse performance.
|
inlineexplicit |
|
inline |
Definition at line 153 of file MPInt.h.
Referenced by divByPositive(), divByPositiveInPlace(), operator%(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), and operator/=().
|
inline |
|
inline |
|
inlineexplicit |
LLVM_ATTRIBUTE_ALWAYS_INLINE bool mlir::presburger::MPInt::operator!= | ( | const MPInt & | o | ) | const |
Definition at line 340 of file MPInt.h.
References MPInt(), and mlir::presburger::detail::mulOverflow().
Definition at line 460 of file MPInt.h.
References MPInt(), and mlir::presburger::detail::mulOverflow().
Definition at line 318 of file MPInt.h.
References mlir::presburger::detail::addOverflow(), and MPInt().
LLVM_ATTRIBUTE_ALWAYS_INLINE MPInt & mlir::presburger::MPInt::operator++ | ( | ) |
Definition at line 432 of file MPInt.h.
References mlir::presburger::detail::addOverflow(), and MPInt().
LLVM_ATTRIBUTE_ALWAYS_INLINE MPInt mlir::presburger::MPInt::operator- | ( | ) | const |
Definition at line 329 of file MPInt.h.
References MPInt(), and mlir::presburger::detail::subOverflow().
LLVM_ATTRIBUTE_ALWAYS_INLINE MPInt & mlir::presburger::MPInt::operator-- | ( | ) |
Definition at line 446 of file MPInt.h.
References MPInt(), and mlir::presburger::detail::subOverflow().
Definition at line 360 of file MPInt.h.
References mlir::presburger::detail::divWouldOverflow(), and MPInt().
Definition at line 474 of file MPInt.h.
References mlir::presburger::detail::divWouldOverflow(), and MPInt().
LLVM_ATTRIBUTE_ALWAYS_INLINE bool mlir::presburger::MPInt::operator< | ( | const MPInt & | o | ) | const |
LLVM_ATTRIBUTE_ALWAYS_INLINE bool mlir::presburger::MPInt::operator<= | ( | const MPInt & | o | ) | const |
|
inline |
LLVM_ATTRIBUTE_ALWAYS_INLINE bool mlir::presburger::MPInt::operator== | ( | const MPInt & | o | ) | const |
LLVM_ATTRIBUTE_ALWAYS_INLINE bool mlir::presburger::MPInt::operator> | ( | const MPInt & | o | ) | const |
LLVM_ATTRIBUTE_ALWAYS_INLINE bool mlir::presburger::MPInt::operator>= | ( | const MPInt & | o | ) | const |
llvm::raw_ostream & MPInt::print | ( | llvm::raw_ostream & | os | ) | const |
Definition at line 382 of file MPInt.h.
Referenced by mlir::FlatLinearConstraints::getSliceBounds().
|
friend |
Redeclarations of friend declaration above to make it discoverable by lookups.
|
friend |
detail::SlowMPInt mlir::presburger::MPInt::valLarge |
int64_t mlir::presburger::MPInt::valSmall |
Definition at line 90 of file MPInt.h.
Referenced by operator=(), and print().