2 Copyright (C) 2010, 2011 Free Software Foundation, Inc.
3 Contributed by Intel Corporation.
4 This file is part of the GNU C Library.
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.
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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 /* for strlen only SHARED version is optimized, for strcat, strncat, strnlen both STATIC and SHARED are optimized */
22 #if (defined USE_AS_STRNLEN || defined USE_AS_STRCAT || defined SHARED) && !defined NOT_IN_libc
24 # ifndef USE_AS_STRCAT
31 # ifdef USE_AS_STRNLEN
32 # define LEN PARMS + 8
33 # define CFI_PUSH(REG) \
34 cfi_adjust_cfa_offset (4); \
35 cfi_rel_offset (REG, 0)
37 # define CFI_POP(REG) \
38 cfi_adjust_cfa_offset (-4); \
41 # define PUSH(REG) pushl REG; CFI_PUSH (REG)
42 # define POP(REG) popl REG; CFI_POP (REG)
44 # define RETURN POP (%edi); CFI_PUSH(%edi); ret
48 # define STRLEN __strlen_sse2
54 # ifdef USE_AS_STRNLEN
58 jbe L(len_less4_prolog)
71 # ifdef USE_AS_STRNLEN
73 jbe L(len_less8_prolog)
85 # ifdef USE_AS_STRNLEN
87 jbe L(len_less12_prolog)
99 # ifdef USE_AS_STRNLEN
101 jbe L(len_less16_prolog)
118 # ifdef USE_AS_STRNLEN
125 pcmpeqb (%eax), %xmm0
132 pcmpeqb (%eax), %xmm1
139 pcmpeqb (%eax), %xmm2
146 pcmpeqb (%eax), %xmm3
152 # ifdef USE_AS_STRNLEN
157 pcmpeqb (%eax), %xmm0
163 pcmpeqb (%eax), %xmm1
169 pcmpeqb (%eax), %xmm2
175 pcmpeqb (%eax), %xmm3
181 # ifdef USE_AS_STRNLEN
186 pcmpeqb (%eax), %xmm0
192 pcmpeqb (%eax), %xmm1
198 pcmpeqb (%eax), %xmm2
204 pcmpeqb (%eax), %xmm3
210 # ifdef USE_AS_STRNLEN
215 pcmpeqb (%eax), %xmm0
221 pcmpeqb (%eax), %xmm1
227 pcmpeqb (%eax), %xmm2
233 pcmpeqb (%eax), %xmm3
239 # ifdef USE_AS_STRNLEN
249 # ifdef USE_AS_STRNLEN
254 movaps 16(%eax), %xmm1
255 movaps 32(%eax), %xmm2
256 movaps 48(%eax), %xmm6
264 jz L(aligned_64_loop)
266 pcmpeqb -64(%eax), %xmm3
278 pcmpeqb -32(%eax), %xmm3
341 # ifdef USE_AS_STRNLEN
348 pcmpeqb (%eax), %xmm0
356 jbe L(return_start_len)
358 pcmpeqb (%eax), %xmm1
365 jbe L(return_start_len)
367 pcmpeqb (%eax), %xmm0
374 jbe L(return_start_len)
376 pcmpeqb (%eax), %xmm1
390 jz L(strnlen_exit_high)
397 jnz L(strnlen_exit_tail1)
399 jnz L(strnlen_exit_tail2)
401 jb L(return_start_len)
408 jnz L(strnlen_exit_tail4)
410 jnz L(strnlen_exit_tail5)
412 jnz L(strnlen_exit_tail6)
414 jb L(return_start_len)
419 L(strnlen_exit_high):
422 jz L(strnlen_exit_high_8)
424 jnz L(strnlen_exit_tail8)
426 jnz L(strnlen_exit_tail9)
428 jnz L(strnlen_exit_tail10)
430 jb L(return_start_len)
435 L(strnlen_exit_high_8):
437 jnz L(strnlen_exit_tail12)
439 jnz L(strnlen_exit_tail13)
441 jnz L(strnlen_exit_tail14)
443 jb L(return_start_len)
448 L(strnlen_exit_tail1):
450 jb L(return_start_len)
455 L(strnlen_exit_tail2):
457 jb L(return_start_len)
462 L(strnlen_exit_tail4):
464 jb L(return_start_len)
469 L(strnlen_exit_tail5):
471 jb L(return_start_len)
476 L(strnlen_exit_tail6):
478 jb L(return_start_len)
483 L(strnlen_exit_tail8):
485 jb L(return_start_len)
490 L(strnlen_exit_tail9):
492 jb L(return_start_len)
497 L(strnlen_exit_tail10):
499 jb L(return_start_len)
504 L(strnlen_exit_tail12):
506 jb L(return_start_len)
511 L(strnlen_exit_tail13):
513 jb L(return_start_len)
518 L(strnlen_exit_tail14):
520 jb L(return_start_len)
529 /* for prolog only */
584 L(len_less12_prolog):
608 L(len_less16_prolog):
691 # ifndef USE_AS_STRCAT