]>
git.proxmox.com Git - mirror_qemu.git/blob - target-sparc/op.c
4 Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
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, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define REG (env->gregs[0])
26 #include "op_template.h"
28 #define REG (env->gregs[1])
29 #include "op_template.h"
31 #define REG (env->gregs[2])
32 #include "op_template.h"
34 #define REG (env->gregs[3])
35 #include "op_template.h"
37 #define REG (env->gregs[4])
38 #include "op_template.h"
40 #define REG (env->gregs[5])
41 #include "op_template.h"
43 #define REG (env->gregs[6])
44 #include "op_template.h"
46 #define REG (env->gregs[7])
47 #include "op_template.h"
49 #define REG (REGWPTR[16])
50 #include "op_template.h"
52 #define REG (REGWPTR[17])
53 #include "op_template.h"
55 #define REG (REGWPTR[18])
56 #include "op_template.h"
58 #define REG (REGWPTR[19])
59 #include "op_template.h"
61 #define REG (REGWPTR[20])
62 #include "op_template.h"
64 #define REG (REGWPTR[21])
65 #include "op_template.h"
67 #define REG (REGWPTR[22])
68 #include "op_template.h"
70 #define REG (REGWPTR[23])
71 #include "op_template.h"
73 #define REG (REGWPTR[8])
74 #include "op_template.h"
76 #define REG (REGWPTR[9])
77 #include "op_template.h"
79 #define REG (REGWPTR[10])
80 #include "op_template.h"
82 #define REG (REGWPTR[11])
83 #include "op_template.h"
85 #define REG (REGWPTR[12])
86 #include "op_template.h"
88 #define REG (REGWPTR[13])
89 #include "op_template.h"
91 #define REG (REGWPTR[14])
92 #include "op_template.h"
94 #define REG (REGWPTR[15])
95 #include "op_template.h"
97 #define REG (REGWPTR[0])
98 #include "op_template.h"
100 #define REG (REGWPTR[1])
101 #include "op_template.h"
103 #define REG (REGWPTR[2])
104 #include "op_template.h"
106 #define REG (REGWPTR[3])
107 #include "op_template.h"
109 #define REG (REGWPTR[4])
110 #include "op_template.h"
112 #define REG (REGWPTR[5])
113 #include "op_template.h"
115 #define REG (REGWPTR[6])
116 #include "op_template.h"
118 #define REG (REGWPTR[7])
119 #include "op_template.h"
122 #define REG (env->fpr[0])
123 #include "fop_template.h"
125 #define REG (env->fpr[1])
126 #include "fop_template.h"
128 #define REG (env->fpr[2])
129 #include "fop_template.h"
131 #define REG (env->fpr[3])
132 #include "fop_template.h"
134 #define REG (env->fpr[4])
135 #include "fop_template.h"
137 #define REG (env->fpr[5])
138 #include "fop_template.h"
140 #define REG (env->fpr[6])
141 #include "fop_template.h"
143 #define REG (env->fpr[7])
144 #include "fop_template.h"
146 #define REG (env->fpr[8])
147 #include "fop_template.h"
149 #define REG (env->fpr[9])
150 #include "fop_template.h"
152 #define REG (env->fpr[10])
153 #include "fop_template.h"
155 #define REG (env->fpr[11])
156 #include "fop_template.h"
158 #define REG (env->fpr[12])
159 #include "fop_template.h"
161 #define REG (env->fpr[13])
162 #include "fop_template.h"
164 #define REG (env->fpr[14])
165 #include "fop_template.h"
167 #define REG (env->fpr[15])
168 #include "fop_template.h"
170 #define REG (env->fpr[16])
171 #include "fop_template.h"
173 #define REG (env->fpr[17])
174 #include "fop_template.h"
176 #define REG (env->fpr[18])
177 #include "fop_template.h"
179 #define REG (env->fpr[19])
180 #include "fop_template.h"
182 #define REG (env->fpr[20])
183 #include "fop_template.h"
185 #define REG (env->fpr[21])
186 #include "fop_template.h"
188 #define REG (env->fpr[22])
189 #include "fop_template.h"
191 #define REG (env->fpr[23])
192 #include "fop_template.h"
194 #define REG (env->fpr[24])
195 #include "fop_template.h"
197 #define REG (env->fpr[25])
198 #include "fop_template.h"
200 #define REG (env->fpr[26])
201 #include "fop_template.h"
203 #define REG (env->fpr[27])
204 #include "fop_template.h"
206 #define REG (env->fpr[28])
207 #include "fop_template.h"
209 #define REG (env->fpr[29])
210 #include "fop_template.h"
212 #define REG (env->fpr[30])
213 #include "fop_template.h"
215 #define REG (env->fpr[31])
216 #include "fop_template.h"
218 #ifdef TARGET_SPARC64
220 #define REG (env->fpr[32])
221 #include "fop_template.h"
223 #define REG (env->fpr[34])
224 #include "fop_template.h"
226 #define REG (env->fpr[36])
227 #include "fop_template.h"
229 #define REG (env->fpr[38])
230 #include "fop_template.h"
232 #define REG (env->fpr[40])
233 #include "fop_template.h"
235 #define REG (env->fpr[42])
236 #include "fop_template.h"
238 #define REG (env->fpr[44])
239 #include "fop_template.h"
241 #define REG (env->fpr[46])
242 #include "fop_template.h"
244 #define REG (env->fpr[47])
245 #include "fop_template.h"
247 #define REG (env->fpr[50])
248 #include "fop_template.h"
250 #define REG (env->fpr[52])
251 #include "fop_template.h"
253 #define REG (env->fpr[54])
254 #include "fop_template.h"
256 #define REG (env->fpr[56])
257 #include "fop_template.h"
259 #define REG (env->fpr[58])
260 #include "fop_template.h"
262 #define REG (env->fpr[60])
263 #include "fop_template.h"
265 #define REG (env->fpr[62])
266 #include "fop_template.h"
269 #ifdef TARGET_SPARC64
270 #ifdef WORDS_BIGENDIAN
271 typedef union UREG64
{
272 struct { uint16_t v3
, v2
, v1
, v0
; } w
;
273 struct { uint32_t v1
, v0
; } l
;
277 typedef union UREG64
{
278 struct { uint16_t v0
, v1
, v2
, v3
; } w
;
279 struct { uint32_t v0
, v1
; } l
;
292 void OPPROTO
op_movq_T0_im64(void)
297 void OPPROTO
op_movq_T1_im64(void)
302 #define XFLAG_SET(x) ((env->xcc&x)?1:0)
305 #define EIP (env->pc)
308 #define FLAG_SET(x) ((env->psr&x)?1:0)
310 void OPPROTO
op_movl_T0_0(void)
315 void OPPROTO
op_movl_T0_im(void)
317 T0
= (uint32_t)PARAM1
;
320 void OPPROTO
op_movl_T1_im(void)
322 T1
= (uint32_t)PARAM1
;
325 void OPPROTO
op_movl_T2_im(void)
327 T2
= (uint32_t)PARAM1
;
330 void OPPROTO
op_movl_T0_sim(void)
332 T0
= (int32_t)PARAM1
;
335 void OPPROTO
op_movl_T1_sim(void)
337 T1
= (int32_t)PARAM1
;
340 void OPPROTO
op_movl_T2_sim(void)
342 T2
= (int32_t)PARAM1
;
345 void OPPROTO
op_movl_T0_env(void)
347 T0
= *(uint32_t *)((char *)env
+ PARAM1
);
350 void OPPROTO
op_movl_env_T0(void)
352 *(uint32_t *)((char *)env
+ PARAM1
) = T0
;
355 void OPPROTO
op_movtl_T0_env(void)
357 T0
= *(target_ulong
*)((char *)env
+ PARAM1
);
360 void OPPROTO
op_movtl_env_T0(void)
362 *(target_ulong
*)((char *)env
+ PARAM1
) = T0
;
365 void OPPROTO
op_add_T1_T0(void)
370 void OPPROTO
op_add_T1_T0_cc(void)
377 #ifdef TARGET_SPARC64
378 if (!(T0
& 0xffffffff))
379 env
->psr
|= PSR_ZERO
;
380 if ((int32_t) T0
< 0)
382 if ((T0
& 0xffffffff) < (src1
& 0xffffffff))
383 env
->psr
|= PSR_CARRY
;
384 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff) ^ -1) &
385 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
390 env
->xcc
|= PSR_ZERO
;
391 if ((int64_t) T0
< 0)
394 env
->xcc
|= PSR_CARRY
;
395 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1ULL << 63))
399 env
->psr
|= PSR_ZERO
;
400 if ((int32_t) T0
< 0)
403 env
->psr
|= PSR_CARRY
;
404 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1 << 31))
410 void OPPROTO
op_addx_T1_T0(void)
412 T0
+= T1
+ FLAG_SET(PSR_CARRY
);
415 void OPPROTO
op_addx_T1_T0_cc(void)
419 if (FLAG_SET(PSR_CARRY
))
423 #ifdef TARGET_SPARC64
424 if ((T0
& 0xffffffff) <= (src1
& 0xffffffff))
425 env
->psr
|= PSR_CARRY
;
428 env
->xcc
|= PSR_CARRY
;
431 env
->psr
|= PSR_CARRY
;
438 #ifdef TARGET_SPARC64
439 if ((T0
& 0xffffffff) < (src1
& 0xffffffff))
440 env
->psr
|= PSR_CARRY
;
443 env
->xcc
|= PSR_CARRY
;
446 env
->psr
|= PSR_CARRY
;
449 #ifdef TARGET_SPARC64
450 if (!(T0
& 0xffffffff))
451 env
->psr
|= PSR_ZERO
;
452 if ((int32_t) T0
< 0)
454 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff) ^ -1) &
455 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
459 env
->xcc
|= PSR_ZERO
;
460 if ((int64_t) T0
< 0)
462 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1ULL << 63))
466 env
->psr
|= PSR_ZERO
;
467 if ((int32_t) T0
< 0)
469 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1 << 31))
475 void OPPROTO
op_tadd_T1_T0_cc(void)
482 #ifdef TARGET_SPARC64
483 if (!(T0
& 0xffffffff))
484 env
->psr
|= PSR_ZERO
;
485 if ((int32_t) T0
< 0)
487 if ((T0
& 0xffffffff) < (src1
& 0xffffffff))
488 env
->psr
|= PSR_CARRY
;
489 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff) ^ -1) &
490 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
492 if ((src1
& 0x03) || (T1
& 0x03))
497 env
->xcc
|= PSR_ZERO
;
498 if ((int64_t) T0
< 0)
501 env
->xcc
|= PSR_CARRY
;
502 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1ULL << 63))
506 env
->psr
|= PSR_ZERO
;
507 if ((int32_t) T0
< 0)
510 env
->psr
|= PSR_CARRY
;
511 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1 << 31))
513 if ((src1
& 0x03) || (T1
& 0x03))
519 void OPPROTO
op_tadd_T1_T0_ccTV(void)
523 if ((T0
& 0x03) || (T1
& 0x03))
524 raise_exception(TT_TOVF
);
529 #ifdef TARGET_SPARC64
530 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff) ^ -1) &
531 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
532 raise_exception(TT_TOVF
);
534 if ((src1
& 0x03) || (T1
& 0x03))
535 raise_exception(TT_TOVF
);
539 #ifdef TARGET_SPARC64
540 if (!(T0
& 0xffffffff))
541 env
->psr
|= PSR_ZERO
;
542 if ((int32_t) T0
< 0)
544 if ((T0
& 0xffffffff) < (src1
& 0xffffffff))
545 env
->psr
|= PSR_CARRY
;
549 env
->xcc
|= PSR_ZERO
;
550 if ((int64_t) T0
< 0)
553 env
->xcc
|= PSR_CARRY
;
556 env
->psr
|= PSR_ZERO
;
557 if ((int32_t) T0
< 0)
560 env
->psr
|= PSR_CARRY
;
565 void OPPROTO
op_sub_T1_T0(void)
570 void OPPROTO
op_sub_T1_T0_cc(void)
577 #ifdef TARGET_SPARC64
578 if (!(T0
& 0xffffffff))
579 env
->psr
|= PSR_ZERO
;
580 if ((int32_t) T0
< 0)
582 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
583 env
->psr
|= PSR_CARRY
;
584 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
585 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
590 env
->xcc
|= PSR_ZERO
;
591 if ((int64_t) T0
< 0)
594 env
->xcc
|= PSR_CARRY
;
595 if (((src1
^ T1
) & (src1
^ T0
)) & (1ULL << 63))
599 env
->psr
|= PSR_ZERO
;
600 if ((int32_t) T0
< 0)
603 env
->psr
|= PSR_CARRY
;
604 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
610 void OPPROTO
op_subx_T1_T0(void)
612 T0
-= T1
+ FLAG_SET(PSR_CARRY
);
615 void OPPROTO
op_subx_T1_T0_cc(void)
619 if (FLAG_SET(PSR_CARRY
))
623 #ifdef TARGET_SPARC64
624 if ((src1
& 0xffffffff) <= (T1
& 0xffffffff))
625 env
->psr
|= PSR_CARRY
;
628 env
->xcc
|= PSR_CARRY
;
631 env
->psr
|= PSR_CARRY
;
638 #ifdef TARGET_SPARC64
639 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
640 env
->psr
|= PSR_CARRY
;
643 env
->xcc
|= PSR_CARRY
;
646 env
->psr
|= PSR_CARRY
;
649 #ifdef TARGET_SPARC64
650 if (!(T0
& 0xffffffff))
651 env
->psr
|= PSR_ZERO
;
652 if ((int32_t) T0
< 0)
654 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
655 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
659 env
->xcc
|= PSR_ZERO
;
660 if ((int64_t) T0
< 0)
662 if (((src1
^ T1
) & (src1
^ T0
)) & (1ULL << 63))
666 env
->psr
|= PSR_ZERO
;
667 if ((int32_t) T0
< 0)
669 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
675 void OPPROTO
op_tsub_T1_T0_cc(void)
682 #ifdef TARGET_SPARC64
683 if (!(T0
& 0xffffffff))
684 env
->psr
|= PSR_ZERO
;
685 if ((int32_t) T0
< 0)
687 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
688 env
->psr
|= PSR_CARRY
;
689 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
690 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
692 if ((src1
& 0x03) || (T1
& 0x03))
697 env
->xcc
|= PSR_ZERO
;
698 if ((int64_t) T0
< 0)
701 env
->xcc
|= PSR_CARRY
;
702 if (((src1
^ T1
) & (src1
^ T0
)) & (1ULL << 63))
706 env
->psr
|= PSR_ZERO
;
707 if ((int32_t) T0
< 0)
710 env
->psr
|= PSR_CARRY
;
711 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
713 if ((src1
& 0x03) || (T1
& 0x03))
719 void OPPROTO
op_tsub_T1_T0_ccTV(void)
723 if ((T0
& 0x03) || (T1
& 0x03))
724 raise_exception(TT_TOVF
);
729 #ifdef TARGET_SPARC64
730 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
731 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
732 raise_exception(TT_TOVF
);
734 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
735 raise_exception(TT_TOVF
);
739 #ifdef TARGET_SPARC64
740 if (!(T0
& 0xffffffff))
741 env
->psr
|= PSR_ZERO
;
742 if ((int32_t) T0
< 0)
744 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
745 env
->psr
|= PSR_CARRY
;
749 env
->xcc
|= PSR_ZERO
;
750 if ((int64_t) T0
< 0)
753 env
->xcc
|= PSR_CARRY
;
756 env
->psr
|= PSR_ZERO
;
757 if ((int32_t) T0
< 0)
760 env
->psr
|= PSR_CARRY
;
765 void OPPROTO
op_and_T1_T0(void)
770 void OPPROTO
op_or_T1_T0(void)
775 void OPPROTO
op_xor_T1_T0(void)
780 void OPPROTO
op_andn_T1_T0(void)
785 void OPPROTO
op_orn_T1_T0(void)
790 void OPPROTO
op_xnor_T1_T0(void)
795 void OPPROTO
op_umul_T1_T0(void)
798 res
= (uint64_t) T0
* (uint64_t) T1
;
799 #ifdef TARGET_SPARC64
802 T0
= res
& 0xffffffff;
807 void OPPROTO
op_smul_T1_T0(void)
810 res
= (int64_t) ((int32_t) T0
) * (int64_t) ((int32_t) T1
);
811 #ifdef TARGET_SPARC64
814 T0
= res
& 0xffffffff;
819 void OPPROTO
op_mulscc_T1_T0(void)
821 unsigned int b1
, N
, V
, b2
;
824 N
= FLAG_SET(PSR_NEG
);
825 V
= FLAG_SET(PSR_OVF
);
828 T0
= (b1
<< 31) | (T0
>> 1);
831 /* do addition and update flags */
836 env
->psr
|= PSR_ZERO
;
837 if ((int32_t) T0
< 0)
840 env
->psr
|= PSR_CARRY
;
841 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1 << 31))
843 env
->y
= (b2
<< 31) | (env
->y
>> 1);
847 void OPPROTO
op_udiv_T1_T0(void)
852 x0
= T0
| ((uint64_t) (env
->y
) << 32);
856 raise_exception(TT_DIV_ZERO
);
860 if (x0
> 0xffffffff) {
870 void OPPROTO
op_sdiv_T1_T0(void)
875 x0
= T0
| ((int64_t) (env
->y
) << 32);
879 raise_exception(TT_DIV_ZERO
);
883 if ((int32_t) x0
!= x0
) {
884 T0
= x0
< 0? 0x80000000: 0x7fffffff;
893 void OPPROTO
op_div_cc(void)
896 #ifdef TARGET_SPARC64
898 env
->psr
|= PSR_ZERO
;
899 if ((int32_t) T0
< 0)
906 env
->xcc
|= PSR_ZERO
;
907 if ((int64_t) T0
< 0)
911 env
->psr
|= PSR_ZERO
;
912 if ((int32_t) T0
< 0)
920 #ifdef TARGET_SPARC64
921 void OPPROTO
op_mulx_T1_T0(void)
927 void OPPROTO
op_udivx_T1_T0(void)
933 void OPPROTO
op_sdivx_T1_T0(void)
935 if (T0
== INT64_MIN
&& T1
== -1)
938 T0
/= (target_long
) T1
;
943 void OPPROTO
op_logic_T0_cc(void)
946 #ifdef TARGET_SPARC64
947 if (!(T0
& 0xffffffff))
948 env
->psr
|= PSR_ZERO
;
949 if ((int32_t) T0
< 0)
954 env
->xcc
|= PSR_ZERO
;
955 if ((int64_t) T0
< 0)
959 env
->psr
|= PSR_ZERO
;
960 if ((int32_t) T0
< 0)
966 void OPPROTO
op_sll(void)
971 #ifdef TARGET_SPARC64
972 void OPPROTO
op_sllx(void)
977 void OPPROTO
op_srl(void)
979 T0
= (T0
& 0xffffffff) >> (T1
& 0x1f);
982 void OPPROTO
op_srlx(void)
987 void OPPROTO
op_sra(void)
989 T0
= ((int32_t) (T0
& 0xffffffff)) >> (T1
& 0x1f);
992 void OPPROTO
op_srax(void)
994 T0
= ((int64_t) T0
) >> (T1
& 0x3f);
997 void OPPROTO
op_srl(void)
1002 void OPPROTO
op_sra(void)
1004 T0
= ((int32_t) T0
) >> (T1
& 0x1f);
1008 /* Load and store */
1009 #define MEMSUFFIX _raw
1011 #if !defined(CONFIG_USER_ONLY)
1012 #define MEMSUFFIX _user
1015 #define MEMSUFFIX _kernel
1019 void OPPROTO
op_ldfsr(void)
1021 PUT_FSR32(env
, *((uint32_t *) &FT0
));
1025 void OPPROTO
op_stfsr(void)
1027 *((uint32_t *) &FT0
) = GET_FSR32(env
);
1030 #ifndef TARGET_SPARC64
1031 void OPPROTO
op_rdpsr(void)
1036 void OPPROTO
op_wrpsr(void)
1042 void OPPROTO
op_wrwim(void)
1047 env
->wim
= T0
& ((1 << NWINDOWS
) - 1);
1051 void OPPROTO
op_rett(void)
1057 /* XXX: use another pointer for %iN registers to avoid slow wrapping
1059 void OPPROTO
op_save(void)
1062 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
1063 if (env
->wim
& (1 << cwp
)) {
1064 raise_exception(TT_WIN_OVF
);
1070 void OPPROTO
op_restore(void)
1073 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
1074 if (env
->wim
& (1 << cwp
)) {
1075 raise_exception(TT_WIN_UNF
);
1081 void OPPROTO
op_rdccr(void)
1086 void OPPROTO
op_wrccr(void)
1091 void OPPROTO
op_rdtick(void)
1093 T0
= 0; // XXX read cycle counter and bit 31
1096 void OPPROTO
op_wrtick(void)
1098 // XXX write cycle counter and bit 31
1101 void OPPROTO
op_rdtpc(void)
1103 T0
= env
->tpc
[env
->tl
];
1106 void OPPROTO
op_wrtpc(void)
1108 env
->tpc
[env
->tl
] = T0
;
1111 void OPPROTO
op_rdtnpc(void)
1113 T0
= env
->tnpc
[env
->tl
];
1116 void OPPROTO
op_wrtnpc(void)
1118 env
->tnpc
[env
->tl
] = T0
;
1121 void OPPROTO
op_rdtstate(void)
1123 T0
= env
->tstate
[env
->tl
];
1126 void OPPROTO
op_wrtstate(void)
1128 env
->tstate
[env
->tl
] = T0
;
1131 void OPPROTO
op_rdtt(void)
1133 T0
= env
->tt
[env
->tl
];
1136 void OPPROTO
op_wrtt(void)
1138 env
->tt
[env
->tl
] = T0
;
1141 void OPPROTO
op_rdpstate(void)
1146 void OPPROTO
op_wrpstate(void)
1151 // CWP handling is reversed in V9, but we still use the V8 register
1153 void OPPROTO
op_rdcwp(void)
1155 T0
= NWINDOWS
- 1 - env
->cwp
;
1158 void OPPROTO
op_wrcwp(void)
1160 env
->cwp
= NWINDOWS
- 1 - T0
;
1163 /* XXX: use another pointer for %iN registers to avoid slow wrapping
1165 void OPPROTO
op_save(void)
1168 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
1169 if (env
->cansave
== 0) {
1170 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
1171 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
1172 ((env
->wstate
& 0x7) << 2)));
1174 if (env
->cleanwin
- env
->canrestore
== 0) {
1175 // XXX Clean windows without trap
1176 raise_exception(TT_CLRWIN
);
1186 void OPPROTO
op_restore(void)
1189 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
1190 if (env
->canrestore
== 0) {
1191 raise_exception(TT_FILL
| (env
->otherwin
!= 0 ?
1192 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
1193 ((env
->wstate
& 0x7) << 2)));
1203 void OPPROTO
op_exception(void)
1205 env
->exception_index
= PARAM1
;
1209 void OPPROTO
op_trap_T0(void)
1211 env
->exception_index
= TT_TRAP
+ (T0
& 0x7f);
1215 void OPPROTO
op_trapcc_T0(void)
1218 env
->exception_index
= TT_TRAP
+ (T0
& 0x7f);
1224 void OPPROTO
op_fpexception_im(void)
1226 env
->exception_index
= TT_FP_EXCP
;
1227 env
->fsr
&= ~FSR_FTT_MASK
;
1233 void OPPROTO
op_debug(void)
1238 void OPPROTO
op_exit_tb(void)
1243 void OPPROTO
op_eval_ba(void)
1248 void OPPROTO
op_eval_be(void)
1250 T2
= FLAG_SET(PSR_ZERO
);
1253 void OPPROTO
op_eval_ble(void)
1255 target_ulong Z
= FLAG_SET(PSR_ZERO
), N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1260 void OPPROTO
op_eval_bl(void)
1262 target_ulong N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1267 void OPPROTO
op_eval_bleu(void)
1269 target_ulong Z
= FLAG_SET(PSR_ZERO
), C
= FLAG_SET(PSR_CARRY
);
1274 void OPPROTO
op_eval_bcs(void)
1276 T2
= FLAG_SET(PSR_CARRY
);
1279 void OPPROTO
op_eval_bvs(void)
1281 T2
= FLAG_SET(PSR_OVF
);
1284 void OPPROTO
op_eval_bn(void)
1289 void OPPROTO
op_eval_bneg(void)
1291 T2
= FLAG_SET(PSR_NEG
);
1294 void OPPROTO
op_eval_bne(void)
1296 T2
= !FLAG_SET(PSR_ZERO
);
1299 void OPPROTO
op_eval_bg(void)
1301 target_ulong Z
= FLAG_SET(PSR_ZERO
), N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1303 T2
= !(Z
| (N
^ V
));
1306 void OPPROTO
op_eval_bge(void)
1308 target_ulong N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1313 void OPPROTO
op_eval_bgu(void)
1315 target_ulong Z
= FLAG_SET(PSR_ZERO
), C
= FLAG_SET(PSR_CARRY
);
1320 void OPPROTO
op_eval_bcc(void)
1322 T2
= !FLAG_SET(PSR_CARRY
);
1325 void OPPROTO
op_eval_bpos(void)
1327 T2
= !FLAG_SET(PSR_NEG
);
1330 void OPPROTO
op_eval_bvc(void)
1332 T2
= !FLAG_SET(PSR_OVF
);
1335 #ifdef TARGET_SPARC64
1336 void OPPROTO
op_eval_xbe(void)
1338 T2
= XFLAG_SET(PSR_ZERO
);
1341 void OPPROTO
op_eval_xble(void)
1343 target_ulong Z
= XFLAG_SET(PSR_ZERO
), N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1348 void OPPROTO
op_eval_xbl(void)
1350 target_ulong N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1355 void OPPROTO
op_eval_xbleu(void)
1357 target_ulong Z
= XFLAG_SET(PSR_ZERO
), C
= XFLAG_SET(PSR_CARRY
);
1362 void OPPROTO
op_eval_xbcs(void)
1364 T2
= XFLAG_SET(PSR_CARRY
);
1367 void OPPROTO
op_eval_xbvs(void)
1369 T2
= XFLAG_SET(PSR_OVF
);
1372 void OPPROTO
op_eval_xbneg(void)
1374 T2
= XFLAG_SET(PSR_NEG
);
1377 void OPPROTO
op_eval_xbne(void)
1379 T2
= !XFLAG_SET(PSR_ZERO
);
1382 void OPPROTO
op_eval_xbg(void)
1384 target_ulong Z
= XFLAG_SET(PSR_ZERO
), N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1386 T2
= !(Z
| (N
^ V
));
1389 void OPPROTO
op_eval_xbge(void)
1391 target_ulong N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1396 void OPPROTO
op_eval_xbgu(void)
1398 target_ulong Z
= XFLAG_SET(PSR_ZERO
), C
= XFLAG_SET(PSR_CARRY
);
1403 void OPPROTO
op_eval_xbcc(void)
1405 T2
= !XFLAG_SET(PSR_CARRY
);
1408 void OPPROTO
op_eval_xbpos(void)
1410 T2
= !XFLAG_SET(PSR_NEG
);
1413 void OPPROTO
op_eval_xbvc(void)
1415 T2
= !XFLAG_SET(PSR_OVF
);
1420 #define FFLAG_SET(x) (env->fsr & x? 1: 0)
1421 #include "fbranch_template.h"
1423 #ifdef TARGET_SPARC64
1425 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 32))? 1: 0)
1426 #include "fbranch_template.h"
1428 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 34))? 1: 0)
1429 #include "fbranch_template.h"
1431 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 36))? 1: 0)
1432 #include "fbranch_template.h"
1435 #ifdef TARGET_SPARC64
1436 void OPPROTO
op_eval_brz(void)
1441 void OPPROTO
op_eval_brnz(void)
1446 void OPPROTO
op_eval_brlz(void)
1448 T2
= ((int64_t)T0
< 0);
1451 void OPPROTO
op_eval_brlez(void)
1453 T2
= ((int64_t)T0
<= 0);
1456 void OPPROTO
op_eval_brgz(void)
1458 T2
= ((int64_t)T0
> 0);
1461 void OPPROTO
op_eval_brgez(void)
1463 T2
= ((int64_t)T0
>= 0);
1466 void OPPROTO
op_jmp_im64(void)
1471 void OPPROTO
op_movq_npc_im64(void)
1477 void OPPROTO
op_jmp_im(void)
1479 env
->pc
= (uint32_t)PARAM1
;
1482 void OPPROTO
op_movl_npc_im(void)
1484 env
->npc
= (uint32_t)PARAM1
;
1487 void OPPROTO
op_movl_npc_T0(void)
1492 void OPPROTO
op_mov_pc_npc(void)
1497 void OPPROTO
op_next_insn(void)
1500 env
->npc
= env
->npc
+ 4;
1503 void OPPROTO
op_goto_tb0(void)
1505 GOTO_TB(op_goto_tb0
, PARAM1
, 0);
1508 void OPPROTO
op_goto_tb1(void)
1510 GOTO_TB(op_goto_tb1
, PARAM1
, 1);
1513 void OPPROTO
op_jmp_label(void)
1515 GOTO_LABEL_PARAM(1);
1518 void OPPROTO
op_jnz_T2_label(void)
1521 GOTO_LABEL_PARAM(1);
1525 void OPPROTO
op_jz_T2_label(void)
1528 GOTO_LABEL_PARAM(1);
1532 void OPPROTO
op_flush_T0(void)
1537 void OPPROTO
op_clear_ieee_excp_and_FTT(void)
1539 env
->fsr
&= ~(FSR_FTT_MASK
| FSR_CEXC_MASK
);;
1542 #define F_OP(name, p) void OPPROTO op_f##name##p(void)
1544 #define F_BINOP(name) \
1547 set_float_exception_flags(0, &env->fp_status); \
1548 FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
1549 check_ieee_exceptions(); \
1553 set_float_exception_flags(0, &env->fp_status); \
1554 DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
1555 check_ieee_exceptions(); \
1564 void OPPROTO
op_fsmuld(void)
1566 set_float_exception_flags(0, &env
->fp_status
);
1567 DT0
= float64_mul(float32_to_float64(FT0
, &env
->fp_status
),
1568 float32_to_float64(FT1
, &env
->fp_status
),
1570 check_ieee_exceptions();
1573 #define F_HELPER(name) \
1587 FT0
= float32_chs(FT1
);
1598 #ifdef TARGET_SPARC64
1601 DT0
= float64_chs(DT1
);
1609 void OPPROTO
op_fcmps_fcc1(void)
1614 void OPPROTO
op_fcmpd_fcc1(void)
1619 void OPPROTO
op_fcmps_fcc2(void)
1624 void OPPROTO
op_fcmpd_fcc2(void)
1629 void OPPROTO
op_fcmps_fcc3(void)
1634 void OPPROTO
op_fcmpd_fcc3(void)
1639 void OPPROTO
op_fcmpes_fcc1(void)
1644 void OPPROTO
op_fcmped_fcc1(void)
1649 void OPPROTO
op_fcmpes_fcc2(void)
1654 void OPPROTO
op_fcmped_fcc2(void)
1659 void OPPROTO
op_fcmpes_fcc3(void)
1664 void OPPROTO
op_fcmped_fcc3(void)
1671 /* Integer to float conversion. */
1672 #ifdef USE_INT_TO_FLOAT_HELPERS
1677 set_float_exception_flags(0, &env
->fp_status
);
1678 FT0
= int32_to_float32(*((int32_t *)&FT1
), &env
->fp_status
);
1679 check_ieee_exceptions();
1684 set_float_exception_flags(0, &env
->fp_status
);
1685 DT0
= int32_to_float64(*((int32_t *)&FT1
), &env
->fp_status
);
1686 check_ieee_exceptions();
1689 #ifdef TARGET_SPARC64
1692 set_float_exception_flags(0, &env
->fp_status
);
1693 FT0
= int64_to_float32(*((int64_t *)&DT1
), &env
->fp_status
);
1694 check_ieee_exceptions();
1699 set_float_exception_flags(0, &env
->fp_status
);
1700 DT0
= int64_to_float64(*((int64_t *)&DT1
), &env
->fp_status
);
1701 check_ieee_exceptions();
1707 /* floating point conversion */
1708 void OPPROTO
op_fdtos(void)
1710 set_float_exception_flags(0, &env
->fp_status
);
1711 FT0
= float64_to_float32(DT1
, &env
->fp_status
);
1712 check_ieee_exceptions();
1715 void OPPROTO
op_fstod(void)
1717 set_float_exception_flags(0, &env
->fp_status
);
1718 DT0
= float32_to_float64(FT1
, &env
->fp_status
);
1719 check_ieee_exceptions();
1722 /* Float to integer conversion. */
1723 void OPPROTO
op_fstoi(void)
1725 set_float_exception_flags(0, &env
->fp_status
);
1726 *((int32_t *)&FT0
) = float32_to_int32_round_to_zero(FT1
, &env
->fp_status
);
1727 check_ieee_exceptions();
1730 void OPPROTO
op_fdtoi(void)
1732 set_float_exception_flags(0, &env
->fp_status
);
1733 *((int32_t *)&FT0
) = float64_to_int32_round_to_zero(DT1
, &env
->fp_status
);
1734 check_ieee_exceptions();
1737 #ifdef TARGET_SPARC64
1738 void OPPROTO
op_fstox(void)
1740 set_float_exception_flags(0, &env
->fp_status
);
1741 *((int64_t *)&DT0
) = float32_to_int64_round_to_zero(FT1
, &env
->fp_status
);
1742 check_ieee_exceptions();
1745 void OPPROTO
op_fdtox(void)
1747 set_float_exception_flags(0, &env
->fp_status
);
1748 *((int64_t *)&DT0
) = float64_to_int64_round_to_zero(DT1
, &env
->fp_status
);
1749 check_ieee_exceptions();
1752 void OPPROTO
op_fmovs_cc(void)
1758 void OPPROTO
op_fmovd_cc(void)
1764 void OPPROTO
op_mov_cc(void)
1770 void OPPROTO
op_flushw(void)
1772 if (env
->cansave
!= NWINDOWS
- 2) {
1773 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
1774 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
1775 ((env
->wstate
& 0x7) << 2)));
1779 void OPPROTO
op_saved(void)
1782 if (env
->otherwin
== 0)
1789 void OPPROTO
op_restored(void)
1792 if (env
->cleanwin
< NWINDOWS
- 1)
1794 if (env
->otherwin
== 0)
1801 void OPPROTO
op_popc(void)
1806 void OPPROTO
op_done(void)
1811 void OPPROTO
op_retry(void)
1816 void OPPROTO
op_sir(void)
1822 void OPPROTO
op_ld_asi_reg()
1825 helper_ld_asi(env
->asi
, PARAM2
, PARAM3
);
1828 void OPPROTO
op_st_asi_reg()
1831 helper_st_asi(env
->asi
, PARAM2
, PARAM3
);
1835 void OPPROTO
op_ld_asi()
1837 helper_ld_asi(PARAM1
, PARAM2
, PARAM3
);
1840 void OPPROTO
op_st_asi()
1842 helper_st_asi(PARAM1
, PARAM2
, PARAM3
);
1845 #ifdef TARGET_SPARC64
1846 void OPPROTO
op_alignaddr()
1852 env
->gsr
|= tmp
& 7ULL;
1856 void OPPROTO
op_faligndata()
1860 tmp
= (*((uint64_t *)&DT0
)) << ((env
->gsr
& 7) * 8);
1861 tmp
|= (*((uint64_t *)&DT1
)) >> (64 - (env
->gsr
& 7) * 8);
1862 (*((uint64_t *)&DT0
)) = tmp
;