Package iota
Class NControlFlowGraph
java.lang.Object
iota.NControlFlowGraph
Representation of a control flow graph (cfg) for a method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of basic blocks forming this cfg.Constant pool of the class containing the method.Descriptor of the method.static int
HIR instruction identifier.Maps HIR instruction ids in this cfg to HIR instructions.Liveness intervals of this cfg.static int
LIR instruction identifier.Contains information about the method.Name of the method.int
Number of local variables (including parameters) in the method.Physical registers used in this cfg.static int
Virtual register identifier.Virtual and physical registers used in this cfg. -
Constructor Summary
ConstructorsConstructorDescriptionNControlFlowGraph
(CLConstantPool cp, CLMethodInfo m, String name, String desc) Constructs a ControlFlowGraph object for a method. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Replaces redundant phi functions of the form x = phi(y, x, x, ..., x) with y.void
Computes the liveness intervals for the registers (virtual and physical) used by this cfg.void
detectLoops
(NBasicBlock block, NBasicBlock pred) Recursively identifies loop header and loop tail blocks starting from the given block.void
hirToLir()
Converts the HIR instructions in this cfg to LIR instructions.void
Converts the LIR instructions in this cfg to Marvin instructions.void
Generate Marvin code for creating a stack frame upon method entry and destroying the frame upon exit.void
Removes basic blocks that cannot be reached from B0.void
Assigns new ids (0, 5, 10, and so on) to the LIR instructions in this cfg.void
Resolves the jump locations in the "calln" instructions.void
Resolve jumps within this method.void
Resolve Phi functions by inserting appropriate "copy" instructions at the end of the predecessor blocks.void
Converts tuples in each block to their high-level (HIR) representations.void
write
(PrintWriter out) Writes the Marvin instructions in this cfg to the give output stream.void
Writes the hir instructions in this cfg to standard output.void
Writes the lir instructions in this cfg to standard output.void
Writes the liveness intervals in this cfg to standard output.void
Writes the local and global liveness sets in this cfg to standard output.void
Writes the tuples in this cfg to standard output.
-
Field Details
-
cp
Constant pool of the class containing the method. -
m
Contains information about the method. -
name
Name of the method. -
desc
Descriptor of the method. -
basicBlocks
List of basic blocks forming this cfg. -
numLocals
public int numLocalsNumber of local variables (including parameters) in the method. -
hirId
public static int hirIdHIR instruction identifier. -
hirMap
Maps HIR instruction ids in this cfg to HIR instructions. -
lirId
public static int lirIdLIR instruction identifier. -
regId
public static int regIdVirtual register identifier. -
intervals
Liveness intervals of this cfg. -
registers
Virtual and physical registers used in this cfg. -
pRegisters
Physical registers used in this cfg.
-
-
Constructor Details
-
NControlFlowGraph
Constructs a ControlFlowGraph object for a method.- Parameters:
cp
- constant pool of the class containing the method.m
- contains information about the method.name
- method name.desc
- method descriptor.
-
-
Method Details
-
detectLoops
Recursively identifies loop header and loop tail blocks starting from the given block.- Parameters:
block
- a block.pred
- block's predecessor or null.
-
removeUnreachableBlocks
public void removeUnreachableBlocks()Removes basic blocks that cannot be reached from B0. -
tuplesToHir
public void tuplesToHir()Converts tuples in each block to their high-level (HIR) representations. -
hirToLir
public void hirToLir()Converts the HIR instructions in this cfg to LIR instructions. -
cleanupPhiFunctions
public void cleanupPhiFunctions()Replaces redundant phi functions of the form x = phi(y, x, x, ..., x) with y. -
resolvePhiFunctions
public void resolvePhiFunctions()Resolve Phi functions by inserting appropriate "copy" instructions at the end of the predecessor blocks. If the last instruction in the predecessor is a jump instruction, then the "copy" instructions are inserted right before the jump instruction. -
renumberLir
public void renumberLir()Assigns new ids (0, 5, 10, and so on) to the LIR instructions in this cfg. The gaps allow us to insert spill/restore instructions if needed during register allocation. -
lirToMarvin
public void lirToMarvin()Converts the LIR instructions in this cfg to Marvin instructions. -
prepareMethodEntryAndExit
public void prepareMethodEntryAndExit()Generate Marvin code for creating a stack frame upon method entry and destroying the frame upon exit. -
resolveJumps
public void resolveJumps()Resolve jumps within this method. This does not include method calls, which are handled by the resolveCalls() method. -
resolveCalls
public void resolveCalls()Resolves the jump locations in the "calln" instructions. -
computeLivenessIntervals
public void computeLivenessIntervals()Computes the liveness intervals for the registers (virtual and physical) used by this cfg. -
writeTuplesToStdOut
Writes the tuples in this cfg to standard output.- Parameters:
p
- for pretty printing with indentation.
-
writeHirToStdOut
Writes the hir instructions in this cfg to standard output.- Parameters:
p
- for pretty printing with indentation.
-
writeLirToStdOut
Writes the lir instructions in this cfg to standard output.- Parameters:
p
- for pretty printing with indentation.
-
writeLivenessSetsToStdOut
Writes the local and global liveness sets in this cfg to standard output.- Parameters:
p
- for pretty printing with indentation.
-
writeLivenessIntervalsToStdOut
Writes the liveness intervals in this cfg to standard output.- Parameters:
p
- for pretty printing with indentation.
-
write
Writes the Marvin instructions in this cfg to the give output stream.- Parameters:
out
- output stream.
-