LLVM API Documentation
00001 //===- Interval.cpp - Interval class code ---------------------------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the definition of the Interval class, which represents a 00011 // partition of a control flow graph of some kind. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #include "llvm/Analysis/Interval.h" 00016 #include "llvm/BasicBlock.h" 00017 #include "llvm/Support/CFG.h" 00018 #include <algorithm> 00019 00020 using namespace llvm; 00021 00022 //===----------------------------------------------------------------------===// 00023 // Interval Implementation 00024 //===----------------------------------------------------------------------===// 00025 00026 // isLoop - Find out if there is a back edge in this interval... 00027 // 00028 bool Interval::isLoop() const { 00029 // There is a loop in this interval iff one of the predecessors of the header 00030 // node lives in the interval. 00031 for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode); 00032 I != E; ++I) { 00033 if (contains(*I)) return true; 00034 } 00035 return false; 00036 } 00037 00038 00039 void Interval::print(std::ostream &o) const { 00040 o << "-------------------------------------------------------------\n" 00041 << "Interval Contents:\n"; 00042 00043 // Print out all of the basic blocks in the interval... 00044 for (std::vector<BasicBlock*>::const_iterator I = Nodes.begin(), 00045 E = Nodes.end(); I != E; ++I) 00046 o << **I << "\n"; 00047 00048 o << "Interval Predecessors:\n"; 00049 for (std::vector<BasicBlock*>::const_iterator I = Predecessors.begin(), 00050 E = Predecessors.end(); I != E; ++I) 00051 o << **I << "\n"; 00052 00053 o << "Interval Successors:\n"; 00054 for (std::vector<BasicBlock*>::const_iterator I = Successors.begin(), 00055 E = Successors.end(); I != E; ++I) 00056 o << **I << "\n"; 00057 }