~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* wcschr with SSE2, without using bsf instructions
 
2
   Copyright (C) 2011 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
#ifndef NOT_IN_libc
 
22
# include <sysdep.h>
 
23
 
 
24
# define CFI_PUSH(REG)  \
 
25
        cfi_adjust_cfa_offset (4);      \
 
26
        cfi_rel_offset (REG, 0)
 
27
 
 
28
# define CFI_POP(REG)   \
 
29
        cfi_adjust_cfa_offset (-4);     \
 
30
        cfi_restore (REG)
 
31
 
 
32
# define PUSH(REG)      pushl REG; CFI_PUSH (REG)
 
33
# define POP(REG)       popl REG; CFI_POP (REG)
 
34
 
 
35
# define PARMS  4
 
36
# define STR1   PARMS
 
37
# define STR2   STR1+4
 
38
 
 
39
        atom_text_section
 
40
ENTRY (__wcschr_sse2)
 
41
 
 
42
        mov     STR1(%esp), %ecx
 
43
        movd    STR2(%esp), %xmm1
 
44
 
 
45
        mov     %ecx, %eax
 
46
        punpckldq %xmm1, %xmm1
 
47
        pxor    %xmm2, %xmm2
 
48
        punpckldq %xmm1, %xmm1
 
49
 
 
50
        and     $63, %eax
 
51
        cmp     $48, %eax
 
52
        ja      L(cross_cache)
 
53
 
 
54
        movdqu  (%ecx), %xmm0
 
55
        pcmpeqd %xmm0, %xmm2
 
56
        pcmpeqd %xmm1, %xmm0
 
57
        pmovmskb %xmm2, %edx
 
58
        pmovmskb %xmm0, %eax
 
59
        or      %eax, %edx
 
60
        jnz     L(matches)
 
61
        and     $-16, %ecx
 
62
        jmp     L(loop)
 
63
 
 
64
        .p2align 4
 
65
L(cross_cache):
 
66
        PUSH    (%edi)
 
67
        mov     %ecx, %edi
 
68
        mov     %eax, %ecx
 
69
        and     $-16, %edi
 
70
        and     $15, %ecx
 
71
        movdqa  (%edi), %xmm0
 
72
        pcmpeqd %xmm0, %xmm2
 
73
        pcmpeqd %xmm1, %xmm0
 
74
        pmovmskb %xmm2, %edx
 
75
        pmovmskb %xmm0, %eax
 
76
 
 
77
        sarl    %cl, %edx
 
78
        sarl    %cl, %eax
 
79
        test    %eax, %eax
 
80
        jz      L(unaligned_no_match)
 
81
 
 
82
        add     %edi, %ecx
 
83
        POP     (%edi)
 
84
 
 
85
        test    %edx, %edx
 
86
        jz      L(match_case1)
 
87
        test    %al, %al
 
88
        jz      L(match_higth_case2)
 
89
        test    $15, %al
 
90
        jnz     L(match_case2_4)
 
91
        test    $15, %dl
 
92
        jnz     L(return_null)
 
93
        lea     4(%ecx), %eax
 
94
        ret
 
95
 
 
96
        CFI_PUSH (%edi)
 
97
 
 
98
        .p2align 4
 
99
L(unaligned_no_match):
 
100
        mov     %edi, %ecx
 
101
        POP     (%edi)
 
102
 
 
103
        test    %edx, %edx
 
104
        jnz     L(return_null)
 
105
 
 
106
        pxor    %xmm2, %xmm2
 
107
 
 
108
/* Loop start on aligned string.  */
 
109
        .p2align 4
 
110
L(loop):
 
111
        add     $16, %ecx
 
112
        movdqa  (%ecx), %xmm0
 
113
        pcmpeqd %xmm0, %xmm2
 
114
        pcmpeqd %xmm1, %xmm0
 
115
        pmovmskb %xmm2, %edx
 
116
        pmovmskb %xmm0, %eax
 
117
        or      %eax, %edx
 
118
        jnz     L(matches)
 
119
        add     $16, %ecx
 
120
 
 
121
        movdqa  (%ecx), %xmm0
 
122
        pcmpeqd %xmm0, %xmm2
 
123
        pcmpeqd %xmm1, %xmm0
 
124
        pmovmskb %xmm2, %edx
 
125
        pmovmskb %xmm0, %eax
 
126
        or      %eax, %edx
 
127
        jnz     L(matches)
 
128
        add     $16, %ecx
 
129
 
 
130
        movdqa  (%ecx), %xmm0
 
131
        pcmpeqd %xmm0, %xmm2
 
132
        pcmpeqd %xmm1, %xmm0
 
133
        pmovmskb %xmm2, %edx
 
134
        pmovmskb %xmm0, %eax
 
135
        or      %eax, %edx
 
136
        jnz     L(matches)
 
137
        add     $16, %ecx
 
138
 
 
139
        movdqa  (%ecx), %xmm0
 
140
        pcmpeqd %xmm0, %xmm2
 
141
        pcmpeqd %xmm1, %xmm0
 
142
        pmovmskb %xmm2, %edx
 
143
        pmovmskb %xmm0, %eax
 
144
        or      %eax, %edx
 
145
        jz      L(loop)
 
146
 
 
147
        .p2align 4
 
148
L(matches):
 
149
        pmovmskb %xmm2, %edx
 
150
        test    %eax, %eax
 
151
        jz      L(return_null)
 
152
        test    %edx, %edx
 
153
        jz      L(match_case1)
 
154
 
 
155
        .p2align 4
 
156
L(match_case2):
 
157
        test    %al, %al
 
158
        jz      L(match_higth_case2)
 
159
        test    $15, %al
 
160
        jnz     L(match_case2_4)
 
161
        test    $15, %dl
 
162
        jnz     L(return_null)
 
163
        lea     4(%ecx), %eax
 
164
        ret
 
165
 
 
166
        .p2align 4
 
167
L(match_case2_4):
 
168
        mov     %ecx, %eax
 
169
        ret
 
170
 
 
171
        .p2align 4
 
172
L(match_higth_case2):
 
173
        test    %dl, %dl
 
174
        jnz     L(return_null)
 
175
        test    $15, %ah
 
176
        jnz     L(match_case2_12)
 
177
        test    $15, %dh
 
178
        jnz     L(return_null)
 
179
        lea     12(%ecx), %eax
 
180
        ret
 
181
 
 
182
        .p2align 4
 
183
L(match_case2_12):
 
184
        lea     8(%ecx), %eax
 
185
        ret
 
186
 
 
187
        .p2align 4
 
188
L(match_case1):
 
189
        test    %al, %al
 
190
        jz      L(match_higth_case1)
 
191
 
 
192
        test    $0x01, %al
 
193
        jnz     L(exit0)
 
194
        lea     4(%ecx), %eax
 
195
        ret
 
196
 
 
197
        .p2align 4
 
198
L(match_higth_case1):
 
199
        test    $0x01, %ah
 
200
        jnz     L(exit3)
 
201
        lea     12(%ecx), %eax
 
202
        ret
 
203
 
 
204
        .p2align 4
 
205
L(exit0):
 
206
        mov     %ecx, %eax
 
207
        ret
 
208
 
 
209
        .p2align 4
 
210
L(exit3):
 
211
        lea     8(%ecx), %eax
 
212
        ret
 
213
 
 
214
        .p2align 4
 
215
L(return_null):
 
216
        xor     %eax, %eax
 
217
        ret
 
218
 
 
219
END (__wcschr_sse2)
 
220
#endif