blob: a4aa88abdbc946edc1dc4872e899eb822ae78fe9 [file] [log] [blame]
Chris Lattnerdec727e2001-06-24 04:05:21 +00001//===- Interval.cpp - Interval class code ------------------------*- C++ -*--=//
Chris Lattner28ae5cb2001-06-20 20:09:55 +00002//
Chris Lattner78dd56f2002-04-28 16:21:30 +00003// This file contains the definition of the Interval class, which represents a
4// partition of a control flow graph of some kind.
Chris Lattner28ae5cb2001-06-20 20:09:55 +00005//
6//===----------------------------------------------------------------------===//
7
Chris Lattnerdec727e2001-06-24 04:05:21 +00008#include "llvm/Analysis/Interval.h"
Chris Lattner28ae5cb2001-06-20 20:09:55 +00009#include "llvm/BasicBlock.h"
Chris Lattner83d485b2002-02-12 22:39:50 +000010#include "llvm/Support/CFG.h"
Chris Lattner28ae5cb2001-06-20 20:09:55 +000011
Chris Lattnerd79faa32001-06-21 05:26:15 +000012//===----------------------------------------------------------------------===//
13// Interval Implementation
14//===----------------------------------------------------------------------===//
15
16// isLoop - Find out if there is a back edge in this interval...
17//
Chris Lattner78dd56f2002-04-28 16:21:30 +000018bool Interval::isLoop() const {
Chris Lattnerd79faa32001-06-21 05:26:15 +000019 // There is a loop in this interval iff one of the predecessors of the header
20 // node lives in the interval.
Chris Lattner83d485b2002-02-12 22:39:50 +000021 for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode);
22 I != E; ++I) {
Chris Lattnerd79faa32001-06-21 05:26:15 +000023 if (contains(*I)) return true;
24 }
25 return false;
26}
27
28