IntervalPartition & IntervalIterator classes have been split out into
[oota-llvm.git] / lib / Analysis / Interval.cpp
1 //===- Interval.cpp - Interval class code ------------------------*- C++ -*--=//
2 //
3 // This file contains the definition of the cfg::Interval class, which
4 // represents a partition of a control flow graph of some kind.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #include "llvm/Analysis/Interval.h"
9 #include "llvm/BasicBlock.h"
10 #include "llvm/CFG.h"
11
12 using namespace cfg;
13
14 //===----------------------------------------------------------------------===//
15 // Interval Implementation
16 //===----------------------------------------------------------------------===//
17
18 // isLoop - Find out if there is a back edge in this interval...
19 //
20 bool Interval::isLoop() const {
21   // There is a loop in this interval iff one of the predecessors of the header
22   // node lives in the interval.
23   for (BasicBlock::pred_iterator I = pred_begin(HeaderNode), 
24                                  E = pred_end(HeaderNode); I != E; ++I) {
25     if (contains(*I)) return true;
26   }
27   return false;
28 }
29
30