Change MRegisterInfo::foldMemoryOperand to return the folded
[oota-llvm.git] / include / llvm / PassSupport.h
index 2f6c316227a916bab10b8fa55f4446790c4eb24d..bc2b7da8a2442ac1f3a4fb86a282524f645982b1 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:
 #ifndef LLVM_PASS_SUPPORT_H
 #define LLVM_PASS_SUPPORT_H
 
-#include <assert.h>
-
 // No need to include Pass.h, we are being included by it!
 
+namespace llvm {
+
 class TargetMachine;
 
 //===---------------------------------------------------------------------------
@@ -154,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>
@@ -198,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>));
+    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 &)) {
+               Pass *(*targetctor)(TargetMachine &), bool CFGOnly = false) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
                               PassInfo::Optimization, 0, targetctor));
+    if (CFGOnly) setOnlyUsesCFG();
+  }
+
+  /// Register FunctionPass using TargetMachine constructor...
+  ///
+  RegisterOpt(const char *PassArg, const char *Name,
+              FunctionPass *(*targetctor)(TargetMachine &),
+              bool CFGOnly = false) {
+    registerPass(new PassInfo(Name, PassArg, typeid(PassName),
+                              PassInfo::Optimization, 0,
+                            static_cast<Pass*(*)(TargetMachine&)>(targetctor)));
+    if (CFGOnly) setOnlyUsesCFG();
   }
 };
 
@@ -233,8 +265,7 @@ struct RegisterAnalysis : public RegisterPassBase {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
                               PassInfo::Analysis,
                               callDefaultCtor<PassName>));
-    if (CFGOnly)
-      setPreservesCFG();
+    if (CFGOnly) setOnlyUsesCFG();
   }
 };
 
@@ -367,4 +398,7 @@ struct PassRegistrationListener {
 struct IncludeFile {
   IncludeFile(void *);
 };
+
+} // End llvm namespace
+
 #endif