1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Copyright (c) 2012
3cabdff1aSopenharmony_ci *      MIPS Technologies, Inc., California.
4cabdff1aSopenharmony_ci *
5cabdff1aSopenharmony_ci * Redistribution and use in source and binary forms, with or without
6cabdff1aSopenharmony_ci * modification, are permitted provided that the following conditions
7cabdff1aSopenharmony_ci * are met:
8cabdff1aSopenharmony_ci * 1. Redistributions of source code must retain the above copyright
9cabdff1aSopenharmony_ci *    notice, this list of conditions and the following disclaimer.
10cabdff1aSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
11cabdff1aSopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
12cabdff1aSopenharmony_ci *    documentation and/or other materials provided with the distribution.
13cabdff1aSopenharmony_ci * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14cabdff1aSopenharmony_ci *    contributors may be used to endorse or promote products derived from
15cabdff1aSopenharmony_ci *    this software without specific prior written permission.
16cabdff1aSopenharmony_ci *
17cabdff1aSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18cabdff1aSopenharmony_ci * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19cabdff1aSopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20cabdff1aSopenharmony_ci * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21cabdff1aSopenharmony_ci * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22cabdff1aSopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23cabdff1aSopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24cabdff1aSopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25cabdff1aSopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26cabdff1aSopenharmony_ci * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27cabdff1aSopenharmony_ci * SUCH DAMAGE.
28cabdff1aSopenharmony_ci *
29cabdff1aSopenharmony_ci * Author:  Branimir Vasic (bvasic@mips.com)
30cabdff1aSopenharmony_ci * Author:  Zoran Lukic (zoranl@mips.com)
31cabdff1aSopenharmony_ci *
32cabdff1aSopenharmony_ci * This file is part of FFmpeg.
33cabdff1aSopenharmony_ci *
34cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
35cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
36cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
37cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
38cabdff1aSopenharmony_ci *
39cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
40cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
41cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
42cabdff1aSopenharmony_ci * Lesser General Public License for more details.
43cabdff1aSopenharmony_ci *
44cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
45cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
46cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
47cabdff1aSopenharmony_ci */
48cabdff1aSopenharmony_ci
49cabdff1aSopenharmony_ci/**
50cabdff1aSopenharmony_ci * @file
51cabdff1aSopenharmony_ci * Reference: libavutil/float_dsp.c
52cabdff1aSopenharmony_ci */
53cabdff1aSopenharmony_ci
54cabdff1aSopenharmony_ci#include "config.h"
55cabdff1aSopenharmony_ci#include "libavutil/float_dsp.h"
56cabdff1aSopenharmony_ci#include "libavutil/mips/asmdefs.h"
57cabdff1aSopenharmony_ci
58cabdff1aSopenharmony_ci#if HAVE_INLINE_ASM && HAVE_MIPSFPU
59cabdff1aSopenharmony_ci#if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
60cabdff1aSopenharmony_cistatic void vector_fmul_mips(float *dst, const float *src0, const float *src1,
61cabdff1aSopenharmony_ci                             int len)
62cabdff1aSopenharmony_ci{
63cabdff1aSopenharmony_ci    int i;
64cabdff1aSopenharmony_ci
65cabdff1aSopenharmony_ci    if (len & 3) {
66cabdff1aSopenharmony_ci        for (i = 0; i < len; i++)
67cabdff1aSopenharmony_ci            dst[i] = src0[i] * src1[i];
68cabdff1aSopenharmony_ci    } else {
69cabdff1aSopenharmony_ci        float *d     = (float *)dst;
70cabdff1aSopenharmony_ci        float *d_end = d + len;
71cabdff1aSopenharmony_ci        float *s0    = (float *)src0;
72cabdff1aSopenharmony_ci        float *s1    = (float *)src1;
73cabdff1aSopenharmony_ci
74cabdff1aSopenharmony_ci        float src0_0, src0_1, src0_2, src0_3;
75cabdff1aSopenharmony_ci        float src1_0, src1_1, src1_2, src1_3;
76cabdff1aSopenharmony_ci
77cabdff1aSopenharmony_ci        __asm__ volatile (
78cabdff1aSopenharmony_ci            "1:                                         \n\t"
79cabdff1aSopenharmony_ci            "lwc1   %[src0_0],  0(%[s0])                \n\t"
80cabdff1aSopenharmony_ci            "lwc1   %[src1_0],  0(%[s1])                \n\t"
81cabdff1aSopenharmony_ci            "lwc1   %[src0_1],  4(%[s0])                \n\t"
82cabdff1aSopenharmony_ci            "lwc1   %[src1_1],  4(%[s1])                \n\t"
83cabdff1aSopenharmony_ci            "lwc1   %[src0_2],  8(%[s0])                \n\t"
84cabdff1aSopenharmony_ci            "lwc1   %[src1_2],  8(%[s1])                \n\t"
85cabdff1aSopenharmony_ci            "lwc1   %[src0_3],  12(%[s0])               \n\t"
86cabdff1aSopenharmony_ci            "lwc1   %[src1_3],  12(%[s1])               \n\t"
87cabdff1aSopenharmony_ci            "mul.s  %[src0_0],  %[src0_0],  %[src1_0]   \n\t"
88cabdff1aSopenharmony_ci            "mul.s  %[src0_1],  %[src0_1],  %[src1_1]   \n\t"
89cabdff1aSopenharmony_ci            "mul.s  %[src0_2],  %[src0_2],  %[src1_2]   \n\t"
90cabdff1aSopenharmony_ci            "mul.s  %[src0_3],  %[src0_3],  %[src1_3]   \n\t"
91cabdff1aSopenharmony_ci            "swc1   %[src0_0],  0(%[d])                 \n\t"
92cabdff1aSopenharmony_ci            "swc1   %[src0_1],  4(%[d])                 \n\t"
93cabdff1aSopenharmony_ci            "swc1   %[src0_2],  8(%[d])                 \n\t"
94cabdff1aSopenharmony_ci            "swc1   %[src0_3],  12(%[d])                \n\t"
95cabdff1aSopenharmony_ci            PTR_ADDIU "%[s0],   %[s0],      16          \n\t"
96cabdff1aSopenharmony_ci            PTR_ADDIU "%[s1],   %[s1],      16          \n\t"
97cabdff1aSopenharmony_ci            PTR_ADDIU "%[d],    %[d],       16          \n\t"
98cabdff1aSopenharmony_ci            "bne    %[d],       %[d_end],   1b          \n\t"
99cabdff1aSopenharmony_ci
100cabdff1aSopenharmony_ci            : [src0_0]"=&f"(src0_0), [src0_1]"=&f"(src0_1),
101cabdff1aSopenharmony_ci              [src0_2]"=&f"(src0_2), [src0_3]"=&f"(src0_3),
102cabdff1aSopenharmony_ci              [src1_0]"=&f"(src1_0), [src1_1]"=&f"(src1_1),
103cabdff1aSopenharmony_ci              [src1_2]"=&f"(src1_2), [src1_3]"=&f"(src1_3),
104cabdff1aSopenharmony_ci              [d]"+r"(d), [s0]"+r"(s0), [s1]"+r"(s1)
105cabdff1aSopenharmony_ci            : [d_end]"r"(d_end)
106cabdff1aSopenharmony_ci            : "memory"
107cabdff1aSopenharmony_ci        );
108cabdff1aSopenharmony_ci    }
109cabdff1aSopenharmony_ci}
110cabdff1aSopenharmony_ci
111cabdff1aSopenharmony_cistatic void vector_fmul_scalar_mips(float *dst, const float *src, float mul,
112cabdff1aSopenharmony_ci                                 int len)
113cabdff1aSopenharmony_ci{
114cabdff1aSopenharmony_ci    float temp0, temp1, temp2, temp3;
115cabdff1aSopenharmony_ci    float *local_src = (float*)src;
116cabdff1aSopenharmony_ci    float *end = local_src + len;
117cabdff1aSopenharmony_ci
118cabdff1aSopenharmony_ci    /* loop unrolled 4 times */
119cabdff1aSopenharmony_ci    __asm__ volatile(
120cabdff1aSopenharmony_ci        ".set    push                             \n\t"
121cabdff1aSopenharmony_ci        ".set    noreorder                        \n\t"
122cabdff1aSopenharmony_ci    "1:                                           \n\t"
123cabdff1aSopenharmony_ci        "lwc1    %[temp0],   0(%[src])            \n\t"
124cabdff1aSopenharmony_ci        "lwc1    %[temp1],   4(%[src])            \n\t"
125cabdff1aSopenharmony_ci        "lwc1    %[temp2],   8(%[src])            \n\t"
126cabdff1aSopenharmony_ci        "lwc1    %[temp3],   12(%[src])           \n\t"
127cabdff1aSopenharmony_ci        PTR_ADDIU "%[dst],   %[dst],     16       \n\t"
128cabdff1aSopenharmony_ci        "mul.s   %[temp0],   %[temp0],   %[mul]   \n\t"
129cabdff1aSopenharmony_ci        "mul.s   %[temp1],   %[temp1],   %[mul]   \n\t"
130cabdff1aSopenharmony_ci        "mul.s   %[temp2],   %[temp2],   %[mul]   \n\t"
131cabdff1aSopenharmony_ci        "mul.s   %[temp3],   %[temp3],   %[mul]   \n\t"
132cabdff1aSopenharmony_ci        PTR_ADDIU "%[src],   %[src],     16       \n\t"
133cabdff1aSopenharmony_ci        "swc1    %[temp0],   -16(%[dst])          \n\t"
134cabdff1aSopenharmony_ci        "swc1    %[temp1],   -12(%[dst])          \n\t"
135cabdff1aSopenharmony_ci        "swc1    %[temp2],   -8(%[dst])           \n\t"
136cabdff1aSopenharmony_ci        "bne     %[src],     %[end],     1b       \n\t"
137cabdff1aSopenharmony_ci        " swc1   %[temp3],   -4(%[dst])           \n\t"
138cabdff1aSopenharmony_ci        ".set    pop                              \n\t"
139cabdff1aSopenharmony_ci
140cabdff1aSopenharmony_ci        : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1),
141cabdff1aSopenharmony_ci          [temp2]"=&f"(temp2), [temp3]"=&f"(temp3),
142cabdff1aSopenharmony_ci          [dst]"+r"(dst), [src]"+r"(local_src)
143cabdff1aSopenharmony_ci        : [end]"r"(end), [mul]"f"(mul)
144cabdff1aSopenharmony_ci        : "memory"
145cabdff1aSopenharmony_ci    );
146cabdff1aSopenharmony_ci}
147cabdff1aSopenharmony_ci
148cabdff1aSopenharmony_cistatic void vector_fmul_window_mips(float *dst, const float *src0,
149cabdff1aSopenharmony_ci                                    const float *src1, const float *win, int len)
150cabdff1aSopenharmony_ci{
151cabdff1aSopenharmony_ci    float * dst_j, *win_j, *src0_i, *src1_j, *dst_i, *win_i;
152cabdff1aSopenharmony_ci    float temp, temp1, temp2, temp3;
153cabdff1aSopenharmony_ci    float s0, s01, s1, s11;
154cabdff1aSopenharmony_ci    float wi, wi1, wi2, wi3;
155cabdff1aSopenharmony_ci    float wj, wj1, wj2, wj3;
156cabdff1aSopenharmony_ci    const float * lp_end = win + len;
157cabdff1aSopenharmony_ci
158cabdff1aSopenharmony_ci    win_i  = (float *)win;
159cabdff1aSopenharmony_ci    win_j  = (float *)(win + 2 * len -1);
160cabdff1aSopenharmony_ci    src1_j = (float *)(src1 + len - 1);
161cabdff1aSopenharmony_ci    src0_i = (float *)src0;
162cabdff1aSopenharmony_ci    dst_i  = (float *)dst;
163cabdff1aSopenharmony_ci    dst_j  = (float *)(dst + 2 * len -1);
164cabdff1aSopenharmony_ci
165cabdff1aSopenharmony_ci    /* loop unrolled 4 times */
166cabdff1aSopenharmony_ci    __asm__ volatile (
167cabdff1aSopenharmony_ci        "1:"
168cabdff1aSopenharmony_ci        "lwc1    %[s1],     0(%[src1_j])                \n\t"
169cabdff1aSopenharmony_ci        "lwc1    %[wi],     0(%[win_i])                 \n\t"
170cabdff1aSopenharmony_ci        "lwc1    %[wj],     0(%[win_j])                 \n\t"
171cabdff1aSopenharmony_ci        "lwc1    %[s11],   -4(%[src1_j])                \n\t"
172cabdff1aSopenharmony_ci        "lwc1    %[wi1],    4(%[win_i])                 \n\t"
173cabdff1aSopenharmony_ci        "lwc1    %[wj1],   -4(%[win_j])                 \n\t"
174cabdff1aSopenharmony_ci        "lwc1    %[s0],     0(%[src0_i])                \n\t"
175cabdff1aSopenharmony_ci        "lwc1    %[s01],    4(%[src0_i])                \n\t"
176cabdff1aSopenharmony_ci        "mul.s   %[temp],   %[s1],   %[wi]              \n\t"
177cabdff1aSopenharmony_ci        "mul.s   %[temp1],  %[s1],   %[wj]              \n\t"
178cabdff1aSopenharmony_ci        "mul.s   %[temp2],  %[s11],  %[wi1]             \n\t"
179cabdff1aSopenharmony_ci        "mul.s   %[temp3],  %[s11],  %[wj1]             \n\t"
180cabdff1aSopenharmony_ci        "lwc1    %[s1],    -8(%[src1_j])                \n\t"
181cabdff1aSopenharmony_ci        "lwc1    %[wi2],    8(%[win_i])                 \n\t"
182cabdff1aSopenharmony_ci        "lwc1    %[wj2],   -8(%[win_j])                 \n\t"
183cabdff1aSopenharmony_ci        "lwc1    %[s11],   -12(%[src1_j])               \n\t"
184cabdff1aSopenharmony_ci        "msub.s  %[temp],   %[temp],  %[s0],  %[wj]     \n\t"
185cabdff1aSopenharmony_ci        "madd.s  %[temp1],  %[temp1], %[s0],  %[wi]     \n\t"
186cabdff1aSopenharmony_ci        "msub.s  %[temp2],  %[temp2], %[s01], %[wj1]    \n\t"
187cabdff1aSopenharmony_ci        "madd.s  %[temp3],  %[temp3], %[s01], %[wi1]    \n\t"
188cabdff1aSopenharmony_ci        "lwc1    %[wi3],    12(%[win_i])                \n\t"
189cabdff1aSopenharmony_ci        "lwc1    %[wj3],   -12(%[win_j])                \n\t"
190cabdff1aSopenharmony_ci        "lwc1    %[s0],     8(%[src0_i])                \n\t"
191cabdff1aSopenharmony_ci        "lwc1    %[s01],    12(%[src0_i])               \n\t"
192cabdff1aSopenharmony_ci        PTR_ADDIU "%[src1_j],-16                        \n\t"
193cabdff1aSopenharmony_ci        PTR_ADDIU "%[win_i],16                          \n\t"
194cabdff1aSopenharmony_ci        PTR_ADDIU "%[win_j],-16                         \n\t"
195cabdff1aSopenharmony_ci        PTR_ADDIU "%[src0_i],16                         \n\t"
196cabdff1aSopenharmony_ci        "swc1    %[temp],   0(%[dst_i])                 \n\t" /* dst[i] = s0*wj - s1*wi; */
197cabdff1aSopenharmony_ci        "swc1    %[temp1],  0(%[dst_j])                 \n\t" /* dst[j] = s0*wi + s1*wj; */
198cabdff1aSopenharmony_ci        "swc1    %[temp2],  4(%[dst_i])                 \n\t" /* dst[i+1] = s01*wj1 - s11*wi1; */
199cabdff1aSopenharmony_ci        "swc1    %[temp3], -4(%[dst_j])                 \n\t" /* dst[j-1] = s01*wi1 + s11*wj1; */
200cabdff1aSopenharmony_ci        "mul.s   %[temp],   %[s1],    %[wi2]            \n\t"
201cabdff1aSopenharmony_ci        "mul.s   %[temp1],  %[s1],    %[wj2]            \n\t"
202cabdff1aSopenharmony_ci        "mul.s   %[temp2],  %[s11],   %[wi3]            \n\t"
203cabdff1aSopenharmony_ci        "mul.s   %[temp3],  %[s11],   %[wj3]            \n\t"
204cabdff1aSopenharmony_ci        "msub.s  %[temp],   %[temp],  %[s0],  %[wj2]    \n\t"
205cabdff1aSopenharmony_ci        "madd.s  %[temp1],  %[temp1], %[s0],  %[wi2]    \n\t"
206cabdff1aSopenharmony_ci        "msub.s  %[temp2],  %[temp2], %[s01], %[wj3]    \n\t"
207cabdff1aSopenharmony_ci        "madd.s  %[temp3],  %[temp3], %[s01], %[wi3]    \n\t"
208cabdff1aSopenharmony_ci        "swc1    %[temp],   8(%[dst_i])                 \n\t" /* dst[i+2] = s0*wj2 - s1*wi2; */
209cabdff1aSopenharmony_ci        "swc1    %[temp1], -8(%[dst_j])                 \n\t" /* dst[j-2] = s0*wi2 + s1*wj2; */
210cabdff1aSopenharmony_ci        "swc1    %[temp2],  12(%[dst_i])                \n\t" /* dst[i+2] = s01*wj3 - s11*wi3; */
211cabdff1aSopenharmony_ci        "swc1    %[temp3], -12(%[dst_j])                \n\t" /* dst[j-3] = s01*wi3 + s11*wj3; */
212cabdff1aSopenharmony_ci        PTR_ADDIU "%[dst_i],16                          \n\t"
213cabdff1aSopenharmony_ci        PTR_ADDIU "%[dst_j],-16                         \n\t"
214cabdff1aSopenharmony_ci        "bne     %[win_i], %[lp_end], 1b                \n\t"
215cabdff1aSopenharmony_ci        : [temp]"=&f"(temp), [temp1]"=&f"(temp1), [temp2]"=&f"(temp2),
216cabdff1aSopenharmony_ci          [temp3]"=&f"(temp3), [src0_i]"+r"(src0_i), [win_i]"+r"(win_i),
217cabdff1aSopenharmony_ci          [src1_j]"+r"(src1_j), [win_j]"+r"(win_j), [dst_i]"+r"(dst_i),
218cabdff1aSopenharmony_ci          [dst_j]"+r"(dst_j), [s0] "=&f"(s0), [s01]"=&f"(s01), [s1] "=&f"(s1),
219cabdff1aSopenharmony_ci          [s11]"=&f"(s11), [wi] "=&f"(wi), [wj] "=&f"(wj), [wi2]"=&f"(wi2),
220cabdff1aSopenharmony_ci          [wj2]"=&f"(wj2), [wi3]"=&f"(wi3), [wj3]"=&f"(wj3), [wi1]"=&f"(wi1),
221cabdff1aSopenharmony_ci          [wj1]"=&f"(wj1)
222cabdff1aSopenharmony_ci        : [lp_end]"r"(lp_end)
223cabdff1aSopenharmony_ci        : "memory"
224cabdff1aSopenharmony_ci    );
225cabdff1aSopenharmony_ci}
226cabdff1aSopenharmony_ci
227cabdff1aSopenharmony_cistatic void butterflies_float_mips(float *av_restrict v1, float *av_restrict v2,
228cabdff1aSopenharmony_ci                                int len)
229cabdff1aSopenharmony_ci{
230cabdff1aSopenharmony_ci    float temp0, temp1, temp2, temp3, temp4;
231cabdff1aSopenharmony_ci    float temp5, temp6, temp7, temp8, temp9;
232cabdff1aSopenharmony_ci    float temp10, temp11, temp12, temp13, temp14, temp15;
233cabdff1aSopenharmony_ci    int pom;
234cabdff1aSopenharmony_ci    pom = (len >> 2)-1;
235cabdff1aSopenharmony_ci
236cabdff1aSopenharmony_ci    /* loop unrolled 4 times */
237cabdff1aSopenharmony_ci    __asm__ volatile (
238cabdff1aSopenharmony_ci        "lwc1     %[temp0],    0(%[v1])                 \n\t"
239cabdff1aSopenharmony_ci        "lwc1     %[temp1],    4(%[v1])                 \n\t"
240cabdff1aSopenharmony_ci        "lwc1     %[temp2],    8(%[v1])                 \n\t"
241cabdff1aSopenharmony_ci        "lwc1     %[temp3],    12(%[v1])                \n\t"
242cabdff1aSopenharmony_ci        "lwc1     %[temp4],    0(%[v2])                 \n\t"
243cabdff1aSopenharmony_ci        "lwc1     %[temp5],    4(%[v2])                 \n\t"
244cabdff1aSopenharmony_ci        "lwc1     %[temp6],    8(%[v2])                 \n\t"
245cabdff1aSopenharmony_ci        "lwc1     %[temp7],    12(%[v2])                \n\t"
246cabdff1aSopenharmony_ci        "beq      %[pom],      $zero,       2f          \n\t"
247cabdff1aSopenharmony_ci    "1:                                                 \n\t"
248cabdff1aSopenharmony_ci        "sub.s    %[temp8],    %[temp0],    %[temp4]    \n\t"
249cabdff1aSopenharmony_ci        "add.s    %[temp9],    %[temp0],    %[temp4]    \n\t"
250cabdff1aSopenharmony_ci        "sub.s    %[temp10],   %[temp1],    %[temp5]    \n\t"
251cabdff1aSopenharmony_ci        "add.s    %[temp11],   %[temp1],    %[temp5]    \n\t"
252cabdff1aSopenharmony_ci        "sub.s    %[temp12],   %[temp2],    %[temp6]    \n\t"
253cabdff1aSopenharmony_ci        "add.s    %[temp13],   %[temp2],    %[temp6]    \n\t"
254cabdff1aSopenharmony_ci        "sub.s    %[temp14],   %[temp3],    %[temp7]    \n\t"
255cabdff1aSopenharmony_ci        "add.s    %[temp15],   %[temp3],    %[temp7]    \n\t"
256cabdff1aSopenharmony_ci        PTR_ADDIU "%[v1],      %[v1],       16          \n\t"
257cabdff1aSopenharmony_ci        PTR_ADDIU "%[v2],      %[v2],       16          \n\t"
258cabdff1aSopenharmony_ci        "addiu    %[pom],      %[pom],      -1          \n\t"
259cabdff1aSopenharmony_ci        "lwc1     %[temp0],    0(%[v1])                 \n\t"
260cabdff1aSopenharmony_ci        "lwc1     %[temp1],    4(%[v1])                 \n\t"
261cabdff1aSopenharmony_ci        "lwc1     %[temp2],    8(%[v1])                 \n\t"
262cabdff1aSopenharmony_ci        "lwc1     %[temp3],    12(%[v1])                \n\t"
263cabdff1aSopenharmony_ci        "lwc1     %[temp4],    0(%[v2])                 \n\t"
264cabdff1aSopenharmony_ci        "lwc1     %[temp5],    4(%[v2])                 \n\t"
265cabdff1aSopenharmony_ci        "lwc1     %[temp6],    8(%[v2])                 \n\t"
266cabdff1aSopenharmony_ci        "lwc1     %[temp7],    12(%[v2])                \n\t"
267cabdff1aSopenharmony_ci        "swc1     %[temp9],    -16(%[v1])               \n\t"
268cabdff1aSopenharmony_ci        "swc1     %[temp8],    -16(%[v2])               \n\t"
269cabdff1aSopenharmony_ci        "swc1     %[temp11],   -12(%[v1])               \n\t"
270cabdff1aSopenharmony_ci        "swc1     %[temp10],   -12(%[v2])               \n\t"
271cabdff1aSopenharmony_ci        "swc1     %[temp13],   -8(%[v1])                \n\t"
272cabdff1aSopenharmony_ci        "swc1     %[temp12],   -8(%[v2])                \n\t"
273cabdff1aSopenharmony_ci        "swc1     %[temp15],   -4(%[v1])                \n\t"
274cabdff1aSopenharmony_ci        "swc1     %[temp14],   -4(%[v2])                \n\t"
275cabdff1aSopenharmony_ci        "bgtz     %[pom],      1b                       \n\t"
276cabdff1aSopenharmony_ci    "2:                                                 \n\t"
277cabdff1aSopenharmony_ci        "sub.s    %[temp8],    %[temp0],    %[temp4]    \n\t"
278cabdff1aSopenharmony_ci        "add.s    %[temp9],    %[temp0],    %[temp4]    \n\t"
279cabdff1aSopenharmony_ci        "sub.s    %[temp10],   %[temp1],    %[temp5]    \n\t"
280cabdff1aSopenharmony_ci        "add.s    %[temp11],   %[temp1],    %[temp5]    \n\t"
281cabdff1aSopenharmony_ci        "sub.s    %[temp12],   %[temp2],    %[temp6]    \n\t"
282cabdff1aSopenharmony_ci        "add.s    %[temp13],   %[temp2],    %[temp6]    \n\t"
283cabdff1aSopenharmony_ci        "sub.s    %[temp14],   %[temp3],    %[temp7]    \n\t"
284cabdff1aSopenharmony_ci        "add.s    %[temp15],   %[temp3],    %[temp7]    \n\t"
285cabdff1aSopenharmony_ci        "swc1     %[temp9],    0(%[v1])                 \n\t"
286cabdff1aSopenharmony_ci        "swc1     %[temp8],    0(%[v2])                 \n\t"
287cabdff1aSopenharmony_ci        "swc1     %[temp11],   4(%[v1])                 \n\t"
288cabdff1aSopenharmony_ci        "swc1     %[temp10],   4(%[v2])                 \n\t"
289cabdff1aSopenharmony_ci        "swc1     %[temp13],   8(%[v1])                 \n\t"
290cabdff1aSopenharmony_ci        "swc1     %[temp12],   8(%[v2])                 \n\t"
291cabdff1aSopenharmony_ci        "swc1     %[temp15],   12(%[v1])                \n\t"
292cabdff1aSopenharmony_ci        "swc1     %[temp14],   12(%[v2])                \n\t"
293cabdff1aSopenharmony_ci
294cabdff1aSopenharmony_ci        : [v1]"+r"(v1), [v2]"+r"(v2), [pom]"+r"(pom), [temp0] "=&f" (temp0),
295cabdff1aSopenharmony_ci          [temp1]"=&f"(temp1), [temp2]"=&f"(temp2), [temp3]"=&f"(temp3),
296cabdff1aSopenharmony_ci          [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), [temp6]"=&f"(temp6),
297cabdff1aSopenharmony_ci          [temp7]"=&f"(temp7), [temp8]"=&f"(temp8), [temp9]"=&f"(temp9),
298cabdff1aSopenharmony_ci          [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), [temp12]"=&f"(temp12),
299cabdff1aSopenharmony_ci          [temp13]"=&f"(temp13), [temp14]"=&f"(temp14), [temp15]"=&f"(temp15)
300cabdff1aSopenharmony_ci        :
301cabdff1aSopenharmony_ci        : "memory"
302cabdff1aSopenharmony_ci    );
303cabdff1aSopenharmony_ci}
304cabdff1aSopenharmony_ci
305cabdff1aSopenharmony_cistatic void vector_fmul_reverse_mips(float *dst, const float *src0, const float *src1, int len){
306cabdff1aSopenharmony_ci    int i;
307cabdff1aSopenharmony_ci    float temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
308cabdff1aSopenharmony_ci    src1 += len-1;
309cabdff1aSopenharmony_ci
310cabdff1aSopenharmony_ci    for(i=0; i<(len>>2); i++)
311cabdff1aSopenharmony_ci    {
312cabdff1aSopenharmony_ci        /* loop unrolled 4 times */
313cabdff1aSopenharmony_ci        __asm__ volatile(
314cabdff1aSopenharmony_ci            "lwc1      %[temp0],     0(%[src0])                 \n\t"
315cabdff1aSopenharmony_ci            "lwc1      %[temp1],     0(%[src1])                 \n\t"
316cabdff1aSopenharmony_ci            "lwc1      %[temp2],     4(%[src0])                 \n\t"
317cabdff1aSopenharmony_ci            "lwc1      %[temp3],     -4(%[src1])                \n\t"
318cabdff1aSopenharmony_ci            "lwc1      %[temp4],     8(%[src0])                 \n\t"
319cabdff1aSopenharmony_ci            "lwc1      %[temp5],     -8(%[src1])                \n\t"
320cabdff1aSopenharmony_ci            "lwc1      %[temp6],     12(%[src0])                \n\t"
321cabdff1aSopenharmony_ci            "lwc1      %[temp7],     -12(%[src1])               \n\t"
322cabdff1aSopenharmony_ci            "mul.s     %[temp0],     %[temp1],     %[temp0]     \n\t"
323cabdff1aSopenharmony_ci            "mul.s     %[temp2],     %[temp3],     %[temp2]     \n\t"
324cabdff1aSopenharmony_ci            "mul.s     %[temp4],     %[temp5],     %[temp4]     \n\t"
325cabdff1aSopenharmony_ci            "mul.s     %[temp6],     %[temp7],     %[temp6]     \n\t"
326cabdff1aSopenharmony_ci            PTR_ADDIU "%[src0],      %[src0],      16           \n\t"
327cabdff1aSopenharmony_ci            PTR_ADDIU "%[src1],      %[src1],      -16          \n\t"
328cabdff1aSopenharmony_ci            PTR_ADDIU "%[dst],       %[dst],       16           \n\t"
329cabdff1aSopenharmony_ci            "swc1      %[temp0],     -16(%[dst])                \n\t"
330cabdff1aSopenharmony_ci            "swc1      %[temp2],     -12(%[dst])                \n\t"
331cabdff1aSopenharmony_ci            "swc1      %[temp4],     -8(%[dst])                 \n\t"
332cabdff1aSopenharmony_ci            "swc1      %[temp6],     -4(%[dst])                 \n\t"
333cabdff1aSopenharmony_ci
334cabdff1aSopenharmony_ci            : [dst]"+r"(dst), [src0]"+r"(src0), [src1]"+r"(src1),
335cabdff1aSopenharmony_ci              [temp0]"=&f"(temp0), [temp1]"=&f"(temp1),[temp2]"=&f"(temp2),
336cabdff1aSopenharmony_ci              [temp3]"=&f"(temp3), [temp4]"=&f"(temp4), [temp5]"=&f"(temp5),
337cabdff1aSopenharmony_ci              [temp6]"=&f"(temp6), [temp7]"=&f"(temp7)
338cabdff1aSopenharmony_ci            :
339cabdff1aSopenharmony_ci            : "memory"
340cabdff1aSopenharmony_ci        );
341cabdff1aSopenharmony_ci    }
342cabdff1aSopenharmony_ci}
343cabdff1aSopenharmony_ci#endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
344cabdff1aSopenharmony_ci#endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */
345cabdff1aSopenharmony_ci
346cabdff1aSopenharmony_civoid ff_float_dsp_init_mips(AVFloatDSPContext *fdsp) {
347cabdff1aSopenharmony_ci#if HAVE_INLINE_ASM && HAVE_MIPSFPU
348cabdff1aSopenharmony_ci#if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
349cabdff1aSopenharmony_ci    fdsp->vector_fmul = vector_fmul_mips;
350cabdff1aSopenharmony_ci    fdsp->vector_fmul_scalar  = vector_fmul_scalar_mips;
351cabdff1aSopenharmony_ci    fdsp->vector_fmul_window = vector_fmul_window_mips;
352cabdff1aSopenharmony_ci    fdsp->butterflies_float = butterflies_float_mips;
353cabdff1aSopenharmony_ci    fdsp->vector_fmul_reverse = vector_fmul_reverse_mips;
354cabdff1aSopenharmony_ci#endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
355cabdff1aSopenharmony_ci#endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */
356cabdff1aSopenharmony_ci}
357