This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 0/6] Thread pointer built-in functions


Hi, following discussion here:
http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00229.html
(and a few other mails in the thread between Richard Sandiford)

A number of targets implement the same name __builtin_thread_pointer(),
__builtin_set_thread_pointer() TLS builtins. This set of patches changes
them into machine-independent builtins, implemented by target hooks.

Currently, the backend interface does not seem to expose any notion of
TLS registers, hence these functions are not really implementable by the
expanders (the default target hooks are simply sorry()).

I have here the associated backend changes for all ports that have those
builtins implemented, namely alpha, arm, s390, xtensa, plus adding the
mips support which was the original reason I started this. I have CCed
the respective port maintainers in the rest of the patches.

It wasn't convenient for me to build/test the alpha, s390, and xtensa
ports, so please bear with me if you see anything wrong (the patches are
simply straightforward changes associated with the builtin).

Thanks,
Chung-Lin

Full ChangeLog:

2012-07-12  Chung-Lin Tang  <cltang@codesourcery.com>

        * targhooks.c (default_expand_builtin_thread_pointer): New.
        (default_expand_builtin_set_thread_pointer): New.
        * targhooks.h (default_expand_builtin_thread_pointer): New.
        (default_expand_builtin_set_thread_pointer): New.
        * target.def (expand_builtin_thread_pointer): New target hook.
        (expand_builtin_set_thread_pointer): New target hook.
        * builtins.c (expand_builtin_thread_pointer): New.
        (expand_builtin_set_thread_pointer): New.
        (expand_builtin): Add BUILT_IN_THREAD_POINTER,
        BUILT_IN_SET_THREAD_POINTER expand cases.
        * builtins.def (BUILT_IN_THREAD_POINTER):
        New __builtin_thread_pointer builtin.
        (BUILT_IN_SET_THREAD_POINTER):
        New __builtin_set_thread_pointer builtin.
        * doc/tm.texi.in: Add BUILT_IN_THREAD_POINTER,
        BUILT_IN_SET_THREAD_POINTER hook entries.
        * doc/tm.texi: Update.

        * config/alpha/alpha.c (alpha_builtin): Remove
        ALPHA_BUILTIN_THREAD_POINTER, ALPHA_BUILTIN_SET_THREAD_POINTER.
        (code_for_builtin): Remove CODE_FOR_load_tp, CODE_FOR_set_tp.
        (alpha_init_builtins): Remove __builtin_thread_pointer,
        __builtin_set_thread_pointer machine-specific builtins.
        (alpha_expand_builtin_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_THREAD_POINTER.
        (alpha_expand_builtin_set_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_SET_THREAD_POINTER.
        (alpha_fold_builtin): Remove ALPHA_BUILTIN_THREAD_POINTER,
        ALPHA_BUILTIN_SET_THREAD_POINTER cases.

        * config/s390/s390.c (s390_builtin,code_for_builtin_64,
        code_for_builtin_31,s390_init_builtins,s390_expand_builtin):
        Remove.
        (s390_expand_builtin_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_THREAD_POINTER.
        (s390_expand_builtin_set_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_SET_THREAD_POINTER.

        * config/xtensa/xtensa.c
        (xtensa_expand_builtin_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_THREAD_POINTER.
        (xtensa_expand_builtin_set_thread_pointer): Add hook function
        for TARGET_EXPAND_BUILTIN_SET_THREAD_POINTER.
        (xtensa_builtin): Remove XTENSA_BUILTIN_THREAD_POINTER and
        XTENSA_BUILTIN_SET_THREAD_POINTER.
        (xtensa_init_builtins): Remove __builtin_thread_pointer,
        __builtin_set_thread_pointer machine-specific builtins.
        (xtensa_fold_builtin): Remove XTENSA_BUILTIN_THREAD_POINTER,
        XTENSA_BUILTIN_SET_THREAD_POINTER cases.
        (xtensa_expand_builtin): Remove XTENSA_BUILTIN_THREAD_POINTER,
        XTENSA_BUILTIN_SET_THREAD_POINTER cases.

        * config/arm/arm.c (arm_builtins): Remove
        ARM_BUILTIN_THREAD_POINTER.
        (arm_init_tls_builtins): Remove function.
        (arm_init_builtins): Remove call to arm_init_tls_builtins().
        (arm_expand_builtin): Remove ARM_BUILTIN_THREAD_POINTER case.
        (arm_expand_builtin_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_THREAD_POINTER.

        * config/mips/mips.c (mips_get_tp): Add 'target' parameter for
        generating to specific reg.
        (mips_legitimize_tls_address): Update calls to mips_get_tp().
        (mips_expand_builtin_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_THREAD_POINTER.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]