MLIR 24.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//===----------------------------------------------------------------------===//
9#ifndef MLIR_DIALECT_ARITH_TRANSFORMS_PASSES_H_
10#define MLIR_DIALECT_ARITH_TRANSFORMS_PASSES_H_
12#include "mlir/Pass/Pass.h"
13
14namespace mlir {
15class DataFlowSolver;
17class TypeConverter;
18
19namespace arith {
21#define GEN_PASS_DECL
22#include "mlir/Dialect/Arith/Transforms/Passes.h.inc"
23
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`
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.
55 const TypeConverter &converter);
56/// Add patterns to expand Arith ceil/floor division ops.
58
59/// Add patterns to expand Arith bf16 patterns to lower level bitcasts/shifts.
61
62/// Add patterns to expand Arith f4e2m1 patterns to lower level bitcasts/shifts.
64
65/// Add patterns to expand Arith f8e5m2 patterns to lower level bitcasts/shifts.
67
68/// Add patterns to expand Arith f8e4m3fn patterns to lower level
69/// bitcasts/shifts.
71
72/// Add patterns to expand Arith f8e8m0 patterns to lower level bitcasts/shifts.
74
75/// Add patterns to expand scaling ExtF/TruncF ops to equivalent arith ops
77
78/// Add patterns to expand the floating-point min/max ops (`arith.maximumf`/
79/// `minimumf`/`maxnumf`/`minnumf`) into `cmpf` + `select` sequences.
81
82/// Add patterns to expand the signed/unsigned integer min/max ops
83/// (`arith.maxsi`/`maxui`/`minsi`/`minui`) into `cmpi` + `select` sequences.
85
86/// Add patterns to expand both the floating-point and integer min/max ops into
87/// `cmpf`/`cmpi` + `select` sequences. These ops also have a direct
88/// arith-to-llvm lowering, so pipelines that run arith-to-llvm may prefer to
89/// skip this expansion.
91
92/// Add patterns to expand `arith.flush_denormals` into integer arithmetic
93/// (bitcast + bit masks + compare + select). Only matches IEEE-like
94/// floating-point types.
96
97/// Add patterns to expand Arith ops.
99
100/// Add patterns for int range based optimizations.
102 DataFlowSolver &solver);
103
104/// Replace signed ops with unsigned ones where they are proven equivalent.
106 DataFlowSolver &solver);
107
108/// Create a pass which do optimizations based on integer range analysis.
109std::unique_ptr<Pass> createIntRangeOptimizationsPass();
110
111/// Add patterns for int range based narrowing.
113 DataFlowSolver &solver,
114 ArrayRef<unsigned> bitwidthsSupported);
115
116/// Add patterns for narrowing control flow values (loop bounds, steps, etc.)
117/// based on int range analysis.
119 RewritePatternSet &patterns, DataFlowSolver &solver,
120 ArrayRef<unsigned> bitwidthsSupported);
121
122//===----------------------------------------------------------------------===//
123// Registration
124//===----------------------------------------------------------------------===//
125
126/// Generate the code for registering passes.
127#define GEN_PASS_REGISTRATION
128#include "mlir/Dialect/Arith/Transforms/Passes.h.inc"
129
130} // namespace arith
131} // namespace mlir
132
133#endif // MLIR_DIALECT_ARITH_TRANSFORMS_PASSES_H_
The general data-flow analysis solver.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
Converts narrow integer or float types that are not supported by the target hardware to wider types.
Converts integer types that are too wide for the target by splitting them in two halves and thus turn...
void populateExpandF8E4M3FNPatterns(RewritePatternSet &patterns)
Add patterns to expand Arith f8e4m3fn patterns to lower level bitcasts/shifts.
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.
void populateExpandScalingExtTruncPatterns(RewritePatternSet &patterns)
Add patterns to expand scaling ExtF/TruncF ops to equivalent arith ops.
void populateExpandF8E8M0Patterns(RewritePatternSet &patterns)
Add patterns to expand Arith f8e8m0 patterns to lower level bitcasts/shifts.
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.
void populateExpandF4E2M1Patterns(RewritePatternSet &patterns)
Add patterns to expand Arith f4e2m1 patterns to lower level bitcasts/shifts.
void populateExpandFlushDenormalsPatterns(RewritePatternSet &patterns)
Add patterns to expand arith.flush_denormals into integer arithmetic (bitcast + bit masks + compare +...
void populateExpandMinMaxFPatterns(RewritePatternSet &patterns)
Add patterns to expand the floating-point min/max ops (arith.maximumf/ minimumf/maxnumf/minnumf) into...
std::unique_ptr< Pass > createIntRangeOptimizationsPass()
Create a pass which do optimizations based on integer range analysis.
void populateControlFlowValuesNarrowingPatterns(RewritePatternSet &patterns, DataFlowSolver &solver, ArrayRef< unsigned > bitwidthsSupported)
Add patterns for narrowing control flow values (loop bounds, steps, etc.) based on int range analysis...
void populateExpandMinMaxIPatterns(RewritePatternSet &patterns)
Add patterns to expand the signed/unsigned integer min/max ops (arith.maxsi/maxui/minsi/minui) into c...
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 populateExpandMinMaxPatterns(RewritePatternSet &patterns)
Add patterns to expand both the floating-point and integer min/max ops into cmpf/cmpi + select sequen...
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.
void populateIntRangeOptimizationsPatterns(RewritePatternSet &patterns, DataFlowSolver &solver)
Add patterns for int range based optimizations.
void populateExpandF8E5M2Patterns(RewritePatternSet &patterns)
Add patterns to expand Arith f8e5m2 patterns to lower level bitcasts/shifts.
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.