Projects
openEuler:24.03:SP1:Everything
gcc
_service:tar_scm:0019-LoongArch-Implement-__bui...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:0019-LoongArch-Implement-__builtin_thread_pointer-for-TLS.patch of Package gcc
From 619b6081064bf85a19f4659e278a361875e4f9fb Mon Sep 17 00:00:00 2001 From: chenxiaolong <chenxiaolong@loongson.cn> Date: Tue, 24 Oct 2023 14:40:14 +0800 Subject: [PATCH 019/188] LoongArch: Implement __builtin_thread_pointer for TLS. gcc/ChangeLog: * config/loongarch/loongarch.md (get_thread_pointer<mode>):Adds the instruction template corresponding to the __builtin_thread_pointer function. * doc/extend.texi:Add the __builtin_thread_pointer function support description to the documentation. gcc/testsuite/ChangeLog: * gcc.target/loongarch/builtin_thread_pointer.c: New test. --- gcc/config/loongarch/loongarch.md | 7 +++++++ gcc/doc/extend.texi | 5 +++++ .../gcc.target/loongarch/builtin_thread_pointer.c | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/gcc.target/loongarch/builtin_thread_pointer.c diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index c4c6baa60..80487488d 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -113,6 +113,7 @@ (define_constants [(RETURN_ADDR_REGNUM 1) + (TP_REGNUM 2) (T0_REGNUM 12) (T1_REGNUM 13) (S0_REGNUM 23) @@ -3647,6 +3648,12 @@ [(set_attr "length" "0") (set_attr "type" "ghost")]) +;; Named pattern for expanding thread pointer reference. +(define_expand "get_thread_pointer<mode>" + [(set (match_operand:P 0 "register_operand" "=r") + (reg:P TP_REGNUM))] + "HAVE_AS_TLS" + {}) (define_split [(match_operand 0 "small_data_pattern")] diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 1d1bac255..497c6de5f 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -16257,6 +16257,11 @@ function you need to include @code{larchintrin.h}. void __break (imm0_32767) @end smallexample +Returns the value that is currently set in the @samp{tp} register. +@smallexample + void * __builtin_thread_pointer (void) +@end smallexample + @node MIPS DSP Built-in Functions @subsection MIPS DSP Built-in Functions diff --git a/gcc/testsuite/gcc.target/loongarch/builtin_thread_pointer.c b/gcc/testsuite/gcc.target/loongarch/builtin_thread_pointer.c new file mode 100644 index 000000000..541e3b143 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/builtin_thread_pointer.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls_native } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "or\t\\\$r4,\\\$r2,\\\$r0" } } */ + +void * +get_tp () +{ + return __builtin_thread_pointer (); +} -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2