Remove dead field
[oota-llvm.git] / include / llvm / PassSupport.h
index 567ea9adf0c4bc290d80bba7a21104b078578697..f20e40743f36b5f7b2a7c6b975e01e8d41dd5705 100644 (file)
@@ -1,4 +1,11 @@
 //===- llvm/PassSupport.h - Pass Support code -------------------*- C++ -*-===//
+// 
+//                     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 defines stuff that is used to define and "use" Passes.  This file
 // is automatically #included by Pass.h, so:
@@ -16,7 +23,8 @@
 
 // No need to include Pass.h, we are being included by it!
 
-class TargetData;
+namespace llvm {
+
 class TargetMachine;
 
 //===---------------------------------------------------------------------------
@@ -33,7 +41,7 @@ class PassInfo {
   std::vector<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
 
   Pass *(*NormalCtor)();               // No argument ctor
-  Pass *(*DataCtor)(const TargetData&);// Ctor taking TargetData object...
+  Pass *(*TargetCtor)(TargetMachine&);   // Ctor taking TargetMachine object...
 
 public:
   /// PassType - Define symbolic constants that can be used to test to see if
@@ -48,9 +56,10 @@ 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, 
-           unsigned pt, Pass *(*normal)(), Pass *(*data)(const TargetData &))
+           unsigned char pt, Pass *(*normal)() = 0,
+           Pass *(*targetctor)(TargetMachine &) = 0)
     : PassName(name), PassArgument(arg), TypeInfo(ti), PassType(pt),
-      NormalCtor(normal), DataCtor(data) {
+      NormalCtor(normal), TargetCtor(targetctor)  {
   }
 
   /// getPassName - Return the friendly name for the pass, never returns null
@@ -94,12 +103,12 @@ public:
     return NormalCtor();
   }
 
-  /// getDataCtor - Return a pointer to a function that creates an instance of
+  /// getTargetCtor - Return a pointer to a function that creates an instance of
   /// the pass and returns it.  This returns a constructor for a version of the
-  /// pass that takes a TArgetData object as a parameter.
+  /// pass that takes a TargetMachine object as a parameter.
   ///
-  Pass *(*getDataCtor() const)(const TargetData &) {
-    return DataCtor;
+  Pass *(*getTargetCtor() const)(TargetMachine &) {
+    return TargetCtor;
   }
 
   /// addInterfaceImplemented - This method is called when this pass is
@@ -152,10 +161,10 @@ protected:
   void registerPass(PassInfo *);
   void unregisterPass(PassInfo *);
 
-  /// setPreservesCFG - Notice that this pass only depends on the CFG, so
+  /// setOnlyUsesCFG - Notice that this pass only depends on the CFG, so
   /// transformations that do not modify the CFG do not invalidate this pass.
   ///
-  void setPreservesCFG();
+  void setOnlyUsesCFG();
 };
 
 template<typename PassName>
@@ -165,29 +174,29 @@ template<typename PassName>
 struct RegisterPass : public RegisterPassBase {
   
   // Register Pass using default constructor...
-  RegisterPass(const char *PassArg, const char *Name, unsigned PassTy = 0) {
+  RegisterPass(const char *PassArg, const char *Name, unsigned char PassTy = 0){
     registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
-                              callDefaultCtor<PassName>, 0));
+                              callDefaultCtor<PassName>));
   }
 
   // Register Pass using default constructor explicitly...
-  RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
+  RegisterPass(const char *PassArg, const char *Name, unsigned char PassTy,
                Pass *(*ctor)()) {
-    registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor,0));
+    registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor));
   }
 
-  // Register Pass using TargetData constructor...
-  RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
-               Pass *(*datactor)(const TargetData &)) {
+  // Register Pass using TargetMachine constructor...
+  RegisterPass(const char *PassArg, const char *Name, unsigned char PassTy,
+               Pass *(*targetctor)(TargetMachine &)) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
-                              0, datactor));
+                              0, targetctor));
   }
 
   // Generic constructor version that has an unknown ctor type...
   template<typename CtorType>
-  RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
+  RegisterPass(const char *PassArg, const char *Name, unsigned char PassTy,
                CtorType *Fn) {
-    registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, 0, 0));
+    registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, 0));
   }
 };
 
@@ -196,25 +205,50 @@ struct RegisterPass : public RegisterPassBase {
 ///
 template<typename PassName>
 struct RegisterOpt : public RegisterPassBase {
-  RegisterOpt(const char *PassArg, const char *Name) {
+  RegisterOpt(const char *PassArg, const char *Name, bool CFGOnly = false) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
                               PassInfo::Optimization,
-                              callDefaultCtor<PassName>, 0));
+                              callDefaultCtor<PassName>));
+    if (CFGOnly) setOnlyUsesCFG();
   }
 
   /// Register Pass using default constructor explicitly...
   ///
-  RegisterOpt(const char *PassArg, const char *Name, Pass *(*ctor)()) {
+  RegisterOpt(const char *PassArg, const char *Name, Pass *(*ctor)(),
+              bool CFGOnly = false) {
+    registerPass(new PassInfo(Name, PassArg, typeid(PassName),
+                              PassInfo::Optimization, ctor));
+    if (CFGOnly) setOnlyUsesCFG();
+  }
+
+  /// Register FunctionPass using default constructor explicitly...
+  ///
+  RegisterOpt(const char *PassArg, const char *Name, FunctionPass *(*ctor)(),
+              bool CFGOnly = false) {
+    registerPass(new PassInfo(Name, PassArg, typeid(PassName),
+                              PassInfo::Optimization, 
+                              static_cast<Pass*(*)()>(ctor)));
+    if (CFGOnly) setOnlyUsesCFG();
+  }
+
+  /// Register Pass using TargetMachine constructor...
+  ///
+  RegisterOpt(const char *PassArg, const char *Name,
+               Pass *(*targetctor)(TargetMachine &), bool CFGOnly = false) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
-                              PassInfo::Optimization, ctor, 0));
+                              PassInfo::Optimization, 0, targetctor));
+    if (CFGOnly) setOnlyUsesCFG();
   }
 
-  /// Register Pass using TargetData constructor...
+  /// Register FunctionPass using TargetMachine constructor...
   ///
   RegisterOpt(const char *PassArg, const char *Name,
-               Pass *(*datactor)(const TargetData &)) {
+              FunctionPass *(*targetctor)(TargetMachine &),
+              bool CFGOnly = false) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
-                              PassInfo::Optimization, 0, datactor));
+                              PassInfo::Optimization, 0,
+                            static_cast<Pass*(*)(TargetMachine&)>(targetctor)));
+    if (CFGOnly) setOnlyUsesCFG();
   }
 };
 
@@ -230,9 +264,8 @@ struct RegisterAnalysis : public RegisterPassBase {
                    bool CFGOnly = false) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
                               PassInfo::Analysis,
-                              callDefaultCtor<PassName>, 0));
-    if (CFGOnly)
-      setPreservesCFG();
+                              callDefaultCtor<PassName>));
+    if (CFGOnly) setOnlyUsesCFG();
   }
 };
 
@@ -244,22 +277,14 @@ struct RegisterLLC : public RegisterPassBase {
   RegisterLLC(const char *PassArg, const char *Name) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
                               PassInfo::LLC,
-                              callDefaultCtor<PassName>, 0));
+                              callDefaultCtor<PassName>));
   }
 
   /// Register Pass using default constructor explicitly...
   ///
   RegisterLLC(const char *PassArg, const char *Name, Pass *(*ctor)()) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
-                              PassInfo::LLC, ctor, 0));
-  }
-
-  /// Register Pass using TargetData constructor...
-  ///
-  RegisterLLC(const char *PassArg, const char *Name,
-               Pass *(*datactor)(const TargetData &)) {
-    registerPass(new PassInfo(Name, PassArg, typeid(PassName),
-                              PassInfo::LLC, 0, datactor));
+                              PassInfo::LLC, ctor));
   }
 
   /// Register Pass using TargetMachine constructor...
@@ -267,7 +292,7 @@ struct RegisterLLC : public RegisterPassBase {
   RegisterLLC(const char *PassArg, const char *Name,
                Pass *(*datactor)(TargetMachine &)) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
-                              PassInfo::LLC, 0, 0));
+                              PassInfo::LLC));
   }
 };
 
@@ -373,4 +398,7 @@ struct PassRegistrationListener {
 struct IncludeFile {
   IncludeFile(void *);
 };
+
+} // End llvm namespace
+
 #endif