Skip to content

Commit f888d5f

Browse files
committed
RISC-V: Remove user-level interrupts
There was once a RISC-V extension draft ("N"), which introduced user-level interrupts. However, it was never ratified and the specification draft has been removed from the RISC-V ISA manual in commit `b6cade07034` with the comment "it'll likely need to be redesigned". Support for a N extension never made it to GCC, but we support fuction attributes for user-level interrupt handlers that use the URET instruction. The "user" interrupt attribute was documented in the RISC-V C API, but has been removed in PR #106 in May 2025 (driven by LLVM devs/ maintainers and ack'ed by at least one GCC maintainer). Let's drop URET support from GCC as well. gcc/ChangeLog: * config/riscv/riscv.cc (enum riscv_privilege_levels): Remove USER_MODE. (riscv_handle_type_attribute): Remove "user" interrupts. (riscv_expand_epilogue): Likewise. (riscv_get_interrupt_type): Likewise. * config/riscv/riscv.md (riscv_uret): Remove URET pattern. * doc/extend.texi: Remove documentation of user interrupts. gcc/testsuite/ChangeLog: * gcc.target/riscv/interrupt-conflict-mode.c: Remove "user" interrupts. * gcc.target/riscv/xtheadint-push-pop.c: Likewise. * gcc.target/riscv/interrupt-umode.c: Removed. Reported-by: Sam Elliott <[email protected]> Signed-off-by: Christoph Müllner <[email protected]>
1 parent 22e5711 commit f888d5f

File tree

6 files changed

+11
-36
lines changed

6 files changed

+11
-36
lines changed

gcc/config/riscv/riscv.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct GTY(()) riscv_frame_info {
170170
};
171171

172172
enum riscv_privilege_levels {
173-
UNKNOWN_MODE, USER_MODE, SUPERVISOR_MODE, MACHINE_MODE, RNMI_MODE
173+
UNKNOWN_MODE, SUPERVISOR_MODE, MACHINE_MODE, RNMI_MODE
174174
};
175175

176176
struct GTY(()) mode_switching_info {
@@ -6929,11 +6929,12 @@ riscv_handle_type_attribute (tree *node ATTRIBUTE_UNUSED, tree name, tree args,
69296929
error ("attribute 'rnmi' requires the Smrnmi ISA extension");
69306930
*no_add_attrs = true;
69316931
}
6932-
else if (strcmp (string, "user") && strcmp (string, "supervisor")
6933-
&& strcmp (string, "machine") && strcmp (string, "rnmi"))
6932+
else if (strcmp (string, "supervisor")
6933+
&& strcmp (string, "machine")
6934+
&& strcmp (string, "rnmi"))
69346935
{
69356936
warning (OPT_Wattributes,
6936-
"argument to %qE attribute is not %<\"user\"%>, %<\"supervisor\"%>, "
6937+
"argument to %qE attribute is not %<\"supervisor\"%>, "
69376938
"%<\"machine\"%>, or %<\"rnmi\"%>", name);
69386939
*no_add_attrs = true;
69396940
}
@@ -9715,14 +9716,12 @@ riscv_expand_epilogue (int style)
97159716

97169717
if (th_int_mask && TH_INT_INTERRUPT (cfun))
97179718
emit_jump_insn (gen_th_int_pop ());
9718-
else if (mode == MACHINE_MODE)
9719-
emit_jump_insn (gen_riscv_mret ());
97209719
else if (mode == SUPERVISOR_MODE)
97219720
emit_jump_insn (gen_riscv_sret ());
97229721
else if (mode == RNMI_MODE)
97239722
emit_jump_insn (gen_riscv_mnret ());
9724-
else
9725-
emit_jump_insn (gen_riscv_uret ());
9723+
else /* Must be MACHINE_MODE. */
9724+
emit_jump_insn (gen_riscv_mret ());
97269725
}
97279726
else if (style != SIBCALL_RETURN)
97289727
{
@@ -12064,9 +12063,7 @@ riscv_get_interrupt_type (tree decl)
1206412063
{
1206512064
const char *string = TREE_STRING_POINTER (TREE_VALUE (attr_args));
1206612065

12067-
if (!strcmp (string, "user"))
12068-
return USER_MODE;
12069-
else if (!strcmp (string, "supervisor"))
12066+
if (!strcmp (string, "supervisor"))
1207012067
return SUPERVISOR_MODE;
1207112068
else if (!strcmp (string, "rnmi"))
1207212069
return RNMI_MODE;

gcc/config/riscv/riscv.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
;; Interrupt handler instructions.
121121
UNSPECV_MRET
122122
UNSPECV_SRET
123-
UNSPECV_URET
124123
UNSPECV_MNRET
125124

126125
;; Blockage and synchronization.
@@ -4167,13 +4166,6 @@
41674166
"sret"
41684167
[(set_attr "type" "ret")])
41694168

4170-
(define_insn "riscv_uret"
4171-
[(return)
4172-
(unspec_volatile [(const_int 0)] UNSPECV_URET)]
4173-
""
4174-
"uret"
4175-
[(set_attr "type" "ret")])
4176-
41774169
(define_insn "riscv_mnret"
41784170
[(return)
41794171
(unspec_volatile [(const_int 0)] UNSPECV_MNRET)]

gcc/doc/extend.texi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,10 +5654,10 @@ You can specify the kind of interrupt to be handled by adding an optional
56545654
parameter to the interrupt attribute like this:
56555655

56565656
@smallexample
5657-
void f (void) __attribute__ ((interrupt ("user")));
5657+
void f (void) __attribute__ ((interrupt ("supervisor")));
56585658
@end smallexample
56595659

5660-
Permissible values for this parameter are @code{user}, @code{supervisor},
5660+
Permissible values for this parameter are @code{supervisor},
56615661
@code{machine}, and @code{rnmi}. If there is no parameter, then it
56625662
defaults to @code{machine}.
56635663

gcc/testsuite/gcc.target/riscv/interrupt-conflict-mode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* Verify proper errors are generated for conflicted interrupt type. */
22
/* { dg-do compile } */
33
/* { dg-options "" } */
4-
void __attribute__ ((interrupt ("user")))
4+
void __attribute__ ((interrupt ("supervisor")))
55
foo(void);
66

77
void __attribute__ ((interrupt ("machine")))

gcc/testsuite/gcc.target/riscv/interrupt-umode.c

Lines changed: 0 additions & 8 deletions
This file was deleted.

gcc/testsuite/gcc.target/riscv/xtheadint-push-pop.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ void func_machine (void)
2020
/* { dg-final { scan-assembler-times {\mth\.ipop\M} 2 { target { rv32 } } } } */
2121

2222

23-
__attribute__ ((interrupt ("user")))
24-
void func_usr (void)
25-
{
26-
f ();
27-
}
28-
2923
__attribute__ ((interrupt ("supervisor")))
3024
void func_supervisor (void)
3125
{

0 commit comments

Comments
 (0)