Debian Codegraph @

modules/lsp-dsp-lib/include/private/dsp/arch/x86/sse/mix.h

raw
1 /*
2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2020 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-dsp-lib
6 * Created on: 31 мар. 2020 г.
7 *
8 * lsp-dsp-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-dsp-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-dsp-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef PRIVATE_DSP_ARCH_X86_SSE_MIX_H_
23 #define PRIVATE_DSP_ARCH_X86_SSE_MIX_H_
24
25 #ifndef PRIVATE_DSP_ARCH_X86_SSE_IMPL
26 #error "This header should not be included directly"
27 #endif /* PRIVATE_DSP_ARCH_X86_SSE_IMPL */
28
29 namespace lsp
30 {
31 namespace sse
32 {
33 void mix2(float *a, const float *b, float k1, float k2, size_t count)
34 {
35 IF_ARCH_X86(size_t off);
36 ARCH_X86_ASM
37 (
38 __ASM_EMIT("movss %[k1], %%xmm6")
39 __ASM_EMIT("movss %[k2], %%xmm7")
40 __ASM_EMIT("xor %[off], %[off]")
41 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
42 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
43 // 12x blocks
44 __ASM_EMIT("sub $12, %[count]")
45 __ASM_EMIT("jb 2f")
46 __ASM_EMIT("1:")
47 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
48 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
49 __ASM_EMIT("movups 0x20(%[a],%[off]), %%xmm2")
50 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm3")
51 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm4")
52 __ASM_EMIT("movups 0x20(%[b],%[off]), %%xmm5")
53 __ASM_EMIT("mulps %%xmm6, %%xmm0")
54 __ASM_EMIT("mulps %%xmm7, %%xmm3")
55 __ASM_EMIT("mulps %%xmm6, %%xmm1")
56 __ASM_EMIT("mulps %%xmm7, %%xmm4")
57 __ASM_EMIT("mulps %%xmm6, %%xmm2")
58 __ASM_EMIT("mulps %%xmm7, %%xmm5")
59 __ASM_EMIT("addps %%xmm3, %%xmm0")
60 __ASM_EMIT("addps %%xmm4, %%xmm1")
61 __ASM_EMIT("addps %%xmm5, %%xmm2")
62 __ASM_EMIT("movups %%xmm0, 0x00(%[a],%[off])")
63 __ASM_EMIT("movups %%xmm1, 0x10(%[a],%[off])")
64 __ASM_EMIT("movups %%xmm2, 0x20(%[a],%[off])")
65 __ASM_EMIT("add $0x30, %[off]")
66 __ASM_EMIT("sub $12, %[count]")
67 __ASM_EMIT("jae 1b")
68 // 8x block
69 __ASM_EMIT("2:")
70 __ASM_EMIT("add $4, %[count]")
71 __ASM_EMIT("jl 4f")
72 __ASM_EMIT("1:")
73 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
74 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
75 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm3")
76 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm4")
77 __ASM_EMIT("mulps %%xmm6, %%xmm0")
78 __ASM_EMIT("mulps %%xmm7, %%xmm3")
79 __ASM_EMIT("mulps %%xmm6, %%xmm1")
80 __ASM_EMIT("mulps %%xmm7, %%xmm4")
81 __ASM_EMIT("addps %%xmm3, %%xmm0")
82 __ASM_EMIT("addps %%xmm4, %%xmm1")
83 __ASM_EMIT("movups %%xmm0, 0x00(%[a],%[off])")
84 __ASM_EMIT("movups %%xmm1, 0x10(%[a],%[off])")
85 __ASM_EMIT("add $0x20, %[off]")
86 __ASM_EMIT("sub $8, %[count]")
87 // 4x block
88 __ASM_EMIT("4:")
89 __ASM_EMIT("add $4, %[count]")
90 __ASM_EMIT("jl 6f")
91 __ASM_EMIT("1:")
92 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
93 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm3")
94 __ASM_EMIT("mulps %%xmm6, %%xmm0")
95 __ASM_EMIT("mulps %%xmm7, %%xmm3")
96 __ASM_EMIT("addps %%xmm3, %%xmm0")
97 __ASM_EMIT("movups %%xmm0, 0x00(%[a],%[off])")
98 __ASM_EMIT("add $0x10, %[off]")
99 __ASM_EMIT("sub $4, %[count]")
100 // 1x blocks
101 __ASM_EMIT("6:")
102 __ASM_EMIT("add $3, %[count]")
103 __ASM_EMIT("jl 8f")
104 __ASM_EMIT("7:")
105 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm0")
106 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm3")
107 __ASM_EMIT("mulss %%xmm6, %%xmm0")
108 __ASM_EMIT("mulss %%xmm7, %%xmm3")
109 __ASM_EMIT("addss %%xmm3, %%xmm0")
110 __ASM_EMIT("movss %%xmm0, 0x00(%[a],%[off])")
111 __ASM_EMIT("add $0x04, %[off]")
112 __ASM_EMIT("dec %[count]")
113 __ASM_EMIT("jge 7b")
114 // End
115 __ASM_EMIT("8:")
116 : [count] "+r" (count),
117 [off] "=&r" (off)
118 : [a] "r" (a), [b] "r" (b),
119 [k1] "m" (k1), [k2] "m" (k2)
120 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
121 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
122 );
123 }
124
125 void mix_copy2(float *dst, const float *a, const float *b, float k1, float k2, size_t count)
126 {
127 IF_ARCH_X86(size_t off);
128 ARCH_X86_ASM
129 (
130 __ASM_EMIT("movss %[k1], %%xmm6")
131 __ASM_EMIT("movss %[k2], %%xmm7")
132 __ASM_EMIT("xor %[off], %[off]")
133 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
134 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
135 // 12x blocks
136 __ASM_EMIT("sub $12, %[count]")
137 __ASM_EMIT("jb 2f")
138 __ASM_EMIT("1:")
139 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
140 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
141 __ASM_EMIT("movups 0x20(%[a],%[off]), %%xmm2")
142 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm3")
143 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm4")
144 __ASM_EMIT("movups 0x20(%[b],%[off]), %%xmm5")
145 __ASM_EMIT("mulps %%xmm6, %%xmm0")
146 __ASM_EMIT("mulps %%xmm7, %%xmm3")
147 __ASM_EMIT("mulps %%xmm6, %%xmm1")
148 __ASM_EMIT("mulps %%xmm7, %%xmm4")
149 __ASM_EMIT("mulps %%xmm6, %%xmm2")
150 __ASM_EMIT("mulps %%xmm7, %%xmm5")
151 __ASM_EMIT("addps %%xmm3, %%xmm0")
152 __ASM_EMIT("addps %%xmm4, %%xmm1")
153 __ASM_EMIT("addps %%xmm5, %%xmm2")
154 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
155 __ASM_EMIT("movups %%xmm1, 0x10(%[dst],%[off])")
156 __ASM_EMIT("movups %%xmm2, 0x20(%[dst],%[off])")
157 __ASM_EMIT("add $0x30, %[off]")
158 __ASM_EMIT("sub $12, %[count]")
159 __ASM_EMIT("jae 1b")
160 // 8x block
161 __ASM_EMIT("2:")
162 __ASM_EMIT("add $4, %[count]")
163 __ASM_EMIT("jl 4f")
164 __ASM_EMIT("1:")
165 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
166 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
167 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm3")
168 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm4")
169 __ASM_EMIT("mulps %%xmm6, %%xmm0")
170 __ASM_EMIT("mulps %%xmm7, %%xmm3")
171 __ASM_EMIT("mulps %%xmm6, %%xmm1")
172 __ASM_EMIT("mulps %%xmm7, %%xmm4")
173 __ASM_EMIT("addps %%xmm3, %%xmm0")
174 __ASM_EMIT("addps %%xmm4, %%xmm1")
175 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
176 __ASM_EMIT("movups %%xmm1, 0x10(%[dst],%[off])")
177 __ASM_EMIT("add $0x20, %[off]")
178 __ASM_EMIT("sub $8, %[count]")
179 // 4x block
180 __ASM_EMIT("4:")
181 __ASM_EMIT("add $4, %[count]")
182 __ASM_EMIT("jl 6f")
183 __ASM_EMIT("1:")
184 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
185 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm3")
186 __ASM_EMIT("mulps %%xmm6, %%xmm0")
187 __ASM_EMIT("mulps %%xmm7, %%xmm3")
188 __ASM_EMIT("addps %%xmm3, %%xmm0")
189 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
190 __ASM_EMIT("add $0x10, %[off]")
191 __ASM_EMIT("sub $4, %[count]")
192 // 1x blocks
193 __ASM_EMIT("6:")
194 __ASM_EMIT("add $3, %[count]")
195 __ASM_EMIT("jl 8f")
196 __ASM_EMIT("7:")
197 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm0")
198 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm3")
199 __ASM_EMIT("mulss %%xmm6, %%xmm0")
200 __ASM_EMIT("mulss %%xmm7, %%xmm3")
201 __ASM_EMIT("addss %%xmm3, %%xmm0")
202 __ASM_EMIT("movss %%xmm0, 0x00(%[dst],%[off])")
203 __ASM_EMIT("add $0x04, %[off]")
204 __ASM_EMIT("dec %[count]")
205 __ASM_EMIT("jge 7b")
206 // End
207 __ASM_EMIT("8:")
208 : [count] "+r" (count),
209 [off] "=&r" (off)
210 : [dst] "r" (dst), [a] "r" (a), [b] "r" (b),
211 [k1] "m" (k1), [k2] "m" (k2)
212 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
213 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
214 );
215 }
216
217 void mix_add2(float *dst, const float *a, const float *b, float k1, float k2, size_t count)
218 {
219 IF_ARCH_X86(size_t off);
220 ARCH_X86_ASM
221 (
222 __ASM_EMIT("movss %[k1], %%xmm6")
223 __ASM_EMIT("movss %[k2], %%xmm7")
224 __ASM_EMIT("xor %[off], %[off]")
225 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
226 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
227 // 8x blocks
228 __ASM_EMIT("sub $8, %[count]")
229 __ASM_EMIT("jb 2f")
230 __ASM_EMIT("1:")
231 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
232 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
233 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
234 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm3")
235 __ASM_EMIT("movups 0x00(%[dst],%[off]), %%xmm4")
236 __ASM_EMIT("movups 0x10(%[dst],%[off]), %%xmm5")
237 __ASM_EMIT("mulps %%xmm6, %%xmm0")
238 __ASM_EMIT("mulps %%xmm7, %%xmm2")
239 __ASM_EMIT("mulps %%xmm6, %%xmm1")
240 __ASM_EMIT("mulps %%xmm7, %%xmm3")
241 __ASM_EMIT("addps %%xmm0, %%xmm4")
242 __ASM_EMIT("addps %%xmm1, %%xmm5")
243 __ASM_EMIT("addps %%xmm2, %%xmm4")
244 __ASM_EMIT("addps %%xmm3, %%xmm5")
245 __ASM_EMIT("movups %%xmm4, 0x00(%[dst],%[off])")
246 __ASM_EMIT("movups %%xmm5, 0x10(%[dst],%[off])")
247 __ASM_EMIT("add $0x20, %[off]")
248 __ASM_EMIT("sub $8, %[count]")
249 __ASM_EMIT("jae 1b")
250 // 4x block
251 __ASM_EMIT("2:")
252 __ASM_EMIT("add $4, %[count]")
253 __ASM_EMIT("jl 4f")
254 __ASM_EMIT("1:")
255 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
256 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
257 __ASM_EMIT("movups 0x00(%[dst],%[off]), %%xmm4")
258 __ASM_EMIT("mulps %%xmm6, %%xmm0")
259 __ASM_EMIT("mulps %%xmm7, %%xmm2")
260 __ASM_EMIT("addps %%xmm0, %%xmm4")
261 __ASM_EMIT("addps %%xmm2, %%xmm4")
262 __ASM_EMIT("movups %%xmm4, 0x00(%[dst],%[off])")
263 __ASM_EMIT("add $0x10, %[off]")
264 __ASM_EMIT("sub $4, %[count]")
265 // 1x blocks
266 __ASM_EMIT("4:")
267 __ASM_EMIT("add $3, %[count]")
268 __ASM_EMIT("jl 6f")
269 __ASM_EMIT("5:")
270 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm0")
271 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm2")
272 __ASM_EMIT("movss 0x00(%[dst],%[off]), %%xmm4")
273 __ASM_EMIT("mulss %%xmm6, %%xmm0")
274 __ASM_EMIT("mulss %%xmm7, %%xmm2")
275 __ASM_EMIT("addss %%xmm0, %%xmm4")
276 __ASM_EMIT("addss %%xmm2, %%xmm4")
277 __ASM_EMIT("movss %%xmm4, 0x00(%[dst],%[off])")
278 __ASM_EMIT("add $0x04, %[off]")
279 __ASM_EMIT("dec %[count]")
280 __ASM_EMIT("jge 5b")
281 // End
282 __ASM_EMIT("6:")
283 : [count] "+r" (count),
284 [off] "=&r" (off)
285 : [dst] "r" (dst), [a] "r" (a), [b] "r" (b),
286 [k1] "m" (k1), [k2] "m" (k2)
287 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
288 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
289 );
290 }
291
292 void mix3(float *a, const float *b, const float *c, float k1, float k2, float k3, size_t count)
293 {
294 IF_ARCH_X86(size_t off);
295 ARCH_X86_ASM
296 (
297 __ASM_EMIT("movss %[k1], %%xmm5")
298 __ASM_EMIT("movss %[k2], %%xmm6")
299 __ASM_EMIT("movss %[k3], %%xmm7")
300 __ASM_EMIT("xor %[off], %[off]")
301 __ASM_EMIT("shufps $0x00, %%xmm5, %%xmm5")
302 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
303 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
304 // 8x blocks
305 __ASM_EMIT("sub $8, %[count]")
306 __ASM_EMIT("jb 2f")
307 __ASM_EMIT("1:")
308 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
309 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
310 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
311 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm3")
312 __ASM_EMIT("mulps %%xmm5, %%xmm0")
313 __ASM_EMIT("mulps %%xmm6, %%xmm2")
314 __ASM_EMIT("mulps %%xmm5, %%xmm1")
315 __ASM_EMIT("mulps %%xmm6, %%xmm3")
316 __ASM_EMIT("addps %%xmm2, %%xmm0")
317 __ASM_EMIT("addps %%xmm3, %%xmm1")
318 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
319 __ASM_EMIT("movups 0x10(%[c],%[off]), %%xmm3")
320 __ASM_EMIT("mulps %%xmm7, %%xmm2")
321 __ASM_EMIT("mulps %%xmm7, %%xmm3")
322 __ASM_EMIT("addps %%xmm2, %%xmm0")
323 __ASM_EMIT("addps %%xmm3, %%xmm1")
324 __ASM_EMIT("movups %%xmm0, 0x00(%[a],%[off])")
325 __ASM_EMIT("movups %%xmm1, 0x10(%[a],%[off])")
326 __ASM_EMIT("add $0x20, %[off]")
327 __ASM_EMIT("sub $8, %[count]")
328 __ASM_EMIT("jae 1b")
329 // 4x block
330 __ASM_EMIT("2:")
331 __ASM_EMIT("add $4, %[count]")
332 __ASM_EMIT("jl 4f")
333 __ASM_EMIT("1:")
334 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
335 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm1")
336 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
337 __ASM_EMIT("mulps %%xmm5, %%xmm0")
338 __ASM_EMIT("mulps %%xmm6, %%xmm1")
339 __ASM_EMIT("mulps %%xmm7, %%xmm2")
340 __ASM_EMIT("addps %%xmm1, %%xmm0")
341 __ASM_EMIT("addps %%xmm2, %%xmm0")
342 __ASM_EMIT("movups %%xmm0, 0x00(%[a],%[off])")
343 __ASM_EMIT("add $0x10, %[off]")
344 __ASM_EMIT("sub $4, %[count]")
345 // 1x blocks
346 __ASM_EMIT("4:")
347 __ASM_EMIT("add $3, %[count]")
348 __ASM_EMIT("jl 6f")
349 __ASM_EMIT("5:")
350 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm0")
351 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm1")
352 __ASM_EMIT("movss 0x00(%[c],%[off]), %%xmm2")
353 __ASM_EMIT("mulss %%xmm5, %%xmm0")
354 __ASM_EMIT("mulss %%xmm6, %%xmm1")
355 __ASM_EMIT("mulss %%xmm7, %%xmm2")
356 __ASM_EMIT("addss %%xmm1, %%xmm0")
357 __ASM_EMIT("addss %%xmm2, %%xmm0")
358 __ASM_EMIT("movss %%xmm0, 0x00(%[a],%[off])")
359 __ASM_EMIT("add $0x04, %[off]")
360 __ASM_EMIT("dec %[count]")
361 __ASM_EMIT("jge 5b")
362 // End
363 __ASM_EMIT("6:")
364 : [count] "+r" (count),
365 [off] "=&r" (off)
366 : [a] "r" (a), [b] "r" (b), [c] "r" (c),
367 [k1] "m" (k1), [k2] "m" (k2), [k3] "m" (k3)
368 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
369 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
370 );
371 }
372
373 void mix_copy3(float *dst, const float *a, const float *b, const float *c, float k1, float k2, float k3, size_t count)
374 {
375 IF_ARCH_X86(size_t off);
376 ARCH_X86_ASM
377 (
378 __ASM_EMIT("movss %[k1], %%xmm5")
379 __ASM_EMIT("movss %[k2], %%xmm6")
380 __ASM_EMIT("movss %[k3], %%xmm7")
381 __ASM_EMIT("xor %[off], %[off]")
382 __ASM_EMIT("shufps $0x00, %%xmm5, %%xmm5")
383 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
384 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
385 // 8x blocks
386 __ASM_EMIT("sub $8, %[count]")
387 __ASM_EMIT("jb 2f")
388 __ASM_EMIT("1:")
389 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
390 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
391 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
392 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm3")
393 __ASM_EMIT("mulps %%xmm5, %%xmm0")
394 __ASM_EMIT("mulps %%xmm6, %%xmm2")
395 __ASM_EMIT("mulps %%xmm5, %%xmm1")
396 __ASM_EMIT("mulps %%xmm6, %%xmm3")
397 __ASM_EMIT("addps %%xmm2, %%xmm0")
398 __ASM_EMIT("addps %%xmm3, %%xmm1")
399 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
400 __ASM_EMIT("movups 0x10(%[c],%[off]), %%xmm3")
401 __ASM_EMIT("mulps %%xmm7, %%xmm2")
402 __ASM_EMIT("mulps %%xmm7, %%xmm3")
403 __ASM_EMIT("addps %%xmm2, %%xmm0")
404 __ASM_EMIT("addps %%xmm3, %%xmm1")
405 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
406 __ASM_EMIT("movups %%xmm1, 0x10(%[dst],%[off])")
407 __ASM_EMIT("add $0x20, %[off]")
408 __ASM_EMIT("sub $8, %[count]")
409 __ASM_EMIT("jae 1b")
410 // 4x block
411 __ASM_EMIT("2:")
412 __ASM_EMIT("add $4, %[count]")
413 __ASM_EMIT("jl 4f")
414 __ASM_EMIT("1:")
415 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
416 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm1")
417 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
418 __ASM_EMIT("mulps %%xmm5, %%xmm0")
419 __ASM_EMIT("mulps %%xmm6, %%xmm1")
420 __ASM_EMIT("mulps %%xmm7, %%xmm2")
421 __ASM_EMIT("addps %%xmm1, %%xmm0")
422 __ASM_EMIT("addps %%xmm2, %%xmm0")
423 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
424 __ASM_EMIT("add $0x10, %[off]")
425 __ASM_EMIT("sub $4, %[count]")
426 // 1x blocks
427 __ASM_EMIT("4:")
428 __ASM_EMIT("add $3, %[count]")
429 __ASM_EMIT("jl 6f")
430 __ASM_EMIT("5:")
431 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm0")
432 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm1")
433 __ASM_EMIT("movss 0x00(%[c],%[off]), %%xmm2")
434 __ASM_EMIT("mulss %%xmm5, %%xmm0")
435 __ASM_EMIT("mulss %%xmm6, %%xmm1")
436 __ASM_EMIT("mulss %%xmm7, %%xmm2")
437 __ASM_EMIT("addss %%xmm1, %%xmm0")
438 __ASM_EMIT("addss %%xmm2, %%xmm0")
439 __ASM_EMIT("movss %%xmm0, 0x00(%[dst],%[off])")
440 __ASM_EMIT("add $0x04, %[off]")
441 __ASM_EMIT("dec %[count]")
442 __ASM_EMIT("jge 5b")
443 // End
444 __ASM_EMIT("6:")
445 : [count] "+r" (count),
446 [off] "=&r" (off)
447 : [dst] "r" (dst), [a] "r" (a), [b] "r" (b), [c] "r" (c),
448 [k1] "m" (k1), [k2] "m" (k2), [k3] "m" (k3)
449 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
450 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
451 );
452 }
453
454 void mix_add3(float *dst, const float *a, const float *b, const float *c, float k1, float k2, float k3, size_t count)
455 {
456 IF_ARCH_X86(size_t off);
457 ARCH_X86_ASM
458 (
459 __ASM_EMIT("movss %[k1], %%xmm5")
460 __ASM_EMIT("movss %[k2], %%xmm6")
461 __ASM_EMIT("movss %[k3], %%xmm7")
462 __ASM_EMIT("xor %[off], %[off]")
463 __ASM_EMIT("shufps $0x00, %%xmm5, %%xmm5")
464 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
465 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
466 // 8x blocks
467 __ASM_EMIT("sub $8, %[count]")
468 __ASM_EMIT("jb 2f")
469 __ASM_EMIT("1:")
470 __ASM_EMIT("movups 0x00(%[dst],%[off]), %%xmm0")
471 __ASM_EMIT("movups 0x10(%[dst],%[off]), %%xmm1")
472 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm2")
473 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm3")
474 __ASM_EMIT("mulps %%xmm5, %%xmm2")
475 __ASM_EMIT("mulps %%xmm5, %%xmm3")
476 __ASM_EMIT("addps %%xmm2, %%xmm0")
477 __ASM_EMIT("addps %%xmm3, %%xmm1")
478 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
479 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm3")
480 __ASM_EMIT("mulps %%xmm6, %%xmm2")
481 __ASM_EMIT("mulps %%xmm6, %%xmm3")
482 __ASM_EMIT("addps %%xmm2, %%xmm0")
483 __ASM_EMIT("addps %%xmm3, %%xmm1")
484 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
485 __ASM_EMIT("movups 0x10(%[c],%[off]), %%xmm3")
486 __ASM_EMIT("mulps %%xmm7, %%xmm2")
487 __ASM_EMIT("mulps %%xmm7, %%xmm3")
488 __ASM_EMIT("addps %%xmm2, %%xmm0")
489 __ASM_EMIT("addps %%xmm3, %%xmm1")
490 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
491 __ASM_EMIT("movups %%xmm1, 0x10(%[dst],%[off])")
492 __ASM_EMIT("add $0x20, %[off]")
493 __ASM_EMIT("sub $8, %[count]")
494 __ASM_EMIT("jae 1b")
495 // 4x block
496 __ASM_EMIT("2:")
497 __ASM_EMIT("add $4, %[count]")
498 __ASM_EMIT("jl 4f")
499 __ASM_EMIT("1:")
500 __ASM_EMIT("movups 0x00(%[dst],%[off]), %%xmm0")
501 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm1")
502 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
503 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm3")
504 __ASM_EMIT("mulps %%xmm5, %%xmm1")
505 __ASM_EMIT("mulps %%xmm6, %%xmm2")
506 __ASM_EMIT("mulps %%xmm7, %%xmm3")
507 __ASM_EMIT("addps %%xmm2, %%xmm1")
508 __ASM_EMIT("addps %%xmm3, %%xmm0")
509 __ASM_EMIT("addps %%xmm1, %%xmm0")
510 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
511 __ASM_EMIT("add $0x10, %[off]")
512 __ASM_EMIT("sub $4, %[count]")
513 // 1x blocks
514 __ASM_EMIT("4:")
515 __ASM_EMIT("add $3, %[count]")
516 __ASM_EMIT("jl 6f")
517 __ASM_EMIT("5:")
518 __ASM_EMIT("movss 0x00(%[dst],%[off]), %%xmm0")
519 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm1")
520 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm2")
521 __ASM_EMIT("movss 0x00(%[c],%[off]), %%xmm3")
522 __ASM_EMIT("mulss %%xmm5, %%xmm1")
523 __ASM_EMIT("mulss %%xmm6, %%xmm2")
524 __ASM_EMIT("mulss %%xmm7, %%xmm3")
525 __ASM_EMIT("addss %%xmm2, %%xmm1")
526 __ASM_EMIT("addss %%xmm3, %%xmm0")
527 __ASM_EMIT("addss %%xmm1, %%xmm0")
528 __ASM_EMIT("movss %%xmm0, 0x00(%[dst],%[off])")
529 __ASM_EMIT("add $0x04, %[off]")
530 __ASM_EMIT("dec %[count]")
531 __ASM_EMIT("jge 5b")
532 // End
533 __ASM_EMIT("6:")
534 : [count] "+r" (count),
535 [off] "=&r" (off)
536 : [dst] "r" (dst), [a] "r" (a), [b] "r" (b), [c] "r" (c),
537 [k1] "m" (k1), [k2] "m" (k2), [k3] "m" (k3)
538 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
539 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
540 );
541 }
542
543 void mix4(float *a, const float *b, const float *c, const float *d,
544 float k1, float k2, float k3, float k4, size_t count)
545 {
546 IF_ARCH_X86(size_t off);
547 ARCH_X86_ASM
548 (
549 __ASM_EMIT("movss %[k1], %%xmm4")
550 __ASM_EMIT("movss %[k2], %%xmm5")
551 __ASM_EMIT("movss %[k3], %%xmm6")
552 __ASM_EMIT("movss %[k4], %%xmm7")
553 __ASM_EMIT("xor %[off], %[off]")
554 __ASM_EMIT("shufps $0x00, %%xmm4, %%xmm4")
555 __ASM_EMIT("shufps $0x00, %%xmm5, %%xmm5")
556 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
557 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
558 // 8x blocks
559 __ASM_EMIT("sub $8, %[count]")
560 __ASM_EMIT("jb 2f")
561 __ASM_EMIT("1:")
562 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
563 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
564 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
565 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm3")
566 __ASM_EMIT("mulps %%xmm4, %%xmm0")
567 __ASM_EMIT("mulps %%xmm4, %%xmm1")
568 __ASM_EMIT("mulps %%xmm5, %%xmm2")
569 __ASM_EMIT("mulps %%xmm5, %%xmm3")
570 __ASM_EMIT("addps %%xmm2, %%xmm0")
571 __ASM_EMIT("addps %%xmm3, %%xmm1")
572 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
573 __ASM_EMIT("movups 0x10(%[c],%[off]), %%xmm3")
574 __ASM_EMIT("mulps %%xmm6, %%xmm2")
575 __ASM_EMIT("mulps %%xmm6, %%xmm3")
576 __ASM_EMIT("addps %%xmm2, %%xmm0")
577 __ASM_EMIT("addps %%xmm3, %%xmm1")
578 __ASM_EMIT("movups 0x00(%[d],%[off]), %%xmm2")
579 __ASM_EMIT("movups 0x10(%[d],%[off]), %%xmm3")
580 __ASM_EMIT("mulps %%xmm7, %%xmm2")
581 __ASM_EMIT("mulps %%xmm7, %%xmm3")
582 __ASM_EMIT("addps %%xmm2, %%xmm0")
583 __ASM_EMIT("addps %%xmm3, %%xmm1")
584 __ASM_EMIT("movups %%xmm0, 0x00(%[a],%[off])")
585 __ASM_EMIT("movups %%xmm1, 0x10(%[a],%[off])")
586 __ASM_EMIT("add $0x20, %[off]")
587 __ASM_EMIT("sub $8, %[count]")
588 __ASM_EMIT("jae 1b")
589 // 4x block
590 __ASM_EMIT("2:")
591 __ASM_EMIT("add $4, %[count]")
592 __ASM_EMIT("jl 4f")
593 __ASM_EMIT("1:")
594 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
595 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm1")
596 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
597 __ASM_EMIT("movups 0x00(%[d],%[off]), %%xmm3")
598 __ASM_EMIT("mulps %%xmm4, %%xmm0")
599 __ASM_EMIT("mulps %%xmm5, %%xmm1")
600 __ASM_EMIT("mulps %%xmm6, %%xmm2")
601 __ASM_EMIT("mulps %%xmm7, %%xmm3")
602 __ASM_EMIT("addps %%xmm1, %%xmm0")
603 __ASM_EMIT("addps %%xmm3, %%xmm2")
604 __ASM_EMIT("addps %%xmm2, %%xmm0")
605 __ASM_EMIT("movups %%xmm0, 0x00(%[a],%[off])")
606 __ASM_EMIT("add $0x10, %[off]")
607 __ASM_EMIT("sub $4, %[count]")
608 // 1x blocks
609 __ASM_EMIT("4:")
610 __ASM_EMIT("add $3, %[count]")
611 __ASM_EMIT("jl 6f")
612 __ASM_EMIT("5:")
613 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm0")
614 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm1")
615 __ASM_EMIT("movss 0x00(%[c],%[off]), %%xmm2")
616 __ASM_EMIT("movss 0x00(%[d],%[off]), %%xmm3")
617 __ASM_EMIT("mulss %%xmm4, %%xmm0")
618 __ASM_EMIT("mulss %%xmm5, %%xmm1")
619 __ASM_EMIT("mulss %%xmm6, %%xmm2")
620 __ASM_EMIT("mulss %%xmm7, %%xmm3")
621 __ASM_EMIT("addss %%xmm1, %%xmm0")
622 __ASM_EMIT("addss %%xmm3, %%xmm2")
623 __ASM_EMIT("addss %%xmm2, %%xmm0")
624 __ASM_EMIT("movss %%xmm0, 0x00(%[a],%[off])")
625 __ASM_EMIT("add $0x04, %[off]")
626 __ASM_EMIT("dec %[count]")
627 __ASM_EMIT("jge 5b")
628 // End
629 __ASM_EMIT("6:")
630 : [count] "+r" (count),
631 [off] "=&r" (off)
632 : [a] "r" (a), [b] "r" (b), [c] "r" (c), [d] "r" (d),
633 [k1] "m" (k1), [k2] "m" (k2), [k3] "m" (k3), [k4] "m" (k4)
634 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
635 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
636 );
637 }
638
639 #if defined(ARCH_I386)
640 void mix_copy4(float *dst, const float *a, const float *b, const float *c,
641 const float *d, float k1, float k2, float k3, float k4, size_t count)
642 {
643 ARCH_X86_ASM
644 (
645 __ASM_EMIT("movss %[k1], %%xmm4")
646 __ASM_EMIT("movss %[k2], %%xmm5")
647 __ASM_EMIT("movss %[k3], %%xmm6")
648 __ASM_EMIT("movss %[k4], %%xmm7")
649 __ASM_EMIT("shufps $0x00, %%xmm4, %%xmm4")
650 __ASM_EMIT("shufps $0x00, %%xmm5, %%xmm5")
651 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
652 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
653 // 8x blocks
654 __ASM_EMIT("subl $8, %[count]")
655 __ASM_EMIT("jb 2f")
656 __ASM_EMIT("1:")
657 __ASM_EMIT("movups 0x00(%[a]), %%xmm0")
658 __ASM_EMIT("movups 0x10(%[a]), %%xmm1")
659 __ASM_EMIT("movups 0x00(%[b]), %%xmm2")
660 __ASM_EMIT("movups 0x10(%[b]), %%xmm3")
661 __ASM_EMIT("mulps %%xmm4, %%xmm0")
662 __ASM_EMIT("mulps %%xmm4, %%xmm1")
663 __ASM_EMIT("mulps %%xmm5, %%xmm2")
664 __ASM_EMIT("mulps %%xmm5, %%xmm3")
665 __ASM_EMIT("addps %%xmm2, %%xmm0")
666 __ASM_EMIT("addps %%xmm3, %%xmm1")
667 __ASM_EMIT("movups 0x00(%[c]), %%xmm2")
668 __ASM_EMIT("movups 0x10(%[c]), %%xmm3")
669 __ASM_EMIT("mulps %%xmm6, %%xmm2")
670 __ASM_EMIT("mulps %%xmm6, %%xmm3")
671 __ASM_EMIT("addps %%xmm2, %%xmm0")
672 __ASM_EMIT("addps %%xmm3, %%xmm1")
673 __ASM_EMIT("movups 0x00(%[d]), %%xmm2")
674 __ASM_EMIT("movups 0x10(%[d]), %%xmm3")
675 __ASM_EMIT("mulps %%xmm7, %%xmm2")
676 __ASM_EMIT("mulps %%xmm7, %%xmm3")
677 __ASM_EMIT("addps %%xmm2, %%xmm0")
678 __ASM_EMIT("addps %%xmm3, %%xmm1")
679 __ASM_EMIT("movups %%xmm0, 0x00(%[dst])")
680 __ASM_EMIT("movups %%xmm1, 0x10(%[dst])")
681 __ASM_EMIT("add $0x20, %[a]")
682 __ASM_EMIT("add $0x20, %[b]")
683 __ASM_EMIT("add $0x20, %[c]")
684 __ASM_EMIT("add $0x20, %[d]")
685 __ASM_EMIT("add $0x20, %[dst]")
686 __ASM_EMIT("subl $8, %[count]")
687 __ASM_EMIT("jae 1b")
688 // 4x block
689 __ASM_EMIT("2:")
690 __ASM_EMIT("addl $4, %[count]")
691 __ASM_EMIT("jl 4f")
692 __ASM_EMIT("1:")
693 __ASM_EMIT("movups 0x00(%[a]), %%xmm0")
694 __ASM_EMIT("movups 0x00(%[b]), %%xmm1")
695 __ASM_EMIT("movups 0x00(%[c]), %%xmm2")
696 __ASM_EMIT("movups 0x00(%[d]), %%xmm3")
697 __ASM_EMIT("mulps %%xmm4, %%xmm0")
698 __ASM_EMIT("mulps %%xmm5, %%xmm1")
699 __ASM_EMIT("mulps %%xmm6, %%xmm2")
700 __ASM_EMIT("mulps %%xmm7, %%xmm3")
701 __ASM_EMIT("addps %%xmm1, %%xmm0")
702 __ASM_EMIT("addps %%xmm3, %%xmm2")
703 __ASM_EMIT("addps %%xmm2, %%xmm0")
704 __ASM_EMIT("movups %%xmm0, 0x00(%[dst])")
705 __ASM_EMIT("add $0x10, %[a]")
706 __ASM_EMIT("add $0x10, %[b]")
707 __ASM_EMIT("add $0x10, %[c]")
708 __ASM_EMIT("add $0x10, %[d]")
709 __ASM_EMIT("add $0x10, %[dst]")
710 __ASM_EMIT("subl $4, %[count]")
711 // 1x blocks
712 __ASM_EMIT("4:")
713 __ASM_EMIT("addl $3, %[count]")
714 __ASM_EMIT("jl 6f")
715 __ASM_EMIT("5:")
716 __ASM_EMIT("movss 0x00(%[a]), %%xmm0")
717 __ASM_EMIT("movss 0x00(%[b]), %%xmm1")
718 __ASM_EMIT("movss 0x00(%[c]), %%xmm2")
719 __ASM_EMIT("movss 0x00(%[d]), %%xmm3")
720 __ASM_EMIT("mulss %%xmm4, %%xmm0")
721 __ASM_EMIT("mulss %%xmm5, %%xmm1")
722 __ASM_EMIT("mulss %%xmm6, %%xmm2")
723 __ASM_EMIT("mulss %%xmm7, %%xmm3")
724 __ASM_EMIT("addss %%xmm1, %%xmm0")
725 __ASM_EMIT("addss %%xmm3, %%xmm2")
726 __ASM_EMIT("addss %%xmm2, %%xmm0")
727 __ASM_EMIT("movss %%xmm0, 0x00(%[dst])")
728 __ASM_EMIT("add $0x04, %[a]")
729 __ASM_EMIT("add $0x04, %[b]")
730 __ASM_EMIT("add $0x04, %[c]")
731 __ASM_EMIT("add $0x04, %[d]")
732 __ASM_EMIT("add $0x04, %[dst]")
733 __ASM_EMIT("decl %[count]")
734 __ASM_EMIT("jge 5b")
735 // End
736 __ASM_EMIT("6:")
737 : [dst] "+r" (dst), [a] "+r" (a), [b] "+r" (b), [c] "+r" (c), [d] "+r" (d),
738 [count] __ASM_ARG_RW(count)
739 : [k1] "m" (k1), [k2] "m" (k2), [k3] "m" (k3), [k4] "m" (k4)
740 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
741 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
742 );
743 }
744
745 void mix_add4(float *dst, const float *a, const float *b, const float *c,
746 const float *d, float k1, float k2, float k3, float k4, size_t count)
747 {
748 ARCH_X86_ASM
749 (
750 __ASM_EMIT("movss %[k1], %%xmm4")
751 __ASM_EMIT("movss %[k2], %%xmm5")
752 __ASM_EMIT("movss %[k3], %%xmm6")
753 __ASM_EMIT("movss %[k4], %%xmm7")
754 __ASM_EMIT("shufps $0x00, %%xmm4, %%xmm4")
755 __ASM_EMIT("shufps $0x00, %%xmm5, %%xmm5")
756 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
757 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
758 // 8x blocks
759 __ASM_EMIT("subl $8, %[count]")
760 __ASM_EMIT("jb 2f")
761 __ASM_EMIT("1:")
762 __ASM_EMIT("movups 0x00(%[dst]), %%xmm0")
763 __ASM_EMIT("movups 0x10(%[dst]), %%xmm1")
764 __ASM_EMIT("movups 0x00(%[a]), %%xmm2")
765 __ASM_EMIT("movups 0x10(%[a]), %%xmm3")
766 __ASM_EMIT("mulps %%xmm4, %%xmm2")
767 __ASM_EMIT("mulps %%xmm4, %%xmm3")
768 __ASM_EMIT("addps %%xmm2, %%xmm0")
769 __ASM_EMIT("addps %%xmm3, %%xmm1")
770 __ASM_EMIT("movups 0x00(%[b]), %%xmm2")
771 __ASM_EMIT("movups 0x10(%[b]), %%xmm3")
772 __ASM_EMIT("mulps %%xmm5, %%xmm2")
773 __ASM_EMIT("mulps %%xmm5, %%xmm3")
774 __ASM_EMIT("addps %%xmm2, %%xmm0")
775 __ASM_EMIT("addps %%xmm3, %%xmm1")
776 __ASM_EMIT("movups 0x00(%[c]), %%xmm2")
777 __ASM_EMIT("movups 0x10(%[c]), %%xmm3")
778 __ASM_EMIT("mulps %%xmm6, %%xmm2")
779 __ASM_EMIT("mulps %%xmm6, %%xmm3")
780 __ASM_EMIT("addps %%xmm2, %%xmm0")
781 __ASM_EMIT("addps %%xmm3, %%xmm1")
782 __ASM_EMIT("movups 0x00(%[d]), %%xmm2")
783 __ASM_EMIT("movups 0x10(%[d]), %%xmm3")
784 __ASM_EMIT("mulps %%xmm7, %%xmm2")
785 __ASM_EMIT("mulps %%xmm7, %%xmm3")
786 __ASM_EMIT("addps %%xmm2, %%xmm0")
787 __ASM_EMIT("addps %%xmm3, %%xmm1")
788 __ASM_EMIT("movups %%xmm0, 0x00(%[dst])")
789 __ASM_EMIT("movups %%xmm1, 0x10(%[dst])")
790 __ASM_EMIT("add $0x20, %[a]")
791 __ASM_EMIT("add $0x20, %[b]")
792 __ASM_EMIT("add $0x20, %[c]")
793 __ASM_EMIT("add $0x20, %[d]")
794 __ASM_EMIT("add $0x20, %[dst]")
795 __ASM_EMIT("sub $8, %[count]")
796 __ASM_EMIT("jae 1b")
797 // 4x block
798 __ASM_EMIT("2:")
799 __ASM_EMIT("addl $4, %[count]")
800 __ASM_EMIT("jl 4f")
801 __ASM_EMIT("1:")
802 __ASM_EMIT("movups 0x00(%[dst]), %%xmm0")
803 __ASM_EMIT("movups 0x00(%[a]), %%xmm2")
804 __ASM_EMIT("movups 0x00(%[b]), %%xmm3")
805 __ASM_EMIT("mulps %%xmm4, %%xmm2")
806 __ASM_EMIT("mulps %%xmm5, %%xmm3")
807 __ASM_EMIT("addps %%xmm2, %%xmm0")
808 __ASM_EMIT("addps %%xmm3, %%xmm0")
809 __ASM_EMIT("movups 0x00(%[c]), %%xmm2")
810 __ASM_EMIT("movups 0x00(%[d]), %%xmm3")
811 __ASM_EMIT("mulps %%xmm6, %%xmm2")
812 __ASM_EMIT("mulps %%xmm7, %%xmm3")
813 __ASM_EMIT("addps %%xmm2, %%xmm0")
814 __ASM_EMIT("addps %%xmm3, %%xmm0")
815 __ASM_EMIT("movups %%xmm0, 0x00(%[dst])")
816 __ASM_EMIT("add $0x10, %[a]")
817 __ASM_EMIT("add $0x10, %[b]")
818 __ASM_EMIT("add $0x10, %[c]")
819 __ASM_EMIT("add $0x10, %[d]")
820 __ASM_EMIT("add $0x10, %[dst]")
821 __ASM_EMIT("subl $4, %[count]")
822 // 1x blocks
823 __ASM_EMIT("4:")
824 __ASM_EMIT("addl $3, %[count]")
825 __ASM_EMIT("jl 6f")
826 __ASM_EMIT("5:")
827 __ASM_EMIT("movss 0x00(%[dst]), %%xmm0")
828 __ASM_EMIT("movss 0x00(%[a]), %%xmm2")
829 __ASM_EMIT("movss 0x00(%[b]), %%xmm3")
830 __ASM_EMIT("mulss %%xmm4, %%xmm2")
831 __ASM_EMIT("mulss %%xmm5, %%xmm3")
832 __ASM_EMIT("addss %%xmm2, %%xmm0")
833 __ASM_EMIT("addss %%xmm3, %%xmm0")
834 __ASM_EMIT("movss 0x00(%[c]), %%xmm2")
835 __ASM_EMIT("movss 0x00(%[d]), %%xmm3")
836 __ASM_EMIT("mulss %%xmm6, %%xmm2")
837 __ASM_EMIT("mulss %%xmm7, %%xmm3")
838 __ASM_EMIT("addss %%xmm2, %%xmm0")
839 __ASM_EMIT("addss %%xmm3, %%xmm0")
840 __ASM_EMIT("movss %%xmm0, 0x00(%[dst])")
841 __ASM_EMIT("add $0x04, %[a]")
842 __ASM_EMIT("add $0x04, %[b]")
843 __ASM_EMIT("add $0x04, %[c]")
844 __ASM_EMIT("add $0x04, %[d]")
845 __ASM_EMIT("add $0x04, %[dst]")
846 __ASM_EMIT("decl %[count]")
847 __ASM_EMIT("jge 5b")
848 // End
849 __ASM_EMIT("6:")
850 : [dst] "+r" (dst), [a] "+r" (a), [b] "+r" (b), [c] "+r" (c), [d] "+r" (d),
851 [count] __ASM_ARG_RW(count)
852 : [k1] "m" (k1), [k2] "m" (k2), [k3] "m" (k3), [k4] "m" (k4)
853 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
854 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
855 );
856 }
857 #else
858 void mix_copy4(float *dst, const float *a, const float *b, const float *c,
859 const float *d, float k1, float k2, float k3, float k4, size_t count)
860 {
861 IF_ARCH_X86(size_t off);
862 ARCH_X86_ASM
863 (
864 __ASM_EMIT("movss %[k1], %%xmm4")
865 __ASM_EMIT("movss %[k2], %%xmm5")
866 __ASM_EMIT("movss %[k3], %%xmm6")
867 __ASM_EMIT("movss %[k4], %%xmm7")
868 __ASM_EMIT("xor %[off], %[off]")
869 __ASM_EMIT("shufps $0x00, %%xmm4, %%xmm4")
870 __ASM_EMIT("shufps $0x00, %%xmm5, %%xmm5")
871 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
872 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
873 // 8x blocks
874 __ASM_EMIT("sub $8, %[count]")
875 __ASM_EMIT("jb 2f")
876 __ASM_EMIT("1:")
877 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
878 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm1")
879 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
880 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm3")
881 __ASM_EMIT("mulps %%xmm4, %%xmm0")
882 __ASM_EMIT("mulps %%xmm4, %%xmm1")
883 __ASM_EMIT("mulps %%xmm5, %%xmm2")
884 __ASM_EMIT("mulps %%xmm5, %%xmm3")
885 __ASM_EMIT("addps %%xmm2, %%xmm0")
886 __ASM_EMIT("addps %%xmm3, %%xmm1")
887 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
888 __ASM_EMIT("movups 0x10(%[c],%[off]), %%xmm3")
889 __ASM_EMIT("mulps %%xmm6, %%xmm2")
890 __ASM_EMIT("mulps %%xmm6, %%xmm3")
891 __ASM_EMIT("addps %%xmm2, %%xmm0")
892 __ASM_EMIT("addps %%xmm3, %%xmm1")
893 __ASM_EMIT("movups 0x00(%[d],%[off]), %%xmm2")
894 __ASM_EMIT("movups 0x10(%[d],%[off]), %%xmm3")
895 __ASM_EMIT("mulps %%xmm7, %%xmm2")
896 __ASM_EMIT("mulps %%xmm7, %%xmm3")
897 __ASM_EMIT("addps %%xmm2, %%xmm0")
898 __ASM_EMIT("addps %%xmm3, %%xmm1")
899 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
900 __ASM_EMIT("movups %%xmm1, 0x10(%[dst],%[off])")
901 __ASM_EMIT("add $0x20, %[off]")
902 __ASM_EMIT("sub $8, %[count]")
903 __ASM_EMIT("jae 1b")
904 // 4x block
905 __ASM_EMIT("2:")
906 __ASM_EMIT("add $4, %[count]")
907 __ASM_EMIT("jl 4f")
908 __ASM_EMIT("1:")
909 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm0")
910 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm1")
911 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
912 __ASM_EMIT("movups 0x00(%[d],%[off]), %%xmm3")
913 __ASM_EMIT("mulps %%xmm4, %%xmm0")
914 __ASM_EMIT("mulps %%xmm5, %%xmm1")
915 __ASM_EMIT("mulps %%xmm6, %%xmm2")
916 __ASM_EMIT("mulps %%xmm7, %%xmm3")
917 __ASM_EMIT("addps %%xmm1, %%xmm0")
918 __ASM_EMIT("addps %%xmm3, %%xmm2")
919 __ASM_EMIT("addps %%xmm2, %%xmm0")
920 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
921 __ASM_EMIT("add $0x10, %[off]")
922 __ASM_EMIT("sub $4, %[count]")
923 // 1x blocks
924 __ASM_EMIT("4:")
925 __ASM_EMIT("add $3, %[count]")
926 __ASM_EMIT("jl 6f")
927 __ASM_EMIT("5:")
928 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm0")
929 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm1")
930 __ASM_EMIT("movss 0x00(%[c],%[off]), %%xmm2")
931 __ASM_EMIT("movss 0x00(%[d],%[off]), %%xmm3")
932 __ASM_EMIT("mulss %%xmm4, %%xmm0")
933 __ASM_EMIT("mulss %%xmm5, %%xmm1")
934 __ASM_EMIT("mulss %%xmm6, %%xmm2")
935 __ASM_EMIT("mulss %%xmm7, %%xmm3")
936 __ASM_EMIT("addss %%xmm1, %%xmm0")
937 __ASM_EMIT("addss %%xmm3, %%xmm2")
938 __ASM_EMIT("addss %%xmm2, %%xmm0")
939 __ASM_EMIT("movss %%xmm0, 0x00(%[dst],%[off])")
940 __ASM_EMIT("add $0x04, %[off]")
941 __ASM_EMIT("dec %[count]")
942 __ASM_EMIT("jge 5b")
943 // End
944 __ASM_EMIT("6:")
945 : [count] "+r" (count),
946 [off] "=&r" (off)
947 : [dst] "r" (dst), [a] "r" (a), [b] "r" (b), [c] "r" (c), [d] "r" (d),
948 [k1] "m" (k1), [k2] "m" (k2), [k3] "m" (k3), [k4] "m" (k4)
949 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
950 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
951 );
952 }
953
954 void mix_add4(float *dst, const float *a, const float *b, const float *c,
955 const float *d, float k1, float k2, float k3, float k4, size_t count)
956 {
957 IF_ARCH_X86(size_t off);
958 ARCH_X86_ASM
959 (
960 __ASM_EMIT("movss %[k1], %%xmm4")
961 __ASM_EMIT("movss %[k2], %%xmm5")
962 __ASM_EMIT("movss %[k3], %%xmm6")
963 __ASM_EMIT("movss %[k4], %%xmm7")
964 __ASM_EMIT("xor %[off], %[off]")
965 __ASM_EMIT("shufps $0x00, %%xmm4, %%xmm4")
966 __ASM_EMIT("shufps $0x00, %%xmm5, %%xmm5")
967 __ASM_EMIT("shufps $0x00, %%xmm6, %%xmm6")
968 __ASM_EMIT("shufps $0x00, %%xmm7, %%xmm7")
969 // 8x blocks
970 __ASM_EMIT("sub $8, %[count]")
971 __ASM_EMIT("jb 2f")
972 __ASM_EMIT("1:")
973 __ASM_EMIT("movups 0x00(%[dst],%[off]), %%xmm0")
974 __ASM_EMIT("movups 0x10(%[dst],%[off]), %%xmm1")
975 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm2")
976 __ASM_EMIT("movups 0x10(%[a],%[off]), %%xmm3")
977 __ASM_EMIT("mulps %%xmm4, %%xmm2")
978 __ASM_EMIT("mulps %%xmm4, %%xmm3")
979 __ASM_EMIT("addps %%xmm2, %%xmm0")
980 __ASM_EMIT("addps %%xmm3, %%xmm1")
981 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm2")
982 __ASM_EMIT("movups 0x10(%[b],%[off]), %%xmm3")
983 __ASM_EMIT("mulps %%xmm5, %%xmm2")
984 __ASM_EMIT("mulps %%xmm5, %%xmm3")
985 __ASM_EMIT("addps %%xmm2, %%xmm0")
986 __ASM_EMIT("addps %%xmm3, %%xmm1")
987 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
988 __ASM_EMIT("movups 0x10(%[c],%[off]), %%xmm3")
989 __ASM_EMIT("mulps %%xmm6, %%xmm2")
990 __ASM_EMIT("mulps %%xmm6, %%xmm3")
991 __ASM_EMIT("addps %%xmm2, %%xmm0")
992 __ASM_EMIT("addps %%xmm3, %%xmm1")
993 __ASM_EMIT("movups 0x00(%[d],%[off]), %%xmm2")
994 __ASM_EMIT("movups 0x10(%[d],%[off]), %%xmm3")
995 __ASM_EMIT("mulps %%xmm7, %%xmm2")
996 __ASM_EMIT("mulps %%xmm7, %%xmm3")
997 __ASM_EMIT("addps %%xmm2, %%xmm0")
998 __ASM_EMIT("addps %%xmm3, %%xmm1")
999 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
1000 __ASM_EMIT("movups %%xmm1, 0x10(%[dst],%[off])")
1001 __ASM_EMIT("add $0x20, %[off]")
1002 __ASM_EMIT("sub $8, %[count]")
1003 __ASM_EMIT("jae 1b")
1004 // 4x block
1005 __ASM_EMIT("2:")
1006 __ASM_EMIT("add $4, %[count]")
1007 __ASM_EMIT("jl 4f")
1008 __ASM_EMIT("1:")
1009 __ASM_EMIT("movups 0x00(%[dst],%[off]), %%xmm0")
1010 __ASM_EMIT("movups 0x00(%[a],%[off]), %%xmm2")
1011 __ASM_EMIT("movups 0x00(%[b],%[off]), %%xmm3")
1012 __ASM_EMIT("mulps %%xmm4, %%xmm2")
1013 __ASM_EMIT("mulps %%xmm5, %%xmm3")
1014 __ASM_EMIT("addps %%xmm2, %%xmm0")
1015 __ASM_EMIT("addps %%xmm3, %%xmm0")
1016 __ASM_EMIT("movups 0x00(%[c],%[off]), %%xmm2")
1017 __ASM_EMIT("movups 0x00(%[d],%[off]), %%xmm3")
1018 __ASM_EMIT("mulps %%xmm6, %%xmm2")
1019 __ASM_EMIT("mulps %%xmm7, %%xmm3")
1020 __ASM_EMIT("addps %%xmm2, %%xmm0")
1021 __ASM_EMIT("addps %%xmm3, %%xmm0")
1022 __ASM_EMIT("movups %%xmm0, 0x00(%[dst],%[off])")
1023 __ASM_EMIT("add $0x10, %[off]")
1024 __ASM_EMIT("sub $4, %[count]")
1025 // 1x blocks
1026 __ASM_EMIT("4:")
1027 __ASM_EMIT("add $3, %[count]")
1028 __ASM_EMIT("jl 6f")
1029 __ASM_EMIT("5:")
1030 __ASM_EMIT("movss 0x00(%[dst],%[off]), %%xmm0")
1031 __ASM_EMIT("movss 0x00(%[a],%[off]), %%xmm2")
1032 __ASM_EMIT("movss 0x00(%[b],%[off]), %%xmm3")
1033 __ASM_EMIT("mulss %%xmm4, %%xmm2")
1034 __ASM_EMIT("mulss %%xmm5, %%xmm3")
1035 __ASM_EMIT("addss %%xmm2, %%xmm0")
1036 __ASM_EMIT("addss %%xmm3, %%xmm0")
1037 __ASM_EMIT("movss 0x00(%[c],%[off]), %%xmm2")
1038 __ASM_EMIT("movss 0x00(%[d],%[off]), %%xmm3")
1039 __ASM_EMIT("mulss %%xmm6, %%xmm2")
1040 __ASM_EMIT("mulss %%xmm7, %%xmm3")
1041 __ASM_EMIT("addss %%xmm2, %%xmm0")
1042 __ASM_EMIT("addss %%xmm3, %%xmm0")
1043 __ASM_EMIT("movss %%xmm0, 0x00(%[dst],%[off])")
1044 __ASM_EMIT("add $0x04, %[off]")
1045 __ASM_EMIT("dec %[count]")
1046 __ASM_EMIT("jge 5b")
1047 // End
1048 __ASM_EMIT("6:")
1049 : [count] "+r" (count),
1050 [off] "=&r" (off)
1051 : [dst] "r" (dst), [a] "r" (a), [b] "r" (b), [c] "r" (c), [d] "r" (d),
1052 [k1] "m" (k1), [k2] "m" (k2), [k3] "m" (k3), [k4] "m" (k4)
1053 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
1054 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
1055 );
1056 }
1057 #endif
1058 }
1059 }
1060
1061 #endif /* PRIVATE_DSP_ARCH_X86_SSE_MIX_H_ */