562
|
1 /*
|
|
2 decode_3dnow.s - 3DNow! optimized synth_1to1()
|
|
3
|
|
4 copyright ?-2007 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 Syuuhei Kashiyama
|
|
7
|
|
8 This code based 'decode_3dnow.s' by Syuuhei Kashiyama
|
|
9 <squash@mb.kcom.ne.jp>,only two types of changes have been made:
|
|
10
|
|
11 - remove PREFETCH instruction for speedup
|
|
12 - change function name for support 3DNow! automatic detect
|
|
13 - femms moved to before 'call dct64_3dnow'
|
|
14
|
|
15 You can find Kashiyama's original 3dnow! support patch
|
|
16 (for mpg123-0.59o) at
|
|
17 http://user.ecc.u-tokyo.ac.jp/~g810370/linux-simd/ (Japanese).
|
|
18
|
|
19 by KIMURA Takuhiro <kim@hannah.ipc.miyakyo-u.ac.jp> - until 31.Mar.1999
|
|
20 <kim@comtec.co.jp> - after 1.Apr.1999
|
|
21
|
|
22
|
|
23
|
|
24 Replacement of synth_1to1() with AMD's 3DNow! SIMD operations support
|
|
25
|
|
26 Syuuhei Kashiyama <squash@mb.kcom.ne.jp>
|
|
27
|
|
28 The author of this program disclaim whole expressed or implied
|
|
29 warranties with regard to this program, and in no event shall the
|
|
30 author of this program liable to whatever resulted from the use of
|
|
31 this program. Use it at your own risk.
|
|
32 */
|
|
33
|
|
34 #include "mangle.h"
|
|
35
|
|
36 .text
|
|
37 .globl ASM_NAME(synth_1to1_3dnow_asm)
|
|
38 /* int synth_1to1_3dnow_asm(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin); */
|
|
39 ASM_NAME(synth_1to1_3dnow_asm):
|
|
40 subl $24,%esp
|
|
41 pushl %ebp
|
|
42 pushl %edi
|
|
43 xorl %ebp,%ebp
|
|
44 pushl %esi
|
|
45 pushl %ebx
|
|
46 /* stack old: 0=ebx 4=esi 8=edi 12=ebp 16,20,24,28,32,36=local 40=back 44=bandptr 48=channel 52=out 56=pnt */
|
|
47 /* stack new: 0=ebx 4=esi 8=edi 12=ebp 16,20,24,28,32,36=local 40=back 44=bandptr 48=channel 52=out 56=buffs 60=bo 64=decwin */
|
|
48 #define OUT 52(%esp)
|
|
49 #define CHANNEL 48(%esp)
|
|
50 #define BANDPTR 44(%esp)
|
|
51 #define BUFFS 56(%esp)
|
|
52 #define BO 60(%esp)
|
|
53 #define DECWIN 64(%esp)
|
|
54 #define LOCAL0 16(%esp)
|
|
55 #define LOCAL1 20(%esp)
|
|
56 #define LOCAL5 36(%esp)
|
|
57 movl OUT,%esi
|
|
58 movl %esi,LOCAL0 /* save buffer start (samples pointer) to another local var */
|
|
59 movl CHANNEL,%ebx
|
|
60 movl BO,%esi /* bo address */
|
|
61 movl (%esi),%edx /* bo value */
|
|
62
|
|
63 femms
|
|
64 testl %ebx,%ebx
|
|
65 jne .L26
|
|
66 /* if(!channel) */
|
|
67 decl %edx /* --bo */
|
|
68 andl $15,%edx
|
|
69 movl %edx,(%esi) /* save bo */
|
|
70 movl BUFFS,%ecx
|
|
71 jmp .L27
|
|
72 .L26: /* if(channel) */
|
|
73 addl $2,LOCAL0 /* samples++ */
|
|
74 movl BUFFS,%ecx
|
|
75 addl $2176,%ecx
|
|
76 .L27:
|
|
77 /* edx (and it's lower end) still holds bo value */
|
|
78 testb $1,%dl /* bo & 0x1 */
|
|
79 je .L28
|
|
80 movl %edx,LOCAL5
|
|
81 movl %ecx,%ebx
|
|
82 movl BANDPTR,%esi
|
|
83 movl %edx,%edi
|
|
84 pushl %esi
|
|
85 sall $2,%edi
|
|
86 movl %ebx,%eax
|
|
87 movl %edi,24(%esp) /* LOCAL1, actually */
|
|
88 addl %edi,%eax
|
|
89 pushl %eax
|
|
90 movl %edx,%eax
|
|
91 incl %eax
|
|
92 andl $15,%eax
|
|
93 leal 1088(,%eax,4),%eax
|
|
94 addl %ebx,%eax
|
|
95 pushl %eax
|
|
96 call ASM_NAME(dct64_3dnow)
|
|
97 addl $12,%esp
|
|
98 jmp .L29
|
|
99 .L28:
|
|
100 leal 1(%edx),%esi
|
|
101 movl BANDPTR,%edi
|
|
102 movl %esi,LOCAL5
|
|
103 leal 1092(%ecx,%edx,4),%eax
|
|
104 pushl %edi
|
|
105 leal 1088(%ecx),%ebx
|
|
106 pushl %eax
|
|
107 sall $2,%esi
|
|
108 leal (%ecx,%edx,4),%eax
|
|
109 pushl %eax
|
|
110 call ASM_NAME(dct64_3dnow)
|
|
111 addl $12,%esp
|
|
112 movl %esi,LOCAL1
|
|
113 .L29:
|
|
114 movl DECWIN,%edx
|
|
115 addl $64,%edx
|
|
116 movl $16,%ecx
|
|
117 subl LOCAL1,%edx
|
|
118 movl LOCAL0,%edi
|
|
119
|
|
120 movq (%edx),%mm0
|
|
121 movq (%ebx),%mm1
|
|
122 ALIGN32
|
|
123 .L33:
|
|
124 movq 8(%edx),%mm3
|
|
125 pfmul %mm1,%mm0
|
|
126 movq 8(%ebx),%mm4
|
|
127 movq 16(%edx),%mm5
|
|
128 pfmul %mm4,%mm3
|
|
129 movq 16(%ebx),%mm6
|
|
130 pfadd %mm3,%mm0
|
|
131 movq 24(%edx),%mm1
|
|
132 pfmul %mm6,%mm5
|
|
133 movq 24(%ebx),%mm2
|
|
134 pfadd %mm5,%mm0
|
|
135 movq 32(%edx),%mm3
|
|
136 pfmul %mm2,%mm1
|
|
137 movq 32(%ebx),%mm4
|
|
138 pfadd %mm1,%mm0
|
|
139 movq 40(%edx),%mm5
|
|
140 pfmul %mm4,%mm3
|
|
141 movq 40(%ebx),%mm6
|
|
142 pfadd %mm3,%mm0
|
|
143 movq 48(%edx),%mm1
|
|
144 pfmul %mm6,%mm5
|
|
145 movq 48(%ebx),%mm2
|
|
146 pfadd %mm0,%mm5
|
|
147 movq 56(%edx),%mm3
|
|
148 pfmul %mm1,%mm2
|
|
149 movq 56(%ebx),%mm4
|
|
150 pfadd %mm5,%mm2
|
|
151 addl $64,%ebx
|
|
152 subl $-128,%edx
|
|
153 movq (%edx),%mm0
|
|
154 pfmul %mm4,%mm3
|
|
155 movq (%ebx),%mm1
|
|
156 pfadd %mm3,%mm2
|
|
157 movq %mm2,%mm3
|
|
158 psrlq $32,%mm3
|
|
159 pfsub %mm3,%mm2
|
|
160 incl %ebp
|
|
161 pf2id %mm2,%mm2
|
|
162 packssdw %mm2,%mm2
|
|
163 movd %mm2,%eax
|
|
164 movw %ax,0(%edi)
|
|
165 addl $4,%edi
|
|
166 decl %ecx
|
|
167 jnz .L33
|
|
168
|
|
169 movd (%ebx),%mm0
|
|
170 movd (%edx),%mm1
|
|
171 punpckldq 8(%ebx),%mm0
|
|
172 punpckldq 8(%edx),%mm1
|
|
173 movd 16(%ebx),%mm3
|
|
174 movd 16(%edx),%mm4
|
|
175 pfmul %mm1,%mm0
|
|
176 punpckldq 24(%ebx),%mm3
|
|
177 punpckldq 24(%edx),%mm4
|
|
178 movd 32(%ebx),%mm5
|
|
179 movd 32(%edx),%mm6
|
|
180 pfmul %mm4,%mm3
|
|
181 punpckldq 40(%ebx),%mm5
|
|
182 punpckldq 40(%edx),%mm6
|
|
183 pfadd %mm3,%mm0
|
|
184 movd 48(%ebx),%mm1
|
|
185 movd 48(%edx),%mm2
|
|
186 pfmul %mm6,%mm5
|
|
187 punpckldq 56(%ebx),%mm1
|
|
188 punpckldq 56(%edx),%mm2
|
|
189 pfadd %mm5,%mm0
|
|
190 pfmul %mm2,%mm1
|
|
191 pfadd %mm1,%mm0
|
|
192 pfacc %mm1,%mm0
|
|
193 pf2id %mm0,%mm0
|
|
194 packssdw %mm0,%mm0
|
|
195 movd %mm0,%eax
|
|
196 movw %ax,0(%edi)
|
|
197 incl %ebp
|
|
198 movl LOCAL5,%esi
|
|
199 addl $-64,%ebx
|
|
200 movl $15,%ebp
|
|
201 addl $4,%edi
|
|
202 leal -128(%edx,%esi,8),%edx
|
|
203
|
|
204 movl $15,%ecx
|
|
205 movd (%ebx),%mm0
|
|
206 movd -4(%edx),%mm1
|
|
207 punpckldq 4(%ebx),%mm0
|
|
208 punpckldq -8(%edx),%mm1
|
|
209 ALIGN32
|
|
210 .L46:
|
|
211 movd 8(%ebx),%mm3
|
|
212 movd -12(%edx),%mm4
|
|
213 pfmul %mm1,%mm0
|
|
214 punpckldq 12(%ebx),%mm3
|
|
215 punpckldq -16(%edx),%mm4
|
|
216 movd 16(%ebx),%mm5
|
|
217 movd -20(%edx),%mm6
|
|
218 pfmul %mm4,%mm3
|
|
219 punpckldq 20(%ebx),%mm5
|
|
220 punpckldq -24(%edx),%mm6
|
|
221 pfadd %mm3,%mm0
|
|
222 movd 24(%ebx),%mm1
|
|
223 movd -28(%edx),%mm2
|
|
224 pfmul %mm6,%mm5
|
|
225 punpckldq 28(%ebx),%mm1
|
|
226 punpckldq -32(%edx),%mm2
|
|
227 pfadd %mm5,%mm0
|
|
228 movd 32(%ebx),%mm3
|
|
229 movd -36(%edx),%mm4
|
|
230 pfmul %mm2,%mm1
|
|
231 punpckldq 36(%ebx),%mm3
|
|
232 punpckldq -40(%edx),%mm4
|
|
233 pfadd %mm1,%mm0
|
|
234 movd 40(%ebx),%mm5
|
|
235 movd -44(%edx),%mm6
|
|
236 pfmul %mm4,%mm3
|
|
237 punpckldq 44(%ebx),%mm5
|
|
238 punpckldq -48(%edx),%mm6
|
|
239 pfadd %mm3,%mm0
|
|
240 movd 48(%ebx),%mm1
|
|
241 movd -52(%edx),%mm2
|
|
242 pfmul %mm6,%mm5
|
|
243 punpckldq 52(%ebx),%mm1
|
|
244 punpckldq -56(%edx),%mm2
|
|
245 pfadd %mm0,%mm5
|
|
246 movd 56(%ebx),%mm3
|
|
247 movd -60(%edx),%mm4
|
|
248 pfmul %mm2,%mm1
|
|
249 punpckldq 60(%ebx),%mm3
|
|
250 punpckldq (%edx),%mm4
|
|
251 pfadd %mm1,%mm5
|
|
252 addl $-128,%edx
|
|
253 addl $-64,%ebx
|
|
254 movd (%ebx),%mm0
|
|
255 movd -4(%edx),%mm1
|
|
256 pfmul %mm4,%mm3
|
|
257 punpckldq 4(%ebx),%mm0
|
|
258 punpckldq -8(%edx),%mm1
|
|
259 pfadd %mm5,%mm3
|
|
260 pfacc %mm3,%mm3
|
|
261 incl %ebp
|
|
262 pf2id %mm3,%mm3
|
|
263 movd %mm3,%eax
|
|
264 negl %eax
|
|
265 movd %eax,%mm3
|
|
266 packssdw %mm3,%mm3
|
|
267 movd %mm3,%eax
|
|
268 movw %ax,(%edi)
|
|
269 addl $4,%edi
|
|
270 decl %ecx
|
|
271 jnz .L46
|
|
272
|
|
273 femms
|
|
274 movl %ebp,%eax
|
|
275 popl %ebx
|
|
276 popl %esi
|
|
277 popl %edi
|
|
278 popl %ebp
|
|
279 addl $24,%esp
|
|
280 ret
|
|
281
|
|
282 /* Mark non-executable stack. */
|
|
283 #if defined(__linux__) && defined(__ELF__)
|
|
284 .section .note.GNU-stack,"",%progbits
|
|
285 #endif
|