Package jminusminus
Class NControlFlowGraph
java.lang.Object
jminusminus.NControlFlowGraph
Representation of a control flow graph (cfg) for a method.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionList of blocks forming the cfg for the method.static intBlock identifier.SPIM code for string literals added to the data segment.Descriptor of the method this cfg corresponds to.static intHIR instruction identifier.Maps HIR instruction ids in this cfg to HIR instructions.Intervals allocated by the register allocation algorithm.Used to construct jump labels in spim output.static intHIR instruction identifier.static intLoop identifier.intThe total number of intervals.Name of the method this cfg corresponds to.intStack offset counter..Physical registers allocated for this cfg by the HIR to LIR conversion algorithm.static intVirtual register identifier.Registers allocated for this cfg by the HIR to LIR conversion algorithm.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a NControlFlowGraph object for a method..
- 
Method SummaryModifier and TypeMethodDescriptionvoidReplaces references to virtual registers in LIR instructions with references to physical registers.blockAt(int id) Returns the basic block at a particular instruction id, or null.voidcomputeDominators(NBasicBlock block, NBasicBlock pred) Computes the dominator of each block in this cfg recursively given the starting block and its predecessor.voiddetectLoops(NBasicBlock block, NBasicBlock pred) Implements loop detection algorithm to figure out if the specified block is a loop head or a loop tail.voidEliminates redundant phi functions of the form x = (y, x, x, ..., x) with y.voidhirToLir()Converts the hir instructions in this cfg to lir instructions.voidoptimize()Carries out optimizations on the high-level instructions.voidComputes optimal ordering of the basic blocks in this cfg.voidRemoves blocks that cannot be reached from the begin block (B0).voidAssigns new ids to the LIR instructions in this cfg.voidResolves 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.voidConverts tuples in each block to their high-level (HIR) representations.voidWrites the hir instructions in this cfg to standard output.voidWrites the intervals in this cfg to standard output.voidWrites the lir instructions in this cfg to standard output.voidWrites the tuples in this cfg to standard output.
- 
Field Details- 
blockIdpublic static int blockIdBlock identifier.
- 
hirIdpublic static int hirIdHIR instruction identifier.
- 
lirIdpublic static int lirIdHIR instruction identifier.
- 
regIdpublic static int regIdVirtual register identifier.
- 
offsetpublic int offsetStack offset counter..
- 
loopIndexpublic static int loopIndexLoop identifier.
- 
nameName of the method this cfg corresponds to.
- 
descDescriptor of the method this cfg corresponds to.
- 
basicBlocksList of blocks forming the cfg for the method.
- 
hirMapMaps HIR instruction ids in this cfg to HIR instructions.
- 
registersRegisters allocated for this cfg by the HIR to LIR conversion algorithm.
- 
maxIntervalspublic int maxIntervalsThe total number of intervals. This is used to name split children and grows as more intervals are created by spills.
- 
pRegistersPhysical registers allocated for this cfg by the HIR to LIR conversion algorithm.
- 
intervalsIntervals allocated by the register allocation algorithm.
- 
labelPrefixUsed to construct jump labels in spim output.
- 
dataSPIM code for string literals added to the data segment.
 
- 
- 
Constructor Details- 
NControlFlowGraphConstructs a NControlFlowGraph object for a method..- Parameters:
- cp- constant pool for the class containing the method.
- m- contains information about the method.
 
 
- 
- 
Method Details- 
detectLoopsImplements loop detection algorithm to figure out if the specified block is a loop head or a loop tail. Also calculates the number of backward branches to the block.- Parameters:
- block- a block.
- pred- block's predecessor or null.
 
- 
removeUnreachableBlockspublic void removeUnreachableBlocks()Removes blocks that cannot be reached from the begin block (B0). Also removes these blocks from the predecessor lists.
- 
computeDominatorsComputes the dominator of each block in this cfg recursively given the starting block and its predecessor.- Parameters:
- block- starting block.
- pred- block's predecessor.
 
- 
tuplesToHirpublic void tuplesToHir()Converts tuples in each block to their high-level (HIR) representations.
- 
optimizepublic void optimize()Carries out optimizations on the high-level instructions.
- 
eliminateRedundantPhiFunctionspublic void eliminateRedundantPhiFunctions()Eliminates redundant phi functions of the form x = (y, x, x, ..., x) with y.
- 
hirToLirpublic void hirToLir()Converts the hir instructions in this cfg to lir instructions.
- 
resolvePhiFunctionspublic void resolvePhiFunctions()Resolves 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.
- 
orderBlockspublic void orderBlocks()Computes optimal ordering of the basic blocks in this cfg.
- 
blockAtReturns the basic block at a particular instruction id, or null.- Parameters:
- id- the (LIR) instruction id.
- Returns:
- the basic block at a particular instruction id, or null.
 
- 
renumberLirInstructionspublic void renumberLirInstructions()Assigns new ids to the LIR instructions in this cfg.
- 
allocatePhysicalRegisterspublic void allocatePhysicalRegisters()Replaces references to virtual registers in LIR instructions with references to physical registers.
- 
writeTuplesToStdOutWrites the tuples in this cfg to standard output.- Parameters:
- p- for pretty printing with indentation.
 
- 
writeHirToStdOutWrites the hir instructions in this cfg to standard output.- Parameters:
- p- for pretty printing with indentation.
 
- 
writeLirToStdOutWrites the lir instructions in this cfg to standard output.- Parameters:
- p- for pretty printing with indentation.
 
- 
writeIntervalsToStdOutWrites the intervals in this cfg to standard output.- Parameters:
- p- for pretty printing with indentation.
 
 
-