Remove uses of llvm/System/IncludeFile.h that are no longer needed.
[oota-llvm.git] / include / llvm / PassSupport.h
index 16419d7b7a71227f972e3e91f6f9e05da4bac2c7..29e7374815373d0af8ae405d500c8699262982d4 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group 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.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -21,7 +21,6 @@
 #ifndef LLVM_PASS_SUPPORT_H
 #define LLVM_PASS_SUPPORT_H
 
-#include "llvm/System/IncludeFile.h"
 // No need to include Pass.h, we are being included by it!
 
 namespace llvm {
@@ -37,20 +36,22 @@ class TargetMachine;
 class PassInfo {
   const char           *PassName;      // Nice name for Pass
   const char           *PassArgument;  // Command Line argument to run this pass
-  const std::type_info &TypeInfo;      // type_info object for this Pass class
+  intptr_t             PassID;      
   bool IsCFGOnlyPass;                  // Pass only looks at the CFG.
+  bool IsAnalysis;                     // True if an analysis pass.
   bool IsAnalysisGroup;                // True if an analysis group.
   std::vector<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
 
-  Pass *(*NormalCtor)();               // No argument ctor
+  Pass *(*NormalCtor)();
 
 public:
   /// PassInfo ctor - Do not call this directly, this should only be invoked
   /// through RegisterPass.
-  PassInfo(const char *name, const char *arg, const std::type_info &ti,
-           Pass *(*normal)() = 0, bool isCFGOnly = false)
-    : PassName(name), PassArgument(arg), TypeInfo(ti), 
-      IsCFGOnlyPass(isCFGOnly), IsAnalysisGroup(false), NormalCtor(normal) {
+  PassInfo(const char *name, const char *arg, intptr_t pi,
+           Pass *(*normal)() = 0, bool isCFGOnly = false, bool isAnalysis = false)
+    : PassName(name), PassArgument(arg), PassID(pi), 
+      IsCFGOnlyPass(isCFGOnly), 
+      IsAnalysis(isAnalysis), IsAnalysisGroup(false), NormalCtor(normal) {
   }
 
   /// getPassName - Return the friendly name for the pass, never returns null
@@ -64,14 +65,15 @@ public:
   ///
   const char *getPassArgument() const { return PassArgument; }
 
-  /// getTypeInfo - Return the type_info object for the pass...
-  ///
-  const std::type_info &getTypeInfo() const { return TypeInfo; }
+  /// getTypeInfo - Return the id object for the pass...
+  /// TODO : Rename
+  intptr_t getTypeInfo() const { return PassID; }
 
   /// isAnalysisGroup - Return true if this is an analysis group, not a normal
   /// pass.
   ///
   bool isAnalysisGroup() const { return IsAnalysisGroup; }
+  bool isAnalysis() const { return IsAnalysis; }
   void SetIsAnalysisGroup() { IsAnalysisGroup = true; }
 
   /// isCFGOnlyPass - return true if this pass only looks at the CFG for the
@@ -137,12 +139,15 @@ struct RegisterPassBase {
   ///
   const PassInfo *getPassInfo() const { return &PIObj; }
 
-  RegisterPassBase(const char *Name, const char *Arg, const std::type_info &TI,
-                   Pass *(*NormalCtor)() = 0, bool CFGOnly = false)
-    : PIObj(Name, Arg, TI, NormalCtor, CFGOnly) {
+  typedef Pass* (*NormalCtor_t)();
+  
+  RegisterPassBase(const char *Name, const char *Arg, intptr_t TI,
+                   NormalCtor_t NormalCtor = 0, bool CFGOnly = false, 
+                   bool IsAnalysis = false)
+    : PIObj(Name, Arg, TI, NormalCtor, CFGOnly, IsAnalysis) {
     registerPass();
   }
-  RegisterPassBase(const std::type_info &TI)
+  explicit RegisterPassBase(intptr_t TI)
     : PIObj("", "", TI) {
     // This ctor may only be used for analysis groups: it does not auto-register
     // the pass.
@@ -162,9 +167,11 @@ template<typename PassName>
 struct RegisterPass : public RegisterPassBase {
 
   // Register Pass using default constructor...
-  RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false)
-  : RegisterPassBase(Name, PassArg, typeid(PassName),
-                     callDefaultCtor<PassName>, CFGOnly) {
+  RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false,
+               bool IsAnalysis = false)
+    : RegisterPassBase(Name, PassArg, intptr_t(&PassName::ID),
+                      RegisterPassBase::NormalCtor_t(callDefaultCtor<PassName>),
+                      CFGOnly, IsAnalysis) {
   }
 };
 
@@ -193,23 +200,21 @@ class RegisterAGBase : public RegisterPassBase {
   const PassInfo *ImplementationInfo;
   bool isDefaultImplementation;
 protected:
-  RegisterAGBase(const std::type_info &Interface,
-                 const std::type_info *Pass = 0,
-                 bool isDefault = false);
+  explicit RegisterAGBase(intptr_t InterfaceID,
+                          intptr_t PassID = 0,
+                          bool isDefault = false);
   void setGroupName(const char *Name);
-public:
-  ~RegisterAGBase();
 };
 
 template<typename Interface, bool Default = false>
 struct RegisterAnalysisGroup : public RegisterAGBase {
-  RegisterAnalysisGroup(RegisterPassBase &RPB)
-    : RegisterAGBase(typeid(Interface), &RPB.getPassInfo()->getTypeInfo(), 
+  explicit RegisterAnalysisGroup(RegisterPassBase &RPB)
+    : RegisterAGBase(intptr_t(&Interface::ID), RPB.getPassInfo()->getTypeInfo(),
                      Default) {
   }
 
-  RegisterAnalysisGroup(const char *Name)
-  : RegisterAGBase(typeid(Interface)) {
+  explicit RegisterAnalysisGroup(const char *Name)
+    : RegisterAGBase(intptr_t(&Interface::ID)) {
     setGroupName(Name);
   }
 };
@@ -239,7 +244,6 @@ struct PassRegistrationListener {
   /// or removed from the current executable.
   ///
   virtual void passRegistered(const PassInfo *P) {}
-  virtual void passUnregistered(const PassInfo *P) {}
 
   /// enumeratePasses - Iterate over the registered passes, calling the
   /// passEnumerate callback on each PassInfo object.