MLIR  22.0.0git
Passes.h
Go to the documentation of this file.
1 //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===//
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 #ifndef MLIR_DIALECT_MATH_TRANSFORMS_PASSES_H_
10 #define MLIR_DIALECT_MATH_TRANSFORMS_PASSES_H_
11 
12 #include "mlir/IR/PatternMatch.h"
13 #include "mlir/Pass/Pass.h"
14 
15 namespace mlir {
16 namespace math {
17 #define GEN_PASS_DECL
18 #define GEN_PASS_REGISTRATION
19 #include "mlir/Dialect/Math/Transforms/Passes.h.inc"
20 } // namespace math
21 
22 class ConversionTarget;
23 class RewritePatternSet;
24 class TypeConverter;
25 
26 namespace math {
27 /// Adds patterns to expand math operations into other more fundamental
28 /// operations. For example, hyperbolic functions are expanded into expressions
29 /// using `exp`. If `opMnemonics` is empty then all available patterns will be
30 /// added, otherwise only the patterns corresponding to ops in `opMnemonics`
31 /// will be added to the set.
32 void populateExpansionPatterns(RewritePatternSet &patterns,
33  ArrayRef<StringRef> opMnemonics = {});
34 } // namespace math
35 
37 
39  // Enables the use of AVX2 intrinsics in some of the approximations.
40  bool enableAvx2 = false;
41 };
42 
46 
47 // Adds patterns to convert to f32 around math functions for which `predicate`
48 // returns true.
50  RewritePatternSet &patterns, llvm::function_ref<bool(StringRef)> predicate,
51  PatternBenefit = 1);
52 
53 // Adds patterns to enable polynomial approximations for math functions for
54 // which `predicate` returns true.
56  RewritePatternSet &patterns, llvm::function_ref<bool(StringRef)> predicate,
57  PatternBenefit = 1);
58 
59 // Legacy. Calls both populateMathF32ExpansionPatterns and
60 // populateMathPolynomialApproximationPatterns with predicates enabling a
61 // certain set of math function rewrites, that probably can't be changed for
62 // compatibility reasons. Notice that unlike
63 // populateMathPolynomialApproximationPatterns(patterns, predicate), this
64 // overload also calls populateMathF32ExpansionPatterns.
65 // Prefer calling these functions directly:
66 // * populateMathF32ExpansionPatterns(patterns, predicate)
67 // * populateMathPolynomialApproximationPatterns(patterns, predicate)
71 
72 void populateUpliftToFMAPatterns(RewritePatternSet &patterns);
73 
74 namespace math {
76  TypeConverter &typeConverter, const SetVector<Type> &sourceTypes,
77  Type targetType);
79  ConversionTarget &target, TypeConverter &typeConverter);
80 void populateExtendToSupportedTypesPatterns(RewritePatternSet &patterns,
81  const TypeConverter &typeConverter);
82 } // namespace math
83 } // namespace mlir
84 
85 #endif // MLIR_DIALECT_MATH_TRANSFORMS_PASSES_H_
static llvm::ManagedStatic< PassManagerOptions > options
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
Definition: PatternMatch.h:34
void populateExtendToSupportedTypesPatterns(RewritePatternSet &patterns, const TypeConverter &typeConverter)
void populateExtendToSupportedTypesConversionTarget(ConversionTarget &target, TypeConverter &typeConverter)
void populateExpansionPatterns(RewritePatternSet &patterns, ArrayRef< StringRef > opMnemonics={})
Adds patterns to expand math operations into other more fundamental operations.
Definition: ExpandOps.cpp:678
void populateExtendToSupportedTypesTypeConverter(TypeConverter &typeConverter, const SetVector< Type > &sourceTypes, Type targetType)
Include the generated interface declarations.
void populatePolynomialApproximateErfcPattern(RewritePatternSet &patterns)
void populateMathF32ExpansionPatterns(RewritePatternSet &patterns, llvm::function_ref< bool(StringRef)> predicate, PatternBenefit=1)
void populatePolynomialApproximateErfPattern(RewritePatternSet &patterns)
void populatePolynomialApproximateTanhPattern(RewritePatternSet &patterns)
void populateUpliftToFMAPatterns(RewritePatternSet &patterns)
Definition: UpliftToFMA.cpp:76
void populateMathAlgebraicSimplificationPatterns(RewritePatternSet &patterns)
const FrozenRewritePatternSet & patterns
void populateMathPolynomialApproximationPatterns(RewritePatternSet &patterns, llvm::function_ref< bool(StringRef)> predicate, PatternBenefit=1)