1193323Sed//===- Interval.cpp - Interval class code ---------------------------------===// 2193323Sed// 3193323Sed// The LLVM Compiler Infrastructure 4193323Sed// 5193323Sed// This file is distributed under the University of Illinois Open Source 6193323Sed// License. See LICENSE.TXT for details. 7193323Sed// 8193323Sed//===----------------------------------------------------------------------===// 9193323Sed// 10193323Sed// This file contains the definition of the Interval class, which represents a 11193323Sed// partition of a control flow graph of some kind. 12193323Sed// 13193323Sed//===----------------------------------------------------------------------===// 14193323Sed 15193323Sed#include "llvm/Analysis/Interval.h" 16252723Sdim#include "llvm/IR/BasicBlock.h" 17193323Sed#include "llvm/Support/CFG.h" 18198090Srdivacky#include "llvm/Support/raw_ostream.h" 19193323Sed#include <algorithm> 20193323Sed 21193323Sedusing namespace llvm; 22193323Sed 23193323Sed//===----------------------------------------------------------------------===// 24193323Sed// Interval Implementation 25193323Sed//===----------------------------------------------------------------------===// 26193323Sed 27193323Sed// isLoop - Find out if there is a back edge in this interval... 28193323Sed// 29193323Sedbool Interval::isLoop() const { 30193323Sed // There is a loop in this interval iff one of the predecessors of the header 31193323Sed // node lives in the interval. 32193323Sed for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode); 33198090Srdivacky I != E; ++I) 34198090Srdivacky if (contains(*I)) 35198090Srdivacky return true; 36193323Sed return false; 37193323Sed} 38193323Sed 39193323Sed 40198090Srdivackyvoid Interval::print(raw_ostream &OS) const { 41198090Srdivacky OS << "-------------------------------------------------------------\n" 42193323Sed << "Interval Contents:\n"; 43193323Sed 44193323Sed // Print out all of the basic blocks in the interval... 45193323Sed for (std::vector<BasicBlock*>::const_iterator I = Nodes.begin(), 46193323Sed E = Nodes.end(); I != E; ++I) 47198090Srdivacky OS << **I << "\n"; 48193323Sed 49198090Srdivacky OS << "Interval Predecessors:\n"; 50193323Sed for (std::vector<BasicBlock*>::const_iterator I = Predecessors.begin(), 51193323Sed E = Predecessors.end(); I != E; ++I) 52198090Srdivacky OS << **I << "\n"; 53193323Sed 54198090Srdivacky OS << "Interval Successors:\n"; 55193323Sed for (std::vector<BasicBlock*>::const_iterator I = Successors.begin(), 56193323Sed E = Successors.end(); I != E; ++I) 57198090Srdivacky OS << **I << "\n"; 58193323Sed} 59