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 //===----------------------------------------------------------------------===//
8 //
9 // This header file defines prototypes that expose pass constructors in the loop
10 // transformation library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_TRANSFORMS_PASSES_H
15 #define MLIR_TRANSFORMS_PASSES_H
16 
17 #include "mlir/Pass/Pass.h"
18 #include "mlir/Pass/PassManager.h"
22 #include "llvm/Support/Debug.h"
23 #include <limits>
24 #include <memory>
25 
26 namespace mlir {
27 
28 class GreedyRewriteConfig;
29 
30 //===----------------------------------------------------------------------===//
31 // Passes
32 //===----------------------------------------------------------------------===//
33 
34 #define GEN_PASS_DECL_CANONICALIZER
35 #define GEN_PASS_DECL_CONTROLFLOWSINK
36 #define GEN_PASS_DECL_CSE
37 #define GEN_PASS_DECL_INLINER
38 #define GEN_PASS_DECL_LOOPINVARIANTCODEMOTION
39 #define GEN_PASS_DECL_MEM2REG
40 #define GEN_PASS_DECL_PRINTIRPASS
41 #define GEN_PASS_DECL_PRINTOPSTATS
42 #define GEN_PASS_DECL_SROA
43 #define GEN_PASS_DECL_STRIPDEBUGINFO
44 #define GEN_PASS_DECL_SCCP
45 #define GEN_PASS_DECL_SYMBOLDCE
46 #define GEN_PASS_DECL_SYMBOLPRIVATIZE
47 #define GEN_PASS_DECL_TOPOLOGICALSORT
48 #define GEN_PASS_DECL_COMPOSITEFIXEDPOINTPASS
49 #define GEN_PASS_DECL_BUBBLEDOWNMEMORYSPACECASTS
50 #define GEN_PASS_DECL_GENERATERUNTIMEVERIFICATION
51 #include "mlir/Transforms/Passes.h.inc"
52 
53 /// Creates an instance of the Canonicalizer pass, configured with default
54 /// settings (which can be overridden by pass options on the command line).
55 std::unique_ptr<Pass> createCanonicalizerPass();
56 
57 /// Creates an instance of the Canonicalizer pass with the specified config.
58 /// `disabledPatterns` is a set of labels used to filter out input patterns with
59 /// a debug label or debug name in this set. `enabledPatterns` is a set of
60 /// labels used to filter out input patterns that do not have one of the labels
61 /// in this set. Debug labels must be set explicitly on patterns or when adding
62 /// them with `RewritePatternSet::addWithLabel`. Debug names may be empty, but
63 /// patterns created with `RewritePattern::create` have their default debug name
64 /// set to their type name.
65 std::unique_ptr<Pass>
66 createCanonicalizerPass(const GreedyRewriteConfig &config,
67  ArrayRef<std::string> disabledPatterns = {},
68  ArrayRef<std::string> enabledPatterns = {});
69 
70 /// Creates a pass to perform control-flow sinking.
71 std::unique_ptr<Pass> createControlFlowSinkPass();
72 
73 /// Creates a pass to perform common sub expression elimination.
74 std::unique_ptr<Pass> createCSEPass();
75 
76 /// Creates a pass to print IR on the debug stream.
77 std::unique_ptr<Pass> createPrintIRPass(const PrintIRPassOptions & = {});
78 
79 /// Creates a pass that generates IR to verify ops at runtime.
80 std::unique_ptr<Pass> createGenerateRuntimeVerificationPass();
81 
82 /// Creates a loop invariant code motion pass that hoists loop invariant
83 /// instructions out of the loop.
84 std::unique_ptr<Pass> createLoopInvariantCodeMotionPass();
85 
86 /// Creates a pass that hoists loop-invariant subset ops.
87 std::unique_ptr<Pass> createLoopInvariantSubsetHoistingPass();
88 
89 /// Creates a pass to strip debug information from a function.
90 std::unique_ptr<Pass> createStripDebugInfoPass();
91 
92 /// Creates a pass which prints the list of ops and the number of occurrences in
93 /// the module.
94 std::unique_ptr<Pass> createPrintOpStatsPass(raw_ostream &os = llvm::errs());
95 
96 /// Creates a pass which prints the list of ops and the number of occurrences in
97 /// the module with the output format option.
98 std::unique_ptr<Pass> createPrintOpStatsPass(raw_ostream &os, bool printAsJSON);
99 
100 /// Creates a pass which inlines calls and callable operations as defined by
101 /// the CallGraph.
102 std::unique_ptr<Pass> createInlinerPass();
103 /// Creates an instance of the inliner pass, and use the provided pass managers
104 /// when optimizing callable operations with names matching the key type.
105 /// Callable operations with a name not within the provided map will use the
106 /// default inliner pipeline during optimization.
107 std::unique_ptr<Pass>
108 createInlinerPass(llvm::StringMap<OpPassManager> opPipelines);
109 /// Creates an instance of the inliner pass, and use the provided pass managers
110 /// when optimizing callable operations with names matching the key type.
111 /// Callable operations with a name not within the provided map will use the
112 /// provided default pipeline builder.
113 std::unique_ptr<Pass>
114 createInlinerPass(llvm::StringMap<OpPassManager> opPipelines,
115  std::function<void(OpPassManager &)> defaultPipelineBuilder);
116 
117 /// Creates an optimization pass to remove dead values.
118 std::unique_ptr<Pass> createRemoveDeadValuesPass();
119 
120 /// Creates a pass which performs sparse conditional constant propagation over
121 /// nested operations.
122 std::unique_ptr<Pass> createSCCPPass();
123 
124 /// Creates a pass which delete symbol operations that are unreachable. This
125 /// pass may *only* be scheduled on an operation that defines a SymbolTable.
126 std::unique_ptr<Pass> createSymbolDCEPass();
127 
128 /// Creates a pass which marks top-level symbol operations as `private` unless
129 /// listed in `excludeSymbols`.
130 std::unique_ptr<Pass>
131 createSymbolPrivatizePass(ArrayRef<std::string> excludeSymbols = {});
132 
133 /// Creates a pass that recursively sorts nested regions without SSA dominance
134 /// topologically such that, as much as possible, users of values appear after
135 /// their producers.
136 std::unique_ptr<Pass> createTopologicalSortPass();
137 
138 /// Create composite pass, which runs provided set of passes until fixed point
139 /// or maximum number of iterations reached.
140 std::unique_ptr<Pass> createCompositeFixedPointPass(
141  std::string name, llvm::function_ref<void(OpPassManager &)> populateFunc,
142  int maxIterations = 10);
143 
144 //===----------------------------------------------------------------------===//
145 // Registration
146 //===----------------------------------------------------------------------===//
147 
148 /// Generate the code for registering passes.
149 #define GEN_PASS_REGISTRATION
150 #include "mlir/Transforms/Passes.h.inc"
151 
152 } // namespace mlir
153 
154 #endif // MLIR_TRANSFORMS_PASSES_H
Include the generated interface declarations.
std::unique_ptr< Pass > createPrintIRPass(const PrintIRPassOptions &={})
Creates a pass to print IR on the debug stream.
Definition: PrintIR.cpp:34
std::unique_ptr< Pass > createCSEPass()
Creates a pass to perform common sub expression elimination.
Definition: CSE.cpp:412
std::unique_ptr< Pass > createLoopInvariantCodeMotionPass()
Creates a loop invariant code motion pass that hoists loop invariant instructions out of the loop.
std::unique_ptr< Pass > createStripDebugInfoPass()
Creates a pass to strip debug information from a function.
const FrozenRewritePatternSet GreedyRewriteConfig config
std::unique_ptr< Pass > createTopologicalSortPass()
Creates a pass that recursively sorts nested regions without SSA dominance topologically such that,...
std::unique_ptr< Pass > createCompositeFixedPointPass(std::string name, llvm::function_ref< void(OpPassManager &)> populateFunc, int maxIterations=10)
Create composite pass, which runs provided set of passes until fixed point or maximum number of itera...
std::unique_ptr< Pass > createSCCPPass()
Creates a pass which performs sparse conditional constant propagation over nested operations.
Definition: SCCP.cpp:133
std::unique_ptr< Pass > createSymbolDCEPass()
Creates a pass which delete symbol operations that are unreachable.
Definition: SymbolDCE.cpp:190
std::unique_ptr< Pass > createInlinerPass()
Creates a pass which inlines calls and callable operations as defined by the CallGraph.
std::unique_ptr< Pass > createGenerateRuntimeVerificationPass()
Creates a pass that generates IR to verify ops at runtime.
std::unique_ptr< Pass > createCanonicalizerPass()
Creates an instance of the Canonicalizer pass, configured with default settings (which can be overrid...
std::unique_ptr< Pass > createRemoveDeadValuesPass()
Creates an optimization pass to remove dead values.
std::unique_ptr< Pass > createPrintOpStatsPass(raw_ostream &os=llvm::errs())
Creates a pass which prints the list of ops and the number of occurrences in the module.
Definition: OpStats.cpp:114
std::unique_ptr< Pass > createControlFlowSinkPass()
Creates a pass to perform control-flow sinking.
std::unique_ptr< Pass > createLoopInvariantSubsetHoistingPass()
Creates a pass that hoists loop-invariant subset ops.
std::unique_ptr< Pass > createSymbolPrivatizePass(ArrayRef< std::string > excludeSymbols={})
Creates a pass which marks top-level symbol operations as private unless listed in excludeSymbols.