qat.experimental.dialect.q1.ir.abstract_ops module

Abstract operation formats for the QBlox Q1 ISA.

The classes in this module describe reusable operand/result formats. For example RsIRd: encodes source register, immediate, destination register, in that order. Concrete operations in the dialect inherit one of these templates and provide the opcode-specific name and traits.

class ImmImmImmImmImmOperation(imm1, imm2, imm3, imm4, imm5, comment=None)

Bases: Q1Instruction, ABC, Generic[ImmT1, ImmT2, ImmT3, ImmT4, ImmT5]

A base class for QBlox Q1 operations that have five immediate operands.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm1 = <xdsl.irdl.operations._PropertyFieldDef object>
imm2 = <xdsl.irdl.operations._PropertyFieldDef object>
imm3 = <xdsl.irdl.operations._PropertyFieldDef object>
imm4 = <xdsl.irdl.operations._PropertyFieldDef object>
imm5 = <xdsl.irdl.operations._PropertyFieldDef object>
class ImmImmImmImmOperation(imm1, imm2, imm3, imm4, comment=None)

Bases: Q1Instruction, ABC, Generic[ImmT1, ImmT2, ImmT3, ImmT4]

A base class for QBlox Q1 operations that have four immediate operands.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm1 = <xdsl.irdl.operations._PropertyFieldDef object>
imm2 = <xdsl.irdl.operations._PropertyFieldDef object>
imm3 = <xdsl.irdl.operations._PropertyFieldDef object>
imm4 = <xdsl.irdl.operations._PropertyFieldDef object>
class ImmImmImmOperation(imm1, imm2, imm3, comment=None)

Bases: Q1Instruction, ABC, Generic[ImmT1, ImmT2, ImmT3]

A base class for QBlox Q1 operations that have three immediate operands.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm1 = <xdsl.irdl.operations._PropertyFieldDef object>
imm2 = <xdsl.irdl.operations._PropertyFieldDef object>
imm3 = <xdsl.irdl.operations._PropertyFieldDef object>
class ImmImmOperation(imm1, imm2, comment=None)

Bases: Q1Instruction, ABC, Generic[ImmT1, ImmT2]

A base class for QBlox Q1 operations that have two immediate operands.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm1 = <xdsl.irdl.operations._PropertyFieldDef object>
imm2 = <xdsl.irdl.operations._PropertyFieldDef object>
class ImmOperation(imm, comment=None)

Bases: Q1Instruction, ABC, Generic[ImmT]

A base class for QBlox Q1 operations that have one immediate operand.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
class ImmRdOperation(imm, rd, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one immediate operand followed by one destination register.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rd: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
class ImmRsImmImmOperation(imm1, rs, imm2, imm3, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT1, ImmT2, ImmT3]

A base class for QBlox Q1 operations that have one immediate operand followed by one source register followed by two immediate operands.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm1 = <xdsl.irdl.operations._PropertyFieldDef object>
imm2 = <xdsl.irdl.operations._PropertyFieldDef object>
imm3 = <xdsl.irdl.operations._PropertyFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class ImmRsImmOperation(imm1, rs, imm2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT1, ImmT2]

A base class for QBlox Q1 operations that have an immediate, a source register, and then another immediate.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm1 = <xdsl.irdl.operations._PropertyFieldDef object>
imm2 = <xdsl.irdl.operations._PropertyFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class ImmRsOperation(imm, rs, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one immediate operand followed by one source register.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class ImmRsRdOperation(imm, rs, rd, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one immediate operand followed by one source register and then one destination register.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rd: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class ImmRsRdRdOperation(imm, rs, rd1, rd2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one immediate operand followed by one source register and then two destination registers.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rd1: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rd2: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class ImmRsRsRsImmOperation(imm1, rs1, rs2, rs3, imm2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT1, ImmT2]

A base class for QBlox Q1 operations that have three source registers surrounded by two immediate operands.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm1 = <xdsl.irdl.operations._PropertyFieldDef object>
imm2 = <xdsl.irdl.operations._PropertyFieldDef object>
rs1 = <xdsl.irdl.operations._OperandFieldDef object>
rs2 = <xdsl.irdl.operations._OperandFieldDef object>
rs3 = <xdsl.irdl.operations._OperandFieldDef object>
class JumpImmOperation(imm, comment=None)

Bases: Q1Instruction, ABC

A base class for jumps whose target is an immediate address or a symbolic label.

The immediate accepts either an AddressImm or a LabelAttr. Label targets print in Q1 assembly as @name and are the form produced by linearising q1_cf control flow.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
JumpTarget: TypeAlias = qat.experimental.dialect.q1.ir.imm_desc.UI14Imm | qat.experimental.dialect.q1.ir.attrs.LabelAttr

A jump destination: an immediate address or a symbolic label.

JumpTargetInput: TypeAlias = qat.experimental.dialect.q1.ir.imm_desc.UI14Imm | qat.experimental.dialect.q1.ir.attrs.LabelAttr | int | str

An unnormalised jump destination, accepting an integer address or label name.

class LoopImmOperation(rd, imm, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT]

A base class for loop instructions with a counter register and address-or-label target.

The counter register is decremented and the branch is taken while it remains non-zero. The target accepts either an AddressImm or a LabelAttr.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str | None, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rd: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
class NullaryOperation(comment=None)

Bases: Q1Instruction, ABC

A base class for QBlox Q1 operations that have neither sources nor destinations.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

class Q1AsmOperation(*, operands=None, result_types=None, properties=None, attributes=None, successors=None, regions=None)

Bases: IRDLOperation, OneLineAssemblyPrintable, ABC

Base class for operations that can be printed and parsed.

Printing support textual IR and assembly which are implemented by print() and assembly_line() respectively.

Parsing currently covers parsing only textual IR which is implemented by parse() and parse_op_type()

assembly_line()

Emits Q1 assembly instruction line corresponding to this operation.

Return type:

str | None

abstract assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str | None, ...]

assembly_mnemonic()

Because operation name must match q1.<format>.<mnemonic>, the instruction name (mnemonic) is extracted from the operation name to be the third field.

Return type:

str

comment = <xdsl.irdl.operations._PropertyFieldDef object>
classmethod parse(parser)

Parse a Q1 operation from IR textual form.

Return type:

Q1AsmOperation

Expects the MLIR generic operation format:

op-name(operands) <{properties}> {attributes} : (input_types) -> (result_types)

classmethod parse_op_type(parser)

Parse the operation type (operand and result types).

Return type:

tuple[Sequence[Attribute], Sequence[Attribute]]

print(printer)

Print a Q1 operation in IR textual form.

Return type:

None

print_op_type(printer)

Print the operation type signature.

Return type:

None

class Q1Instruction(*, operands=None, result_types=None, properties=None, attributes=None, successors=None, regions=None)

Bases: Q1AsmOperation, Q1RegAllocOperation, ABC

Base class for operations that represent an instruction in the QBlox Q1 ISA.

These instructions have the following format:

[label:] mnemonic argument,argument,… [comment]

The name of the operation will be used as the QBlox Q1 assembly mnemonic. The comment is optional. When present, it will be printed along with the instruction.

class Q1RegAllocOperation(*, operands=None, result_types=None, properties=None, attributes=None, successors=None, regions=None)

Bases: HasRegisterConstraints, IRDLOperation, ABC

Base class for operations that can take part in register allocation.

get_register_constraints()

Default constraints are that all operands are “in”, and all results are “out” registers.

If some registers are “inout” then this function must be overridden.

Return type:

RegisterConstraints

class RdImmOperation(rd, imm, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one destination register followed by one immediate operand.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str | None, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rd: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
class RdRdOperation(rd1, rd2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT]

A base class for QBlox Q1 operations that produce two destination registers.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

rd1 = <xdsl.irdl.operations._ResultFieldDef object>
rd2 = <xdsl.irdl.operations._ResultFieldDef object>
class RdRsOperation(rd, rs, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT]

A base class for QBlox Q1 operations that have one destination register followed by one source register.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

rd: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class RsImmImmOperation(rs, imm1, imm2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT1, ImmT2]

A base class for QBlox Q1 operations that have one source register followed by two immediate operands.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm1 = <xdsl.irdl.operations._PropertyFieldDef object>
imm2 = <xdsl.irdl.operations._PropertyFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class RsImmOperation(rs, imm, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one source register followed by one immediate operand.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class RsImmRdOperation(rs, imm, rd, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one immediate operand surrounded by a source register on the left and a destination register on the right.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rd: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class RsImmRdRdOperation(rs, imm, rd1, rd2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one source register followed by one immediate operand and then two destination registers.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rd1: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rd2: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class RsImmRsOperation(rs1, imm, rs2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have one immediate operand surrounded by two source registers.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rs1 = <xdsl.irdl.operations._OperandFieldDef object>
rs2 = <xdsl.irdl.operations._OperandFieldDef object>
class RsOperation(rs, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT]

A base class for QBlox Q1 operations that have one source register.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

rs = <xdsl.irdl.operations._OperandFieldDef object>
class RsRdOperation(rs, rd, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT]

A base class for QBlox Q1 operations that have one source register followed by one destination register.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

rd: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rs = <xdsl.irdl.operations._OperandFieldDef object>
class RsRsImmOperation(rs1, rs2, imm, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have two source registers followed by one immediate operand.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rs1 = <xdsl.irdl.operations._OperandFieldDef object>
rs2 = <xdsl.irdl.operations._OperandFieldDef object>
class RsRsOperation(rs1, rs2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT]

A base class for QBlox Q1 operations that have two source registers.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

rs1 = <xdsl.irdl.operations._OperandFieldDef object>
rs2 = <xdsl.irdl.operations._OperandFieldDef object>
class RsRsRdOperation(rs1, rs2, rd, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT]

A base class for QBlox Q1 operations that have two source registers followed by one destination register.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

rd: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rs1 = <xdsl.irdl.operations._OperandFieldDef object>
rs2 = <xdsl.irdl.operations._OperandFieldDef object>
class RsRsRdRdOperation(rs1, rs2, rd1, rd2, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT]

A base class for QBlox Q1 operations that have two source registers followed by two destination registers.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

rd1: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rd2: OpResult[RInvT] = <xdsl.irdl.operations._ResultFieldDef object>
rs1 = <xdsl.irdl.operations._OperandFieldDef object>
rs2 = <xdsl.irdl.operations._OperandFieldDef object>
class RsRsRsImmOperation(rs1, rs2, rs3, imm, comment=None)

Bases: Q1Instruction, ABC, Generic[RInvT, ImmT]

A base class for QBlox Q1 operations that have three source registers followed by one immediate operand.

assembly_line_args()

Instruction arguments in the order they should be printed in the assembly.

Return type:

tuple[Q1Imm | LabelAttr | SSAValue | RegisterType | StringAttr | str, ...]

imm = <xdsl.irdl.operations._PropertyFieldDef object>
rs1 = <xdsl.irdl.operations._OperandFieldDef object>
rs2 = <xdsl.irdl.operations._OperandFieldDef object>
rs3 = <xdsl.irdl.operations._OperandFieldDef object>