X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FAnalysis%2FPHITransAddr.h;h=d7a3dd889a1b2aca62cb50671132a5208fbf295c;hb=ec3bb4b660fc2f8353c510ebfc15277bcf28df8b;hp=8257396a09f797dc6bb5bcc7bc3cc7cfb13377a5;hpb=43678f41a37c077f28517c2e4889cca88cada6ce;p=oota-llvm.git diff --git a/include/llvm/Analysis/PHITransAddr.h b/include/llvm/Analysis/PHITransAddr.h index 8257396a09f..d7a3dd889a1 100644 --- a/include/llvm/Analysis/PHITransAddr.h +++ b/include/llvm/Analysis/PHITransAddr.h @@ -14,13 +14,14 @@ #ifndef LLVM_ANALYSIS_PHITRANSADDR_H #define LLVM_ANALYSIS_PHITRANSADDR_H -#include "llvm/Instruction.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/IR/Instruction.h" namespace llvm { class DominatorTree; - class TargetData; - + class DataLayout; + class TargetLibraryInfo; + /// PHITransAddr - An address value which tracks and handles phi translation. /// As we walk "up" the CFG through predecessors, we need to ensure that the /// address we're tracking is kept up to date. For example, if we're analyzing @@ -36,12 +37,15 @@ class PHITransAddr { Value *Addr; /// TD - The target data we are playing with if known, otherwise null. - const TargetData *TD; + const DataLayout *TD; + + /// TLI - The target library info if known, otherwise null. + const TargetLibraryInfo *TLI; /// InstInputs - The inputs for our symbolic address. SmallVector InstInputs; public: - PHITransAddr(Value *addr, const TargetData *td) : Addr(addr), TD(td) { + PHITransAddr(Value *addr, const DataLayout *td) : Addr(addr), TD(td), TLI(0) { // If the address is an instruction, the whole thing is considered an input. if (Instruction *I = dyn_cast(Addr)) InstInputs.push_back(I); @@ -66,9 +70,11 @@ public: bool IsPotentiallyPHITranslatable() const; /// PHITranslateValue - PHI translate the current address up the CFG from - /// CurBB to Pred, updating our state the reflect any needed changes. This - /// returns true on failure and sets Addr to null. - bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB); + /// CurBB to Pred, updating our state to reflect any needed changes. If the + /// dominator tree DT is non-null, the translated value must dominate + /// PredBB. This returns true on failure and sets Addr to null. + bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB, + const DominatorTree *DT); /// PHITranslateWithInsertion - PHI translate this value into the specified /// predecessor block, inserting a computation of the value if it is @@ -80,15 +86,16 @@ public: Value *PHITranslateWithInsertion(BasicBlock *CurBB, BasicBlock *PredBB, const DominatorTree &DT, SmallVectorImpl &NewInsts); -private: - Value *PHITranslateSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB); + void dump() const; - /// GetAvailablePHITranslatedSubExpr - Return the value computed by - /// PHITranslateSubExpr if it dominates PredBB, otherwise return null. - Value *GetAvailablePHITranslatedSubExpr(Value *V, - BasicBlock *CurBB, BasicBlock *PredBB, - const DominatorTree &DT) const; + /// Verify - Check internal consistency of this data structure. If the + /// structure is valid, it returns true. If invalid, it prints errors and + /// returns false. + bool Verify() const; +private: + Value *PHITranslateSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB, + const DominatorTree *DT); /// InsertPHITranslatedSubExpr - Insert a computation of the PHI translated /// version of 'V' for the edge PredBB->CurBB into the end of the PredBB @@ -99,10 +106,14 @@ private: BasicBlock *PredBB, const DominatorTree &DT, SmallVectorImpl &NewInsts); - /// ReplaceInstWithValue - Remove any instruction inputs in the InstInputs - /// array that are due to the specified instruction that is about to be - /// removed from the address, and add any corresponding to V. This returns V. - Value *ReplaceInstWithValue(Instruction *I, Value *V); + /// AddAsInput - If the specified value is an instruction, add it as an input. + Value *AddAsInput(Value *V) { + // If V is an instruction, it is now an input. + if (Instruction *VI = dyn_cast(V)) + InstInputs.push_back(VI); + return V; + } + }; } // end namespace llvm