MLIR 23.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"
22#include "llvm/Support/Debug.h"
23#include <limits>
24#include <memory>
25
26namespace mlir {
27
29
30//===----------------------------------------------------------------------===//
31// Passes
32//===----------------------------------------------------------------------===//
33
34#define GEN_PASS_DECL_BUBBLEDOWNMEMORYSPACECASTS
35#define GEN_PASS_DECL_CSEPASS
36#define GEN_PASS_DECL_CANONICALIZERPASS
37#define GEN_PASS_DECL_COMPOSITEFIXEDPOINTPASS
38#define GEN_PASS_DECL_CONTROLFLOWSINKPASS
39#define GEN_PASS_DECL_GENERATERUNTIMEVERIFICATIONPASS
40#define GEN_PASS_DECL_LOOPINVARIANTCODEMOTIONPASS
41#define GEN_PASS_DECL_LOOPINVARIANTSUBSETHOISTINGPASS
42#define GEN_PASS_DECL_INLINERPASS
43#define GEN_PASS_DECL_MEM2REG
44#define GEN_PASS_DECL_PRINTIRPASS
45#define GEN_PASS_DECL_PRINTOPSTATSPASS
46#define GEN_PASS_DECL_REMOVEDEADVALUESPASS
47#define GEN_PASS_DECL_SCCPPASS
48#define GEN_PASS_DECL_SROA
49#define GEN_PASS_DECL_STRIPDEBUGINFOPASS
50#define GEN_PASS_DECL_SYMBOLDCEPASS
51#define GEN_PASS_DECL_SYMBOLPRIVATIZEPASS
52#define GEN_PASS_DECL_TOPOLOGICALSORTPASS
53#include "mlir/Transforms/Passes.h.inc"
54
55/// Creates an instance of the Canonicalizer pass with the specified config.
56/// `disabledPatterns` is a set of labels used to filter out input patterns with
57/// a debug label or debug name in this set. `enabledPatterns` is a set of
58/// labels used to filter out input patterns that do not have one of the labels
59/// in this set. Debug labels must be set explicitly on patterns or when adding
60/// them with `RewritePatternSet::addWithLabel`. Debug names may be empty, but
61/// patterns created with `RewritePattern::create` have their default debug name
62/// set to their type name.
63std::unique_ptr<Pass>
64createCanonicalizerPass(const GreedyRewriteConfig &config,
65 ArrayRef<std::string> disabledPatterns = {},
66 ArrayRef<std::string> enabledPatterns = {});
67
68/// Creates an instance of the inliner pass, and use the provided pass managers
69/// when optimizing callable operations with names matching the key type.
70/// Callable operations with a name not within the provided map will use the
71/// default inliner pipeline during optimization.
72std::unique_ptr<Pass>
73createInlinerPass(llvm::StringMap<OpPassManager> opPipelines);
74/// Creates an instance of the inliner pass, and use the provided pass managers
75/// when optimizing callable operations with names matching the key type.
76/// Callable operations with a name not within the provided map will use the
77/// provided default pipeline builder.
78std::unique_ptr<Pass>
79createInlinerPass(llvm::StringMap<OpPassManager> opPipelines,
80 std::function<void(OpPassManager &)> defaultPipelineBuilder);
81
82/// Creates a pass which prints the list of ops and the number of occurrences in
83/// the module.
84std::unique_ptr<Pass> createPrintOpStatsPass(raw_ostream &os);
85
86/// Creates a pass which prints the list of ops and the number of occurrences in
87/// the module with the output format option.
88std::unique_ptr<Pass> createPrintOpStatsPass(raw_ostream &os, bool printAsJSON);
89
90/// Create composite pass, which runs provided set of passes until fixed point
91/// or maximum number of iterations reached.
92std::unique_ptr<Pass> createCompositeFixedPointPass(
93 std::string name, llvm::function_ref<void(OpPassManager &)> populateFunc,
94 int maxIterations = 10);
95
96//===----------------------------------------------------------------------===//
97// Registration
98//===----------------------------------------------------------------------===//
99
100/// Generate the code for registering passes.
101#define GEN_PASS_REGISTRATION
102#include "mlir/Transforms/Passes.h.inc"
103
104} // namespace mlir
105
106#endif // MLIR_TRANSFORMS_PASSES_H
This class allows control over how the GreedyPatternRewriteDriver works.
This class represents a pass manager that runs passes on either a specific operation type,...
Definition PassManager.h:46
Include the generated interface declarations.
std::unique_ptr< Pass > createInlinerPass(llvm::StringMap< OpPassManager > opPipelines)
Creates an instance of the inliner pass, and use the provided pass managers when optimizing callable ...
std::unique_ptr< Pass > createCanonicalizerPass(const GreedyRewriteConfig &config, ArrayRef< std::string > disabledPatterns={}, ArrayRef< std::string > enabledPatterns={})
Creates an instance of the Canonicalizer pass with the specified config.
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 > createPrintOpStatsPass(raw_ostream &os)
Creates a pass which prints the list of ops and the number of occurrences in the module.
Definition OpStats.cpp:116