28 if (getLowerBounds().size() != getBoundedValues().size())
29 return emitOpError() <<
"incorrect number of lower bounds, expected "
30 << getBoundedValues().size() <<
" but found "
31 << getLowerBounds().size();
32 if (getUpperBounds().size() != getBoundedValues().size())
33 return emitOpError() <<
"incorrect number of upper bounds, expected "
34 << getBoundedValues().size() <<
" but found "
35 << getUpperBounds().size();
42 template <
typename OpTy>
57 simplified->getOperands());
74 for (
const auto &it : llvm::zip_equal(getBoundedValues(), getLowerBounds(),
76 Value handle = std::get<0>(it);
77 for (
Operation *op : state.getPayloadOps(handle)) {
81 <<
"expected bounded value handle to point to one or multiple "
82 "single-result index-typed ops";
83 diag.attachNote(op->
getLoc()) <<
"multiple/non-index result";
86 boundedValues.push_back(op->
getResult(0));
87 boundedOps.insert(op);
88 lbs.push_back(std::get<1>(it));
89 ubs.push_back(std::get<2>(it));
95 for (
const auto &it : llvm::zip(boundedValues, lbs, ubs)) {
97 if (!cstr.
findVar(std::get<0>(it), &pos))
106 for (
Operation *target : state.getPayloadOps(getTarget())) {
107 if (!isa<AffineMinOp, AffineMaxOp>(target)) {
109 <<
"target must be affine.min or affine.max";
110 diag.attachNote(target->getLoc()) <<
"target op";
113 if (boundedOps.contains(target)) {
115 <<
"target op result must not be constrainted";
116 diag.attachNote(target->getLoc()) <<
"target/constrained op";
119 targets.push_back(target);
125 AffineMaxOp::getCanonicalizationPatterns(patterns,
getContext());
126 AffineMinOp::getCanonicalizationPatterns(patterns,
getContext());
127 patterns.insert<SimplifyAffineMinMaxOp<AffineMinOp>,
128 SimplifyAffineMinMaxOp<AffineMaxOp>>(
getContext(), cstr);
137 <<
"affine.min/max simplification did not converge";
143 void SimplifyBoundedAffineOpsOp::getEffects(
146 for (
Value v : getBoundedValues())
156 class AffineTransformDialectExtension
158 AffineTransformDialectExtension> {
163 declareGeneratedDialect<AffineDialect>();
165 registerTransformOps<
167 #include "mlir/Dialect/Affine/TransformOps/AffineTransformOps.cpp.inc"
173 #define GET_OP_CLASSES
174 #include "mlir/Dialect/Affine/TransformOps/AffineTransformOps.cpp.inc"
static MLIRContext * getContext(OpFoldResult val)
static std::string diag(const llvm::Value &value)
The result of a transform IR operation application.
static DiagnosedSilenceableFailure success()
Constructs a DiagnosedSilenceableFailure in the success state.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
void addExtensions()
Add the given extensions to the registry.
This class provides support for representing a failure result, or a valid value of type T.
bool findVar(Value val, unsigned *pos, unsigned offset=0) const
Looks up the position of the variable with the specified Value starting with variables at offset offs...
unsigned appendSymbolVar(ValueRange vals)
This class represents a frozen set of patterns that can be processed by a pattern applicator.
This class allows control over how the GreedyPatternRewriteDriver works.
GreedyRewriteStrictness strictMode
Strict mode can restrict the ops that are added to the worklist during the rewrite.
RewriterBase::Listener * listener
An optional listener that should be notified about IR modifications.
MLIRContext is the top-level object for a collection of MLIR operations.
Listener * getListener() const
Returns the current listener of this builder, or nullptr if this builder doesn't have a listener.
Operation is the basic unit of execution within MLIR.
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
Location getLoc()
The source location the operation was defined or derived from.
unsigned getNumResults()
Return the number of results held by this operation.
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replaces the result op with a new op that is created without verification.
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.
FlatAffineValueConstraints is an extension of FlatLinearValueConstraints with helper functions for Af...
LogicalResult addBound(presburger::BoundType type, unsigned pos, AffineMap boundMap, ValueRange operands)
Adds a bound for the variable at the specified position with constraints being drawn from the specifi...
Base class for extensions of the Transform dialect that supports injecting operations into the Transf...
void registerTransformDialectExtension(DialectRegistry ®istry)
FailureOr< AffineValueMap > simplifyConstrainedMinMaxOp(Operation *op, FlatAffineValueConstraints constraints)
Try to simplify the given affine.min or affine.max op to an affine map with a single result and opera...
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
LogicalResult applyOpPatternsAndFold(ArrayRef< Operation * > ops, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr, bool *allErased=nullptr)
Applies the specified rewrite patterns on ops while also trying to fold these ops.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
DiagnosedDefiniteFailure emitDefiniteFailure(Location loc, const Twine &message={})
Emits a definite failure with the given message.
@ ExistingAndNewOps
Only pre-existing and newly created ops are processed.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...