xref: /minix/external/bsd/llvm/dist/llvm/tools/opt/Passes.h (revision 0a6a1f1d)
1 //===- Passes.h - Parsing, selection, and running of passes -----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
11 /// Interfaces for producing common pass manager configurations and parsing
12 /// textual pass specifications.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_TOOLS_OPT_PASSES_H
17 #define LLVM_TOOLS_OPT_PASSES_H
18 
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Analysis/CGSCCPassManager.h"
21 #include "llvm/IR/PassManager.h"
22 
23 namespace llvm {
24 
25 /// \brief Registers all available module analysis passes.
26 ///
27 /// This is an interface that can be used to populate a \c
28 /// ModuleAnalysisManager with all registered module analyses. Callers can
29 /// still manually register any additional analyses.
30 void registerModuleAnalyses(ModuleAnalysisManager &MAM);
31 
32 /// \brief Registers all available CGSCC analysis passes.
33 ///
34 /// This is an interface that can be used to populate a \c CGSCCAnalysisManager
35 /// with all registered CGSCC analyses. Callers can still manually register any
36 /// additional analyses.
37 void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM);
38 
39 /// \brief Registers all available function analysis passes.
40 ///
41 /// This is an interface that can be used to populate a \c
42 /// FunctionAnalysisManager with all registered function analyses. Callers can
43 /// still manually register any additional analyses.
44 void registerFunctionAnalyses(FunctionAnalysisManager &FAM);
45 
46 /// \brief Parse a textual pass pipeline description into a \c ModulePassManager.
47 ///
48 /// The format of the textual pass pipeline description looks something like:
49 ///
50 ///   module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)
51 ///
52 /// Pass managers have ()s describing the nest structure of passes. All passes
53 /// are comma separated. As a special shortcut, if the very first pass is not
54 /// a module pass (as a module pass manager is), this will automatically form
55 /// the shortest stack of pass managers that allow inserting that first pass.
56 /// So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop passes
57 /// 'lpassN', all of these are valid:
58 ///
59 ///   fpass1,fpass2,fpass3
60 ///   cgpass1,cgpass2,cgpass3
61 ///   lpass1,lpass2,lpass3
62 ///
63 /// And they are equivalent to the following (resp.):
64 ///
65 ///   module(function(fpass1,fpass2,fpass3))
66 ///   module(cgscc(cgpass1,cgpass2,cgpass3))
67 ///   module(function(loop(lpass1,lpass2,lpass3)))
68 ///
69 /// This shortcut is especially useful for debugging and testing small pass
70 /// combinations. Note that these shortcuts don't introduce any other magic. If
71 /// the sequence of passes aren't all the exact same kind of pass, it will be
72 /// an error. You cannot mix different levels implicitly, you must explicitly
73 /// form a pass manager in which to nest passes.
74 bool parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
75                        bool VerifyEachPass = true, bool DebugLogging = false);
76 }
77 
78 #endif
79