2003-10-13 11:32:08 +08:00
|
|
|
//===- Interval.cpp - Interval class code ---------------------------------===//
|
2005-04-22 05:13:18 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 05:13:18 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-21 04:09:55 +08:00
|
|
|
//
|
2002-04-29 00:21:30 +08:00
|
|
|
// This file contains the definition of the Interval class, which represents a
|
|
|
|
// partition of a control flow graph of some kind.
|
2001-06-21 04:09:55 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2001-06-24 12:05:21 +08:00
|
|
|
#include "llvm/Analysis/Interval.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/BasicBlock.h"
|
2014-03-04 19:45:46 +08:00
|
|
|
#include "llvm/IR/CFG.h"
|
2009-08-23 12:37:46 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2002-07-27 09:12:17 +08:00
|
|
|
#include <algorithm>
|
2001-06-21 04:09:55 +08:00
|
|
|
|
2003-11-12 06:41:34 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2001-06-21 13:26:15 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Interval Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// isLoop - Find out if there is a back edge in this interval...
|
|
|
|
//
|
2002-04-29 00:21:30 +08:00
|
|
|
bool Interval::isLoop() const {
|
2012-09-27 18:14:43 +08:00
|
|
|
// There is a loop in this interval iff one of the predecessors of the header
|
2001-06-21 13:26:15 +08:00
|
|
|
// node lives in the interval.
|
2014-07-22 01:06:51 +08:00
|
|
|
for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode);
|
|
|
|
I != E; ++I)
|
|
|
|
if (contains(*I))
|
2009-08-23 12:37:46 +08:00
|
|
|
return true;
|
2001-06-21 13:26:15 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-23 14:03:38 +08:00
|
|
|
void Interval::print(raw_ostream &OS) const {
|
2009-08-23 12:37:46 +08:00
|
|
|
OS << "-------------------------------------------------------------\n"
|
2002-07-27 09:12:17 +08:00
|
|
|
<< "Interval Contents:\n";
|
2005-04-22 05:13:18 +08:00
|
|
|
|
2002-07-27 09:12:17 +08:00
|
|
|
// Print out all of the basic blocks in the interval...
|
2016-06-27 01:27:42 +08:00
|
|
|
for (const BasicBlock *Node : Nodes)
|
|
|
|
OS << *Node << "\n";
|
2002-07-27 09:12:17 +08:00
|
|
|
|
2009-08-23 12:37:46 +08:00
|
|
|
OS << "Interval Predecessors:\n";
|
2016-06-27 01:27:42 +08:00
|
|
|
for (const BasicBlock *Predecessor : Predecessors)
|
|
|
|
OS << *Predecessor << "\n";
|
2004-07-15 10:31:46 +08:00
|
|
|
|
2009-08-23 12:37:46 +08:00
|
|
|
OS << "Interval Successors:\n";
|
2016-06-27 01:27:42 +08:00
|
|
|
for (const BasicBlock *Successor : Successors)
|
|
|
|
OS << *Successor << "\n";
|
2002-07-27 09:12:17 +08:00
|
|
|
}
|