4 * Copyright (c) 2003-2005 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
23 #define DT0 (env->dt0)
24 #define DT1 (env->dt1)
25 #define QT0 (env->qt0)
26 #define QT1 (env->qt1)
28 /* This function uses non-native bit order */
29 #define GET_FIELD(X, FROM, TO) \
30 ((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1))
32 /* This function uses the order in the manuals, i.e. bit 0 is 2^0 */
33 #define GET_FIELD_SP(X, FROM, TO) \
34 GET_FIELD(X, 63 - (TO), 63 - (FROM))
36 target_ulong
helper_array8(CPUState
*env
, target_ulong pixel_addr
,
37 target_ulong cubesize
)
39 return (GET_FIELD_SP(pixel_addr
, 60, 63) << (17 + 2 * cubesize
)) |
40 (GET_FIELD_SP(pixel_addr
, 39, 39 + cubesize
- 1) << (17 + cubesize
)) |
41 (GET_FIELD_SP(pixel_addr
, 17 + cubesize
- 1, 17) << 17) |
42 (GET_FIELD_SP(pixel_addr
, 56, 59) << 13) |
43 (GET_FIELD_SP(pixel_addr
, 35, 38) << 9) |
44 (GET_FIELD_SP(pixel_addr
, 13, 16) << 5) |
45 (((pixel_addr
>> 55) & 1) << 4) |
46 (GET_FIELD_SP(pixel_addr
, 33, 34) << 2) |
47 GET_FIELD_SP(pixel_addr
, 11, 12);
50 target_ulong
helper_alignaddr(CPUState
*env
, target_ulong addr
,
57 env
->gsr
|= tmp
& 7ULL;
61 void helper_faligndata(CPUState
*env
)
65 tmp
= (*((uint64_t *)&DT0
)) << ((env
->gsr
& 7) * 8);
66 /* on many architectures a shift of 64 does nothing */
67 if ((env
->gsr
& 7) != 0) {
68 tmp
|= (*((uint64_t *)&DT1
)) >> (64 - (env
->gsr
& 7) * 8);
70 *((uint64_t *)&DT0
) = tmp
;
73 #ifdef HOST_WORDS_BIGENDIAN
74 #define VIS_B64(n) b[7 - (n)]
75 #define VIS_W64(n) w[3 - (n)]
76 #define VIS_SW64(n) sw[3 - (n)]
77 #define VIS_L64(n) l[1 - (n)]
78 #define VIS_B32(n) b[3 - (n)]
79 #define VIS_W32(n) w[1 - (n)]
81 #define VIS_B64(n) b[n]
82 #define VIS_W64(n) w[n]
83 #define VIS_SW64(n) sw[n]
84 #define VIS_L64(n) l[n]
85 #define VIS_B32(n) b[n]
86 #define VIS_W32(n) w[n]
105 void helper_fpmerge(CPUState
*env
)
112 /* Reverse calculation order to handle overlap */
113 d
.VIS_B64(7) = s
.VIS_B64(3);
114 d
.VIS_B64(6) = d
.VIS_B64(3);
115 d
.VIS_B64(5) = s
.VIS_B64(2);
116 d
.VIS_B64(4) = d
.VIS_B64(2);
117 d
.VIS_B64(3) = s
.VIS_B64(1);
118 d
.VIS_B64(2) = d
.VIS_B64(1);
119 d
.VIS_B64(1) = s
.VIS_B64(0);
120 /* d.VIS_B64(0) = d.VIS_B64(0); */
125 void helper_fmul8x16(CPUState
*env
)
134 tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \
135 if ((tmp & 0xff) > 0x7f) { \
138 d.VIS_W64(r) = tmp >> 8;
149 void helper_fmul8x16al(CPUState
*env
)
158 tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \
159 if ((tmp & 0xff) > 0x7f) { \
162 d.VIS_W64(r) = tmp >> 8;
173 void helper_fmul8x16au(CPUState
*env
)
182 tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \
183 if ((tmp & 0xff) > 0x7f) { \
186 d.VIS_W64(r) = tmp >> 8;
197 void helper_fmul8sux16(CPUState
*env
)
206 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
207 if ((tmp & 0xff) > 0x7f) { \
210 d.VIS_W64(r) = tmp >> 8;
221 void helper_fmul8ulx16(CPUState
*env
)
230 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
231 if ((tmp & 0xff) > 0x7f) { \
234 d.VIS_W64(r) = tmp >> 8;
245 void helper_fmuld8sux16(CPUState
*env
)
254 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
255 if ((tmp & 0xff) > 0x7f) { \
260 /* Reverse calculation order to handle overlap */
268 void helper_fmuld8ulx16(CPUState
*env
)
277 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
278 if ((tmp & 0xff) > 0x7f) { \
283 /* Reverse calculation order to handle overlap */
291 void helper_fexpand(CPUState
*env
)
296 s
.l
= (uint32_t)(*(uint64_t *)&DT0
& 0xffffffff);
298 d
.VIS_W64(0) = s
.VIS_B32(0) << 4;
299 d
.VIS_W64(1) = s
.VIS_B32(1) << 4;
300 d
.VIS_W64(2) = s
.VIS_B32(2) << 4;
301 d
.VIS_W64(3) = s
.VIS_B32(3) << 4;
306 #define VIS_HELPER(name, F) \
307 void name##16(CPUState *env) \
314 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0)); \
315 d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1)); \
316 d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2)); \
317 d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3)); \
322 uint32_t name##16s(CPUState *env, uint32_t src1, \
330 d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0)); \
331 d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1)); \
336 void name##32(CPUState *env) \
343 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0)); \
344 d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1)); \
349 uint32_t name##32s(CPUState *env, uint32_t src1, \
362 #define FADD(a, b) ((a) + (b))
363 #define FSUB(a, b) ((a) - (b))
364 VIS_HELPER(helper_fpadd
, FADD
)
365 VIS_HELPER(helper_fpsub
, FSUB
)
367 #define VIS_CMPHELPER(name, F) \
368 uint64_t name##16(CPUState *env) \
375 d.VIS_W64(0) = F(s.VIS_W64(0), d.VIS_W64(0)) ? 1 : 0; \
376 d.VIS_W64(0) |= F(s.VIS_W64(1), d.VIS_W64(1)) ? 2 : 0; \
377 d.VIS_W64(0) |= F(s.VIS_W64(2), d.VIS_W64(2)) ? 4 : 0; \
378 d.VIS_W64(0) |= F(s.VIS_W64(3), d.VIS_W64(3)) ? 8 : 0; \
379 d.VIS_W64(1) = d.VIS_W64(2) = d.VIS_W64(3) = 0; \
384 uint64_t name##32(CPUState *env) \
391 d.VIS_L64(0) = F(s.VIS_L64(0), d.VIS_L64(0)) ? 1 : 0; \
392 d.VIS_L64(0) |= F(s.VIS_L64(1), d.VIS_L64(1)) ? 2 : 0; \
398 #define FCMPGT(a, b) ((a) > (b))
399 #define FCMPEQ(a, b) ((a) == (b))
400 #define FCMPLE(a, b) ((a) <= (b))
401 #define FCMPNE(a, b) ((a) != (b))
403 VIS_CMPHELPER(helper_fcmpgt
, FCMPGT
)
404 VIS_CMPHELPER(helper_fcmpeq
, FCMPEQ
)
405 VIS_CMPHELPER(helper_fcmple
, FCMPLE
)
406 VIS_CMPHELPER(helper_fcmpne
, FCMPNE
)