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