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 f8e8m0 patterns to lower level bitcasts/shifts.
67
68/// Add patterns to expand scaling ExtF/TruncF ops to equivalent arith ops
70
71/// Add patterns to expand the floating-point min/max ops (`arith.maximumf`/
72/// `minimumf`/`maxnumf`/`minnumf`) into `cmpf` + `select` sequences.
74
75/// Add patterns to expand the signed/unsigned integer min/max ops
76/// (`arith.maxsi`/`maxui`/`minsi`/`minui`) into `cmpi` + `select` sequences.
78
79/// Add patterns to expand both the floating-point and integer min/max ops into
80/// `cmpf`/`cmpi` + `select` sequences. These ops also have a direct
81/// arith-to-llvm lowering, so pipelines that run arith-to-llvm may prefer to
82/// skip this expansion.
84
85/// Add patterns to expand `arith.flush_denormals` into integer arithmetic
86/// (bitcast + bit masks + compare + select). Only matches IEEE-like
87/// floating-point types.
89
90/// Add patterns to expand Arith ops.
92
93/// Add patterns for int range based optimizations.
95 DataFlowSolver &solver);
96
97/// Replace signed ops with unsigned ones where they are proven equivalent.
99 DataFlowSolver &solver);
100
101/// Create a pass which do optimizations based on integer range analysis.
102std::unique_ptr<Pass> createIntRangeOptimizationsPass();
103
104/// Add patterns for int range based narrowing.
106 DataFlowSolver &solver,
107 ArrayRef<unsigned> bitwidthsSupported);
108
109/// Add patterns for narrowing control flow values (loop bounds, steps, etc.)
110/// based on int range analysis.
112 RewritePatternSet &patterns, DataFlowSolver &solver,
113 ArrayRef<unsigned> bitwidthsSupported);
114
115//===----------------------------------------------------------------------===//
116// Registration
117//===----------------------------------------------------------------------===//
119/// Generate the code for registering passes.
120#define GEN_PASS_REGISTRATION
121#include "mlir/Dialect/Arith/Transforms/Passes.h.inc"
122
123} // namespace arith
124} // namespace mlir
125
126#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 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 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.