Add FunctionPassManager - it's like a PassManager, but it only deals in
authorBrian Gaeke <gaeke@uiuc.edu>
Tue, 12 Aug 2003 17:22:39 +0000 (17:22 +0000)
committerBrian Gaeke <gaeke@uiuc.edu>
Tue, 12 Aug 2003 17:22:39 +0000 (17:22 +0000)
FunctionPasses.

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

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

index f67d9da1a32a94d73266bcf700d8d247fdb6edaf..5a313d5a6f1cba3c50829a9e44d7e95fd1765949 100644 (file)
@@ -28,9 +28,33 @@ public:
   void add(Pass *P);
 
   /// run - Execute all of the passes scheduled for execution.  Keep track of
-  /// whether any of the functions modifies the program, and if so, return true.
+  /// whether any of the passes modifies the module, and if so, return true.
   ///
   bool run(Module &M);
 };
 
+class FunctionPass;
+class Function;
+
+class FunctionPassManager {
+  PassManagerT<Function> *PM;    // This is a straightforward Pimpl class
+public:
+  FunctionPassManager();
+  ~FunctionPassManager();
+
+  /// add - Add a pass to the queue of passes to run.  This passes
+  /// ownership of the FunctionPass 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(FunctionPass *P);
+
+  /// run - Execute all of the passes scheduled for execution.  Keep
+  /// track of whether any of the passes modifies the function, and if
+  /// so, return true.
+  ///
+  bool run(Function &M);
+};
+
 #endif
index ec193debfa4210fb2e072baaacd4df1fd1e94f4f..6535d104677b060fd37b7209971698014fb19f96 100644 (file)
@@ -70,6 +70,16 @@ PassManager::~PassManager() { delete PM; }
 void PassManager::add(Pass *P) { PM->add(P); }
 bool PassManager::run(Module &M) { return PM->run(M); }
 
+//===----------------------------------------------------------------------===//
+// FunctionPassManager implementation - The FunctionPassManager class
+// is a simple Pimpl class that wraps the PassManagerT template. It
+// is like PassManager, but only deals in FunctionPasses.
+//
+FunctionPassManager::FunctionPassManager() : PM(new PassManagerT<Function>()) {}
+FunctionPassManager::~FunctionPassManager() { delete PM; }
+void FunctionPassManager::add(FunctionPass *P) { PM->add(P); }
+bool FunctionPassManager::run(Function &F) { return PM->run(F); }
+
 
 //===----------------------------------------------------------------------===//
 // TimingInfo Class - This class is used to calculate information about the