fix build error
[platform/upstream/openblas.git] / kernel / mips / cgemm_tcopy_4_msa.c
1 /*******************************************************************************
2 Copyright (c) 2016, The OpenBLAS Project
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
7 1. Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 2. Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 3. Neither the name of the OpenBLAS project nor the names of
14 its contributors may be used to endorse or promote products
15 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *******************************************************************************/
27
28 #include "common.h"
29 #include "macros_msa.h"
30
31 int CNAME(BLASLONG m, BLASLONG n, FLOAT *src, BLASLONG lda, FLOAT *dst)
32 {
33     BLASLONG i, j;
34     FLOAT *psrc0;
35     FLOAT *psrc1, *psrc2;
36     FLOAT *pdst0;
37     FLOAT ctemp01, ctemp02, ctemp03, ctemp04;
38     v4f32 src0, src1, src2, src3;
39
40     psrc0 = src;
41     pdst0 = dst;
42     lda *= 2;
43
44     for (j = (n >> 2); j--;)
45     {
46         psrc1 = psrc0;
47         psrc2 = psrc0 + lda;
48         psrc0 += 8;
49
50         for (i = (m >> 1); i--;)
51         {
52             LD_SP2(psrc1, 4, src0, src1);
53             LD_SP2(psrc2, 4, src2, src3);
54             ST_SP4_INC(src0, src1, src2, src3, pdst0, 4);
55             psrc1 += 2 * lda;
56             psrc2 += 2 * lda;
57         }
58
59         if (m & 1)
60         {
61             LD_SP2(psrc1, 4, src0, src1);
62             ST_SP2_INC(src0, src1, pdst0, 4);
63         }
64     }
65
66     if (n & 2)
67     {
68         psrc1 = psrc0;
69         psrc2 = psrc0 + lda;
70         psrc0 += 4;
71
72         for (i = (m >> 1); i--;)
73         {
74             src0 = LD_SP(psrc1);
75             src1 = LD_SP(psrc2);
76             ST_SP2_INC(src0, src1, pdst0, 4);
77
78             psrc1 += 2 * lda;
79             psrc2 += 2 * lda;
80         }
81
82         if (m & 1)
83         {
84             src0 = LD_SP(psrc1);
85             ST_SP(src0, pdst0);
86             pdst0 += 4;
87         }
88     }
89
90     if (n & 1)
91     {
92         psrc1 = psrc0;
93         psrc2 = psrc0 + lda;
94         psrc0 += 2;
95
96         for (i = (m >> 1); i--;)
97         {
98             ctemp01 = *(psrc1 + 0);
99             ctemp02 = *(psrc1 + 1);
100             ctemp03 = *(psrc2 + 0);
101             ctemp04 = *(psrc2 + 1);
102
103             *(pdst0 + 0) = ctemp01;
104             *(pdst0 + 1) = ctemp02;
105             *(pdst0 + 2) = ctemp03;
106             *(pdst0 + 3) = ctemp04;
107
108             psrc1 += 2 * lda;
109             psrc2 += 2 * lda;
110             pdst0 += 4;
111         }
112
113         if (m & 1)
114         {
115             ctemp01 = *(psrc1 + 0);
116             ctemp02 = *(psrc1 + 1);
117
118             *(pdst0 + 0) = ctemp01;
119             *(pdst0 + 1) = ctemp02;
120             pdst0 += 2;
121         }
122     }
123
124     return 0;
125 }