This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Prefer mempcpy to memcpy on x86_64 target (PR middle-end/81657).
On Tue, Mar 13, 2018 at 04:19:21PM +0100, Martin Liška wrote:
> > Yes, see e.g. TARGET_LIBC_HAS_FUNCTION target hook,
> > where in particular linux_libc_has_function deals with various C libraries.
> > Of course, in this case you need another target hook, that is dependent both
> > on the target backend and C library.
> >
> > It would be nice to make the target hook a little bit more generic as well,
> > e.g. pass it enum builtin_function and query if it is fast, slow or
> > unknown, or even some kind of cost, where the caller could ask for cost of
> > BUILT_IN_MEMCPY and BUILT_IN_MEMPCPY and decide based on the relative costs.
>
> Let me start with simple return enum value of FAST,SLOW,UNKNOWN. I've added new hook
> definition to gcc/config/gnu-user.h that will point to gnu_libc_function_implementation.
> I would like to implement the function in gcc/targhooks.c, but I don't know how to
> make ifdef according to target?
Put there just the default implementation (everything is UNKNOWN?).
> One another issue is that built_in_function is enum defined in tree.h. Thus I'll replace the
> callback argument with int, that will be casted. One last issue: am I right that I'll have to define
> TARGET_LIBC_FUNCTION_IMPLEMENTATION in each config file (similar to no_c99_libc_has_function)?
And define the i386/x86_64 glibc one in config/i386/*.h, check there
OPTION_GLIBC and only in that case return something other than UNKNOWN.
And redefine TARGET_LIBC_FUNCTION_IMPLEMENTATION only in that case.
Jakub