Utils
utils
¶
register_type_for_type(attr: Attribute) -> type[riscv.IntRegisterType] | type[riscv.FloatRegisterType]
¶
Returns the appropriate register fype for a given input type.
Source code in xdsl/backend/riscv/lowering/utils.py
move_ops_for_value(value: SSAValue, value_type: Attribute, rd: riscv.RISCVRegisterType) -> tuple[Operation, SSAValue]
¶
Returns the operation that moves the value from the input to a new register. In order to disambiguate which floating point move should be used (fmv.s vs fmv.d), the floating point type in question must be passed
Source code in xdsl/backend/riscv/lowering/utils.py
move_to_regs(values: Iterable[SSAValue], value_types: Iterable[Attribute], reg_types: Iterable[riscv.RISCVRegisterType], flen: int = 64, xlen: int = 32) -> tuple[list[Operation], list[SSAValue]]
¶
Return move operations to a registers (a0, a1, ... | fa0, fa1, ...).
Source code in xdsl/backend/riscv/lowering/utils.py
a_regs_for_types(types: Iterable[Attribute]) -> Iterator[riscv.RISCVRegisterType]
¶
Returns the "a" registers in which to store types, i.e. fa0, fa1, etc for
floating-point values and a0, a1, etc for integer values and pointers. The
register index is separate for integer and floating-point registers according to the
RISC-V ABI.
Source code in xdsl/backend/riscv/lowering/utils.py
a_regs(values: Iterable[SSAValue]) -> Iterator[riscv.RISCVRegisterType]
¶
move_to_a_regs(values: Iterable[SSAValue], value_types: Iterable[Attribute], flen: int = 64, xlen: int = 32) -> tuple[list[Operation], list[SSAValue]]
¶
Return move operations to a registers (a0, a1, ... | fa0, fa1, ...).
Source code in xdsl/backend/riscv/lowering/utils.py
move_to_unallocated_regs(values: Iterable[SSAValue], value_types: Iterable[Attribute], flen: int = 64, xlen: int = 32) -> tuple[list[Operation], list[SSAValue]]
¶
Return move operations to unallocated registers.
Source code in xdsl/backend/riscv/lowering/utils.py
cast_operands_to_regs(rewriter: PatternRewriter, operation: Operation) -> list[SSAValue]
¶
Add cast operations just before the targeted operation if the operands were not already int registers.
Source code in xdsl/backend/riscv/lowering/utils.py
cast_op_results(builder: Builder, op: Operation) -> list[SSAValue]
¶
Add cast operations just after the provided operation, to preserve the type validity of arguments of uses of results.
Source code in xdsl/backend/riscv/lowering/utils.py
cast_block_args_from_a_regs(block: Block, rewriter: PatternRewriter)
¶
Change the type of the block arguments to "a" registers and add cast operations just
after the block entry. Use fa0, fa1, etc for floating-point values and a0, a1,
etc for integer values and pointers. The register index is separate for integer and
floating-point registers according to the RISC-V ABI.
Source code in xdsl/backend/riscv/lowering/utils.py
cast_block_args_to_regs(block: Block, rewriter: PatternRewriter)
¶
Change the type of the block arguments to registers and add cast operations just after the block entry.