]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Add support for resumable non-maskable interrupt (RNMI) handlers
authorChristoph Müllner <christoph.muellner@vrull.eu>
Thu, 24 Jul 2025 21:08:40 +0000 (23:08 +0200)
committerChristoph Müllner <christoph.muellner@vrull.eu>
Fri, 25 Jul 2025 07:35:50 +0000 (09:35 +0200)
commit1603eeb6c8ea9cf68762a7755307077c7fb143d3
tree782e8228534194007dc838268eba6bd9feae7c67
parent2142ff28a8efec0a9701c3c2f6fe965ebde9bd41
RISC-V: Add support for resumable non-maskable interrupt (RNMI) handlers

The Smrnmi extension introduces the nmret instruction to return from RNMI
handlers.  We already have basic Smrnmi support.  This patch introduces
support for the nmret instruction and the ability to set the function
attribute `__attribute__ ((interrupt ("rnmi")))` to let the compiler
generate RNMI handlers.

The attribute name is proposed in a PR for the RISC C API and approved
by LLVM maintainers:
  https://github.com/riscv-non-isa/riscv-c-api-doc/pull/116

gcc/ChangeLog:

* config/riscv/riscv.cc (enum riscv_privilege_levels): Add
RNMI_MODE.
(riscv_handle_type_attribute): Handle 'rnmi' interrupt attribute.
(riscv_expand_epilogue): Generate nmret for RNMI handlers.
(riscv_get_interrupt_type): Handle 'rnmi' interrupt attribute.
* config/riscv/riscv.md (riscv_rnmi): Add nmret INSN.
* doc/extend.texi: Add documentation for 'rnmi' interrupt attribute.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/interrupt-rnmi.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/config/riscv/riscv.cc
gcc/config/riscv/riscv.md
gcc/doc/extend.texi
gcc/testsuite/gcc.target/riscv/interrupt-rnmi.c [new file with mode: 0644]