| 1 |
/* |
| 2 |
synth_x86_64_float: SSE optimized synth for x86-64 (float output version) |
| 3 |
|
| 4 |
copyright 1995-2026 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 Taihei Monma |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "x86_64_defs.h" |
| 10 |
#include "mangle.h" |
| 11 |
|
| 12 |
#ifdef IS_MSABI |
| 13 |
/* short *window; */ |
| 14 |
#define ARG0 %r10 |
| 15 |
/* short *b0; */ |
| 16 |
#define ARG1 %rdx |
| 17 |
/* short *samples; */ |
| 18 |
#define ARG2 %r8 |
| 19 |
/* int bo1; */ |
| 20 |
#define ARG3 %r9 |
| 21 |
#else |
| 22 |
/* real *window; */ |
| 23 |
#define ARG0 %rdi |
| 24 |
/* real *b0; */ |
| 25 |
#define ARG1 %rsi |
| 26 |
/* real *samples; */ |
| 27 |
#define ARG2 %rdx |
| 28 |
/* int bo1; */ |
| 29 |
#define ARG3 %rcx |
| 30 |
#endif |
| 31 |
|
| 32 |
#define XMMREG_SCALE %xmm15 /* {1/32768.0, 1/32768.0, 1/32768.0, 1/32768.0} */ |
| 33 |
|
| 34 |
/* |
| 35 |
int synth_1to1_real_x86_64_asm(real *window, real *b0, real *samples, int bo1); |
| 36 |
return value: number of clipped samples (0) |
| 37 |
*/ |
| 38 |
|
| 39 |
RODATA |
| 40 |
ALIGN32 |
| 41 |
ASM_NAME(INT123_scale_x86_64): |
| 42 |
.long 939524096 |
| 43 |
.long 939524096 |
| 44 |
.long 939524096 |
| 45 |
.long 939524096 |
| 46 |
.text |
| 47 |
ALIGN16 |
| 48 |
.globl ASM_NAME(INT123_synth_1to1_real_x86_64_asm) |
| 49 |
ASM_NAME(INT123_synth_1to1_real_x86_64_asm): |
| 50 |
#ifdef IS_MSABI /* should save xmm6-15 */ |
| 51 |
movq %rcx, ARG0 |
| 52 |
subq $120, %rsp /* stack alignment + 7 xmm registers */ |
| 53 |
movaps %xmm6, (%rsp) |
| 54 |
movaps %xmm7, 16(%rsp) |
| 55 |
movaps %xmm8, 32(%rsp) |
| 56 |
movaps %xmm9, 48(%rsp) |
| 57 |
movaps %xmm10, 64(%rsp) |
| 58 |
movaps %xmm11, 80(%rsp) |
| 59 |
movaps %xmm15, 96(%rsp) |
| 60 |
#endif |
| 61 |
|
| 62 |
leaq ASM_NAME(INT123_scale_x86_64)(%rip), %rax |
| 63 |
movaps (%rax), XMMREG_SCALE |
| 64 |
|
| 65 |
andq $0xf, ARG3 |
| 66 |
shlq $2, ARG3 |
| 67 |
leaq 64(ARG0), ARG0 |
| 68 |
subq ARG3, ARG0 |
| 69 |
|
| 70 |
movl $4, %ecx |
| 71 |
|
| 72 |
ALIGN16 |
| 73 |
1: |
| 74 |
movups (ARG0), %xmm8 |
| 75 |
movups 16(ARG0), %xmm1 |
| 76 |
movups 32(ARG0), %xmm2 |
| 77 |
movups 48(ARG0), %xmm3 |
| 78 |
movups 128(ARG0), %xmm9 |
| 79 |
movups 144(ARG0), %xmm5 |
| 80 |
movups 160(ARG0), %xmm6 |
| 81 |
movups 176(ARG0), %xmm7 |
| 82 |
mulps (ARG1), %xmm8 |
| 83 |
mulps 16(ARG1), %xmm1 |
| 84 |
mulps 32(ARG1), %xmm2 |
| 85 |
mulps 48(ARG1), %xmm3 |
| 86 |
mulps 64(ARG1), %xmm9 |
| 87 |
mulps 80(ARG1), %xmm5 |
| 88 |
mulps 96(ARG1), %xmm6 |
| 89 |
mulps 112(ARG1), %xmm7 |
| 90 |
|
| 91 |
addps %xmm1, %xmm8 |
| 92 |
addps %xmm2, %xmm3 |
| 93 |
addps %xmm5, %xmm9 |
| 94 |
addps %xmm7, %xmm6 |
| 95 |
addps %xmm3, %xmm8 |
| 96 |
addps %xmm6, %xmm9 |
| 97 |
leaq 256(ARG0), ARG0 |
| 98 |
leaq 128(ARG1), ARG1 |
| 99 |
|
| 100 |
movups (ARG0), %xmm10 |
| 101 |
movups 16(ARG0), %xmm1 |
| 102 |
movups 32(ARG0), %xmm2 |
| 103 |
movups 48(ARG0), %xmm3 |
| 104 |
movups 128(ARG0), %xmm11 |
| 105 |
movups 144(ARG0), %xmm5 |
| 106 |
movups 160(ARG0), %xmm6 |
| 107 |
movups 176(ARG0), %xmm7 |
| 108 |
mulps (ARG1), %xmm10 |
| 109 |
mulps 16(ARG1), %xmm1 |
| 110 |
mulps 32(ARG1), %xmm2 |
| 111 |
mulps 48(ARG1), %xmm3 |
| 112 |
mulps 64(ARG1), %xmm11 |
| 113 |
mulps 80(ARG1), %xmm5 |
| 114 |
mulps 96(ARG1), %xmm6 |
| 115 |
mulps 112(ARG1), %xmm7 |
| 116 |
|
| 117 |
addps %xmm1, %xmm10 |
| 118 |
addps %xmm2, %xmm3 |
| 119 |
addps %xmm5, %xmm11 |
| 120 |
addps %xmm7, %xmm6 |
| 121 |
addps %xmm3, %xmm10 |
| 122 |
addps %xmm6, %xmm11 |
| 123 |
leaq 256(ARG0), ARG0 |
| 124 |
leaq 128(ARG1), ARG1 |
| 125 |
|
| 126 |
movaps %xmm8, %xmm0 |
| 127 |
movaps %xmm10, %xmm1 |
| 128 |
unpcklps %xmm9, %xmm8 |
| 129 |
unpcklps %xmm11, %xmm10 |
| 130 |
unpckhps %xmm9, %xmm0 |
| 131 |
unpckhps %xmm11, %xmm1 |
| 132 |
movaps %xmm8, %xmm2 |
| 133 |
movaps %xmm0, %xmm3 |
| 134 |
movlhps %xmm10, %xmm8 |
| 135 |
movhlps %xmm2, %xmm10 |
| 136 |
movlhps %xmm1, %xmm0 |
| 137 |
movhlps %xmm3, %xmm1 |
| 138 |
subps %xmm10, %xmm8 |
| 139 |
subps %xmm1, %xmm0 |
| 140 |
addps %xmm8, %xmm0 |
| 141 |
|
| 142 |
movups (ARG2), %xmm1 |
| 143 |
movups 16(ARG2), %xmm2 |
| 144 |
mulps XMMREG_SCALE, %xmm0 |
| 145 |
shufps $0xdd, %xmm2, %xmm1 |
| 146 |
movaps %xmm0, %xmm2 |
| 147 |
unpcklps %xmm1, %xmm0 |
| 148 |
unpckhps %xmm1, %xmm2 |
| 149 |
movups %xmm0, (ARG2) |
| 150 |
movups %xmm2, 16(ARG2) |
| 151 |
|
| 152 |
leaq 32(ARG2), ARG2 |
| 153 |
decl %ecx |
| 154 |
jnz 1b |
| 155 |
|
| 156 |
movl $4, %ecx |
| 157 |
|
| 158 |
ALIGN16 |
| 159 |
1: |
| 160 |
movups (ARG0), %xmm8 |
| 161 |
movups 16(ARG0), %xmm1 |
| 162 |
movups 32(ARG0), %xmm2 |
| 163 |
movups 48(ARG0), %xmm3 |
| 164 |
movups 128(ARG0), %xmm9 |
| 165 |
movups 144(ARG0), %xmm5 |
| 166 |
movups 160(ARG0), %xmm6 |
| 167 |
movups 176(ARG0), %xmm7 |
| 168 |
mulps (ARG1), %xmm8 |
| 169 |
mulps 16(ARG1), %xmm1 |
| 170 |
mulps 32(ARG1), %xmm2 |
| 171 |
mulps 48(ARG1), %xmm3 |
| 172 |
mulps -64(ARG1), %xmm9 |
| 173 |
mulps -48(ARG1), %xmm5 |
| 174 |
mulps -32(ARG1), %xmm6 |
| 175 |
mulps -16(ARG1), %xmm7 |
| 176 |
|
| 177 |
addps %xmm1, %xmm8 |
| 178 |
addps %xmm2, %xmm3 |
| 179 |
addps %xmm5, %xmm9 |
| 180 |
addps %xmm7, %xmm6 |
| 181 |
addps %xmm3, %xmm8 |
| 182 |
addps %xmm6, %xmm9 |
| 183 |
leaq 256(ARG0), ARG0 |
| 184 |
leaq -128(ARG1), ARG1 |
| 185 |
|
| 186 |
movups (ARG0), %xmm10 |
| 187 |
movups 16(ARG0), %xmm1 |
| 188 |
movups 32(ARG0), %xmm2 |
| 189 |
movups 48(ARG0), %xmm3 |
| 190 |
movups 128(ARG0), %xmm11 |
| 191 |
movups 144(ARG0), %xmm5 |
| 192 |
movups 160(ARG0), %xmm6 |
| 193 |
movups 176(ARG0), %xmm7 |
| 194 |
mulps (ARG1), %xmm10 |
| 195 |
mulps 16(ARG1), %xmm1 |
| 196 |
mulps 32(ARG1), %xmm2 |
| 197 |
mulps 48(ARG1), %xmm3 |
| 198 |
mulps -64(ARG1), %xmm11 |
| 199 |
mulps -48(ARG1), %xmm5 |
| 200 |
mulps -32(ARG1), %xmm6 |
| 201 |
mulps -16(ARG1), %xmm7 |
| 202 |
|
| 203 |
addps %xmm1, %xmm10 |
| 204 |
addps %xmm2, %xmm3 |
| 205 |
addps %xmm5, %xmm11 |
| 206 |
addps %xmm7, %xmm6 |
| 207 |
addps %xmm3, %xmm10 |
| 208 |
addps %xmm6, %xmm11 |
| 209 |
leaq 256(ARG0), ARG0 |
| 210 |
leaq -128(ARG1), ARG1 |
| 211 |
|
| 212 |
movaps %xmm8, %xmm0 |
| 213 |
movaps %xmm10, %xmm1 |
| 214 |
unpcklps %xmm9, %xmm8 |
| 215 |
unpcklps %xmm11, %xmm10 |
| 216 |
unpckhps %xmm9, %xmm0 |
| 217 |
unpckhps %xmm11, %xmm1 |
| 218 |
movaps %xmm8, %xmm2 |
| 219 |
movaps %xmm0, %xmm3 |
| 220 |
movlhps %xmm10, %xmm8 |
| 221 |
movhlps %xmm2, %xmm10 |
| 222 |
movlhps %xmm1, %xmm0 |
| 223 |
movhlps %xmm3, %xmm1 |
| 224 |
addps %xmm10, %xmm8 |
| 225 |
addps %xmm1, %xmm0 |
| 226 |
addps %xmm8, %xmm0 |
| 227 |
|
| 228 |
movups (ARG2), %xmm1 |
| 229 |
movups 16(ARG2), %xmm2 |
| 230 |
mulps XMMREG_SCALE, %xmm0 |
| 231 |
shufps $0xdd, %xmm2, %xmm1 |
| 232 |
movaps %xmm0, %xmm2 |
| 233 |
unpcklps %xmm1, %xmm0 |
| 234 |
unpckhps %xmm1, %xmm2 |
| 235 |
movups %xmm0, (ARG2) |
| 236 |
movups %xmm2, 16(ARG2) |
| 237 |
|
| 238 |
leaq 32(ARG2), ARG2 |
| 239 |
decl %ecx |
| 240 |
jnz 1b |
| 241 |
|
| 242 |
xorl %eax, %eax |
| 243 |
|
| 244 |
#ifdef IS_MSABI |
| 245 |
movaps (%rsp), %xmm6 |
| 246 |
movaps 16(%rsp), %xmm7 |
| 247 |
movaps 32(%rsp), %xmm8 |
| 248 |
movaps 48(%rsp), %xmm9 |
| 249 |
movaps 64(%rsp), %xmm10 |
| 250 |
movaps 80(%rsp), %xmm11 |
| 251 |
movaps 96(%rsp), %xmm15 |
| 252 |
addq $120, %rsp |
| 253 |
#endif |
| 254 |
ret |
| 255 |
|
| 256 |
NONEXEC_STACK |