qat.experimental.dialect.q1_scf package
The q1_scf dialect.
q1_scf is the structured control flow dialect for the QBlox Q1 sequence
processor. It sits above q1_cf, the target-specific block CFG, and below the
pulse level, and provides an if conditional and while/for loop
containers with the condition and yield terminators. The dialect neither
lowers control flow nor performs register allocation. It is the representation on
which a subsequent register-allocation pass operates.
Structured control flow branches on register values alone. A measurement outcome
reaches q1_scf only as a q1.reg dequeued through q1_linq; an outcome
consumed through q1_trigger drives predicated execution without exposing its
value and never reaches this dialect.
Reference: https://docs.qblox.com/en/main/products/qblox_instruments/q1/index.html
- class BinaryPredicate(value)
Bases:
StrEnumComparison applied between two operand values.
- eq = 'eq'
- ne = 'ne'
- sge = 'sge'
- sgt = 'sgt'
- sle = 'sle'
- slt = 'slt'
- uge = 'uge'
- ugt = 'ugt'
- ule = 'ule'
- ult = 'ult'
- class BinaryPredicateAttr(data)
Bases:
EnumAttribute[BinaryPredicate],SpacedOpaqueSyntaxAttributeAttribute wrapper carrying a
BinaryPredicate.- data: DataElement
- enum_type
alias of
BinaryPredicate
- name: ClassVar[str] = 'q1_cf.binary_predicate'
The attribute name should be a static field in the attribute classes.
- class ConditionOp(predicate, predicate_args, forward_args)
Bases:
ConditionOp,IRDLOperation,Operation,_IRNode,ABC,objectTerminate the
beforeregion of aWhileOp.The loop continues while
predicateholds over its register operands, and theforward_argsare threaded to theafterregion or, on exit, to the loop results.q1_scf.condition slt %x : q1.reg, %n : q1.reg (%acc : q1.reg)
- forward_args
Access a variadic construct when there is a “segment size” attribute.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- irdl_options = (AttrSizedOperandSegments(as_property=False),)
- name: ClassVar[str] = 'q1_scf.condition'
The operation name. Should be a static member of the class
- classmethod parse(parser)
- Return type:
Self
- predicate
Accessor for an operation property.
- predicate_args
Access a variadic construct when there is a “segment size” attribute.
- print(printer)
- Return type:
None
- traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>
Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.
- verify_()
- class ForOp(iter_count, iter_args, body, iter_domain=None)
Bases:
ForOp,IRDLOperation,RegisterAllocatableOperation,Operation,_IRNode,ABC,objectCounted loop whose induction value is the remaining count.
iter_countcounts down to zero, mapping one-to-one onto the native Q1 decrement-and-branch loop and ontoq1_cf.loop_branch. The body is a single block terminated byYieldOp, and its entry block arguments are the induction counter followed by the carried values. AForOpis reducible to aWhileOp. The optionaliter_domainrecords the linear iteration the counted loop realises.q1_scf.for %n : q1.reg iter_args(%acc : q1.reg) { ... }- allocate_registers(allocator)
Entry point for structured register allocation over this loop.
This allocation is done under the following assumptions: :rtype:
NoneThe iter_args that instantiate the loop-carried arguments are not consumed after initialising the loop. This is to prevent accidental reallocation due to the coalescing constraints between the iter_args and the block arguments.
The iter_count is not consumed after initialising the loop. This is to prevent accidental reallocation due to the coalescing constraints between the iter_count and the induction variable.
Relocations are applied to block arguments where required to allow for register allocation with the coalescing constraints.
Because of these assumptions, not every allocation is possible. It’s expected that legalisation via relocations happens prior to allocation. In particular, lowering from other dialects would enforce this through move operations on iter args, block arguments and the induction variable.
- body
Access a non-variadic construct which appears before any variadic arguments.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- iter_args
Access a variadic construct in the case where it is the only variadic.
- iter_count
Access a non-variadic construct which appears before any variadic arguments.
- iter_domain
Accessor for an optional operation property.
- name: ClassVar[str] = 'q1_scf.for'
The operation name. Should be a static member of the class
- classmethod parse(parser)
- Return type:
Self
- print(printer)
- Return type:
None
- res
Access a variadic construct in the case where it is the only variadic.
- traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>
Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.
- verify_()
- class IfOp(predicate, predicate_args, result_types, then_region, else_region=None)
Bases:
IfOp,IRDLOperation,RegisterAllocatableOperation,Operation,_IRNode,ABC,objectStructured conditional for single-sequencer feedforward.
Evaluates
predicateover its register operands, runs thethenregion or the optionalelseregion, and returns their yielded values as its results. Both regions are terminated byYieldOp. Feedforward here denotes intra-sequencer conditional execution, distinct from a loop or a cross-sequencer message.q1_scf.if nez %flag : q1.reg -> (q1.reg) { ... } else { ... }- allocate_registers(allocator)
Entry point for structured register allocation over this conditional.
Ensures the yield arguments of the then and else regions are allocated to the same registers as the results of the IfOp, and that the predicate operands are allocated to registers. Allocates each region separately, allowing use of shared registers between the two regions.
- Return type:
None
- else_region
Access a non-variadic construct which appears before any variadic arguments.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- name: ClassVar[str] = 'q1_scf.if'
The operation name. Should be a static member of the class
- output
Access a variadic construct in the case where it is the only variadic.
- classmethod parse(parser)
- Return type:
Self
- predicate
Accessor for an operation property.
- predicate_args
Access a variadic construct in the case where it is the only variadic.
- print(printer)
- Return type:
None
- then_region
Access a non-variadic construct which appears before any variadic arguments.
- traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>
Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.
- verify_()
- class IterDomainAttr(start, stop, step, count, parameter)
Bases:
IterDomainAttrLinear iteration domain of a
ForOp.The domain is the affine sequence
start, start + step, ...truncated tocountpoints, all measured in the unit implied byparameter. It records the physical meaning of a counted loop and does not alter its control-flow semantics.- Parameters:
start¶ (
float) – First value of the varied quantity.stop¶ (
float) – Exclusive upper bound of the varied quantity.step¶ (
float) – Increment between successive iterations; must be non-zero.count¶ (
int) – Number of loop iterations, which must equalceil((stop - start) / step).parameter¶ (
IterParameter) – The varied quantity and, implicitly, its unit.
- count: IntAttr = <xdsl.irdl.attributes._ParameterDef object>
- classmethod get_irdl_definition()
Get the IRDL attribute definition.
- name: ClassVar[str] = 'q1_scf.iter_domain'
The attribute name should be a static field in the attribute classes.
- parameter: IterParameterAttr = <xdsl.irdl.attributes._ParameterDef object>
- start: FloatAttr = <xdsl.irdl.attributes._ParameterDef object>
- step: FloatAttr = <xdsl.irdl.attributes._ParameterDef object>
- stop: FloatAttr = <xdsl.irdl.attributes._ParameterDef object>
- verify()
Verify the domain is a well-formed linear iteration.
- Raises:
VerifyException – If
stepis zero, ifcountis negative, or ifcountdoes not equalceil((stop - start) / step).- Return type:
None
- class IterParameter(value)
Bases:
StrEnumThe quantity varied across iterations, which also fixes the domain unit.
- duration = 'duration'
- frequency = 'frequency'
- gain = 'gain'
- phase = 'phase'
- class IterParameterAttr(data)
Bases:
EnumAttribute[IterParameter],SpacedOpaqueSyntaxAttributeAttribute wrapper carrying an
IterParameter.- enum_type
alias of
IterParameter
- name: ClassVar[str] = 'q1_scf.iter_parameter'
The attribute name should be a static field in the attribute classes.
- class UnaryPredicate(value)
Bases:
StrEnumCondition-code test applied to a single register value.
- eqz = 'eqz'
- gez = 'gez'
- ltz = 'ltz'
- nez = 'nez'
- class UnaryPredicateAttr(data)
Bases:
EnumAttribute[UnaryPredicate],SpacedOpaqueSyntaxAttributeAttribute wrapper carrying a
UnaryPredicate.- data: DataElement
- enum_type
alias of
UnaryPredicate
- name: ClassVar[str] = 'q1_cf.unary_predicate'
The attribute name should be a static field in the attribute classes.
- class WhileOp(init_args, result_types, before_region, after_region)
Bases:
WhileOp,IRDLOperation,RegisterAllocatableOperation,Operation,_IRNode,ABC,objectGeneral structured loop with a
before/aftersplit.The
beforeregion computes and tests the loop condition and is terminated byConditionOp. Theafterregion is the loop body, terminated byYieldOp, whose yielded values feed back to thebeforeblock arguments. Any structured loop is expressible in this form.q1_scf.while (%acc : q1.reg) -> (q1.reg) { ... } do { ... }- after_region
Access a non-variadic construct which appears before any variadic arguments.
- allocate_registers(allocator)
Entry point for structured register allocation over this loop.
- Return type:
None
- before_region
Access a non-variadic construct which appears before any variadic arguments.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- init_args
Access a variadic construct in the case where it is the only variadic.
- name: ClassVar[str] = 'q1_scf.while'
The operation name. Should be a static member of the class
- classmethod parse(parser)
- Return type:
Self
- print(printer)
- Return type:
None
- res
Access a variadic construct in the case where it is the only variadic.
- traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>
Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.
- verify_()
- class YieldOp(*arguments)
Bases:
YieldOp,IRDLOperation,Operation,_IRNode,ABC,objectTerminate a structured region, forwarding register values to its parent.
Terminates the body of a
ForOp, theafterregion of aWhileOp, and each region of anIfOp.q1_scf.yield %a, %b : q1.reg, q1.reg
- arguments
Access a variadic construct in the case where it is the only variadic.
- assembly_format: ClassVar[str | None] = 'attr-dict ($arguments^ `:` type($arguments))?'
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- name: ClassVar[str] = 'q1_scf.yield'
The operation name. Should be a static member of the class
- classmethod parse(parser: Parser) IRDLOperationInvT
- Return type:
TypeVar(IRDLOperationInvT, bound= IRDLOperation)
- print(printer: Printer)
- traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>
Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.
- verify_()