2 # Copyright 2002,2005 Free Software Foundation, Inc.
4 # This file is part of GNU Radio
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
23 # input and taps are guarenteed to be 16 byte aligned.
24 # n_2_complex_blocks is != 0
27 # complex_dotprod_generic (const short *input,
28 # const float *taps, unsigned n_2_complex_blocks, float *result)
37 # sum0 += input[0] * taps[0];
38 # sum1 += input[0] * taps[1];
39 # sum2 += input[1] * taps[2];
40 # sum3 += input[1] * taps[3];
45 # } while (--n_2_complex_blocks != 0);
48 # result[0] = sum0 + sum2;
49 # result[1] = sum1 + sum3;
53 # TODO: prefetch and better scheduling
58 .file "complex_dotprod_sse64.S"
62 .globl GLOB_SYMB(complex_dotprod_sse)
63 DEF_FUNC_HEAD(complex_dotprod_sse)
64 GLOB_SYMB(complex_dotprod_sse):
66 # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx
71 # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults
72 # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results
74 xorps %xmm4, %xmm4 # zero two accumulators
75 xorps %xmm5, %xmm5 # xmm5 holds zero for use below
77 # first handle any non-zero remainder of (n_2_complex_blocks % 4)
86 punpcklwd 0(%rdi), %mm0
89 shufps $0x50, %xmm0, %xmm0
100 # set up for primary loop which is unrolled 4 times
102 movaps %xmm5, %xmm6 # zero remaining accumulators
103 shr $2, %rdx # n_2_complex_blocks / 4
106 je .cleanup # if zero, take short path
108 # finish setup and loop priming
111 punpcklwd 0(%rdi), %mm0
114 shufps $0x50, %xmm0, %xmm0
119 punpcklwd 4(%rdi), %mm1
122 shufps $0x50, %xmm1, %xmm1
126 # we know rax is not zero, we checked above,
127 # hence enter loop at top
135 punpcklwd 8(%rdi), %mm2
138 shufps $0x50, %xmm2, %xmm2
140 mulps 0x10(%rsi), %xmm1
144 punpcklwd 12(%rdi), %mm3
147 shufps $0x50, %xmm3, %xmm3
149 mulps 0x20(%rsi), %xmm2
153 punpcklwd 16(%rdi), %mm0
156 shufps $0x50, %xmm0, %xmm0
158 mulps 0x30(%rsi), %xmm3
162 punpcklwd 20(%rdi), %mm1
165 shufps $0x50, %xmm1, %xmm1
172 # OK, now we've done with all the multiplies, but
173 # we still need to handle the unaccumulated
174 # products in xmm2 and xmm3
179 # now we want to add all accumulators into xmm4
186 # At this point, xmm4 contains 2x2 partial sums. We need
187 # to compute a "horizontal complex add" across xmm4.
189 .cleanup: # xmm4 = r1 i2 r3 i4
190 movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2
191 addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4
192 movlps %xmm0, (%rcx) # store low 2x32 bits (complex) to memory
197 FUNC_TAIL(complex_dotprod_sse)
198 .ident "Hand coded x86_64 SSE assembly"