L2Basic Block
This is a traditional basic block, consisting of a sequence of L2Instructions. It has no incoming jumps except to the start, and has no outgoing jumps or branches except from the last instruction.
Author
Mark van Gulik
Parameters
A descriptive name for the block.
Whether this block is the head of a loop. Default is false.
A mechanism to visually group blocks in the L2ControlFlowGraphVisualizer, indicating the purpose of that group.
Constructors
Properties
Whether this block must be tracked until final code generation. Set for blocks that must not be removed. Such a block may be referenced for tracking entry points, and must therefore exist through final code generation.
Whether this block is the head of a loop. Default is false.
The block's optional L2ControlFlowGraph.Zone, a mechanism to visually group blocks in the L2ControlFlowGraphVisualizer.
Functions
Append an instruction to this basic block, notifying the operands that the instruction was just added. Adding a phi instruction automatically places it at the start.
Add a predecessor, due to an earlier basic block adding an instruction that reaches this basic block. Also allow backward edges to attach to a loop head after code generation has already taken place in the target.
Add a successor edge.
Determine whether code added after the last instruction of this block would be reachable. Take into account whether the block itself seems to be reachable.
Answer this block's last L2Instruction. This instruction must be a branching instruction of some sort, having zero or more target edges, but not falling through to the next instruction (which doesn't exist).
Add this block's instructions to the given instruction list. Also do a special peephole optimization by removing any preceding L2_JUMP if its target is this block, unless this block is a loop head.
Answer the zero-based index of the first index beyond any L2_ENTER_L2_CHUNK or L2_PHI_PSEUDO_OPERATIONs. It might be just past the last valid index (i.e., equal to the size).
Insert an instruction in this basic block at the specified instruction index, notifying the operands that the instruction was just added.
Answer this block's List of L2Instruction. They consist of a sequence of non-branching instructions, ending in an instruction that branches to zero or more targets via its L2PcOperands.
Prevent this block from being removed, so that its position can be identified in the final generated code.
Answer a read-only List of predecessor edges of this block.
The final instruction of the block altered control flow, it was removed and later re-added to the instructions list directly.
The final instruction of the block altered control flow, and it has just been removed. Subsequent code generation may take place in this block.
Remove a predecessor, perhaps due to a branch to it becoming unreachable.
Remove a successor edge.
One of my predecessors has been replaced. Update my list of predecessors to account for this change.
Having completed code generation in each of its predecessors, prepare this block for its own code generation.
Answer the non-modifiable List of successor edges that this block has. The underlying MutableList might be changed by other operations, so be aware that it's not truly immutable, just an immutable view.