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/LLVMIR/LLVMDialect.h"
14 #include "mlir/Dialect/Math/IR/Math.h"
15 #include "mlir/Dialect/Math/Transforms/Passes.h"
16 #include "mlir/Dialect/Vector/VectorOps.h"
17 #include "mlir/Pass/Pass.h"
18 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
19 
20 using namespace mlir;
21 
22 namespace {
23 struct TestMathAlgebraicSimplificationPass
24     : public PassWrapper<TestMathAlgebraicSimplificationPass, FunctionPass> {
25   void runOnFunction() override;
26   void getDependentDialects(DialectRegistry &registry) 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 } // end anonymous namespace
37 
38 void TestMathAlgebraicSimplificationPass::runOnFunction() {
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