MLIR
20.0.0git
|
A set of arbitrary-precision integers representing bounds on a given integer value. More...
#include "mlir/Interfaces/InferIntRangeInterface.h"
Public Member Functions | |
ConstantIntRanges (const APInt &umin, const APInt &umax, const APInt &smin, const APInt &smax) | |
Bound umin <= (unsigned)x <= umax and smin <= signed(x) <= smax. More... | |
bool | operator== (const ConstantIntRanges &other) const |
const APInt & | umin () const |
The minimum value of an integer when it is interpreted as unsigned. More... | |
const APInt & | umax () const |
The maximum value of an integer when it is interpreted as unsigned. More... | |
const APInt & | smin () const |
The minimum value of an integer when it is interpreted as signed. More... | |
const APInt & | smax () const |
The maximum value of an integer when it is interpreted as signed. More... | |
ConstantIntRanges | rangeUnion (const ConstantIntRanges &other) const |
Returns the union (computed separately for signed and unsigned bounds) of this range and other . More... | |
ConstantIntRanges | intersection (const ConstantIntRanges &other) const |
Returns the intersection (computed separately for signed and unsigned bounds) of this range and other . More... | |
std::optional< APInt > | getConstantValue () const |
If either the signed or unsigned interpretations of the range indicate that the value it bounds is a constant, return that constant value. More... | |
Static Public Member Functions | |
static unsigned | getStorageBitwidth (Type type) |
Return the bitwidth that should be used for integer ranges describing type . More... | |
static ConstantIntRanges | maxRange (unsigned bitwidth) |
Create a ConstantIntRanges with the maximum bounds for the width bitwidth , that is - [0, uint_max(width)]/[sint_min(width), sint_max(width)]. More... | |
static ConstantIntRanges | constant (const APInt &value) |
Create a ConstantIntRanges with a constant value - that is, with the bounds [value, value] for both its signed interpretations. More... | |
static ConstantIntRanges | range (const APInt &min, const APInt &max, bool isSigned) |
Create a ConstantIntRanges whose minimum is min and maximum is max with isSigned specifying if the min and max should be interpreted as signed or unsigned. More... | |
static ConstantIntRanges | fromSigned (const APInt &smin, const APInt &smax) |
Create an ConstantIntRanges with the signed minimum and maximum equal to smin and smax , where the unsigned bounds are constructed from the signed ones if they correspond to a contigious range of bit patterns when viewed as unsigned values and are left at [0, int_max()] otherwise. More... | |
static ConstantIntRanges | fromUnsigned (const APInt &umin, const APInt &umax) |
Create an ConstantIntRanges with the unsigned minimum and maximum equal to umin and umax and the signed part equal to umin and umax unless the sign bit changes between the minimum and maximum. More... | |
Friends | |
raw_ostream & | operator<< (raw_ostream &os, const ConstantIntRanges &range) |
A set of arbitrary-precision integers representing bounds on a given integer value.
These bounds are inclusive on both ends, so bounds of [4, 5] mean 4 <= x <= 5. Separate bounds are tracked for the unsigned and signed interpretations of values in order to enable more precice inference of the interplay between operations with signed and unsigned semantics.
Definition at line 27 of file InferIntRangeInterface.h.
|
inline |
Bound umin <= (unsigned)x <= umax and smin <= signed(x) <= smax.
Non-integer values should be bounded by APInts of bitwidth 0.
Definition at line 31 of file InferIntRangeInterface.h.
|
static |
Create a ConstantIntRanges
with a constant value - that is, with the bounds [value, value] for both its signed interpretations.
Definition at line 45 of file InferIntRangeInterface.cpp.
Referenced by mlir::detail::constant_int_range_predicate_matcher::match().
|
static |
Create an ConstantIntRanges
with the signed minimum and maximum equal to smin
and smax
, where the unsigned bounds are constructed from the signed ones if they correspond to a contigious range of bit patterns when viewed as unsigned values and are left at [0, int_max()] otherwise.
Definition at line 56 of file InferIntRangeInterface.cpp.
References smax(), smin(), umax(), and umin().
Referenced by mlir::intrange::extSIRange(), mlir::intrange::inferMaxS(), mlir::intrange::inferMinS(), mlir::intrange::inferRemS(), range(), and mlir::dataflow::IntegerRangeAnalysis::visitNonControlFlowArguments().
|
static |
Create an ConstantIntRanges
with the unsigned minimum and maximum equal to umin
and umax
and the signed part equal to umin
and umax
unless the sign bit changes between the minimum and maximum.
Definition at line 70 of file InferIntRangeInterface.cpp.
References smax(), smin(), umax(), and umin().
Referenced by mlir::intrange::extUIRange(), getIndexRange(), inferDivURange(), mlir::intrange::inferMaxU(), mlir::intrange::inferMinU(), mlir::intrange::inferRemU(), mlir::intrange::inferXor(), maxRange(), and range().
std::optional< APInt > ConstantIntRanges::getConstantValue | ( | ) | const |
If either the signed or unsigned interpretations of the range indicate that the value it bounds is a constant, return that constant value.
Definition at line 118 of file InferIntRangeInterface.cpp.
References getBitWidth(), smax(), smin(), umax(), and umin().
Referenced by getMaybeConstantValue(), isStaticallyTrue(), and mlir::dataflow::IntegerValueRangeLattice::onUpdate().
|
static |
Return the bitwidth that should be used for integer ranges describing type
.
For concrete integer types, this is their bitwidth, for index
, this is the internal storage bitwidth of index
attributes, and for non-integer types this is 0.
Definition at line 31 of file InferIntRangeInterface.cpp.
References mlir::getElementTypeOrSelf(), and mlir::Type::isIndex().
Referenced by mlir::IntegerValueRange::getMaxRange(), inferIndexCast(), and mlir::dataflow::IntegerRangeAnalysis::visitNonControlFlowArguments().
ConstantIntRanges ConstantIntRanges::intersection | ( | const ConstantIntRanges & | other | ) | const |
Returns the intersection (computed separately for signed and unsigned bounds) of this range and other
.
Definition at line 102 of file InferIntRangeInterface.cpp.
References getBitWidth(), smax(), smin(), umax(), and umin().
Referenced by mlir::intrange::inferAdd(), mlir::intrange::inferMul(), and mlir::intrange::inferSub().
|
static |
Create a ConstantIntRanges
with the maximum bounds for the width bitwidth
, that is - [0, uint_max(width)]/[sint_min(width), sint_max(width)].
Definition at line 41 of file InferIntRangeInterface.cpp.
References fromUnsigned(), and getZero().
Referenced by computeBoundsBy(), inferDivSRange(), and minMaxBy().
bool ConstantIntRanges::operator== | ( | const ConstantIntRanges & | other | ) | const |
|
static |
Create a ConstantIntRanges
whose minimum is min
and maximum is max
with isSigned
specifying if the min and max should be interpreted as signed or unsigned.
Definition at line 49 of file InferIntRangeInterface.cpp.
References fromSigned(), fromUnsigned(), max(), and min().
Referenced by computeBoundsBy(), and minMaxBy().
ConstantIntRanges ConstantIntRanges::rangeUnion | ( | const ConstantIntRanges & | other | ) | const |
Returns the union (computed separately for signed and unsigned bounds) of this range and other
.
Definition at line 85 of file InferIntRangeInterface.cpp.
References getBitWidth(), smax(), smin(), umax(), and umin().
Referenced by inferIndexCast(), mlir::intrange::inferIndexOp(), and mlir::IntegerValueRange::join().
const APInt & ConstantIntRanges::smax | ( | ) | const |
The maximum value of an integer when it is interpreted as signed.
Definition at line 29 of file InferIntRangeInterface.cpp.
Referenced by mlir::intrange::extSIRange(), fromSigned(), fromUnsigned(), getConstantValue(), mlir::intrange::inferAdd(), inferDivSRange(), mlir::intrange::inferIndexOp(), mlir::intrange::inferMaxS(), mlir::intrange::inferMinS(), mlir::intrange::inferMul(), mlir::intrange::inferRemS(), mlir::intrange::inferSub(), intersection(), isStaticallyTrue(), mlir::operator<<(), operator==(), rangeUnion(), and mlir::dataflow::IntegerRangeAnalysis::visitNonControlFlowArguments().
const APInt & ConstantIntRanges::smin | ( | ) | const |
The minimum value of an integer when it is interpreted as signed.
Definition at line 27 of file InferIntRangeInterface.cpp.
Referenced by mlir::intrange::extSIRange(), fromSigned(), fromUnsigned(), getConstantValue(), mlir::intrange::inferAdd(), inferDivSRange(), mlir::intrange::inferIndexOp(), mlir::intrange::inferMaxS(), mlir::intrange::inferMinS(), mlir::intrange::inferMul(), mlir::intrange::inferRemS(), mlir::intrange::inferSub(), intersection(), isStaticallyTrue(), mlir::operator<<(), operator==(), rangeUnion(), staticallyNonNegative(), and mlir::dataflow::IntegerRangeAnalysis::visitNonControlFlowArguments().
const APInt & ConstantIntRanges::umax | ( | ) | const |
The maximum value of an integer when it is interpreted as unsigned.
Definition at line 25 of file InferIntRangeInterface.cpp.
Referenced by mlir::intrange::extUIRange(), fromSigned(), fromUnsigned(), getConstantValue(), getVaryingBitsMask(), mlir::intrange::inferAdd(), inferDivURange(), mlir::intrange::inferIndexOp(), mlir::intrange::inferMaxU(), mlir::intrange::inferMinU(), mlir::intrange::inferMul(), mlir::intrange::inferRemU(), mlir::intrange::inferSub(), intersection(), isStaticallyTrue(), mlir::operator<<(), operator==(), rangeUnion(), and widenBitwiseBounds().
const APInt & ConstantIntRanges::umin | ( | ) | const |
The minimum value of an integer when it is interpreted as unsigned.
Definition at line 23 of file InferIntRangeInterface.cpp.
Referenced by mlir::intrange::extUIRange(), fromSigned(), fromUnsigned(), getConstantValue(), getVaryingBitsMask(), mlir::intrange::inferAdd(), inferDivURange(), mlir::intrange::inferIndexOp(), mlir::intrange::inferMaxU(), mlir::intrange::inferMinU(), mlir::intrange::inferMul(), mlir::intrange::inferRemU(), mlir::intrange::inferSub(), mlir::intrange::inferXor(), intersection(), isStaticallyTrue(), mlir::operator<<(), operator==(), rangeUnion(), and widenBitwiseBounds().
|
friend |