qblox_scheduler.backends.qblox.control_flow_graph#

Control-flow graph definition.

Classes#

BasicBlock

A sequence of instructions that does not branch.

_UnfinishedBasicBlock

An unfinished basic block, that is used during control-flow graph construction.

InstructionsIteratorFactory

Iterator factory for instructions built from an iterator of basic blocks.

ControlFlowGraph

An intermediate representation of the instructions for one sequencer, with explicit control-flow

Module Contents#

class BasicBlock(unfinished_basic_block: _UnfinishedBasicBlock)[source]#

Bases: qblox_scheduler.helpers.linked_list.DLinkedList[qblox_scheduler.backends.qblox.operation_handling.base.IOperationStrategy]

A sequence of instructions that does not branch.

The BasicBlock is constructed with pointers to its first and its last instruction in a DLinkedList of instructions.

A basic block does not contain any control-flow between its first and last instruction, meaning the flow of execution can only enter at the first instruction, and exit at the last.

start_time_ns[source]#

The start time of this block. This is helpful information as we do not have explicit wait operations.

end_time_ns[source]#

The end time of this block. This is helpful information as we do not have explicit wait operations.

If the block is a loop, this is the time after 1 repetition finished, not the whole loop.

successors: list[BasicBlock] = [][source]#

The basic blocks that can directly succeed this block.

class _UnfinishedBasicBlock(start_time_ns: int, predecessors: list[_UnfinishedBasicBlock])[source]#

Bases: qblox_scheduler.helpers.linked_list.DLinkedList

An unfinished basic block, that is used during control-flow graph construction.

successors: list[_UnfinishedBasicBlock] = [][source]#
predecessors: list[_UnfinishedBasicBlock][source]#
start_time_ns: int[source]#
end_time_ns: int | None = None[source]#
class InstructionsIteratorFactory(basic_blocks: collections.abc.Iterable[BasicBlock])[source]#

Iterator factory for instructions built from an iterator of basic blocks.

_basic_blocks[source]#
class ControlFlowGraph[source]#

An intermediate representation of the instructions for one sequencer, with explicit control-flow information.

It consists of two doubly linked lists: one for all instructions in chronological order, and one for basic blocks with pointers into the list of instructions.

basic_blocks: list[BasicBlock] = [][source]#
property instructions: collections.abc.Iterable[qblox_scheduler.backends.qblox.operation_handling.base.IOperationStrategy][source]#

Iterator for instructions.

property instructions_len: int[source]#

Number of instructions.

classmethod __parse_operations_recursively(instructions_iter: collections.abc.Iterator[qblox_scheduler.backends.qblox.operation_handling.base.IOperationStrategy], current_block: _UnfinishedBasicBlock, unfinished_blocks: list[_UnfinishedBasicBlock]) _UnfinishedBasicBlock[source]#
classmethod from_instructions(instructions: list[qblox_scheduler.backends.qblox.operation_handling.base.IOperationStrategy]) ControlFlowGraph[source]#

Construct a control-flow graph from a chronologically ordered IOperationStrategy list.

Parameters:

instructions (list[IOperationStrategy]) – A chronologically ordered list of IOperationStrategy objects.

Returns:

ControlFlowGraph The control-flow graph representation of the instructions.

classmethod __finish_basic_blocks(unfinished_blocks: list[_UnfinishedBasicBlock]) ControlFlowGraph[source]#

The unfinished blocks reference other unfinished blocks in the predecessors and successors. These must be corrected to point to already finished block objects.