L2BasicBlock

class L2BasicBlock(name: String, var isLoopHead: Boolean = false, var zone: L2ControlFlowGraph.Zone? = null)

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

name

A descriptive name for the block.

isLoopHead

Whether this block is the head of a loop. Default is false.

zone

A mechanism to visually group blocks in the L2ControlFlowGraphVisualizer, indicating the purpose of that group.

Constructors

Link copied to clipboard
constructor(name: String, isLoopHead: Boolean = false, zone: L2ControlFlowGraph.Zone? = null)

Create a new basic block, marking it as a loop head if requested.

Properties

Link copied to clipboard

A place to write notes for marking up a graph.

Link copied to clipboard

Whether we've started adding instructions to this basic block.

Link copied to clipboard

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.

Link copied to clipboard

Whether this block is the head of a loop. Default is false.

Link copied to clipboard

The block's optional L2ControlFlowGraph.Zone, a mechanism to visually group blocks in the L2ControlFlowGraphVisualizer.

Functions

Link copied to clipboard
fun addInstruction(instruction: L2Instruction, manifest: L2ValueManifest)

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.

Link copied to clipboard
fun addPredecessorEdge(predecessorEdge: L2PcOperand)

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.

Link copied to clipboard
fun addSuccessorEdge(successorEdge: L2PcOperand)

Add a successor edge.

Link copied to clipboard

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.

Link copied to clipboard

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).

Link copied to clipboard

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.

Link copied to clipboard

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).

Link copied to clipboard
fun insertInstruction(index: Int, instruction: L2Instruction)

Insert an instruction in this basic block at the specified instruction index, notifying the operands that the instruction was just added.

Link copied to clipboard

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.

Link copied to clipboard

Prevent this block from being removed, so that its position can be identified in the final generated code.

Link copied to clipboard
fun name(): String

Answer the descriptive name of this basic block.

Link copied to clipboard
fun offset(): Int

Answer the L2 offset at which the block starts. Only populated after code generation has completed.

Link copied to clipboard

Answer a read-only List of predecessor edges of this block.

Link copied to clipboard

The final instruction of the block altered control flow, it was removed and later re-added to the instructions list directly.

Link copied to clipboard

The final instruction of the block altered control flow, and it has just been removed. Subsequent code generation may take place in this block.

Link copied to clipboard
fun removePredecessorEdge(predecessorEdge: L2PcOperand)

Remove a predecessor, perhaps due to a branch to it becoming unreachable.

Link copied to clipboard
fun removeSuccessorEdge(successorEdge: L2PcOperand)

Remove a successor edge.

Link copied to clipboard
fun replacePredecessorEdge(oldPredecessorEdge: L2PcOperand, newPredecessorEdge: L2PcOperand)

One of my predecessors has been replaced. Update my list of predecessors to account for this change.

Link copied to clipboard
fun startIn(generator: L2Generator, generatePhis: Boolean = true, regenerator: L2Regenerator? = null)

Having completed code generation in each of its predecessors, prepare this block for its own code generation.

Link copied to clipboard

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.

Link copied to clipboard
open override fun toString(): String