1 //===- TestComposeSubView.cpp - Test composed subviews --------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file implements a pass to test the composed subview patterns. 10 // 11 //===----------------------------------------------------------------------===// 12 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" 17 18 using namespace mlir; 19 20 namespace { 21 struct TestComposeSubViewPass 22 : public PassWrapper<TestComposeSubViewPass, OperationPass<FuncOp>> { 23 StringRef getArgument() const final { return "test-compose-subview"; } 24 StringRef getDescription() const final { 25 return "Test combining composed subviews"; 26 } 27 void runOnOperation() override; 28 void getDependentDialects(DialectRegistry ®istry) const override; 29 }; 30 31 void TestComposeSubViewPass::getDependentDialects( 32 DialectRegistry ®istry) const { 33 registry.insert<AffineDialect>(); 34 } 35 36 void TestComposeSubViewPass::runOnOperation() { 37 RewritePatternSet patterns(&getContext()); 38 memref::populateComposeSubViewPatterns(patterns, &getContext()); 39 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); 40 } 41 } // namespace 42 43 namespace mlir { 44 namespace test { 45 void registerTestComposeSubView() { 46 PassRegistration<TestComposeSubViewPass>(); 47 } 48 } // namespace test 49 } // namespace mlir 50