Skip to content

rvp for rv32/rv64#2246

Open
chihminchao wants to merge 51 commits intoriscv-software-src:masterfrom
chihminchao:rvp-rv32-rv64
Open

rvp for rv32/rv64#2246
chihminchao wants to merge 51 commits intoriscv-software-src:masterfrom
chihminchao:rvp-rv32-rv64

Conversation

@chihminchao
Copy link
Copy Markdown
Contributor

The PR merges the works, #2210 and #2211 and the main author is @jason01180118. The changes from me are

  1. generate opcode from Refine rvp riscv/riscv-opcodes#409
  2. add disassembler
  3. fix some compilation warnings, names, and corner incorrect behavior

@chihminchao
Copy link
Copy Markdown
Contributor Author

@chihminchao
Copy link
Copy Markdown
Contributor Author

Update : 03/26/2026

  1. add new instructions introduced by 0.20
  2. fix the compilation warning reported by @arromanoff
    all of them are caused by nclip-related ones in 9ed6e1c

@chihminchao
Copy link
Copy Markdown
Contributor Author

update: 03/26/2026

  1. forget to add rvp64 definition to makefile
  2. add missing macro for zip series
  3. make rv64p higher priority by overlap_list
  4. fix opcode typo for wsla ext-p: fix typo riscv/riscv-opcodes#414

jason01180118 and others added 26 commits April 7, 2026 19:55
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
The complete set of instructions added for RV32 are:
  PSSHL.HS SSHL PSSHL.DHS PSSHL.DWS
  PSSHLR.HS SSHLR PSSHLR.DHS PSSHLR.DWS
And for RV64:
  PSSHL.HS PSSHL.WS SHL PNCLIPP.B PNCLIPP.H PNCLIPP.W
  PSSHLR.HS PSSHLR.WS SHLR PNCLIPUP.B PNCLIPUP.H PNCLIPUP.W

reference:
  https://www.jhauser.us/RISCV/ext-P/RVP-instrEncodings-020.pdf
https://www.jhauser.us/RISCV/ext-P/RVP-baseInstrs-Sail-020.txt

Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
make rv64_p instructions higer priority

Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Per the P-extension spec, any instruction that performs saturation must
set the vxsat CSR to 1 when the result is clamped. 70 instructions were
missing this write, addressed here in two ways:

1. Convert P_SAT, P_USAT, and P_USAT_FULL macros from pure expression
   macros to GCC statement expressions that detect when saturation
   occurs and write P.VU.vxsat. This automatically fixes ~42
   instructions that use these macros (nclip/nclipi/nclipr/nclipri
   families, psati, psslai, pssh1sadd, pusati, sati, usati, ssh1sadd,
   sslai, and their packed/double-wide variants).

2. Add explicit vxsat writes to 22 instructions with inline saturation
   logic that bypasses the macros:
   - mulq/mulqr/pmulq/pmulqr: set vxsat on INT_MIN * INT_MIN overflow
   - psas/pssa cross variants: set vxsat from sat_add/sat_sub sat flag
   - pssha/psshar DW variants: set vxsat from ov overflow flag
   - pssha/psshar/ssha/sshar: set vxsat in sshamt >= BIT overflow path
   - pusati_dh/pusati_dw: set vxsat on unsigned range clamping

Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
…_INT128

Replace bare __int128 / unsigned __int128 in psshar_dhs.h and psshar_dws.h
with the int128_t / uint128_t typedefs from fesvr/byteorder.h, and guard
the entire riscv_insn_ext_p list in riscv.mk.in with $(if $(HAVE_INT128),...)
matching the existing pattern for the V extension

Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
@chihminchao
Copy link
Copy Markdown
Contributor Author

Several change in this version

  1. use a new macro to tell clip and sati. The saturation behavior is a little different
  2. return the even register number rather than encoding field
  3. mimic V/Q to check int128 support and use standard in128_t type
  4. simplify abd related calculation
  5. add missing vxsat update for some saturation instructions.

#include "internals.h"
#include "specialize.h"
#include "tracer.h"
#include "p_ext_macros.h"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is causing the CI failure.

Note that Spike CI tests that all commits are functional, so you will need to squash this change into the commit that removed p_ext_macros.h.

Ping me when the PR is ready to merge. Thanks @chihminchao!

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.

4 participants