14463ffed1a2d8bdbabed87a7b506803848b41a1
[oota-llvm.git] / include / llvm / PassManager.h
1 //===- llvm/PassManager.h - Container for Passes ----------------*- C++ -*-===//
2 //
3 // This file defines the PassManager class.  This class is used to hold,
4 // maintain, and optimize execution of Passes.  The PassManager class ensures
5 // that analysis results are available before a pass runs, and that Pass's are
6 // destroyed when the PassManager is destroyed.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_PASSMANAGER_H
11 #define LLVM_PASSMANAGER_H
12
13 class Pass;
14 class Module;
15 class ModuleProvider;
16 template<class UnitType> class PassManagerT;
17
18 class PassManager {
19   PassManagerT<Module> *PM;    // This is a straightforward Pimpl class
20 public:
21   PassManager();
22   ~PassManager();
23
24   /// add - Add a pass to the queue of passes to run.  This passes ownership of
25   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
26   /// will be destroyed as well, so there is no need to delete the pass.  This
27   /// implies that all passes MUST be allocated with 'new'.
28   ///
29   void add(Pass *P);
30
31   /// run - Execute all of the passes scheduled for execution.  Keep track of
32   /// whether any of the passes modifies the module, and if so, return true.
33   ///
34   bool run(Module &M);
35 };
36
37 class FunctionPass;
38 class ImmutablePass;
39 class Function;
40
41 class FunctionPassManager {
42   PassManagerT<Function> *PM;    // This is a straightforward Pimpl class
43   ModuleProvider *MP;
44 public:
45   FunctionPassManager(ModuleProvider *P);
46   ~FunctionPassManager();
47
48   /// add - Add a pass to the queue of passes to run.  This passes
49   /// ownership of the FunctionPass to the PassManager.  When the
50   /// PassManager is destroyed, the pass will be destroyed as well, so
51   /// there is no need to delete the pass.  This implies that all
52   /// passes MUST be allocated with 'new'.
53   ///
54   void add(FunctionPass *P);
55
56   /// add - ImmutablePasses are not FunctionPasses, so we have a 
57   /// special hack to get them into a FunctionPassManager.
58   ///
59   void add(ImmutablePass *IP);
60
61   /// run - Execute all of the passes scheduled for execution.  Keep
62   /// track of whether any of the passes modifies the function, and if
63   /// so, return true.
64   ///
65   bool run(Function &F);
66 };
67
68 #endif