fix(riscv): correct Zcmp rlist=5 register count - #244
Closed
carlosqwqqwq wants to merge 1 commit into
Closed
Conversation
carlosqwqqwq
force-pushed
the
fix-riscv-zcmp-rlist5
branch
from
August 11, 2026 22:14
5b2f666 to
8170d4b
Compare
Member
|
Thank you for reporting the Zcmp rlist=5 defect. I independently reproduced issue #243 against the current RISC-V Zcmp register-list and stack-adjustment tables and an LLVM decoder oracle, then reimplemented the correction across compressed decode sizing, direct execution, disassembly, and SMIR/JIT in #231. No commits or code from this PR were taken. Your contribution is credited through the co-author trailer on the rollup commit. I’m closing this PR as superseded by the consolidation in #231. Please review the consolidated implementation there, particularly the rlist=5/rlist=6 boundary and the RV32/RV64 stack adjustments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(riscv): correct Zcmp rlist=5 register count
Closes #243
Summary
The RISC-V Zcmp specification maps the CM.PUSH/CM.POP rlist encoding 5 to two saved registers ({ra, s0}). The affected RAX implementation counts rlist=5 as three registers ({ra, s0, s1}) in the interpreter, in the compressed decoder, and in the SMIR lifter, so the stack adjustment is too large and s1 is spuriously saved and restored. For example,
cm.push {ra, s0}, -32(raw halfword 0xB852) produces a stack adjustment of 48 instead of the normative 32, and stores ra, s0 and s1 instead of ra and s0.The fix corrects the register-count table in all three places so rlist=5 counts two registers and rlist=6 keeps the three-register meaning, and updates the decode and translated-path tests to the normative semantics.
Validation
zcmp_rlist5_saves_two_registersfails on the base checkout and passes with the fix.cargo test --lib: full library test suite passes with no regressions.No new upstream test files are added; this is a source-only change.