harpoon.Analysis.SizeOpt
Class BitWidthAnalysis

java.lang.Object
  extended by harpoon.Analysis.SizeOpt.BitWidthAnalysis
All Implemented Interfaces:
ConstMap, ExactTypeMap, ExecMap, TypeMap

public class BitWidthAnalysis
extends Object
implements ExactTypeMap, ConstMap, ExecMap

BitWidthAnalysis implements Sparse Conditional Constant Propagation, with extensions to allow type and bitwidth analysis. It combines the intraprocedural SCC analysis with an interprocedural driver to infer the widths of object fields.

Only works with quads in SSI form.

Version:
$Id: BitWidthAnalysis.java,v 1.10 2004/02/08 03:20:22 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Nested Class Summary
 
Nested classes/interfaces inherited from interface harpoon.Analysis.Maps.ExactTypeMap
ExactTypeMap.ExactType
 
Nested classes/interfaces inherited from interface harpoon.Analysis.Maps.TypeMap
TypeMap.TypeNotKnownException
 
Constructor Summary
BitWidthAnalysis(Linker linker, HCodeFactory hcf, ClassHierarchy ch, Set roots, Set fieldRoots)
          Creates a BitWidthAnalysis.
BitWidthAnalysis(Linker linker, HCodeFactory hcf, ClassHierarchy ch, Set roots, String resourceName)
           
 
Method Summary
 Object constMap(HCodeElement hce, Temp t)
          Determine the constant value of Temp t.
 Object constMap(HField hf)
          Determine the constant value of HField hf.
 boolean execMap(HCodeEdge edge)
          Determine whether Edge e is executable.
 boolean execMap(HCodeElement quad)
          Determine whether Quad q is executable.
 boolean isConst(HCodeElement hce, Temp t)
          Determine whether Temp t has a constant value.
 boolean isConst(HField hf)
          Determine whether HField hf has a constant value.
 boolean isExactType(HCodeElement hce, Temp t)
          Determine whether the static type of Temp t defined at hce is exact (or whether the runtime type could be a subclass of the static type).
 boolean isPossiblyNull(HCodeElement hce, Temp t)
          Determine whether the given Temp can possibly be null.
 boolean isRead(HField hf)
          Determine whether the given HField is ever read.
 int minusWidthMap(HCodeElement hce, Temp t)
          Determine the negative bit width of Temp t.
 int minusWidthMap(HField hf)
          Determine the negative bit width of HField hf.
 int plusWidthMap(HCodeElement hce, Temp t)
          Determine the positive bit width of Temp t.
 int plusWidthMap(HField hf)
          Determine the positive bit width of HField hf.
 HClass typeMap(HCodeElement hce, Temp t)
          Determine the static type of Temp t in HMethod m.
 HClass typeMap(HField hf)
          Determine the static type of Temp t in HMethod m.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitWidthAnalysis

public BitWidthAnalysis(Linker linker,
                        HCodeFactory hcf,
                        ClassHierarchy ch,
                        Set roots,
                        String resourceName)

BitWidthAnalysis

public BitWidthAnalysis(Linker linker,
                        HCodeFactory hcf,
                        ClassHierarchy ch,
                        Set roots,
                        Set fieldRoots)
Creates a BitWidthAnalysis.

Method Detail

isRead

public boolean isRead(HField hf)
Determine whether the given HField is ever read.


execMap

public boolean execMap(HCodeElement quad)
Determine whether Quad q is executable.

Specified by:
execMap in interface ExecMap
Parameters:
quad - The HCodeElement to examine.
Returns:
true if it is possible to execute this HCodeElement; or false if it can be proved that this HCodeElement will never be executed.

execMap

public boolean execMap(HCodeEdge edge)
Determine whether Edge e is executable.

Specified by:
execMap in interface ExecMap
Parameters:
edge - An edge between two HCodeElements in some HCode.
Returns:
true if it is possible to traverse this edge during execution, or false if it can be proved that this edge will never be followed.

typeMap

public HClass typeMap(HCodeElement hce,
                      Temp t)
Determine the static type of Temp t in HMethod m.

Specified by:
typeMap in interface TypeMap
Parameters:
hce - The HCodeElement defining t.
t - The temporary to examine.
Returns:
the static type of t.

typeMap

public HClass typeMap(HField hf)
Determine the static type of Temp t in HMethod m.


isExactType

public boolean isExactType(HCodeElement hce,
                           Temp t)
Determine whether the static type of Temp t defined at hce is exact (or whether the runtime type could be a subclass of the static type).

Specified by:
isExactType in interface ExactTypeMap
Parameters:
hce - The HCodeElement defining t for this request.
t - The Temp to examine.
Returns:
true if t's type is exact, false otherwise.

isPossiblyNull

public boolean isPossiblyNull(HCodeElement hce,
                              Temp t)
Determine whether the given Temp can possibly be null.


isConst

public boolean isConst(HCodeElement hce,
                       Temp t)
Determine whether Temp t has a constant value.

Specified by:
isConst in interface ConstMap
Parameters:
hce - the definition point.
t - the Temp to be examined.
Returns:
true is the given definition point can be proven to give the specified Temp a constant value, false otherwise.

constMap

public Object constMap(HCodeElement hce,
                       Temp t)
Determine the constant value of Temp t.

Specified by:
constMap in interface ConstMap
Parameters:
hce - the definition point.
t - the temporary to be examined.
Returns:
an object corresponding to the constant value of this temporary defined at this point. Values of base types get wrapped in objects in the standard way.
Throws:
Error - if Temp t is not a constant.

isConst

public boolean isConst(HField hf)
Determine whether HField hf has a constant value.


constMap

public Object constMap(HField hf)
Determine the constant value of HField hf.

Throws:
Error - if HField hf is not a constant.

plusWidthMap

public int plusWidthMap(HCodeElement hce,
                        Temp t)
Determine the positive bit width of Temp t.


minusWidthMap

public int minusWidthMap(HCodeElement hce,
                         Temp t)
Determine the negative bit width of Temp t.


plusWidthMap

public int plusWidthMap(HField hf)
Determine the positive bit width of HField hf.


minusWidthMap

public int minusWidthMap(HField hf)
Determine the negative bit width of HField hf.