Debian Codegraph @

src/libmpg123/dct64_x86_64.S

raw
1 /*
2 dct64_x86_64: SSE optimized dct64 for x86-64
3
4 copyright 1995-2026 by the mpg123 project - free software under the terms of the LGPL 2.1
5 see COPYING and AUTHORS files in distribution or http://mpg123.org
6 initially written by Taihei Monma
7 */
8
9 #include "x86_64_defs.h"
10 #include "mangle.h"
11
12 #ifdef IS_MSABI
13 /* short *out0 */
14 #define ARG0 %r9
15 /* short *out1 */
16 #define ARG1 %rdx
17 /* real *samples */
18 #define ARG2 %r8
19 #else
20 /* short *out0 */
21 #define ARG0 %rdi
22 /* short *out1 */
23 #define ARG1 %rsi
24 /* real *samples */
25 #define ARG2 %rdx
26 #endif
27
28 /*
29 void dct64_x86_64(short *out0, short *out1, real *samples);
30 */
31
32 RODATA
33 ALIGN32
34 ASM_NAME(INT123_costab_x86_64):
35 .long 1056974725
36 .long 1057056395
37 .long 1057223771
38 .long 1057485416
39 .long 1057855544
40 .long 1058356026
41 .long 1059019886
42 .long 1059897405
43 .long 1061067246
44 .long 1062657950
45 .long 1064892987
46 .long 1066774581
47 .long 1069414683
48 .long 1073984175
49 .long 1079645762
50 .long 1092815430
51 .long 1057005197
52 .long 1057342072
53 .long 1058087743
54 .long 1059427869
55 .long 1061799040
56 .long 1065862217
57 .long 1071413542
58 .long 1084439708
59 .long 1057128951
60 .long 1058664893
61 .long 1063675095
62 .long 1076102863
63 .long 1057655764
64 .long 1067924853
65 .long 1060439283
66 .long 0
67 .text
68 ALIGN16
69 .globl ASM_NAME(INT123_dct64_x86_64)
70 ASM_NAME(INT123_dct64_x86_64):
71 #ifdef IS_MSABI /* should save xmm6-15 */
72 movq %rcx, ARG0
73 subq $168, %rsp /* stack alignment + 10 xmm registers */
74 movaps %xmm6, (%rsp)
75 movaps %xmm7, 16(%rsp)
76 movaps %xmm8, 32(%rsp)
77 movaps %xmm9, 48(%rsp)
78 movaps %xmm10, 64(%rsp)
79 movaps %xmm11, 80(%rsp)
80 movaps %xmm12, 96(%rsp)
81 movaps %xmm13, 112(%rsp)
82 movaps %xmm14, 128(%rsp)
83 movaps %xmm15, 144(%rsp)
84 #endif
85
86 leaq ASM_NAME(INT123_costab_x86_64)(%rip), %rcx
87
88 MOVUAPS (ARG2), %xmm15
89 MOVUAPS 16(ARG2), %xmm14
90 MOVUAPS 112(ARG2), %xmm0
91 MOVUAPS 96(ARG2), %xmm1
92 shufps $0x1b, %xmm0, %xmm0
93 shufps $0x1b, %xmm1, %xmm1
94 movaps %xmm15, %xmm8
95 movaps %xmm14, %xmm9
96 addps %xmm0, %xmm8
97 addps %xmm1, %xmm9
98 subps %xmm0, %xmm15
99 subps %xmm1, %xmm14
100
101 MOVUAPS 32(ARG2), %xmm13
102 MOVUAPS 48(ARG2), %xmm12
103 MOVUAPS 80(ARG2), %xmm0
104 MOVUAPS 64(ARG2), %xmm1
105 shufps $0x1b, %xmm0, %xmm0
106 shufps $0x1b, %xmm1, %xmm1
107 movaps %xmm13, %xmm10
108 movaps %xmm12, %xmm11
109 addps %xmm0, %xmm10
110 addps %xmm1, %xmm11
111 subps %xmm0, %xmm13
112 subps %xmm1, %xmm12
113
114 movaps (%rcx), %xmm0
115 movaps 16(%rcx), %xmm1
116 movaps 32(%rcx), %xmm2
117 movaps 48(%rcx), %xmm3
118 mulps %xmm0, %xmm15
119 mulps %xmm1, %xmm14
120 mulps %xmm2, %xmm13
121 mulps %xmm3, %xmm12
122
123 movaps 64(%rcx), %xmm0
124 movaps 80(%rcx), %xmm1
125
126 pshufd $0x1b, %xmm11, %xmm2
127 pshufd $0x1b, %xmm10, %xmm3
128 shufps $0x1b, %xmm13, %xmm13
129 shufps $0x1b, %xmm12, %xmm12
130 movaps %xmm8, %xmm11
131 movaps %xmm9, %xmm10
132 movaps %xmm14, %xmm4
133 movaps %xmm15, %xmm5
134 subps %xmm2, %xmm11
135 subps %xmm3, %xmm10
136 subps %xmm13, %xmm14
137 subps %xmm12, %xmm15
138 addps %xmm2, %xmm8
139 addps %xmm3, %xmm9
140 addps %xmm5, %xmm12
141 addps %xmm4, %xmm13
142 mulps %xmm0, %xmm11
143 mulps %xmm1, %xmm10
144 mulps %xmm1, %xmm14
145 mulps %xmm0, %xmm15
146
147 movaps 96(%rcx), %xmm0
148
149 pshufd $0x1b, %xmm9, %xmm1
150 pshufd $0x1b, %xmm13, %xmm2
151 shufps $0x1b, %xmm10, %xmm10
152 shufps $0x1b, %xmm14, %xmm14
153 movaps %xmm8, %xmm9
154 movaps %xmm12, %xmm13
155 movaps %xmm11, %xmm3
156 movaps %xmm15, %xmm4
157 subps %xmm1, %xmm9
158 subps %xmm2, %xmm13
159 subps %xmm10, %xmm11
160 subps %xmm14, %xmm15
161 addps %xmm1, %xmm8
162 addps %xmm2, %xmm12
163 addps %xmm3, %xmm10
164 addps %xmm4, %xmm14
165 mulps %xmm0, %xmm9
166 mulps %xmm0, %xmm13
167 mulps %xmm0, %xmm11
168 mulps %xmm0, %xmm15
169
170 movaps 112(%rcx), %xmm0
171 movaps %xmm0, %xmm1
172 movlhps %xmm1, %xmm1
173
174 movaps %xmm8, %xmm2
175 movaps %xmm9, %xmm3
176 shufps $0x44, %xmm10, %xmm2
177 shufps $0xbb, %xmm11, %xmm9
178 shufps $0xbb, %xmm10, %xmm8
179 shufps $0x44, %xmm11, %xmm3
180 movaps %xmm2, %xmm4
181 movaps %xmm3, %xmm5
182 subps %xmm8, %xmm2
183 subps %xmm9, %xmm3
184 addps %xmm4, %xmm8
185 addps %xmm5, %xmm9
186 mulps %xmm1, %xmm2
187 mulps %xmm1, %xmm3
188 movaps %xmm8, %xmm10
189 movaps %xmm9, %xmm11
190 shufps $0x14, %xmm2, %xmm8
191 shufps $0xbe, %xmm2, %xmm10
192 shufps $0x14, %xmm3, %xmm9
193 shufps $0xbe, %xmm3, %xmm11
194
195 movaps %xmm12, %xmm2
196 movaps %xmm13, %xmm3
197 shufps $0x44, %xmm14, %xmm2
198 shufps $0xbb, %xmm15, %xmm13
199 shufps $0xbb, %xmm14, %xmm12
200 shufps $0x44, %xmm15, %xmm3
201 movaps %xmm2, %xmm4
202 movaps %xmm3, %xmm5
203 subps %xmm12, %xmm2
204 subps %xmm13, %xmm3
205 addps %xmm4, %xmm12
206 addps %xmm5, %xmm13
207 mulps %xmm1, %xmm2
208 mulps %xmm1, %xmm3
209 movaps %xmm12, %xmm14
210 movaps %xmm13, %xmm15
211 shufps $0x14, %xmm2, %xmm12
212 shufps $0xbe, %xmm2, %xmm14
213 shufps $0x14, %xmm3, %xmm13
214 shufps $0xbe, %xmm3, %xmm15
215
216 shufps $0xaa, %xmm0, %xmm0
217 pcmpeqd %xmm1, %xmm1
218 pslld $31, %xmm1
219 psllq $32, %xmm1
220 xorps %xmm1, %xmm0
221
222 movaps %xmm8, %xmm1
223 movaps %xmm10, %xmm2
224 unpcklps %xmm9, %xmm8
225 unpckhps %xmm9, %xmm1
226 unpcklps %xmm11, %xmm10
227 unpckhps %xmm11, %xmm2
228 movaps %xmm8, %xmm3
229 movaps %xmm10, %xmm4
230 unpcklps %xmm1, %xmm8
231 unpckhps %xmm1, %xmm3
232 unpcklps %xmm2, %xmm10
233 unpckhps %xmm2, %xmm4
234 movaps %xmm8, %xmm1
235 movaps %xmm10, %xmm2
236 subps %xmm3, %xmm1
237 subps %xmm4, %xmm2
238 addps %xmm3, %xmm8
239 addps %xmm4, %xmm10
240 mulps %xmm0, %xmm1
241 mulps %xmm0, %xmm2
242 movaps %xmm8, %xmm9
243 movaps %xmm10, %xmm11
244 unpcklps %xmm1, %xmm8
245 unpckhps %xmm1, %xmm9
246 unpcklps %xmm2, %xmm10
247 unpckhps %xmm2, %xmm11
248
249 movaps %xmm12, %xmm1
250 movaps %xmm14, %xmm2
251 unpcklps %xmm13, %xmm12
252 unpckhps %xmm13, %xmm1
253 unpcklps %xmm15, %xmm14
254 unpckhps %xmm15, %xmm2
255 movaps %xmm12, %xmm3
256 movaps %xmm14, %xmm4
257 unpcklps %xmm1, %xmm12
258 unpckhps %xmm1, %xmm3
259 unpcklps %xmm2, %xmm14
260 unpckhps %xmm2, %xmm4
261 movaps %xmm12, %xmm1
262 movaps %xmm14, %xmm2
263 subps %xmm3, %xmm1
264 subps %xmm4, %xmm2
265 addps %xmm3, %xmm12
266 addps %xmm4, %xmm14
267 mulps %xmm0, %xmm1
268 mulps %xmm0, %xmm2
269 movaps %xmm12, %xmm13
270 movaps %xmm14, %xmm15
271 unpcklps %xmm1, %xmm12
272 unpckhps %xmm1, %xmm13
273 unpcklps %xmm2, %xmm14
274 unpckhps %xmm2, %xmm15
275
276
277 xorps %xmm0, %xmm0
278 xorps %xmm1, %xmm1
279 shufpd $0x2, %xmm8, %xmm0
280 shufpd $0x2, %xmm9, %xmm1
281 psrlq $32, %xmm0
282 psrlq $32, %xmm1
283 addps %xmm0, %xmm8
284 addps %xmm1, %xmm9
285
286 xorps %xmm0, %xmm0
287 xorps %xmm1, %xmm1
288 shufpd $0x2, %xmm10, %xmm0
289 shufpd $0x2, %xmm11, %xmm1
290 psrlq $32, %xmm0
291 psrlq $32, %xmm1
292 addps %xmm0, %xmm10
293 addps %xmm1, %xmm11
294
295 xorps %xmm0, %xmm0
296 xorps %xmm1, %xmm1
297 shufpd $0x2, %xmm12, %xmm0
298 shufpd $0x2, %xmm13, %xmm1
299 psrlq $32, %xmm0
300 psrlq $32, %xmm1
301 addps %xmm0, %xmm12
302 addps %xmm1, %xmm13
303
304 xorps %xmm0, %xmm0
305 xorps %xmm1, %xmm1
306 shufpd $0x2, %xmm14, %xmm0
307 shufpd $0x2, %xmm15, %xmm1
308 psrlq $32, %xmm0
309 psrlq $32, %xmm1
310 addps %xmm0, %xmm14
311 addps %xmm1, %xmm15
312
313 pshufd $0x78, %xmm9, %xmm0
314 pshufd $0x78, %xmm11, %xmm1
315 pshufd $0x78, %xmm13, %xmm2
316 pshufd $0x78, %xmm15, %xmm3
317 psrldq $4, %xmm0
318 psrldq $4, %xmm1
319 psrldq $4, %xmm2
320 psrldq $4, %xmm3
321 addps %xmm0, %xmm9
322 addps %xmm1, %xmm11
323 addps %xmm2, %xmm13
324 addps %xmm3, %xmm15
325
326 pshufd $0x78, %xmm10, %xmm0
327 pshufd $0x78, %xmm14, %xmm1
328 psrldq $4, %xmm0
329 psrldq $4, %xmm1
330 addps %xmm11, %xmm10
331 addps %xmm15, %xmm14
332 addps %xmm0, %xmm11
333 addps %xmm1, %xmm15
334
335 cvtps2dq %xmm8, %xmm8
336 cvtps2dq %xmm9, %xmm9
337 cvtps2dq %xmm10, %xmm10
338 cvtps2dq %xmm11, %xmm11
339 packssdw %xmm10, %xmm8
340 packssdw %xmm11, %xmm9
341
342 movd %xmm8, %eax
343 movd %xmm9, %ecx
344 movw %ax, 512(ARG0)
345 movw %cx, 384(ARG0)
346 shrl $16, %eax
347 shrl $16, %ecx
348 movw %ax, (ARG0)
349 movw %ax, (ARG1)
350 movw %cx, 128(ARG1)
351
352 movhlps %xmm8, %xmm0
353 movhlps %xmm9, %xmm1
354 movd %xmm0, %eax
355 movd %xmm1, %ecx
356 movw %ax, 448(ARG0)
357 movw %cx, 320(ARG0)
358 shrl $16, %eax
359 shrl $16, %ecx
360 movw %ax, 64(ARG1)
361 movw %cx, 192(ARG1)
362
363 pshuflw $0xee, %xmm8, %xmm2
364 pshuflw $0xee, %xmm9, %xmm3
365 movd %xmm2, %eax
366 movd %xmm3, %ecx
367 movw %ax, 256(ARG0)
368 movw %cx, 128(ARG0)
369 shrl $16, %eax
370 shrl $16, %ecx
371 movw %ax, 256(ARG1)
372 movw %cx, 384(ARG1)
373
374 pshuflw $0xee, %xmm0, %xmm0
375 pshuflw $0xee, %xmm1, %xmm1
376 movd %xmm0, %eax
377 movd %xmm1, %ecx
378 movw %ax, 192(ARG0)
379 movw %cx, 64(ARG0)
380 shrl $16, %eax
381 shrl $16, %ecx
382 movw %ax, 320(ARG1)
383 movw %cx, 448(ARG1)
384
385 movaps %xmm12, %xmm0
386 movaps %xmm13, %xmm1
387 movaps %xmm14, %xmm2
388 movaps %xmm15, %xmm3
389 shufps $0x1e, %xmm0, %xmm0
390 pslldq $4, %xmm0
391 psrldq $4, %xmm0
392 addps %xmm2, %xmm12
393 addps %xmm3, %xmm13
394 addps %xmm1, %xmm14
395 addps %xmm0, %xmm15
396
397 cvtps2dq %xmm12, %xmm12
398 cvtps2dq %xmm13, %xmm13
399 cvtps2dq %xmm14, %xmm14
400 cvtps2dq %xmm15, %xmm15
401 packssdw %xmm13, %xmm12
402 packssdw %xmm15, %xmm14
403
404 movd %xmm12, %eax
405 movd %xmm14, %ecx
406 movw %ax, 480(ARG0)
407 movw %cx, 416(ARG0)
408 shrl $16, %eax
409 shrl $16, %ecx
410 movw %ax, 32(ARG1)
411 movw %cx, 96(ARG1)
412
413 pshuflw $0xee, %xmm12, %xmm0
414 pshuflw $0xee, %xmm14, %xmm1
415 movd %xmm0, %eax
416 movd %xmm1, %ecx
417 movw %ax, 224(ARG0)
418 movw %cx, 160(ARG0)
419 shrl $16, %eax
420 shrl $16, %ecx
421 movw %ax, 288(ARG1)
422 movw %cx, 352(ARG1)
423
424 movhlps %xmm12, %xmm0
425 movhlps %xmm14, %xmm1
426 movd %xmm0, %eax
427 movd %xmm1, %ecx
428 movw %ax, 352(ARG0)
429 movw %cx, 288(ARG0)
430 shrl $16, %eax
431 shrl $16, %ecx
432 movw %ax, 160(ARG1)
433 movw %cx, 224(ARG1)
434
435 pshuflw $0xee, %xmm0, %xmm0
436 pshuflw $0xee, %xmm1, %xmm1
437 movd %xmm0, %eax
438 movd %xmm1, %ecx
439 movw %ax, 96(ARG0)
440 movw %cx, 32(ARG0)
441 shrl $16, %eax
442 shrl $16, %ecx
443 movw %ax, 416(ARG1)
444 movw %cx, 480(ARG1)
445
446 #ifdef IS_MSABI
447 movaps (%rsp), %xmm6
448 movaps 16(%rsp), %xmm7
449 movaps 32(%rsp), %xmm8
450 movaps 48(%rsp), %xmm9
451 movaps 64(%rsp), %xmm10
452 movaps 80(%rsp), %xmm11
453 movaps 96(%rsp), %xmm12
454 movaps 112(%rsp), %xmm13
455 movaps 128(%rsp), %xmm14
456 movaps 144(%rsp), %xmm15
457 addq $168, %rsp
458 #endif
459 ret
460
461 NONEXEC_STACK