~vorlon/ubuntu/natty/eglibc/multiarch

« back to all changes in this revision

Viewing changes to sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S

  • Committer: Steve Langasek
  • Date: 2011-02-18 21:18:44 UTC
  • mfrom: (103.1.7 eglibc)
  • Revision ID: steve.langasek@linaro.org-20110218211844-lodmi8b1qhyq3f3x
Tags: 2.13~pre1-0ubuntu1+multiarch.1
merge from natty

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* strlen with SSE2 and BSF
 
2
   Copyright (C) 2010 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
#if defined SHARED && !defined NOT_IN_libc
 
22
 
 
23
#include <sysdep.h>
 
24
#include "asm-syntax.h"
 
25
 
 
26
#define CFI_PUSH(REG)                                           \
 
27
  cfi_adjust_cfa_offset (4);                                    \
 
28
  cfi_rel_offset (REG, 0)
 
29
 
 
30
#define CFI_POP(REG)                                            \
 
31
  cfi_adjust_cfa_offset (-4);                                   \
 
32
  cfi_restore (REG)
 
33
 
 
34
#define PUSH(REG)       pushl REG; CFI_PUSH (REG)
 
35
#define POP(REG)        popl REG; CFI_POP (REG)
 
36
#define PARMS           4 + 8   /* Preserve ESI and EDI.  */
 
37
#define STR             PARMS
 
38
#define ENTRANCE        PUSH (%esi); PUSH (%edi); cfi_remember_state
 
39
#define RETURN          POP (%edi); POP (%esi); ret; \
 
40
                        cfi_restore_state; cfi_remember_state
 
41
 
 
42
        .text
 
43
ENTRY ( __strlen_sse2_bsf)
 
44
        ENTRANCE
 
45
        mov     STR(%esp), %edi
 
46
        xor     %eax, %eax
 
47
        mov     %edi, %ecx
 
48
        and     $0x3f, %ecx
 
49
        pxor    %xmm0, %xmm0
 
50
        cmp     $0x30, %ecx
 
51
        ja      L(next)
 
52
        movdqu  (%edi), %xmm1
 
53
        pcmpeqb %xmm1, %xmm0
 
54
        pmovmskb %xmm0, %edx
 
55
        test    %edx, %edx
 
56
        jnz     L(exit_less16)
 
57
        mov     %edi, %eax
 
58
        and     $-16, %eax
 
59
        jmp     L(align16_start)
 
60
L(next):
 
61
 
 
62
        mov     %edi, %eax
 
63
        and     $-16, %eax
 
64
        pcmpeqb (%eax), %xmm0
 
65
        mov     $-1, %esi
 
66
        sub     %eax, %ecx
 
67
        shl     %cl, %esi
 
68
        pmovmskb %xmm0, %edx
 
69
        and     %esi, %edx
 
70
        jnz     L(exit)
 
71
L(align16_start):
 
72
        pxor    %xmm0, %xmm0
 
73
        pxor    %xmm1, %xmm1
 
74
        pxor    %xmm2, %xmm2
 
75
        pxor    %xmm3, %xmm3
 
76
        .p2align 4
 
77
L(align16_loop):
 
78
        pcmpeqb 16(%eax), %xmm0
 
79
        pmovmskb %xmm0, %edx
 
80
        test    %edx, %edx
 
81
        jnz     L(exit16)
 
82
 
 
83
        pcmpeqb 32(%eax), %xmm1
 
84
        pmovmskb %xmm1, %edx
 
85
        test    %edx, %edx
 
86
        jnz     L(exit32)
 
87
 
 
88
        pcmpeqb 48(%eax), %xmm2
 
89
        pmovmskb %xmm2, %edx
 
90
        test    %edx, %edx
 
91
        jnz     L(exit48)
 
92
 
 
93
        pcmpeqb 64(%eax), %xmm3
 
94
        pmovmskb %xmm3, %edx
 
95
        lea     64(%eax), %eax
 
96
        test    %edx, %edx
 
97
        jz      L(align16_loop)
 
98
L(exit):
 
99
        sub     %edi, %eax
 
100
L(exit_less16):
 
101
        bsf     %edx, %edx
 
102
        add     %edx, %eax
 
103
        RETURN
 
104
L(exit16):
 
105
        sub     %edi, %eax
 
106
        bsf     %edx, %edx
 
107
        add     %edx, %eax
 
108
        add     $16, %eax
 
109
        RETURN
 
110
L(exit32):
 
111
        sub     %edi, %eax
 
112
        bsf     %edx, %edx
 
113
        add     %edx, %eax
 
114
        add     $32, %eax
 
115
        RETURN
 
116
L(exit48):
 
117
        sub     %edi, %eax
 
118
        bsf     %edx, %edx
 
119
        add     %edx, %eax
 
120
        add     $48, %eax
 
121
        POP (%edi)
 
122
        POP (%esi)
 
123
        ret
 
124
 
 
125
END ( __strlen_sse2_bsf)
 
126
 
 
127
#endif