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