| 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<>> { |
| 23 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestComposeSubViewPass) |
| 24 | |
| 25 | StringRef getArgument() const final { return "test-compose-subview"; } |
| 26 | StringRef getDescription() const final { |
| 27 | return "Test combining composed subviews"; |
| 28 | } |
| 29 | void runOnOperation() override; |
| 30 | void getDependentDialects(DialectRegistry ®istry) const override; |
| 31 | }; |
| 32 | |
| 33 | void TestComposeSubViewPass::getDependentDialects( |
| 34 | DialectRegistry ®istry) const { |
| 35 | registry.insert<affine::AffineDialect>(); |
| 36 | } |
| 37 | |
| 38 | void TestComposeSubViewPass::runOnOperation() { |
| 39 | RewritePatternSet patterns(&getContext()); |
| 40 | memref::populateComposeSubViewPatterns(patterns, context: &getContext()); |
| 41 | (void)applyPatternsGreedily(getOperation(), std::move(patterns)); |
| 42 | } |
| 43 | } // namespace |
| 44 | |
| 45 | namespace mlir { |
| 46 | namespace test { |
| 47 | void registerTestComposeSubView() { |
| 48 | PassRegistration<TestComposeSubViewPass>(); |
| 49 | } |
| 50 | } // namespace test |
| 51 | } // namespace mlir |
| 52 |
