SFE.Compiler
Class AssignmentStatement

java.lang.Object
  extended by SFE.Compiler.Statement
      extended by SFE.Compiler.AssignmentStatement
All Implemented Interfaces:
Multi2SingleBit

public class AssignmentStatement
extends Statement

A class for representing assignment statements that can be defined in the program.


Field Summary
static java.util.Vector inputFormat
           
 
Constructor Summary
AssignmentStatement(LvalExpression lhs, OperationExpression rhs)
          Constructs a new AssignmentStatement from a given lhs and rhs.
 
Method Summary
 void buildUsedStatementsHash()
          Adds this AssignmentStatement to the list of statements that are needed to compute the output pins of the output circuit, if this AssigmentStatement IS indeed needed.
 Statement duplicate()
          Returns a replica this statement.
 LvalExpression getLHS()
          Returns this AssignmentStatement's lhs.
 int getOutputLine()
          Returns an int that represents the line number of this assignmnet statement in the output circuit.
 OperationExpression getRHS()
          Returns this AssignmentStatement's rhs.
 boolean hasUnaryOperator()
          Returns true iff rhs if an UnaryOpExpression.
 BlockStatement multi2SingleBit(java.lang.Object obj)
          Transforms this multibit AssignmentStatement into singlebit Statements and returns a BlockStatement containing the result.
 void optimizePhaseI()
          Optimizes this AssignmentStatement (Phase I):
Peephole optimization: local simplifications of code, e.g.
 void optimizePhaseII(java.util.Vector newBody)
          Second phase of the optimization: Dead code elimination.
 void setOutputLine(int line)
          Sets the output line of this assignment statement.
 void toCircuit(java.io.PrintWriter circuit)
          Prints this AssignmentStatement into the circuit.
 java.lang.String toString()
          Returns a string representation of this AssignmentStatement.
 Statement uniqueVars()
          Unique vars transformations.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inputFormat

public static final java.util.Vector inputFormat
Constructor Detail

AssignmentStatement

public AssignmentStatement(LvalExpression lhs,
                           OperationExpression rhs)
Constructs a new AssignmentStatement from a given lhs and rhs.

Parameters:
lhs - An LvalExpression which is the LHS of the assignment.
rhs - An OperationExpression which is the RHS of the assignment expression.
Method Detail

multi2SingleBit

public BlockStatement multi2SingleBit(java.lang.Object obj)
Transforms this multibit AssignmentStatement into singlebit Statements and returns a BlockStatement containing the result.

Specified by:
multi2SingleBit in interface Multi2SingleBit
Parameters:
obj - not used (null).
Returns:
BlockStatement containing singlebit Statements of this AssignmentStatement.

toString

public java.lang.String toString()
Returns a string representation of this AssignmentStatement.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this AssignmentStatement.

getRHS

public OperationExpression getRHS()
Returns this AssignmentStatement's rhs.

Returns:
this AssignmentStatement's rhs.

getLHS

public LvalExpression getLHS()
Returns this AssignmentStatement's lhs.

Returns:
this AssignmentStatement's lhs.

toCircuit

public void toCircuit(java.io.PrintWriter circuit)
Prints this AssignmentStatement into the circuit.

Parameters:
circuit - the circuit output file.

getOutputLine

public int getOutputLine()
Returns an int that represents the line number of this assignmnet statement in the output circuit.

Returns:
an int that represents the line number of this assignmnet statement in the output circuit.

setOutputLine

public void setOutputLine(int line)
Sets the output line of this assignment statement.

Parameters:
line - the line number in the output.

optimizePhaseI

public void optimizePhaseI()
Optimizes this AssignmentStatement (Phase I):
Peephole optimization: local simplifications of code, e.g. (x and true --> x), (x or not x --> true), etc.
Duplicate code removal: a hash table of all values computed in the circuit is kept. If some value is computed twice, then one of the duplicates is removed and replaced with direct access to the other wire.
For more information see documation files.


optimizePhaseII

public void optimizePhaseII(java.util.Vector newBody)
Second phase of the optimization: Dead code elimination. This statement adds to the new function-body, only if it is relevant the computation of the output pins of the circuit ( acording to a list of the needed statements that was assembled in earlier stage ).

Parameters:
newBody - the new function-body.

buildUsedStatementsHash

public void buildUsedStatementsHash()
Adds this AssignmentStatement to the list of statements that are needed to compute the output pins of the output circuit, if this AssigmentStatement IS indeed needed. The list is stored in Optimizer data structure.


uniqueVars

public Statement uniqueVars()
Unique vars transformations.

Specified by:
uniqueVars in class Statement

hasUnaryOperator

public boolean hasUnaryOperator()
Returns true iff rhs if an UnaryOpExpression.

Overrides:
hasUnaryOperator in class Statement
Returns:
true iff rhs if an UnaryOpExpression.

duplicate

public Statement duplicate()
Returns a replica this statement.

Specified by:
duplicate in class Statement
Returns:
a replica this statement.