Skip to content

simx: reject RV32 shift-immediate code points with shamt[5] set - #411

Open
Lfan-ke wants to merge 1 commit into
vortexgpgpu:masterfrom
Lfan-ke:fix/rvc-shamt5-rv32
Open

simx: reject RV32 shift-immediate code points with shamt[5] set#411
Lfan-ke wants to merge 1 commit into
vortexgpgpu:masterfrom
Lfan-ke:fix/rvc-shamt5-rv32

Conversation

@Lfan-ke

@Lfan-ke Lfan-ke commented Sep 3, 2026

Copy link
Copy Markdown

The Zca spec reserves shamt[5]=1 for custom extensions when XLEN=32:

For XLEN=32, shamt[5] must be zero; the code points with shamt[5]=1 are designated for custom extensions.

— stated for c.slli and c.srli, with c.srai defined analogously.

rvc_decompress expanded those code points regardless, emitting a 32-bit shift by 32 or more, which is itself an illegal encoding on RV32. This flags them instead, following the guard already used for the RV64-only c.subw / c.addw.

Verification

rvc_decompress on the three encodings, built for each XLEN:

                XLEN=32              XLEN=64
c.slli shamt5=1 illegal              0x02009093
c.srli shamt5=1 illegal              0x02045413
c.srai shamt5=1 illegal              0x42045413
c.slli shamt5=0 0x00409093           0x00409093

RV64 and every shamt[5]=0 encoding are unchanged. decompressor.cpp compiles clean under -Wall -Wextra -Werror for both XLEN values.

The Zca spec reserves shamt[5]=1 in c.slli, c.srli and c.srai for custom
extensions when XLEN=32. The decompressor expanded them anyway, producing a
32-bit shift by 32 or more — itself an illegal encoding on RV32 — instead of
reporting the compressed instruction as illegal.

Flag them, following the existing guard for the RV64-only c.subw and c.addw.
RV64 is unaffected, where shamt[5] is a valid part of the shift amount.

Signed-off-by: Leo Cheng <chengkelfan@qq.com>
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.

1 participant