From be06a8b00ab3d1f410ecd447d8f3a7a6d00e3dad Mon Sep 17 00:00:00 2001 From: Oleg Endo <olegendo@gcc.gnu.org> Date: Tue, 9 Oct 2012 18:59:11 +0000 Subject: [PATCH] re PR target/54760 ([SH] Add __builtin_thread_pointer, __builtin_set_thread_pointer) PR target/54760 * doc/extend.texi (Target Builtins): Add SH built-in section. Document __builtin_thread_pointer and __builtin_set_thread_pointer. From-SVN: r192269 --- gcc/ChangeLog | 6 ++++++ gcc/doc/extend.texi | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6d245742d977..3ee1d6b0da99 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-10-09 Oleg Endo <olegendo@gcc.gnu.org> + + PR target/54760 + * doc/extend.texi (Target Builtins): Add SH built-in section. + Document __builtin_thread_pointer and __builtin_set_thread_pointer. + 2012-10-09 Venkataramanan Kumar <venkataramanan.kumar@amd.com> PR middle-end/53397 diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 9b216df8e1c3..9fd2f27b0fdd 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -8651,6 +8651,7 @@ instructions, but allow the compiler to schedule those calls. * PowerPC Built-in Functions:: * PowerPC AltiVec/VSX Built-in Functions:: * RX Built-in Functions:: +* SH Built-in Functions:: * SPARC VIS Built-in Functions:: * SPU Built-in Functions:: * TI C6X Built-in Functions:: @@ -13687,6 +13688,41 @@ if the VSX instruction set is available. The @samp{vec_vsx_ld} and @samp{vec_vsx_st} builtins will always generate the VSX @samp{LXVD2X}, @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions. +@node SH Built-in Functions +@subsection SH Built-in Functions +The following built-in functions are supported on the SH1, SH2, SH3 and SH4 +families of processors: + +@deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr}) +Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually +used by system code that manages threads and execution contexts. The compiler +normally will not generate code that modifies the contents of @samp{GBR} and +thus the value is preserved across function calls. Changing the @samp{GBR} +value in user code must be done with caution, since the compiler might use +@samp{GBR} in order to access thread local variables. + +@end deftypefn + +@deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void) +Returns the value that is currently set in the @samp{GBR} register. +Memory loads and stores that use the thread pointer as a base address will be +turned into @samp{GBR} based displacement loads and stores, if possible. +For example: +@smallexample +struct my_tcb +@{ + int a, b, c, d, e; +@}; + +int get_tcb_value (void) +@{ + // Generate @samp{mov.l @@(8,gbr),r0} instruction + return ((my_tcb*)__builtin_thread_pointer ())->c; +@} + +@end smallexample +@end deftypefn + @node RX Built-in Functions @subsection RX Built-in Functions GCC supports some of the RX instructions which cannot be expressed in -- GitLab