Abstract ops
abstract_ops
¶
AssemblyInstructionArg: TypeAlias = IntegerAttr | LabelAttr | 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
RISCVCustomFormatOperation
dataclass
¶
Bases: IRDLOperation, ABC
Base class for RISC-V operations that specialize their custom format.
Source code in xdsl/dialects/riscv/abstract_ops.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
parse(parser: Parser) -> Self
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
parse_unresolved_operands(parser: Parser) -> list[UnresolvedOperand]
classmethod
¶
Parse a list of comma separated unresolved operands.
Notice that this method will consume trailing comma.
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Parse attributes with custom syntax. Subclasses may override this method.
parse_op_type(parser: Parser) -> tuple[Sequence[Attribute], Sequence[Attribute]]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
print(printer: Printer) -> None
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
Print attributes with custom syntax. Return the names of the attributes printed. Subclasses may override this method.
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: RISCVCustomFormatOperation, 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
¶
__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: RISCVCustomFormatOperation, 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
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, immediate: int | IntegerAttr[I12] | str | LabelAttr, *, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
RdRsImmFloatOperation
¶
Bases: RISCVCustomFormatOperation, 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] | LabelAttr)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: int | IntegerAttr[I12] | str | LabelAttr, *, rd: FloatRegisterType = Registers.UNALLOCATED_FLOAT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
RdRsRsRsFloatOperation
¶
Bases: RISCVCustomFormatOperation, 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
¶
__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: RISCVCustomFormatOperation, 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)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, fastmath: FastMathFlagsAttr = FastMathFlagsAttr('none'), comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
RdRsRsFloatOperationWithFastMath
¶
Bases: RISCVCustomFormatOperation, 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 = opt_attr_def(FastMathFlagsAttr)
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
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdImmIntegerOperation
¶
Bases: RISCVCustomFormatOperation, 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] | LabelAttr)
class-attribute
instance-attribute
¶
__init__(immediate: int | IntegerAttr | str | LabelAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
RdImmJumpOperation
¶
Bases: RISCVCustomFormatOperation, 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] | LabelAttr)
class-attribute
instance-attribute
¶
__init__(immediate: int | IntegerAttr[SI20] | str | LabelAttr, *, rd: IntRegisterType | None = None, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg | None, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
print_op_type(printer: Printer) -> None
¶
RdRsImmIntegerOperation
¶
Bases: RISCVCustomFormatOperation, 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] | LabelAttr)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: int | IntegerAttr[SI12] | str | LabelAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
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: RISCVCustomFormatOperation, 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] | LabelAttr)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: int | IntegerAttr[UI5] | str | LabelAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
RdRsImmJumpOperation
¶
Bases: RISCVCustomFormatOperation, 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] | LabelAttr)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, immediate: int | IntegerAttr[SI12] | str | LabelAttr, *, rd: IntRegisterType | None = None, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg | None, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
RdRsOperation
¶
Bases: RISCVCustomFormatOperation, 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
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: RISCVCustomFormatOperation, 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] | LabelAttr)
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, offset: int | IntegerAttr[SI12] | LabelAttr, *, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
RsRsImmIntegerOperation
¶
Bases: RISCVCustomFormatOperation, 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
¶
traits = traits_def(MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, immediate: int | IntegerAttr[SI12] | str | LabelAttr, *, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
RsRsIntegerOperation
¶
Bases: RISCVCustomFormatOperation, 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
¶
__init__(rs1: Operation | SSAValue, rs2: Operation | SSAValue, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
NullaryOperation
¶
Bases: RISCVCustomFormatOperation, 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: RISCVCustomFormatOperation, 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
Source code in xdsl/dialects/riscv/abstract_ops.py
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | |
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
csr = attr_def(IntegerAttr)
class-attribute
instance-attribute
¶
writeonly = opt_attr_def(UnitAttr)
class-attribute
instance-attribute
¶
traits = traits_def(MemoryReadEffect(), MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, csr: IntegerAttr, *, 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
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
CsrBitwiseOperation
¶
Bases: RISCVCustomFormatOperation, 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
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 | |
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
rs1 = operand_def(IntRegisterType)
class-attribute
instance-attribute
¶
csr = attr_def(IntegerAttr)
class-attribute
instance-attribute
¶
readonly = opt_attr_def(UnitAttr)
class-attribute
instance-attribute
¶
traits = traits_def(MemoryReadEffect(), MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(rs1: Operation | SSAValue, csr: IntegerAttr, *, 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
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
CsrReadWriteImmOperation
¶
Bases: RISCVCustomFormatOperation, 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
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 | |
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
csr = attr_def(IntegerAttr)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr)
class-attribute
instance-attribute
¶
writeonly = opt_attr_def(UnitAttr)
class-attribute
instance-attribute
¶
traits = traits_def(MemoryReadEffect(), MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(csr: IntegerAttr, immediate: IntegerAttr, *, 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
assembly_line_args() -> tuple[AssemblyInstructionArg | None, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
CsrBitwiseImmOperation
¶
Bases: RISCVCustomFormatOperation, 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)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr)
class-attribute
instance-attribute
¶
traits = traits_def(MemoryReadEffect(), MemoryWriteEffect())
class-attribute
instance-attribute
¶
__init__(csr: IntegerAttr, immediate: IntegerAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
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: RISCVCustomFormatOperation, 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
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 | |
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
¶
immediate = attr_def(IntegerAttr[IWidth] | LabelAttr)
class-attribute
instance-attribute
¶
traits = traits_def(AlwaysSpeculatable(), ConstantLike(), LiOpHasCanonicalizationPatternTrait())
class-attribute
instance-attribute
¶
__init__(immediate: IntegerAttr[IWidth] | str | LabelAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
¶
Source code in xdsl/dialects/riscv/abstract_ops.py
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
¶
fold() -> tuple[IntegerAttr[IWidth] | LabelAttr]
¶
custom_print_attributes(printer: Printer) -> AbstractSet[str]
¶
parse_op_type(parser: Parser) -> tuple[Sequence[Attribute], Sequence[Attribute]]
classmethod
¶
GetAnyRegisterOperation
¶
Bases: RISCVCustomFormatOperation, 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