* Pull BasicBlock::pred_* and BasicBlock::succ_* out of BasicBlock.h and into
llvm/Support/CFG.h * Make pred & succ iterators for intervals global functions llvm-svn: 1748
This commit is contained in:
		
							parent
							
								
									64d051c33b
								
							
						
					
					
						commit
						f22ca4d45c
					
				| 
						 | 
					@ -87,21 +87,29 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // isLoop - Find out if there is a back edge in this interval...
 | 
					  // isLoop - Find out if there is a back edge in this interval...
 | 
				
			||||||
  bool isLoop() const;
 | 
					  bool isLoop() const;
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // succ_begin/succ_end - define methods so that Intervals may be used
 | 
					 | 
				
			||||||
  // just like BasicBlocks can with the succ_* functions, and *::succ_iterator.
 | 
					 | 
				
			||||||
  //
 | 
					 | 
				
			||||||
  inline succ_iterator succ_begin() { return Successors.begin(); }
 | 
					 | 
				
			||||||
  inline succ_iterator succ_end()   { return Successors.end(); }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  // pred_begin/pred_end - define methods so that Intervals may be used
 | 
					 | 
				
			||||||
  // just like BasicBlocks can with the pred_* functions, and *::pred_iterator.
 | 
					 | 
				
			||||||
  //
 | 
					 | 
				
			||||||
  inline Interval::pred_iterator pred_begin() { return Predecessors.begin(); }
 | 
					 | 
				
			||||||
  inline Interval::pred_iterator pred_end()   { return Predecessors.end(); }
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}    // End namespace cfg
 | 
					}    // End namespace cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// succ_begin/succ_end - define methods so that Intervals may be used
 | 
				
			||||||
 | 
					// just like BasicBlocks can with the succ_* functions, and *::succ_iterator.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					inline cfg::Interval::succ_iterator succ_begin(cfg::Interval *I) {
 | 
				
			||||||
 | 
					  return I->Successors.begin();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					inline cfg::Interval::succ_iterator succ_end(cfg::Interval *I)   {
 | 
				
			||||||
 | 
					  return I->Successors.end();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					// pred_begin/pred_end - define methods so that Intervals may be used
 | 
				
			||||||
 | 
					// just like BasicBlocks can with the pred_* functions, and *::pred_iterator.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					inline cfg::Interval::pred_iterator pred_begin(cfg::Interval *I) {
 | 
				
			||||||
 | 
					  return I->Predecessors.begin();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					inline cfg::Interval::pred_iterator pred_end(cfg::Interval *I)   {
 | 
				
			||||||
 | 
					  return I->Predecessors.end();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,6 +29,7 @@
 | 
				
			||||||
#include "llvm/Analysis/IntervalPartition.h"
 | 
					#include "llvm/Analysis/IntervalPartition.h"
 | 
				
			||||||
#include "llvm/Method.h"
 | 
					#include "llvm/Method.h"
 | 
				
			||||||
#include "llvm/BasicBlock.h"
 | 
					#include "llvm/BasicBlock.h"
 | 
				
			||||||
 | 
					#include "llvm/Support/CFG.h"
 | 
				
			||||||
#include <stack>
 | 
					#include <stack>
 | 
				
			||||||
#include <set>
 | 
					#include <set>
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
| 
						 | 
					@ -128,7 +129,7 @@ public:
 | 
				
			||||||
      // All of the intervals on the stack have been visited.  Try visiting
 | 
					      // All of the intervals on the stack have been visited.  Try visiting
 | 
				
			||||||
      // their successors now.
 | 
					      // their successors now.
 | 
				
			||||||
      Interval::succ_iterator &SuccIt = IntStack.top().second,
 | 
					      Interval::succ_iterator &SuccIt = IntStack.top().second,
 | 
				
			||||||
	                        EndIt = IntStack.top().first->succ_end();
 | 
						                        EndIt = succ_end(IntStack.top().first);
 | 
				
			||||||
      while (SuccIt != EndIt) {                 // Loop over all interval succs
 | 
					      while (SuccIt != EndIt) {                 // Loop over all interval succs
 | 
				
			||||||
	bool Done = ProcessInterval(getSourceGraphNode(OrigContainer, *SuccIt));
 | 
						bool Done = ProcessInterval(getSourceGraphNode(OrigContainer, *SuccIt));
 | 
				
			||||||
	++SuccIt;                               // Increment iterator
 | 
						++SuccIt;                               // Increment iterator
 | 
				
			||||||
| 
						 | 
					@ -165,11 +166,11 @@ private:
 | 
				
			||||||
    Visited.insert(Header);   // The header has now been visited!
 | 
					    Visited.insert(Header);   // The header has now been visited!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Check all of our successors to see if they are in the interval...
 | 
					    // Check all of our successors to see if they are in the interval...
 | 
				
			||||||
    for (typename NodeTy::succ_iterator I = Node->succ_begin(),
 | 
					    for (typename NodeTy::succ_iterator I = succ_begin(Node),
 | 
				
			||||||
                                        E = Node->succ_end(); I != E; ++I)
 | 
					                                        E = succ_end(Node); I != E; ++I)
 | 
				
			||||||
      ProcessNode(Int, getSourceGraphNode(OrigContainer, *I));
 | 
					      ProcessNode(Int, getSourceGraphNode(OrigContainer, *I));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    IntStack.push(make_pair(Int, Int->succ_begin()));
 | 
					    IntStack.push(make_pair(Int, succ_begin(Int)));
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
| 
						 | 
					@ -196,8 +197,8 @@ private:
 | 
				
			||||||
	  Int->Successors.push_back(NodeHeader);
 | 
						  Int->Successors.push_back(NodeHeader);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else {                             // Otherwise, not in interval yet
 | 
					    } else {                             // Otherwise, not in interval yet
 | 
				
			||||||
      for (typename NodeTy::pred_iterator I = Node->pred_begin(), 
 | 
					      for (typename NodeTy::pred_iterator I = pred_begin(Node), 
 | 
				
			||||||
	                                  E = Node->pred_end(); I != E; ++I) {
 | 
						                                  E = pred_end(Node); I != E; ++I) {
 | 
				
			||||||
	if (!Int->contains(*I)) {        // If pred not in interval, we can't be
 | 
						if (!Int->contains(*I)) {        // If pred not in interval, we can't be
 | 
				
			||||||
	  if (!Int->isSuccessor(NodeHeader)) // Add only if not already in set
 | 
						  if (!Int->isSuccessor(NodeHeader)) // Add only if not already in set
 | 
				
			||||||
	    Int->Successors.push_back(NodeHeader);
 | 
						    Int->Successors.push_back(NodeHeader);
 | 
				
			||||||
| 
						 | 
					@ -219,8 +220,8 @@ private:
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
      // Now that we have discovered that Node is in the interval, perhaps some
 | 
					      // Now that we have discovered that Node is in the interval, perhaps some
 | 
				
			||||||
      // of its successors are as well?
 | 
					      // of its successors are as well?
 | 
				
			||||||
      for (typename NodeTy::succ_iterator It = Node->succ_begin(), 
 | 
					      for (typename NodeTy::succ_iterator It = succ_begin(Node),
 | 
				
			||||||
	     End = Node->succ_end(); It != End; ++It)
 | 
						     End = succ_end(Node); It != End; ++It)
 | 
				
			||||||
	ProcessNode(Int, getSourceGraphNode(OrigContainer, *It));
 | 
						ProcessNode(Int, getSourceGraphNode(OrigContainer, *It));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue