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
15 16 17 18 19 20 21 22 23 24 25 | |
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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
move_to_regs(values: Iterable[SSAValue], value_types: Iterable[Attribute], reg_types: Iterable[riscv.RISCVRegisterType]) -> tuple[list[Operation], list[SSAValue]]
Return move operations to a registers (a0, a1, ... | fa0, fa1, ...).
Source code in xdsl/backend/riscv/lowering/utils.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
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
78 79 80 81 82 83 84 85 86 87 88 89 90 | |
a_regs(values: Iterable[SSAValue]) -> Iterator[riscv.RISCVRegisterType]
Source code in xdsl/backend/riscv/lowering/utils.py
93 94 | |
move_to_a_regs(values: Iterable[SSAValue], value_types: Iterable[Attribute]) -> tuple[list[Operation], list[SSAValue]]
Return move operations to a registers (a0, a1, ... | fa0, fa1, ...).
Source code in xdsl/backend/riscv/lowering/utils.py
97 98 99 100 101 102 103 104 | |
move_to_unallocated_regs(values: Iterable[SSAValue], value_types: Iterable[Attribute]) -> tuple[list[Operation], list[SSAValue]]
Return move operations to unallocated registers.
Source code in xdsl/backend/riscv/lowering/utils.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
cast_operands_to_regs(rewriter: PatternRewriter, operation: Operation | None = None) -> 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
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
cast_matched_op_results(rewriter: PatternRewriter) -> list[SSAValue]
Add cast operations just after the matched operation, to preserve the type validity of arguments of uses of results.
Source code in xdsl/backend/riscv/lowering/utils.py
148 149 150 151 152 153 154 | |
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
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
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
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
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.
Source code in xdsl/backend/riscv/lowering/utils.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |