2003-10-13 05:32:08 +02:00
|
|
|
//===- Interval.cpp - Interval class code ---------------------------------===//
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
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"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/BasicBlock.h"
|
2014-03-04 12:45:46 +01:00
|
|
|
#include "llvm/IR/CFG.h"
|
2009-08-23 06:37:46 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
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 {
|
2012-09-27 12:14:43 +02:00
|
|
|
// There is a loop in this interval iff one of the predecessors of the header
|
2001-06-21 07:26:15 +02:00
|
|
|
// node lives in the interval.
|
2014-07-21 19:06:51 +02:00
|
|
|
for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode);
|
|
|
|
I != E; ++I)
|
|
|
|
if (contains(*I))
|
2009-08-23 06:37:46 +02:00
|
|
|
return true;
|
2001-06-21 07:26:15 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-23 08:03:38 +02:00
|
|
|
void Interval::print(raw_ostream &OS) const {
|
2009-08-23 06:37:46 +02:00
|
|
|
OS << "-------------------------------------------------------------\n"
|
2002-07-27 03:12:17 +02:00
|
|
|
<< "Interval Contents:\n";
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2002-07-27 03:12:17 +02:00
|
|
|
// Print out all of the basic blocks in the interval...
|
2016-06-26 19:27:42 +02:00
|
|
|
for (const BasicBlock *Node : Nodes)
|
|
|
|
OS << *Node << "\n";
|
2002-07-27 03:12:17 +02:00
|
|
|
|
2009-08-23 06:37:46 +02:00
|
|
|
OS << "Interval Predecessors:\n";
|
2016-06-26 19:27:42 +02:00
|
|
|
for (const BasicBlock *Predecessor : Predecessors)
|
|
|
|
OS << *Predecessor << "\n";
|
2004-07-15 04:31:46 +02:00
|
|
|
|
2009-08-23 06:37:46 +02:00
|
|
|
OS << "Interval Successors:\n";
|
2016-06-26 19:27:42 +02:00
|
|
|
for (const BasicBlock *Successor : Successors)
|
|
|
|
OS << *Successor << "\n";
|
2002-07-27 03:12:17 +02:00
|
|
|
}
|