RISC-V: Deduplicate `ADDI` OpCode and compressed counterparts `C.ADDI`, `C.ADDI16SP` and `C.ADDI4SPN`.
Closes RV-427
What
Reduce the number of Addi related internal opcodes needed and transition to using NonZeroXRegister.
NB: I have introduced a new intermediate Args constructor for Addi with XRegisterParsed as the splitting of the register is required in parser.rs anyway, so it is better to retain this information rather than throw it away.
Why
This is part of the opcode refinement work. The reduced number of internal opcodes and simpler run functionality using read_nz / write_nz makes the JIT work simpler to implement.
How
RISC-V Addi is deduplicated into Nop when rd = x0, Li when just rs1 = x0, and addi when both are non-zero. The run-addi function now only uses NonZeroXRegister.
RISC-V C.Addi, C.Addi16sp and C.Addi4spn all now also use Addi.
Manually Testing
make -C src/riscv all
Benchmarking
master |
This MR | Improvement | |
|---|---|---|---|
| M3 MBP | 5.999 TPS | 6.022 TPS | 0.38% |
| Benchmark Machine | 3.438 TPS | 3.413 TPS | -0.72% |
Regressions
Each of these opcodes has changed in representation in the block cache. Previous Addi can now be Nop, Li or Addi and only uses NonZeroXRegister. All others have changed to Addi instead of CAddi, CAddi16sp or Caddi4spn.
Tasks for the Author
-
Link all Linear issues related to this MR using magic words (e.g. part of, relates to, closes). -
Eliminate dead code and other spurious artefacts introduced in your changes. -
Document new public functions, methods and types. -
Make sure the documentation for updated functions, methods, and types is correct. -
Add tests for bugs that have been fixed. -
Put in reasonable effort to ensure that CI will pass. make -C src/riscvdune build src/lib_riscvdune build src/rust_deps
-
Benchmark performance and populate the table above if needed. -
Explain changes to regression test captures when applicable. -
Write commit messages to reflect the changes they're about. -
Self-review your changes to ensure they are high-quality. -
Complete all of the above before assigning this MR to reviewers.