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/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, FunctionPass> { 24 void runOnFunction() override; 25 void getDependentDialects(DialectRegistry ®istry) const override { 26 registry.insert<vector::VectorDialect, math::MathDialect>(); 27 } 28 StringRef getArgument() const final { 29 return "test-math-algebraic-simplification"; 30 } 31 StringRef getDescription() const final { 32 return "Test math algebraic simplification"; 33 } 34 }; 35 } // end anonymous namespace 36 37 void TestMathAlgebraicSimplificationPass::runOnFunction() { 38 RewritePatternSet patterns(&getContext()); 39 populateMathAlgebraicSimplificationPatterns(patterns); 40 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); 41 } 42 43 namespace mlir { 44 namespace test { 45 void registerTestMathAlgebraicSimplificationPass() { 46 PassRegistration<TestMathAlgebraicSimplificationPass>(); 47 } 48 } // namespace test 49 } // namespace mlir 50