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//===----------------------------------------------------------------------===//
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,
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,
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 Arith ops.
73
74/// Add patterns for int range based optimizations.
76 DataFlowSolver &solver);
77
78/// Replace signed ops with unsigned ones where they are proven equivalent.
80 DataFlowSolver &solver);
81
82/// Create a pass which do optimizations based on integer range analysis.
83std::unique_ptr<Pass> createIntRangeOptimizationsPass();
84
85/// Add patterns for int range based narrowing.
87 DataFlowSolver &solver,
88 ArrayRef<unsigned> bitwidthsSupported);
89
90//===----------------------------------------------------------------------===//
91// Registration
92//===----------------------------------------------------------------------===//
93
94/// Generate the code for registering passes.
95#define GEN_PASS_REGISTRATION
96#include "mlir/Dialect/Arith/Transforms/Passes.h.inc"
97
98} // namespace arith
99} // namespace mlir
100
101#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.
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.
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.
const FrozenRewritePatternSet & patterns