move llvm/Transforms/Pass.h to the top level llvm/Pass.h file
authorChris Lattner <sabre@nondot.org>
Thu, 18 Oct 2001 20:19:09 +0000 (20:19 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Oct 2001 20:19:09 +0000 (20:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@901 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
include/llvm/Optimizations/LevelChange.h
include/llvm/Pass.h [new file with mode: 0644]
include/llvm/Transforms/ChangeAllocations.h
include/llvm/Transforms/FunctionInlining.h
include/llvm/Transforms/HoistPHIConstants.h
include/llvm/Transforms/IPO/ConstantMerge.h
include/llvm/Transforms/Instrumentation/TraceValues.h
include/llvm/Transforms/Pass.h [deleted file]
include/llvm/Transforms/PrintModulePass.h
include/llvm/Transforms/Scalar/ConstantProp.h
include/llvm/Transforms/Scalar/DCE.h
include/llvm/Transforms/Scalar/InductionVars.h
include/llvm/Transforms/Scalar/SymbolStripping.h

index 128e9e1b2125fa24f6c59cc4e7354522c5333e43..b68ed765f2addb328f98d2d8e99acdb7e1de2eff 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef LLVM_OPT_LEVELCHANGE_H
 #define LLVM_OPT_LEVELCHANGE_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 #include "llvm/Module.h"
 #include "llvm/Method.h"
 
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h
new file mode 100644 (file)
index 0000000..e357df0
--- /dev/null
@@ -0,0 +1,126 @@
+//===- llvm/Pass.h - Base class for XForm Passes -----------------*- C++ -*--=//
+//
+// This file defines a base class that indicates that a specified class is a
+// transformation pass implementation.
+//
+// Pass's are designed this way so that it is possible to apply N passes to a
+// module, by first doing N Pass specific initializations for the module, then
+// looping over all of the methods in the module, doing method specific work
+// N times for each method.  Like this:
+//
+// for_each(Passes.begin(), Passes.end(), doPassInitialization(Module));
+// for_each(Method *M <- Module->begin(), Module->end())
+//   for_each(Passes.begin(), Passes.end(), doPerMethodWork(M));
+//
+// The other way to do things is like this:
+// for_each(Pass *P <- Passes.begin(), Passes.end()) {
+//   Passes->doPassInitialization(Module)
+//   for_each(Module->begin(), Module->end(), P->doPerMethodWork);
+// }
+//
+// But this can cause thrashing and poor cache performance, so we don't do it
+// that way.
+//
+// Because a transformation does not see all methods consecutively, it should
+// be careful about the state that it maintains... another pass may modify a
+// method between two invocatations of doPerMethodWork.
+//
+// Also, implementations of doMethodWork should not remove any methods from the
+// module.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_PASS_H
+#define LLVM_PASS_H
+
+#include "llvm/Module.h"
+#include "llvm/Method.h"
+
+//===----------------------------------------------------------------------===//
+// Pass interface - Implemented by all 'passes'.
+//
+struct Pass {
+  //===--------------------------------------------------------------------===//
+  // The externally useful entry points
+  //
+
+  // runAllPasses - Run a bunch of passes on the specified module, efficiently.
+  static bool runAllPasses(Module *M, vector<Pass*> &Passes) {
+    bool MadeChanges = false;
+    // Run all of the pass initializers
+    for (unsigned i = 0; i < Passes.size(); ++i)
+      MadeChanges |= Passes[i]->doPassInitialization(M);
+    
+    // Loop over all of the methods, applying all of the passes to them
+    for (unsigned m = 0; m < M->size(); ++m)
+      for (unsigned i = 0; i < Passes.size(); ++i)
+        MadeChanges |= Passes[i]->doPerMethodWork(*(M->begin()+m));
+
+    // Run all of the pass finalizers...
+    for (unsigned i = 0; i < Passes.size(); ++i)
+      MadeChanges |= Passes[i]->doPassFinalization(M);
+    return MadeChanges;
+  }
+
+  // runAllPassesAndFree - Run a bunch of passes on the specified module,
+  // efficiently.  When done, delete all of the passes.
+  //
+  static bool runAllPassesAndFree(Module *M, vector<Pass*> &Passes) {
+    // First run all of the passes
+    bool MadeChanges = runAllPasses(M, Passes);
+
+    // Free all of the passes.
+    for (unsigned i = 0; i < Passes.size(); ++i)
+      delete Passes[i];
+    return MadeChanges;
+  }
+
+
+  // run(Module*) - Run this pass on a module and all of the methods contained
+  // within it.  Returns true if any of the contained passes returned true.
+  //
+  bool run(Module *M) {
+    bool MadeChanges = doPassInitialization(M);
+
+    // Loop over methods in the module.  doPerMethodWork could add a method to
+    // the Module, so we have to keep checking for end of method list condition.
+    //
+    for (unsigned m = 0; m < M->size(); ++m)
+      MadeChanges |= doPerMethodWork(*(M->begin()+m));
+    return MadeChanges | doPassFinalization(M);
+  }
+
+  // run(Method*) - Run this pass on a module and one specific method.  Returns
+  // false on success.
+  //
+  bool run(Method *M) {
+    return doPassInitialization(M->getParent()) | doPerMethodWork(M) |
+           doPassFinalization(M->getParent());
+  }
+
+
+  //===--------------------------------------------------------------------===//
+  // Functions to be implemented by subclasses
+  //
+
+  // Destructor - Virtual so we can be subclassed
+  inline virtual ~Pass() {}
+
+  // doPassInitialization - Virtual method overridden by subclasses to do
+  // any neccesary per-module initialization.
+  //
+  virtual bool doPassInitialization(Module *M) { return false; }
+
+  // doPerMethodWork - Virtual method overriden by subclasses to do the
+  // per-method processing of the pass.
+  //
+  virtual bool doPerMethodWork(Method *M) { return false; }
+
+  // doPassFinalization - Virtual method overriden by subclasses to do any post
+  // processing needed after all passes have run.
+  //
+  virtual bool doPassFinalization(Module *M) { return false; }
+};
+
+#endif
+
index 46efa26077b92eb9708b1845eca41eb77ec296b6..8f53051da34fe3d027f77f078dc249dbb199f3bf 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef LLVM_TRANSFORMS_LOWERALLOCATIONS_H
 #define LLVM_TRANSFORMS_LOWERALLOCATIONS_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 class TargetData;
 
 class LowerAllocations : public Pass {
index 373708d6b0de806ecbccdbf5a42dae00d841ff39..520cc7fe6cf02a52807f86f35e7efc27badd9b55 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef LLVM_OPT_METHOD_INLINING_H
 #define LLVM_OPT_METHOD_INLINING_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 #include "llvm/BasicBlock.h"
 class CallInst;
 
index 931269bc0b13f3a38fc522c070ffb3973f7a91bc..65bae751a81ab0c7a914081f8039cd6645da75bf 100644 (file)
@@ -9,12 +9,13 @@
 #ifndef LLVM_TRANSFORMS_HOISTPHICONSTANTS_H
 #define LLVM_TRANSFORMS_HOISTPHICONSTANTS_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 
 struct HoistPHIConstants : public Pass {
+  // doHoistPHIConstants - Hoist constants out of PHI instructions
+  //
   static bool doHoistPHIConstants(Method *M);
 
-
   virtual bool doPerMethodWork(Method *M) { return doHoistPHIConstants(M); }
 };
 
index e98e375f084e1ac90a556c2f475044a3fc2aff83..4ebbfd3d93062b5ecdf84de52f85581981a73f3d 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef LLVM_TRANSFORMS_CONSTANTMERGE_H
 #define LLVM_TRANSFORMS_CONSTANTMERGE_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 #include <map>
 class ConstPoolVal;
 class GlobalVariable;
index 4f9201b5e8ed29fb0d589dc8425b31353323ae98..d4e2edd5ddd34f49884d9ffe8881bfe90cd0dba8 100644 (file)
@@ -1,21 +1,14 @@
-// $Id$ -*-c++-*-
-//***************************************************************************
-// File:
-//     TraceValues.h
-// 
-// Purpose:
-//      Support for inserting LLVM code to print values at basic block
-//      and method exits.  Also exports functions to create a call
-//      "printf" instruction with one of the signatures listed below.
-// 
-// History:
-//     10/11/01         -  Vikram Adve  -  Created
-//**************************************************************************/
+//===- llvm/Transforms/Instrumentation/TraceValues.h - Tracing ---*- C++ -*--=//
+//
+// Support for inserting LLVM code to print values at basic block and method
+// exits.
+//
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_TRACEVALUES_H
 #define LLVM_TRANSFORMS_INSTRUMENTATION_TRACEVALUES_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 
 class InsertTraceCode : public Pass {
   bool TraceBasicBlockExits, TraceMethodExits;
@@ -30,13 +23,10 @@ public:
   // 
   // Inserts tracing code for all live values at basic block and/or method exits
   // as specified by `traceBasicBlockExits' and `traceMethodExits'.
-  //--------------------------------------------------------------------------
-
+  //
   static bool doInsertTraceCode(Method *M, bool traceBasicBlockExits,
                                 bool traceMethodExits);
 
-
-
   // doPerMethodWork - This method does the work.  Always successful.
   //
   bool doPerMethodWork(Method *M) {
diff --git a/include/llvm/Transforms/Pass.h b/include/llvm/Transforms/Pass.h
deleted file mode 100644 (file)
index 259a432..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-//===- llvm/Transforms/Pass.h - Base class for XForm Passes ------*- C++ -*--=//
-//
-// This file defines a marker class that indicates that a specified class is a
-// transformation pass implementation.
-//
-// Pass's are designed this way so that it is possible to apply N passes to a
-// module, by first doing N Pass specific initializations for the module, then
-// looping over all of the methods in the module, doing method specific work
-// N times for each method.  Like this:
-//
-// for_each(Passes.begin(), Passes.end(), doPassInitialization(Module));
-// for_each(Method *M <- Module->begin(), Module->end())
-//   for_each(Passes.begin(), Passes.end(), doPerMethodWork(M));
-//
-// The other way to do things is like this:
-// for_each(Pass *P <- Passes.begin(), Passes.end()) {
-//   Passes->doPassInitialization(Module)
-//   for_each(Module->begin(), Module->end(), P->doPerMethodWork);
-// }
-//
-// But this can cause thrashing and poor cache performance, so we don't do it
-// that way.
-//
-// Because a transformation does not see all methods consecutively, it should
-// be careful about the state that it maintains... another pass may modify a
-// method between two invocatations of doPerMethodWork.
-//
-// Also, implementations of doMethodWork should not remove any methods from the
-// module.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_PASS_H
-#define LLVM_TRANSFORMS_PASS_H
-
-#include "llvm/Module.h"
-#include "llvm/Method.h"
-
-//===----------------------------------------------------------------------===//
-// Pass interface - Implemented by all 'passes'.
-//
-struct Pass {
-  //===--------------------------------------------------------------------===//
-  // The externally useful entry points
-  //
-
-  // runAllPasses - Run a bunch of passes on the specified module, efficiently.
-  static bool runAllPasses(Module *M, vector<Pass*> &Passes) {
-    bool MadeChanges = false;
-    // Run all of the pass initializers
-    for (unsigned i = 0; i < Passes.size(); ++i)
-      MadeChanges |= Passes[i]->doPassInitialization(M);
-    
-    // Loop over all of the methods, applying all of the passes to them
-    for (unsigned m = 0; m < M->size(); ++m)
-      for (unsigned i = 0; i < Passes.size(); ++i)
-        MadeChanges |= Passes[i]->doPerMethodWork(*(M->begin()+m));
-
-    // Run all of the pass finalizers...
-    for (unsigned i = 0; i < Passes.size(); ++i)
-      MadeChanges |= Passes[i]->doPassFinalization(M);
-    return MadeChanges;
-  }
-
-  // runAllPassesAndFree - Run a bunch of passes on the specified module,
-  // efficiently.  When done, delete all of the passes.
-  //
-  static bool runAllPassesAndFree(Module *M, vector<Pass*> &Passes) {
-    // First run all of the passes
-    bool MadeChanges = runAllPasses(M, Passes);
-
-    // Free all of the passes.
-    for (unsigned i = 0; i < Passes.size(); ++i)
-      delete Passes[i];
-    return MadeChanges;
-  }
-
-
-  // run(Module*) - Run this pass on a module and all of the methods contained
-  // within it.  Returns true if any of the contained passes returned true.
-  //
-  bool run(Module *M) {
-    bool MadeChanges = doPassInitialization(M);
-
-    // Loop over methods in the module.  doPerMethodWork could add a method to
-    // the Module, so we have to keep checking for end of method list condition.
-    //
-    for (unsigned m = 0; m < M->size(); ++m)
-      MadeChanges |= doPerMethodWork(*(M->begin()+m));
-    return MadeChanges | doPassFinalization(M);
-  }
-
-  // run(Method*) - Run this pass on a module and one specific method.  Returns
-  // false on success.
-  //
-  bool run(Method *M) {
-    return doPassInitialization(M->getParent()) | doPerMethodWork(M) |
-           doPassFinalization(M->getParent());
-  }
-
-
-  //===--------------------------------------------------------------------===//
-  // Functions to be implemented by subclasses
-  //
-
-  // Destructor - Virtual so we can be subclassed
-  inline virtual ~Pass() {}
-
-  // doPassInitialization - Virtual method overridden by subclasses to do
-  // any neccesary per-module initialization.
-  //
-  virtual bool doPassInitialization(Module *M) { return false; }
-
-  // doPerMethodWork - Virtual method overriden by subclasses to do the
-  // per-method processing of the pass.
-  //
-  virtual bool doPerMethodWork(Method *M) { return false; }
-
-  // doPassFinalization - Virtual method overriden by subclasses to do any post
-  // processing needed after all passes have run.
-  //
-  virtual bool doPassFinalization(Module *M) { return false; }
-};
-
-#endif
-
index 142c2b08d1f2280db9546ff80fe7be487d6095d1..a7a441207687a0fd7fcea6f6bb8b60c29772b92a 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef LLVM_TRANSFORMS_PRINTMODULE_H
 #define LLVM_TRANSFORMS_PRINTMODULE_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Bytecode/Writer.h"
 
@@ -61,6 +61,7 @@ public:
   
   bool doPassFinalization(Module *M) {
     WriteBytecodeToFile(M, *Out);    
+    return false;
   }
 };
 
index 918ef07270bd7837ac3252c4f3dd0d35477c07b3..f094ec5496f538b5e6df117b28e4868522b256c6 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef LLVM_OPT_CONSTANT_PROPOGATION_H
 #define LLVM_OPT_CONSTANT_PROPOGATION_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 class TerminatorInst;
 
 namespace opt {
index 9a7bd6e77b4830e3b740e62cd41fff2c86e57a30..e7a07ec89681f0b579b918a27b0ff9bbdff27f50 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef LLVM_OPT_DCE_H
 #define LLVM_OPT_DCE_H
 
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 
 namespace opt {
 
index e0c46d85efab0619144a6d8ef38c25ab921869bd..82ec9fcc75ff4a24d0d76b814898a0bea93c4310 100644 (file)
@@ -8,8 +8,7 @@
 #ifndef LLVM_OPT_INDUCTION_VARS_H
 #define LLVM_OPT_INDUCTION_VARS_H
 
-#include "llvm/Transforms/Pass.h"
-#include "llvm/Module.h"
+#include "llvm/Pass.h"
 
 namespace opt {
 
index a5540f9869fd03682a1cb91fc1dc7e035d937906..1feb4381e96bf51e3e2f0722e2f8f35dbd13e286 100644 (file)
@@ -8,9 +8,7 @@
 #ifndef LLVM_OPT_SYMBOL_STRIPPING_H
 #define LLVM_OPT_SYMBOL_STRIPPING_H
 
-class Method;
-class Module;
-#include "llvm/Transforms/Pass.h"
+#include "llvm/Pass.h"
 
 namespace opt {