| 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_AARCH64_ASIMD_FFT_NORMALIZE_H_ |
| 23 |
#define PRIVATE_DSP_ARCH_AARCH64_ASIMD_FFT_NORMALIZE_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 |
void normalize_fft3(float *dre, float *dim, const float *re, const float *im, size_t rank) |
| 34 |
{ |
| 35 |
IF_ARCH_AARCH64( |
| 36 |
float k = 1.0f/(1 << rank); |
| 37 |
size_t count = 1 << rank; |
| 38 |
); |
| 39 |
ARCH_AARCH64_ASM( |
| 40 |
// x8 blocks |
| 41 |
__ASM_EMIT("dup v0.4s, %[k].s[0]") // v0 = k |
| 42 |
__ASM_EMIT("subs %[count], %[count], #8") |
| 43 |
__ASM_EMIT("mov v1.16b, v0.16b") |
| 44 |
__ASM_EMIT("b.lt 2f") |
| 45 |
__ASM_EMIT("1:") |
| 46 |
__ASM_EMIT("ldp q4, q5, [%[s_re], #0x00]") |
| 47 |
__ASM_EMIT("ldp q6, q7, [%[s_im], #0x00]") |
| 48 |
__ASM_EMIT("fmul v4.4s, v4.4s, v0.4s") |
| 49 |
__ASM_EMIT("fmul v5.4s, v5.4s, v1.4s") |
| 50 |
__ASM_EMIT("fmul v6.4s, v6.4s, v0.4s") |
| 51 |
__ASM_EMIT("fmul v7.4s, v7.4s, v1.4s") |
| 52 |
__ASM_EMIT("stp q4, q5, [%[d_re], #0x00]") |
| 53 |
__ASM_EMIT("stp q6, q7, [%[d_im], #0x00]") |
| 54 |
__ASM_EMIT("subs %[count], %[count], #8") |
| 55 |
__ASM_EMIT("add %[s_re], %[s_re], #0x20") |
| 56 |
__ASM_EMIT("add %[s_im], %[s_im], #0x20") |
| 57 |
__ASM_EMIT("add %[d_re], %[d_re], #0x20") |
| 58 |
__ASM_EMIT("add %[d_im], %[d_im], #0x20") |
| 59 |
__ASM_EMIT("b.hs 1b") |
| 60 |
__ASM_EMIT("2:") |
| 61 |
: [s_re] "+r" (re), [s_im] "+r" (im), |
| 62 |
[d_re] "+r" (dre), [d_im] "+r" (dim), |
| 63 |
[k] "+w" (k), [count] "+r" (count) |
| 64 |
: |
| 65 |
: "cc", "memory", |
| 66 |
"v0", "v1", |
| 67 |
"v4", "v5", "v6", "v7" |
| 68 |
); |
| 69 |
} |
| 70 |
|
| 71 |
void normalize_fft2(float *re, float *im, size_t rank) |
| 72 |
{ |
| 73 |
IF_ARCH_AARCH64( |
| 74 |
float k = 1.0f/(1 << rank); |
| 75 |
size_t count = 1 << rank; |
| 76 |
); |
| 77 |
ARCH_AARCH64_ASM( |
| 78 |
// x8 blocks |
| 79 |
__ASM_EMIT("dup v0.4s, %[k].s[0]") // v0 = k |
| 80 |
__ASM_EMIT("subs %[count], %[count], #8") |
| 81 |
__ASM_EMIT("mov v1.16b, v0.16b") |
| 82 |
__ASM_EMIT("b.lt 2f") |
| 83 |
__ASM_EMIT("1:") |
| 84 |
__ASM_EMIT("ldp q4, q5, [%[d_re], #0x00]") |
| 85 |
__ASM_EMIT("ldp q6, q7, [%[d_im], #0x00]") |
| 86 |
__ASM_EMIT("fmul v4.4s, v4.4s, v0.4s") |
| 87 |
__ASM_EMIT("fmul v5.4s, v5.4s, v1.4s") |
| 88 |
__ASM_EMIT("fmul v6.4s, v6.4s, v0.4s") |
| 89 |
__ASM_EMIT("fmul v7.4s, v7.4s, v1.4s") |
| 90 |
__ASM_EMIT("stp q4, q5, [%[d_re], #0x00]") |
| 91 |
__ASM_EMIT("stp q6, q7, [%[d_im], #0x00]") |
| 92 |
__ASM_EMIT("subs %[count], %[count], #8") |
| 93 |
__ASM_EMIT("add %[d_re], %[d_re], #0x20") |
| 94 |
__ASM_EMIT("add %[d_im], %[d_im], #0x20") |
| 95 |
__ASM_EMIT("b.hs 1b") |
| 96 |
__ASM_EMIT("2:") |
| 97 |
: [d_re] "+r" (re), [d_im] "+r" (im), |
| 98 |
[k] "+w" (k), [count] "+r" (count) |
| 99 |
: |
| 100 |
: "cc", "memory", |
| 101 |
"v0", "v1", |
| 102 |
"v4", "v5", "v6", "v7" |
| 103 |
); |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
#endif /* PRIVATE_DSP_ARCH_AARCH64_ASIMD_FFT_NORMALIZE_H_ */ |