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
18using namespace mlir;
19
20namespace {
21struct 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 &registry) const override;
31};
32
33void TestComposeSubViewPass::getDependentDialects(
34 DialectRegistry &registry) const {
35 registry.insert<affine::AffineDialect>();
36}
37
38void TestComposeSubViewPass::runOnOperation() {
39 RewritePatternSet patterns(&getContext());
40 memref::populateComposeSubViewPatterns(patterns, context: &getContext());
41 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
42}
43} // namespace
44
45namespace mlir {
46namespace test {
47void registerTestComposeSubView() {
48 PassRegistration<TestComposeSubViewPass>();
49}
50} // namespace test
51} // namespace mlir
52

source code of mlir/test/lib/Dialect/MemRef/TestComposeSubView.cpp