org.jikesrvm.compilers.opt.dfsolver
Class DF_Equation

java.lang.Object
  extended by org.jikesrvm.compilers.opt.dfsolver.DF_Equation
All Implemented Interfaces:
GraphElement, GraphNode

public class DF_Equation
extends Object
implements GraphNode

Represents a single Data Flow equation.


Field Summary
private  int index
          Field used for GraphNode interface.
protected  DF_LatticeCell[] operands
          The operands.
protected  DF_Operator operator
          The operator in the equation
private  int scratch
           
(package private)  int topologicalNumber
          The number of this equation when the system is sorted in topological order.
 
Constructor Summary
DF_Equation(DF_LatticeCell lhs, DF_Operator operator, DF_LatticeCell op1)
          Constructor for case of one operand on the right-hand side.
DF_Equation(DF_LatticeCell lhs, DF_Operator operator, DF_LatticeCell[] rhs)
          Constructor for case of more than three operands on the right-hand side.
DF_Equation(DF_LatticeCell lhs, DF_Operator operator, DF_LatticeCell op1, DF_LatticeCell op2)
          Constructor for case of two operands on the right-hand side.
DF_Equation(DF_LatticeCell lhs, DF_Operator operator, DF_LatticeCell op1, DF_LatticeCell op2, DF_LatticeCell op3)
          Constructor for case of three operands on the right-hand side.
 
Method Summary
(package private)  boolean evaluate()
          Evaluate this equation, setting a new value for the left-hand side.
 int getIndex()
          The index of this node in its graph.
(package private)  DF_LatticeCell getLHS()
          Return the left-hand side of this equation.
 DF_LatticeCell[] getOperands()
          Return the operands in this equation.
(package private)  DF_Operator getOperator()
          Return the operator for this equation
 int getScratch()
          read the scratch field of int type
(package private)  int getTopologicalNumber()
          Get the topological number for this equation
 boolean hasCell(DF_LatticeCell cell)
          Does this equation contain an appearance of a given cell?
 Enumeration<GraphNode> inNodes()
          Return an enumeration of the equations upon whose results this equation depends.
 Enumeration<GraphNode> outNodes()
          Return an enumeration of the equations which use the result of this equation.
 void setIndex(int i)
          Implementation of GraphNode interface.
 int setScratch(int o)
          set the scratch field of int type
(package private)  void setTopologicalNumber(int n)
          Get the topological number for this equation
 String toString()
          Return a string representation of this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

operator

protected final DF_Operator operator
The operator in the equation


operands

protected final DF_LatticeCell[] operands
The operands. Operand[0] is the left hand side.


topologicalNumber

int topologicalNumber
The number of this equation when the system is sorted in topological order.


index

private int index
Field used for GraphNode interface. TODO: is this needed?


scratch

private int scratch
Constructor Detail

DF_Equation

DF_Equation(DF_LatticeCell lhs,
            DF_Operator operator,
            DF_LatticeCell op1)
Constructor for case of one operand on the right-hand side.

Parameters:
lhs - the lattice cell set by this equation
operator - the equation operator
op1 - the first operand on the rhs

DF_Equation

DF_Equation(DF_LatticeCell lhs,
            DF_Operator operator,
            DF_LatticeCell op1,
            DF_LatticeCell op2)
Constructor for case of two operands on the right-hand side.

Parameters:
lhs - the lattice cell set by this equation
operator - the equation operator
op1 - the first operand on the rhs
op2 - the second operand on the rhs

DF_Equation

DF_Equation(DF_LatticeCell lhs,
            DF_Operator operator,
            DF_LatticeCell op1,
            DF_LatticeCell op2,
            DF_LatticeCell op3)
Constructor for case of three operands on the right-hand side.

Parameters:
lhs - the lattice cell set by this equation
operator - the equation operator
op1 - the first operand on the rhs
op2 - the second operand on the rhs
op3 - the third operand on the rhs

DF_Equation

DF_Equation(DF_LatticeCell lhs,
            DF_Operator operator,
            DF_LatticeCell[] rhs)
Constructor for case of more than three operands on the right-hand side.

Parameters:
lhs - the lattice cell set by this equation
operator - the equation operator
rhs - the operands of the right-hand side in order
Method Detail

evaluate

boolean evaluate()
Evaluate this equation, setting a new value for the left-hand side.

Returns:
true if the lhs value changed. false otherwise

getLHS

DF_LatticeCell getLHS()
Return the left-hand side of this equation.

Returns:
the lattice cell this equation computes

getOperands

public DF_LatticeCell[] getOperands()
Return the operands in this equation.

Returns:
the operands in this equation.

getOperator

DF_Operator getOperator()
Return the operator for this equation

Returns:
the operator for this equation

hasCell

public boolean hasCell(DF_LatticeCell cell)
Does this equation contain an appearance of a given cell?

Parameters:
cell - the cell in question
Returns:
true or false

toString

public String toString()
Return a string representation of this object

Overrides:
toString in class Object
Returns:
a string representation of this object

getTopologicalNumber

int getTopologicalNumber()
Get the topological number for this equation

Returns:
the topological number

setTopologicalNumber

void setTopologicalNumber(int n)
Get the topological number for this equation

Parameters:
n - the topological order

setIndex

public void setIndex(int i)
Implementation of GraphNode interface.

Specified by:
setIndex in interface GraphNode

getIndex

public int getIndex()
Description copied from interface: GraphNode
The index of this node in its graph. In general, this can e anarbitrary number, but after a call to Graph.compactNodeNumbering the nodes of a graph should be numbered 0 thru (# of nodes in graph - 1).

Specified by:
getIndex in interface GraphNode
Returns:
the index of this node in its graph.

outNodes

public Enumeration<GraphNode> outNodes()
Return an enumeration of the equations which use the result of this equation.

Specified by:
outNodes in interface GraphNode
Returns:
an enumeration of the equations which use the result of this equation.

inNodes

public Enumeration<GraphNode> inNodes()
Return an enumeration of the equations upon whose results this equation depends.

Specified by:
inNodes in interface GraphNode
Returns:
an enumeration of the equations upon whose results this equation depends

getScratch

public int getScratch()
Description copied from interface: GraphElement
read the scratch field of int type

Specified by:
getScratch in interface GraphElement
Returns:
the contents of the int scratch field

setScratch

public int setScratch(int o)
Description copied from interface: GraphElement
set the scratch field of int type

Specified by:
setScratch in interface GraphElement
Parameters:
o - the new contents of the int scratch field