LLVM API Documentation
00001 //===-- llvm/Transforms/Utils/SimplifyIndVar.h - Indvar Utils ---*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines in interface for induction variable simplification. It does 00011 // not define any actual pass or policy, but provides a single function to 00012 // simplify a loop's induction variables based on ScalarEvolution. 00013 // 00014 //===----------------------------------------------------------------------===// 00015 00016 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H 00017 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H 00018 00019 #include "llvm/IR/ValueHandle.h" 00020 #include "llvm/Support/CommandLine.h" 00021 00022 namespace llvm { 00023 00024 class CastInst; 00025 class DominatorTree; 00026 class IVUsers; 00027 class Loop; 00028 class LPPassManager; 00029 class PHINode; 00030 class ScalarEvolution; 00031 00032 /// Interface for visiting interesting IV users that are recognized but not 00033 /// simplified by this utility. 00034 class IVVisitor { 00035 protected: 00036 const DominatorTree *DT; 00037 bool ShouldSplitOverflowIntrinsics; 00038 00039 virtual void anchor(); 00040 00041 public: 00042 IVVisitor(): DT(nullptr), ShouldSplitOverflowIntrinsics(false) {} 00043 virtual ~IVVisitor() {} 00044 00045 const DominatorTree *getDomTree() const { return DT; } 00046 00047 bool shouldSplitOverflowInstrinsics() const { 00048 return ShouldSplitOverflowIntrinsics; 00049 } 00050 void setSplitOverflowIntrinsics() { 00051 ShouldSplitOverflowIntrinsics = true; 00052 assert(DT && "Splitting overflow intrinsics requires a DomTree."); 00053 } 00054 00055 virtual void visitCast(CastInst *Cast) = 0; 00056 }; 00057 00058 /// simplifyUsersOfIV - Simplify instructions that use this induction variable 00059 /// by using ScalarEvolution to analyze the IV's recurrence. 00060 bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, LPPassManager *LPM, 00061 SmallVectorImpl<WeakVH> &Dead, IVVisitor *V = nullptr); 00062 00063 /// SimplifyLoopIVs - Simplify users of induction variables within this 00064 /// loop. This does not actually change or add IVs. 00065 bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, LPPassManager *LPM, 00066 SmallVectorImpl<WeakVH> &Dead); 00067 00068 } // namespace llvm 00069 00070 #endif