RISC-V: Implement __builtin_thread_pointer
authorKito Cheng <kito.cheng@sifive.com>
Tue, 7 Jul 2020 08:20:53 +0000 (16:20 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 9 Jul 2020 06:51:00 +0000 (14:51 +0800)
commit1073b500e5d33af8b75567108a8c04fe2598df2b
tree53722ec431b5e5d16c38b3c81f16cd6fb862d800
parent4c0d1322033ce979532425d336530b217f6b5fd3
RISC-V: Implement __builtin_thread_pointer

RISC-V has a dedicate register for thread pointer which is specified in psABI
doc, so we could support __builtin_thread_pointer in straightforward way.

Note: clang/llvm was supported __builtin_thread_pointer for RISC-V port
recently.
- https://reviews.llvm.org/rGaabc24acf0d5f8677bd22fe9c108581e07c3e180

gcc/ChangeLog:

* config/riscv/riscv.md (get_thread_pointer<mode>): New.
(TP_REGNUM): Ditto.
* doc/extend.texi (Target Builtins): Add RISC-V built-in section.
Document __builtin_thread_pointer.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/read-thread-pointer.c: New.
gcc/config/riscv/riscv.md
gcc/doc/extend.texi
gcc/testsuite/gcc.target/riscv/read-thread-pointer.c [new file with mode: 0644]