On 03/29/2018 02:25 PM, Jakub Jelinek wrote:
On Thu, Mar 29, 2018 at 01:28:13PM +0200, Martin Liška wrote:
On 03/28/2018 06:36 PM, Jakub Jelinek wrote:
On Wed, Mar 28, 2018 at 06:30:21PM +0200, Martin Liška wrote:
--- a/gcc/config/linux.c
+++ b/gcc/config/linux.c
@@ -37,3 +37,24 @@ linux_libc_has_function (enum function_class fn_class)
     return false;
   }
+
+/* This hook determines whether a function from libc has a fast implementation
+   FN is present at the runtime.  We override it for i386 and glibc C library
+   as this combination provides fast implementation of mempcpy function.  */
+
+enum libc_speed
+ix86_linux_libc_func_speed (int fn)

Putting a ix86_ function into config/linux.c used by most linux targets is
weird.  Either we multiple linux targets with mempcpy fast, then name it
somehow cpu neutral and let all those CPUs pick it up in config/*/linux.h.
And yes, we do care about i?86-linux.  Or it is for x86 only, and then
it shouldn't be in config/linux.c, but either e.g. static inline in
config/i386/linux.h, or we need config/i386/linux.c if we don't have it
already.

I'm fine with putting the implementation into gcc/config/i386/linux.c. Can you 
please

Can't you just put it into gcc/config/i386/linux-common.h as static inline,
so that it is optimized away whenever not needed?

I would like to put it there, but:

g++ -c   -g  -DIN_GCC     -fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic 
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  
-DHAVE_CONFIG_H -DGENERATOR_FILE -fno-PIE -I. -Ibuild -I../../gcc 
-I../../gcc/build -I../../gcc/../include  -I../../gcc/../libcpp/include  \
        -o build/genpreds.o ../../gcc/genpreds.c
In file included from ./tm.h:38:0,
                 from ../../gcc/genpreds.c:26:
../../gcc/config/i386/linux-common.h: In function ‘libc_speed 
ix86_linux_libc_func_speed(int)’:
../../gcc/config/i386/linux-common.h:137:8: error: use of enum 
‘built_in_function’ without previous declaration
   enum built_in_function f = (built_in_function)fn;
        ^~~~~~~~~~~~~~~~~
../../gcc/config/i386/linux-common.h:137:31: error: ‘built_in_function’ was not 
declared in this scope
   enum built_in_function f = (built_in_function)fn;
                               ^~~~~~~~~~~~~~~~~
../../gcc/config/i386/linux-common.h:137:31: note: suggested alternative: 
‘machine_function’
   enum built_in_function f = (built_in_function)fn;
                               ^~~~~~~~~~~~~~~~~
                               machine_function
../../gcc/config/i386/linux-common.h:144:12: error: ‘BUILT_IN_MEMPCPY’ was not 
declared in this scope
       case BUILT_IN_MEMPCPY:
            ^~~~~~~~~~~~~~~~
Martin


If you really want to add a c file, it better not be called linux.c, because
linux.o for it would clash with linux.o from gcc/config/linux.c.  And,
you'd need to add the whatever.o into extra_objs in gcc/config.gcc and add
rules for it into gcc/config/i386/t-linux (see linux.o in config.gcc and
config/t-linux).

help me how to conditionally build the file?

        Jakub


Reply via email to