[PATCH] RISC-V: Support the RVA20S64 and RVA22S64 profiles

Jiawei jiawei@iscas.ac.cn
Sun Nov 22 06:19:04 GMT 2026


Accept rva20s64 and rva22s64 in -march [1, 2]. Include the required
supervisor ISA versions, Ss 1.11 and 1.12 respectively, and Zifencei
in both profiles. RVA22S64 also requires Zihpm, Sscounterenw, Svpbmt
and Svinval. Add readelf tests for the complete ISA attributes.

[1] https://docs.riscv.org/reference/rva20-rvi20-rva22/v1.0/rva20.html
[2] https://docs.riscv.org/reference/rva20-rvi20-rva22/v1.0/rva22.html
---
 bfd/elfxx-riscv.c                          | 11 +++++++++++
 gas/NEWS                                   |  2 ++
 gas/testsuite/gas/riscv/attribute-rva20s.d |  6 ++++++
 gas/testsuite/gas/riscv/attribute-rva22s.d |  6 ++++++
 4 files changed, 25 insertions(+)
 create mode 100644 gas/testsuite/gas/riscv/attribute-rva20s.d
 create mode 100644 gas/testsuite/gas/riscv/attribute-rva22s.d

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 6a02d80bcd3..87705c1d10b 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1448,6 +1448,11 @@ static const struct riscv_profiles riscv_profiles_table[] =
   {"rva20u64", "rv64imafdc_zicsr_zicntr_ziccif_ziccrse_ziccamoa"
    "_zicclsm_za128rs"},
 
+  /* RVA20S64 adds Zifencei and supervisor requirements to RVA20U64.
+     BFD does not currently encode the Sv39 translation mode.  */
+  {"rva20s64", "rv64imafdc_zicsr_zicntr_ziccif_ziccrse_ziccamoa"
+   "_zicclsm_za128rs_zifencei_ss1p11_ssccptr_sstvala_sstvecd_svade_svbare"},
+
   /* RVA22U contains the 'i,m,a,f,d,c,zicsr,zihintpause,zba,zbb,zbs,zicntr,
      zihpm,ziccif,ziccrse,ziccamoa, zicclsm,zic64b,za64rs,zicbom,zicbop,zicboz,
      zfhmin,zkt' as mandatory extensions.  */
@@ -1455,6 +1460,12 @@ static const struct riscv_profiles riscv_profiles_table[] =
    "_zicclsm_zic64b_za64rs_zihintpause_zba_zbb_zbs_zicbom_zicbop"
    "_zicboz_zfhmin_zkt"},
 
+  /* RVA22S64 adds Zifencei and supervisor requirements to RVA22U64.  */
+  {"rva22s64", "rv64imafdcb_zicsr_zicntr_zihpm_ziccif_ziccrse_ziccamoa"
+   "_zicclsm_zic64b_za64rs_zihintpause_zba_zbb_zbs_zicbom_zicbop"
+   "_zicboz_zfhmin_zkt_zifencei_ss1p12_ssccptr_sscounterenw_sstvala_sstvecd"
+   "_svade_svbare_svinval_svpbmt"},
+
   /* RVA23 contains all mandatory base ISA for RVA22U64 and the new extension
      'v,zihintntl,zvfhmin,zvbb,zvkt,zicond,zimop,zcmop,zfa,zawrs' as mandatory
      extensions.  */
diff --git a/gas/NEWS b/gas/NEWS
index 58bbd8bfe1d..998fc0bd596 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -17,6 +17,8 @@
 
 * Add support for new variants and encodings of RISC-V Zvabd extension v0.9.
 
+* Add support for the RISC-V RVA20S64 and RVA22S64 profiles in -march.
+
 * Add support for RISC-V standard extensions:
   ziccamoc 1.0, zama16b v1.0, sspmp v1.0, sspmpen v1.0, smpmpdeleg v1.0
   and shlcofideleg v1.0.
diff --git a/gas/testsuite/gas/riscv/attribute-rva20s.d b/gas/testsuite/gas/riscv/attribute-rva20s.d
new file mode 100644
index 00000000000..6a6a0f01c22
--- /dev/null
+++ b/gas/testsuite/gas/riscv/attribute-rva20s.d
@@ -0,0 +1,6 @@
+#as: -march=rva20s64 -misa-spec=20191213
+#readelf: -A
+#source: empty.s
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicsr2p0_zifencei2p0_zmmul1p0_za128rs1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_ss1p11_ssccptr1p0_sstvala1p0_sstvecd1p0_svade1p0_svbare1p0"
diff --git a/gas/testsuite/gas/riscv/attribute-rva22s.d b/gas/testsuite/gas/riscv/attribute-rva22s.d
new file mode 100644
index 00000000000..275c32f6a12
--- /dev/null
+++ b/gas/testsuite/gas/riscv/attribute-rva22s.d
@@ -0,0 +1,6 @@
+#as: -march=rva22s64 -misa-spec=20191213
+#readelf: -A
+#source: empty.s
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicsr2p0_zifencei2p0_zihintpause2p0_zihpm2p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zfhmin1p0_zca1p0_zcd1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_ss1p12_ssccptr1p0_sscounterenw1p0_sstvala1p0_sstvecd1p0_svade1p0_svbare1p0_svinval1p0_svpbmt1p0"

base-commit: ab4dbb9838795fe09a82d41d86b47de29fbf80f3



More information about the Binutils mailing list