qat.experimental.dialect.q1_cf.ir.ops module

q1_cf dialect operations.

Target-specific CFG operations for QBlox Q1. Each operation is a block terminator that carries one or more named successor blocks, each with its own group of SSA block arguments. Conditions are expressed as SSA operands (q1.reg) plus a predicate attribute rather than via the physical flag registers; the flag machinery is reintroduced at linearisation to flat q1.

The dialect occupies the layer above flat q1 (ISA mnemonics). It provides four terminators:

  • JmpBranchOp — unconditional branch.

  • FlagBranchOp — branch on a condition-code test of one register.

  • ComparisonBranchOp — branch on a comparison of two operands.

  • LoopBranchOp — counted-loop back-edge.

Reference: https://docs.qblox.com/en/main/products/qblox_instruments/q1/index.html

class ComparisonBranchOp(predicate, lhs, rhs, then_arguments, else_arguments, then_block, else_block)

Bases: ComparisonBranchOp, HasRegisterConstraints, RegisterAllocatableOperation, IRDLOperation, Operation, _IRNode, ABC, object

Branch on a comparison of two operands.

The predicate selects the signed/unsigned comparison applied to lhs and rhs, both register-typed SSA values. The then block is taken when the comparison holds; else is the fall-through successor and must immediately follow the parent block in its region. Lowers to a cmp followed by the matching flag jump at flat q1.

q1_cf.comparison_branch slt %lhs : q1.reg, %rhs : q1.reg, ^then(...), ^else(...)
attributes: dict[str, Attribute]

The attributes attached to the operation.

const_evaluate(lhs, rhs, bitwidth)

Evaluate the comparison predicate on constant operand values.

This is the hook a future CFG-canonicalisation pattern will call when both operands fold to constants: the branch is then rewritten to an unconditional q1_cf.jmp_branch to the statically taken edge (the dead edge and any blocks it solely reaches become unreachable and are pruned). It exists ahead of that pattern so the constant-folding semantics live with the op that defines them; the rewrite itself is tracked separately.

Parameters:
  • lhs (int) – Signless bit pattern of the left comparison operand.

  • rhs (int) – Signless bit pattern of the right comparison operand.

  • bitwidth (int) – Register width, used to reinterpret both operands as signed or unsigned according to the predicate.

Return type:

bool

Returns:

True if the then edge is taken, False if the branch falls through to else.

else_arguments

Access a variadic construct when there is a “segment size” attribute.

else_block

Access a non-variadic construct which appears before any variadic arguments.

classmethod get_irdl_definition()

Get the IRDL operation definition.

get_register_constraints()

The values with register types used by this operation, for use in register allocation.

Return type:

RegisterConstraints

irdl_options = (AttrSizedOperandSegments(as_property=False),)
lhs

Access a non-variadic construct when there is a “segment size” attribute.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'q1_cf.comparison_branch'

The operation name. Should be a static member of the class

classmethod parse(parser)
Return type:

Self

predicate

Accessor for an operation property.

print(printer)
Return type:

None

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

rhs

Access a non-variadic construct when there is a “segment size” attribute.

then_arguments

Access a variadic construct when there is a “segment size” attribute.

then_block

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 FlagBranchOp(predicate, rs, then_arguments, else_arguments, then_block, else_block)

Bases: FlagBranchOp, HasRegisterConstraints, RegisterAllocatableOperation, IRDLOperation, Operation, _IRNode, ABC, object

Branch on a condition-code test of a single register.

The predicate selects the zero/sign test applied to rs. The then block is taken when the test holds; else is the fall-through successor and must immediately follow the parent block in its region. Lowers to a test/cmp against zero followed by the matching flag jump at flat q1.

q1_cf.flag_branch eqz %rs : q1.reg, ^then(...), ^else(...)
attributes: dict[str, Attribute]

The attributes attached to the operation.

const_evaluate(rs, bitwidth)

Evaluate the flag predicate on a constant operand value.

Parameters:
  • rs (int) – Signless bit pattern of the tested register.

  • bitwidth (int) – Register width, used to reinterpret rs as signed or unsigned according to the predicate.

Return type:

bool

Returns:

True if the then edge is taken, False if the branch falls through to else.

else_arguments

Access a variadic construct when there is a “segment size” attribute.

else_block

Access a non-variadic construct which appears before any variadic arguments.

classmethod get_irdl_definition()

Get the IRDL operation definition.

get_register_constraints()

The values with register types used by this operation, for use in register allocation.

Return type:

RegisterConstraints

irdl_options = (AttrSizedOperandSegments(as_property=False),)
location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'q1_cf.flag_branch'

The operation name. Should be a static member of the class

classmethod parse(parser)
Return type:

Self

predicate

Accessor for an operation property.

print(printer)
Return type:

None

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

rs

Access a non-variadic construct when there is a “segment size” attribute.

then_arguments

Access a variadic construct when there is a “segment size” attribute.

then_block

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 JmpBranchOp(successor_arguments, successor)

Bases: JmpBranchOp, HasRegisterConstraints, RegisterAllocatableOperation, IRDLOperation, Operation, _IRNode, ABC, object

Unconditional branch to a successor block.

Carries optional per-successor block arguments. At linearisation to flat q1 this becomes q1.i.jmp (or is elided when successor is the fall-through block).

q1_cf.jmp_branch ^dest(%arg0 : q1.reg, ...)
attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

get_register_constraints()

The values with register types used by this operation, for use in register allocation.

Return type:

RegisterConstraints

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'q1_cf.jmp_branch'

The operation name. Should be a static member of the class

classmethod parse(parser)
Return type:

Self

print(printer)
Return type:

None

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

successor

Access a non-variadic construct which appears before any variadic arguments.

successor_arguments

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 LoopBranchOp(counter, body_arguments, exit_arguments, body_block, exit_block)

Bases: LoopBranchOp, HasRegisterConstraints, RegisterAllocatableOperation, IRDLOperation, Operation, _IRNode, ABC, object

Decrement counter and branch to body while non-zero; else exit.

Lowers to q1.ri.loop / q1.rr.loop at flat q1.

q1_cf.loop_branch %counter : q1.reg, ^body(%a : q1.reg, ...), ^exit(%b : q1.reg, ...)
attributes: dict[str, Attribute]

The attributes attached to the operation.

body_arguments

Access a variadic construct when there is a “segment size” attribute.

body_block

Access a non-variadic construct which appears before any variadic arguments.

counter

Access a non-variadic construct when there is a “segment size” attribute.

exit_arguments

Access a variadic construct when there is a “segment size” attribute.

exit_block

Access a non-variadic construct which appears before any variadic arguments.

classmethod get_irdl_definition()

Get the IRDL operation definition.

get_register_constraints()

The values with register types used by this operation, for use in register allocation.

Return type:

RegisterConstraints

irdl_options = (AttrSizedOperandSegments(as_property=False),)
location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'q1_cf.loop_branch'

The operation name. Should be a static member of the class

classmethod parse(parser)
Return type:

Self

print(printer)
Return type:

None

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

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_()