30 "expected index or signless integer type");
31 return IndexCastOp::create(
b, loc,
b.getIndexType(), value);
37 assert(map.
getNumResults() == 1 &&
"multiple results not supported yet");
39 switch (e.getKind()) {
42 cast<AffineConstantExpr>(e).getValue());
45 operands[cast<AffineDimExpr>(e).getPosition()]);
49 operands[cast<AffineSymbolExpr>(e).getPosition() + map.
getNumDims()]);
51 auto binaryExpr = cast<AffineBinaryOpExpr>(e);
52 return AddIOp::create(
b, loc, buildExpr(binaryExpr.getLHS()),
53 buildExpr(binaryExpr.getRHS()));
56 auto binaryExpr = cast<AffineBinaryOpExpr>(e);
57 return MulIOp::create(
b, loc, buildExpr(binaryExpr.getLHS()),
58 buildExpr(binaryExpr.getRHS()));
61 auto binaryExpr = cast<AffineBinaryOpExpr>(e);
62 return DivSIOp::create(
b, loc, buildExpr(binaryExpr.getLHS()),
63 buildExpr(binaryExpr.getRHS()));
66 auto binaryExpr = cast<AffineBinaryOpExpr>(e);
67 return CeilDivSIOp::create(
b, loc, buildExpr(binaryExpr.getLHS()),
68 buildExpr(binaryExpr.getRHS()));
71 auto binaryExpr = cast<AffineBinaryOpExpr>(e);
72 return RemSIOp::create(
b, loc, buildExpr(binaryExpr.getLHS()),
73 buildExpr(binaryExpr.getRHS()));
76 llvm_unreachable(
"unsupported AffineExpr kind");
90 boundMap, mapOperands, type, var, std::move(stopCondition),
options)))
95 for (
auto valueDim : mapOperands) {
96 Value value = valueDim.first;
97 std::optional<int64_t> dim = valueDim.second;
99 if (!dim.has_value()) {
102 "expected index or integer type");
103 operands.push_back(value);
107 assert(cast<ShapedType>(value.
getType()).isDynamicDim(*dim) &&
108 "expected dynamic dim");
109 if (isa<RankedTensorType>(value.
getType())) {
111 operands.push_back(tensor::DimOp::create(
b, loc, value, *dim));
112 }
else if (isa<MemRefType>(value.
getType())) {
114 operands.push_back(memref::DimOp::create(
b, loc, value, *dim));
116 llvm_unreachable(
"cannot generate DimOp for unsupported shaped type");
127 if (
auto expr = dyn_cast<AffineDimExpr>(boundMap.
getResult(0)))
130 if (
auto expr = dyn_cast<AffineSymbolExpr>(boundMap.
getResult(0)))
132 b, loc, operands[expr.getPosition() + boundMap.
getNumDims()]));
141 auto reifyToOperands = [&](
Value v, std::optional<int64_t> d,
151 stopCondition ? stopCondition : reifyToOperands,
159 auto reifyToOperands = [&](
Value v, std::optional<int64_t> d,
164 stopCondition ? stopCondition : reifyToOperands,
static llvm::ManagedStatic< PassManagerOptions > options
Base type for affine expression.
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
int64_t getSingleConstantResult() const
Returns the constant result of this map.
bool isSingleConstant() const
Returns true if this affine map is a single result constant function.
unsigned getNumDims() const
unsigned getNumResults() const
AffineExpr getResult(unsigned idx) const
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
This class represents a single result from folding an operation.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
bool isSignlessInteger() const
Return true if this is a signless integer type (with the specified width).
bool isInteger() const
Return true if this is an integer type (with the specified width).
A variable that can be added to the constraint set as a "column".
A helper class to be used with ValueBoundsOpInterface.
static LogicalResult computeBound(AffineMap &resultMap, ValueDimList &mapOperands, presburger::BoundType type, const Variable &var, StopConditionFn stopCondition, ValueBoundsOptions options={})
Compute a bound for the given variable.
std::function< bool( Value, std::optional< int64_t >, ValueBoundsConstraintSet &cstr)> StopConditionFn
The stop condition when traversing the backward slice of a shaped value/ index-type value.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
static ConstantIndexOp create(OpBuilder &builder, Location location, int64_t value)
FailureOr< OpFoldResult > reifyShapedValueDimBound(OpBuilder &b, Location loc, presburger::BoundType type, Value value, int64_t dim, const ValueBoundsConstraintSet::StopConditionFn &stopCondition=nullptr, ValueBoundsOptions options={})
Reify a bound for the specified dimension of the given shaped value in terms of SSA values for which ...
FailureOr< OpFoldResult > reifyIndexValueBound(OpBuilder &b, Location loc, presburger::BoundType type, Value value, const ValueBoundsConstraintSet::StopConditionFn &stopCondition=nullptr, ValueBoundsOptions options={})
Reify a bound for the given index-typed value in terms of SSA values for which stopCondition is met.
FailureOr< OpFoldResult > reifyValueBound(OpBuilder &b, Location loc, presburger::BoundType type, const ValueBoundsConstraintSet::Variable &var, ValueBoundsConstraintSet::StopConditionFn stopCondition, ValueBoundsOptions options={})
Reify a bound for the given variable in terms of SSA values for which stopCondition is met.
BoundType
The type of bound: equal, lower bound or upper bound.
Include the generated interface declarations.
@ CeilDiv
RHS of ceildiv is always a constant or a symbolic expression.
@ Mul
RHS of mul is always a constant or a symbolic expression.
@ Mod
RHS of mod is always a constant or a symbolic expression with a positive value.
@ DimId
Dimensional identifier.
@ FloorDiv
RHS of floordiv is always a constant or a symbolic expression.
@ Constant
Constant integer.
@ SymbolId
Symbolic identifier.
SmallVector< std::pair< Value, std::optional< int64_t > >, 2 > ValueDimList
Options that control value bound computation.