]>
git.proxmox.com Git - mirror_qemu.git/blob - target-sparc/vis_helper.c
a007b0f30c932a1683a4bf1fa6813dbc655cc047
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 /* This function uses non-native bit order */
24 #define GET_FIELD(X, FROM, TO) \
25 ((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1))
27 /* This function uses the order in the manuals, i.e. bit 0 is 2^0 */
28 #define GET_FIELD_SP(X, FROM, TO) \
29 GET_FIELD(X, 63 - (TO), 63 - (FROM))
31 target_ulong
helper_array8(CPUState
*env
, target_ulong pixel_addr
,
32 target_ulong cubesize
)
34 return (GET_FIELD_SP(pixel_addr
, 60, 63) << (17 + 2 * cubesize
)) |
35 (GET_FIELD_SP(pixel_addr
, 39, 39 + cubesize
- 1) << (17 + cubesize
)) |
36 (GET_FIELD_SP(pixel_addr
, 17 + cubesize
- 1, 17) << 17) |
37 (GET_FIELD_SP(pixel_addr
, 56, 59) << 13) |
38 (GET_FIELD_SP(pixel_addr
, 35, 38) << 9) |
39 (GET_FIELD_SP(pixel_addr
, 13, 16) << 5) |
40 (((pixel_addr
>> 55) & 1) << 4) |
41 (GET_FIELD_SP(pixel_addr
, 33, 34) << 2) |
42 GET_FIELD_SP(pixel_addr
, 11, 12);
45 target_ulong
helper_alignaddr(CPUState
*env
, target_ulong addr
,
52 env
->gsr
|= tmp
& 7ULL;
56 uint64_t helper_faligndata(CPUState
*env
, uint64_t src1
, uint64_t src2
)
60 tmp
= src1
<< ((env
->gsr
& 7) * 8);
61 /* on many architectures a shift of 64 does nothing */
62 if ((env
->gsr
& 7) != 0) {
63 tmp
|= src2
>> (64 - (env
->gsr
& 7) * 8);
68 #ifdef HOST_WORDS_BIGENDIAN
69 #define VIS_B64(n) b[7 - (n)]
70 #define VIS_W64(n) w[3 - (n)]
71 #define VIS_SW64(n) sw[3 - (n)]
72 #define VIS_L64(n) l[1 - (n)]
73 #define VIS_B32(n) b[3 - (n)]
74 #define VIS_W32(n) w[1 - (n)]
76 #define VIS_B64(n) b[n]
77 #define VIS_W64(n) w[n]
78 #define VIS_SW64(n) sw[n]
79 #define VIS_L64(n) l[n]
80 #define VIS_B32(n) b[n]
81 #define VIS_W32(n) w[n]
100 uint64_t helper_fpmerge(CPUState
*env
, uint64_t src1
, uint64_t src2
)
107 /* Reverse calculation order to handle overlap */
108 d
.VIS_B64(7) = s
.VIS_B64(3);
109 d
.VIS_B64(6) = d
.VIS_B64(3);
110 d
.VIS_B64(5) = s
.VIS_B64(2);
111 d
.VIS_B64(4) = d
.VIS_B64(2);
112 d
.VIS_B64(3) = s
.VIS_B64(1);
113 d
.VIS_B64(2) = d
.VIS_B64(1);
114 d
.VIS_B64(1) = s
.VIS_B64(0);
115 /* d.VIS_B64(0) = d.VIS_B64(0); */
120 uint64_t helper_fmul8x16(CPUState
*env
, uint64_t src1
, uint64_t src2
)
129 tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \
130 if ((tmp & 0xff) > 0x7f) { \
133 d.VIS_W64(r) = tmp >> 8;
144 uint64_t helper_fmul8x16al(CPUState
*env
, uint64_t src1
, uint64_t src2
)
153 tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \
154 if ((tmp & 0xff) > 0x7f) { \
157 d.VIS_W64(r) = tmp >> 8;
168 uint64_t helper_fmul8x16au(CPUState
*env
, uint64_t src1
, uint64_t src2
)
177 tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \
178 if ((tmp & 0xff) > 0x7f) { \
181 d.VIS_W64(r) = tmp >> 8;
192 uint64_t helper_fmul8sux16(CPUState
*env
, uint64_t src1
, uint64_t src2
)
201 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
202 if ((tmp & 0xff) > 0x7f) { \
205 d.VIS_W64(r) = tmp >> 8;
216 uint64_t helper_fmul8ulx16(CPUState
*env
, uint64_t src1
, uint64_t src2
)
225 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
226 if ((tmp & 0xff) > 0x7f) { \
229 d.VIS_W64(r) = tmp >> 8;
240 uint64_t helper_fmuld8sux16(CPUState
*env
, uint64_t src1
, uint64_t src2
)
249 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
250 if ((tmp & 0xff) > 0x7f) { \
255 /* Reverse calculation order to handle overlap */
263 uint64_t helper_fmuld8ulx16(CPUState
*env
, uint64_t src1
, uint64_t src2
)
272 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
273 if ((tmp & 0xff) > 0x7f) { \
278 /* Reverse calculation order to handle overlap */
286 uint64_t helper_fexpand(CPUState
*env
, uint64_t src1
, uint64_t src2
)
291 s
.l
= (uint32_t)src1
;
293 d
.VIS_W64(0) = s
.VIS_B32(0) << 4;
294 d
.VIS_W64(1) = s
.VIS_B32(1) << 4;
295 d
.VIS_W64(2) = s
.VIS_B32(2) << 4;
296 d
.VIS_W64(3) = s
.VIS_B32(3) << 4;
301 #define VIS_HELPER(name, F) \
302 uint64_t name##16(CPUState *env, uint64_t src1, uint64_t src2) \
309 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0)); \
310 d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1)); \
311 d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2)); \
312 d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3)); \
317 uint32_t name##16s(CPUState *env, uint32_t src1, \
325 d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0)); \
326 d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1)); \
331 uint64_t name##32(CPUState *env, uint64_t src1, uint64_t src2) \
338 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0)); \
339 d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1)); \
344 uint32_t name##32s(CPUState *env, uint32_t src1, \
357 #define FADD(a, b) ((a) + (b))
358 #define FSUB(a, b) ((a) - (b))
359 VIS_HELPER(helper_fpadd
, FADD
)
360 VIS_HELPER(helper_fpsub
, FSUB
)
362 #define VIS_CMPHELPER(name, F) \
363 uint64_t name##16(CPUState *env, uint64_t src1, uint64_t src2) \
370 d.VIS_W64(0) = F(s.VIS_W64(0), d.VIS_W64(0)) ? 1 : 0; \
371 d.VIS_W64(0) |= F(s.VIS_W64(1), d.VIS_W64(1)) ? 2 : 0; \
372 d.VIS_W64(0) |= F(s.VIS_W64(2), d.VIS_W64(2)) ? 4 : 0; \
373 d.VIS_W64(0) |= F(s.VIS_W64(3), d.VIS_W64(3)) ? 8 : 0; \
374 d.VIS_W64(1) = d.VIS_W64(2) = d.VIS_W64(3) = 0; \
379 uint64_t name##32(CPUState *env, uint64_t src1, uint64_t src2) \
386 d.VIS_L64(0) = F(s.VIS_L64(0), d.VIS_L64(0)) ? 1 : 0; \
387 d.VIS_L64(0) |= F(s.VIS_L64(1), d.VIS_L64(1)) ? 2 : 0; \
393 #define FCMPGT(a, b) ((a) > (b))
394 #define FCMPEQ(a, b) ((a) == (b))
395 #define FCMPLE(a, b) ((a) <= (b))
396 #define FCMPNE(a, b) ((a) != (b))
398 VIS_CMPHELPER(helper_fcmpgt
, FCMPGT
)
399 VIS_CMPHELPER(helper_fcmpeq
, FCMPEQ
)
400 VIS_CMPHELPER(helper_fcmple
, FCMPLE
)
401 VIS_CMPHELPER(helper_fcmpne
, FCMPNE
)