qat.experimental.dialect.q1_cf package

The q1_cf dialect.

q1_cf specifies target-specific CFG operations for QBlox Q1. It sits above flat q1 (ISA mnemonics). Every operation is a block terminator with named successor blocks, per-successor SSA operand groups, and explicit register-type condition operands. Conditional branches carry a predicate attribute selecting the test applied to their operands.

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

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

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 ComparisonPredicate(value)

Bases: StrEnum

Comparison 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 ComparisonPredicateAttr(data)

Bases: EnumAttribute[ComparisonPredicate], SpacedOpaqueSyntaxAttribute

Attribute wrapper carrying a ComparisonPredicate.

enum_type

alias of ComparisonPredicate

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

The attribute name should be a static field in the attribute classes.

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

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 FlagPredicate(value)

Bases: StrEnum

Condition-code test applied to a single register value.

eqz = 'eqz'
gez = 'gez'
ltz = 'ltz'
nez = 'nez'
class FlagPredicateAttr(data)

Bases: EnumAttribute[FlagPredicate], SpacedOpaqueSyntaxAttribute

Attribute wrapper carrying a FlagPredicate.

enum_type

alias of FlagPredicate

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

The attribute name should be a static field in the attribute classes.

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

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

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

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

Subpackages