The BasicBlockBuildingStage translates a stream of instructions (provided by a previous stage implementing the IInstructionProvider interface) into BasicBlocks. These basic blocks provide some important properties for further optimizations in later compilation stages. The BasicBlockBuildingStage implements IBasicBlockProvider to provide following stages with the basic blocks.

BasicBlock properties

The BasicBlocks emitted by the BasicBlockBuildingStage hold code sequences that are linear, e.g there are no internal jumps and no jumps to the inside of a BasicBlock. The blocks are linked together by the NextBlock/PreviousBlock lists, which hold direct references to the blocks that jump to the start of the block itself and references to the blocks the block jumps to.

The last instruction in each block is always implements the IBranchInstruction interface. There are various kinds of instructions, which implement this interface. The ones you will most likely find at the end of a block are conditional branches, unconditional branches to another block, switch instructions, jumps to another method or instructions that throw an exception.

With the properties of basic blocks following compilation stages are safe to assume that the instructions inside a basic block will always be executed in sequence.

Last edited Nov 21, 2008 at 6:44 AM by tgiphil, version 1


No comments yet.