scale.score.pp
Class PPBlock

java.lang.Object
  extended by scale.common.Root
      extended by scale.score.pp.PPBlock
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
PPSupergraphBlock

public class PPBlock
extends Root

Represents a basic block in a path profiling CFG (PPCfg).

$Id: PPBlock.java,v 1.14 2007-10-29 13:38:14 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.


Constructor Summary
protected PPBlock()
          A constructor used by subclass PPSupergraphBlock.
  PPBlock(Chord firstChord, PPCfg cfg)
          Constructor that sets the first and last chords in the basic block.
 
Method Summary
 void addAllInEdges(java.util.AbstractCollection<PPEdge> list)
          Add all incoming edges to the specified collection.
 void addAllOutEdges(java.util.AbstractCollection<PPEdge> list)
          Add all outgoing edges to the specified collection.
 boolean addInEdge(PPEdge edge)
          Add the edge to the incoming edges.
 boolean addOutEdge(PPEdge edge)
          Add the edge to the outgoing edges.
 void dumpEdges()
           
 boolean equals(java.lang.Object o)
          Two blocks are the same if they have the same first chord.
 Chord firstChord()
          Return the first Chord of this block.
 double getAvgTripCount()
          Get the average trip count for a loop.
 long getBranchEdgeFrequency()
          Return the outgoing branch edge frequency.
 PPCfg getCfg()
          Return the path profiling CFG representation that this block is part of.
 java.lang.String getDisplayName()
          Return a unique label for graphical displays.
 PPEdge getHighestOutEdge(long pathNum)
          Return the outgoing edge that has the highest value that is less than or equal to the current value of pathNum..
 long getHighRange()
           
 PPEdge getInEdge(int i)
          Return the specified incoming edge.
 long getInEdgeFrequency()
          Return the incoming edge frequency.
 long getLowRange()
           
 int getNumChords()
           
 long getNumPaths()
          Return the number of paths for this block.
 PPEdge getOutEdge(int i)
          Return the specified outgoing edge.
 long getOutEdgeFrequency()
          Return the outgoing edge frequency.
 java.lang.String getRangeText()
           
 int getRank()
           
 double getWeight()
          The computed weight of the block.
 boolean hasEdges()
          Return true if there are any edges.
 int hashCode()
          Return the hash code for this block which is just the first Chord's hash code.
 boolean hasInEdges()
          Return true if there are any incoming edges.
 boolean hasOutEdges()
          Return true if there are any outgoing edges.
 PPEdge[] incoming()
          Return a list of the incoming edges of this block.
 void incRank()
           
 void incrementInEdges(long inc)
          Add the specified increment to all of the incoming edges.
 boolean isBeginBlock()
          Return true if and only if this basic block is BEGIN.
 boolean isEndBlock()
          Return true if and only if this basic block is END.
 boolean isLoopHeader()
          Return true if the basic block is a loop header.
 boolean isNumPathsSet()
          Return true if and only the number of paths for this block has been set.
 Chord lastChord()
          Return the last Chord of this block.
 int numInEdges()
          Return the number of incoming edges.
 int numOutEdges()
          Return the number of incoming edges.
 PPEdge[] outgoing()
          Return a list of the incoming edges of this block.
 boolean removeInEdge(PPEdge edge)
          Remove the specified incoming edge.
 boolean removeOutEdge(PPEdge edge)
          Remove the specified outgoing edge.
 void resetNumPaths()
          Reset the number of paths for this block.
 void setHighRange(long high)
           
 void setLowRange(long low)
           
 void setNumPaths(long numPaths)
          Set the number of paths for this block.
 void setRank(int rank)
           
 java.lang.String toString()
           
 void unionRange(long low, long high)
           
 void validate(PPBlock block, HashSet<PPEdge> incomingEdgesEncountered, HashSet<PPEdge> outgoingEdgesEncountered)
          Check the block edges and add them to the specified sets.
 
Methods inherited from class scale.common.Root
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayColorHint, getDisplayLabel, getDisplayShapeHint, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, toStringSpecial, trace, trace, trace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PPBlock

public PPBlock(Chord firstChord,
               PPCfg cfg)
Constructor that sets the first and last chords in the basic block.

Parameters:
firstChord - The first Chord (from Scribble) of a basic block.
cfg - The CFG that this basic block is part of.

PPBlock

protected PPBlock()
A constructor used by subclass PPSupergraphBlock.

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class Root

getDisplayName

public java.lang.String getDisplayName()
Description copied from class: Root
Return a unique label for graphical displays.

Specified by:
getDisplayName in interface DisplayNode
Overrides:
getDisplayName in class Root

firstChord

public Chord firstChord()
Return the first Chord of this block.


lastChord

public Chord lastChord()
Return the last Chord of this block.


incoming

public PPEdge[] incoming()
Return a list of the incoming edges of this block.


outgoing

public PPEdge[] outgoing()
Return a list of the incoming edges of this block.


addInEdge

public boolean addInEdge(PPEdge edge)
Add the edge to the incoming edges.

Returns:
true if the edge was already there

addOutEdge

public boolean addOutEdge(PPEdge edge)
Add the edge to the outgoing edges.

Returns:
true if the edge was already there

removeInEdge

public boolean removeInEdge(PPEdge edge)
Remove the specified incoming edge.

Returns:
true if the edge was an incoming edge

removeOutEdge

public boolean removeOutEdge(PPEdge edge)
Remove the specified outgoing edge.

Returns:
true if the edge was an outgoing edge

addAllInEdges

public void addAllInEdges(java.util.AbstractCollection<PPEdge> list)
Add all incoming edges to the specified collection.


addAllOutEdges

public void addAllOutEdges(java.util.AbstractCollection<PPEdge> list)
Add all outgoing edges to the specified collection.


numInEdges

public int numInEdges()
Return the number of incoming edges.


getInEdge

public PPEdge getInEdge(int i)
Return the specified incoming edge.


getOutEdge

public PPEdge getOutEdge(int i)
Return the specified outgoing edge.


numOutEdges

public int numOutEdges()
Return the number of incoming edges.


hasInEdges

public boolean hasInEdges()
Return true if there are any incoming edges.


hasOutEdges

public boolean hasOutEdges()
Return true if there are any outgoing edges.


hasEdges

public final boolean hasEdges()
Return true if there are any edges.


getInEdgeFrequency

public long getInEdgeFrequency()
Return the incoming edge frequency.


getOutEdgeFrequency

public long getOutEdgeFrequency()
Return the outgoing edge frequency.


getBranchEdgeFrequency

public long getBranchEdgeFrequency()
Return the outgoing branch edge frequency.


getHighestOutEdge

public PPEdge getHighestOutEdge(long pathNum)
Return the outgoing edge that has the highest value that is less than or equal to the current value of pathNum..


dumpEdges

public void dumpEdges()

incrementInEdges

public void incrementInEdges(long inc)
Add the specified increment to all of the incoming edges.


getAvgTripCount

public double getAvgTripCount()
Get the average trip count for a loop.


validate

public void validate(PPBlock block,
                     HashSet<PPEdge> incomingEdgesEncountered,
                     HashSet<PPEdge> outgoingEdgesEncountered)
Check the block edges and add them to the specified sets.


getNumPaths

public long getNumPaths()
Return the number of paths for this block. This is used for path profiling instrumentation.


setNumPaths

public void setNumPaths(long numPaths)
Set the number of paths for this block. This is used for path profiling instrumentation.

Parameters:
numPaths - The number of paths for this block.

resetNumPaths

public void resetNumPaths()
Reset the number of paths for this block. This is used for path profiling instrumentation.


isNumPathsSet

public boolean isNumPathsSet()
Return true if and only the number of paths for this block has been set. This is used for path profiling instrumentation.


isBeginBlock

public boolean isBeginBlock()
Return true if and only if this basic block is BEGIN.


isEndBlock

public boolean isEndBlock()
Return true if and only if this basic block is END.


getCfg

public PPCfg getCfg()
Return the path profiling CFG representation that this block is part of.


getNumChords

public int getNumChords()

isLoopHeader

public boolean isLoopHeader()
Return true if the basic block is a loop header.


equals

public boolean equals(java.lang.Object o)
Two blocks are the same if they have the same first chord.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Return the hash code for this block which is just the first Chord's hash code.

Overrides:
hashCode in class Root

getWeight

public double getWeight()
The computed weight of the block. The weight is computed from edge weights in weightMap.

Returns:
The computed weight of the block.

getLowRange

public final long getLowRange()

setLowRange

public final void setLowRange(long low)

getHighRange

public final long getHighRange()

setHighRange

public final void setHighRange(long high)

unionRange

public final void unionRange(long low,
                             long high)

getRangeText

public final java.lang.String getRangeText()

getRank

public final int getRank()

setRank

public final void setRank(int rank)

incRank

public final void incRank()