Abstract ops
abstract_ops
¶
AssemblyInstructionArg: TypeAlias = IntegerAttr | StringAttr | SSAValue | RegisterType | str
module-attribute
¶
IWidth = TypeVar('IWidth', bound=I32 | I64)
module-attribute
¶
ShiftImmT = TypeVar('ShiftImmT', bound=UI5 | UI6)
module-attribute
¶
ShiftImmAttrT = TypeVar('ShiftImmAttrT', bound=I32 | I64)
module-attribute
¶
IOffset = TypeVar('IOffset', bound=I12 | SI12)
module-attribute
¶
RISCVAsmOperation
dataclass
¶
Bases: IRDLOperation, OneLineAssemblyPrintable, ABC
Base class for operations that can be a part of RISC-V assembly printing.
Source code in xdsl/dialects/riscv/abstract_ops.py
RISCVRegallocOperation
dataclass
¶
Bases: HasRegisterConstraints, IRDLOperation, ABC
Base class for operations that can take part in register allocation.
Source code in xdsl/dialects/riscv/abstract_ops.py
get_register_constraints() -> RegisterConstraints
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RISCVInstruction
dataclass
¶
Bases: RISCVAsmOperation, RISCVRegallocOperation, ABC
Base class for operations that can be a part of RISC-V assembly printing. Must represent an instruction in the RISC-V instruction set, and have the following format:
name arg0, arg1, arg2 # comment
The name of the operation will be used as the RISC-V assembly instruction name.
Source code in xdsl/dialects/riscv/abstract_ops.py
comment = opt_attr_def(StringAttr)
class-attribute
instance-attribute
¶
An optional comment that will be printed along with the instruction.
traits = traits_def(RegisterAllocatedMemoryEffect())
class-attribute
instance-attribute
¶
assembly_line_args() -> tuple[AssemblyInstructionArg | None, ...]
abstractmethod
¶
The arguments to the instruction, in the order they should be printed in the assembly.
assembly_instruction_name() -> str
¶
By default, the name of the instruction is the same as the name of the operation.
assembly_line() -> str | None
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RISCVAsmTarget
dataclass
¶
RdRsRsOperation
¶
Bases: RISCVInstruction, ABC, Generic[RDInvT, RS1InvT, RS2InvT]
A base class for RISC-V operations that have one destination register, and two source registers.
This is called R-Type in the RISC-V specification.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd: OpResult[RDInvT] = result_def(RDInvT)
class-attribute
instance-attribute
¶
rs1 = operand_def(RS1InvT)
class-attribute
instance-attribute
¶
rs2 = operand_def(RS2InvT)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $rs2 attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, *, rd: RDInvT = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsRsIntegerOperation
¶
Bases: RdRsRsOperation[IntRegisterType, RS1InvT, RS2InvT], ABC, Generic[RS1InvT, RS2InvT]
Source code in xdsl/dialects/riscv/abstract_ops.py
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsRsFloatOperation
¶
Bases: RdRsRsOperation[FloatRegisterType, RS1InvT, RS2InvT], ABC, Generic[RS1InvT, RS2InvT]
Source code in xdsl/dialects/riscv/abstract_ops.py
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, *, rd: FloatRegisterType = Registers.UNALLOCATED_FLOAT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RsRsImmFloatOperation
¶
Bases: RISCVInstruction, ABC
A base class for RV32F operations that have two source registers (one integer and one floating-point) and an immediate.
Source code in xdsl/dialects/riscv/abstract_ops.py
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs2 = operand_def(FloatRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[I12])
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $rs2 `,` $immediate attr-dict `:` `(` type(operands) `)` `->` `(` `)`'
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, immediate: int | IntegerAttr[I12] | str | StringAttr, *, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsImmFloatOperation
¶
Bases: RISCVInstruction, ABC
A base class for RV32Foperations that have one floating-point destination register, one source register and one immediate operand.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(FloatRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[I12] | StringAttr)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` custom<ImmediateI12>($immediate) attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
custom_directives = (ImmediateI12,)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: int | IntegerAttr[I12] | str | StringAttr, *, rd: FloatRegisterType = Registers.UNALLOCATED_FLOAT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsRsRsFloatOperation
¶
Bases: RISCVInstruction, ABC
A base class for RV32F operations that take three floating-point input registers and a destination register, e.g: fused-multiply-add (FMA) instructions.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(FloatRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(FloatRegisterType)
class-attribute
instance-attribute
¶
rs2 = operand_def(FloatRegisterType)
class-attribute
instance-attribute
¶
rs3 = operand_def(FloatRegisterType)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $rs2 `,` $rs3 attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, rs3: Operation | SSAValue, *, rd: FloatRegisterType = Registers.UNALLOCATED_FLOAT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsRsFloatFloatIntegerOperationWithFastMath
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have two source floating-point registers with an integer destination register, and can be annotated with fastmath flags.
This is called R-Type in the RISC-V specification.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(FloatRegisterType)
class-attribute
instance-attribute
¶
rs2 = operand_def(FloatRegisterType)
class-attribute
instance-attribute
¶
fastmath = attr_def(FastMathFlagsAttr, default_value=FastMathFlagsAttr('none'))
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $rs2 (`fastmath` `` $fastmath^)? attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, fastmath: FastMathFlagsAttr | None = None, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsRsFloatOperationWithFastMath
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have one destination floating-point register, and two source floating-point registers and can be annotated with fastmath flags.
This is called R-Type in the RISC-V specification.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(FloatRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(FloatRegisterType)
class-attribute
instance-attribute
¶
rs2 = operand_def(FloatRegisterType)
class-attribute
instance-attribute
¶
fastmath = attr_def(FastMathFlagsAttr, default_value=FastMathFlagsAttr('none'))
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $rs2 (`fastmath` `` $fastmath^)? attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, *, rd: FloatRegisterType = Registers.UNALLOCATED_FLOAT, fastmath: FastMathFlagsAttr | None = None, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdImmIntegerOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have one destination register, and one immediate operand (e.g. U-Type and J-Type instructions in the RISC-V spec).
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[I20] | StringAttr)
class-attribute
instance-attribute
¶
assembly_format = 'custom<ImmediateI20>($immediate) attr-dict `:` `(` `)` `->` type($rd)'
class-attribute
instance-attribute
¶
custom_directives = (ImmediateI20,)
class-attribute
instance-attribute
¶
__init__(immediate: int | IntegerAttr | str | StringAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdImmJumpOperation
¶
Bases: RISCVInstruction, ABC
In the RISC-V spec, this is the same as RdImmOperation. For jumps, the rd register
is neither an operand, because the stored value is overwritten, nor a result value,
because the value in rd is not defined after the jump back. So the rd makes the
most sense as an attribute.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = opt_attr_def(IntRegisterType)
class-attribute
instance-attribute
¶
The rd register here is not a register storing the result, rather the register where the program counter is stored before jumping.
immediate = attr_def(IntegerAttr[SI20] | StringAttr)
class-attribute
instance-attribute
¶
assembly_format = 'custom<ImmediateSI20>($immediate) (`,` qualified($rd)^)? attr-dict'
class-attribute
instance-attribute
¶
custom_directives = (ImmediateSI20,)
class-attribute
instance-attribute
¶
__init__(immediate: int | IntegerAttr[SI20] | str | StringAttr, *, rd: IntRegisterType | None = None, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsImmIntegerOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have one destination register, one source register and one immediate operand.
This is called I-Type in the RISC-V specification.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[SI12] | StringAttr)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` custom<ImmediateSI12>($immediate) attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
custom_directives = (ImmediateSI12,)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: int | IntegerAttr[SI12] | str | StringAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsImmShiftOperation
¶
Bases: RISCVInstruction, ABC, Generic[ShiftImmT, ShiftImmAttrT]
A base class for RISC-V operations that have one destination register, one source register and one immediate operand.
This is called I-Type in the RISC-V specification.
Shifts by a constant are encoded as a specialization of the I-type format. The shift amount is encoded in the lower 5 bits of the I-immediate field for RV32
For RV32I, SLLI, SRLI, and SRAI generate an illegal instruction exception if imm[5] 6 != 0 but the shift amount is encoded in the lower 6 bits of the I-immediate field for RV64I.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[ShiftImmT])
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $immediate attr-dict `:` `(` type($rs1) `)` `->` type($rd)'
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: IntegerAttr[ShiftImmT], *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
py_operation(rs1: IntegerAttr[ShiftImmAttrT]) -> IntegerAttr[ShiftImmAttrT]
abstractmethod
¶
Performs a python function corresponding to this operation.
If i := py_operation(rs1) is an IntegerAttr[ShiftImmAttrT], then this operation can be
canonicalized to a constant with value i when the inputs are constants
with values rs1. The immediate value is retrieved from the immediate attribute of the operation.
Source code in xdsl/dialects/riscv/abstract_ops.py
ImmShiftOpHasCanonicalizationPatternsTrait
dataclass
¶
Bases: HasCanonicalizationPatternsTrait, Generic[IWidth]
Source code in xdsl/dialects/riscv/abstract_ops.py
li_op_type: type[LiOperation[IWidth]]
instance-attribute
¶
shift_op_type: type[RdRsImmShiftOperation[Any, IWidth]]
instance-attribute
¶
__init_subclass__(li_op_type: type[LiOperation[IWidth]], shift_op_type: type[RdRsImmShiftOperation[Any, IWidth]], **kwargs: Any) -> None
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
get_canonicalization_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsImmBitManipOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have one destination register, one source register and one immediate operand.
These operations are from the Zba, Zbb, and Zbs extensions.
The immediate value is encoded in the lower 5 bits of the immediate field for RV32 and the lower 6 bits for RV64.
See external documentation.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[UI5] | StringAttr)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` custom<ImmediateUI5>($immediate) attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
custom_directives = (ImmediateUI5,)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: int | IntegerAttr[UI5] | str | StringAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsImmJumpOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have one destination register, one source register and one immediate operand.
This is called I-Type in the RISC-V specification.
In the RISC-V spec, this is the same as RdRsImmOperation. For jumps, the rd register
is neither an operand, because the stored value is overwritten, nor a result value,
because the value in rd is not defined after the jump back. So the rd makes the
most sense as an attribute.
Source code in xdsl/dialects/riscv/abstract_ops.py
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
rd = opt_attr_def(IntRegisterType)
class-attribute
instance-attribute
¶
The rd register here is not a register storing the result, rather the register where the program counter is stored before jumping.
immediate = attr_def(IntegerAttr[SI12] | StringAttr)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` custom<ImmediateSI12>($immediate) (`,` qualified($rd)^)? attr-dict `:` `(` type($rs1) `)` `->` `(` `)`'
class-attribute
instance-attribute
¶
custom_directives = (ImmediateSI12,)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: int | IntegerAttr[SI12] | str | StringAttr, *, rd: IntRegisterType | None = None, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsOperation
¶
Bases: RISCVInstruction, ABC, Generic[RDInvT, RSInvT]
A base class for RISC-V pseudo-instructions that have one destination register and one source register.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(RDInvT)
class-attribute
instance-attribute
¶
rs = operand_def(RSInvT)
class-attribute
instance-attribute
¶
assembly_format = '$rs attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
__init__(rs: Operation | SSAValue, *, rd: RDInvT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsIntegerOperation
¶
Bases: RdRsOperation[IntRegisterType, RSInvT], ABC, Generic[RSInvT]
Source code in xdsl/dialects/riscv/abstract_ops.py
__init__(rs: Operation | SSAValue, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
RdRsFloatOperation
¶
Bases: RdRsOperation[FloatRegisterType, RSInvT], ABC, Generic[RSInvT]
Source code in xdsl/dialects/riscv/abstract_ops.py
__init__(rs: Operation | SSAValue, *, rd: FloatRegisterType = Registers.UNALLOCATED_FLOAT, comment: str | StringAttr | None = None)
¶
RsRsOffIntegerOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have one source register and a destination register, and an offset.
This is called B-Type in the RISC-V specification.
Source code in xdsl/dialects/riscv/abstract_ops.py
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs2 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
offset = attr_def(IntegerAttr[SI12] | StringAttr)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $rs2 `,` custom<ImmediateSI12>($offset) attr-dict `:` `(` type(operands) `)` `->` `(` `)`'
class-attribute
instance-attribute
¶
custom_directives = (ImmediateSI12,)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, offset: int | IntegerAttr[SI12] | StringAttr, *, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RsRsImmIntegerOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have two source registers and an immediate.
This is called S-Type in the RISC-V specification.
Source code in xdsl/dialects/riscv/abstract_ops.py
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs2 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[SI12])
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $rs2 `,` $immediate attr-dict `:` `(` type(operands) `)` `->` `(` `)`'
class-attribute
instance-attribute
¶
traits = traits_def(MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, immediate: int | IntegerAttr[SI12] | str | StringAttr, *, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RsRsIntegerOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have two source registers.
Source code in xdsl/dialects/riscv/abstract_ops.py
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs2 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $rs2 attr-dict `:` `(` type(operands) `)` `->` `(` `)`'
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
NullaryOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations that have neither sources nor destinations.
Source code in xdsl/dialects/riscv/abstract_ops.py
CsrReadWriteOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations performing a swap to/from a CSR.
The 'writeonly' attribute controls the actual behaviour of the operation: * when True, the operation writes the rs value to the CSR but never reads it and in this case rd must be allocated to x0 * when False, a proper atomic swap is performed and the previous CSR value is returned in rd
CSR addresses are 12-bit unsigned values, independent of XLEN: https://docs.riscv.org/reference/isa/unpriv/zicsr.html
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
csr = attr_def(IntegerAttr[UI12])
class-attribute
instance-attribute
¶
writeonly = opt_attr_def(UnitAttr)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $csr (`writeonly` $writeonly^)? attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
traits = traits_def(MemoryReadEffect(), MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, csr: IntegerAttr[UI12], *, writeonly: bool = False, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
verify_() -> None
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
CsrBitwiseOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations performing a masked bitwise operation on the CSR while returning the original value.
The 'readonly' attribute controls the actual behaviour of the operation: * when True, the operation is guaranteed to have no side effects that can be potentially related to writing to a CSR; in this case rs must be allocated to x0 * when False, the bitwise operations is performed and any side effect related to writing to a CSR takes place even if the mask in rs has no actual bits set.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
csr = attr_def(IntegerAttr[UI12])
class-attribute
instance-attribute
¶
readonly = opt_attr_def(UnitAttr)
class-attribute
instance-attribute
¶
assembly_format = '$rs1 `,` $csr (`readonly` $readonly^)? attr-dict `:` functional-type(operands, results)'
class-attribute
instance-attribute
¶
traits = traits_def(MemoryReadEffect(), MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, csr: IntegerAttr[UI12], *, readonly: bool = False, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
verify_() -> None
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
CsrReadWriteImmOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations performing a write immediate to/read from a CSR.
The 'writeonly' attribute controls the actual behaviour of the operation: * when True, the operation writes the rs value to the CSR but never reads it and in this case rd must be allocated to x0 * when False, a proper atomic swap is performed and the previous CSR value is returned in rd
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
csr = attr_def(IntegerAttr[UI12])
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[UI5])
class-attribute
instance-attribute
¶
Unsigned five-bit value, zero-extended to XLEN before writing the CSR.
writeonly = opt_attr_def(UnitAttr)
class-attribute
instance-attribute
¶
assembly_format = '$csr `,` $immediate (`writeonly` $writeonly^)? attr-dict `:` `(` `)` `->` type($rd)'
class-attribute
instance-attribute
¶
traits = traits_def(MemoryReadEffect(), MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(csr: IntegerAttr[UI12], immediate: IntegerAttr[UI5], *, writeonly: bool = False, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
verify_() -> None
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
CsrBitwiseImmOperation
¶
Bases: RISCVInstruction, ABC
A base class for RISC-V operations performing a masked bitwise operation on the CSR while returning the original value. The bitmask is specified in the 'immediate' attribute.
The 'immediate' attribute controls the actual behaviour of the operation: * when equals to zero, the operation is guaranteed to have no side effects that can be potentially related to writing to a CSR; * when not equal to zero, any side effect related to writing to a CSR takes place.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
csr = attr_def(IntegerAttr[UI12])
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[UI5])
class-attribute
instance-attribute
¶
assembly_format = '$csr `,` $immediate attr-dict `:` `(` `)` `->` type($rd)'
class-attribute
instance-attribute
¶
traits = traits_def(MemoryReadEffect(), MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(csr: IntegerAttr[UI12], immediate: IntegerAttr[UI5], *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
LiOpHasCanonicalizationPatternTrait
dataclass
¶
Bases: HasCanonicalizationPatternsTrait
Source code in xdsl/dialects/riscv/abstract_ops.py
get_canonicalization_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
LiOperation
¶
Bases: RISCVInstruction, HasFolderInterface, ABC, Generic[IWidth]
Base class for RISC-V operations that load an immediate into rd.
See external documentation.
Source code in xdsl/dialects/riscv/abstract_ops.py
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[IWidth] | StringAttr)
class-attribute
instance-attribute
¶
traits = traits_def(AlwaysSpeculatable(), ConstantLike(), LiOpHasCanonicalizationPatternTrait())
class-attribute
instance-attribute
¶
__init__(immediate: IntegerAttr[IWidth] | str | StringAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
GetAnyRegisterOperation
¶
Bases: RISCVAsmOperation, RISCVRegallocOperation, ABC, Generic[RDInvT]
This instruction allows us to create an SSAValue with for a given register name. This
is useful for bridging the RISC-V convention that stores the result of function calls
in a0 and a1 into SSA form.
For example, to generate this assembly:
One needs to do the following:
rhs = rv32.GetRegisterOp(Registers.s0).res
riscv.JalOp("my_func")
lhs = rv32.GetRegisterOp(Registers.A0).res
sum = riscv.AddOp(lhs, rhs, Registers.A0).rd