git subrepo clone https://github.com/libretro/libretro-common.git deps/libretro-common
[pcsx_rearmed.git] / deps / libretro-common / audio / resampler / drivers / sinc_resampler_neon.S
1 /* Copyright  (C) 2010-2020 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (sinc_resampler_neon.S).
5  * ---------------------------------------------------------------------------------------
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22
23 #if defined(__ARM_NEON__) && defined(HAVE_ARM_NEON_ASM_OPTIMIZATIONS)
24
25 #ifndef __MACH__
26 .arm
27 #endif
28 .align 4
29 .globl process_sinc_neon_asm
30 #ifndef __MACH__
31 .type process_sinc_neon_asm, %function
32 #endif
33 .globl _process_sinc_neon_asm
34 #ifndef __MACH__
35 .type _process_sinc_neon_asm, %function
36 #endif
37 # void process_sinc_neon(float *out, const float *left, const float *right, const float *coeff, unsigned taps)
38 # Assumes taps is >= 8, and a multiple of 8.
39 process_sinc_neon_asm:
40 _process_sinc_neon_asm:
41
42    push {r4, lr}
43    vmov.f32 q0, #0.0
44    vmov.f32 q8, #0.0
45
46    # Taps argument (r4) goes on stack in armeabi.
47    ldr r4, [sp, #8]
48
49 1:
50    # Left
51    vld1.f32 {q2-q3}, [r1]!
52    # Right
53    vld1.f32 {q10-q11}, [r2]!
54    # Coeff
55    vld1.f32 {q12-q13}, [r3, :128]!
56
57    # Left / Right
58    vmla.f32 q0, q2, q12
59    vmla.f32 q8, q10, q12
60    vmla.f32 q0, q3, q13
61    vmla.f32 q8, q11, q13
62
63    subs r4, r4, #8
64    bne 1b
65
66    # Add everything together
67    vadd.f32 d0, d0, d1
68    vadd.f32 d16, d16, d17
69    vpadd.f32 d0, d0, d16
70    vst1.f32 d0, [r0]
71
72    pop {r4, pc}
73
74 #endif