1 | //===- TestTransformDialectInterpreter.cpp --------------------------------===// |
---|---|
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 defines a test pass that interprets Transform dialect operations in |
10 | // the module. |
11 | // |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h" |
15 | #include "mlir/IR/BuiltinOps.h" |
16 | #include "mlir/Pass/Pass.h" |
17 | |
18 | using namespace mlir; |
19 | |
20 | namespace { |
21 | template <typename Derived> |
22 | class OpPassWrapper : public PassWrapper<Derived, OperationPass<>> {}; |
23 | |
24 | struct TestTransformDialectEraseSchedulePass |
25 | : public PassWrapper<TestTransformDialectEraseSchedulePass, |
26 | OperationPass<ModuleOp>> { |
27 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID( |
28 | TestTransformDialectEraseSchedulePass) |
29 | |
30 | StringRef getArgument() const final { |
31 | return "test-transform-dialect-erase-schedule"; |
32 | } |
33 | |
34 | StringRef getDescription() const final { |
35 | return "erase transform dialect schedule from the IR"; |
36 | } |
37 | |
38 | void runOnOperation() override { |
39 | getOperation()->walk<WalkOrder::PreOrder>([&](Operation *nestedOp) { |
40 | if (isa<transform::TransformOpInterface>(nestedOp)) { |
41 | nestedOp->erase(); |
42 | return WalkResult::skip(); |
43 | } |
44 | return WalkResult::advance(); |
45 | }); |
46 | } |
47 | }; |
48 | } // namespace |
49 | |
50 | namespace mlir { |
51 | namespace test { |
52 | /// Registers the test pass for erasing transform dialect ops. |
53 | void registerTestTransformDialectEraseSchedulePass() { |
54 | PassRegistration<TestTransformDialectEraseSchedulePass> reg; |
55 | } |
56 | } // namespace test |
57 | } // namespace mlir |
58 |