Home | History | Annotate | Download | only in Utils
      1 //===-- llvm/Transforms/Utils/SimplifyIndVar.h - Indvar Utils ---*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file defines in interface for induction variable simplification. It does
     11 // not define any actual pass or policy, but provides a single function to
     12 // simplify a loop's induction variables based on ScalarEvolution.
     13 //
     14 //===----------------------------------------------------------------------===//
     15 
     16 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
     17 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
     18 
     19 #include "llvm/Support/CommandLine.h"
     20 
     21 namespace llvm {
     22 
     23 extern cl::opt<bool> DisableIVRewrite;
     24 
     25 class Loop;
     26 class LoopInfo;
     27 class DominatorTree;
     28 class ScalarEvolution;
     29 class LPPassManager;
     30 class IVUsers;
     31 
     32 /// Interface for visiting interesting IV users that are recognized but not
     33 /// simplified by this utility.
     34 class IVVisitor {
     35 public:
     36   virtual ~IVVisitor() {}
     37   virtual void visitCast(CastInst *Cast) = 0;
     38 };
     39 
     40 /// simplifyUsersOfIV - Simplify instructions that use this induction variable
     41 /// by using ScalarEvolution to analyze the IV's recurrence.
     42 bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, LPPassManager *LPM,
     43                        SmallVectorImpl<WeakVH> &Dead, IVVisitor *V = NULL);
     44 
     45 /// SimplifyLoopIVs - Simplify users of induction variables within this
     46 /// loop. This does not actually change or add IVs.
     47 bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, LPPassManager *LPM,
     48                      SmallVectorImpl<WeakVH> &Dead);
     49 
     50 /// simplifyIVUsers - Simplify instructions recorded by the IVUsers pass.
     51 /// This is a legacy implementation to reproduce the behavior of the
     52 /// IndVarSimplify pass prior to DisableIVRewrite.
     53 bool simplifyIVUsers(IVUsers *IU, ScalarEvolution *SE, LPPassManager *LPM,
     54                      SmallVectorImpl<WeakVH> &Dead);
     55 
     56 } // namespace llvm
     57 
     58 #endif
     59