CORE-V: Support CORE-V fast interrupts
Adds support for __attribute__((interrupt("corev-fast", mode))), where
mode is optional and is one of "machine", "supervisor" or "user".
CORE-V fast interrupt functions behave the same as standard RISC-V
interrupt functions except they do not save caller saved registers
(including ra, which the RISC-V ABI defines as caller saved but gcc
treats as callee saved).
gcc/ChangeLog:
* config/riscv/riscv.cc (struct machine_function): Replace
interrupt_mode with interrupt_type.
(struct riscv_interrupt_type): New.
(riscv_attribute_table): Alllow two arguments in interrupt
attribute.
(riscv_handle_type_attribute): Handle optional corev-fast
argument.
(riscv_save_reg_p): Do not save caller saved registers for
interrupt functions if interrupt_type.save_call_used_p is false.
(riscv_compute_frame_info): Do not save prologue temporary
register for interrupt functions if
interrupt_type.save_call_used_p is false.
(riscv_expand_epilogue): Replace interrupt_mode with
interrupt_type.mode.
(riscv_epilogue_uses): Do not add uses for caller saved
registers if interrupt_type.save_call_used_p is false.
(riscv_get_interrupt_type): Construct and return a
riscv_interrupt_type instead of riscv_privilege_levels.
(riscv_set_current_function): Set interrupt_type intead of
interrupt_mode. Check interrupt_type.mode instead of
interrupt_type.
(riscv_merge_decl_attributes): Change riscv_privilege_levels
to riscv_interrupt_type. Add check for matching
save_call_used_p.
* doc/extend.texi: Document new optional "corev-fast" parameter
to RISC-V interrupt attribute.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/interrupt-5.c: Update dg-warning text.
* gcc.target/riscv/cv-interrupt-1.c: New test.
* gcc.target/riscv/cv-interrupt-2.c: New test.
* gcc.target/riscv/cv-interrupt-3.c: New test.
* gcc.target/riscv/cv-interrupt-4.c: New test.
* gcc.target/riscv/cv-interrupt-5.c: New test.
* gcc.target/riscv/cv-interrupt-all-f-1.c: New test.
* gcc.target/riscv/cv-interrupt-all-f-2.c: New test.
* gcc.target/riscv/cv-interrupt-all-x-1.c: New test.
* gcc.target/riscv/cv-interrupt-all-x-2.c: New test.
* gcc.target/riscv/cv-interrupt-all-x-3.c: New test.
* gcc.target/riscv/cv-interrupt-all-x-4.c: New test.
* gcc.target/riscv/cv-interrupt-conflict-type.c: New test.
* gcc.target/riscv/cv-interrupt-debug.c: New test.
* gcc.target/riscv/cv-interrupt-mmode.c: New test.
* gcc.target/riscv/cv-interrupt-smode.c: New test.
* gcc.target/riscv/cv-interrupt-umode.c: New test.