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