FlowGraphNormalizer

public final class FlowGraphNormalizer

Detects the loop nesting and dfst ordering between the Blocks of a newly built FlowGraph. Also detects dead (not connected) blocks.

Constructors

FlowGraphNormalizer

protected FlowGraphNormalizer(EntryBlock entryBlock, TapList<Block> allBlocks, ExitBlock exitBlock)

Creates a FlowGraphNormalizer for the FlowGraph starting at “entryBlock”, ending at “exitBlock” and knowing that “allBlocks” is the list of all blocks in this FlowGraph.

Methods

condenseFG

protected void condenseFG(boolean finalGraph)

Sweeps through the FlowGraph, using the allBlocks list, looking for mergings of BasicBlock’s, and of FGArrow’s, and removing empty Block’s and empty IF’s and Loop’s .

Parameters
  • finalGraph – true to get a more aggressive condensationin the end.

findOptimalLoops

protected TapList<Block> findOptimalLoops()

Explores the nesting of loops. Makes a reasonable decision about which Block’s are in which loops, and which Block’s should become the HeaderBlock’s of these loops. Also computes the DFST order of the FlowGraph for this particular decision of loops. When this function returns, all blocks have been turned into BasicBlock’s or HeaderBlock’s according to the above decision, LoopBlock’s are created and now contain in their “inside” field the DFST list of their immediately enclosed Block’s. The output of this function is the DFST list of the top level Block’s.

getDeadBlocks

protected TapList<Block> getDeadBlocks()

Must be run just after findOptimalLoops.

Returns

the list of Block’s detected as dead, because they are unreachable, i.e. not marked “VISITED” at the end of “findOptimalLoops”.

makeSurePrivateDeclarationsBlock

protected void makeSurePrivateDeclarationsBlock(Unit unit)

Make sure block 0 can serve as host for additional local declarations. If not (loop header, many entries…) then insert another empty block 0 that will do the job.

Parameters
  • unit – current unit.

sortFlowArrows

protected void sortFlowArrows()

For each Block, sorts the flow FGarrows that exit from this block. The resulting conventional order will give a better block numbering during the DFST.