scale.score.trans
Class Optimization

java.lang.Object
  extended by scale.score.trans.Optimization
Direct Known Subclasses:
AASR, BasicBlockOps, CP, DeadVarElimination, GlobalVarReplacement, LICM, LoopTrans, Noopt, PRE, ScalarReplacement, SCC, SFIR, TreeHeight, URJ, UselessCopy, ValNum

public abstract class Optimization
extends java.lang.Object

This class is the base class for all optimizations performed on the CFG.

$Id: Optimization.java,v 1.27 2007-10-04 19:58:36 burrill Exp $

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

All optimizations applied to the CFG must be defined in this package and must be derived from this class.


Field Summary
protected  boolean dChanged
          True if CFG nodes added or deleted by the optimization.
static boolean fpReorder
          True if floating point operations may be reordered.
static boolean hasDummyAliases
          True if there may be aliases between address arguments to subroutines.
static int IN_SSA
          The optimization requires that the CFG be in SSA form.
static int minimumExecutionCost
          Do not move expressions whose execution cost estimate is less than minimumExecutionCost.
static int NA_SSA
          The optimization does not require SSA form or non-SSA form.
static int NO_SSA
          The optimization requires that the CFG not be in SSA form.
protected  boolean rChanged
          True if the variable references are no longer valid.
protected  Scribble scribble
          The CFG.
static boolean signedIntsWrapOnOverflow
          Should signed integers wrap upon overflow?
protected  boolean trace
          True if the optimization should be traced.
protected  UniqueName un
          The name generator to use for any variables created.
static boolean unsafe
          True if unsafe optimuzations are allowd.
static boolean unsignedIntsWrapOnOverflow
          Should unsigned integers wrap upon overflow?
static int VALID_SSA
          The optimization requires that the CFG be in SSA form.
 
Constructor Summary
Optimization(Scribble scribble, java.lang.String tempPrefix)
           
 
Method Summary
 boolean assertTrace(boolean trace, java.lang.String msg, boolean val)
          Print out a trace message to System.out.
 boolean assertTrace(boolean trace, java.lang.String msg, double val)
          Print out a trace message to System.out.
 boolean assertTrace(boolean trace, java.lang.String msg, long val)
          Print out a trace message to System.out.
 boolean assertTrace(boolean trace, java.lang.String msg, java.lang.Object o)
          Print out a trace message to System.out.
 boolean assertTrace(boolean trace, java.lang.String msg, Vector<? extends java.lang.Object> v)
          Print out a trace message to System.out.
protected  VariableDecl genTemp(Type t)
          Create a new temporary variable for use by the optimized code.
static int insertStores(java.util.AbstractCollection<Chord> nodes, Expr lhs, Expr rhs)
          Insert new copy CFG nodes between CFG nodes in the specified set and CFG nodes that are not in the set but have an edge to them from a node in the set.
abstract  void perform()
          Perform the optimization.
 int requiresSSA()
          Return whether this optimization requires that the CFG be in SSA form.
protected  boolean setTrace(boolean classTrace)
          Sets the trace flag.
static void sort(java.lang.Object[] v)
          Place array elements in ascending lexigraphical order by CFG node execution order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_SSA

public static final int NO_SSA
The optimization requires that the CFG not be in SSA form.

See Also:
Constant Field Values

IN_SSA

public static final int IN_SSA
The optimization requires that the CFG be in SSA form.

See Also:
Constant Field Values

VALID_SSA

public static final int VALID_SSA
The optimization requires that the CFG be in SSA form.

See Also:
Constant Field Values

NA_SSA

public static final int NA_SSA
The optimization does not require SSA form or non-SSA form.

See Also:
Constant Field Values

minimumExecutionCost

public static int minimumExecutionCost
Do not move expressions whose execution cost estimate is less than minimumExecutionCost.


unsafe

public static boolean unsafe
True if unsafe optimuzations are allowd. An unsafe optimization is one that will cause the generated program to be incorrect if there is aliasing.


fpReorder

public static boolean fpReorder
True if floating point operations may be reordered. Reordering floating point operations may result in the generation of slightly different floating point results by the compiled program.


signedIntsWrapOnOverflow

public static boolean signedIntsWrapOnOverflow
Should signed integers wrap upon overflow?


unsignedIntsWrapOnOverflow

public static boolean unsignedIntsWrapOnOverflow
Should unsigned integers wrap upon overflow?


hasDummyAliases

public static boolean hasDummyAliases
True if there may be aliases between address arguments to subroutines.


scribble

protected Scribble scribble
The CFG.


un

protected UniqueName un
The name generator to use for any variables created.


dChanged

protected boolean dChanged
True if CFG nodes added or deleted by the optimization.


rChanged

protected boolean rChanged
True if the variable references are no longer valid.


trace

protected boolean trace
True if the optimization should be traced.

Constructor Detail

Optimization

public Optimization(Scribble scribble,
                    java.lang.String tempPrefix)
Parameters:
scribble - is the CFG to be transformed
tempPrefix - is used to generate temporary variable names
Method Detail

setTrace

protected boolean setTrace(boolean classTrace)
Sets the trace flag.


genTemp

protected VariableDecl genTemp(Type t)
Create a new temporary variable for use by the optimized code. The variable definition is added to the set of variables for this CFG.


perform

public abstract void perform()
Perform the optimization. Each optimization must specify after it completes. The Scribble class provides methods that may be used to sepcify this information.


requiresSSA

public int requiresSSA()
Return whether this optimization requires that the CFG be in SSA form. It returns either
NO_SSA
the CFG must not be in SSA form,
IN_SSA
the CFG must be in SSA form,
VALID_SSA
the CFG must be in valid SSA form, or
NA_SSA
the CFG does not need to be in valid SSA form.


sort

public static void sort(java.lang.Object[] v)
Place array elements in ascending lexigraphical order by CFG node execution order.

Parameters:
v - is an array of CFG nodes or expressions
See Also:
Chord.pushChordWhenReady(scale.common.Stack, int)

insertStores

public static int insertStores(java.util.AbstractCollection<Chord> nodes,
                               Expr lhs,
                               Expr rhs)
Insert new copy CFG nodes between CFG nodes in the specified set and CFG nodes that are not in the set but have an edge to them from a node in the set.

Parameters:
nodes - is the set of CFG nodes
lhs - is the left hand side for new CFG nodes
rhs - is the right hand side for new CFG nodes
Returns:
the number of new CFG nodes added

assertTrace

public final boolean assertTrace(boolean trace,
                                 java.lang.String msg,
                                 java.lang.Object o)
Print out a trace message to System.out. This method is meant to be used in an assert statement.

Parameters:
msg - is the message
o - is an object to append to the message
Returns:
true

assertTrace

public final boolean assertTrace(boolean trace,
                                 java.lang.String msg,
                                 long val)
Print out a trace message to System.out. This method is meant to be used in an assert statement.

Parameters:
msg - is the message
val - is an integer to append to the message
Returns:
true

assertTrace

public final boolean assertTrace(boolean trace,
                                 java.lang.String msg,
                                 double val)
Print out a trace message to System.out. This method is meant to be used in an assert statement.

Parameters:
msg - is the message
val - is an integer to append to the message
Returns:
true

assertTrace

public final boolean assertTrace(boolean trace,
                                 java.lang.String msg,
                                 boolean val)
Print out a trace message to System.out. This method is meant to be used in an assert statement.

Parameters:
msg - is the message
val - is an integer to append to the message
Returns:
true

assertTrace

public final boolean assertTrace(boolean trace,
                                 java.lang.String msg,
                                 Vector<? extends java.lang.Object> v)
Print out a trace message to System.out. This method is meant to be used in an assert statement.

Parameters:
msg - is the message
v - is a vector of things to display
Returns:
true