[PATCH] D79521: [RISCV] Add SiFive's interrupt modes

Ana Pazos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 14:44:41 PDT 2020


apazos created this revision.
Herald added subscribers: llvm-commits, evandro, luismarques, sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
Herald added a reviewer: aaron.ballman.
Herald added a project: LLVM.

RISC-V already has support for all the standard interrupt modes:
void f (void) _attribute_ ((interrupt ("machine")));
void f (void) _attribute_ ((interrupt ("user")));
void f (void) _attribute_ ((interrupt ("supervisor")));

This patch adds SiFive's interrupt modes which are available in SiFive's IP.

Reference: https://sifive.cdn.prismic.io/sifive/d1984d2b-c9b9-4c91-8de0-d68a5e64fa0f_sifive-interrupt-cookbook-v1p2.pdf

"SiFive-CLIC-preemptible"
void f (void) _attribute_ ((interrupt ("SiFive-CLIC-preemptible")));
In this type of interrupt handler, in the prologue, the mepc and mcause
registers are saved, and interrupts are enabled.  In the epilogue,
interrupts are disabled, and the mepc and mcause registers are restored.
This type of interrupt handler must be @code{machine} mode,and must not
use the frame pointer.

"SiFive-CLIC-stack-swap"
void f (void) _attribute_ ((interrupt ("SiFive-CLIC-stack-swap")));
In this type of interrupt handler, the stack pointer will be swapped with
the @code{mscratch} register in the prologue before the first use of the stack
pointer, and in the epilogue after the last use of the stack pointer.
This type of interrupt handler must be @code{machine} mode.


https://reviews.llvm.org/D79521

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/riscv-interrupt-attr.c
  clang/test/Sema/riscv-sifive-interrupt-attr.c
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h
  llvm/test/CodeGen/RISCV/sifive-interrupt-attr.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79521.262477.patch
Type: text/x-patch
Size: 38844 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200506/edfe6895/attachment.bin>


More information about the llvm-commits mailing list