InstructionSource Class

Constructor

InstructionSource()

Methods

add_node

Add a node to the instruction source graph.

add_root

Add a root node to the instruction source graph.

from_isa

Construct an InstructionSource graph from an ISA.

The instruction source graph contains more information than the provenance graph in the context, as it connects the instructions to the transforms and architectures that generated them.

get

Retrieve the first instruction source root node with the given instruction ID. Returns default if no such node exists.

add_node

Add a node to the instruction source graph.

add_node(instruction: Instruction, transform: ISATransform | Architecture | None, children: list[int]) -> int

Parameters

Name Description
instruction
Required
<xref:qdk.qre.Instruction>

The instruction for this node.

transform
Required
<xref:Optional>[<xref:ISATransform | Architecture>]

The transform that produced the instruction.

children
Required

Indices of child nodes.

Returns

Type Description
int

The index of the newly added node.

add_root

Add a root node to the instruction source graph.

add_root(node_id: int) -> None

Parameters

Name Description
node_id
Required
int

The index of the node to add as a root.

from_isa

Construct an InstructionSource graph from an ISA.

The instruction source graph contains more information than the provenance graph in the context, as it connects the instructions to the transforms and architectures that generated them.

from_isa(ctx: ISAContext, isa: ISA) -> InstructionSource

Parameters

Name Description
ctx
Required

The enumeration context containing the provenance graph.

isa
Required
ISA

Instructions in the ISA will serve as root nodes in the source graph.

Returns

Type Description

The instruction source graph for the estimation result.

get

Retrieve the first instruction source root node with the given instruction ID. Returns default if no such node exists.

get(id: int, default: _InstructionSourceNodeReference | None = None) -> _InstructionSourceNodeReference | None

Parameters

Name Description
id
Required
int

The instruction ID to search for.

default
<xref:Optional>[<xref:_InstructionSourceNodeReference>]

The value to return if no node with the given ID is found. Default is None.

Default value: None

Returns

Type Description
Optional[<xref:_InstructionSourceNodeReference>]

The first instruction source node with the given instruction ID, or default if no such node exists.

Attributes

nodes

nodes: list[qdk.qre._instruction._InstructionSourceNode]

roots

roots: list[int]