Skip to content

Use fd/fs# operand names for floating-point registers - #444

Merged
Andrew Waterman (aswaterman) merged 3 commits into
riscv:masterfrom
leo7martins:fp-operand-naming
Nov 25, 2026
Merged

Andrew Waterman (aswaterman) merged 3 commits into
riscv:masterfrom
leo7martins:fp-operand-naming

Conversation

@leo7martins

@leo7martins leo7martins commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #190.

As requested in the issue, this renames the floating-point register operands from rd/rs1/rs2/rs3 to fd/fs1/fs2/fs3 across the extension files, matching the naming the ISA manual already uses for FP operands. The naming is now consistent with how the manual (#1094) and the assembler conventions distinguish FP registers from integer registers.

What changed

  • extensions/ (23 files, 226 instruction entries): rv_f, rv_d, rv_q, rv_zfh, rv_zfhmin, rv_d_zfhmin, rv_q_zfhmin, rv64_d/rv64_f/rv64_q/rv64_zfh, rv_c_d, rv32_c_f, the *_zfa variants, rv_zfbfmin, rv32_zclsd, rv_v, rv_zvfbfwma.
    • Load/store: flw→fd, fsw→fs2; compressed variants get fd_p/fs2_p/c_fs2 (and the Zclsd equivalents with the _e suffixes).
    • Arithmetic 4-operand (fmadd-family): fd/fs1/fs2/fs3; 3-operand (fadd-family, fmin/fmax and the Zfa min/max/round variants): fd/fs1/fs2.
    • Compare/fclass/convert-to-integer keep the integer rd (or rs1 for X→FP), since that operand really is an integer register; fmv.x.* keeps rd and fmv.*.x keeps rs1.
  • arg_lut.csv: the new fd/fs1/fs2/fs3 (and compressed variants) entries sit at the same bit positions as their rd/rs# parents.
  • src/riscv_opcodes/constants.py: latex_mapping aliases each new name to the exact rendering its parent already used (e.g. fd_p → rd\,$'$), so LaTeX output is unchanged.
  • tests/test.py: new FloatingPointOperandNamingTest covering the naming in the extension files, the arg_lut rows, and the LaTeX renderings (17 → 20 tests, all passing).

Outputs are unchanged

None of the generated artifacts change, which was the acceptance criterion in the issue:

  • instr-table.tex, priv-instr-table.tex, inst.go, inst.rs, inst.sverilog: byte-identical to a baseline generated at the parent commit.
  • inst.chisel: identical content; the only machine-produced file whose text ordering shifts is discussed below.
  • The committed encoding.h is untouched. Only the (untracked, build-time) encoding.out.h is affected, gaining the new INSN_FIELD_FD/INSN_FIELD_FS1/... macros and INSN_FIELD_RS2_EQ_RS1 → INSN_FIELD_FS2_EQ_FS1.

Notes

  • NyembeziIMG said in July 2024, “We will schedule work on our side for this and aim to contribute.” No PR followed; if that work resurfaces, I’m happy to coordinate.
  • This change and its tests were prepared with an AI coding assistant (Mistral Vibe). The assistant reports running tests/test.py (20 passed) and byte-comparing generated outputs against the parent commit. GitHub workflows are awaiting maintainer approval; no human review or independent human testing is claimed.

Rename the floating-point destination/source operands from rd/rs1/rs2/rs3
to fd/fs1/fs2/fs3 (and their compressed/H-extension variants) across the
extension files, following the ISA manual's naming convention for FP
register operands. Closes riscv#190.

- Rename operands in 23 extension files: rv_f, rv_d, rv_q, rv_zfh,
  rv_zfhmin, rv_d_zfhmin, rv_q_zfhmin, the rv64 variants, rv_c_d,
  rv32_c_f, the *_zfa variants, rv_zfbfmin, rv32_zclsd, rv_v and
  rv_zvfbfwma (226 instruction entries in total).
- Add the fd/fs# entries to arg_lut.csv at the same bit positions as
  their rd/rs# parents.
- Alias the new names to the existing LaTeX renderings in constants.py,
  so every generated format renders exactly what it rendered before.
- Add unit tests covering the naming in extension files, the arg_lut
  rows, and the LaTeX renderings.

All outputs are unchanged: instr-table.tex, priv-instr-table.tex, inst.go,
inst.rs, inst.sverilog and inst.chisel are byte-identical to a baseline
generated before this change, and the committed encoding.h is unchanged
as well. Only the untracked encoding.out.h is affected, gaining the new
INSN_FIELD_FD/FS*/... macros.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

Signed-off-by: leo7martins <219400372+leo7martins@users.noreply.github.com>
Comment thread extensions/rv32_zclsd Outdated
#quadrant 2
$pseudo_op rv32_c_f::c.flwsp c.ldsp rd_n0_e c_uimm9sphi c_uimm9splo 1..0=2 15..13=3 7=0
$pseudo_op rv32_c_f::c.fswsp c.sdsp c_rs2_e c_uimm9sp_s 2..0=2 15..13=7
$pseudo_op rv32_c_f::c.flwsp c.ldsp fd_n0_e c_uimm9sphi c_uimm9splo 1..0=2 15..13=3 7=0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c.flwsp doesn't impose the != 0 requirement (and the fd_n0_e token can be deleted down below). Ping me when this is ready to merge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Andrew Waterman (@aswaterman) Thanks for the review. Addressed in f8bc6a3: the Zclsd c.ldsp pseudo-op is back to rd_n0_e, since the nonzero, even constraint comes from c.ldsp's integer register pair and not from c.flwsp. The fd_n0_e token is gone from arg_lut.csv and the LaTeX mapping. A second commit, d9b8227, fixes isort/black/pyright findings in the new tests.

An AI agent re-ran the checks locally on Python 3.12: python -m unittest -b tests/test.py passes (20 tests), pre-commit run --all-files passes, and generating all outputs works. Apart from the removed INSN_FIELD_FD_N0_E macro in encoding.out.h, the generated outputs are the same as before this change. The earlier build (3.9) failure happened because setup-python couldn't find 3.9 on the ubuntu-26.04 runner. It wasn't caused by this PR, and master has since dropped 3.9 (#443).

This should be ready to merge from my side once CI is green.

This change was prepared with an AI coding assistant.

c.flwsp has no rd != 0 restriction; the nonzero, even constraint
belongs to the integer register pair of c.ldsp. Restore rd_n0_e on the
c.ldsp pseudo-op and delete the now-unused fd_n0_e token from
arg_lut.csv and the LaTeX mapping.

Signed-off-by: leo7martins <219400372+leo7martins@users.noreply.github.com>
Apply isort/black formatting and add the type annotations pyright
requires on the _extension_file helper.

Signed-off-by: leo7martins <219400372+leo7martins@users.noreply.github.com>
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.89%. Comparing base (4644ba3) to head (d9b8227).
⚠️ Report is 33 commits behind head on master.

Files with missing lines Patch % Lines
tests/test.py 97.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #444      +/-   ##
==========================================
- Coverage   97.08%   96.89%   -0.20%     
==========================================
  Files          14       14              
  Lines         926      997      +71     
==========================================
+ Hits          899      966      +67     
- Misses         27       31       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aswaterman
Andrew Waterman (aswaterman) merged commit 0a7bd76 into riscv:master Nov 25, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use fd/fs# for floating point operands

2 participants