scale.score.pp
Class PPEdge

java.lang.Object
  extended by scale.common.Root
      extended by scale.score.pp.PPEdge
All Implemented Interfaces:
java.lang.Comparable<PPEdge>, AnnotationInterface, DisplayNode

public final class PPEdge
extends Root
implements java.lang.Comparable<PPEdge>

Represents an edge in a path profiling CFG (PPCfg).

$Id: PPEdge.java,v 1.15 2007-10-29 13:38:15 burrill Exp $

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

TODO: Description of this class.


Field Summary
static int DUMMY_FOR_BACK_EDGE
          The type for a dummy edge added because a back edge was removed.
static int DUMMY_FOR_TRUNCATED_EDGE
          The type for a dummy edge added because a non-back edge was truncated.
static int NORMAL
          The type for a normal (non-dummy) edge.
 
Constructor Summary
PPEdge(PPBlock source, PPBlock target, int type, PPCfg cfg)
          A constructor that sets the source and target basic blocks of this edge, as well as the CFG that this edge is in.
 
Method Summary
 void addToFrequency(long frequency)
          Add the frequency to the frequency value of this edge.
 void addToIncrement(long increment)
          Add the increment to the increment value of this edge.
 void addWeight(PPEdge srcEdge)
          Add the weight of one edge to another edge.
 int compareTo(PPEdge o2)
          Compare two edges by edge weight.
 int dir(PPEdge e1)
          Return 1 if the edges are in the same direction and -1 otherwise.
 boolean equals(java.lang.Object o)
          Compares two edges.
 boolean equals(PPBlock source, PPBlock target, int type)
          Compares two edges.
 PPCfg getCfg()
          Return the CFG that contains this edge.
 long getFrequency()
          Retun the frequency value of this edge.
 long getIncrement()
          Retun the increment value of this edge.
 int getType()
          Return the type of this edge (see the constants in this class).
 double getWeight()
          Return the edge's weight
 int hashCode()
          The hash code for a block is a combination of the source, target, and type hash codes.
static int hashCode(PPBlock source, PPBlock target, int type)
          The hash code for a block is a combination of the source, target, and type hash codes.
 boolean isBackEdge()
          Return true if the edge is a back edge.
 boolean isBranchEdge()
           
 boolean isDummy()
          Tells us whether this edge is a dummy edge.
 boolean isEditable()
          Return true if this path profiling CFG edge is editable.
static boolean isEditable(Chord sourceChord, Chord targetChord)
          Return true if the Scribble CFG edge is editable.
 boolean mayTruncate()
          Return true if and only if it is okay to truncate this edge.
 void setFrequency(long frequency)
          Set the frequency value of this edge.
 void setIncrement(long increment)
          Set the increment value of this edge.
 void setWeight(double weight)
          Return the edge's weight
 PPBlock source()
          Return The source basic block of this edge.
 PPBlock target()
          Return The target basic block of this edge.
 java.lang.String toString()
           
 
Methods inherited from class scale.common.Root
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayColorHint, getDisplayLabel, getDisplayName, 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
 

Field Detail

NORMAL

public static final int NORMAL
The type for a normal (non-dummy) edge.

See Also:
Constant Field Values

DUMMY_FOR_BACK_EDGE

public static final int DUMMY_FOR_BACK_EDGE
The type for a dummy edge added because a back edge was removed. This type is also used for dummy edges that are added for reasons other than back edge removal and truncation, such as the END to BEGIN edge added for the minimal instrumentation algorithm and the SUPERBEGIN to BEGIN and END to SUPEREND edges added to make the supergraph for flow analysis.

See Also:
Constant Field Values

DUMMY_FOR_TRUNCATED_EDGE

public static final int DUMMY_FOR_TRUNCATED_EDGE
The type for a dummy edge added because a non-back edge was truncated.

See Also:
Constant Field Values
Constructor Detail

PPEdge

public PPEdge(PPBlock source,
              PPBlock target,
              int type,
              PPCfg cfg)
A constructor that sets the source and target basic blocks of this edge, as well as the CFG that this edge is in.

Parameters:
source - is the source basic block of this edge.
target - is the target basic block of this edge.
type - is the type of this edge. See the constants in this class.
cfg - is the CFG that this edge is in.
Method Detail

compareTo

public int compareTo(PPEdge o2)
Compare two edges by edge weight.

Specified by:
compareTo in interface java.lang.Comparable<PPEdge>

toString

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

source

public PPBlock source()
Return The source basic block of this edge.


target

public PPBlock target()
Return The target basic block of this edge.


getType

public int getType()
Return the type of this edge (see the constants in this class).


isDummy

public boolean isDummy()
Tells us whether this edge is a dummy edge.

Returns:
True if and only if this edge is a dummy edge.

getIncrement

public final long getIncrement()
Retun the increment value of this edge. This is used for path profiling instrumentation.


setIncrement

public final void setIncrement(long increment)
Set the increment value of this edge. This is used for path profiling instrumentation.

Parameters:
increment - The new increment value for this edge.

addToIncrement

public final void addToIncrement(long increment)
Add the increment to the increment value of this edge. This is used for path profiling instrumentation.

Parameters:
increment - The new increment value for this edge.

getFrequency

public final long getFrequency()
Retun the frequency value of this edge. This is used for path profiling instrumentation.


setFrequency

public final void setFrequency(long frequency)
Set the frequency value of this edge. This is used for path profiling instrumentation.

Parameters:
frequency - The new frequency value for this edge.

addToFrequency

public final void addToFrequency(long frequency)
Add the frequency to the frequency value of this edge. This is used for path profiling instrumentation.

Parameters:
frequency - The new frequency value for this edge.

isEditable

public boolean isEditable()
Return true if this path profiling CFG edge is editable.


isEditable

public static boolean isEditable(Chord sourceChord,
                                 Chord targetChord)
Return true if the Scribble CFG edge is editable. All edges are editable except the following: (1) edges from LoopPreHeaderChord to LoopHeaderChord; (2) edges from LoopTailChord to LoopHeaderChord.

Parameters:
sourceChord - The source of the edge. This parameter may be null.
targetChord - The target of the edge.

isBackEdge

public boolean isBackEdge()
Return true if the edge is a back edge.


mayTruncate

public boolean mayTruncate()
Return true if and only if it is okay to truncate this edge.


getCfg

public PPCfg getCfg()
Return the CFG that contains this edge.


equals

public boolean equals(PPBlock source,
                      PPBlock target,
                      int type)
Compares two edges. Two edges are equal if and only if their sources and targets are the same AND they're types are the same.


equals

public boolean equals(java.lang.Object o)
Compares two edges. Two edges are equal if and only if their sources and targets are the same AND they're types are the same.

Overrides:
equals in class java.lang.Object

hashCode

public static int hashCode(PPBlock source,
                           PPBlock target,
                           int type)
The hash code for a block is a combination of the source, target, and type hash codes.


hashCode

public int hashCode()
The hash code for a block is a combination of the source, target, and type hash codes.

Overrides:
hashCode in class Root

getWeight

public double getWeight()
Return the edge's weight


setWeight

public void setWeight(double weight)
Return the edge's weight


addWeight

public void addWeight(PPEdge srcEdge)
Add the weight of one edge to another edge.

Parameters:
srcEdge - The edge to get weight from.

dir

public int dir(PPEdge e1)
Return 1 if the edges are in the same direction and -1 otherwise. e1 can be null.


isBranchEdge

public boolean isBranchEdge()