1 //===- TestDecomposeAffineOps.cpp - Test affine ops decomposition utility -===//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements a pass to test affine data copy utility functions and
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"
24 using namespace mlir::affine
;
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
;
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
);
54 void registerTestDecomposeAffineOpPass() {
55 PassRegistration
<TestDecomposeAffineOps
>();