1 //===- TestSimplification.cpp - Test simplification -----------------------===//
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 #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"
19 struct TestMeshSimplificationsPass
20 : public PassWrapper
<TestMeshSimplificationsPass
, OperationPass
<>> {
21 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMeshSimplificationsPass
)
23 void runOnOperation() override
;
24 void getDependentDialects(DialectRegistry
®istry
) const override
{
25 registry
.insert
<arith::ArithDialect
, mesh::MeshDialect
>();
27 StringRef
getArgument() const final
{ return "test-mesh-simplifications"; }
28 StringRef
getDescription() const final
{ return "Test mesh simplifications"; }
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.");
43 void registerTestMeshSimplificationsPass() {
44 PassRegistration
<TestMeshSimplificationsPass
>();