MLIR  20.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_ARITH_TRANSFORMS_PASSES_H_
10 #define MLIR_DIALECT_ARITH_TRANSFORMS_PASSES_H_
11 
12 #include "mlir/Pass/Pass.h"
13 
14 namespace mlir {
15 class DataFlowSolver;
16 class ConversionTarget;
17 class TypeConverter;
18 
19 namespace arith {
20 
21 #define GEN_PASS_DECL
22 #include "mlir/Dialect/Arith/Transforms/Passes.h.inc"
23 
24 class WideIntEmulationConverter;
25 class NarrowTypeEmulationConverter;
26 
27 /// Adds patterns to emulate wide Arith and Function ops over integer
28 /// types into supported ones. This is done by splitting original power-of-two
29 /// i2N integer types into two iN halves.
31  const WideIntEmulationConverter &typeConverter,
32  RewritePatternSet &patterns);
33 
34 /// Adds patterns to emulate narrow Arith and Function ops into wide
35 /// supported types. Users need to add conversions about the computation
36 /// domain of narrow types.
38  const NarrowTypeEmulationConverter &typeConverter,
39  RewritePatternSet &patterns);
40 
41 /// Populate the type conversions needed to emulate the unsupported
42 /// `sourceTypes` with `destType`
43 void populateEmulateUnsupportedFloatsConversions(TypeConverter &converter,
44  ArrayRef<Type> sourceTypes,
45  Type targetType);
46 
47 /// Add rewrite patterns for converting operations that use illegal float types
48 /// to ones that use legal ones.
50  const TypeConverter &converter);
51 
52 /// Set up a dialect conversion to reject arithmetic operations on unsupported
53 /// float types.
54 void populateEmulateUnsupportedFloatsLegality(ConversionTarget &target,
55  const TypeConverter &converter);
56 /// Add patterns to expand Arith ceil/floor division ops.
57 void populateCeilFloorDivExpandOpsPatterns(RewritePatternSet &patterns);
58 
59 /// Add patterns to expand Arith bf16 patterns to lower level bitcasts/shifts.
60 void populateExpandBFloat16Patterns(RewritePatternSet &patterns);
61 
62 /// Add patterns to expand Arith ops.
63 void populateArithExpandOpsPatterns(RewritePatternSet &patterns);
64 
65 /// Create a pass to replace signed ops with unsigned ones where they are proven
66 /// equivalent.
67 std::unique_ptr<Pass> createArithUnsignedWhenEquivalentPass();
68 
69 /// Add patterns for int range based optimizations.
70 void populateIntRangeOptimizationsPatterns(RewritePatternSet &patterns,
71  DataFlowSolver &solver);
72 
73 /// Replace signed ops with unsigned ones where they are proven equivalent.
74 void populateUnsignedWhenEquivalentPatterns(RewritePatternSet &patterns,
75  DataFlowSolver &solver);
76 
77 /// Create a pass which do optimizations based on integer range analysis.
78 std::unique_ptr<Pass> createIntRangeOptimizationsPass();
79 
80 /// Add patterns for int range based narrowing.
81 void populateIntRangeNarrowingPatterns(RewritePatternSet &patterns,
82  DataFlowSolver &solver,
83  ArrayRef<unsigned> bitwidthsSupported);
84 
85 //===----------------------------------------------------------------------===//
86 // Registration
87 //===----------------------------------------------------------------------===//
88 
89 /// Generate the code for registering passes.
90 #define GEN_PASS_REGISTRATION
91 #include "mlir/Dialect/Arith/Transforms/Passes.h.inc"
92 
93 } // namespace arith
94 } // namespace mlir
95 
96 #endif // MLIR_DIALECT_ARITH_TRANSFORMS_PASSES_H_
void populateArithWideIntEmulationPatterns(const WideIntEmulationConverter &typeConverter, RewritePatternSet &patterns)
Adds patterns to emulate wide Arith and Function ops over integer types into supported ones.
void populateUnsignedWhenEquivalentPatterns(RewritePatternSet &patterns, DataFlowSolver &solver)
Replace signed ops with unsigned ones where they are proven equivalent.
void populateExpandBFloat16Patterns(RewritePatternSet &patterns)
Add patterns to expand Arith bf16 patterns to lower level bitcasts/shifts.
Definition: ExpandOps.cpp:397
void populateArithNarrowTypeEmulationPatterns(const NarrowTypeEmulationConverter &typeConverter, RewritePatternSet &patterns)
Adds patterns to emulate narrow Arith and Function ops into wide supported types.
void populateCeilFloorDivExpandOpsPatterns(RewritePatternSet &patterns)
Add patterns to expand Arith ceil/floor division ops.
Definition: ExpandOps.cpp:390
std::unique_ptr< Pass > createIntRangeOptimizationsPass()
Create a pass which do optimizations based on integer range analysis.
void populateEmulateUnsupportedFloatsPatterns(RewritePatternSet &patterns, const TypeConverter &converter)
Add rewrite patterns for converting operations that use illegal float types to ones that use legal on...
void populateEmulateUnsupportedFloatsLegality(ConversionTarget &target, const TypeConverter &converter)
Set up a dialect conversion to reject arithmetic operations on unsupported float types.
void populateArithExpandOpsPatterns(RewritePatternSet &patterns)
Add patterns to expand Arith ops.
Definition: ExpandOps.cpp:402
void populateIntRangeOptimizationsPatterns(RewritePatternSet &patterns, DataFlowSolver &solver)
Add patterns for int range based optimizations.
std::unique_ptr< Pass > createArithUnsignedWhenEquivalentPass()
Create a pass to replace signed ops with unsigned ones where they are proven equivalent.
void populateIntRangeNarrowingPatterns(RewritePatternSet &patterns, DataFlowSolver &solver, ArrayRef< unsigned > bitwidthsSupported)
Add patterns for int range based narrowing.
void populateEmulateUnsupportedFloatsConversions(TypeConverter &converter, ArrayRef< Type > sourceTypes, Type targetType)
Populate the type conversions needed to emulate the unsupported sourceTypes with destType
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns