1f0fa1acd1d7d18f3f72c394a528dd8c7310d324
[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 class ModulePassManager;
29 class FunctionPassManagerT;
30 class BasicBlockPassManager;
31
32 class PassManager {
33   ModulePassManager *PM;    // This is a straightforward Pimpl class
34 public:
35   PassManager();
36   ~PassManager();
37
38   /// add - Add a pass to the queue of passes to run.  This passes ownership of
39   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
40   /// will be destroyed as well, so there is no need to delete the pass.  This
41   /// implies that all passes MUST be allocated with 'new'.
42   ///
43   void add(Pass *P);
44
45   /// run - Execute all of the passes scheduled for execution.  Keep track of
46   /// whether any of the passes modifies the module, and if so, return true.
47   ///
48   bool run(Module &M);
49 };
50
51 class FunctionPass;
52 class ImmutablePass;
53 class Function;
54
55 class FunctionPassManager {
56   FunctionPassManagerT *PM;    // This is a straightforward Pimpl class
57   ModuleProvider *MP;
58 public:
59   FunctionPassManager(ModuleProvider *P);
60   ~FunctionPassManager();
61
62   /// add - Add a pass to the queue of passes to run.  This passes
63   /// ownership of the FunctionPass to the PassManager.  When the
64   /// PassManager is destroyed, the pass will be destroyed as well, so
65   /// there is no need to delete the pass.  This implies that all
66   /// passes MUST be allocated with 'new'.
67   ///
68   void add(FunctionPass *P);
69
70   /// add - ImmutablePasses are not FunctionPasses, so we have a
71   /// special hack to get them into a FunctionPassManager.
72   ///
73   void add(ImmutablePass *IP);
74
75   /// doInitialization - Run all of the initializers for the function passes.
76   ///
77   bool doInitialization();
78   
79   /// run - Execute all of the passes scheduled for execution.  Keep
80   /// track of whether any of the passes modifies the function, and if
81   /// so, return true.
82   ///
83   bool run(Function &F);
84   
85   /// doFinalization - Run all of the initializers for the function passes.
86   ///
87   bool doFinalization();
88 };
89
90 class ModulePassManager_New;
91 class PassManagerImpl_New;
92 class FunctionPassManagerImpl_New;
93
94 /// PassManager_New manages ModulePassManagers
95 class PassManager_New {
96
97 public:
98
99   PassManager_New();
100   ~PassManager_New();
101
102   /// add - Add a pass to the queue of passes to run.  This passes ownership of
103   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
104   /// will be destroyed as well, so there is no need to delete the pass.  This
105   /// implies that all passes MUST be allocated with 'new'.
106   void add(Pass *P);
107  
108   /// run - Execute all of the passes scheduled for execution.  Keep track of
109   /// whether any of the passes modifies the module, and if so, return true.
110   bool run(Module &M);
111
112 private:
113
114   /// PassManagerImpl_New is the actual class. PassManager_New is just the 
115   /// wraper to publish simple pass manager interface
116   PassManagerImpl_New *PM;
117
118 };
119
120 /// FunctionPassManager_New manages FunctionPasses and BasicBlockPassManagers.
121 class FunctionPassManager_New {
122 public:
123   FunctionPassManager_New(ModuleProvider *P);
124   FunctionPassManager_New();
125   ~FunctionPassManager_New();
126  
127   /// add - Add a pass to the queue of passes to run.  This passes
128   /// ownership of the Pass to the PassManager.  When the
129   /// PassManager_X is destroyed, the pass will be destroyed as well, so
130   /// there is no need to delete the pass. (TODO delete passes.)
131   /// This implies that all passes MUST be allocated with 'new'.
132   void add(Pass *P);
133
134   /// run - Execute all of the passes scheduled for execution.  Keep
135   /// track of whether any of the passes modifies the function, and if
136   /// so, return true.
137   ///
138   bool run(Function &F);
139   
140   /// doInitialization - Run all of the initializers for the function passes.
141   ///
142   bool doInitialization();
143   
144   /// doFinalization - Run all of the initializers for the function passes.
145   ///
146   bool doFinalization();
147 private:
148   
149   FunctionPassManagerImpl_New *FPM;
150   ModuleProvider *MP;
151 };
152
153
154 } // End llvm namespace
155
156 #endif