blob: de5d57f85e7deae144d78e0b04b609fa4eb1dd45 [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 Lattner455889a2002-02-12 22:39:50 +000010#include "llvm/Support/CFG.h"
Chris Lattner2275c1d2001-06-20 20:09:55 +000011
Chris Lattner1c54f1d2001-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 Lattnerf0604b82001-10-01 13:19:53 +000018bool cfg::Interval::isLoop() const {
Chris Lattner1c54f1d2001-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 Lattner455889a2002-02-12 22:39:50 +000021 for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode);
22 I != E; ++I) {
Chris Lattner1c54f1d2001-06-21 05:26:15 +000023 if (contains(*I)) return true;
24 }
25 return false;
26}
27
28