00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef LLVM_ANALYSIS_PHITRANSADDR_H
00015 #define LLVM_ANALYSIS_PHITRANSADDR_H
00016
00017 #include "llvm/Instruction.h"
00018 #include "llvm/ADT/SmallVector.h"
00019
00020 namespace llvm {
00021 class DominatorTree;
00022 class TargetData;
00023
00034 class PHITransAddr {
00036 Value *Addr;
00037
00039 const TargetData *TD;
00040
00042 SmallVector<Instruction*, 4> InstInputs;
00043 public:
00044 PHITransAddr(Value *addr, const TargetData *td) : Addr(addr), TD(td) {
00045
00046 if (Instruction *I = dyn_cast<Instruction>(Addr))
00047 InstInputs.push_back(I);
00048 }
00049
00050 Value *getAddr() const { return Addr; }
00051
00054 bool NeedsPHITranslationFromBlock(BasicBlock *BB) const {
00055
00056
00057 for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
00058 if (InstInputs[i]->getParent() == BB)
00059 return true;
00060 return false;
00061 }
00062
00066 bool IsPotentiallyPHITranslatable() const;
00067
00072 bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB,
00073 const DominatorTree *DT);
00074
00082 Value *PHITranslateWithInsertion(BasicBlock *CurBB, BasicBlock *PredBB,
00083 const DominatorTree &DT,
00084 SmallVectorImpl<Instruction*> &NewInsts);
00085
00086 void dump() const;
00087
00091 bool Verify() const;
00092 private:
00093 Value *PHITranslateSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB,
00094 const DominatorTree *DT);
00095
00101 Value *InsertPHITranslatedSubExpr(Value *InVal, BasicBlock *CurBB,
00102 BasicBlock *PredBB, const DominatorTree &DT,
00103 SmallVectorImpl<Instruction*> &NewInsts);
00104
00106 Value *AddAsInput(Value *V) {
00107
00108 if (Instruction *VI = dyn_cast<Instruction>(V))
00109 InstInputs.push_back(VI);
00110 return V;
00111 }
00112
00113 };
00114
00115 }
00116
00117 #endif