52 lines · cpp
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-exception6//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 TestComposeSubViewPass22 : 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 33void TestComposeSubViewPass::getDependentDialects(34 DialectRegistry ®istry) const {35 registry.insert<affine::AffineDialect>();36}37 38void TestComposeSubViewPass::runOnOperation() {39 RewritePatternSet patterns(&getContext());40 memref::populateComposeSubViewPatterns(patterns, &getContext());41 (void)applyPatternsGreedily(getOperation(), std::move(patterns));42}43} // namespace44 45namespace mlir {46namespace test {47void registerTestComposeSubView() {48 PassRegistration<TestComposeSubViewPass>();49}50} // namespace test51} // namespace mlir52