Convert xforms over to use new pass structure
authorChris Lattner <sabre@nondot.org>
Wed, 30 Jan 2002 23:29:35 +0000 (23:29 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 30 Jan 2002 23:29:35 +0000 (23:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1596 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/IPO.h
include/llvm/Transforms/IPO/ConstantMerge.h
include/llvm/Transforms/IPO/GlobalDCE.h
include/llvm/Transforms/IPO/SimpleStructMutation.h
include/llvm/Transforms/MutateStructTypes.h
include/llvm/Transforms/Scalar/ConstantProp.h
include/llvm/Transforms/Scalar/DCE.h
include/llvm/Transforms/Scalar/IndVarSimplify.h
include/llvm/Transforms/Scalar/InductionVars.h
include/llvm/Transforms/Scalar/InstructionCombining.h
include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h [new file with mode: 0644]

index 1141d22490c8c726cedd3caf72f19f5a2e2b0a01..313aea2090e1db9f47d1fbf9c51c65b3ab4dd955 100644 (file)
@@ -6,12 +6,9 @@
 #ifndef LLVM_TRANSFORMS_CLEANUPGCCOUTPUT_H
 #define LLVM_TRANSFORMS_CLEANUPGCCOUTPUT_H
 
-#include "llvm/Analysis/FindUsedTypes.h"
-
-class CleanupGCCOutput : public MethodPass {
-  FindUsedTypes FUT;      // Use FUT to eliminate type names that are never used
-public:
+#include "llvm/Pass.h"
 
+struct CleanupGCCOutput : public MethodPass {
   // PatchUpMethodReferences - This is a part of the functionality exported by
   // the CleanupGCCOutput pass.  This causes functions with different signatures
   // to be linked together if they have the same name.
@@ -32,6 +29,12 @@ public:
 
   // doPassFinalization - Strip out type names that are unused by the program
   bool doFinalization(Module *M);
+
+  // getAnalysisUsageInfo - This function needs FindUsedTypes to do its job...
+  //
+  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
+                                    Pass::AnalysisSet &Destroyed,
+                                    Pass::AnalysisSet &Provided);
 };
 
 #endif
index 54f699a81183de20a5d926e832f589610d88a583..efc91f400b309da2e8e0a8de3deef398fb75fb08 100644 (file)
@@ -18,7 +18,6 @@
 #define LLVM_TRANSFORMS_CONSTANTMERGE_H
 
 #include "llvm/Pass.h"
-#include <map>
 class Constant;
 class GlobalVariable;
 
index c4c74470de47a9d06fa1c40dcdb515e97493dc1e..497416cbce3d516b9254ddfec857e70d947284bc 100644 (file)
@@ -18,6 +18,14 @@ struct GlobalDCE : public Pass {
   // the specified callgraph to reflect the changes.
   //
   bool run(Module *M);
+
+  // getAnalysisUsageInfo - This function works on the call graph of a module.
+  // It is capable of updating the call graph to reflect the new state of the
+  // module.
+  //
+  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
+                                    Pass::AnalysisSet &Destroyed,
+                                    Pass::AnalysisSet &Provided);
 };
 
 #endif
index 49c34e37f241e47fd8118b9dda901606c3dae9ec..f159c4de022ccda5c04d3ebf648b73e523a56a07 100644 (file)
@@ -23,8 +23,15 @@ public:
     return Changed;
   }
 
+  // getAnalysisUsageInfo - This function needs the results of the
+  // FindUsedTypes and FindUnsafePointerTypes analysis passes...
+  //
+  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
+                                    Pass::AnalysisSet &Destroyed,
+                                    Pass::AnalysisSet &Provided);
+
 private:
-  static TransformsType getTransforms(Module *M, enum Transform);
+  TransformsType getTransforms(Module *M, enum Transform);
 };
 
 #endif
index 390168f645eb6760dd287814e3d203cd09e14e73..f1132fd6a65c76d96d26d1b4b062cd6b5c2238c9 100644 (file)
 #define LLVM_TRANSFORMS_MUTATESTRUCTTYPES_H
 
 #include "llvm/Pass.h"
-#include <map>
+#include "llvm/AbstractTypeUser.h"
 
+class Value;
+class Type;
 class StructType;
 class CompositeType;
 class GlobalValue;
@@ -58,6 +60,13 @@ public:
   // run - do the transformation
   virtual bool run(Module *M);
 
+  // getAnalysisUsageInfo - This function needs the results of the
+  // FindUsedTypes and FindUnsafePointerTypes analysis passes...
+  //
+  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
+                                    Pass::AnalysisSet &Destroyed,
+                                    Pass::AnalysisSet &Provided);
+
 protected:
 
   // Alternatively, it is valid to subclass this class and provide transforms
index d9adf3f399a7b4299c4096d4a15fafc3a41e6585..c4d973516c4edb5f586610af4c31ee57fa58b6a4 100644 (file)
@@ -4,10 +4,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_OPT_CONSTANT_PROPOGATION_H
-#define LLVM_OPT_CONSTANT_PROPOGATION_H
+#ifndef LLVM_TRANSFORMS_SCALAR_CONSTANT_PROPOGATION_H
+#define LLVM_TRANSFORMS_SCALAR_CONSTANT_PROPOGATION_H
 
 #include "llvm/Pass.h"
+#include "llvm/BasicBlock.h"
 class TerminatorInst;
 
 struct ConstantPropogation : public MethodPass {
index 712223e1d0c2c59caeb26a472a63590f7e9f0b6b..6fc5287e42cca874b825a1b51e88f698000a7865 100644 (file)
@@ -9,7 +9,7 @@
 #define LLVM_OPT_DCE_H
 
 #include "llvm/Pass.h"
-#include "llvm/BasicBlock.h"
+#include "llvm/Method.h"
 
 //===----------------------------------------------------------------------===//
 // DeadInstElimination - This pass quickly removes trivially dead instructions
@@ -68,13 +68,13 @@ struct DeadCodeElimination : public MethodPass {
 // it more successful are removing non-obviously dead instructions.
 //
 struct AgressiveDCE : public MethodPass {
-  // DoADCE - Execute the Agressive Dead Code Elimination Algorithm
-  //
-  static bool doADCE(Method *M);                        // Defined in ADCE.cpp
+  virtual bool runOnMethod(Method *M);
 
-  virtual bool runOnMethod(Method *M) {
-    return doADCE(M);
-  }
+  // getAnalysisUsageInfo - We require post dominance frontiers (aka Control
+  // Dependence Graph)
+  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
+                                    Pass::AnalysisSet &Destroyed,
+                                    Pass::AnalysisSet &Provided);
 };
 
 
index 13f811994b66095d6f5d5bc3f3cb1aa88f34928c..902483eb8cb8e262f99bfeeb6ae3ede0ef4bd5ef 100644 (file)
 
 #include "llvm/Pass.h"
 
+namespace cfg { class LoopInfo; }
+
 struct InductionVariableSimplify : public MethodPass {
-  static bool doit(Method *M);
+  static bool doit(Method *M, cfg::LoopInfo &Loops);
+
+  virtual bool runOnMethod(Method *M);
 
-  virtual bool runOnMethod(Method *M) { return doit(M); }
+  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
+                                    Pass::AnalysisSet &Destroyed,
+                                    Pass::AnalysisSet &Provided);
 };
 
 #endif
index 4faf3458f6698022f64a80a2108e0e6ca8d3237b..7c79afaa594940acc59ca18846cef8dc2aecb7d6 100644 (file)
@@ -9,15 +9,19 @@
 #define LLVM_OPT_INDUCTION_VARS_H
 
 #include "llvm/Pass.h"
+namespace cfg { class IntervalPartition; }
 
 struct InductionVariableCannonicalize : public MethodPass {
   // doInductionVariableCannonicalize - Simplify induction variables in loops
   //
-  static bool doIt(Method *M);
+  static bool doIt(Method *M, cfg::IntervalPartition &IP);
 
-  virtual bool runOnMethod(Method *M) {
-    return doIt(M);
-  }
+  virtual bool runOnMethod(Method *M);
+
+  // getAnalysisUsageInfo - Declare that we need IntervalPartitions
+  void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
+                            Pass::AnalysisSet &Destroyed,
+                            Pass::AnalysisSet &Provided);
 };
 
 #endif
index c79a1caf4b5b4ac73394047e7a852db880d4b61b..0c395720e66a5366858d370f7f437934511a3851 100644 (file)
@@ -16,6 +16,7 @@
 #define LLVM_TRANSFORMS_SCALAR_INSTRUCTIONCOMBINING_H
 
 #include "llvm/Pass.h"
+class Instruction;
 
 struct InstructionCombining : public MethodPass {
   static bool doit(Method *M);
diff --git a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
new file mode 100644 (file)
index 0000000..0939468
--- /dev/null
@@ -0,0 +1,37 @@
+//===-- UnifyMethodExitNodes.h - Ensure methods have one return --*- C++ -*--=//
+//
+// This pass is used to ensure that methods have at most one return instruction
+// in them.  It also holds onto the return instruction of the last unified
+// method.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_XFORMS_UNIFY_METHOD_EXIT_NODES_H
+#define LLVM_XFORMS_UNIFY_METHOD_EXIT_NODES_H
+
+#include "llvm/Pass.h"
+#include "llvm/Analysis/SimplifyCFG.h"   // FIXME!!
+
+struct UnifyMethodExitNodes : public MethodPass {
+  BasicBlock *ExitNode;
+public:
+  static AnalysisID ID;            // Pass ID
+  UnifyMethodExitNodes(AnalysisID id) : ExitNode(0) { assert(ID == id); }
+
+  virtual bool runOnMethod(Method *M) {
+    ExitNode = cfg::UnifyAllExitNodes(M);
+
+    return true; // FIXME: This should return a correct code!!!
+  }
+
+  BasicBlock *getExitNode() const { return ExitNode; }
+
+  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
+                                    Pass::AnalysisSet &Destroyed,
+                                    Pass::AnalysisSet &Provided) {
+    // FIXME: Should invalidate CFG
+    Provided.push_back(ID);  // Provide self!
+  }
+};
+
+#endif