1 //===- TestAlgebraicSimplification.cpp - Test algebraic 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 // This file contains test passes for algebraic simplification patterns. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "mlir/Dialect/Math/IR/Math.h" 14 #include "mlir/Dialect/Math/Transforms/Passes.h" 15 #include "mlir/Dialect/Vector/IR/VectorOps.h" 16 #include "mlir/Pass/Pass.h" 17 #include "mlir/Transforms/GreedyPatternRewriteDriver.h" 18 19 using namespace mlir; 20 21 namespace { 22 struct TestMathAlgebraicSimplificationPass 23 : public PassWrapper<TestMathAlgebraicSimplificationPass, 24 OperationPass<FuncOp>> { 25 void runOnOperation() override; 26 void getDependentDialects(DialectRegistry ®istry) const override { 27 registry.insert<vector::VectorDialect, math::MathDialect>(); 28 } 29 StringRef getArgument() const final { 30 return "test-math-algebraic-simplification"; 31 } 32 StringRef getDescription() const final { 33 return "Test math algebraic simplification"; 34 } 35 }; 36 } // namespace 37 38 void TestMathAlgebraicSimplificationPass::runOnOperation() { 39 RewritePatternSet patterns(&getContext()); 40 populateMathAlgebraicSimplificationPatterns(patterns); 41 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); 42 } 43 44 namespace mlir { 45 namespace test { 46 void registerTestMathAlgebraicSimplificationPass() { 47 PassRegistration<TestMathAlgebraicSimplificationPass>(); 48 } 49 } // namespace test 50 } // namespace mlir 51