Debian Codegraph @

src/libmpg123/dct36_x86_64.S

raw
1 /*
2 dct36_x86_64: SSE optimized dct36 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 #define in %rcx
14 #define out1 %rdx
15 #define out2 %r8
16 #define w %r9
17 #define ts %r10
18 #define COS9_ %rax
19 #define tfcos36_ %r11
20 #else
21 #define in %rdi
22 #define out1 %rsi
23 #define out2 %rdx
24 #define w %rcx
25 #define ts %r8
26 #define COS9_ %rax
27 #define tfcos36_ %r9
28 #endif
29
30 /*
31 void dct36_x86_64(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf);
32 */
33
34 RODATA
35 ALIGN16
36 dct36_x86_64_COS9:
37 .long 0x3f5db3d7
38 .long 0x3f5db3d7
39 .long 0x3f000000
40 .long 0x3f000000
41 .long 0x3f7c1c5c
42 .long 0x3f7c1c5c
43 .long 0x3f708fb2
44 .long 0x3f708fb2
45 .long 0x3f248dbb
46 .long 0x3f248dbb
47 .long 0x3e31d0d4
48 .long 0x3e31d0d4
49 .long 0x3eaf1d44
50 .long 0x3eaf1d44
51 .long 0x3f441b7d
52 .long 0x3f441b7d
53 ALIGN16
54 dct36_x86_64_tfcos36:
55 .long 0x3f007d2b
56 .long 0x3f0483ee
57 .long 0x3f0d3b7d
58 .long 0x3f1c4257
59 .long 0x40b79454
60 .long 0x3ff746ea
61 .long 0x3f976fd9
62 .long 0x3f5f2944
63 .long 0x3f3504f3
64 ALIGN16
65 dct36_x86_64_mask:
66 .long 0,0xffffffff,0,0xffffffff
67 ALIGN16
68 dct36_x86_64_sign:
69 .long 0x80000000,0x80000000,0x80000000,0x80000000
70 .text
71 ALIGN16
72 .globl ASM_NAME(INT123_dct36_x86_64)
73 ASM_NAME(INT123_dct36_x86_64):
74 #ifdef IS_MSABI
75 push %rbp
76 mov %rsp, %rbp
77 sub $160, %rsp
78 movaps %xmm6, (%rsp)
79 movaps %xmm7, 16(%rsp)
80 movaps %xmm8, 32(%rsp)
81 movaps %xmm9, 48(%rsp)
82 movaps %xmm10, 64(%rsp)
83 movaps %xmm11, 80(%rsp)
84 movaps %xmm12, 96(%rsp)
85 movaps %xmm13, 112(%rsp)
86 movaps %xmm14, 128(%rsp)
87 movaps %xmm15, 144(%rsp)
88 movq 48(%rbp), ts
89 #endif
90 lea dct36_x86_64_COS9(%rip), COS9_
91 lea dct36_x86_64_tfcos36(%rip), tfcos36_
92
93 xorps %xmm5, %xmm5
94 movups (in), %xmm1
95 movups 16(in), %xmm2
96 movups 32(in), %xmm3
97 movups 48(in), %xmm4
98 movlps 64(in), %xmm5
99 xorps %xmm6, %xmm6
100 movaps %xmm1, %xmm7
101 shufps $0x93, %xmm7, %xmm7
102 movaps %xmm2, %xmm8
103 shufps $0x93, %xmm8, %xmm8
104 movaps %xmm3, %xmm9
105 shufps $0x93, %xmm9, %xmm9
106 movaps %xmm4, %xmm10
107 shufps $0x93, %xmm10, %xmm10
108 movaps %xmm5, %xmm11
109 shufps $0xe1, %xmm11, %xmm11
110 movss %xmm10, %xmm11
111 addps %xmm11, %xmm5
112 movss %xmm9, %xmm10
113 addps %xmm10, %xmm4
114 movss %xmm8, %xmm9
115 addps %xmm9, %xmm3
116 movss %xmm7, %xmm8
117 addps %xmm8, %xmm2
118 movss %xmm6, %xmm7
119 addps %xmm7, %xmm1
120
121 movaps dct36_x86_64_mask(%rip), %xmm0
122 movaps %xmm4, %xmm6
123 shufps $0x4e, %xmm5, %xmm4
124 movaps %xmm3, %xmm7
125 shufps $0x4e, %xmm6, %xmm3
126 andps %xmm0, %xmm6
127 addps %xmm6, %xmm4
128 movaps %xmm2, %xmm6
129 shufps $0x4e, %xmm7, %xmm2
130 andps %xmm0, %xmm7
131 addps %xmm7, %xmm3
132 movaps %xmm1, %xmm7
133 shufps $0x4e, %xmm6, %xmm1
134 andps %xmm0, %xmm6
135 addps %xmm6, %xmm2
136 movaps %xmm7, %xmm6
137 andps %xmm0, %xmm7
138 xorps %xmm0, %xmm0
139 addps %xmm7, %xmm1
140 movlhps %xmm6, %xmm0
141
142 /*
143 xmm0 in[-,-,0,1]
144 xmm1 in[2,3,4,5]
145 xmm2 in[6,7,8,9]
146 xmm3 in[10,11,12,13]
147 xmm4 in[14,15,16,17]
148 */
149
150 movaps %xmm2, %xmm5
151 shufps $0xe4, %xmm3, %xmm5
152 shufps $0xe4, %xmm4, %xmm3
153 shufps $0xe4, %xmm2, %xmm4
154 movaps %xmm5, %xmm2
155 /*
156 xmm2 in[6,7,12,13]
157 xmm3 in[10,11,16,17]
158 xmm4 in[14,15,8,9]
159 */
160
161 movaps (COS9_), %xmm15
162 movaps 16(COS9_), %xmm6
163 movaps 32(COS9_), %xmm7
164 movaps 48(COS9_), %xmm8
165 mulps %xmm15, %xmm5
166 addps %xmm0, %xmm5
167
168 /*
169 xmm5 [ta33,tb33,ta66,tb66]
170 xmm6 COS9_[1,1,2,2]
171 xmm7 COS9_[5,5,8,8]
172 xmm8 COS9_[7,7,4,4]
173 xmm15 COS9_[3,3,6,6]
174 */
175 movaps %xmm6, %xmm9
176 movaps %xmm7, %xmm12
177 movaps %xmm8, %xmm13
178 mulps %xmm1, %xmm9
179 mulps %xmm3, %xmm12
180 mulps %xmm4, %xmm13
181 addps %xmm5, %xmm9
182 addps %xmm13, %xmm12
183 addps %xmm9, %xmm12
184
185 movaps %xmm1, %xmm13
186 subps %xmm3, %xmm13
187 movaps %xmm0, %xmm10
188 shufps $0xe0, %xmm2, %xmm10
189 movaps %xmm0, %xmm14
190 subps %xmm10, %xmm14
191 subps %xmm4, %xmm13
192 mulps %xmm15, %xmm13
193 addps %xmm14, %xmm13
194
195 movaps %xmm7, %xmm9
196 movaps %xmm8, %xmm15
197 movaps %xmm6, %xmm14
198 mulps %xmm1, %xmm9
199 mulps %xmm3, %xmm15
200 mulps %xmm4, %xmm14
201 subps %xmm5, %xmm9
202 subps %xmm15, %xmm14
203 addps %xmm9, %xmm14
204
205 mulps %xmm1, %xmm8
206 mulps %xmm3, %xmm6
207 mulps %xmm4, %xmm7
208 subps %xmm5, %xmm8
209 subps %xmm7, %xmm6
210 addps %xmm6, %xmm8
211 movaps %xmm8, %xmm15
212
213 movss 32(tfcos36_), %xmm5
214 subps %xmm1, %xmm0
215 subps %xmm2, %xmm4
216 addps %xmm3, %xmm0
217 addps %xmm4, %xmm0
218 shufps $0xaf, %xmm0, %xmm0
219 mulss %xmm5, %xmm0
220 movaps %xmm0, %xmm11
221
222 /*
223 xmm12 [1a-0,1b-0, 2a-0, 2b-0]
224 xmm13 [1a-1,1b-1, 2a-1, 2b-1]
225 xmm14 [1a-2,1b-2,-2a-2,-2b-2]
226 xmm15 [1a-3,1b-3,-2a-3,-2b-3]
227 */
228 movaps %xmm12, %xmm5
229 unpckhps %xmm13, %xmm5
230 unpcklps %xmm13, %xmm12
231 movaps %xmm14, %xmm6
232 unpckhps %xmm15, %xmm6
233 unpcklps %xmm15, %xmm14
234 xorps dct36_x86_64_sign(%rip), %xmm6
235
236 /*
237 xmm12 [1a-0,1a-1,1b-0,1b-1]
238 xmm5 [2a-0,2a-1,2b-0,2b-1]
239 xmm14 [1a-2,1a-3,1b-2,1b-3]
240 xmm6 [2a-2,2a-3,2b-2,2b-3]
241 */
242
243 movaps %xmm12, %xmm0
244 movlhps %xmm14, %xmm12
245 movhlps %xmm0, %xmm14
246 movaps %xmm5, %xmm0
247 movlhps %xmm6, %xmm0
248 movhlps %xmm5, %xmm6
249 movaps %xmm6, %xmm15
250
251 /*
252 xmm12 tmp1a
253 xmm0 tmp2a
254 xmm14 tmp1b
255 xmm15 tmp2b
256 */
257
258 movaps (tfcos36_), %xmm6
259 movaps 16(tfcos36_), %xmm7
260 movaps %xmm15, %xmm10
261 addps %xmm14, %xmm15
262 subps %xmm14, %xmm10
263 movaps %xmm0, %xmm14
264 addps %xmm12, %xmm0
265 subps %xmm12, %xmm14
266 mulps %xmm6, %xmm15
267 mulps %xmm10, %xmm7
268
269 /*
270 %xmm0 tmp[0,1,2,3]
271 %xmm15 tmp[17,16,15,14]
272 %xmm14 tmp[8,7,6,5]
273 %xmm7 tmp[9,10,11,12]
274 %xmm11 tmp[13,-,4,-]
275 */
276
277 movaps %xmm15, %xmm1
278 movups 108(w), %xmm2
279 movups 92(w), %xmm3
280 shufps $0x1b, %xmm3, %xmm3
281 movups 36(w), %xmm4
282 movups 20(w), %xmm5
283 shufps $0x1b, %xmm5, %xmm5
284 movaps %xmm0, %xmm6
285 addps %xmm1, %xmm0
286 subps %xmm1, %xmm6
287 mulps %xmm0, %xmm2
288 mulps %xmm3, %xmm0
289 mulps %xmm6, %xmm4
290 mulps %xmm5, %xmm6
291 movups 36(out1), %xmm1
292 movups 20(out1), %xmm3
293 shufps $0x1b, %xmm6, %xmm6
294 addps %xmm4, %xmm1
295 addps %xmm6, %xmm3
296 shufps $0x1b, %xmm0, %xmm0
297 movups %xmm2, 36(out2)
298 movups %xmm0, 20(out2)
299 movss %xmm1, 32*36(ts)
300 movss %xmm3, 32*20(ts)
301 movhlps %xmm1, %xmm2
302 movhlps %xmm3, %xmm4
303 movss %xmm2, 32*44(ts)
304 movss %xmm4, 32*28(ts)
305 shufps $0xb1, %xmm1, %xmm1
306 shufps $0xb1, %xmm3, %xmm3
307 movss %xmm1, 32*40(ts)
308 movss %xmm3, 32*24(ts)
309 movhlps %xmm1, %xmm2
310 movhlps %xmm3, %xmm4
311 movss %xmm2, 32*48(ts)
312 movss %xmm4, 32*32(ts)
313
314 movhlps %xmm11, %xmm0
315 movaps %xmm11, %xmm1
316 movss 124(w), %xmm2
317 movss 88(w), %xmm3
318 movss 52(w), %xmm4
319 movss 16(w), %xmm5
320 movss %xmm0, %xmm6
321 addss %xmm1, %xmm0
322 subss %xmm1, %xmm6
323 mulss %xmm0, %xmm2
324 mulss %xmm3, %xmm0
325 mulss %xmm6, %xmm4
326 mulss %xmm5, %xmm6
327 addss 52(out1), %xmm4
328 addss 16(out1), %xmm6
329 movss %xmm2, 52(out2)
330 movss %xmm0, 16(out2)
331 movss %xmm4, 32*52(ts)
332 movss %xmm6, 32*16(ts)
333
334 movaps %xmm14, %xmm0
335 movaps %xmm7, %xmm1
336 MOVUAPS 128(w), %xmm2
337 movups 72(w), %xmm3
338 shufps $0x1b, %xmm2, %xmm2
339 movlps 56(w), %xmm4
340 movhps 64(w), %xmm4
341 MOVUAPS (w), %xmm5
342 shufps $0x1b, %xmm4, %xmm4
343 movaps %xmm0, %xmm6
344 addps %xmm1, %xmm0
345 subps %xmm1, %xmm6
346 mulps %xmm0, %xmm2
347 mulps %xmm3, %xmm0
348 mulps %xmm6, %xmm4
349 mulps %xmm5, %xmm6
350 movlps 56(out1), %xmm1
351 movhps 64(out1), %xmm1
352 movups (out1), %xmm3
353 shufps $0x1b, %xmm4, %xmm4
354 addps %xmm6, %xmm3
355 addps %xmm4, %xmm1
356 shufps $0x1b, %xmm2, %xmm2
357 movups %xmm0, (out2)
358 movlps %xmm2, 56(out2)
359 movhps %xmm2, 64(out2)
360 movss %xmm1, 32*56(ts)
361 movss %xmm3, (ts)
362 movhlps %xmm1, %xmm2
363 movhlps %xmm3, %xmm4
364 movss %xmm2, 32*64(ts)
365 movss %xmm4, 32*8(ts)
366 shufps $0xb1, %xmm1, %xmm1
367 shufps $0xb1, %xmm3, %xmm3
368 movss %xmm1, 32*60(ts)
369 movss %xmm3, 32*4(ts)
370 movhlps %xmm1, %xmm2
371 movhlps %xmm3, %xmm4
372 movss %xmm2, 32*68(ts)
373 movss %xmm4, 32*12(ts)
374
375 #ifdef IS_MSABI
376 movaps (%rsp), %xmm6
377 movaps 16(%rsp), %xmm7
378 movaps 32(%rsp), %xmm8
379 movaps 48(%rsp), %xmm9
380 movaps 64(%rsp), %xmm10
381 movaps 80(%rsp), %xmm11
382 movaps 96(%rsp), %xmm12
383 movaps 112(%rsp), %xmm13
384 movaps 128(%rsp), %xmm14
385 movaps 144(%rsp), %xmm15
386 mov %rbp, %rsp
387 pop %rbp
388 #endif
389 ret
390
391 NONEXEC_STACK