2003-10-13 05:32:08 +02:00
|
|
|
//===- Interval.cpp - Interval class code ---------------------------------===//
|
2003-10-20 21:43:21 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-20 22:09:55 +02:00
|
|
|
//
|
2002-04-28 18:21:30 +02:00
|
|
|
// This file contains the definition of the Interval class, which represents a
|
|
|
|
// partition of a control flow graph of some kind.
|
2001-06-20 22:09:55 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2001-06-24 06:05:21 +02:00
|
|
|
#include "llvm/Analysis/Interval.h"
|
2001-06-20 22:09:55 +02:00
|
|
|
#include "llvm/BasicBlock.h"
|
2002-02-12 23:39:50 +01:00
|
|
|
#include "llvm/Support/CFG.h"
|
2002-07-27 03:12:17 +02:00
|
|
|
#include <algorithm>
|
2001-06-20 22:09:55 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
using namespace llvm;
|
|
|
|
|
2001-06-21 07:26:15 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Interval Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// isLoop - Find out if there is a back edge in this interval...
|
|
|
|
//
|
2002-04-28 18:21:30 +02:00
|
|
|
bool Interval::isLoop() const {
|
2001-06-21 07:26:15 +02:00
|
|
|
// There is a loop in this interval iff one of the predecessors of the header
|
|
|
|
// node lives in the interval.
|
2002-02-12 23:39:50 +01:00
|
|
|
for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode);
|
|
|
|
I != E; ++I) {
|
2001-06-21 07:26:15 +02:00
|
|
|
if (contains(*I)) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-31 21:32:01 +02:00
|
|
|
void Interval::print(std::ostream &o) const {
|
2002-07-27 03:12:17 +02:00
|
|
|
o << "-------------------------------------------------------------\n"
|
|
|
|
<< "Interval Contents:\n";
|
|
|
|
|
|
|
|
// Print out all of the basic blocks in the interval...
|
|
|
|
std::copy(Nodes.begin(), Nodes.end(),
|
|
|
|
std::ostream_iterator<BasicBlock*>(o, "\n"));
|
|
|
|
|
|
|
|
o << "Interval Predecessors:\n";
|
|
|
|
std::copy(Predecessors.begin(), Predecessors.end(),
|
|
|
|
std::ostream_iterator<BasicBlock*>(o, "\n"));
|
|
|
|
|
|
|
|
o << "Interval Successors:\n";
|
|
|
|
std::copy(Successors.begin(), Successors.end(),
|
|
|
|
std::ostream_iterator<BasicBlock*>(o, "\n"));
|
|
|
|
}
|