LLVM  9.0.0svn
Interval.cpp
Go to the documentation of this file.
1 //===- Interval.cpp - Interval class code ---------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the definition of the Interval class, which represents a
10 // partition of a control flow graph of some kind.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/Analysis/Interval.h"
15 #include "llvm/IR/BasicBlock.h"
16 #include "llvm/IR/CFG.h"
18 
19 using namespace llvm;
20 
21 //===----------------------------------------------------------------------===//
22 // Interval Implementation
23 //===----------------------------------------------------------------------===//
24 
25 // isLoop - Find out if there is a back edge in this interval...
26 bool Interval::isLoop() const {
27  // There is a loop in this interval iff one of the predecessors of the header
28  // node lives in the interval.
29  for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode);
30  I != E; ++I)
31  if (contains(*I))
32  return true;
33  return false;
34 }
35 
36 void Interval::print(raw_ostream &OS) const {
37  OS << "-------------------------------------------------------------\n"
38  << "Interval Contents:\n";
39 
40  // Print out all of the basic blocks in the interval...
41  for (const BasicBlock *Node : Nodes)
42  OS << *Node << "\n";
43 
44  OS << "Interval Predecessors:\n";
45  for (const BasicBlock *Predecessor : Predecessors)
46  OS << *Predecessor << "\n";
47 
48  OS << "Interval Successors:\n";
49  for (const BasicBlock *Successor : Successors)
50  OS << *Successor << "\n";
51 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool isLoop() const
isLoop - Find out if there is a back edge in this interval...
Definition: Interval.cpp:26
std::vector< BasicBlock * >::iterator pred_iterator
Definition: Interval.h:44
bool contains(BasicBlock *BB) const
contains - Find out if a basic block is in this interval
Definition: Interval.h:66
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:112
Interval::pred_iterator pred_end(Interval *I)
Definition: Interval.h:115
std::vector< BasicBlock * > Nodes
Nodes - The basic blocks in this interval.
Definition: Interval.h:54
std::vector< BasicBlock * > Predecessors
Predecessors - List of BasicBlocks that have this Interval&#39;s header block as one of their successors...
Definition: Interval.h:63
std::vector< BasicBlock * > Successors
Successors - List of BasicBlocks that are reachable directly from nodes in this interval, but are not in the interval themselves.
Definition: Interval.h:59
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
#define I(x, y, z)
Definition: MD5.cpp:58
void print(raw_ostream &O) const
print - Show contents in human readable format...
Definition: Interval.cpp:36
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45