Change over to use new style pass mechanism, now passes only expose small
[oota-llvm.git] / lib / Transforms / Scalar / IndVarSimplify.cpp
index 692fcacb7e3b2723334d9245d4e685c0c79a021b..fcf49e171a61ebda747d6f4fa077d41a6e2e0326 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/Type.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/ConstantVals.h"
+#include "llvm/Pass.h"
 #include "llvm/Support/CFG.h"
 #include "Support/STLExtras.h"
 
@@ -186,19 +187,29 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) {
   return Changed;
 }
 
-bool InductionVariableSimplify::doit(Method *M, cfg::LoopInfo &Loops) {
+static bool doit(Method *M, cfg::LoopInfo &Loops) {
   // Induction Variables live in the header nodes of the loops of the method...
   return reduce_apply_bool(Loops.getTopLevelLoops().begin(),
                            Loops.getTopLevelLoops().end(),
                            std::bind1st(std::ptr_fun(TransformLoop), &Loops));
 }
 
-bool InductionVariableSimplify::runOnMethod(Method *M) {
-  return doit(M, getAnalysis<cfg::LoopInfo>());
+
+namespace {
+  struct InductionVariableSimplify : public MethodPass {
+    virtual bool runOnMethod(Method *M) {
+      return doit(M, getAnalysis<cfg::LoopInfo>());
+    }
+    
+    virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
+                                      Pass::AnalysisSet &Destroyed,
+                                      Pass::AnalysisSet &Provided) {
+      Required.push_back(cfg::LoopInfo::ID);
+    }
+  };
 }
 
-void InductionVariableSimplify::getAnalysisUsageInfo(Pass::AnalysisSet &Req,
-                                                     Pass::AnalysisSet &Dest,
-                                                     Pass::AnalysisSet &Prov) {
-  Req.push_back(cfg::LoopInfo::ID);
+Pass *createIndVarSimplifyPass() {
+  return new InductionVariableSimplify();
 }
+