Clarify the comments here, to make slightly more clear the
[oota-llvm.git] / include / llvm / PassManagers.h
index 76302db4e9ebda60097c1e5285021de9b819b3f3..bac962612f9ad59a4f3b645eea82ba8b135669a2 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Devang Patel and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -13,9 +13,8 @@
 
 #include "llvm/PassManager.h"
 #include "llvm/ADT/SmallVector.h"
-using namespace llvm;
-class llvm::PMDataManager;
-class llvm::PMStack;
+#include <deque>
+#include <map>
 
 //===----------------------------------------------------------------------===//
 // Overview:
@@ -29,8 +28,8 @@ class llvm::PMStack;
 //
 // Pass Manager Infrastructure uses multiple pass managers.  They are
 // PassManager, FunctionPassManager, MPPassManager, FPPassManager, BBPassManager.
-// This class hierarcy uses multiple inheritance but pass managers do not derive
-// from another pass manager.
+// This class hierarchy uses multiple inheritance but pass managers do not
+// derive from another pass manager.
 //
 // PassManager and FunctionPassManager are two top-level pass manager that
 // represents the external interface of this entire pass manager infrastucture.
@@ -84,6 +83,12 @@ class llvm::PMStack;
 // MPPassManagers.
 //===----------------------------------------------------------------------===//
 
+#ifndef PASSMANAGERS_H
+#define PASSMANAGERS_H
+
+#include "llvm/Pass.h"
+#include <deque>
+
 namespace llvm {
 
 /// FunctionPassManager and PassManager, two top level managers, serve 
@@ -105,6 +110,36 @@ enum PassDebuggingString {
   ON_CG_MSG // "' on Call Graph ...\n'"
 };  
 
+//===----------------------------------------------------------------------===//
+// PMStack
+//
+/// PMStack
+/// Top level pass managers (see PassManager.cpp) maintain active Pass Managers 
+/// using PMStack. Each Pass implements assignPassManager() to connect itself
+/// with appropriate manager. assignPassManager() walks PMStack to find
+/// suitable manager.
+///
+/// PMStack is just a wrapper around standard deque that overrides pop() and
+/// push() methods.
+class PMStack {
+public:
+  typedef std::deque<PMDataManager *>::reverse_iterator iterator;
+  iterator begin() { return S.rbegin(); }
+  iterator end() { return S.rend(); }
+
+  void handleLastUserOverflow();
+
+  void pop();
+  inline PMDataManager *top() { return S.back(); }
+  void push(PMDataManager *PM);
+  inline bool empty() { return S.empty(); }
+
+  void dump();
+private:
+  std::deque<PMDataManager *> S;
+};
+
+
 //===----------------------------------------------------------------------===//
 // PMTopLevelManager
 //
@@ -113,8 +148,8 @@ enum PassDebuggingString {
 class PMTopLevelManager {
 public:
 
-  virtual unsigned getNumContainedManagers() {
-    return PassManagers.size();
+  virtual unsigned getNumContainedManagers() const {
+    return (unsigned)PassManagers.size();
   }
 
   /// Schedule pass P for execution. Make sure that passes required by
@@ -150,7 +185,7 @@ public:
     return ImmutablePasses;
   }
 
-  void addPassManager(Pass *Manager) {
+  void addPassManager(PMDataManager *Manager) {
     PassManagers.push_back(Manager);
   }
 
@@ -172,7 +207,7 @@ public:
 protected:
   
   /// Collection of pass managers
-  std::vector<Pass *> PassManagers;
+  std::vector<PMDataManager *> PassManagers;
 
 private:
 
@@ -204,21 +239,20 @@ public:
 
   virtual ~PMDataManager();
 
-  /// Return true IFF pass P's required analysis set does not required new
-  /// manager.
-  bool manageablePass(Pass *P);
-
   /// Augment AvailableAnalysis by adding analysis made available by pass P.
   void recordAvailableAnalysis(Pass *P);
 
   /// verifyPreservedAnalysis -- Verify analysis presreved by pass P.
   void verifyPreservedAnalysis(Pass *P);
 
+  /// verifyDomInfo -- Verify dominator information if it is available.
+  void verifyDomInfo(Pass &P, Function &F);
+
   /// Remove Analysis that is not preserved by the pass
   void removeNotPreservedAnalysis(Pass *P);
   
   /// Remove dead passes
-  void removeDeadPasses(Pass *P, std::string Msg, enum PassDebuggingString);
+  void removeDeadPasses(Pass *P, const char *Msg, enum PassDebuggingString);
 
   /// Add pass P into the PassVector. Update 
   /// AvailableAnalysis appropriately if ProcessAnalysis is true.
@@ -273,12 +307,12 @@ public:
   void dumpLastUses(Pass *P, unsigned Offset) const;
   void dumpPassArguments() const;
   void dumpPassInfo(Pass *P, enum PassDebuggingString S1,
-                    enum PassDebuggingString S2, std::string Msg);
+                    enum PassDebuggingString S2, const char *Msg);
   void dumpAnalysisSetInfo(const char *Msg, Pass *P,
                            const std::vector<AnalysisID> &Set) const;
 
-  virtual unsigned getNumContainedPasses() 
-    return PassVector.size();
+  virtual unsigned getNumContainedPasses() const {
+    return (unsigned)PassVector.size();
   }
 
   virtual PassManagerType getPassManagerType() const { 
@@ -338,7 +372,7 @@ class FPPassManager : public ModulePass, public PMDataManager {
 public:
   static char ID;
   explicit FPPassManager(int Depth) 
-  : ModulePass((intptr_t)&ID), PMDataManager(Depth) { }
+  : ModulePass(intptr_t(&ID)), PMDataManager(Depth) { }
   
   /// 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.
@@ -378,5 +412,8 @@ public:
 
 }
 
-extern void StartPassTimer(Pass *);
-extern void StopPassTimer(Pass *);
+extern void StartPassTimer(llvm::Pass *);
+extern void StopPassTimer(llvm::Pass *);
+
+#endif
+