riscv / sail-riscv

Sail RISC-V model
https://lists.riscv.org/g/tech-golden-model
Other
463 stars 168 forks source link

Use newtypes for register indices and numbers #617

Open nwf opened 1 week ago

nwf commented 1 week ago

In preparation for more seriously tackling #523. This PR...

  1. Changes the definition of regidx and regno to be newtypes and updates all use sites appropriately.
  2. Splits vregidx from regidx (and friends) for Vector (vext) registers, which, AFAIK, are a completely separate set of 32 registers.
  3. Splits fregidx from regidx (and friends) for F/D/Zcd/Zcf/Zfa/Zfh and V (again) extensions. There's a little muss and fuss around the definition to do with Zfinx, but otherwise it's also pretty rote.
  4. Stops some punning in Zicsr and splits the CSR ast ctor into CSRImm and CSRReg.

This was a slog. Most of the changes can be described as "type-directed" and "mechanical" but were all done... er, artisanally, so some more careful review is probably merited. Perhaps best viewed with word diff, not line diff.

The curious are welcome to look at https://github.com/nwf/sail-riscv/tree/202411-eext to see how I think we can properly support E atop this base, and indeed, most of these changes were motivated or directed by that work, but I would like to get this reviewed independently of that shuffling and further refactoring.

github-actions[bot] commented 1 week ago

Test Results

396 tests  ±0   396 ✅ ±0   0s ⏱️ ±0s   4 suites ±0     0 💤 ±0    1 files   ±0     0 ❌ ±0 

Results for commit 97a77428. ± Comparison against base commit 8a2e0f56.

:recycle: This comment has been updated with latest results.