Fix GCC build problem with 288f05f related to SmallVector. (#116958)
[llvm-project.git] / mlir / test / lib / Dialect / Math / TestExpandMath.cpp
blob69af2a08b97bdee13a1bb9ca950acecd925e3ffb
1 //===- TestExpandMath.cpp - Test expand math op into exp form -------------===//
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 expanding math operations.
11 //===----------------------------------------------------------------------===//
13 #include "mlir/Dialect/Arith/IR/Arith.h"
14 #include "mlir/Dialect/Math/Transforms/Passes.h"
15 #include "mlir/Dialect/SCF/IR/SCF.h"
16 #include "mlir/Dialect/Vector/IR/VectorOps.h"
17 #include "mlir/Pass/Pass.h"
18 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
20 using namespace mlir;
22 namespace {
23 struct TestExpandMathPass
24 : public PassWrapper<TestExpandMathPass, OperationPass<>> {
25 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestExpandMathPass)
27 void runOnOperation() override;
28 StringRef getArgument() const final { return "test-expand-math"; }
29 void getDependentDialects(DialectRegistry &registry) const override {
30 registry
31 .insert<arith::ArithDialect, scf::SCFDialect, vector::VectorDialect>();
33 StringRef getDescription() const final { return "Test expanding math"; }
35 } // namespace
37 void TestExpandMathPass::runOnOperation() {
38 RewritePatternSet patterns(&getContext());
39 populateExpandCtlzPattern(patterns);
40 populateExpandExp2FPattern(patterns);
41 populateExpandTanPattern(patterns);
42 populateExpandSinhPattern(patterns);
43 populateExpandCoshPattern(patterns);
44 populateExpandTanhPattern(patterns);
45 populateExpandAsinhPattern(patterns);
46 populateExpandAcoshPattern(patterns);
47 populateExpandAtanhPattern(patterns);
48 populateExpandFmaFPattern(patterns);
49 populateExpandFloorFPattern(patterns);
50 populateExpandCeilFPattern(patterns);
51 populateExpandPowFPattern(patterns);
52 populateExpandFPowIPattern(patterns);
53 populateExpandRoundFPattern(patterns);
54 populateExpandRoundEvenPattern(patterns);
55 populateExpandRsqrtPattern(patterns);
56 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
59 namespace mlir {
60 namespace test {
61 void registerTestExpandMathPass() { PassRegistration<TestExpandMathPass>(); }
62 } // namespace test
63 } // namespace mlir