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