fix build error
[platform/upstream/openblas.git] / kernel / mips / ccopy_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 n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y)
32 {
33     BLASLONG i, inc_x2, inc_y2;
34     v4f32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
35     FLOAT f0, f1, f2, f3, f4, f5, f6, f7;
36
37     if (n < 0)  return (0);
38
39     if ((1 == inc_x) && (1 == inc_y))
40     {
41         if (n > 31)
42         {
43             FLOAT *x_pref;
44             BLASLONG pref_offset;
45
46             pref_offset = (BLASLONG)x & (L1_DATA_LINESIZE - 1);
47             if (pref_offset > 0)
48             {
49                 pref_offset = L1_DATA_LINESIZE - pref_offset;
50                 pref_offset = pref_offset / sizeof(FLOAT);
51             }
52             x_pref = x + pref_offset + 128 + 32;
53
54             LD_SP8_INC(x, 4, x0, x1, x2, x3, x4, x5, x6, x7);
55             for (i = (n >> 5) - 1; i--;)
56             {
57                 PREF_OFFSET(x_pref, 0);
58                 PREF_OFFSET(x_pref, 32);
59                 PREF_OFFSET(x_pref, 64);
60                 PREF_OFFSET(x_pref, 96);
61                 PREF_OFFSET(x_pref, 128);
62                 PREF_OFFSET(x_pref, 160);
63                 PREF_OFFSET(x_pref, 192);
64                 PREF_OFFSET(x_pref, 224);
65                 x_pref += 64;
66
67                 x8 = LD_SP(x); x += 4;
68                 ST_SP(x0, y); y += 4;
69                 x9 = LD_SP(x); x += 4;
70                 ST_SP(x1, y); y += 4;
71                 x10 = LD_SP(x); x += 4;
72                 ST_SP(x2, y); y += 4;
73                 x11 = LD_SP(x); x += 4;
74                 ST_SP(x3, y); y += 4;
75                 x12 = LD_SP(x); x += 4;
76                 ST_SP(x4, y); y += 4;
77                 x13 = LD_SP(x); x += 4;
78                 ST_SP(x5, y); y += 4;
79                 x14 = LD_SP(x); x += 4;
80                 ST_SP(x6, y); y += 4;
81                 x15 = LD_SP(x); x += 4;
82                 ST_SP(x7, y); y += 4;
83                 x0 = LD_SP(x); x += 4;
84                 ST_SP(x8, y); y += 4;
85                 x1 = LD_SP(x); x += 4;
86                 ST_SP(x9, y); y += 4;
87                 x2 = LD_SP(x); x += 4;
88                 ST_SP(x10, y); y += 4;
89                 x3 = LD_SP(x); x += 4;
90                 ST_SP(x11, y); y += 4;
91                 x4 = LD_SP(x); x += 4;
92                 ST_SP(x12, y); y += 4;
93                 x5 = LD_SP(x); x += 4;
94                 ST_SP(x13, y); y += 4;
95                 x6 = LD_SP(x); x += 4;
96                 ST_SP(x14, y); y += 4;
97                 x7 = LD_SP(x); x += 4;
98                 ST_SP(x15, y); y += 4;
99             }
100
101             x8 = LD_SP(x); x += 4;
102             x9 = LD_SP(x); x += 4;
103             ST_SP(x0, y); y += 4;
104             x10 = LD_SP(x); x += 4;
105             ST_SP(x1, y); y += 4;
106             x11 = LD_SP(x); x += 4;
107             ST_SP(x2, y); y += 4;
108             x12 = LD_SP(x); x += 4;
109             ST_SP(x3, y); y += 4;
110             x13 = LD_SP(x); x += 4;
111             ST_SP(x4, y); y += 4;
112             x14 = LD_SP(x); x += 4;
113             ST_SP(x5, y); y += 4;
114             x15 = LD_SP(x); x += 4;
115             ST_SP(x6, y); y += 4;
116             ST_SP(x7, y); y += 4;
117
118             ST_SP8_INC(x8, x9, x10, x11, x12, x13, x14, x15, y, 4);
119         }
120
121         if (n & 31)
122         {
123             if (n & 16)
124             {
125                 LD_SP8_INC(x, 4, x0, x1, x2, x3, x4, x5, x6, x7);
126                 ST_SP8_INC(x0, x1, x2, x3, x4, x5, x6, x7, y, 4);
127             }
128
129             if (n & 8)
130             {
131                 LD_SP4_INC(x, 4, x0, x1, x2, x3);
132                 ST_SP4_INC(x0, x1, x2, x3, y, 4);
133             }
134
135             if (n & 4)
136             {
137                 LD_SP2_INC(x, 4, x0, x1);
138                 ST_SP2_INC(x0, x1, y, 4);
139             }
140
141             if (n & 2)
142             {
143                 LD_GP4_INC(x, 1, f0, f1, f2, f3);
144                 ST_GP4_INC(f0, f1, f2, f3, y, 1);
145             }
146
147             if (n & 1)
148             {
149                 LD_GP2_INC(x, 1, f0, f1);
150                 ST_GP2_INC(f0, f1, y, 1);
151             }
152         }
153     }
154     else
155     {
156         inc_x2 = 2 * inc_x;
157         inc_y2 = 2 * inc_y;
158
159         for (i = (n >> 2); i--;)
160         {
161             f0 = *x;
162             f1 = *(x+1); x += inc_x2;
163             f2 = *x;
164             f3 = *(x+1); x += inc_x2;
165             f4 = *x;
166             f5 = *(x+1); x += inc_x2;
167             f6 = *x;
168             f7 = *(x+1); x += inc_x2;
169
170             *y = f0;
171             *(y+1) = f1; y += inc_y2;
172             *y = f2;
173             *(y+1) = f3; y += inc_y2;
174             *y = f4;
175             *(y+1) = f5; y += inc_y2;
176             *y = f6;
177             *(y+1) = f7; y += inc_y2;
178         }
179
180         if (n & 2)
181         {
182             f0 = *x;
183             f1 = *(x+1); x += inc_x2;
184             f2 = *x;
185             f3 = *(x+1); x += inc_x2;
186
187             *y = f0;
188             *(y+1) = f1; y += inc_y2;
189             *y = f2;
190             *(y+1) = f3; y += inc_y2;
191         }
192
193         if (n & 1)
194         {
195             LD_GP2_INC(x, 1, f0, f1);
196             ST_GP2_INC(f0, f1, y, 1);
197         }
198     }
199
200     return (0);
201 }