1 //===- Passes.h - Utilities for manipulating all passes ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// Interfaces for registering passes, producing common pass manager
12 /// configurations, and parsing of pass pipelines.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TOOLS_OPT_PASSES_H
17 #define LLVM_TOOLS_OPT_PASSES_H
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Analysis/CGSCCPassManager.h"
21 #include "llvm/IR/PassManager.h"
25 /// \brief This class provides access to all of LLVM's passes.
27 /// It's members provide the baseline state available to passes during their
28 /// construction. The \c PassRegistry.def file specifies how to construct all
29 /// of the built-in passes, and those may reference these members during
33 /// \brief Registers all available module analysis passes.
35 /// This is an interface that can be used to populate a \c
36 /// ModuleAnalysisManager with all registered module analyses. Callers can
37 /// still manually register any additional analyses.
38 void registerModuleAnalyses(ModuleAnalysisManager &MAM);
40 /// \brief Registers all available CGSCC analysis passes.
42 /// This is an interface that can be used to populate a \c CGSCCAnalysisManager
43 /// with all registered CGSCC analyses. Callers can still manually register any
44 /// additional analyses.
45 void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM);
47 /// \brief Registers all available function analysis passes.
49 /// This is an interface that can be used to populate a \c
50 /// FunctionAnalysisManager with all registered function analyses. Callers can
51 /// still manually register any additional analyses.
52 void registerFunctionAnalyses(FunctionAnalysisManager &FAM);
54 /// \brief Parse a textual pass pipeline description into a \c ModulePassManager.
56 /// The format of the textual pass pipeline description looks something like:
58 /// module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)
60 /// Pass managers have ()s describing the nest structure of passes. All passes
61 /// are comma separated. As a special shortcut, if the very first pass is not
62 /// a module pass (as a module pass manager is), this will automatically form
63 /// the shortest stack of pass managers that allow inserting that first pass.
64 /// So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop passes
65 /// 'lpassN', all of these are valid:
67 /// fpass1,fpass2,fpass3
68 /// cgpass1,cgpass2,cgpass3
69 /// lpass1,lpass2,lpass3
71 /// And they are equivalent to the following (resp.):
73 /// module(function(fpass1,fpass2,fpass3))
74 /// module(cgscc(cgpass1,cgpass2,cgpass3))
75 /// module(function(loop(lpass1,lpass2,lpass3)))
77 /// This shortcut is especially useful for debugging and testing small pass
78 /// combinations. Note that these shortcuts don't introduce any other magic. If
79 /// the sequence of passes aren't all the exact same kind of pass, it will be
80 /// an error. You cannot mix different levels implicitly, you must explicitly
81 /// form a pass manager in which to nest passes.
82 bool parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
83 bool VerifyEachPass = true, bool DebugLogging = false);
86 bool parseModulePassName(ModulePassManager &MPM, StringRef Name);
87 bool parseCGSCCPassName(CGSCCPassManager &CGPM, StringRef Name);
88 bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name);
89 bool parseFunctionPassPipeline(FunctionPassManager &FPM,
90 StringRef &PipelineText, bool VerifyEachPass,
92 bool parseCGSCCPassPipeline(CGSCCPassManager &CGPM, StringRef &PipelineText,
93 bool VerifyEachPass, bool DebugLogging);
94 bool parseModulePassPipeline(ModulePassManager &MPM, StringRef &PipelineText,
95 bool VerifyEachPass, bool DebugLogging);