22 #define GEN_PASS_DEF_AFFINEEXPANDINDEXOPS
23 #include "mlir/Dialect/Affine/Passes.h.inc"
33 struct LowerDelinearizeIndexOps
36 LogicalResult matchAndRewrite(AffineDelinearizeIndexOp op,
38 FailureOr<SmallVector<Value>> multiIndex =
40 llvm::to_vector(op.getBasis()));
41 if (failed(multiIndex))
48 class ExpandAffineIndexOpsPass
49 :
public affine::impl::AffineExpandIndexOpsBase<ExpandAffineIndexOpsPass> {
51 ExpandAffineIndexOpsPass() =
default;
53 void runOnOperation()
override {
59 return signalPassFailure();
71 return std::make_unique<ExpandAffineIndexOpsPass>();
static MLIRContext * getContext(OpFoldResult val)
MLIRContext is the top-level object for a collection of MLIR operations.
Location getLoc()
The source location the operation was defined or derived from.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
RewritePatternSet & insert(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
MLIRContext * getContext() const
virtual void replaceOp(Operation *op, ValueRange newValues)
Replace the results of the given (original) operation with the specified list of values (replacements...
FailureOr< SmallVector< Value > > delinearizeIndex(OpBuilder &b, Location loc, Value linearIndex, ArrayRef< Value > basis)
Generate the IR to delinearize linearIndex given the basis and return the multi-index.
std::unique_ptr< Pass > createAffineExpandIndexOpsPass()
Creates a pass to expand affine index operations into more fundamental operations (not necessarily re...
void populateAffineExpandIndexOpsPatterns(RewritePatternSet &patterns)
Populate patterns that expand affine index operations into more fundamental operations (not necessari...
Include the generated interface declarations.
LogicalResult applyPatternsAndFoldGreedily(Region ®ion, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr)
Rewrite ops in the given region, which must be isolated from above, by repeatedly applying the highes...
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...