14 #ifndef MLIR_INTERFACES_INFERINTRANGEINTERFACE_H
15 #define MLIR_INTERFACES_INFERINTRANGEINTERFACE_H
34 assert(uminVal.getBitWidth() == umaxVal.getBitWidth() &&
35 umaxVal.getBitWidth() == sminVal.getBitWidth() &&
36 sminVal.getBitWidth() == smaxVal.getBitWidth() &&
37 "All bounds in the ranges must have the same bitwidth");
43 const APInt &
umin()
const;
46 const APInt &
umax()
const;
49 const APInt &
smin()
const;
52 const APInt &
smax()
const;
103 APInt uminVal, umaxVal, sminVal, smaxVal;
121 : value(std::move(value)) {}
135 return value == rhs.value;
149 void print(raw_ostream &os)
const { os << value; }
153 std::optional<ConstantIntRanges> value;
156 raw_ostream &
operator<<(raw_ostream &,
const IntegerValueRange &);
170 class InferIntRangeInterface;
172 namespace intrange::detail {
187 #include "mlir/Interfaces/InferIntRangeInterface.h.inc"
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)
static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)
A set of arbitrary-precision integers representing bounds on a given integer value.
friend raw_ostream & operator<<(raw_ostream &os, const ConstantIntRanges &range)
static ConstantIntRanges maxRange(unsigned bitwidth)
Create a ConstantIntRanges with the maximum bounds for the width bitwidth, that is - [0,...
ConstantIntRanges(const APInt &umin, const APInt &umax, const APInt &smin, const APInt &smax)
Bound umin <= (unsigned)x <= umax and smin <= signed(x) <= smax.
const APInt & smax() const
The maximum value of an integer when it is interpreted as signed.
static ConstantIntRanges constant(const APInt &value)
Create a ConstantIntRanges with a constant value - that is, with the bounds [value,...
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 sign...
const APInt & smin() const
The minimum value of an integer when it is interpreted as signed.
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 mi...
ConstantIntRanges intersection(const ConstantIntRanges &other) const
Returns the intersection (computed separately for signed and unsigned bounds) of this range and other...
static ConstantIntRanges fromSigned(const APInt &smin, const APInt &smax)
Create an ConstantIntRanges with the signed minimum and maximum equal to smin and smax,...
static unsigned getStorageBitwidth(Type type)
Return the bitwidth that should be used for integer ranges describing type.
std::optional< APInt > getConstantValue() const
If either the signed or unsigned interpretations of the range indicate that the value it bounds is a ...
const APInt & umax() const
The maximum value of an integer when it is interpreted as unsigned.
const APInt & umin() const
The minimum value of an integer when it is interpreted as unsigned.
ConstantIntRanges rangeUnion(const ConstantIntRanges &other) const
Returns the union (computed separately for signed and unsigned bounds) of this range and other.
bool operator==(const ConstantIntRanges &other) const
This lattice value represents the integer range of an SSA value.
IntegerValueRange(ConstantIntRanges value)
Create an integer value range lattice value.
void print(raw_ostream &os) const
Print the integer value range.
const ConstantIntRanges & getValue() const
Get the known integer value range.
IntegerValueRange(std::optional< ConstantIntRanges > value=std::nullopt)
Create an integer value range lattice value.
bool isUninitialized() const
Whether the range is uninitialized.
static IntegerValueRange getMaxRange(Value value)
Create a maximal range ([0, uint_max(t)] / [int_min(t), int_max(t)]) range that is used to mark the v...
bool operator==(const IntegerValueRange &rhs) const
Compare two ranges.
static IntegerValueRange join(const IntegerValueRange &lhs, const IntegerValueRange &rhs)
Compute the least upper bound of two ranges.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
void defaultInferResultRanges(InferIntRangeInterface interface, ArrayRef< IntegerValueRange > argRanges, SetIntLatticeFn setResultRanges)
Default implementation of inferResultRanges which dispatches to the inferResultRangesFromOptional.
void defaultInferResultRangesFromOptional(InferIntRangeInterface interface, ArrayRef< ConstantIntRanges > argRanges, SetIntRangeFn setResultRanges)
Default implementation of inferResultRangesFromOptional which dispatches to the inferResultRanges.
Include the generated interface declarations.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)