[PM] Move the analysis registry into the Passes.cpp file and provide
[oota-llvm.git] / tools / opt / Passes.h
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
21 namespace llvm {
22 class CGSCCAnalysisManager;
23 class FunctionAnalysisManager;
24 class ModuleAnalysisManager;
25 class ModulePassManager;
26
27 /// \brief Registers all available module analysis passes.
28 ///
29 /// This is an interface that can be used to populate a \c
30 /// ModuleAnalysisManager with all registered module analyses. Callers can
31 /// still manually register any additional analyses.
32 void registerModuleAnalyses(ModuleAnalysisManager &MAM);
33
34 /// \brief Registers all available CGSCC analysis passes.
35 ///
36 /// This is an interface that can be used to populate a \c CGSCCAnalysisManager
37 /// with all registered CGSCC analyses. Callers can still manually register any
38 /// additional analyses.
39 void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM);
40
41 /// \brief Registers all available function analysis passes.
42 ///
43 /// This is an interface that can be used to populate a \c
44 /// FunctionAnalysisManager with all registered function analyses. Callers can
45 /// still manually register any additional analyses.
46 void registerFunctionAnalyses(FunctionAnalysisManager &FAM);
47
48 /// \brief Parse a textual pass pipeline description into a \c ModulePassManager.
49 ///
50 /// The format of the textual pass pipeline description looks something like:
51 ///
52 ///   module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)
53 ///
54 /// Pass managers have ()s describing the nest structure of passes. All passes
55 /// are comma separated. As a special shortcut, if the very first pass is not
56 /// a module pass (as a module pass manager is), this will automatically form
57 /// the shortest stack of pass managers that allow inserting that first pass.
58 /// So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop passes
59 /// 'lpassN', all of these are valid:
60 ///
61 ///   fpass1,fpass2,fpass3
62 ///   cgpass1,cgpass2,cgpass3
63 ///   lpass1,lpass2,lpass3
64 ///
65 /// And they are equivalent to the following (resp.):
66 ///
67 ///   module(function(fpass1,fpass2,fpass3))
68 ///   module(cgscc(cgpass1,cgpass2,cgpass3))
69 ///   module(function(loop(lpass1,lpass2,lpass3)))
70 ///
71 /// This shortcut is especially useful for debugging and testing small pass
72 /// combinations. Note that these shortcuts don't introduce any other magic. If
73 /// the sequence of passes aren't all the exact same kind of pass, it will be
74 /// an error. You cannot mix different levels implicitly, you must explicitly
75 /// form a pass manager in which to nest passes.
76 bool parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
77                        bool VerifyEachPass = true);
78
79 }
80
81 #endif