Split PassManager_New into PassManager_New and PassManagerImpl_New.
authorDevang Patel <dpatel@apple.com>
Wed, 8 Nov 2006 10:29:57 +0000 (10:29 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 8 Nov 2006 10:29:57 +0000 (10:29 +0000)
PassManagerImpl_New implements the pass manager.
PassManager_New is the public interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31546 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/PassManager.h
lib/VMCore/PassManager.cpp

index 31ce3daae4f0db5ae93619de74b897ae42eaa9a5..927ea9f785b8b2e5a6dc18d618df554e5b829a1c 100644 (file)
@@ -89,6 +89,7 @@ public:
 };
 
 class ModulePassManager_New;
+class PassManagerImpl_New;
 
 /// PassManagerAnalysisHelper helps pass manager analysis required by
 /// the managed passes. It provides methods to add/remove analysis
@@ -127,6 +128,8 @@ class PassManager_New : public Pass,
 
 public:
 
+  PassManager_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
@@ -138,22 +141,11 @@ public:
   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();
+  /// PassManagerImpl_New is the actual class. PassManager_New is just the 
+  /// wraper to publish simple pass manager interface
+  PassManagerImpl_New *PM;
 
-  // 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 llvm namespace
index 2592c4e907a24ecc98c842f1657643f1869ec27d..5d5b67baa53938f9a13a90a65423eb4547a6f84f 100644 (file)
@@ -100,6 +100,41 @@ private:
   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 @@ ModulePassManager_New::runOnModule(Module &M) {
 /// 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 @@ PassManager_New::add(Pass *P) {
 /// 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 @@ PassManager_New::addPass(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
-PassManager_New::run(Module &M) {
+PassManagerImpl_New::run(Module &M) {
 
   schedulePasses();
   bool Changed = false;
@@ -342,3 +377,25 @@ PassManager_New::run(Module &M) {
   }
   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);
+}
+