checkpoint of the new PHITransAddr code, still not done and not used by
[oota-llvm.git] / include / llvm / Analysis / MemoryDependenceAnalysis.h
index ac92b90731e71893b1f785b017e57537fd863662..b55be29d2eb69c245ce9cfb9f6de5d5094535091 100644 (file)
@@ -30,6 +30,7 @@ namespace llvm {
   class TargetData;
   class MemoryDependenceAnalysis;
   class PredIteratorCache;
+  class DominatorTree;
   
   /// MemDepResult - A memory dependence query can return one of three different
   /// answers, described below.
@@ -59,9 +60,9 @@ namespace llvm {
       ///      this case, the load is loading an undef value or a store is the
       ///      first store to (that part of) the allocation.
       ///   3. Dependence queries on calls return Def only when they are
-      ///      readonly calls with identical callees and no intervening
-      ///      clobbers.  No validation is done that the operands to the calls
-      ///      are the same.
+      ///      readonly calls or memory use intrinsics with identical callees
+      ///      and no intervening clobbers.  No validation is done that the
+      ///      operands to the calls are the same.
       Def,
       
       /// NonLocal - This marker indicates that the query has no dependency in
@@ -95,7 +96,7 @@ namespace llvm {
     /// a instruction definition dependency.
     bool isDef() const { return Value.getInt() == Def; }
     
-    /// isNonLocal - Return true if this MemDepResult represents an query that
+    /// isNonLocal - Return true if this MemDepResult represents a query that
     /// is transparent to the start of the block, but where a non-local hasn't
     /// been done.
     bool isNonLocal() const { return Value.getInt() == NonLocal; }
@@ -104,10 +105,10 @@ namespace llvm {
     /// is depended on.  Otherwise, return null.
     Instruction *getInst() const { return Value.getPointer(); }
     
-    bool operator==(const MemDepResult &M) const { return M.Value == Value; }
-    bool operator!=(const MemDepResult &M) const { return M.Value != Value; }
-    bool operator<(const MemDepResult &M) const { return M.Value < Value; }
-    bool operator>(const MemDepResult &M) const { return M.Value > Value; }
+    bool operator==(const MemDepResult &M) const { return Value == M.Value; }
+    bool operator!=(const MemDepResult &M) const { return Value != M.Value; }
+    bool operator<(const MemDepResult &M) const { return Value < M.Value; }
+    bool operator>(const MemDepResult &M) const { return Value > M.Value; }
   private:
     friend class MemoryDependenceAnalysis;
     /// Dirty - Entries with this marker occur in a LocalDeps map or
@@ -171,9 +172,8 @@ namespace llvm {
     CachedNonLocalPointerInfo NonLocalPointerDeps;
 
     // A map from instructions to their non-local pointer dependencies.
-    // The elements of the SmallPtrSet are ValueIsLoadPair's.
     typedef DenseMap<Instruction*, 
-                     SmallPtrSet<void*, 4> > ReverseNonLocalPtrDepTy;
+                     SmallPtrSet<ValueIsLoadPair, 4> > ReverseNonLocalPtrDepTy;
     ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;
 
     
@@ -245,6 +245,29 @@ namespace llvm {
                                       BasicBlock *BB,
                                      SmallVectorImpl<NonLocalDepEntry> &Result);
     
+    /// GetPHITranslatedValue - Find an available version of the specified value
+    /// PHI translated across the specified edge.  If MemDep isn't able to
+    /// satisfy this request, it returns null.
+    Value *GetPHITranslatedValue(Value *V,
+                                 BasicBlock *CurBB, BasicBlock *PredBB,
+                                 const TargetData *TD) const;
+
+    /// GetAvailablePHITranslatedValue - Return the value computed by
+    /// PHITranslatePointer if it dominates PredBB, otherwise return null.
+    Value *GetAvailablePHITranslatedValue(Value *V,
+                                          BasicBlock *CurBB, BasicBlock *PredBB,
+                                          const TargetData *TD,
+                                          const DominatorTree &DT) const;
+    
+    /// InsertPHITranslatedPointer - Insert a computation of the PHI translated
+    /// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
+    /// block.  All newly created instructions are added to the NewInsts list.
+    Value *InsertPHITranslatedPointer(Value *V,
+                                      BasicBlock *CurBB, BasicBlock *PredBB,
+                                      const TargetData *TD,
+                                      const DominatorTree &DT,
+                                 SmallVectorImpl<Instruction*> &NewInsts) const;
+    
     /// removeInstruction - Remove an instruction from the dependence analysis,
     /// updating the dependence of instructions that previously depended on it.
     void removeInstruction(Instruction *InstToRemove);