MLIR  21.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 // This header file defines a set of transforms specific for the AffineOps
10 // dialect.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_DIALECT_AFFINE_PASSES_H
15 #define MLIR_DIALECT_AFFINE_PASSES_H
16 
18 #include "mlir/Pass/Pass.h"
19 #include <limits>
20 
21 namespace mlir {
22 
23 namespace func {
24 class FuncOp;
25 } // namespace func
26 
27 namespace affine {
28 class AffineForOp;
29 
30 /// Fusion mode to attempt. The default mode `Greedy` does both
31 /// producer-consumer and sibling fusion.
33 
34 #define GEN_PASS_DECL
35 #include "mlir/Dialect/Affine/Passes.h.inc"
36 
37 /// Creates a simplification pass for affine structures (maps and sets). In
38 /// addition, this pass also normalizes memrefs to have the trivial (identity)
39 /// layout map.
40 std::unique_ptr<OperationPass<func::FuncOp>>
42 
43 /// Creates a loop invariant code motion pass that hoists loop invariant
44 /// operations out of affine loops.
45 std::unique_ptr<OperationPass<func::FuncOp>>
47 
48 /// Apply normalization transformations to affine loop-like ops. If
49 /// `promoteSingleIter` is true, single iteration loops are promoted (i.e., the
50 /// loop is replaced by its loop body).
51 std::unique_ptr<OperationPass<func::FuncOp>>
52 createAffineLoopNormalizePass(bool promoteSingleIter = false);
53 
54 /// Performs packing (or explicit copying) of accessed memref regions into
55 /// buffers in the specified faster memory space through either pointwise copies
56 /// or DMA operations.
57 std::unique_ptr<OperationPass<func::FuncOp>> createAffineDataCopyGenerationPass(
58  unsigned slowMemorySpace, unsigned fastMemorySpace,
59  unsigned tagMemorySpace = 0, int minDmaTransferSize = 1024,
60  uint64_t fastMemCapacityBytes = std::numeric_limits<uint64_t>::max());
61 /// Overload relying on pass options for initialization.
62 std::unique_ptr<OperationPass<func::FuncOp>>
64 
65 /// Creates a pass to replace affine memref accesses by scalars using store to
66 /// load forwarding and redundant load elimination; consequently also eliminate
67 /// dead allocs.
68 std::unique_ptr<OperationPass<func::FuncOp>>
70 
71 /// Creates a pass that transforms perfectly nested loops with independent
72 /// bounds into a single loop.
73 std::unique_ptr<OperationPass<func::FuncOp>> createLoopCoalescingPass();
74 
75 /// Creates a loop fusion pass which fuses affine loop nests at the top-level of
76 /// the operation the pass is created on according to the type of fusion
77 /// specified in `fusionMode`. Buffers of size less than or equal to
78 /// `localBufSizeThreshold` are promoted to memory space `fastMemorySpace`.
79 std::unique_ptr<Pass>
80 createLoopFusionPass(unsigned fastMemorySpace = 0,
81  uint64_t localBufSizeThreshold = 0,
82  bool maximalFusion = false,
83  enum FusionMode fusionMode = FusionMode::Greedy);
84 
85 /// Creates a pass to perform tiling on loop nests.
86 std::unique_ptr<OperationPass<func::FuncOp>>
87 createLoopTilingPass(uint64_t cacheSizeBytes);
88 /// Overload relying on pass options for initialization.
89 std::unique_ptr<OperationPass<func::FuncOp>> createLoopTilingPass();
90 
91 /// Creates a loop unrolling pass with the provided parameters.
92 /// 'getUnrollFactor' is a function callback for clients to supply a function
93 /// that computes an unroll factor - the callback takes precedence over unroll
94 /// factors supplied through other means. If -1 is passed as the unrollFactor
95 /// and no callback is provided, anything passed from the command-line (if at
96 /// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor).
97 std::unique_ptr<InterfacePass<FunctionOpInterface>> createLoopUnrollPass(
98  int unrollFactor = -1, bool unrollUpToFactor = false,
99  bool unrollFull = false,
100  const std::function<unsigned(AffineForOp)> &getUnrollFactor = nullptr);
101 
102 /// Creates a loop unroll jam pass to unroll jam by the specified factor. A
103 /// factor of -1 lets the pass use the default factor or the one on the command
104 /// line if provided.
105 std::unique_ptr<InterfacePass<FunctionOpInterface>>
106 createLoopUnrollAndJamPass(int unrollJamFactor = -1);
107 
108 /// Creates a pass to pipeline explicit movement of data across levels of the
109 /// memory hierarchy.
110 std::unique_ptr<OperationPass<func::FuncOp>> createPipelineDataTransferPass();
111 
112 /// Creates a pass to expand affine index operations into more fundamental
113 /// operations (not necessarily restricted to Affine dialect).
114 std::unique_ptr<Pass> createAffineExpandIndexOpsPass();
115 
116 /// Creates a pass to expand affine index operations into affine.apply
117 /// operations.
118 std::unique_ptr<Pass> createAffineExpandIndexOpsAsAffinePass();
119 
120 //===----------------------------------------------------------------------===//
121 // Registration
122 //===----------------------------------------------------------------------===//
123 
124 /// Generate the code for registering passes.
125 #define GEN_PASS_REGISTRATION
126 #include "mlir/Dialect/Affine/Passes.h.inc"
127 
128 } // namespace affine
129 } // namespace mlir
130 
131 #endif // MLIR_DIALECT_AFFINE_PASSES_H
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)
std::unique_ptr< OperationPass< func::FuncOp > > createAffineScalarReplacementPass()
Creates a pass to replace affine memref accesses by scalars using store to load forwarding and redund...
std::unique_ptr< OperationPass< func::FuncOp > > createAffineLoopInvariantCodeMotionPass()
Creates a loop invariant code motion pass that hoists loop invariant operations out of affine loops.
std::unique_ptr< OperationPass< func::FuncOp > > createLoopCoalescingPass()
Creates a pass that transforms perfectly nested loops with independent bounds into a single loop.
std::unique_ptr< OperationPass< func::FuncOp > > createAffineLoopNormalizePass(bool promoteSingleIter=false)
Apply normalization transformations to affine loop-like ops.
std::unique_ptr< OperationPass< func::FuncOp > > createAffineDataCopyGenerationPass(unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace=0, int minDmaTransferSize=1024, uint64_t fastMemCapacityBytes=std::numeric_limits< uint64_t >::max())
Performs packing (or explicit copying) of accessed memref regions into buffers in the specified faste...
std::unique_ptr< Pass > createLoopFusionPass(unsigned fastMemorySpace=0, uint64_t localBufSizeThreshold=0, bool maximalFusion=false, enum FusionMode fusionMode=FusionMode::Greedy)
Creates a loop fusion pass which fuses affine loop nests at the top-level of the operation the pass i...
FusionMode
Fusion mode to attempt.
Definition: Passes.h:32
@ ProducerConsumer
Definition: Passes.h:32
std::unique_ptr< OperationPass< func::FuncOp > > createLoopTilingPass(uint64_t cacheSizeBytes)
Creates a pass to perform tiling on loop nests.
Definition: LoopTiling.cpp:68
std::unique_ptr< Pass > createAffineExpandIndexOpsPass()
Creates a pass to expand affine index operations into more fundamental operations (not necessarily re...
std::unique_ptr< OperationPass< func::FuncOp > > createSimplifyAffineStructuresPass()
Creates a simplification pass for affine structures (maps and sets).
std::unique_ptr< OperationPass< func::FuncOp > > createPipelineDataTransferPass()
Creates a pass to pipeline explicit movement of data across levels of the memory hierarchy.
std::unique_ptr< InterfacePass< FunctionOpInterface > > createLoopUnrollAndJamPass(int unrollJamFactor=-1)
Creates a loop unroll jam pass to unroll jam by the specified factor.
std::unique_ptr< Pass > createAffineExpandIndexOpsAsAffinePass()
Creates a pass to expand affine index operations into affine.apply operations.
std::unique_ptr< InterfacePass< FunctionOpInterface > > createLoopUnrollPass(int unrollFactor=-1, bool unrollUpToFactor=false, bool unrollFull=false, const std::function< unsigned(AffineForOp)> &getUnrollFactor=nullptr)
Creates a loop unrolling pass with the provided parameters.
Definition: LoopUnroll.cpp:149
Include the generated interface declarations.