1 //===- Interval.cpp - Interval class code ------------------------*- C++ -*--=//
3 // This file contains the definition of the Interval class, which represents a
4 // partition of a control flow graph of some kind.
6 //===----------------------------------------------------------------------===//
8 #include "llvm/Analysis/Interval.h"
9 #include "llvm/BasicBlock.h"
10 #include "llvm/Support/CFG.h"
13 //===----------------------------------------------------------------------===//
14 // Interval Implementation
15 //===----------------------------------------------------------------------===//
17 // isLoop - Find out if there is a back edge in this interval...
19 bool Interval::isLoop() const {
20 // There is a loop in this interval iff one of the predecessors of the header
21 // node lives in the interval.
22 for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode);
24 if (contains(*I)) return true;
30 void Interval::print(std::ostream &o) const {
31 o << "-------------------------------------------------------------\n"
32 << "Interval Contents:\n";
34 // Print out all of the basic blocks in the interval...
35 std::copy(Nodes.begin(), Nodes.end(),
36 std::ostream_iterator<BasicBlock*>(o, "\n"));
38 o << "Interval Predecessors:\n";
39 std::copy(Predecessors.begin(), Predecessors.end(),
40 std::ostream_iterator<BasicBlock*>(o, "\n"));
42 o << "Interval Successors:\n";
43 std::copy(Successors.begin(), Successors.end(),
44 std::ostream_iterator<BasicBlock*>(o, "\n"));