Fix GCC build problem with 288f05f related to SmallVector. (#116958)
[llvm-project.git] / mlir / test / lib / Dialect / Affine / TestDecomposeAffineOps.cpp
blob429784f26e03846f8d99143c867860e9bf0a54a3
1 //===- TestDecomposeAffineOps.cpp - Test affine ops decomposition utility -===//
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 affine data copy utility functions and
10 // options.
12 //===----------------------------------------------------------------------===//
14 #include "mlir/Dialect/Affine/IR/AffineOps.h"
15 #include "mlir/Dialect/Affine/Transforms/Transforms.h"
16 #include "mlir/Dialect/Func/IR/FuncOps.h"
17 #include "mlir/IR/PatternMatch.h"
18 #include "mlir/Pass/Pass.h"
19 #include "mlir/Transforms/Passes.h"
21 #define PASS_NAME "test-decompose-affine-ops"
23 using namespace mlir;
24 using namespace mlir::affine;
26 namespace {
28 struct TestDecomposeAffineOps
29 : public PassWrapper<TestDecomposeAffineOps, OperationPass<func::FuncOp>> {
30 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestDecomposeAffineOps)
32 StringRef getArgument() const final { return PASS_NAME; }
33 StringRef getDescription() const final {
34 return "Tests affine ops decomposition utility functions.";
36 TestDecomposeAffineOps() = default;
37 TestDecomposeAffineOps(const TestDecomposeAffineOps &pass) = default;
39 void runOnOperation() override;
42 } // namespace
44 void TestDecomposeAffineOps::runOnOperation() {
45 IRRewriter rewriter(&getContext());
46 this->getOperation().walk([&](AffineApplyOp op) {
47 rewriter.setInsertionPoint(op);
48 reorderOperandsByHoistability(rewriter, op);
49 (void)decompose(rewriter, op);
50 });
53 namespace mlir {
54 void registerTestDecomposeAffineOpPass() {
55 PassRegistration<TestDecomposeAffineOps>();
57 } // namespace mlir