1 //===- llvm/PassManager.h - Container for Passes ----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
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.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_PASSMANAGER_H
18 #define LLVM_PASSMANAGER_H
20 #include "llvm/Pass.h"
28 class ModulePassManager;
29 class FunctionPassManagerT;
30 class BasicBlockPassManager;
33 ModulePassManager *PM; // This is a straightforward Pimpl class
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'.
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.
55 class FunctionPassManager {
56 FunctionPassManagerT *PM; // This is a straightforward Pimpl class
59 FunctionPassManager(ModuleProvider *P);
60 ~FunctionPassManager();
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'.
68 void add(FunctionPass *P);
70 /// add - ImmutablePasses are not FunctionPasses, so we have a
71 /// special hack to get them into a FunctionPassManager.
73 void add(ImmutablePass *IP);
75 /// doInitialization - Run all of the initializers for the function passes.
77 bool doInitialization();
79 /// run - Execute all of the passes scheduled for execution. Keep
80 /// track of whether any of the passes modifies the function, and if
83 bool run(Function &F);
85 /// doFinalization - Run all of the initializers for the function passes.
87 bool doFinalization();
90 class ModulePassManager_New;
91 class PassManagerImpl_New;
92 class FunctionPassManagerImpl_New;
94 /// PassManager_New manages ModulePassManagers
95 class PassManager_New {
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'.
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.
113 /// PassManagerImpl_New is the actual class. PassManager_New is just the
114 /// wraper to publish simple pass manager interface
115 PassManagerImpl_New *PM;
119 /// FunctionPassManager_New manages FunctionPasses and BasicBlockPassManagers.
120 class FunctionPassManager_New {
122 FunctionPassManager_New(ModuleProvider *P) { /* TODO */ }
123 FunctionPassManager_New();
124 ~FunctionPassManager_New() { /* TODO */ };
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'.
133 /// Execute all of the passes scheduled for execution. Keep
134 /// track of whether any of the passes modifies the function, and if
136 bool runOnModule(Module &M);
138 /// run - Execute all of the passes scheduled for execution. Keep
139 /// track of whether any of the passes modifies the function, and if
142 bool run(Function &F);
144 /// doInitialization - Run all of the initializers for the function passes.
146 bool doInitialization();
148 /// doFinalization - Run all of the initializers for the function passes.
150 bool doFinalization();
153 FunctionPassManagerImpl_New *FPM;
158 } // End llvm namespace