MC: Make setVariableValue check the redefinition condition a bit more strongly.
[oota-llvm.git] / include / llvm / Pass.h
index 7bc6295432a750230c04c8226a98709ead89d451..8d0c47d7bbe3a2b8a0c52e2c729cfd93cbea7edb 100644 (file)
@@ -30,7 +30,9 @@
 #define LLVM_PASS_H
 
 #include "llvm/System/DataTypes.h"
+
 #include <cassert>
+#include <string>
 #include <utility>
 #include <vector>
 
@@ -56,14 +58,24 @@ typedef const PassInfo* AnalysisID;
 /// Ordering of pass manager types is important here.
 enum PassManagerType {
   PMT_Unknown = 0,
-  PMT_ModulePassManager = 1, /// MPPassManager 
-  PMT_CallGraphPassManager,  /// CGPassManager
-  PMT_FunctionPassManager,   /// FPPassManager
-  PMT_LoopPassManager,       /// LPPassManager
-  PMT_BasicBlockPassManager, /// BBPassManager
+  PMT_ModulePassManager = 1, ///< MPPassManager 
+  PMT_CallGraphPassManager,  ///< CGPassManager
+  PMT_FunctionPassManager,   ///< FPPassManager
+  PMT_LoopPassManager,       ///< LPPassManager
+  PMT_BasicBlockPassManager, ///< BBPassManager
   PMT_Last
 };
 
+// Different types of passes.
+enum PassKind {
+  PT_BasicBlock,
+  PT_Loop,
+  PT_Function,
+  PT_CallGraphSCC,
+  PT_Module,
+  PT_PassManager
+};
+  
 //===----------------------------------------------------------------------===//
 /// Pass interface - Implemented by all 'passes'.  Subclass this if you are an
 /// interprocedural optimization or you do not fit into any of the more
@@ -72,19 +84,23 @@ enum PassManagerType {
 class Pass {
   AnalysisResolver *Resolver;  // Used to resolve analysis
   intptr_t PassID;
-
+  PassKind Kind;
   void operator=(const Pass&);  // DO NOT IMPLEMENT
   Pass(const Pass &);           // DO NOT IMPLEMENT
   
 public:
-  explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) {
+  explicit Pass(PassKind K, intptr_t pid) : Resolver(0), PassID(pid), Kind(K) {
     assert(pid && "pid cannot be 0");
   }
-  explicit Pass(const void *pid) : Resolver(0), PassID((intptr_t)pid) {
+  explicit Pass(PassKind K, const void *pid)
+    : Resolver(0), PassID((intptr_t)pid), Kind(K) {
     assert(pid && "pid cannot be 0"); 
   }
   virtual ~Pass();
 
+  
+  PassKind getPassKind() const { return Kind; }
+  
   /// getPassName - Return a nice clean name for a pass.  This usually
   /// implemented in terms of the name that is registered by one of the
   /// Registration templates, but can be overloaded directly.
@@ -106,6 +122,11 @@ public:
   virtual void print(raw_ostream &O, const Module *M) const;
   void dump() const; // dump - Print to stderr.
 
+  /// createPrinterPass - Get a Pass appropriate to print the IR this
+  /// pass operates one (Module, Function or MachineFunction).
+  virtual Pass *createPrinterPass(raw_ostream &O,
+                                  const std::string &Banner) const = 0;
+
   /// Each pass is responsible for assigning a pass manager to itself.
   /// PMS is the stack of available pass manager. 
   virtual void assignPassManager(PMStack &, 
@@ -118,7 +139,7 @@ public:
 
   // Access AnalysisResolver
   inline void setResolver(AnalysisResolver *AR) { 
-    assert (!Resolver && "Resolver is already set");
+    assert(!Resolver && "Resolver is already set");
     Resolver = AR; 
   }
   inline AnalysisResolver *getResolver() { 
@@ -149,7 +170,7 @@ public:
   /// an analysis interface through multiple inheritance.  If needed, it should
   /// override this to adjust the this pointer as needed for the specified pass
   /// info.
-  virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
+  virtual void *getAdjustedAnalysisPointer(const PassInfo *) {
     return this;
   }
   virtual ImmutablePass *getAsImmutablePass() { return 0; }
@@ -219,6 +240,9 @@ public:
 ///
 class ModulePass : public Pass {
 public:
+  /// createPrinterPass - Get a module printer pass.
+  Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;
+
   /// runOnModule - Virtual method overriden by subclasses to process the module
   /// being operated on.
   virtual bool runOnModule(Module &M) = 0;
@@ -229,8 +253,8 @@ public:
   ///  Return what kind of Pass Manager can manage this pass.
   virtual PassManagerType getPotentialPassManagerType() const;
 
-  explicit ModulePass(intptr_t pid) : Pass(pid) {}
-  explicit ModulePass(const void *pid) : Pass(pid) {}
+  explicit ModulePass(intptr_t pid) : Pass(PT_Module, pid) {}
+  explicit ModulePass(const void *pid) : Pass(PT_Module, pid) {}
   // Force out-of-line virtual method.
   virtual ~ModulePass();
 };
@@ -276,8 +300,11 @@ public:
 ///
 class FunctionPass : public Pass {
 public:
-  explicit FunctionPass(intptr_t pid) : Pass(pid) {}
-  explicit FunctionPass(const void *pid) : Pass(pid) {}
+  explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {}
+  explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {}
+
+  /// createPrinterPass - Get a function printer pass.
+  Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;
 
   /// doInitialization - Virtual method overridden by subclasses to do
   /// any necessary per-module initialization.
@@ -326,8 +353,11 @@ public:
 ///
 class BasicBlockPass : public Pass {
 public:
-  explicit BasicBlockPass(intptr_t pid) : Pass(pid) {}
-  explicit BasicBlockPass(const void *pid) : Pass(pid) {}
+  explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {}
+  explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {}
+
+  /// createPrinterPass - Get a function printer pass.
+  Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;
 
   /// doInitialization - Virtual method overridden by subclasses to do
   /// any necessary per-module initialization.