]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Declare TLSDESC clobbers for vector registers and CSRs per psABI
authorLuke Zhuang <luke.zhuang@linux.alibaba.com>
Thu, 25 Jun 2026 05:45:16 +0000 (13:45 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Wed, 15 Jul 2026 09:29:14 +0000 (17:29 +0800)
commit0748d2c83fc0440f101fe01cc3dfc97c8e11c3b2
treebb702c0a9d8f48d5c44885a8c36d277ff5c4f565
parent8a1346f379a15dc8b79e50656dc5d8728336231c
RISC-V: Declare TLSDESC clobbers for vector registers and CSRs per psABI

Per the RISC-V psABI, the TLSDESC resolver clobbers a0 and t0 in the
base case.  With the new psABI update
(https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/496),
when the V extension is enabled, it additionally clobbers all vector
registers and vector CSRs.

This patch updates the clobbering of tlsdesc define_insn: clobbering
not only a0 and t0, but also all V-regs (using 4 x LMUL8 reg
groups covering all 32 physical V-regs), and 4 vector CSRs
(vl/vtype/vxrm/vxstat).

Three new tests are added covering GPR, vector register, and vector
CSR clobber behavior.

gcc/ChangeLog:

* config/riscv/riscv.md (VXSAT_REGNUM): New constant.
(@tlsdesc<mode>): update clobbering.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/tlsdesc_clobber.c: New test.
* gcc.target/riscv/tlsdesc_clobber_v.c: New test.
* gcc.target/riscv/tlsdesc_clobber_v_csr.c: New test.
gcc/config/riscv/riscv.md
gcc/testsuite/gcc.target/riscv/tlsdesc_clobber.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/tlsdesc_clobber_v.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/tlsdesc_clobber_v_csr.c [new file with mode: 0644]