5b8c7f6220e6c5c226bf7ed90481d9964e407604
[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
101   /// add - Add a pass to the queue of passes to run.  This passes ownership of
102   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
103   /// will be destroyed as well, so there is no need to delete the pass.  This
104   /// implies that all passes MUST be allocated with 'new'.
105   void add(Pass *P);
106  
107   /// run - Execute all of the passes scheduled for execution.  Keep track of
108   /// whether any of the passes modifies the module, and if so, return true.
109   bool run(Module &M);
110
111 private:
112
113   /// PassManagerImpl_New is the actual class. PassManager_New is just the 
114   /// wraper to publish simple pass manager interface
115   PassManagerImpl_New *PM;
116
117 };
118
119 /// FunctionPassManager_New manages FunctionPasses and BasicBlockPassManagers.
120 class FunctionPassManager_New {
121 public:
122   FunctionPassManager_New(ModuleProvider *P) { /* TODO */ }
123   FunctionPassManager_New();
124   ~FunctionPassManager_New() { /* TODO */ };
125  
126   /// add - Add a pass to the queue of passes to run.  This passes
127   /// ownership of the Pass to the PassManager.  When the
128   /// PassManager_X is destroyed, the pass will be destroyed as well, so
129   /// there is no need to delete the pass. (TODO delete passes.)
130   /// This implies that all passes MUST be allocated with 'new'.
131   void add(Pass *P);
132
133   /// Execute all of the passes scheduled for execution.  Keep
134   /// track of whether any of the passes modifies the function, and if
135   /// so, return true.
136   bool runOnModule(Module &M);
137
138 private:
139   
140   FunctionPassManagerImpl_New *FPM;
141
142 };
143
144
145 } // End llvm namespace
146
147 #endif