Fix old-style type names in comments.
[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 is distributed under the University of Illinois Open Source
6 // 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 class PassManagerImpl;
30 class FunctionPassManagerImpl;
31
32 /// PassManagerBase - An abstract interface to allow code to add passes to
33 /// a pass manager without having to hard-code what kind of pass manager
34 /// it is.
35 class PassManagerBase {
36 public:
37   virtual ~PassManagerBase();
38
39   /// add - Add a pass to the queue of passes to run.  This passes ownership of
40   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
41   /// will be destroyed as well, so there is no need to delete the pass.  This
42   /// implies that all passes MUST be allocated with 'new'.
43   virtual void add(Pass *P) = 0;
44 };
45
46 /// PassManager manages ModulePassManagers
47 class PassManager : public PassManagerBase {
48 public:
49
50   PassManager();
51   ~PassManager();
52
53   /// add - Add a pass to the queue of passes to run.  This passes ownership of
54   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
55   /// will be destroyed as well, so there is no need to delete the pass.  This
56   /// implies that all passes MUST be allocated with 'new'.
57   void add(Pass *P);
58  
59   /// run - Execute all of the passes scheduled for execution.  Keep track of
60   /// whether any of the passes modifies the module, and if so, return true.
61   bool run(Module &M);
62
63 private:
64
65   /// PassManagerImpl_New is the actual class. PassManager is just the 
66   /// wraper to publish simple pass manager interface
67   PassManagerImpl *PM;
68 };
69
70 /// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
71 class FunctionPassManager : public PassManagerBase {
72 public:
73   /// FunctionPassManager ctor - This initializes the pass manager.  It needs,
74   /// but does not take ownership of, the specified module provider.
75   explicit FunctionPassManager(ModuleProvider *P);
76   ~FunctionPassManager();
77  
78   /// add - Add a pass to the queue of passes to run.  This passes
79   /// ownership of the Pass to the PassManager.  When the
80   /// PassManager_X is destroyed, the pass will be destroyed as well, so
81   /// there is no need to delete the pass. (TODO delete passes.)
82   /// This implies that all passes MUST be allocated with 'new'.
83   void add(Pass *P);
84
85   /// run - Execute all of the passes scheduled for execution.  Keep
86   /// track of whether any of the passes modifies the function, and if
87   /// so, return true.
88   ///
89   bool run(Function &F);
90   
91   /// doInitialization - Run all of the initializers for the function passes.
92   ///
93   bool doInitialization();
94   
95   /// doFinalization - Run all of the finalizers for the function passes.
96   ///
97   bool doFinalization();
98   
99   /// getModuleProvider - Return the module provider that this passmanager is
100   /// currently using.  This is the module provider that it uses when a function
101   /// is optimized that is non-resident in the module.
102   ModuleProvider *getModuleProvider() const { return MP; }
103   void setModuleProvider(ModuleProvider *NewMP) { MP = NewMP; }
104
105 private:
106   FunctionPassManagerImpl *FPM;
107   ModuleProvider *MP;
108 };
109
110 } // End llvm namespace
111
112 #endif