Debian Codegraph @

crypto_kem/348864/avx/update_asm.S

raw
1 // 20240504 djb: add note.GNU-stack
2 // 20221231 djb: port hidden to macos; tnx thom wiggers
3 // 20221230 djb: add linker line
4
5 // linker define update_asm
6
7 #include "crypto_asm_hidden.h"
8
9 #define update_asm CRYPTO_SHARED_NAMESPACE(update_asm)
10 #define _update_asm _CRYPTO_SHARED_NAMESPACE(update_asm)
11
12 # qhasm: int64 input_0
13
14 # qhasm: int64 input_1
15
16 # qhasm: int64 input_2
17
18 # qhasm: int64 input_3
19
20 # qhasm: int64 input_4
21
22 # qhasm: int64 input_5
23
24 # qhasm: stack64 input_6
25
26 # qhasm: stack64 input_7
27
28 # qhasm: int64 caller_r11
29
30 # qhasm: int64 caller_r12
31
32 # qhasm: int64 caller_r13
33
34 # qhasm: int64 caller_r14
35
36 # qhasm: int64 caller_r15
37
38 # qhasm: int64 caller_rbx
39
40 # qhasm: int64 caller_rbp
41
42 # qhasm: int64 s0
43
44 # qhasm: int64 s1
45
46 # qhasm: enter update_asm
47 .p2align 5
48 ASM_HIDDEN _update_asm
49 ASM_HIDDEN update_asm
50 .global _update_asm
51 .global update_asm
52 _update_asm:
53 update_asm:
54 mov %rsp,%r11
55 AND $31,%r11
56 add $0,%r11
57 sub %r11,%rsp
58
59 # qhasm: s1 = input_1
60 # asm 1: mov <input_1=int64#2,>s1=int64#2
61 # asm 2: mov <input_1=%rsi,>s1=%rsi
62 mov %rsi,%rsi
63
64 # qhasm: s0 = mem64[ input_0 + 0 ]
65 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
66 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
67 movq 0(%rdi),%rcx
68
69 # qhasm: s0 = (s1 s0) >> 1
70 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
71 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
72 shrd $1,%rsi,%rcx
73
74 # qhasm: (uint64) s1 >>= 1
75 # asm 1: shr $1,<s1=int64#2
76 # asm 2: shr $1,<s1=%rsi
77 shr $1,%rsi
78
79 # qhasm: mem64[ input_0 + 0 ] = s0
80 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
81 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
82 movq %rcx,0(%rdi)
83
84 # qhasm: input_0 += input_2
85 # asm 1: add <input_2=int64#3,<input_0=int64#1
86 # asm 2: add <input_2=%rdx,<input_0=%rdi
87 add %rdx,%rdi
88
89 # qhasm: s0 = mem64[ input_0 + 0 ]
90 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
91 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
92 movq 0(%rdi),%rcx
93
94 # qhasm: s0 = (s1 s0) >> 1
95 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
96 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
97 shrd $1,%rsi,%rcx
98
99 # qhasm: (uint64) s1 >>= 1
100 # asm 1: shr $1,<s1=int64#2
101 # asm 2: shr $1,<s1=%rsi
102 shr $1,%rsi
103
104 # qhasm: mem64[ input_0 + 0 ] = s0
105 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
106 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
107 movq %rcx,0(%rdi)
108
109 # qhasm: input_0 += input_2
110 # asm 1: add <input_2=int64#3,<input_0=int64#1
111 # asm 2: add <input_2=%rdx,<input_0=%rdi
112 add %rdx,%rdi
113
114 # qhasm: s0 = mem64[ input_0 + 0 ]
115 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
116 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
117 movq 0(%rdi),%rcx
118
119 # qhasm: s0 = (s1 s0) >> 1
120 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
121 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
122 shrd $1,%rsi,%rcx
123
124 # qhasm: (uint64) s1 >>= 1
125 # asm 1: shr $1,<s1=int64#2
126 # asm 2: shr $1,<s1=%rsi
127 shr $1,%rsi
128
129 # qhasm: mem64[ input_0 + 0 ] = s0
130 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
131 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
132 movq %rcx,0(%rdi)
133
134 # qhasm: input_0 += input_2
135 # asm 1: add <input_2=int64#3,<input_0=int64#1
136 # asm 2: add <input_2=%rdx,<input_0=%rdi
137 add %rdx,%rdi
138
139 # qhasm: s0 = mem64[ input_0 + 0 ]
140 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
141 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
142 movq 0(%rdi),%rcx
143
144 # qhasm: s0 = (s1 s0) >> 1
145 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
146 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
147 shrd $1,%rsi,%rcx
148
149 # qhasm: (uint64) s1 >>= 1
150 # asm 1: shr $1,<s1=int64#2
151 # asm 2: shr $1,<s1=%rsi
152 shr $1,%rsi
153
154 # qhasm: mem64[ input_0 + 0 ] = s0
155 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
156 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
157 movq %rcx,0(%rdi)
158
159 # qhasm: input_0 += input_2
160 # asm 1: add <input_2=int64#3,<input_0=int64#1
161 # asm 2: add <input_2=%rdx,<input_0=%rdi
162 add %rdx,%rdi
163
164 # qhasm: s0 = mem64[ input_0 + 0 ]
165 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
166 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
167 movq 0(%rdi),%rcx
168
169 # qhasm: s0 = (s1 s0) >> 1
170 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
171 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
172 shrd $1,%rsi,%rcx
173
174 # qhasm: (uint64) s1 >>= 1
175 # asm 1: shr $1,<s1=int64#2
176 # asm 2: shr $1,<s1=%rsi
177 shr $1,%rsi
178
179 # qhasm: mem64[ input_0 + 0 ] = s0
180 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
181 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
182 movq %rcx,0(%rdi)
183
184 # qhasm: input_0 += input_2
185 # asm 1: add <input_2=int64#3,<input_0=int64#1
186 # asm 2: add <input_2=%rdx,<input_0=%rdi
187 add %rdx,%rdi
188
189 # qhasm: s0 = mem64[ input_0 + 0 ]
190 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
191 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
192 movq 0(%rdi),%rcx
193
194 # qhasm: s0 = (s1 s0) >> 1
195 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
196 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
197 shrd $1,%rsi,%rcx
198
199 # qhasm: (uint64) s1 >>= 1
200 # asm 1: shr $1,<s1=int64#2
201 # asm 2: shr $1,<s1=%rsi
202 shr $1,%rsi
203
204 # qhasm: mem64[ input_0 + 0 ] = s0
205 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
206 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
207 movq %rcx,0(%rdi)
208
209 # qhasm: input_0 += input_2
210 # asm 1: add <input_2=int64#3,<input_0=int64#1
211 # asm 2: add <input_2=%rdx,<input_0=%rdi
212 add %rdx,%rdi
213
214 # qhasm: s0 = mem64[ input_0 + 0 ]
215 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
216 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
217 movq 0(%rdi),%rcx
218
219 # qhasm: s0 = (s1 s0) >> 1
220 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
221 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
222 shrd $1,%rsi,%rcx
223
224 # qhasm: (uint64) s1 >>= 1
225 # asm 1: shr $1,<s1=int64#2
226 # asm 2: shr $1,<s1=%rsi
227 shr $1,%rsi
228
229 # qhasm: mem64[ input_0 + 0 ] = s0
230 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
231 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
232 movq %rcx,0(%rdi)
233
234 # qhasm: input_0 += input_2
235 # asm 1: add <input_2=int64#3,<input_0=int64#1
236 # asm 2: add <input_2=%rdx,<input_0=%rdi
237 add %rdx,%rdi
238
239 # qhasm: s0 = mem64[ input_0 + 0 ]
240 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
241 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
242 movq 0(%rdi),%rcx
243
244 # qhasm: s0 = (s1 s0) >> 1
245 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
246 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
247 shrd $1,%rsi,%rcx
248
249 # qhasm: (uint64) s1 >>= 1
250 # asm 1: shr $1,<s1=int64#2
251 # asm 2: shr $1,<s1=%rsi
252 shr $1,%rsi
253
254 # qhasm: mem64[ input_0 + 0 ] = s0
255 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
256 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
257 movq %rcx,0(%rdi)
258
259 # qhasm: input_0 += input_2
260 # asm 1: add <input_2=int64#3,<input_0=int64#1
261 # asm 2: add <input_2=%rdx,<input_0=%rdi
262 add %rdx,%rdi
263
264 # qhasm: s0 = mem64[ input_0 + 0 ]
265 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
266 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
267 movq 0(%rdi),%rcx
268
269 # qhasm: s0 = (s1 s0) >> 1
270 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
271 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
272 shrd $1,%rsi,%rcx
273
274 # qhasm: (uint64) s1 >>= 1
275 # asm 1: shr $1,<s1=int64#2
276 # asm 2: shr $1,<s1=%rsi
277 shr $1,%rsi
278
279 # qhasm: mem64[ input_0 + 0 ] = s0
280 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
281 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
282 movq %rcx,0(%rdi)
283
284 # qhasm: input_0 += input_2
285 # asm 1: add <input_2=int64#3,<input_0=int64#1
286 # asm 2: add <input_2=%rdx,<input_0=%rdi
287 add %rdx,%rdi
288
289 # qhasm: s0 = mem64[ input_0 + 0 ]
290 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
291 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
292 movq 0(%rdi),%rcx
293
294 # qhasm: s0 = (s1 s0) >> 1
295 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
296 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
297 shrd $1,%rsi,%rcx
298
299 # qhasm: (uint64) s1 >>= 1
300 # asm 1: shr $1,<s1=int64#2
301 # asm 2: shr $1,<s1=%rsi
302 shr $1,%rsi
303
304 # qhasm: mem64[ input_0 + 0 ] = s0
305 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
306 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
307 movq %rcx,0(%rdi)
308
309 # qhasm: input_0 += input_2
310 # asm 1: add <input_2=int64#3,<input_0=int64#1
311 # asm 2: add <input_2=%rdx,<input_0=%rdi
312 add %rdx,%rdi
313
314 # qhasm: s0 = mem64[ input_0 + 0 ]
315 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
316 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
317 movq 0(%rdi),%rcx
318
319 # qhasm: s0 = (s1 s0) >> 1
320 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
321 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
322 shrd $1,%rsi,%rcx
323
324 # qhasm: (uint64) s1 >>= 1
325 # asm 1: shr $1,<s1=int64#2
326 # asm 2: shr $1,<s1=%rsi
327 shr $1,%rsi
328
329 # qhasm: mem64[ input_0 + 0 ] = s0
330 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
331 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
332 movq %rcx,0(%rdi)
333
334 # qhasm: input_0 += input_2
335 # asm 1: add <input_2=int64#3,<input_0=int64#1
336 # asm 2: add <input_2=%rdx,<input_0=%rdi
337 add %rdx,%rdi
338
339 # qhasm: s0 = mem64[ input_0 + 0 ]
340 # asm 1: movq 0(<input_0=int64#1),>s0=int64#4
341 # asm 2: movq 0(<input_0=%rdi),>s0=%rcx
342 movq 0(%rdi),%rcx
343
344 # qhasm: s0 = (s1 s0) >> 1
345 # asm 1: shrd $1,<s1=int64#2,<s0=int64#4
346 # asm 2: shrd $1,<s1=%rsi,<s0=%rcx
347 shrd $1,%rsi,%rcx
348
349 # qhasm: (uint64) s1 >>= 1
350 # asm 1: shr $1,<s1=int64#2
351 # asm 2: shr $1,<s1=%rsi
352 shr $1,%rsi
353
354 # qhasm: mem64[ input_0 + 0 ] = s0
355 # asm 1: movq <s0=int64#4,0(<input_0=int64#1)
356 # asm 2: movq <s0=%rcx,0(<input_0=%rdi)
357 movq %rcx,0(%rdi)
358
359 # qhasm: input_0 += input_2
360 # asm 1: add <input_2=int64#3,<input_0=int64#1
361 # asm 2: add <input_2=%rdx,<input_0=%rdi
362 add %rdx,%rdi
363
364 # qhasm: return
365 add %r11,%rsp
366 ret
367 .section .note.GNU-stack,"",@progbits