xref: /openbmc/qemu/target/sparc/vis_helper.c (revision fa9079a86d94c202c316c97ca2eb61ca3e763907)
1fcf5ef2aSThomas Huth /*
2fcf5ef2aSThomas Huth  * VIS op helpers
3fcf5ef2aSThomas Huth  *
4fcf5ef2aSThomas Huth  *  Copyright (c) 2003-2005 Fabrice Bellard
5fcf5ef2aSThomas Huth  *
6fcf5ef2aSThomas Huth  * This library is free software; you can redistribute it and/or
7fcf5ef2aSThomas Huth  * modify it under the terms of the GNU Lesser General Public
8fcf5ef2aSThomas Huth  * License as published by the Free Software Foundation; either
95650b549SChetan Pant  * version 2.1 of the License, or (at your option) any later version.
10fcf5ef2aSThomas Huth  *
11fcf5ef2aSThomas Huth  * This library is distributed in the hope that it will be useful,
12fcf5ef2aSThomas Huth  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13fcf5ef2aSThomas Huth  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14fcf5ef2aSThomas Huth  * Lesser General Public License for more details.
15fcf5ef2aSThomas Huth  *
16fcf5ef2aSThomas Huth  * You should have received a copy of the GNU Lesser General Public
17fcf5ef2aSThomas Huth  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18fcf5ef2aSThomas Huth  */
19fcf5ef2aSThomas Huth 
20fcf5ef2aSThomas Huth #include "qemu/osdep.h"
21fcf5ef2aSThomas Huth #include "cpu.h"
22fcf5ef2aSThomas Huth #include "exec/helper-proto.h"
23fcf5ef2aSThomas Huth 
24*fa9079a8SRichard Henderson target_ulong helper_array8(target_ulong rs1, target_ulong rs2)
25fcf5ef2aSThomas Huth {
26*fa9079a8SRichard Henderson     /*
27*fa9079a8SRichard Henderson      * From Oracle SPARC Architecture 2015:
28*fa9079a8SRichard Henderson      * Architecturally, an illegal R[rs2] value (>5) causes the array
29*fa9079a8SRichard Henderson      * instructions to produce undefined results. For historic reference,
30*fa9079a8SRichard Henderson      * past implementations of these instructions have ignored R[rs2]{63:3}
31*fa9079a8SRichard Henderson      * and have treated R[rs2] values of 6 and 7 as if they were 5.
32*fa9079a8SRichard Henderson      */
33*fa9079a8SRichard Henderson     target_ulong n = MIN(rs2 & 7, 5);
34*fa9079a8SRichard Henderson 
35*fa9079a8SRichard Henderson     target_ulong x_int = (rs1 >> 11) & 0x7ff;
36*fa9079a8SRichard Henderson     target_ulong y_int = (rs1 >> 33) & 0x7ff;
37*fa9079a8SRichard Henderson     target_ulong z_int = rs1 >> 55;
38*fa9079a8SRichard Henderson 
39*fa9079a8SRichard Henderson     target_ulong lower_x = x_int & 3;
40*fa9079a8SRichard Henderson     target_ulong lower_y = y_int & 3;
41*fa9079a8SRichard Henderson     target_ulong lower_z = z_int & 1;
42*fa9079a8SRichard Henderson 
43*fa9079a8SRichard Henderson     target_ulong middle_x = (x_int >> 2) & 15;
44*fa9079a8SRichard Henderson     target_ulong middle_y = (y_int >> 2) & 15;
45*fa9079a8SRichard Henderson     target_ulong middle_z = (z_int >> 1) & 15;
46*fa9079a8SRichard Henderson 
47*fa9079a8SRichard Henderson     target_ulong upper_x = (x_int >> 6) & ((1 << n) - 1);
48*fa9079a8SRichard Henderson     target_ulong upper_y = (y_int >> 6) & ((1 << n) - 1);
49*fa9079a8SRichard Henderson     target_ulong upper_z = z_int >> 5;
50*fa9079a8SRichard Henderson 
51*fa9079a8SRichard Henderson     return (upper_z << (17 + 2 * n))
52*fa9079a8SRichard Henderson          | (upper_y << (17 + n))
53*fa9079a8SRichard Henderson          | (upper_x << 17)
54*fa9079a8SRichard Henderson          | (middle_z << 13)
55*fa9079a8SRichard Henderson          | (middle_y << 9)
56*fa9079a8SRichard Henderson          | (middle_x << 5)
57*fa9079a8SRichard Henderson          | (lower_z << 4)
58*fa9079a8SRichard Henderson          | (lower_y << 2)
59*fa9079a8SRichard Henderson          | lower_x;
60fcf5ef2aSThomas Huth }
61fcf5ef2aSThomas Huth 
62e03b5686SMarc-André Lureau #if HOST_BIG_ENDIAN
63fcf5ef2aSThomas Huth #define VIS_B64(n) b[7 - (n)]
64d6f898cfSRichard Henderson #define VIS_SB64(n) sb[7 - (n)]
65fcf5ef2aSThomas Huth #define VIS_W64(n) w[3 - (n)]
66fcf5ef2aSThomas Huth #define VIS_SW64(n) sw[3 - (n)]
67fcf5ef2aSThomas Huth #define VIS_L64(n) l[1 - (n)]
68fcf5ef2aSThomas Huth #define VIS_B32(n) b[3 - (n)]
69fcf5ef2aSThomas Huth #define VIS_W32(n) w[1 - (n)]
70fcf5ef2aSThomas Huth #else
71fcf5ef2aSThomas Huth #define VIS_B64(n) b[n]
72d6f898cfSRichard Henderson #define VIS_SB64(n) sb[n]
73fcf5ef2aSThomas Huth #define VIS_W64(n) w[n]
74fcf5ef2aSThomas Huth #define VIS_SW64(n) sw[n]
75fcf5ef2aSThomas Huth #define VIS_L64(n) l[n]
76fcf5ef2aSThomas Huth #define VIS_B32(n) b[n]
77fcf5ef2aSThomas Huth #define VIS_W32(n) w[n]
78fcf5ef2aSThomas Huth #endif
79fcf5ef2aSThomas Huth 
80fcf5ef2aSThomas Huth typedef union {
81fcf5ef2aSThomas Huth     uint8_t b[8];
82d6f898cfSRichard Henderson     int8_t sb[8];
83fcf5ef2aSThomas Huth     uint16_t w[4];
84fcf5ef2aSThomas Huth     int16_t sw[4];
85fcf5ef2aSThomas Huth     uint32_t l[2];
86fcf5ef2aSThomas Huth     uint64_t ll;
87fcf5ef2aSThomas Huth     float64 d;
88fcf5ef2aSThomas Huth } VIS64;
89fcf5ef2aSThomas Huth 
90fcf5ef2aSThomas Huth typedef union {
91fcf5ef2aSThomas Huth     uint8_t b[4];
92fcf5ef2aSThomas Huth     uint16_t w[2];
93fcf5ef2aSThomas Huth     uint32_t l;
94fcf5ef2aSThomas Huth     float32 f;
95fcf5ef2aSThomas Huth } VIS32;
96fcf5ef2aSThomas Huth 
97d3ef26afSRichard Henderson uint64_t helper_fpmerge(uint32_t src1, uint32_t src2)
98fcf5ef2aSThomas Huth {
99d3ef26afSRichard Henderson     VIS32 s1, s2;
100d3ef26afSRichard Henderson     VIS64 d;
101fcf5ef2aSThomas Huth 
102d3ef26afSRichard Henderson     s1.l = src1;
103d3ef26afSRichard Henderson     s2.l = src2;
104d3ef26afSRichard Henderson     d.ll = 0;
105fcf5ef2aSThomas Huth 
106d3ef26afSRichard Henderson     d.VIS_B64(7) = s1.VIS_B32(3);
107d3ef26afSRichard Henderson     d.VIS_B64(6) = s2.VIS_B32(3);
108d3ef26afSRichard Henderson     d.VIS_B64(5) = s1.VIS_B32(2);
109d3ef26afSRichard Henderson     d.VIS_B64(4) = s2.VIS_B32(2);
110d3ef26afSRichard Henderson     d.VIS_B64(3) = s1.VIS_B32(1);
111d3ef26afSRichard Henderson     d.VIS_B64(2) = s2.VIS_B32(1);
112d3ef26afSRichard Henderson     d.VIS_B64(1) = s1.VIS_B32(0);
113d3ef26afSRichard Henderson     d.VIS_B64(0) = s2.VIS_B32(0);
114fcf5ef2aSThomas Huth 
115fcf5ef2aSThomas Huth     return d.ll;
116fcf5ef2aSThomas Huth }
117fcf5ef2aSThomas Huth 
118d6f898cfSRichard Henderson static inline int do_ms16b(int x, int y)
119d6f898cfSRichard Henderson {
120d6f898cfSRichard Henderson     return ((x * y) + 0x80) >> 8;
121d6f898cfSRichard Henderson }
122d6f898cfSRichard Henderson 
1239157dcccSRichard Henderson uint64_t helper_fmul8x16(uint32_t src1, uint64_t src2)
124fcf5ef2aSThomas Huth {
1259157dcccSRichard Henderson     VIS64 d;
1269157dcccSRichard Henderson     VIS32 s;
127fcf5ef2aSThomas Huth 
1289157dcccSRichard Henderson     s.l = src1;
129fcf5ef2aSThomas Huth     d.ll = src2;
130fcf5ef2aSThomas Huth 
131d6f898cfSRichard Henderson     d.VIS_W64(0) = do_ms16b(s.VIS_B32(0), d.VIS_SW64(0));
132d6f898cfSRichard Henderson     d.VIS_W64(1) = do_ms16b(s.VIS_B32(1), d.VIS_SW64(1));
133d6f898cfSRichard Henderson     d.VIS_W64(2) = do_ms16b(s.VIS_B32(2), d.VIS_SW64(2));
134d6f898cfSRichard Henderson     d.VIS_W64(3) = do_ms16b(s.VIS_B32(3), d.VIS_SW64(3));
135fcf5ef2aSThomas Huth 
136fcf5ef2aSThomas Huth     return d.ll;
137fcf5ef2aSThomas Huth }
138fcf5ef2aSThomas Huth 
139a859602cSRichard Henderson uint64_t helper_fmul8x16a(uint32_t src1, int32_t src2)
140fcf5ef2aSThomas Huth {
141a859602cSRichard Henderson     VIS32 s;
142a859602cSRichard Henderson     VIS64 d;
143fcf5ef2aSThomas Huth 
144a859602cSRichard Henderson     s.l = src1;
145a859602cSRichard Henderson     d.ll = 0;
146fcf5ef2aSThomas Huth 
147d6f898cfSRichard Henderson     d.VIS_W64(0) = do_ms16b(s.VIS_B32(0), src2);
148d6f898cfSRichard Henderson     d.VIS_W64(1) = do_ms16b(s.VIS_B32(1), src2);
149d6f898cfSRichard Henderson     d.VIS_W64(2) = do_ms16b(s.VIS_B32(2), src2);
150d6f898cfSRichard Henderson     d.VIS_W64(3) = do_ms16b(s.VIS_B32(3), src2);
151fcf5ef2aSThomas Huth 
152fcf5ef2aSThomas Huth     return d.ll;
153fcf5ef2aSThomas Huth }
154fcf5ef2aSThomas Huth 
155fcf5ef2aSThomas Huth uint64_t helper_fmul8sux16(uint64_t src1, uint64_t src2)
156fcf5ef2aSThomas Huth {
157fcf5ef2aSThomas Huth     VIS64 s, d;
158fcf5ef2aSThomas Huth 
159fcf5ef2aSThomas Huth     s.ll = src1;
160fcf5ef2aSThomas Huth     d.ll = src2;
161fcf5ef2aSThomas Huth 
162d6f898cfSRichard Henderson     d.VIS_W64(0) = do_ms16b(s.VIS_SB64(1), d.VIS_SW64(0));
163d6f898cfSRichard Henderson     d.VIS_W64(1) = do_ms16b(s.VIS_SB64(3), d.VIS_SW64(1));
164d6f898cfSRichard Henderson     d.VIS_W64(2) = do_ms16b(s.VIS_SB64(5), d.VIS_SW64(2));
165d6f898cfSRichard Henderson     d.VIS_W64(3) = do_ms16b(s.VIS_SB64(7), d.VIS_SW64(3));
166fcf5ef2aSThomas Huth 
167fcf5ef2aSThomas Huth     return d.ll;
168fcf5ef2aSThomas Huth }
169fcf5ef2aSThomas Huth 
170fcf5ef2aSThomas Huth uint64_t helper_fmul8ulx16(uint64_t src1, uint64_t src2)
171fcf5ef2aSThomas Huth {
172fcf5ef2aSThomas Huth     VIS64 s, d;
173fcf5ef2aSThomas Huth 
174fcf5ef2aSThomas Huth     s.ll = src1;
175fcf5ef2aSThomas Huth     d.ll = src2;
176fcf5ef2aSThomas Huth 
177d6f898cfSRichard Henderson     d.VIS_W64(0) = do_ms16b(s.VIS_B64(0), d.VIS_SW64(0));
178d6f898cfSRichard Henderson     d.VIS_W64(1) = do_ms16b(s.VIS_B64(2), d.VIS_SW64(1));
179d6f898cfSRichard Henderson     d.VIS_W64(2) = do_ms16b(s.VIS_B64(4), d.VIS_SW64(2));
180d6f898cfSRichard Henderson     d.VIS_W64(3) = do_ms16b(s.VIS_B64(6), d.VIS_SW64(3));
181fcf5ef2aSThomas Huth 
182fcf5ef2aSThomas Huth     return d.ll;
183fcf5ef2aSThomas Huth }
184fcf5ef2aSThomas Huth 
1857b616f36SRichard Henderson uint64_t helper_fexpand(uint32_t src2)
186fcf5ef2aSThomas Huth {
187fcf5ef2aSThomas Huth     VIS32 s;
188fcf5ef2aSThomas Huth     VIS64 d;
189fcf5ef2aSThomas Huth 
1907b616f36SRichard Henderson     s.l = src2;
1917b616f36SRichard Henderson     d.ll = 0;
192fcf5ef2aSThomas Huth     d.VIS_W64(0) = s.VIS_B32(0) << 4;
193fcf5ef2aSThomas Huth     d.VIS_W64(1) = s.VIS_B32(1) << 4;
194fcf5ef2aSThomas Huth     d.VIS_W64(2) = s.VIS_B32(2) << 4;
195fcf5ef2aSThomas Huth     d.VIS_W64(3) = s.VIS_B32(3) << 4;
196fcf5ef2aSThomas Huth 
197fcf5ef2aSThomas Huth     return d.ll;
198fcf5ef2aSThomas Huth }
199fcf5ef2aSThomas Huth 
200fcf5ef2aSThomas Huth #define VIS_CMPHELPER(name, F)                                    \
201fcf5ef2aSThomas Huth     uint64_t name##16(uint64_t src1, uint64_t src2)               \
202fcf5ef2aSThomas Huth     {                                                             \
203fcf5ef2aSThomas Huth         VIS64 s, d;                                               \
204fcf5ef2aSThomas Huth                                                                   \
205fcf5ef2aSThomas Huth         s.ll = src1;                                              \
206fcf5ef2aSThomas Huth         d.ll = src2;                                              \
207fcf5ef2aSThomas Huth                                                                   \
208fcf5ef2aSThomas Huth         d.VIS_W64(0) = F(s.VIS_W64(0), d.VIS_W64(0)) ? 1 : 0;     \
209fcf5ef2aSThomas Huth         d.VIS_W64(0) |= F(s.VIS_W64(1), d.VIS_W64(1)) ? 2 : 0;    \
210fcf5ef2aSThomas Huth         d.VIS_W64(0) |= F(s.VIS_W64(2), d.VIS_W64(2)) ? 4 : 0;    \
211fcf5ef2aSThomas Huth         d.VIS_W64(0) |= F(s.VIS_W64(3), d.VIS_W64(3)) ? 8 : 0;    \
212fcf5ef2aSThomas Huth         d.VIS_W64(1) = d.VIS_W64(2) = d.VIS_W64(3) = 0;           \
213fcf5ef2aSThomas Huth                                                                   \
214fcf5ef2aSThomas Huth         return d.ll;                                              \
215fcf5ef2aSThomas Huth     }                                                             \
216fcf5ef2aSThomas Huth                                                                   \
217fcf5ef2aSThomas Huth     uint64_t name##32(uint64_t src1, uint64_t src2)               \
218fcf5ef2aSThomas Huth     {                                                             \
219fcf5ef2aSThomas Huth         VIS64 s, d;                                               \
220fcf5ef2aSThomas Huth                                                                   \
221fcf5ef2aSThomas Huth         s.ll = src1;                                              \
222fcf5ef2aSThomas Huth         d.ll = src2;                                              \
223fcf5ef2aSThomas Huth                                                                   \
224fcf5ef2aSThomas Huth         d.VIS_L64(0) = F(s.VIS_L64(0), d.VIS_L64(0)) ? 1 : 0;     \
225fcf5ef2aSThomas Huth         d.VIS_L64(0) |= F(s.VIS_L64(1), d.VIS_L64(1)) ? 2 : 0;    \
226fcf5ef2aSThomas Huth         d.VIS_L64(1) = 0;                                         \
227fcf5ef2aSThomas Huth                                                                   \
228fcf5ef2aSThomas Huth         return d.ll;                                              \
229fcf5ef2aSThomas Huth     }
230fcf5ef2aSThomas Huth 
231fcf5ef2aSThomas Huth #define FCMPGT(a, b) ((a) > (b))
232fcf5ef2aSThomas Huth #define FCMPEQ(a, b) ((a) == (b))
233fcf5ef2aSThomas Huth #define FCMPLE(a, b) ((a) <= (b))
234fcf5ef2aSThomas Huth #define FCMPNE(a, b) ((a) != (b))
235fcf5ef2aSThomas Huth 
236fcf5ef2aSThomas Huth VIS_CMPHELPER(helper_fcmpgt, FCMPGT)
237fcf5ef2aSThomas Huth VIS_CMPHELPER(helper_fcmpeq, FCMPEQ)
238fcf5ef2aSThomas Huth VIS_CMPHELPER(helper_fcmple, FCMPLE)
239fcf5ef2aSThomas Huth VIS_CMPHELPER(helper_fcmpne, FCMPNE)
240fcf5ef2aSThomas Huth 
241fcf5ef2aSThomas Huth uint64_t helper_pdist(uint64_t sum, uint64_t src1, uint64_t src2)
242fcf5ef2aSThomas Huth {
243fcf5ef2aSThomas Huth     int i;
244fcf5ef2aSThomas Huth     for (i = 0; i < 8; i++) {
245fcf5ef2aSThomas Huth         int s1, s2;
246fcf5ef2aSThomas Huth 
247fcf5ef2aSThomas Huth         s1 = (src1 >> (56 - (i * 8))) & 0xff;
248fcf5ef2aSThomas Huth         s2 = (src2 >> (56 - (i * 8))) & 0xff;
249fcf5ef2aSThomas Huth 
250fcf5ef2aSThomas Huth         /* Absolute value of difference. */
251fcf5ef2aSThomas Huth         s1 -= s2;
252fcf5ef2aSThomas Huth         if (s1 < 0) {
253fcf5ef2aSThomas Huth             s1 = -s1;
254fcf5ef2aSThomas Huth         }
255fcf5ef2aSThomas Huth 
256fcf5ef2aSThomas Huth         sum += s1;
257fcf5ef2aSThomas Huth     }
258fcf5ef2aSThomas Huth 
259fcf5ef2aSThomas Huth     return sum;
260fcf5ef2aSThomas Huth }
261fcf5ef2aSThomas Huth 
262fcf5ef2aSThomas Huth uint32_t helper_fpack16(uint64_t gsr, uint64_t rs2)
263fcf5ef2aSThomas Huth {
264fcf5ef2aSThomas Huth     int scale = (gsr >> 3) & 0xf;
265fcf5ef2aSThomas Huth     uint32_t ret = 0;
266fcf5ef2aSThomas Huth     int byte;
267fcf5ef2aSThomas Huth 
268fcf5ef2aSThomas Huth     for (byte = 0; byte < 4; byte++) {
269fcf5ef2aSThomas Huth         uint32_t val;
270fcf5ef2aSThomas Huth         int16_t src = rs2 >> (byte * 16);
271fcf5ef2aSThomas Huth         int32_t scaled = src << scale;
272fcf5ef2aSThomas Huth         int32_t from_fixed = scaled >> 7;
273fcf5ef2aSThomas Huth 
274fcf5ef2aSThomas Huth         val = (from_fixed < 0 ?  0 :
275fcf5ef2aSThomas Huth                from_fixed > 255 ?  255 : from_fixed);
276fcf5ef2aSThomas Huth 
277fcf5ef2aSThomas Huth         ret |= val << (8 * byte);
278fcf5ef2aSThomas Huth     }
279fcf5ef2aSThomas Huth 
280fcf5ef2aSThomas Huth     return ret;
281fcf5ef2aSThomas Huth }
282fcf5ef2aSThomas Huth 
283fcf5ef2aSThomas Huth uint64_t helper_fpack32(uint64_t gsr, uint64_t rs1, uint64_t rs2)
284fcf5ef2aSThomas Huth {
285fcf5ef2aSThomas Huth     int scale = (gsr >> 3) & 0x1f;
286fcf5ef2aSThomas Huth     uint64_t ret = 0;
287fcf5ef2aSThomas Huth     int word;
288fcf5ef2aSThomas Huth 
289fcf5ef2aSThomas Huth     ret = (rs1 << 8) & ~(0x000000ff000000ffULL);
290fcf5ef2aSThomas Huth     for (word = 0; word < 2; word++) {
291fcf5ef2aSThomas Huth         uint64_t val;
292fcf5ef2aSThomas Huth         int32_t src = rs2 >> (word * 32);
293fcf5ef2aSThomas Huth         int64_t scaled = (int64_t)src << scale;
294fcf5ef2aSThomas Huth         int64_t from_fixed = scaled >> 23;
295fcf5ef2aSThomas Huth 
296fcf5ef2aSThomas Huth         val = (from_fixed < 0 ? 0 :
297fcf5ef2aSThomas Huth                (from_fixed > 255) ? 255 : from_fixed);
298fcf5ef2aSThomas Huth 
299fcf5ef2aSThomas Huth         ret |= val << (32 * word);
300fcf5ef2aSThomas Huth     }
301fcf5ef2aSThomas Huth 
302fcf5ef2aSThomas Huth     return ret;
303fcf5ef2aSThomas Huth }
304fcf5ef2aSThomas Huth 
305fcf5ef2aSThomas Huth uint32_t helper_fpackfix(uint64_t gsr, uint64_t rs2)
306fcf5ef2aSThomas Huth {
307fcf5ef2aSThomas Huth     int scale = (gsr >> 3) & 0x1f;
308fcf5ef2aSThomas Huth     uint32_t ret = 0;
309fcf5ef2aSThomas Huth     int word;
310fcf5ef2aSThomas Huth 
311fcf5ef2aSThomas Huth     for (word = 0; word < 2; word++) {
312fcf5ef2aSThomas Huth         uint32_t val;
313fcf5ef2aSThomas Huth         int32_t src = rs2 >> (word * 32);
314fcf5ef2aSThomas Huth         int64_t scaled = (int64_t)src << scale;
315fcf5ef2aSThomas Huth         int64_t from_fixed = scaled >> 16;
316fcf5ef2aSThomas Huth 
317fcf5ef2aSThomas Huth         val = (from_fixed < -32768 ? -32768 :
318fcf5ef2aSThomas Huth                from_fixed > 32767 ?  32767 : from_fixed);
319fcf5ef2aSThomas Huth 
320fcf5ef2aSThomas Huth         ret |= (val & 0xffff) << (word * 16);
321fcf5ef2aSThomas Huth     }
322fcf5ef2aSThomas Huth 
323fcf5ef2aSThomas Huth     return ret;
324fcf5ef2aSThomas Huth }
325fcf5ef2aSThomas Huth 
326fcf5ef2aSThomas Huth uint64_t helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)
327fcf5ef2aSThomas Huth {
328fcf5ef2aSThomas Huth     union {
329fcf5ef2aSThomas Huth         uint64_t ll[2];
330fcf5ef2aSThomas Huth         uint8_t b[16];
331fcf5ef2aSThomas Huth     } s;
332fcf5ef2aSThomas Huth     VIS64 r;
333fcf5ef2aSThomas Huth     uint32_t i, mask, host;
334fcf5ef2aSThomas Huth 
335fcf5ef2aSThomas Huth     /* Set up S such that we can index across all of the bytes.  */
336e03b5686SMarc-André Lureau #if HOST_BIG_ENDIAN
337fcf5ef2aSThomas Huth     s.ll[0] = src1;
338fcf5ef2aSThomas Huth     s.ll[1] = src2;
339fcf5ef2aSThomas Huth     host = 0;
340fcf5ef2aSThomas Huth #else
341fcf5ef2aSThomas Huth     s.ll[1] = src1;
342fcf5ef2aSThomas Huth     s.ll[0] = src2;
343fcf5ef2aSThomas Huth     host = 15;
344fcf5ef2aSThomas Huth #endif
345fcf5ef2aSThomas Huth     mask = gsr >> 32;
346fcf5ef2aSThomas Huth 
347fcf5ef2aSThomas Huth     for (i = 0; i < 8; ++i) {
348fcf5ef2aSThomas Huth         unsigned e = (mask >> (28 - i*4)) & 0xf;
349fcf5ef2aSThomas Huth         r.VIS_B64(i) = s.b[e ^ host];
350fcf5ef2aSThomas Huth     }
351fcf5ef2aSThomas Huth 
352fcf5ef2aSThomas Huth     return r.ll;
353fcf5ef2aSThomas Huth }
354