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