Added Appro's SSSE3 SHA implementations
[gnutls:gnutls.git] / lib / accelerated / x86 / macosx / openssl-cpuid-x86.s
1 # Copyright (c) 2011-2012, Andy Polyakov <appro@openssl.org>
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7
8 #     * Redistributions of source code must retain copyright notices,
9 #      this list of conditions and the following disclaimer.
10 #
11 #     * Redistributions in binary form must reproduce the above
12 #      copyright notice, this list of conditions and the following
13 #      disclaimer in the documentation and/or other materials
14 #      provided with the distribution.
15 #
16 #     * Neither the name of the Andy Polyakov nor the names of its
17 #      copyright holder and contributors may be used to endorse or
18 #      promote products derived from this software without specific
19 #      prior written permission.
20 #
21 # ALTERNATIVELY, provided that this notice is retained in full, this
22 # product may be distributed under the terms of the GNU General Public
23 # License (GPL), in which case the provisions of the GPL apply INSTEAD OF
24 # those given above.
25 #
26 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
27 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #
38 # *** This file is auto-generated ***
39 #
40 .file   "x86cpuid.s"
41 .text
42 .globl  _OPENSSL_ia32_cpuid
43 .align  4
44 _OPENSSL_ia32_cpuid:
45 L_OPENSSL_ia32_cpuid_begin:
46         pushl   %ebp
47         pushl   %ebx
48         pushl   %esi
49         pushl   %edi
50         xorl    %edx,%edx
51         pushfl
52         popl    %eax
53         movl    %eax,%ecx
54         xorl    $2097152,%eax
55         pushl   %eax
56         popfl
57         pushfl
58         popl    %eax
59         xorl    %eax,%ecx
60         xorl    %eax,%eax
61         btl     $21,%ecx
62         jnc     L000nocpuid
63         movl    20(%esp),%esi
64         movl    %eax,8(%esi)
65         .byte   0x0f,0xa2
66         movl    %eax,%edi
67         xorl    %eax,%eax
68         cmpl    $1970169159,%ebx
69         setne   %al
70         movl    %eax,%ebp
71         cmpl    $1231384169,%edx
72         setne   %al
73         orl     %eax,%ebp
74         cmpl    $1818588270,%ecx
75         setne   %al
76         orl     %eax,%ebp
77         jz      L001intel
78         cmpl    $1752462657,%ebx
79         setne   %al
80         movl    %eax,%esi
81         cmpl    $1769238117,%edx
82         setne   %al
83         orl     %eax,%esi
84         cmpl    $1145913699,%ecx
85         setne   %al
86         orl     %eax,%esi
87         jnz     L001intel
88         movl    $2147483648,%eax
89         .byte   0x0f,0xa2
90         cmpl    $2147483649,%eax
91         jb      L001intel
92         movl    %eax,%esi
93         movl    $2147483649,%eax
94         .byte   0x0f,0xa2
95         orl     %ecx,%ebp
96         andl    $2049,%ebp
97         cmpl    $2147483656,%esi
98         jb      L001intel
99         movl    $2147483656,%eax
100         .byte   0x0f,0xa2
101         movzbl  %cl,%esi
102         incl    %esi
103         movl    $1,%eax
104         xorl    %ecx,%ecx
105         .byte   0x0f,0xa2
106         btl     $28,%edx
107         jnc     L002generic
108         shrl    $16,%ebx
109         andl    $255,%ebx
110         cmpl    %esi,%ebx
111         ja      L002generic
112         andl    $4026531839,%edx
113         jmp     L002generic
114 L001intel:
115         cmpl    $7,%edi
116         jb      L003cacheinfo
117         movl    20(%esp),%esi
118         movl    $7,%eax
119         xorl    %ecx,%ecx
120         .byte   0x0f,0xa2
121         movl    %ebx,8(%esi)
122 L003cacheinfo:
123         cmpl    $4,%edi
124         movl    $-1,%edi
125         jb      L004nocacheinfo
126         movl    $4,%eax
127         movl    $0,%ecx
128         .byte   0x0f,0xa2
129         movl    %eax,%edi
130         shrl    $14,%edi
131         andl    $4095,%edi
132 L004nocacheinfo:
133         movl    $1,%eax
134         xorl    %ecx,%ecx
135         .byte   0x0f,0xa2
136         andl    $3220176895,%edx
137         cmpl    $0,%ebp
138         jne     L005notintel
139         orl     $1073741824,%edx
140         andb    $15,%ah
141         cmpb    $15,%ah
142         jne     L005notintel
143         orl     $1048576,%edx
144 L005notintel:
145         btl     $28,%edx
146         jnc     L002generic
147         andl    $4026531839,%edx
148         cmpl    $0,%edi
149         je      L002generic
150         orl     $268435456,%edx
151         shrl    $16,%ebx
152         cmpb    $1,%bl
153         ja      L002generic
154         andl    $4026531839,%edx
155 L002generic:
156         andl    $2048,%ebp
157         andl    $4294965247,%ecx
158         movl    %edx,%esi
159         orl     %ecx,%ebp
160         btl     $27,%ecx
161         jnc     L006clear_avx
162         xorl    %ecx,%ecx
163 .byte   15,1,208
164         andl    $6,%eax
165         cmpl    $6,%eax
166         je      L007done
167         cmpl    $2,%eax
168         je      L006clear_avx
169 L008clear_xmm:
170         andl    $4261412861,%ebp
171         andl    $4278190079,%esi
172 L006clear_avx:
173         andl    $4026525695,%ebp
174         movl    20(%esp),%edi
175         andl    $4294967263,8(%edi)
176 L007done:
177         movl    %esi,%eax
178         movl    %ebp,%edx
179 L000nocpuid:
180         popl    %edi
181         popl    %esi
182         popl    %ebx
183         popl    %ebp
184         ret
185 .globl  _OPENSSL_rdtsc
186 .align  4
187 _OPENSSL_rdtsc:
188 L_OPENSSL_rdtsc_begin:
189         xorl    %eax,%eax
190         xorl    %edx,%edx
191         call    L009PIC_me_up
192 L009PIC_me_up:
193         popl    %ecx
194         movl    L__gnutls_x86_cpuid_s$non_lazy_ptr-L009PIC_me_up(%ecx),%ecx
195         btl     $4,(%ecx)
196         jnc     L010notsc
197         .byte   0x0f,0x31
198 L010notsc:
199         ret
200 .globl  _OPENSSL_instrument_halt
201 .align  4
202 _OPENSSL_instrument_halt:
203 L_OPENSSL_instrument_halt_begin:
204         call    L011PIC_me_up
205 L011PIC_me_up:
206         popl    %ecx
207         movl    L__gnutls_x86_cpuid_s$non_lazy_ptr-L011PIC_me_up(%ecx),%ecx
208         btl     $4,(%ecx)
209         jnc     L012nohalt
210 .long   2421723150
211         andl    $3,%eax
212         jnz     L012nohalt
213         pushfl
214         popl    %eax
215         btl     $9,%eax
216         jnc     L012nohalt
217         .byte   0x0f,0x31
218         pushl   %edx
219         pushl   %eax
220         hlt
221         .byte   0x0f,0x31
222         subl    (%esp),%eax
223         sbbl    4(%esp),%edx
224         addl    $8,%esp
225         ret
226 L012nohalt:
227         xorl    %eax,%eax
228         xorl    %edx,%edx
229         ret
230 .globl  _OPENSSL_far_spin
231 .align  4
232 _OPENSSL_far_spin:
233 L_OPENSSL_far_spin_begin:
234         pushfl
235         popl    %eax
236         btl     $9,%eax
237         jnc     L013nospin
238         movl    4(%esp),%eax
239         movl    8(%esp),%ecx
240 .long   2430111262
241         xorl    %eax,%eax
242         movl    (%ecx),%edx
243         jmp     L014spin
244 .align  4,0x90
245 L014spin:
246         incl    %eax
247         cmpl    (%ecx),%edx
248         je      L014spin
249 .long   529567888
250         ret
251 L013nospin:
252         xorl    %eax,%eax
253         xorl    %edx,%edx
254         ret
255 .globl  _OPENSSL_wipe_cpu
256 .align  4
257 _OPENSSL_wipe_cpu:
258 L_OPENSSL_wipe_cpu_begin:
259         xorl    %eax,%eax
260         xorl    %edx,%edx
261         call    L015PIC_me_up
262 L015PIC_me_up:
263         popl    %ecx
264         movl    L__gnutls_x86_cpuid_s$non_lazy_ptr-L015PIC_me_up(%ecx),%ecx
265         movl    (%ecx),%ecx
266         btl     $1,(%ecx)
267         jnc     L016no_x87
268 .long   4007259865,4007259865,4007259865,4007259865,2430851995
269 L016no_x87:
270         leal    4(%esp),%eax
271         ret
272 .globl  _OPENSSL_atomic_add
273 .align  4
274 _OPENSSL_atomic_add:
275 L_OPENSSL_atomic_add_begin:
276         movl    4(%esp),%edx
277         movl    8(%esp),%ecx
278         pushl   %ebx
279         nop
280         movl    (%edx),%eax
281 L017spin:
282         leal    (%eax,%ecx,1),%ebx
283         nop
284 .long   447811568
285         jne     L017spin
286         movl    %ebx,%eax
287         popl    %ebx
288         ret
289 .globl  _OPENSSL_indirect_call
290 .align  4
291 _OPENSSL_indirect_call:
292 L_OPENSSL_indirect_call_begin:
293         pushl   %ebp
294         movl    %esp,%ebp
295         subl    $28,%esp
296         movl    12(%ebp),%ecx
297         movl    %ecx,(%esp)
298         movl    16(%ebp),%edx
299         movl    %edx,4(%esp)
300         movl    20(%ebp),%eax
301         movl    %eax,8(%esp)
302         movl    24(%ebp),%eax
303         movl    %eax,12(%esp)
304         movl    28(%ebp),%eax
305         movl    %eax,16(%esp)
306         movl    32(%ebp),%eax
307         movl    %eax,20(%esp)
308         movl    36(%ebp),%eax
309         movl    %eax,24(%esp)
310         call    *8(%ebp)
311         movl    %ebp,%esp
312         popl    %ebp
313         ret
314 .globl  _OPENSSL_cleanse
315 .align  4
316 _OPENSSL_cleanse:
317 L_OPENSSL_cleanse_begin:
318         movl    4(%esp),%edx
319         movl    8(%esp),%ecx
320         xorl    %eax,%eax
321         cmpl    $7,%ecx
322         jae     L018lot
323         cmpl    $0,%ecx
324         je      L019ret
325 L020little:
326         movb    %al,(%edx)
327         subl    $1,%ecx
328         leal    1(%edx),%edx
329         jnz     L020little
330 L019ret:
331         ret
332 .align  4,0x90
333 L018lot:
334         testl   $3,%edx
335         jz      L021aligned
336         movb    %al,(%edx)
337         leal    -1(%ecx),%ecx
338         leal    1(%edx),%edx
339         jmp     L018lot
340 L021aligned:
341         movl    %eax,(%edx)
342         leal    -4(%ecx),%ecx
343         testl   $-4,%ecx
344         leal    4(%edx),%edx
345         jnz     L021aligned
346         cmpl    $0,%ecx
347         jne     L020little
348         ret
349 .globl  _OPENSSL_instrument_bus
350 .align  4
351 _OPENSSL_instrument_bus:
352 L_OPENSSL_instrument_bus_begin:
353         pushl   %ebp
354         pushl   %ebx
355         pushl   %esi
356         pushl   %edi
357         movl    $0,%eax
358         popl    %edi
359         popl    %esi
360         popl    %ebx
361         popl    %ebp
362         ret
363 .globl  _OPENSSL_instrument_bus2
364 .align  4
365 _OPENSSL_instrument_bus2:
366 L_OPENSSL_instrument_bus2_begin:
367         pushl   %ebp
368         pushl   %ebx
369         pushl   %esi
370         pushl   %edi
371         movl    $0,%eax
372         popl    %edi
373         popl    %esi
374         popl    %ebx
375         popl    %ebp
376         ret
377 .globl  _OPENSSL_ia32_rdrand
378 .align  4
379 _OPENSSL_ia32_rdrand:
380 L_OPENSSL_ia32_rdrand_begin:
381         movl    $8,%ecx
382 L022loop:
383 .byte   15,199,240
384         jc      L023break
385         loop    L022loop
386 L023break:
387         cmpl    $0,%eax
388         cmovel  %ecx,%eax
389         ret
390 .section __IMPORT,__pointers,non_lazy_symbol_pointers
391 L__gnutls_x86_cpuid_s$non_lazy_ptr:
392 .indirect_symbol        __gnutls_x86_cpuid_s
393 .long   0
394 .comm   __gnutls_x86_cpuid_s,16,2
395 .mod_init_func
396 .align 2
397 .long   _OPENSSL_cpuid_setup
398
399 .section .note.GNU-stack,"",%progbits