Workaround for xkbcommon dead keys.
[chromium-blink-merge.git] / third_party / boringssl / win-x86 / crypto / cpu-x86-asm.asm
blob22bae78599f03e3fce68bfb91a5e0163fa5137bd
1 %ifidn __OUTPUT_FORMAT__,obj
2 section code use32 class=code align=64
3 %elifidn __OUTPUT_FORMAT__,win32
4 %ifdef __YASM_VERSION_ID__
5 %if __YASM_VERSION_ID__ < 01010000h
6 %error yasm version 1.1.0 or later needed.
7 %endif
8 ; Yasm automatically includes .00 and complains about redefining it.
9 ; https://www.tortall.net/projects/yasm/manual/html/objfmt-win32-safeseh.html
10 %else
11 $@feat.00 equ 1
12 %endif
13 section .text code align=64
14 %else
15 section .text code
16 %endif
17 global _OPENSSL_ia32_cpuid
18 align 16
19 _OPENSSL_ia32_cpuid:
20 L$_OPENSSL_ia32_cpuid_begin:
21 push ebp
22 push ebx
23 push esi
24 push edi
25 xor edx,edx
26 pushfd
27 pop eax
28 mov ecx,eax
29 xor eax,2097152
30 push eax
31 popfd
32 pushfd
33 pop eax
34 xor ecx,eax
35 xor eax,eax
36 bt ecx,21
37 jnc NEAR L$000nocpuid
38 mov esi,DWORD [20+esp]
39 mov DWORD [8+esi],eax
40 cpuid
41 mov edi,eax
42 xor eax,eax
43 cmp ebx,1970169159
44 setne al
45 mov ebp,eax
46 cmp edx,1231384169
47 setne al
48 or ebp,eax
49 cmp ecx,1818588270
50 setne al
51 or ebp,eax
52 jz NEAR L$001intel
53 cmp ebx,1752462657
54 setne al
55 mov esi,eax
56 cmp edx,1769238117
57 setne al
58 or esi,eax
59 cmp ecx,1145913699
60 setne al
61 or esi,eax
62 jnz NEAR L$001intel
63 mov eax,2147483648
64 cpuid
65 cmp eax,2147483649
66 jb NEAR L$001intel
67 mov esi,eax
68 mov eax,2147483649
69 cpuid
70 or ebp,ecx
71 and ebp,2049
72 cmp esi,2147483656
73 jb NEAR L$001intel
74 mov eax,2147483656
75 cpuid
76 movzx esi,cl
77 inc esi
78 mov eax,1
79 xor ecx,ecx
80 cpuid
81 bt edx,28
82 jnc NEAR L$002generic
83 shr ebx,16
84 and ebx,255
85 cmp ebx,esi
86 ja NEAR L$002generic
87 and edx,4026531839
88 jmp NEAR L$002generic
89 L$001intel:
90 cmp edi,7
91 jb NEAR L$003cacheinfo
92 mov esi,DWORD [20+esp]
93 mov eax,7
94 xor ecx,ecx
95 cpuid
96 mov DWORD [8+esi],ebx
97 L$003cacheinfo:
98 cmp edi,4
99 mov edi,-1
100 jb NEAR L$004nocacheinfo
101 mov eax,4
102 mov ecx,0
103 cpuid
104 mov edi,eax
105 shr edi,14
106 and edi,4095
107 L$004nocacheinfo:
108 mov eax,1
109 xor ecx,ecx
110 cpuid
111 and edx,3220176895
112 cmp ebp,0
113 jne NEAR L$005notintel
114 or edx,1073741824
115 and ah,15
116 cmp ah,15
117 jne NEAR L$005notintel
118 or edx,1048576
119 L$005notintel:
120 bt edx,28
121 jnc NEAR L$002generic
122 and edx,4026531839
123 cmp edi,0
124 je NEAR L$002generic
125 or edx,268435456
126 shr ebx,16
127 cmp bl,1
128 ja NEAR L$002generic
129 and edx,4026531839
130 L$002generic:
131 and ebp,2048
132 and ecx,4294965247
133 mov esi,edx
134 or ebp,ecx
135 bt ecx,27
136 jnc NEAR L$006clear_avx
137 xor ecx,ecx
138 db 15,1,208
139 and eax,6
140 cmp eax,6
141 je NEAR L$007done
142 cmp eax,2
143 je NEAR L$006clear_avx
144 L$008clear_xmm:
145 and ebp,4261412861
146 and esi,4278190079
147 L$006clear_avx:
148 and ebp,4026525695
149 mov edi,DWORD [20+esp]
150 and DWORD [8+edi],4294967263
151 L$007done:
152 mov eax,esi
153 mov edx,ebp
154 L$000nocpuid:
155 pop edi
156 pop esi
157 pop ebx
158 pop ebp
160 ;extern _OPENSSL_ia32cap_P
161 global _OPENSSL_rdtsc
162 align 16
163 _OPENSSL_rdtsc:
164 L$_OPENSSL_rdtsc_begin:
165 xor eax,eax
166 xor edx,edx
167 lea ecx,[_OPENSSL_ia32cap_P]
168 bt DWORD [ecx],4
169 jnc NEAR L$009notsc
170 rdtsc
171 L$009notsc:
173 global _OPENSSL_instrument_halt
174 align 16
175 _OPENSSL_instrument_halt:
176 L$_OPENSSL_instrument_halt_begin:
177 lea ecx,[_OPENSSL_ia32cap_P]
178 bt DWORD [ecx],4
179 jnc NEAR L$010nohalt
180 dd 2421723150
181 and eax,3
182 jnz NEAR L$010nohalt
183 pushfd
184 pop eax
185 bt eax,9
186 jnc NEAR L$010nohalt
187 rdtsc
188 push edx
189 push eax
191 rdtsc
192 sub eax,DWORD [esp]
193 sbb edx,DWORD [4+esp]
194 add esp,8
196 L$010nohalt:
197 xor eax,eax
198 xor edx,edx
200 global _OPENSSL_far_spin
201 align 16
202 _OPENSSL_far_spin:
203 L$_OPENSSL_far_spin_begin:
204 pushfd
205 pop eax
206 bt eax,9
207 jnc NEAR L$011nospin
208 mov eax,DWORD [4+esp]
209 mov ecx,DWORD [8+esp]
210 dd 2430111262
211 xor eax,eax
212 mov edx,DWORD [ecx]
213 jmp NEAR L$012spin
214 align 16
215 L$012spin:
216 inc eax
217 cmp edx,DWORD [ecx]
218 je NEAR L$012spin
219 dd 529567888
221 L$011nospin:
222 xor eax,eax
223 xor edx,edx
225 global _OPENSSL_wipe_cpu
226 align 16
227 _OPENSSL_wipe_cpu:
228 L$_OPENSSL_wipe_cpu_begin:
229 xor eax,eax
230 xor edx,edx
231 lea ecx,[_OPENSSL_ia32cap_P]
232 mov ecx,DWORD [ecx]
233 bt DWORD [ecx],1
234 jnc NEAR L$013no_x87
235 dd 4007259865,4007259865,4007259865,4007259865,2430851995
236 L$013no_x87:
237 lea eax,[4+esp]
239 global _OPENSSL_atomic_add
240 align 16
241 _OPENSSL_atomic_add:
242 L$_OPENSSL_atomic_add_begin:
243 mov edx,DWORD [4+esp]
244 mov ecx,DWORD [8+esp]
245 push ebx
247 mov eax,DWORD [edx]
248 L$014spin:
249 lea ebx,[ecx*1+eax]
251 dd 447811568
252 jne NEAR L$014spin
253 mov eax,ebx
254 pop ebx
256 global _OPENSSL_indirect_call
257 align 16
258 _OPENSSL_indirect_call:
259 L$_OPENSSL_indirect_call_begin:
260 push ebp
261 mov ebp,esp
262 sub esp,28
263 mov ecx,DWORD [12+ebp]
264 mov DWORD [esp],ecx
265 mov edx,DWORD [16+ebp]
266 mov DWORD [4+esp],edx
267 mov eax,DWORD [20+ebp]
268 mov DWORD [8+esp],eax
269 mov eax,DWORD [24+ebp]
270 mov DWORD [12+esp],eax
271 mov eax,DWORD [28+ebp]
272 mov DWORD [16+esp],eax
273 mov eax,DWORD [32+ebp]
274 mov DWORD [20+esp],eax
275 mov eax,DWORD [36+ebp]
276 mov DWORD [24+esp],eax
277 call DWORD [8+ebp]
278 mov esp,ebp
279 pop ebp
281 global _OPENSSL_ia32_rdrand
282 align 16
283 _OPENSSL_ia32_rdrand:
284 L$_OPENSSL_ia32_rdrand_begin:
285 mov ecx,8
286 L$015loop:
287 db 15,199,240
288 jc NEAR L$016break
289 loop L$015loop
290 L$016break:
291 cmp eax,0
292 cmove eax,ecx
294 segment .bss
295 common _OPENSSL_ia32cap_P 16