1 //===- TestComposeSubView.cpp - Test composed subviews --------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements a pass to test the composed subview patterns.
11 //===----------------------------------------------------------------------===//
13 #include "mlir/Dialect/Affine/IR/AffineOps.h"
14 #include "mlir/Dialect/MemRef/Transforms/ComposeSubView.h"
15 #include "mlir/Pass/Pass.h"
16 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
21 struct TestComposeSubViewPass
22 : public PassWrapper
<TestComposeSubViewPass
, OperationPass
<>> {
23 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestComposeSubViewPass
)
25 StringRef
getArgument() const final
{ return "test-compose-subview"; }
26 StringRef
getDescription() const final
{
27 return "Test combining composed subviews";
29 void runOnOperation() override
;
30 void getDependentDialects(DialectRegistry
®istry
) const override
;
33 void TestComposeSubViewPass::getDependentDialects(
34 DialectRegistry
®istry
) const {
35 registry
.insert
<affine::AffineDialect
>();
38 void TestComposeSubViewPass::runOnOperation() {
39 RewritePatternSet
patterns(&getContext());
40 memref::populateComposeSubViewPatterns(patterns
, &getContext());
41 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns
));
47 void registerTestComposeSubView() {
48 PassRegistration
<TestComposeSubViewPass
>();