LLVM API Documentation
00001 //===- Interval.cpp - Interval class code ---------------------------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // 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/IR/BasicBlock.h" 00017 #include "llvm/IR/CFG.h" 00018 #include "llvm/Support/raw_ostream.h" 00019 #include <algorithm> 00020 00021 using namespace llvm; 00022 00023 //===----------------------------------------------------------------------===// 00024 // Interval Implementation 00025 //===----------------------------------------------------------------------===// 00026 00027 // isLoop - Find out if there is a back edge in this interval... 00028 // 00029 bool Interval::isLoop() const { 00030 // There is a loop in this interval iff one of the predecessors of the header 00031 // node lives in the interval. 00032 for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode); 00033 I != E; ++I) 00034 if (contains(*I)) 00035 return true; 00036 return false; 00037 } 00038 00039 00040 void Interval::print(raw_ostream &OS) const { 00041 OS << "-------------------------------------------------------------\n" 00042 << "Interval Contents:\n"; 00043 00044 // Print out all of the basic blocks in the interval... 00045 for (std::vector<BasicBlock*>::const_iterator I = Nodes.begin(), 00046 E = Nodes.end(); I != E; ++I) 00047 OS << **I << "\n"; 00048 00049 OS << "Interval Predecessors:\n"; 00050 for (std::vector<BasicBlock*>::const_iterator I = Predecessors.begin(), 00051 E = Predecessors.end(); I != E; ++I) 00052 OS << **I << "\n"; 00053 00054 OS << "Interval Successors:\n"; 00055 for (std::vector<BasicBlock*>::const_iterator I = Successors.begin(), 00056 E = Successors.end(); I != E; ++I) 00057 OS << **I << "\n"; 00058 }