1 //===- TestAlgebraicSimplification.cpp - Test algebraic simplification ----===//
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
7 //===----------------------------------------------------------------------===//
9 // This file contains test passes for algebraic simplification patterns.
11 //===----------------------------------------------------------------------===//
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"
22 struct TestMathAlgebraicSimplificationPass
23 : public PassWrapper
<TestMathAlgebraicSimplificationPass
, OperationPass
<>> {
24 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
25 TestMathAlgebraicSimplificationPass
)
27 void runOnOperation() override
;
28 void getDependentDialects(DialectRegistry
®istry
) const override
{
29 registry
.insert
<vector::VectorDialect
, math::MathDialect
>();
31 StringRef
getArgument() const final
{
32 return "test-math-algebraic-simplification";
34 StringRef
getDescription() const final
{
35 return "Test math algebraic simplification";
40 void TestMathAlgebraicSimplificationPass::runOnOperation() {
41 RewritePatternSet
patterns(&getContext());
42 populateMathAlgebraicSimplificationPatterns(patterns
);
43 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns
));
48 void registerTestMathAlgebraicSimplificationPass() {
49 PassRegistration
<TestMathAlgebraicSimplificationPass
>();