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