[llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Devang Patel
dpatel at apple.com
Wed Nov 8 02:30:15 PST 2006
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.8 -> 1.9
---
Log message:
Split PassManager_New into PassManager_New and PassManagerImpl_New.
PassManagerImpl_New implements the pass manager.
PassManager_New is the public interface.
---
Diffs of the changes: (+61 -4)
PassManager.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 61 insertions(+), 4 deletions(-)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.8 llvm/lib/VMCore/PassManager.cpp:1.9
--- llvm/lib/VMCore/PassManager.cpp:1.8 Wed Nov 8 04:05:38 2006
+++ llvm/lib/VMCore/PassManager.cpp Wed Nov 8 04:29:57 2006
@@ -100,6 +100,41 @@
FunctionPassManager_New *activeFunctionPassManager;
};
+/// PassManager_New manages ModulePassManagers
+class PassManagerImpl_New : public Pass,
+ public PassManagerAnalysisHelper {
+
+public:
+
+ /// add - Add a pass to the queue of passes to run. This passes ownership of
+ /// the Pass to the PassManager. When the PassManager is destroyed, the pass
+ /// will be destroyed as well, so there is no need to delete the pass. This
+ /// implies that all passes MUST be allocated with 'new'.
+ void add(Pass *P);
+
+ /// run - Execute all of the passes scheduled for execution. Keep track of
+ /// whether any of the passes modifies the module, and if so, return true.
+ bool run(Module &M);
+
+private:
+
+ /// Add a pass into a passmanager queue. This is used by schedulePasses
+ bool addPass(Pass *p);
+
+ /// Schedule all passes collected in pass queue using add(). Add all the
+ /// schedule passes into various manager's queue using addPass().
+ void schedulePasses();
+
+ // Collection of pass managers
+ std::vector<ModulePassManager_New *> PassManagers;
+
+ // Collection of pass that are not yet scheduled
+ std::vector<Pass *> PassVector;
+
+ // Active Pass Manager
+ ModulePassManager_New *activeManager;
+};
+
} // End of llvm namespace
// PassManagerAnalysisHelper implementation
@@ -304,13 +339,13 @@
/// Schedule all passes from the queue by adding them in their
/// respective manager's queue.
void
-PassManager_New::schedulePasses() {
+PassManagerImpl_New::schedulePasses() {
/* TODO */
}
/// Add pass P to the queue of passes to run.
void
-PassManager_New::add(Pass *P) {
+PassManagerImpl_New::add(Pass *P) {
/* TODO */
}
@@ -318,7 +353,7 @@
/// Add P into active pass manager or use new module pass manager to
/// manage it.
bool
-PassManager_New::addPass(Pass *P) {
+PassManagerImpl_New::addPass(Pass *P) {
if (!activeManager) {
activeManager = new ModulePassManager_New();
@@ -331,7 +366,7 @@
/// run - Execute all of the passes scheduled for execution. Keep track of
/// whether any of the passes modifies the module, and if so, return true.
bool
-PassManager_New::run(Module &M) {
+PassManagerImpl_New::run(Module &M) {
schedulePasses();
bool Changed = false;
@@ -342,3 +377,25 @@
}
return Changed;
}
+
+/// Create new pass manager
+PassManager_New::PassManager_New() {
+ PM = new PassManagerImpl_New();
+}
+
+/// add - Add a pass to the queue of passes to run. This passes ownership of
+/// the Pass to the PassManager. When the PassManager is destroyed, the pass
+/// will be destroyed as well, so there is no need to delete the pass. This
+/// implies that all passes MUST be allocated with 'new'.
+void
+PassManager_New::add(Pass *P) {
+ PM->add(P);
+}
+
+/// run - Execute all of the passes scheduled for execution. Keep track of
+/// whether any of the passes modifies the module, and if so, return true.
+bool
+PassManager_New::run(Module &M) {
+ return PM->run(M);
+}
+
More information about the llvm-commits
mailing list