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