Debian Codegraph @

modules/lsp-dsp-lib/include/private/dsp/arch/aarch64/asimd/msmatrix.h

raw
1 /*
2 * Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2025 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_AARCH64_ASIMD_MSMATRIX_H_
23 #define PRIVATE_DSP_ARCH_AARCH64_ASIMD_MSMATRIX_H_
24
25 #ifndef PRIVATE_DSP_ARCH_AARCH64_ASIMD_IMPL
26 #error "This header should not be included directly"
27 #endif /* PRIVATE_DSP_ARCH_AARCH64_ASIMD_IMPL */
28
29 namespace lsp
30 {
31 namespace asimd
32 {
33 IF_ARCH_AARCH64(
34 static const float msmatrix_const[] __lsp_aligned16 =
35 {
36 LSP_DSP_VEC4(0.5f)
37 };
38 );
39
40 void lr_to_ms(float *m, float *s, const float *l, const float *r, size_t count)
41 {
42 ARCH_AARCH64_ASM(
43 __ASM_EMIT("ldr q24, [%[HALF]]") // v24 = 0.5
44 // x16 blocks
45 __ASM_EMIT("subs %[count], %[count], #16")
46 __ASM_EMIT("b.lo 2f")
47 __ASM_EMIT("1:")
48 __ASM_EMIT("ldp q0, q1, [%[l], #0x00]") // v0 = l
49 __ASM_EMIT("ldp q2, q3, [%[l], #0x20]")
50 __ASM_EMIT("ldp q4, q5, [%[r], #0x00]") // v4 = r
51 __ASM_EMIT("ldp q6, q7, [%[r], #0x20]")
52 __ASM_EMIT("fadd v16.4s, v0.4s, v4.4s") // v16 = l + r
53 __ASM_EMIT("fadd v17.4s, v1.4s, v5.4s")
54 __ASM_EMIT("fadd v18.4s, v2.4s, v6.4s")
55 __ASM_EMIT("fadd v19.4s, v3.4s, v7.4s")
56 __ASM_EMIT("fsub v20.4s, v0.4s, v4.4s") // v20 = l - r
57 __ASM_EMIT("fsub v21.4s, v1.4s, v5.4s")
58 __ASM_EMIT("fsub v22.4s, v2.4s, v6.4s")
59 __ASM_EMIT("fsub v23.4s, v3.4s, v7.4s")
60 __ASM_EMIT("fmul v0.4s, v16.4s, v24.4s") // v0 = (l + r)/2
61 __ASM_EMIT("fmul v1.4s, v17.4s, v24.4s")
62 __ASM_EMIT("fmul v2.4s, v18.4s, v24.4s")
63 __ASM_EMIT("fmul v3.4s, v19.4s, v24.4s")
64 __ASM_EMIT("fmul v4.4s, v20.4s, v24.4s") // v4 = (l - r)/2
65 __ASM_EMIT("fmul v5.4s, v21.4s, v24.4s")
66 __ASM_EMIT("fmul v6.4s, v22.4s, v24.4s")
67 __ASM_EMIT("fmul v7.4s, v23.4s, v24.4s")
68 __ASM_EMIT("stp q0, q1, [%[m], #0x00]")
69 __ASM_EMIT("stp q2, q3, [%[m], #0x20]")
70 __ASM_EMIT("stp q4, q5, [%[s], #0x00]")
71 __ASM_EMIT("stp q6, q7, [%[s], #0x20]")
72 __ASM_EMIT("subs %[count], %[count], #16")
73 __ASM_EMIT("add %[l], %[l], #0x40")
74 __ASM_EMIT("add %[r], %[r], #0x40")
75 __ASM_EMIT("add %[m], %[m], #0x40")
76 __ASM_EMIT("add %[s], %[s], #0x40")
77 __ASM_EMIT("b.hs 1b")
78 __ASM_EMIT("2:")
79 // x8 block
80 __ASM_EMIT("adds %[count], %[count], #8")
81 __ASM_EMIT("b.lt 4f")
82 __ASM_EMIT("ldp q0, q1, [%[l], #0x00]") // v0 = l
83 __ASM_EMIT("ldp q4, q5, [%[r], #0x00]") // v4 = r
84 __ASM_EMIT("fadd v16.4s, v0.4s, v4.4s") // v16 = l + r
85 __ASM_EMIT("fadd v17.4s, v1.4s, v5.4s")
86 __ASM_EMIT("fsub v20.4s, v0.4s, v4.4s") // v20 = l - r
87 __ASM_EMIT("fsub v21.4s, v1.4s, v5.4s")
88 __ASM_EMIT("fmul v0.4s, v16.4s, v24.4s") // v0 = (l + r)/2
89 __ASM_EMIT("fmul v1.4s, v17.4s, v24.4s")
90 __ASM_EMIT("fmul v4.4s, v20.4s, v24.4s") // v4 = (l - r)/2
91 __ASM_EMIT("fmul v5.4s, v21.4s, v24.4s")
92 __ASM_EMIT("stp q0, q1, [%[m], #0x00]")
93 __ASM_EMIT("stp q4, q5, [%[s], #0x00]")
94 __ASM_EMIT("sub %[count], %[count], #8")
95 __ASM_EMIT("add %[l], %[l], #0x20")
96 __ASM_EMIT("add %[r], %[r], #0x20")
97 __ASM_EMIT("add %[m], %[m], #0x20")
98 __ASM_EMIT("add %[s], %[s], #0x20")
99 __ASM_EMIT("4:")
100 // x4 block
101 __ASM_EMIT("adds %[count], %[count], #4")
102 __ASM_EMIT("b.lt 6f")
103 __ASM_EMIT("ldr q0, [%[l]]") // v0 = l
104 __ASM_EMIT("ldr q4, [%[r]]") // v4 = r
105 __ASM_EMIT("fadd v16.4s, v0.4s, v4.4s") // v16 = l + r
106 __ASM_EMIT("fsub v20.4s, v0.4s, v4.4s") // v20 = l - r
107 __ASM_EMIT("fmul v0.4s, v16.4s, v24.4s") // v0 = (l + r)/2
108 __ASM_EMIT("fmul v4.4s, v20.4s, v24.4s") // v4 = (l - r)/2
109 __ASM_EMIT("str q0, [%[m]]")
110 __ASM_EMIT("str q4, [%[s]]")
111 __ASM_EMIT("sub %[count], %[count], #4")
112 __ASM_EMIT("add %[l], %[l], #0x10")
113 __ASM_EMIT("add %[r], %[r], #0x10")
114 __ASM_EMIT("add %[m], %[m], #0x10")
115 __ASM_EMIT("add %[s], %[s], #0x10")
116 __ASM_EMIT("6:")
117 // x1 blocks
118 __ASM_EMIT("adds %[count], %[count], #3")
119 __ASM_EMIT("b.lt 8f")
120 __ASM_EMIT("7:")
121 __ASM_EMIT("ld1r {v0.4s}, [%[l]]") // v0 = l
122 __ASM_EMIT("ld1r {v4.4s}, [%[r]]") // v4 = r
123 __ASM_EMIT("fadd v16.4s, v0.4s, v4.4s") // v16 = l + r
124 __ASM_EMIT("fsub v20.4s, v0.4s, v4.4s") // v20 = l - r
125 __ASM_EMIT("fmul v0.4s, v16.4s, v24.4s") // v0 = (l + r)/2
126 __ASM_EMIT("fmul v4.4s, v20.4s, v24.4s") // v4 = (l - r)/2
127 __ASM_EMIT("st1 {v0.s}[0], [%[m]]")
128 __ASM_EMIT("st1 {v4.s}[0], [%[s]]")
129 __ASM_EMIT("subs %[count], %[count], #1")
130 __ASM_EMIT("add %[l], %[l], #0x04")
131 __ASM_EMIT("add %[r], %[r], #0x04")
132 __ASM_EMIT("add %[m], %[m], #0x04")
133 __ASM_EMIT("add %[s], %[s], #0x04")
134 __ASM_EMIT("b.ge 7b")
135 __ASM_EMIT("8:")
136
137 : [l] "+r" (l), [r] "+r" (r), [m] "+r" (m), [s] "+r" (s),
138 [count] "+r" (count)
139 : [HALF] "r" (&msmatrix_const[0])
140 : "cc", "memory",
141 "v0", "v1", "v2", "v3",
142 "v4", "v5", "v6", "v7",
143 "v16", "v17", "v18", "v19",
144 "v20", "v21", "v22", "v23",
145 "v24"
146 );
147 }
148
149 void ms_to_lr(float *l, float *r, const float *m, const float *s, size_t count)
150 {
151 ARCH_AARCH64_ASM(
152 // x16 blocks
153 __ASM_EMIT("subs %[count], %[count], #16")
154 __ASM_EMIT("b.lo 2f")
155 __ASM_EMIT("1:")
156 __ASM_EMIT("ldp q0, q1, [%[m], #0x00]") // v0 = m
157 __ASM_EMIT("ldp q2, q3, [%[m], #0x20]")
158 __ASM_EMIT("ldp q4, q5, [%[s], #0x00]") // v4 = s
159 __ASM_EMIT("ldp q6, q7, [%[s], #0x20]")
160 __ASM_EMIT("fadd v16.4s, v0.4s, v4.4s") // v16 = m + s
161 __ASM_EMIT("fadd v17.4s, v1.4s, v5.4s")
162 __ASM_EMIT("fadd v18.4s, v2.4s, v6.4s")
163 __ASM_EMIT("fadd v19.4s, v3.4s, v7.4s")
164 __ASM_EMIT("fsub v20.4s, v0.4s, v4.4s") // v20 = m - s
165 __ASM_EMIT("fsub v21.4s, v1.4s, v5.4s")
166 __ASM_EMIT("fsub v22.4s, v2.4s, v6.4s")
167 __ASM_EMIT("fsub v23.4s, v3.4s, v7.4s")
168 __ASM_EMIT("stp q16, q17, [%[l], #0x00]")
169 __ASM_EMIT("stp q18, q19, [%[l], #0x20]")
170 __ASM_EMIT("stp q20, q21, [%[r], #0x00]")
171 __ASM_EMIT("stp q22, q23, [%[r], #0x20]")
172 __ASM_EMIT("subs %[count], %[count], #16")
173 __ASM_EMIT("add %[l], %[l], #0x40")
174 __ASM_EMIT("add %[r], %[r], #0x40")
175 __ASM_EMIT("add %[m], %[m], #0x40")
176 __ASM_EMIT("add %[s], %[s], #0x40")
177 __ASM_EMIT("b.hs 1b")
178 __ASM_EMIT("2:")
179 // x8 block
180 __ASM_EMIT("adds %[count], %[count], #8")
181 __ASM_EMIT("b.lt 4f")
182 __ASM_EMIT("ldp q0, q1, [%[m], #0x00]") // v0 = m
183 __ASM_EMIT("ldp q4, q5, [%[s], #0x00]") // v4 = s
184 __ASM_EMIT("fadd v16.4s, v0.4s, v4.4s") // v16 = m + s
185 __ASM_EMIT("fadd v17.4s, v1.4s, v5.4s")
186 __ASM_EMIT("fsub v20.4s, v0.4s, v4.4s") // v20 = m - s
187 __ASM_EMIT("fsub v21.4s, v1.4s, v5.4s")
188 __ASM_EMIT("stp q16, q17, [%[l], #0x00]")
189 __ASM_EMIT("stp q20, q21, [%[r], #0x00]")
190 __ASM_EMIT("sub %[count], %[count], #8")
191 __ASM_EMIT("add %[l], %[l], #0x20")
192 __ASM_EMIT("add %[r], %[r], #0x20")
193 __ASM_EMIT("add %[m], %[m], #0x20")
194 __ASM_EMIT("add %[s], %[s], #0x20")
195 __ASM_EMIT("4:")
196 // x4 block
197 __ASM_EMIT("adds %[count], %[count], #4")
198 __ASM_EMIT("b.lt 6f")
199 __ASM_EMIT("ldr q0, [%[m]]") // v0 = m
200 __ASM_EMIT("ldr q4, [%[s]]") // v4 = s
201 __ASM_EMIT("fadd v16.4s, v0.4s, v4.4s") // v16 = m + s
202 __ASM_EMIT("fsub v20.4s, v0.4s, v4.4s") // v20 = m - s
203 __ASM_EMIT("str q16, [%[l]]")
204 __ASM_EMIT("str q20, [%[r]]")
205 __ASM_EMIT("sub %[count], %[count], #4")
206 __ASM_EMIT("add %[l], %[l], #0x10")
207 __ASM_EMIT("add %[r], %[r], #0x10")
208 __ASM_EMIT("add %[m], %[m], #0x10")
209 __ASM_EMIT("add %[s], %[s], #0x10")
210 __ASM_EMIT("6:")
211 // x1 blocks
212 __ASM_EMIT("adds %[count], %[count], #3")
213 __ASM_EMIT("b.lt 8f")
214 __ASM_EMIT("7:")
215 __ASM_EMIT("ld1r {v0.4s}, [%[m]]") // v0 = m
216 __ASM_EMIT("ld1r {v4.4s}, [%[s]]") // v4 = s
217 __ASM_EMIT("fadd v16.4s, v0.4s, v4.4s") // v16 = m + s
218 __ASM_EMIT("fsub v20.4s, v0.4s, v4.4s") // v20 = m - s
219 __ASM_EMIT("st1 {v16.s}[0], [%[l]]")
220 __ASM_EMIT("st1 {v20.s}[0], [%[r]]")
221 __ASM_EMIT("subs %[count], %[count], #1")
222 __ASM_EMIT("add %[l], %[l], #0x04")
223 __ASM_EMIT("add %[r], %[r], #0x04")
224 __ASM_EMIT("add %[m], %[m], #0x04")
225 __ASM_EMIT("add %[s], %[s], #0x04")
226 __ASM_EMIT("b.ge 7b")
227 __ASM_EMIT("8:")
228
229 : [l] "+r" (l), [r] "+r" (r), [m] "+r" (m), [s] "+r" (s),
230 [count] "+r" (count)
231 : [HALF] "r" (&msmatrix_const[0])
232 : "cc", "memory",
233 "v0", "v1", "v2", "v3",
234 "v4", "v5", "v6", "v7",
235 "v16", "v17", "v18", "v19",
236 "v20", "v21", "v22", "v23"
237 );
238 }
239
240 #define LR_TO_PART(OP) \
241 __ASM_EMIT("ldr q24, [%[HALF]]") /* v24 = 0.5 */ \
242 /* x16 blocks */ \
243 __ASM_EMIT("subs %[count], %[count], #16") \
244 __ASM_EMIT("b.lo 2f") \
245 __ASM_EMIT("1:") \
246 __ASM_EMIT("ldp q0, q1, [%[l], #0x00]") /* v0 = l */ \
247 __ASM_EMIT("ldp q2, q3, [%[l], #0x20]") \
248 __ASM_EMIT("ldp q4, q5, [%[r], #0x00]") /* v4 = r */ \
249 __ASM_EMIT("ldp q6, q7, [%[r], #0x20]") \
250 __ASM_EMIT(OP " v16.4s, v0.4s, v4.4s") /* v16 = l op r */ \
251 __ASM_EMIT(OP " v17.4s, v1.4s, v5.4s") \
252 __ASM_EMIT(OP " v18.4s, v2.4s, v6.4s") \
253 __ASM_EMIT(OP " v19.4s, v3.4s, v7.4s") \
254 __ASM_EMIT("fmul v0.4s, v16.4s, v24.4s") /* v0 = (l op r)/2 */ \
255 __ASM_EMIT("fmul v1.4s, v17.4s, v24.4s") \
256 __ASM_EMIT("fmul v2.4s, v18.4s, v24.4s") \
257 __ASM_EMIT("fmul v3.4s, v19.4s, v24.4s") \
258 __ASM_EMIT("stp q0, q1, [%[dst], #0x00]") \
259 __ASM_EMIT("stp q2, q3, [%[dst], #0x20]") \
260 __ASM_EMIT("subs %[count], %[count], #16") \
261 __ASM_EMIT("add %[l], %[l], #0x40") \
262 __ASM_EMIT("add %[r], %[r], #0x40") \
263 __ASM_EMIT("add %[dst], %[dst], #0x40") \
264 __ASM_EMIT("b.hs 1b") \
265 __ASM_EMIT("2:") \
266 /* x8 block */ \
267 __ASM_EMIT("adds %[count], %[count], #8") \
268 __ASM_EMIT("b.lt 4f") \
269 __ASM_EMIT("ldp q0, q1, [%[l], #0x00]") /* v0 = l */ \
270 __ASM_EMIT("ldp q4, q5, [%[r], #0x00]") /* v4 = r */ \
271 __ASM_EMIT(OP " v16.4s, v0.4s, v4.4s") /* v16 = l op r */ \
272 __ASM_EMIT(OP " v17.4s, v1.4s, v5.4s") \
273 __ASM_EMIT("fmul v0.4s, v16.4s, v24.4s") /* v0 = (l op r)/2 */ \
274 __ASM_EMIT("fmul v1.4s, v17.4s, v24.4s") \
275 __ASM_EMIT("stp q0, q1, [%[dst], #0x00]") \
276 __ASM_EMIT("sub %[count], %[count], #8") \
277 __ASM_EMIT("add %[l], %[l], #0x20") \
278 __ASM_EMIT("add %[r], %[r], #0x20") \
279 __ASM_EMIT("add %[dst], %[dst], #0x20") \
280 __ASM_EMIT("4:") \
281 /* x4 block */ \
282 __ASM_EMIT("adds %[count], %[count], #4") \
283 __ASM_EMIT("b.lt 6f") \
284 __ASM_EMIT("ldr q0, [%[l]]") /* v0 = l */ \
285 __ASM_EMIT("ldr q4, [%[r]]") /* v4 = r */ \
286 __ASM_EMIT(OP " v16.4s, v0.4s, v4.4s") /* v16 = l op r */ \
287 __ASM_EMIT("fmul v0.4s, v16.4s, v24.4s") /* v0 = (l op r)/2 */ \
288 __ASM_EMIT("str q0, [%[dst]]") \
289 __ASM_EMIT("sub %[count], %[count], #4") \
290 __ASM_EMIT("add %[l], %[l], #0x10") \
291 __ASM_EMIT("add %[r], %[r], #0x10") \
292 __ASM_EMIT("add %[dst], %[dst], #0x10") \
293 __ASM_EMIT("6:") \
294 /* x1 blocks */ \
295 __ASM_EMIT("adds %[count], %[count], #3") \
296 __ASM_EMIT("b.lt 8f") \
297 __ASM_EMIT("7:") \
298 __ASM_EMIT("ld1r {v0.4s}, [%[l]]") /* v0 = l */ \
299 __ASM_EMIT("ld1r {v4.4s}, [%[r]]") /* v4 = r */ \
300 __ASM_EMIT(OP " v16.4s, v0.4s, v4.4s") /* v16 = l op r */ \
301 __ASM_EMIT("fmul v0.4s, v16.4s, v24.4s") /* v0 = (l op r)/2 */ \
302 __ASM_EMIT("st1 {v0.s}[0], [%[dst]]") \
303 __ASM_EMIT("subs %[count], %[count], #1") \
304 __ASM_EMIT("add %[l], %[l], #0x04") \
305 __ASM_EMIT("add %[r], %[r], #0x04") \
306 __ASM_EMIT("add %[dst], %[dst], #0x04") \
307 __ASM_EMIT("b.ge 7b") \
308 __ASM_EMIT("8:")
309
310 void lr_to_mid(float *m, const float *l, const float *r, size_t count)
311 {
312 ARCH_AARCH64_ASM(
313 LR_TO_PART("fadd")
314 : [l] "+r" (l), [r] "+r" (r), [dst] "+r" (m),
315 [count] "+r" (count)
316 : [HALF] "r" (&msmatrix_const[0])
317 : "cc", "memory",
318 "v0", "v1", "v2", "v3",
319 "v4", "v5", "v6", "v7",
320 "v16", "v17", "v18", "v19",
321 "v24"
322 );
323 }
324
325 void lr_to_side(float *s, const float *l, const float *r, size_t count)
326 {
327 ARCH_AARCH64_ASM(
328 LR_TO_PART("fsub")
329 : [l] "+r" (l), [r] "+r" (r), [dst] "+r" (s),
330 [count] "+r" (count)
331 : [HALF] "r" (&msmatrix_const[0])
332 : "cc", "memory",
333 "v0", "v1", "v2", "v3",
334 "v4", "v5", "v6", "v7",
335 "v16", "v17", "v18", "v19",
336 "v24"
337 );
338 }
339
340 #undef LR_TO_PART
341
342 #define MS_TO_PART(OP) \
343 /* x16 blocks */ \
344 __ASM_EMIT("subs %[count], %[count], #16") \
345 __ASM_EMIT("b.lo 2f") \
346 __ASM_EMIT("1:") \
347 __ASM_EMIT("ldp q0, q1, [%[m], #0x00]") /* v0 = m */ \
348 __ASM_EMIT("ldp q2, q3, [%[m], #0x20]") \
349 __ASM_EMIT("ldp q4, q5, [%[s], #0x00]") /* v4 = s */ \
350 __ASM_EMIT("ldp q6, q7, [%[s], #0x20]") \
351 __ASM_EMIT(OP " v16.4s, v0.4s, v4.4s") /* v16 = m op s */ \
352 __ASM_EMIT(OP " v17.4s, v1.4s, v5.4s") \
353 __ASM_EMIT(OP " v18.4s, v2.4s, v6.4s") \
354 __ASM_EMIT(OP " v19.4s, v3.4s, v7.4s") \
355 __ASM_EMIT("stp q0, q1, [%[dst], #0x00]") \
356 __ASM_EMIT("stp q2, q3, [%[dst], #0x20]") \
357 __ASM_EMIT("subs %[count], %[count], #16") \
358 __ASM_EMIT("add %[m], %[m], #0x40") \
359 __ASM_EMIT("add %[s], %[s], #0x40") \
360 __ASM_EMIT("add %[dst], %[dst], #0x40") \
361 __ASM_EMIT("b.hs 1b") \
362 __ASM_EMIT("2:") \
363 /* x8 block */ \
364 __ASM_EMIT("adds %[count], %[count], #8") \
365 __ASM_EMIT("b.lt 4f") \
366 __ASM_EMIT("ldp q0, q1, [%[m], #0x00]") /* v0 = m */ \
367 __ASM_EMIT("ldp q4, q5, [%[s], #0x00]") /* v4 = s */ \
368 __ASM_EMIT(OP " v16.4s, v0.4s, v4.4s") /* v16 = m op s */ \
369 __ASM_EMIT(OP " v17.4s, v1.4s, v5.4s") \
370 __ASM_EMIT("stp q0, q1, [%[dst], #0x00]") \
371 __ASM_EMIT("sub %[count], %[count], #8") \
372 __ASM_EMIT("add %[m], %[m], #0x20") \
373 __ASM_EMIT("add %[s], %[s], #0x20") \
374 __ASM_EMIT("add %[dst], %[dst], #0x20") \
375 __ASM_EMIT("4:") \
376 /* x4 block */ \
377 __ASM_EMIT("adds %[count], %[count], #4") \
378 __ASM_EMIT("b.lt 6f") \
379 __ASM_EMIT("ldr q0, [%[m]]") /* v0 = m */ \
380 __ASM_EMIT("ldr q4, [%[s]]") /* v4 = s */ \
381 __ASM_EMIT(OP " v16.4s, v0.4s, v4.4s") /* v16 = m op s */ \
382 __ASM_EMIT("str q0, [%[dst]]") \
383 __ASM_EMIT("sub %[count], %[count], #4") \
384 __ASM_EMIT("add %[m], %[m], #0x10") \
385 __ASM_EMIT("add %[s], %[s], #0x10") \
386 __ASM_EMIT("add %[dst], %[dst], #0x10") \
387 __ASM_EMIT("6:") \
388 /* x1 blocks */ \
389 __ASM_EMIT("adds %[count], %[count], #3") \
390 __ASM_EMIT("b.lt 8f") \
391 __ASM_EMIT("7:") \
392 __ASM_EMIT("ld1r {v0.4s}, [%[m]]") /* v0 = m */ \
393 __ASM_EMIT("ld1r {v4.4s}, [%[s]]") /* v4 = s */ \
394 __ASM_EMIT(OP " v16.4s, v0.4s, v4.4s") /* v16 = m op s */ \
395 __ASM_EMIT("st1 {v0.s}[0], [%[dst]]") \
396 __ASM_EMIT("subs %[count], %[count], #1") \
397 __ASM_EMIT("add %[m], %[m], #0x04") \
398 __ASM_EMIT("add %[s], %[s], #0x04") \
399 __ASM_EMIT("add %[dst], %[dst], #0x04") \
400 __ASM_EMIT("b.ge 7b") \
401 __ASM_EMIT("8:")
402
403 void ms_to_left(float *l, const float *m, const float *s, size_t count)
404 {
405 ARCH_AARCH64_ASM(
406 MS_TO_PART("fadd")
407 : [m] "+r" (m), [s] "+r" (s), [dst] "+r" (l),
408 [count] "+r" (count)
409 :
410 : "cc", "memory",
411 "v0", "v1", "v2", "v3",
412 "v4", "v5", "v6", "v7",
413 "v16", "v17", "v18", "v19"
414 );
415 }
416
417 void ms_to_right(float *r, const float *m, const float *s, size_t count)
418 {
419 ARCH_AARCH64_ASM(
420 MS_TO_PART("fsub")
421 : [m] "+r" (m), [s] "+r" (s), [dst] "+r" (r),
422 [count] "+r" (count)
423 :
424 : "cc", "memory",
425 "v0", "v1", "v2", "v3",
426 "v4", "v5", "v6", "v7",
427 "v16", "v17", "v18", "v19"
428 );
429 }
430
431 #undef MS_TO_PART
432 } /* namespace asimd */
433 } /* namespace lsp */
434
435 #endif /* PRIVATE_DSP_ARCH_AARCH64_ASIMD_MSMATRIX_H_ */