Add #ifdef switch toggle between old and new pass manager. However,
[oota-llvm.git] / include / llvm / PassManager.h
1 //===- llvm/PassManager.h - Container for Passes ----------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the PassManager class.  This class is used to hold,
11 // maintain, and optimize execution of Passes.  The PassManager class ensures
12 // that analysis results are available before a pass runs, and that Pass's are
13 // destroyed when the PassManager is destroyed.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_PASSMANAGER_H
18 #define LLVM_PASSMANAGER_H
19
20 #include "llvm/Pass.h"
21
22 namespace llvm {
23
24 class Pass;
25 class ModulePass;
26 class Module;
27 class ModuleProvider;
28
29 #ifdef USE_OLD_PASSMANAGER
30
31 class ModulePassManager;
32 class FunctionPassManagerT;
33 class BasicBlockPassManager;
34
35 class PassManager {
36   ModulePassManager *PM;    // This is a straightforward Pimpl class
37 public:
38   PassManager();
39   ~PassManager();
40
41   /// add - Add a pass to the queue of passes to run.  This passes ownership of
42   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
43   /// will be destroyed as well, so there is no need to delete the pass.  This
44   /// implies that all passes MUST be allocated with 'new'.
45   ///
46   void add(Pass *P);
47
48   /// run - Execute all of the passes scheduled for execution.  Keep track of
49   /// whether any of the passes modifies the module, and if so, return true.
50   ///
51   bool run(Module &M);
52 };
53
54 class FunctionPass;
55 class ImmutablePass;
56 class Function;
57
58 class FunctionPassManager {
59   FunctionPassManagerT *PM;    // This is a straightforward Pimpl class
60   ModuleProvider *MP;
61 public:
62   FunctionPassManager(ModuleProvider *P);
63   ~FunctionPassManager();
64
65   /// add - Add a pass to the queue of passes to run.  This passes
66   /// ownership of the FunctionPass to the PassManager.  When the
67   /// PassManager is destroyed, the pass will be destroyed as well, so
68   /// there is no need to delete the pass.  This implies that all
69   /// passes MUST be allocated with 'new'.
70   ///
71   void add(FunctionPass *P);
72
73   /// add - ImmutablePasses are not FunctionPasses, so we have a
74   /// special hack to get them into a FunctionPassManager.
75   ///
76   void add(ImmutablePass *IP);
77
78   /// doInitialization - Run all of the initializers for the function passes.
79   ///
80   bool doInitialization();
81   
82   /// run - Execute all of the passes scheduled for execution.  Keep
83   /// track of whether any of the passes modifies the function, and if
84   /// so, return true.
85   ///
86   bool run(Function &F);
87   
88   /// doFinalization - Run all of the initializers for the function passes.
89   ///
90   bool doFinalization();
91 };
92
93 #else
94
95 class ModulePassManager;
96 class PassManagerImpl_New;
97 class FunctionPassManagerImpl_New;
98
99 /// PassManager manages ModulePassManagers
100 class PassManager {
101
102 public:
103
104   PassManager();
105   ~PassManager();
106
107   /// add - Add a pass to the queue of passes to run.  This passes ownership of
108   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
109   /// will be destroyed as well, so there is no need to delete the pass.  This
110   /// implies that all passes MUST be allocated with 'new'.
111   void add(Pass *P);
112  
113   /// run - Execute all of the passes scheduled for execution.  Keep track of
114   /// whether any of the passes modifies the module, and if so, return true.
115   bool run(Module &M);
116
117 private:
118
119   /// PassManagerImpl_New is the actual class. PassManager is just the 
120   /// wraper to publish simple pass manager interface
121   PassManagerImpl_New *PM;
122
123 };
124
125 /// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
126 class FunctionPassManager {
127 public:
128   FunctionPassManager(ModuleProvider *P);
129   FunctionPassManager();
130   ~FunctionPassManager();
131  
132   /// add - Add a pass to the queue of passes to run.  This passes
133   /// ownership of the Pass to the PassManager.  When the
134   /// PassManager_X is destroyed, the pass will be destroyed as well, so
135   /// there is no need to delete the pass. (TODO delete passes.)
136   /// This implies that all passes MUST be allocated with 'new'.
137   void add(Pass *P);
138
139   /// run - Execute all of the passes scheduled for execution.  Keep
140   /// track of whether any of the passes modifies the function, and if
141   /// so, return true.
142   ///
143   bool run(Function &F);
144   
145   /// doInitialization - Run all of the initializers for the function passes.
146   ///
147   bool doInitialization();
148   
149   /// doFinalization - Run all of the initializers for the function passes.
150   ///
151   bool doFinalization();
152 private:
153   
154   FunctionPassManagerImpl_New *FPM;
155   ModuleProvider *MP;
156 };
157
158 #endif
159
160 } // End llvm namespace
161
162 #endif