harpoon.Analysis.DataFlow
Class LiveTemps

java.lang.Object
  extended by harpoon.Analysis.BasicBlockInterfVisitor
      extended by harpoon.Analysis.DataFlow.DataFlowBasicBlockVisitor
          extended by harpoon.Analysis.DataFlow.BackwardDataFlowBasicBlockVisitor
              extended by harpoon.Analysis.DataFlow.LiveVars.BBVisitor
                  extended by harpoon.Analysis.DataFlow.LiveTemps
Direct Known Subclasses:
CachingLiveTemps, SpaceHeavyLiveTemps

public class LiveTemps
extends LiveVars.BBVisitor

LiveTemps is an extension of LiveVars for performing liveness analysis on Temps.

Version:
$Id: LiveTemps.java,v 1.7 2004/02/08 03:19:21 cananian Exp $
Author:
Felix S. Klock II <pnkfelix@mit.edu>

Nested Class Summary
 
Nested classes/interfaces inherited from class harpoon.Analysis.DataFlow.LiveVars.BBVisitor
LiveVars.BBVisitor.LiveVarInfo
 
Field Summary
protected  SetFactory mySetFactory
           
protected  UseDefer ud
           
 
Fields inherited from class harpoon.Analysis.DataFlow.LiveVars.BBVisitor
bbFact
 
Constructor Summary
LiveTemps(BasicBlock.Factory bbFact, Set liveOnProcExit)
           
LiveTemps(BasicBlock.Factory bbFact, Set liveOnProcExit, SetFactory tempSetFact, UseDefer ud)
          Constructor for LiveVars that allows the user to pass in their own SetFactory for constructing sets of the Temps in the analysis.
LiveTemps(BasicBlock.Factory bbFact, Set liveOnProcExit, UseDefer ud)
          Constructs a new LiveTemps for basicblocks.
 
Method Summary
 String dumpElems()
          Returns a String containing a human-readable version of the analysis results.
protected  Set findUniverse(Set blockSet)
          Constructs a Set of all of the Temps in blocks.
 Set getLiveAfter(HCodeElement hce)
          Returns the Set of Temps that are live on exit from hce.
 Set getLiveBefore(HCodeElement hce)
          Returns the Set of Temps that are live on on entry to hce.
static LiveTemps make(HCode code, Set liveOnExit)
          Produces a default live variable analysis object and solves it.
static LiveTemps make(HCode code, UseDefer ud, Set liveOnExit)
          Produces a default live variable analysis object and solves it.
protected  LiveVars.BBVisitor.LiveVarInfo makeUseDef(BasicBlock bb, SetFactory sf)
          Initializes the USE/DEF information for 'bb' and stores in in the returned LiveVarInfo.
 void solve()
          Finds the fixed-point solution for this LiveTemps.
 
Methods inherited from class harpoon.Analysis.DataFlow.LiveVars.BBVisitor
dump, dump, getLiveOnEntry, getLiveOnExit, initializeBBtoLVI, merge, visit
 
Methods inherited from class harpoon.Analysis.DataFlow.BackwardDataFlowBasicBlockVisitor
addSuccessors
 
Methods inherited from class harpoon.Analysis.DataFlow.DataFlowBasicBlockVisitor
db, visit
 
Methods inherited from class harpoon.Analysis.BasicBlockInterfVisitor
visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mySetFactory

protected SetFactory mySetFactory

ud

protected UseDefer ud
Constructor Detail

LiveTemps

public LiveTemps(BasicBlock.Factory bbFact,
                 Set liveOnProcExit,
                 UseDefer ud)
Constructs a new LiveTemps for basicblocks.
requires:
  1. basicblocks is a Iterator of BasicBlocks,
  2. ud contains use/def information for all of all of the instructions in basicblocks.
  3. No element of basicblocks links to a BasicBlock not contained within basicblocks
  4. No BasicBlock is repeatedly iterated by basicblocks

modifies: basicblocks
effects: constructs a new BasicBlockVisitor and initializes its internal datasets for analysis of the BasicBlocks in basicblocks, iterating over all of basicblocks in the process.

Parameters:
basicblocks - Iterator of BasicBlocks to be analyzed.
liveOnProcExit - Set of Temps that are live on exit from the method (for example, r0 for assembly code).

LiveTemps

public LiveTemps(BasicBlock.Factory bbFact,
                 Set liveOnProcExit)

LiveTemps

public LiveTemps(BasicBlock.Factory bbFact,
                 Set liveOnProcExit,
                 SetFactory tempSetFact,
                 UseDefer ud)
Constructor for LiveVars that allows the user to pass in their own SetFactory for constructing sets of the Temps in the analysis.
requires: All Temps in basicBlocks are members of the universe for tempSetFact.
Doc TODO: Add all of the above documentation from the standard ctor.

Method Detail

make

public static LiveTemps make(HCode code,
                             UseDefer ud,
                             Set liveOnExit)
Produces a default live variable analysis object and solves it. Uses ud to define Temp references in elements of code. elements in code must implement CFGraphable, and liveOnExit must be a Set of Temps (mapped to by ud) that are live on exit from code.


solve

public void solve()
Finds the fixed-point solution for this LiveTemps. (Don't know why its taken me so long to realize that this belonged in here... procedural abstraction, awwwww yeah).


make

public static LiveTemps make(HCode code,
                             Set liveOnExit)
Produces a default live variable analysis object and solves it. elements in code must implement UseDefable, CFGraphable, etc, and liveOnExit must be a Set of Temps that are live on exit from code.


getLiveBefore

public Set getLiveBefore(HCodeElement hce)
Returns the Set of Temps that are live on on entry to hce.
requires: A DataFlow Equation Solver has been run to completion on the graph of BasicBlocks containing some block that contains hce, with this as the DataFlowBasicBlockVisitor.
effects: Returns a Set of Temps that are live on entry to hce.


getLiveAfter

public Set getLiveAfter(HCodeElement hce)
Returns the Set of Temps that are live on exit from hce.
requires: A DataFlow Equation Solver has been run to completion on the graph of BasicBlocks containing some block that contains hce, with this as the DataFlowBasicBlockVisitor.
effects: Returns a Set of Temps that are live on exit from hce.


findUniverse

protected Set findUniverse(Set blockSet)
Constructs a Set of all of the Temps in blocks.
requires:
  1. blocks is an Iterator of BasicBlocks.

modifies: blocks
effects: Iterates through all of the instructions contained in each element of blocks, adding each instruction's useC() and defC() to a universe of values, returning the universe after all of the instructions have been visited.

Specified by:
findUniverse in class LiveVars.BBVisitor

makeUseDef

protected LiveVars.BBVisitor.LiveVarInfo makeUseDef(BasicBlock bb,
                                                    SetFactory sf)
Initializes the USE/DEF information for 'bb' and stores in in the returned LiveVarInfo.

Specified by:
makeUseDef in class LiveVars.BBVisitor

dumpElems

public String dumpElems()
Returns a String containing a human-readable version of the analysis results.