harpoon.Analysis.Tree
Class AlgebraicSimplification

java.lang.Object
  extended by harpoon.Analysis.Tree.Simplification
      extended by harpoon.Analysis.Tree.AlgebraicSimplification

public abstract class AlgebraicSimplification
extends Simplification

AlgebraicSimplification performs algebraic simplification on canonical trees. Warning: this performs modifications on the tree form in place.

Version:
$Id: AlgebraicSimplification.java,v 1.7 2004/02/08 01:54:28 cananian Exp $
Author:
Duncan Bryce <duncan@lcs.mit.edu>

Nested Class Summary
 
Nested classes/interfaces inherited from class harpoon.Analysis.Tree.Simplification
Simplification.Rule
 
Field Summary
static List DEFAULT_RULES
          Default alegraic simplification rules.
 
Fields inherited from class harpoon.Analysis.Tree.Simplification
_ADD, _ALIGN, _AND, _BINOP, _CALL, _CJUMP, _CMPEQ, _CMPGE, _CMPGT, _CMPLE, _CMPLT, _CMPNE, _CONST, _CONST0, _CONST1, _CONSTm1, _CONSTNULL, _DATUM, _DIV, _ESEQ, _EXPR, _JUMP, _LABEL, _MEM, _METHOD, _MOVE, _MUL, _NAME, _NATIVECALL, _OR, _REM, _RETURN, _SEGMENT, _SEQ, _SHL, _SHR, _TEMP, _THROW, _UNOP, _USHR, _XOR
 
Method Summary
static HCodeFactory codeFactory(HCodeFactory parent)
          Code factory for applying the default set of simplifications to the given tree form.
static Exp div2mul(Exp n, int dVal)
          Converts an arbitrary division by a constant into a series of multiplications, shifts, and bitwise operations.
static Exp mul2shift(Exp n, CONST m)
          Converts an arbitrary multiplication by a positive constant into a series of shifts, additions, and multiplies.
 
Methods inherited from class harpoon.Analysis.Tree.Simplification
_KIND, _OP, codeFactory, contains, simplify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RULES

public static final List DEFAULT_RULES
Default alegraic simplification rules.

Method Detail

codeFactory

public static HCodeFactory codeFactory(HCodeFactory parent)
Code factory for applying the default set of simplifications to the given tree form. Clones the tree before simplifying it in-place.


div2mul

public static Exp div2mul(Exp n,
                          int dVal)
Converts an arbitrary division by a constant into a series of multiplications, shifts, and bitwise operations. Based on the paper Division by Invariant Integers using Multiplication, by Granlund and Montgomery. This method is used internally by the AlgebraicSimplification class. However, this method is public because it could conceivably be of use in other transformations. Requires: d is a 32-bit integer constant

Returns:
an Exp which contains no divisions, yet represents the same value as (n/d). not guaranteed to be in canonical form.

mul2shift

public static Exp mul2shift(Exp n,
                            CONST m)
Converts an arbitrary multiplication by a positive constant into a series of shifts, additions, and multiplies. Based on the m4 macros found in the text Sparc Architecture, Assembly Language, Programming, & C, by Richard P. Paul. This method is used internally by the AlgebraicSimplification class. However, this method is public because it could conceivably be of use in other transformations. Requires: m is a positive 32-bit or 64-bit integer constant

Returns:
an Exp which contains no multiplications, yet represents the same value as (n*m).