1
2# qhasm: int64 rp
3
4# qhasm: input rp
5
6# qhasm: int64 r0
7
8# qhasm: int64 r1
9
10# qhasm: int64 r2
11
12# qhasm: int64 r3
13
14# qhasm: int64 r4
15
16# qhasm: int64 t
17
18# qhasm: int64 loop
19
20# qhasm: int64 two51minus1
21
22# qhasm: int64 two51minus19
23
24# qhasm:   int64 caller1
25
26# qhasm:   int64 caller2
27
28# qhasm:   int64 caller3
29
30# qhasm:   int64 caller4
31
32# qhasm:   int64 caller5
33
34# qhasm:   int64 caller6
35
36# qhasm:   int64 caller7
37
38# qhasm:   caller caller1
39
40# qhasm:   caller caller2
41
42# qhasm:   caller caller3
43
44# qhasm:   caller caller4
45
46# qhasm:   caller caller5
47
48# qhasm:   caller caller6
49
50# qhasm:   caller caller7
51
52# qhasm:   stack64 caller1_stack
53
54# qhasm:   stack64 caller2_stack
55
56# qhasm:   stack64 caller3_stack
57
58# qhasm:   stack64 caller4_stack
59
60# qhasm:   stack64 caller5_stack
61
62# qhasm:   stack64 caller6_stack
63
64# qhasm:   stack64 caller7_stack
65
66# qhasm: enter crypto_sign_ed25519_amd64_51_30k_batch_fe25519_freeze
67.text
68.p2align 5
69.globl _crypto_sign_ed25519_amd64_51_30k_batch_fe25519_freeze
70.globl crypto_sign_ed25519_amd64_51_30k_batch_fe25519_freeze
71_crypto_sign_ed25519_amd64_51_30k_batch_fe25519_freeze:
72crypto_sign_ed25519_amd64_51_30k_batch_fe25519_freeze:
73mov %rsp,%r11
74and $31,%r11
75add $64,%r11
76sub %r11,%rsp
77
78# qhasm:   caller1_stack = caller1
79# asm 1: movq <caller1=int64#9,>caller1_stack=stack64#1
80# asm 2: movq <caller1=%r11,>caller1_stack=0(%rsp)
81movq %r11,0(%rsp)
82
83# qhasm:   caller2_stack = caller2
84# asm 1: movq <caller2=int64#10,>caller2_stack=stack64#2
85# asm 2: movq <caller2=%r12,>caller2_stack=8(%rsp)
86movq %r12,8(%rsp)
87
88# qhasm:   caller3_stack = caller3
89# asm 1: movq <caller3=int64#11,>caller3_stack=stack64#3
90# asm 2: movq <caller3=%r13,>caller3_stack=16(%rsp)
91movq %r13,16(%rsp)
92
93# qhasm:   caller4_stack = caller4
94# asm 1: movq <caller4=int64#12,>caller4_stack=stack64#4
95# asm 2: movq <caller4=%r14,>caller4_stack=24(%rsp)
96movq %r14,24(%rsp)
97
98# qhasm:   caller5_stack = caller5
99# asm 1: movq <caller5=int64#13,>caller5_stack=stack64#5
100# asm 2: movq <caller5=%r15,>caller5_stack=32(%rsp)
101movq %r15,32(%rsp)
102
103# qhasm:   caller6_stack = caller6
104# asm 1: movq <caller6=int64#14,>caller6_stack=stack64#6
105# asm 2: movq <caller6=%rbx,>caller6_stack=40(%rsp)
106movq %rbx,40(%rsp)
107
108# qhasm:   caller7_stack = caller7
109# asm 1: movq <caller7=int64#15,>caller7_stack=stack64#7
110# asm 2: movq <caller7=%rbp,>caller7_stack=48(%rsp)
111movq %rbp,48(%rsp)
112
113# qhasm: r0 = *(uint64 *) (rp + 0)
114# asm 1: movq   0(<rp=int64#1),>r0=int64#2
115# asm 2: movq   0(<rp=%rdi),>r0=%rsi
116movq   0(%rdi),%rsi
117
118# qhasm: r1 = *(uint64 *) (rp + 8)
119# asm 1: movq   8(<rp=int64#1),>r1=int64#3
120# asm 2: movq   8(<rp=%rdi),>r1=%rdx
121movq   8(%rdi),%rdx
122
123# qhasm: r2 = *(uint64 *) (rp + 16)
124# asm 1: movq   16(<rp=int64#1),>r2=int64#4
125# asm 2: movq   16(<rp=%rdi),>r2=%rcx
126movq   16(%rdi),%rcx
127
128# qhasm: r3 = *(uint64 *) (rp + 24)
129# asm 1: movq   24(<rp=int64#1),>r3=int64#5
130# asm 2: movq   24(<rp=%rdi),>r3=%r8
131movq   24(%rdi),%r8
132
133# qhasm: r4 = *(uint64 *) (rp + 32)
134# asm 1: movq   32(<rp=int64#1),>r4=int64#6
135# asm 2: movq   32(<rp=%rdi),>r4=%r9
136movq   32(%rdi),%r9
137
138# qhasm: two51minus1 = *(uint64 *) &crypto_sign_ed25519_amd64_51_30k_batch_REDMASK51
139# asm 1: movq crypto_sign_ed25519_amd64_51_30k_batch_REDMASK51,>two51minus1=int64#7
140# asm 2: movq crypto_sign_ed25519_amd64_51_30k_batch_REDMASK51,>two51minus1=%rax
141movq crypto_sign_ed25519_amd64_51_30k_batch_REDMASK51,%rax
142
143# qhasm: two51minus19 = two51minus1
144# asm 1: mov  <two51minus1=int64#7,>two51minus19=int64#8
145# asm 2: mov  <two51minus1=%rax,>two51minus19=%r10
146mov  %rax,%r10
147
148# qhasm: two51minus19 -= 18
149# asm 1: sub  $18,<two51minus19=int64#8
150# asm 2: sub  $18,<two51minus19=%r10
151sub  $18,%r10
152
153# qhasm: loop = 3
154# asm 1: mov  $3,>loop=int64#9
155# asm 2: mov  $3,>loop=%r11
156mov  $3,%r11
157
158# qhasm: reduceloop:
159._reduceloop:
160
161# qhasm:   t = r0
162# asm 1: mov  <r0=int64#2,>t=int64#10
163# asm 2: mov  <r0=%rsi,>t=%r12
164mov  %rsi,%r12
165
166# qhasm:   (uint64) t >>= 51
167# asm 1: shr  $51,<t=int64#10
168# asm 2: shr  $51,<t=%r12
169shr  $51,%r12
170
171# qhasm:   r0 &= two51minus1
172# asm 1: and  <two51minus1=int64#7,<r0=int64#2
173# asm 2: and  <two51minus1=%rax,<r0=%rsi
174and  %rax,%rsi
175
176# qhasm:   r1 += t
177# asm 1: add  <t=int64#10,<r1=int64#3
178# asm 2: add  <t=%r12,<r1=%rdx
179add  %r12,%rdx
180
181# qhasm:   t = r1
182# asm 1: mov  <r1=int64#3,>t=int64#10
183# asm 2: mov  <r1=%rdx,>t=%r12
184mov  %rdx,%r12
185
186# qhasm:   (uint64) t >>= 51
187# asm 1: shr  $51,<t=int64#10
188# asm 2: shr  $51,<t=%r12
189shr  $51,%r12
190
191# qhasm:   r1 &= two51minus1
192# asm 1: and  <two51minus1=int64#7,<r1=int64#3
193# asm 2: and  <two51minus1=%rax,<r1=%rdx
194and  %rax,%rdx
195
196# qhasm:   r2 += t
197# asm 1: add  <t=int64#10,<r2=int64#4
198# asm 2: add  <t=%r12,<r2=%rcx
199add  %r12,%rcx
200
201# qhasm:   t = r2
202# asm 1: mov  <r2=int64#4,>t=int64#10
203# asm 2: mov  <r2=%rcx,>t=%r12
204mov  %rcx,%r12
205
206# qhasm:   (uint64) t >>= 51
207# asm 1: shr  $51,<t=int64#10
208# asm 2: shr  $51,<t=%r12
209shr  $51,%r12
210
211# qhasm:   r2 &= two51minus1
212# asm 1: and  <two51minus1=int64#7,<r2=int64#4
213# asm 2: and  <two51minus1=%rax,<r2=%rcx
214and  %rax,%rcx
215
216# qhasm:   r3 += t
217# asm 1: add  <t=int64#10,<r3=int64#5
218# asm 2: add  <t=%r12,<r3=%r8
219add  %r12,%r8
220
221# qhasm:   t = r3
222# asm 1: mov  <r3=int64#5,>t=int64#10
223# asm 2: mov  <r3=%r8,>t=%r12
224mov  %r8,%r12
225
226# qhasm:   (uint64) t >>= 51
227# asm 1: shr  $51,<t=int64#10
228# asm 2: shr  $51,<t=%r12
229shr  $51,%r12
230
231# qhasm:   r3 &= two51minus1
232# asm 1: and  <two51minus1=int64#7,<r3=int64#5
233# asm 2: and  <two51minus1=%rax,<r3=%r8
234and  %rax,%r8
235
236# qhasm:   r4 += t
237# asm 1: add  <t=int64#10,<r4=int64#6
238# asm 2: add  <t=%r12,<r4=%r9
239add  %r12,%r9
240
241# qhasm:   t = r4
242# asm 1: mov  <r4=int64#6,>t=int64#10
243# asm 2: mov  <r4=%r9,>t=%r12
244mov  %r9,%r12
245
246# qhasm:   (uint64) t >>= 51
247# asm 1: shr  $51,<t=int64#10
248# asm 2: shr  $51,<t=%r12
249shr  $51,%r12
250
251# qhasm:   r4 &= two51minus1
252# asm 1: and  <two51minus1=int64#7,<r4=int64#6
253# asm 2: and  <two51minus1=%rax,<r4=%r9
254and  %rax,%r9
255
256# qhasm:   t *= 19
257# asm 1: imulq  $19,<t=int64#10,>t=int64#10
258# asm 2: imulq  $19,<t=%r12,>t=%r12
259imulq  $19,%r12,%r12
260
261# qhasm:   r0 += t
262# asm 1: add  <t=int64#10,<r0=int64#2
263# asm 2: add  <t=%r12,<r0=%rsi
264add  %r12,%rsi
265
266# qhasm:                    unsigned>? loop -= 1
267# asm 1: sub  $1,<loop=int64#9
268# asm 2: sub  $1,<loop=%r11
269sub  $1,%r11
270# comment:fp stack unchanged by jump
271
272# qhasm: goto reduceloop if unsigned>
273ja ._reduceloop
274
275# qhasm: t = 1
276# asm 1: mov  $1,>t=int64#10
277# asm 2: mov  $1,>t=%r12
278mov  $1,%r12
279
280# qhasm:             signed<? r0 - two51minus19
281# asm 1: cmp  <two51minus19=int64#8,<r0=int64#2
282# asm 2: cmp  <two51minus19=%r10,<r0=%rsi
283cmp  %r10,%rsi
284
285# qhasm: t = loop if signed<
286# asm 1: cmovl <loop=int64#9,<t=int64#10
287# asm 2: cmovl <loop=%r11,<t=%r12
288cmovl %r11,%r12
289
290# qhasm:              =? r1 - two51minus1
291# asm 1: cmp  <two51minus1=int64#7,<r1=int64#3
292# asm 2: cmp  <two51minus1=%rax,<r1=%rdx
293cmp  %rax,%rdx
294
295# qhasm: t = loop if !=
296# asm 1: cmovne <loop=int64#9,<t=int64#10
297# asm 2: cmovne <loop=%r11,<t=%r12
298cmovne %r11,%r12
299
300# qhasm:              =? r2 - two51minus1
301# asm 1: cmp  <two51minus1=int64#7,<r2=int64#4
302# asm 2: cmp  <two51minus1=%rax,<r2=%rcx
303cmp  %rax,%rcx
304
305# qhasm: t = loop if !=
306# asm 1: cmovne <loop=int64#9,<t=int64#10
307# asm 2: cmovne <loop=%r11,<t=%r12
308cmovne %r11,%r12
309
310# qhasm:              =? r3 - two51minus1
311# asm 1: cmp  <two51minus1=int64#7,<r3=int64#5
312# asm 2: cmp  <two51minus1=%rax,<r3=%r8
313cmp  %rax,%r8
314
315# qhasm: t = loop if !=
316# asm 1: cmovne <loop=int64#9,<t=int64#10
317# asm 2: cmovne <loop=%r11,<t=%r12
318cmovne %r11,%r12
319
320# qhasm:              =? r4 - two51minus1
321# asm 1: cmp  <two51minus1=int64#7,<r4=int64#6
322# asm 2: cmp  <two51minus1=%rax,<r4=%r9
323cmp  %rax,%r9
324
325# qhasm: t = loop if !=
326# asm 1: cmovne <loop=int64#9,<t=int64#10
327# asm 2: cmovne <loop=%r11,<t=%r12
328cmovne %r11,%r12
329
330# qhasm: t = -t
331# asm 1: neg  <t=int64#10
332# asm 2: neg  <t=%r12
333neg  %r12
334
335# qhasm: two51minus1 &= t
336# asm 1: and  <t=int64#10,<two51minus1=int64#7
337# asm 2: and  <t=%r12,<two51minus1=%rax
338and  %r12,%rax
339
340# qhasm: two51minus19 &= t
341# asm 1: and  <t=int64#10,<two51minus19=int64#8
342# asm 2: and  <t=%r12,<two51minus19=%r10
343and  %r12,%r10
344
345# qhasm: r0 -= two51minus19
346# asm 1: sub  <two51minus19=int64#8,<r0=int64#2
347# asm 2: sub  <two51minus19=%r10,<r0=%rsi
348sub  %r10,%rsi
349
350# qhasm: r1 -= two51minus1
351# asm 1: sub  <two51minus1=int64#7,<r1=int64#3
352# asm 2: sub  <two51minus1=%rax,<r1=%rdx
353sub  %rax,%rdx
354
355# qhasm: r2 -= two51minus1
356# asm 1: sub  <two51minus1=int64#7,<r2=int64#4
357# asm 2: sub  <two51minus1=%rax,<r2=%rcx
358sub  %rax,%rcx
359
360# qhasm: r3 -= two51minus1
361# asm 1: sub  <two51minus1=int64#7,<r3=int64#5
362# asm 2: sub  <two51minus1=%rax,<r3=%r8
363sub  %rax,%r8
364
365# qhasm: r4 -= two51minus1
366# asm 1: sub  <two51minus1=int64#7,<r4=int64#6
367# asm 2: sub  <two51minus1=%rax,<r4=%r9
368sub  %rax,%r9
369
370# qhasm: *(uint64 *)(rp + 0) = r0
371# asm 1: movq   <r0=int64#2,0(<rp=int64#1)
372# asm 2: movq   <r0=%rsi,0(<rp=%rdi)
373movq   %rsi,0(%rdi)
374
375# qhasm: *(uint64 *)(rp + 8) = r1
376# asm 1: movq   <r1=int64#3,8(<rp=int64#1)
377# asm 2: movq   <r1=%rdx,8(<rp=%rdi)
378movq   %rdx,8(%rdi)
379
380# qhasm: *(uint64 *)(rp + 16) = r2
381# asm 1: movq   <r2=int64#4,16(<rp=int64#1)
382# asm 2: movq   <r2=%rcx,16(<rp=%rdi)
383movq   %rcx,16(%rdi)
384
385# qhasm: *(uint64 *)(rp + 24) = r3
386# asm 1: movq   <r3=int64#5,24(<rp=int64#1)
387# asm 2: movq   <r3=%r8,24(<rp=%rdi)
388movq   %r8,24(%rdi)
389
390# qhasm: *(uint64 *)(rp + 32) = r4
391# asm 1: movq   <r4=int64#6,32(<rp=int64#1)
392# asm 2: movq   <r4=%r9,32(<rp=%rdi)
393movq   %r9,32(%rdi)
394
395# qhasm:   caller1 = caller1_stack
396# asm 1: movq <caller1_stack=stack64#1,>caller1=int64#9
397# asm 2: movq <caller1_stack=0(%rsp),>caller1=%r11
398movq 0(%rsp),%r11
399
400# qhasm:   caller2 = caller2_stack
401# asm 1: movq <caller2_stack=stack64#2,>caller2=int64#10
402# asm 2: movq <caller2_stack=8(%rsp),>caller2=%r12
403movq 8(%rsp),%r12
404
405# qhasm:   caller3 = caller3_stack
406# asm 1: movq <caller3_stack=stack64#3,>caller3=int64#11
407# asm 2: movq <caller3_stack=16(%rsp),>caller3=%r13
408movq 16(%rsp),%r13
409
410# qhasm:   caller4 = caller4_stack
411# asm 1: movq <caller4_stack=stack64#4,>caller4=int64#12
412# asm 2: movq <caller4_stack=24(%rsp),>caller4=%r14
413movq 24(%rsp),%r14
414
415# qhasm:   caller5 = caller5_stack
416# asm 1: movq <caller5_stack=stack64#5,>caller5=int64#13
417# asm 2: movq <caller5_stack=32(%rsp),>caller5=%r15
418movq 32(%rsp),%r15
419
420# qhasm:   caller6 = caller6_stack
421# asm 1: movq <caller6_stack=stack64#6,>caller6=int64#14
422# asm 2: movq <caller6_stack=40(%rsp),>caller6=%rbx
423movq 40(%rsp),%rbx
424
425# qhasm:   caller7 = caller7_stack
426# asm 1: movq <caller7_stack=stack64#7,>caller7=int64#15
427# asm 2: movq <caller7_stack=48(%rsp),>caller7=%rbp
428movq 48(%rsp),%rbp
429
430# qhasm: leave
431add %r11,%rsp
432mov %rdi,%rax
433mov %rsi,%rdx
434ret
435