blob: 97fa34ea7aeb0a0c9069caa423aedda98f4f2676 [file] [log] [blame]
Chris Lattner107109c2001-06-24 04:05:21 +00001//===- Interval.cpp - Interval class code ------------------------*- C++ -*--=//
Chris Lattner2275c1d2001-06-20 20:09:55 +00002//
Chris Lattner107109c2001-06-24 04:05:21 +00003// This file contains the definition of the cfg::Interval class, which
4// represents a partition of a control flow graph of some kind.
Chris Lattner2275c1d2001-06-20 20:09:55 +00005//
6//===----------------------------------------------------------------------===//
7
Chris Lattner107109c2001-06-24 04:05:21 +00008#include "llvm/Analysis/Interval.h"
Chris Lattner2275c1d2001-06-20 20:09:55 +00009#include "llvm/BasicBlock.h"
Chris Lattner2275c1d2001-06-20 20:09:55 +000010
Chris Lattnered465bc2001-06-20 22:44:32 +000011using namespace cfg;
12
Chris Lattner1c54f1d2001-06-21 05:26:15 +000013//===----------------------------------------------------------------------===//
14// Interval Implementation
15//===----------------------------------------------------------------------===//
16
17// isLoop - Find out if there is a back edge in this interval...
18//
19bool 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 (BasicBlock::pred_iterator I = pred_begin(HeaderNode),
23 E = pred_end(HeaderNode); I != E; ++I) {
24 if (contains(*I)) return true;
25 }
26 return false;
27}
28
29