]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Save and restore FCSR in interrupt functions to avoid program errors.
authorJin Ma <jinma@linux.alibaba.com>
Mon, 19 Jun 2023 19:02:47 +0000 (13:02 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 19 Jun 2023 19:02:47 +0000 (13:02 -0600)
commitdbcbc858c71f69da76d1f36d6bb5d72f2db11eda
tree4a9629434541228a56360add55d3ee12dc2fa2de
parent827b2a279fc6ad5bb76e4d2c2eb3432955b5e11c
RISC-V: Save and restore FCSR in interrupt functions to avoid program errors.

In order to avoid interrupt functions to change the FCSR, it needs to be saved
and restored at the beginning and end of the function.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_compute_frame_info): Allocate frame for FCSR.
(riscv_for_each_saved_reg): Save and restore FCSR in interrupt functions.
* config/riscv/riscv.md (riscv_frcsr): New patterns.
(riscv_fscsr): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/interrupt-fcsr-1.c: New test.
* gcc.target/riscv/interrupt-fcsr-2.c: New test.
* gcc.target/riscv/interrupt-fcsr-3.c: New test.
gcc/config/riscv/riscv.cc
gcc/config/riscv/riscv.md
gcc/testsuite/gcc.target/riscv/interrupt-fcsr-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/interrupt-fcsr-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/interrupt-fcsr-3.c [new file with mode: 0644]