Simplify induction variables pass
[oota-llvm.git] / include / llvm / Transforms / Scalar / DCE.h
index 7ddef5e91292a2217f5819bfda2287a1f1d0c165..86943ebd8555568fb7dc4eee6712e01bb313def6 100644 (file)
@@ -8,21 +8,52 @@
 #ifndef LLVM_OPT_DCE_H
 #define LLVM_OPT_DCE_H
 
-#include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Pass.h"
+#include "llvm/BasicBlock.h"
 
 namespace opt {
 
-bool DoDeadCodeElimination(Method *M);         // DCE a method
-bool DoDeadCodeElimination(Module *C);         // DCE & RUC a whole module
+struct DeadCodeElimination : public Pass {
+  // External Interface:
+  //
+  static bool doDCE(Method *M);
 
+  // dceInstruction - Inspect the instruction at *BBI and figure out if it's
+  // [trivially] dead.  If so, remove the instruction and update the iterator
+  // to point to the instruction that immediately succeeded the original
+  // instruction.
+  //
+  static bool dceInstruction(BasicBlock::InstListType &BBIL,
+                             BasicBlock::iterator &BBI);
+
+  // Remove unused global values - This removes unused global values of no
+  // possible value.  This currently includes unused method prototypes and
+  // unitialized global variables.
+  //
+  static bool RemoveUnusedGlobalValues(Module *M);
+
+  // Pass Interface...
+  virtual bool doPassInitialization(Module *M) {
+    return RemoveUnusedGlobalValues(M);
+  }
+  virtual bool doPerMethodWork(Method *M) { return doDCE(M); }
+  virtual bool doPassFinalization(Module *M) {
+    return RemoveUnusedGlobalValues(M);
+  }
+};
+
+
+
+struct AgressiveDCE : public Pass {
+  // DoADCE - Execute the Agressive Dead Code Elimination Algorithm
+  //
+  static bool doADCE(Method *M);                        // Defined in ADCE.cpp
+
+  virtual bool doPerMethodWork(Method *M) {
+    return doADCE(M);
+  }
+};
 
-// DoADCE - Execute the Agressive Dead Code Elimination Algorithm
-//
-bool DoADCE(Method *M);                        // Defined in ADCE.cpp
-static inline bool DoADCE(Module *M) {
-  return M->reduceApply(DoADCE);
-}
 
 // SimplifyCFG - This function is used to do simplification of a CFG.  For
 // example, it adjusts branches to branches to eliminate the extra hop, it