1 | //===- TestSimplification.cpp - Test simplification -----------------------===// |
---|---|
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 | #include "mlir/Dialect/Arith/IR/Arith.h" |
10 | #include "mlir/Dialect/Mesh/IR/MeshDialect.h" |
11 | #include "mlir/Dialect/Mesh/Transforms/Simplifications.h" |
12 | #include "mlir/IR/SymbolTable.h" |
13 | #include "mlir/Pass/Pass.h" |
14 | #include "mlir/Transforms/GreedyPatternRewriteDriver.h" |
15 | |
16 | using namespace mlir; |
17 | |
18 | namespace { |
19 | struct TestMeshSimplificationsPass |
20 | : public PassWrapper<TestMeshSimplificationsPass, OperationPass<>> { |
21 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMeshSimplificationsPass) |
22 | |
23 | void runOnOperation() override; |
24 | void getDependentDialects(DialectRegistry ®istry) const override { |
25 | registry.insert<arith::ArithDialect, mesh::MeshDialect>(); |
26 | } |
27 | StringRef getArgument() const final { return "test-mesh-simplifications"; } |
28 | StringRef getDescription() const final { return "Test mesh simplifications"; } |
29 | }; |
30 | } // namespace |
31 | |
32 | void TestMeshSimplificationsPass::runOnOperation() { |
33 | RewritePatternSet patterns(&getContext()); |
34 | SymbolTableCollection symbolTableCollection; |
35 | mesh::populateSimplificationPatterns(patterns, symbolTableCollection); |
36 | [[maybe_unused]] LogicalResult status = |
37 | applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); |
38 | assert(succeeded(status) && "Rewrite patters application did not converge."); |
39 | } |
40 | |
41 | namespace mlir { |
42 | namespace test { |
43 | void registerTestMeshSimplificationsPass() { |
44 | PassRegistration<TestMeshSimplificationsPass>(); |
45 | } |
46 | } // namespace test |
47 | } // namespace mlir |
48 |