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
19using namespace mlir;
20
21namespace {
22struct 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 &registry) 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
40void TestMathAlgebraicSimplificationPass::runOnOperation() {
41 RewritePatternSet patterns(&getContext());
42 populateMathAlgebraicSimplificationPatterns(patterns);
43 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
44}
45
46namespace mlir {
47namespace test {
48void registerTestMathAlgebraicSimplificationPass() {
49 PassRegistration<TestMathAlgebraicSimplificationPass>();
50}
51} // namespace test
52} // namespace mlir
53

source code of mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp