RISC-V: Implement TLS Descriptors.
commit97069657c4e40b209c7b774e12faaca13812a86c
authorTatsuyuki Ishi <ishitatsuyuki@gmail.com>
Fri, 29 Mar 2024 05:52:39 +0000 (29 14:52 +0900)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 8 Apr 2024 14:28:05 +0000 (8 22:28 +0800)
treece8ca0338fcab2f48f3a259773ed375ba304818c
parentd5d84487dec06186fd9246b505f44ef68a66d6a2
RISC-V: Implement TLS Descriptors.

This implements TLS Descriptors (TLSDESC) as specified in [1].

The 4-instruction sequence is implemented as a single RTX insn for
simplicity, but this can be revisited later if instruction scheduling or
more flexible RA is desired.

The default remains to be the traditional TLS model, but can be configured
with --with-tls={trad,desc}. The choice can be revisited once toolchain
and libc support ships.

[1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373.

gcc/ChangeLog:

* config/riscv/riscv.opt: Add -mtls-dialect to configure TLS flavor.
* config.gcc: Add --with-tls configuration option to change the
default TLS flavor.
* config/riscv/riscv.h: Add TARGET_TLSDESC determined from
-mtls-dialect and with_tls defaults.
* config/riscv/riscv-opts.h: Define enum riscv_tls_type for the
two TLS flavors.
* config/riscv/riscv-protos.h: Define SYMBOL_TLSDESC symbol type.
* config/riscv/riscv.md: Add instruction sequence for TLSDESC.
* config/riscv/riscv.cc (riscv_symbol_insns): Add instruction
sequence length data for TLSDESC.
(riscv_legitimize_tls_address): Add lowering of TLSDESC.
* doc/install.texi: Document --with-tls for RISC-V.
* doc/invoke.texi: Document -mtls-dialect for RISC-V.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/tls_1.x: Add TLSDESC GD test case.
* gcc.target/riscv/tlsdesc.c: Same as above.
gcc/config.gcc
gcc/config/riscv/riscv-opts.h
gcc/config/riscv/riscv-protos.h
gcc/config/riscv/riscv.cc
gcc/config/riscv/riscv.h
gcc/config/riscv/riscv.md
gcc/config/riscv/riscv.opt
gcc/doc/install.texi
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/riscv/tls_1.x [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/tlsdesc.c [new file with mode: 0644]