class NControlFlowGraph extends Object
Modifier and Type | Field and Description |
---|---|
ArrayList<NBasicBlock> |
basicBlocks
List of blocks forming the cfg for the method.
|
static int |
blockId
block identifier.
|
ArrayList<String> |
data
SPIM code for string literals added to the data segment.
|
String |
desc
Descriptor of the method this cfg corresponds to.
|
static int |
hirId
HIR instruction identifier.
|
TreeMap<Integer,NHIRInstruction> |
hirMap
Maps HIR instruction ids in this cfg to HIR instructions.
|
ArrayList<NInterval> |
intervals
Intervals allocated by the register allocation algorithm.
|
String |
labelPrefix
Used to construct jump labels in spim output.
|
static int |
lirId
HIR instruction identifier.
|
static int |
loopIndex
Loop identifier.
|
int |
maxIntervals
The total number of intervals.
|
String |
name
Name of the method this cfg corresponds to.
|
int |
offset
Stack offset counter..
|
ArrayList<NPhysicalRegister> |
pRegisters
Physical registers allocated for this cfg by the HIR to LIR conversion
algorithm.
|
static int |
regId
Virtual register identifier.
|
ArrayList<NRegister> |
registers
Registers allocated for this cfg by the HIR to LIR conversion algorithm.
|
Constructor and Description |
---|
NControlFlowGraph(CLConstantPool cp,
CLMethodInfo m)
Construct an NControlFlowGraph object for a method given the constant
pool for the class containing the method and the object containing
information about the method.
|
Modifier and Type | Method and Description |
---|---|
void |
allocatePhysicalRegisters()
Replace references to virtual registers in LIR instructions with
references to physical registers.
|
NBasicBlock |
blockAt(int id)
The basic block at a particular instruction id.
|
void |
computeDominators(NBasicBlock block,
NBasicBlock pred)
Compute the dominator of each block in this cfg recursively given the
starting block and its predecessor.
|
void |
detectLoops(NBasicBlock block,
NBasicBlock pred)
Implements loop detection algorithm to figure out if the specified block
is a loop head or a loop tail.
|
void |
eliminateRedundantPhiFunctions()
Eliminate redundant phi functions of the form x = (y, x, x, ..., x) with
y.
|
void |
hirToLir()
Convert the hir instructions in this cfg to lir instructions.
|
void |
optimize()
Carry out optimizations on the high-level instructions.
|
void |
orderBlocks()
Compute optimal ordering of the basic blocks in this cfg.
|
void |
removeUnreachableBlocks()
Remove blocks that cannot be reached from the begin block (B0).
|
void |
renumberLirInstructions()
Assign new ids to the LIR instructions in this cfg.
|
void |
resolvePhiFunctions()
Resolve the phi functions in this cfg, i.e., for each x = phi(x1, x2,
..., xn) generate an (LIR) move xi, x instruction at the end of the
predecessor i of thte block defining the phi function; if the instruction
there is a branch, add the instruction prior to the branch.
|
void |
tuplesToHir()
Convert tuples in each block to their high-level (HIR) representations.
|
void |
writeHirToStdOut(PrettyPrinter p)
Write the hir instructions in this cfg to STDOUT.
|
void |
writeIntervalsToStdOut(PrettyPrinter p)
Write the intervals in this cfg to STDOUT.
|
void |
writeLirToStdOut(PrettyPrinter p)
Write the lir instructions in this cfg to STDOUT.
|
void |
writeTuplesToStdOut(PrettyPrinter p)
Write the tuples in this cfg to STDOUT.
|
public static int blockId
public static int hirId
public static int lirId
public static int regId
public int offset
public static int loopIndex
public String name
public String desc
public ArrayList<NBasicBlock> basicBlocks
public TreeMap<Integer,NHIRInstruction> hirMap
public ArrayList<NRegister> registers
public int maxIntervals
public ArrayList<NPhysicalRegister> pRegisters
public ArrayList<NInterval> intervals
public String labelPrefix
public NControlFlowGraph(CLConstantPool cp, CLMethodInfo m)
cp
- constant pool for the class containing the method.m
- contains information about the method.public void detectLoops(NBasicBlock block, NBasicBlock pred)
block
- a block.pred
- block's predecessor or null.public void removeUnreachableBlocks()
public void computeDominators(NBasicBlock block, NBasicBlock pred)
block
- starting block.pred
- block's predecessor.public void tuplesToHir()
public void optimize()
public void eliminateRedundantPhiFunctions()
public void hirToLir()
public void resolvePhiFunctions()
public void orderBlocks()
public NBasicBlock blockAt(int id)
id
- the (LIR) instruction id.public void renumberLirInstructions()
public void allocatePhysicalRegisters()
public void writeTuplesToStdOut(PrettyPrinter p)
p
- for pretty printing with indentation.public void writeHirToStdOut(PrettyPrinter p)
p
- for pretty printing with indentation.public void writeLirToStdOut(PrettyPrinter p)
p
- for pretty printing with indentation.public void writeIntervalsToStdOut(PrettyPrinter p)
p
- for pretty printing with indentation.