0e18a86b042afa559e910e6cb6a62f94d2e7cb86
[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 class PassManagerImpl;
30 class FunctionPassManagerImpl;
31
32 /// PassManager manages ModulePassManagers
33 class PassManager {
34 public:
35
36   PassManager();
37   ~PassManager();
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   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   bool run(Module &M);
48
49 private:
50
51   /// PassManagerImpl_New is the actual class. PassManager is just the 
52   /// wraper to publish simple pass manager interface
53   PassManagerImpl *PM;
54 };
55
56 /// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
57 class FunctionPassManager {
58 public:
59   /// FunctionPassManager ctor - This initializes the pass manager.  It needs,
60   /// but does not take ownership of, the specified module provider.
61   explicit FunctionPassManager(ModuleProvider *P);
62   ~FunctionPassManager();
63  
64   /// add - Add a pass to the queue of passes to run.  This passes
65   /// ownership of the Pass to the PassManager.  When the
66   /// PassManager_X is destroyed, the pass will be destroyed as well, so
67   /// there is no need to delete the pass. (TODO delete passes.)
68   /// This implies that all passes MUST be allocated with 'new'.
69   void add(Pass *P);
70
71   /// run - Execute all of the passes scheduled for execution.  Keep
72   /// track of whether any of the passes modifies the function, and if
73   /// so, return true.
74   ///
75   bool run(Function &F);
76   
77   /// doInitialization - Run all of the initializers for the function passes.
78   ///
79   bool doInitialization();
80   
81   /// doFinalization - Run all of the finalizers for the function passes.
82   ///
83   bool doFinalization();
84
85 private:
86   FunctionPassManagerImpl *FPM;
87   ModuleProvider *MP;
88 };
89
90 } // End llvm namespace
91
92 #endif