xref: /aosp_15_r20/external/cronet/third_party/boringssl/src/gen/bcm/p256_beeu-x86_64-asm-apple.S (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1// This file is generated from a similarly-named Perl script in the BoringSSL
2// source tree. Do not edit by hand.
3
4#include <openssl/asm_base.h>
5
6#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__)
7.text
8
9
10.private_extern	_beeu_mod_inverse_vartime
11.globl	_beeu_mod_inverse_vartime
12.private_extern _beeu_mod_inverse_vartime
13.p2align	5
14_beeu_mod_inverse_vartime:
15
16_CET_ENDBR
17	pushq	%rbp
18
19	pushq	%r12
20
21	pushq	%r13
22
23	pushq	%r14
24
25	pushq	%r15
26
27	pushq	%rbx
28
29	pushq	%rsi
30
31
32	subq	$80,%rsp
33
34	movq	%rdi,0(%rsp)
35
36
37	movq	$1,%r8
38	xorq	%r9,%r9
39	xorq	%r10,%r10
40	xorq	%r11,%r11
41	xorq	%rdi,%rdi
42
43	xorq	%r12,%r12
44	xorq	%r13,%r13
45	xorq	%r14,%r14
46	xorq	%r15,%r15
47	xorq	%rbp,%rbp
48
49
50	vmovdqu	0(%rsi),%xmm0
51	vmovdqu	16(%rsi),%xmm1
52	vmovdqu	%xmm0,48(%rsp)
53	vmovdqu	%xmm1,64(%rsp)
54
55	vmovdqu	0(%rdx),%xmm0
56	vmovdqu	16(%rdx),%xmm1
57	vmovdqu	%xmm0,16(%rsp)
58	vmovdqu	%xmm1,32(%rsp)
59
60L$beeu_loop:
61	xorq	%rbx,%rbx
62	orq	48(%rsp),%rbx
63	orq	56(%rsp),%rbx
64	orq	64(%rsp),%rbx
65	orq	72(%rsp),%rbx
66	jz	L$beeu_loop_end
67
68
69
70
71
72
73
74
75
76
77	movq	$1,%rcx
78
79
80L$beeu_shift_loop_XB:
81	movq	%rcx,%rbx
82	andq	48(%rsp),%rbx
83	jnz	L$beeu_shift_loop_end_XB
84
85
86	movq	$1,%rbx
87	andq	%r8,%rbx
88	jz	L$shift1_0
89	addq	0(%rdx),%r8
90	adcq	8(%rdx),%r9
91	adcq	16(%rdx),%r10
92	adcq	24(%rdx),%r11
93	adcq	$0,%rdi
94
95L$shift1_0:
96	shrdq	$1,%r9,%r8
97	shrdq	$1,%r10,%r9
98	shrdq	$1,%r11,%r10
99	shrdq	$1,%rdi,%r11
100	shrq	$1,%rdi
101
102	shlq	$1,%rcx
103
104
105
106
107
108	cmpq	$0x8000000,%rcx
109	jne	L$beeu_shift_loop_XB
110
111L$beeu_shift_loop_end_XB:
112	bsfq	%rcx,%rcx
113	testq	%rcx,%rcx
114	jz	L$beeu_no_shift_XB
115
116
117
118	movq	8+48(%rsp),%rax
119	movq	16+48(%rsp),%rbx
120	movq	24+48(%rsp),%rsi
121
122	shrdq	%cl,%rax,0+48(%rsp)
123	shrdq	%cl,%rbx,8+48(%rsp)
124	shrdq	%cl,%rsi,16+48(%rsp)
125
126	shrq	%cl,%rsi
127	movq	%rsi,24+48(%rsp)
128
129
130L$beeu_no_shift_XB:
131
132	movq	$1,%rcx
133
134
135L$beeu_shift_loop_YA:
136	movq	%rcx,%rbx
137	andq	16(%rsp),%rbx
138	jnz	L$beeu_shift_loop_end_YA
139
140
141	movq	$1,%rbx
142	andq	%r12,%rbx
143	jz	L$shift1_1
144	addq	0(%rdx),%r12
145	adcq	8(%rdx),%r13
146	adcq	16(%rdx),%r14
147	adcq	24(%rdx),%r15
148	adcq	$0,%rbp
149
150L$shift1_1:
151	shrdq	$1,%r13,%r12
152	shrdq	$1,%r14,%r13
153	shrdq	$1,%r15,%r14
154	shrdq	$1,%rbp,%r15
155	shrq	$1,%rbp
156
157	shlq	$1,%rcx
158
159
160
161
162
163	cmpq	$0x8000000,%rcx
164	jne	L$beeu_shift_loop_YA
165
166L$beeu_shift_loop_end_YA:
167	bsfq	%rcx,%rcx
168	testq	%rcx,%rcx
169	jz	L$beeu_no_shift_YA
170
171
172
173	movq	8+16(%rsp),%rax
174	movq	16+16(%rsp),%rbx
175	movq	24+16(%rsp),%rsi
176
177	shrdq	%cl,%rax,0+16(%rsp)
178	shrdq	%cl,%rbx,8+16(%rsp)
179	shrdq	%cl,%rsi,16+16(%rsp)
180
181	shrq	%cl,%rsi
182	movq	%rsi,24+16(%rsp)
183
184
185L$beeu_no_shift_YA:
186
187	movq	48(%rsp),%rax
188	movq	56(%rsp),%rbx
189	movq	64(%rsp),%rsi
190	movq	72(%rsp),%rcx
191	subq	16(%rsp),%rax
192	sbbq	24(%rsp),%rbx
193	sbbq	32(%rsp),%rsi
194	sbbq	40(%rsp),%rcx
195	jnc	L$beeu_B_bigger_than_A
196
197
198	movq	16(%rsp),%rax
199	movq	24(%rsp),%rbx
200	movq	32(%rsp),%rsi
201	movq	40(%rsp),%rcx
202	subq	48(%rsp),%rax
203	sbbq	56(%rsp),%rbx
204	sbbq	64(%rsp),%rsi
205	sbbq	72(%rsp),%rcx
206	movq	%rax,16(%rsp)
207	movq	%rbx,24(%rsp)
208	movq	%rsi,32(%rsp)
209	movq	%rcx,40(%rsp)
210
211
212	addq	%r8,%r12
213	adcq	%r9,%r13
214	adcq	%r10,%r14
215	adcq	%r11,%r15
216	adcq	%rdi,%rbp
217	jmp	L$beeu_loop
218
219L$beeu_B_bigger_than_A:
220
221	movq	%rax,48(%rsp)
222	movq	%rbx,56(%rsp)
223	movq	%rsi,64(%rsp)
224	movq	%rcx,72(%rsp)
225
226
227	addq	%r12,%r8
228	adcq	%r13,%r9
229	adcq	%r14,%r10
230	adcq	%r15,%r11
231	adcq	%rbp,%rdi
232
233	jmp	L$beeu_loop
234
235L$beeu_loop_end:
236
237
238
239
240	movq	16(%rsp),%rbx
241	subq	$1,%rbx
242	orq	24(%rsp),%rbx
243	orq	32(%rsp),%rbx
244	orq	40(%rsp),%rbx
245
246	jnz	L$beeu_err
247
248
249
250
251	movq	0(%rdx),%r8
252	movq	8(%rdx),%r9
253	movq	16(%rdx),%r10
254	movq	24(%rdx),%r11
255	xorq	%rdi,%rdi
256
257L$beeu_reduction_loop:
258	movq	%r12,16(%rsp)
259	movq	%r13,24(%rsp)
260	movq	%r14,32(%rsp)
261	movq	%r15,40(%rsp)
262	movq	%rbp,48(%rsp)
263
264
265	subq	%r8,%r12
266	sbbq	%r9,%r13
267	sbbq	%r10,%r14
268	sbbq	%r11,%r15
269	sbbq	$0,%rbp
270
271
272	cmovcq	16(%rsp),%r12
273	cmovcq	24(%rsp),%r13
274	cmovcq	32(%rsp),%r14
275	cmovcq	40(%rsp),%r15
276	jnc	L$beeu_reduction_loop
277
278
279	subq	%r12,%r8
280	sbbq	%r13,%r9
281	sbbq	%r14,%r10
282	sbbq	%r15,%r11
283
284L$beeu_save:
285
286	movq	0(%rsp),%rdi
287
288	movq	%r8,0(%rdi)
289	movq	%r9,8(%rdi)
290	movq	%r10,16(%rdi)
291	movq	%r11,24(%rdi)
292
293
294	movq	$1,%rax
295	jmp	L$beeu_finish
296
297L$beeu_err:
298
299	xorq	%rax,%rax
300
301L$beeu_finish:
302	addq	$80,%rsp
303
304	popq	%rsi
305
306	popq	%rbx
307
308	popq	%r15
309
310	popq	%r14
311
312	popq	%r13
313
314	popq	%r12
315
316	popq	%rbp
317
318	ret
319
320
321
322#endif
323