[6/9] RISC-V: Add minimal Smsdid extension support
Checks
Commit Message
This adds minimal support for the Smsdid[1] (Machine-mode supervisor domain
ID) extension, which depends on Zicsr.
[1] https://github.com/riscv/riscv-smmtt
gcc/ChangeLog:
* config/riscv/riscv-ext.def (smsdid): Add new extension.
* config/riscv/riscv-ext.opt: Ditto.
* doc/riscv-ext.texi: Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/smsdid-version.c: New test.
---
gcc/config/riscv/riscv-ext.def | 13 +++++++++++++
gcc/config/riscv/riscv-ext.opt | 2 ++
gcc/doc/riscv-ext.texi | 4 ++++
gcc/testsuite/gcc.target/riscv/smsdid-version.c | 15 +++++++++++++++
4 files changed, 34 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/riscv/smsdid-version.c
Comments
On 7/17/2026 9:15 AM, Jiawei wrote:
> This adds minimal support for the Smsdid[1] (Machine-mode supervisor domain
> ID) extension, which depends on Zicsr.
>
> [1] https://github.com/riscv/riscv-smmtt
>
> gcc/ChangeLog:
>
> * config/riscv/riscv-ext.def (smsdid): Add new extension.
> * config/riscv/riscv-ext.opt: Ditto.
> * doc/riscv-ext.texi: Ditto.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/riscv/smsdid-version.c: New test.
I don't think this has hit the frozen state yet. So I think this needs
to wait.
jeff
On 2026/7/19 11:25, Jeffrey Law wrote:
>
>
> On 7/17/2026 9:15 AM, Jiawei wrote:
>> This adds minimal support for the Smsdid[1] (Machine-mode supervisor
>> domain
>> ID) extension, which depends on Zicsr.
>>
>> [1] https://github.com/riscv/riscv-smmtt
>>
>> gcc/ChangeLog:
>>
>> * config/riscv/riscv-ext.def (smsdid): Add new extension.
>> * config/riscv/riscv-ext.opt: Ditto.
>> * doc/riscv-ext.texi: Ditto.
>>
>> gcc/testsuite/ChangeLog:
>>
>> * gcc.target/riscv/smsdid-version.c: New test.
> I don't think this has hit the frozen state yet. So I think this
> needs to wait.
>
> jeff
I apologize for confusing the current status of Smmtt. It has entered
the freeze
phase but has not been officially forzen, I confused them. I will
suspend this patch.
https://riscv.atlassian.net/jira/software/c/projects/RVS/list?jql=project%20%3D%20RVS%20AND%20textfields%20~%20%22smmtt*%22%20ORDER%20BY%20cf%5B10019%5D%20ASC
Thank you for your careful review again.
Regards,
Jiawei
@@ -1858,6 +1858,19 @@ DEFINE_RISCV_EXT(
/* BITMASK_BIT_POSITION*/ BITMASK_NOT_YET_ALLOCATED,
/* EXTRA_EXTENSION_FLAGS */ 0)
+DEFINE_RISCV_EXT(
+ /* NAME */ smsdid,
+ /* UPPERCASE_NAME */ SMSDID,
+ /* FULL_NAME */ "Machine-mode supervisor domain ID extension",
+ /* DESC */ "",
+ /* URL */ ,
+ /* DEP_EXTS */ ({"zicsr"}),
+ /* SUPPORTED_VERSIONS */ ({{1, 0}}),
+ /* FLAG_GROUP */ sm,
+ /* BITMASK_GROUP_ID */ BITMASK_NOT_YET_ALLOCATED,
+ /* BITMASK_BIT_POSITION*/ BITMASK_NOT_YET_ALLOCATED,
+ /* EXTRA_EXTENSION_FLAGS */ 0)
+
DEFINE_RISCV_EXT(
/* NAME */ smstateen,
/* UPPERCASE_NAME */ SMSTATEEN,
@@ -375,6 +375,8 @@ Mask(SMNPM) Var(riscv_sm_subext)
Mask(SMRNMI) Var(riscv_sm_subext)
+Mask(SMSDID) Var(riscv_sm_subext)
+
Mask(SMSTATEEN) Var(riscv_sm_subext)
Mask(SMDBLTRP) Var(riscv_sm_subext)
@@ -550,6 +550,10 @@
@tab 1.0
@tab Resumable non-maskable interrupts
+@item @samp{smsdid}
+@tab 1.0
+@tab Machine-mode supervisor domain ID extension
+
@item @samp{smstateen}
@tab 1.0
@tab State enable extension
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mriscv-attribute -march=rv64i_smsdid1p0 -mabi=lp64" { target { rv64 } } } */
+/* { dg-options "-mriscv-attribute -march=rv32i_smsdid1p0 -mabi=ilp32" { target { rv32 } } } */
+
+#ifndef __riscv_smsdid
+#error "Feature macro for 'smsdid' not defined"
+#endif
+
+int
+foo (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-assembler ".attribute arch, .*smsdid1p0" } } */