]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/i686/multiarch/strspn.S
Add x86 32-bit SSE4.2 string functions.
[thirdparty/glibc.git] / sysdeps / i386 / i686 / multiarch / strspn.S
1 /* Multiple versions of strspn
2 Copyright (C) 2009 Free Software Foundation, Inc.
3 Contributed by Intel Corporation.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
20
21 #include <config.h>
22
23 #ifdef HAVE_SSE4_SUPPORT
24
25 #include <sysdep.h>
26 #include <ifunc-defines.h>
27
28 /* Define multiple versions only for the definition in libc. */
29 #ifndef NOT_IN_libc
30 .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
31 .globl __i686.get_pc_thunk.bx
32 .hidden __i686.get_pc_thunk.bx
33 .p2align 4
34 .type __i686.get_pc_thunk.bx,@function
35 __i686.get_pc_thunk.bx:
36 movl (%esp), %ebx
37 ret
38
39 .text
40 ENTRY(strspn)
41 .type strspn, @gnu_indirect_function
42 pushl %ebx
43 cfi_adjust_cfa_offset (4)
44 cfi_rel_offset (ebx, 0)
45 call __i686.get_pc_thunk.bx
46 addl $_GLOBAL_OFFSET_TABLE_, %ebx
47 cmpl $0, KIND_OFFSET+__cpu_features@GOTOFF(%ebx)
48 jne 1f
49 call __init_cpu_features
50 1: leal __strspn_ia32@GOTOFF(%ebx), %eax
51 testl $(1<<20), CPUID_OFFSET+COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_ECX_OFFSET+__cpu_features@GOTOFF(%ebx)
52 jz 2f
53 leal __strspn_sse42@GOTOFF(%ebx), %eax
54 2: popl %ebx
55 cfi_adjust_cfa_offset (-4);
56 cfi_restore (ebx)
57 ret
58 END(strspn)
59
60 # undef ENTRY
61 # define ENTRY(name) \
62 .type __strspn_ia32, @function; \
63 .globl __strspn_ia32; \
64 .p2align 4
65 __strspn_ia32: cfi_startproc; \
66 CALL_MCOUNT
67 # undef END
68 # define END(name) \
69 cfi_endproc; .size __strspn_ia32, .-__strspn_ia32
70 # undef libc_hidden_builtin_def
71 /* It doesn't make sense to send libc-internal strspn calls through a PLT.
72 The speedup we get from using SSE4.2 instruction is likely eaten away
73 by the indirect call in the PLT. */
74 # define libc_hidden_builtin_def(name) \
75 .globl __GI_strspn; __GI_strspn = __strspn_ia32
76 #endif
77
78 #endif /* HAVE_SSE4_SUPPORT */
79
80 #include "../../strspn.S"