|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectic.dfa.DataFlowAnalysis<T>
public abstract class DataFlowAnalysis<T>
Abstract Dataflow analysis engine. This is a general class for solving dataflow instances. It is parameterized by the type T, which is the type of value contained in the lattice. The solve method is responsible for computing the solution for the CFG passed into the constructor. After calling solve, the in and out methods can be used to access the dataflow facts for each basic block.
To use the framework, you extend this class with a new class --- LiveVariableAnalysis, for example --- which defines the six abstract methods describing the lattice, transfer functions, meet operator, boundary value, and direction of the analysis.
This implementation assumes the the enter and exit blocks for the CFG do not contain instructions that are part of the code. It will not apply transfer functions to those blocks. You can insert a simple "NoOp" TAC Instruction into those blocks.
Note that for forward analysis, in[enter] is typically undefined, but I set it to Top for simplicity. Similarly, for backward analysis, out[exit] is set to Top.
Field Summary | |
---|---|
protected ControlFlowGraph |
cfg
The graph to analyze |
protected HashMap<BasicBlock,T> |
in
Map for the in values |
protected HashMap<BasicBlock,T> |
out
Map for the out values |
Constructor Summary | |
---|---|
DataFlowAnalysis(ControlFlowGraph cfg)
Create a new dataflow instance that will compute information about the given flow graph. |
Method Summary | |
---|---|
abstract T |
boundary()
Initial value for out[enter] or in[exit], depending on direction. |
abstract boolean |
equals(T t1,
T t2)
Return true if t1 and t2 are equivalent. |
T |
in(BasicBlock b)
Return in[b]. |
abstract boolean |
isForward()
Return true iff the analysis is a forward analysis. |
abstract T |
meet(T t1,
T t2)
Return the meet of t1 and t2 in the lattice. |
T |
out(BasicBlock b)
Return out[b]. |
void |
solve()
Solve a dataflow instance with the iterative algorithm. |
protected void |
solveBackward()
Solve a backward analysis. |
protected void |
solveForward()
Solve a forward analysis and set up in and out. |
abstract T |
top()
Top value in the lattice of T elements. |
String |
toString()
Print out the in/out values for each basic block. |
abstract T |
transfer(TInstr instr,
T t)
Return the result of applying the transfer function for instr to t. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ControlFlowGraph cfg
protected final HashMap<BasicBlock,T> in
protected final HashMap<BasicBlock,T> out
Constructor Detail |
---|
public DataFlowAnalysis(ControlFlowGraph cfg)
Method Detail |
---|
public T in(BasicBlock b)
public T out(BasicBlock b)
public void solve()
protected void solveForward()
protected void solveBackward()
public String toString()
toString
in class Object
public abstract boolean isForward()
public abstract T boundary()
public abstract T top()
public abstract T meet(T t1, T t2)
public abstract boolean equals(T t1, T t2)
public abstract T transfer(TInstr instr, T t)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |