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_sub_T1_T0(void)
480 void OPPROTO
op_sub_T1_T0_cc(void)
487 #ifdef TARGET_SPARC64
488 if (!(T0
& 0xffffffff))
489 env
->psr
|= PSR_ZERO
;
490 if ((int32_t) T0
< 0)
492 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
493 env
->psr
|= PSR_CARRY
;
494 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
495 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
500 env
->xcc
|= PSR_ZERO
;
501 if ((int64_t) T0
< 0)
504 env
->xcc
|= PSR_CARRY
;
505 if (((src1
^ T1
) & (src1
^ T0
)) & (1ULL << 63))
509 env
->psr
|= PSR_ZERO
;
510 if ((int32_t) T0
< 0)
513 env
->psr
|= PSR_CARRY
;
514 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
520 void OPPROTO
op_subx_T1_T0(void)
522 T0
-= T1
+ FLAG_SET(PSR_CARRY
);
525 void OPPROTO
op_subx_T1_T0_cc(void)
529 if (FLAG_SET(PSR_CARRY
))
533 #ifdef TARGET_SPARC64
534 if ((src1
& 0xffffffff) <= (T1
& 0xffffffff))
535 env
->psr
|= PSR_CARRY
;
538 env
->xcc
|= PSR_CARRY
;
541 env
->psr
|= PSR_CARRY
;
548 #ifdef TARGET_SPARC64
549 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
550 env
->psr
|= PSR_CARRY
;
553 env
->xcc
|= PSR_CARRY
;
556 env
->psr
|= PSR_CARRY
;
559 #ifdef TARGET_SPARC64
560 if (!(T0
& 0xffffffff))
561 env
->psr
|= PSR_ZERO
;
562 if ((int32_t) T0
< 0)
564 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
565 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
569 env
->xcc
|= PSR_ZERO
;
570 if ((int64_t) T0
< 0)
572 if (((src1
^ T1
) & (src1
^ T0
)) & (1ULL << 63))
576 env
->psr
|= PSR_ZERO
;
577 if ((int32_t) T0
< 0)
579 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
585 void OPPROTO
op_and_T1_T0(void)
590 void OPPROTO
op_or_T1_T0(void)
595 void OPPROTO
op_xor_T1_T0(void)
600 void OPPROTO
op_andn_T1_T0(void)
605 void OPPROTO
op_orn_T1_T0(void)
610 void OPPROTO
op_xnor_T1_T0(void)
615 void OPPROTO
op_umul_T1_T0(void)
618 res
= (uint64_t) T0
* (uint64_t) T1
;
619 #ifdef TARGET_SPARC64
622 T0
= res
& 0xffffffff;
627 void OPPROTO
op_smul_T1_T0(void)
630 res
= (int64_t) ((int32_t) T0
) * (int64_t) ((int32_t) T1
);
631 #ifdef TARGET_SPARC64
634 T0
= res
& 0xffffffff;
639 void OPPROTO
op_mulscc_T1_T0(void)
641 unsigned int b1
, N
, V
, b2
;
644 N
= FLAG_SET(PSR_NEG
);
645 V
= FLAG_SET(PSR_OVF
);
648 T0
= (b1
<< 31) | (T0
>> 1);
651 /* do addition and update flags */
656 env
->psr
|= PSR_ZERO
;
657 if ((int32_t) T0
< 0)
660 env
->psr
|= PSR_CARRY
;
661 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1 << 31))
663 env
->y
= (b2
<< 31) | (env
->y
>> 1);
667 void OPPROTO
op_udiv_T1_T0(void)
672 x0
= T0
| ((uint64_t) (env
->y
) << 32);
675 if (x0
> 0xffffffff) {
685 void OPPROTO
op_sdiv_T1_T0(void)
690 x0
= T0
| ((int64_t) (env
->y
) << 32);
693 if ((int32_t) x0
!= x0
) {
694 T0
= x0
< 0? 0x80000000: 0x7fffffff;
703 void OPPROTO
op_div_cc(void)
706 #ifdef TARGET_SPARC64
708 env
->psr
|= PSR_ZERO
;
709 if ((int32_t) T0
< 0)
716 env
->xcc
|= PSR_ZERO
;
717 if ((int64_t) T0
< 0)
721 env
->psr
|= PSR_ZERO
;
722 if ((int32_t) T0
< 0)
730 #ifdef TARGET_SPARC64
731 void OPPROTO
op_mulx_T1_T0(void)
737 void OPPROTO
op_udivx_T1_T0(void)
743 void OPPROTO
op_sdivx_T1_T0(void)
745 if (T0
== INT64_MIN
&& T1
== -1)
748 T0
/= (target_long
) T1
;
753 void OPPROTO
op_logic_T0_cc(void)
756 #ifdef TARGET_SPARC64
757 if (!(T0
& 0xffffffff))
758 env
->psr
|= PSR_ZERO
;
759 if ((int32_t) T0
< 0)
764 env
->xcc
|= PSR_ZERO
;
765 if ((int64_t) T0
< 0)
769 env
->psr
|= PSR_ZERO
;
770 if ((int32_t) T0
< 0)
776 void OPPROTO
op_sll(void)
781 #ifdef TARGET_SPARC64
782 void OPPROTO
op_srl(void)
784 T0
= (T0
& 0xffffffff) >> T1
;
787 void OPPROTO
op_srlx(void)
792 void OPPROTO
op_sra(void)
794 T0
= ((int32_t) (T0
& 0xffffffff)) >> T1
;
797 void OPPROTO
op_srax(void)
799 T0
= ((int64_t) T0
) >> T1
;
802 void OPPROTO
op_srl(void)
807 void OPPROTO
op_sra(void)
809 T0
= ((int32_t) T0
) >> T1
;
814 #define MEMSUFFIX _raw
816 #if !defined(CONFIG_USER_ONLY)
817 #define MEMSUFFIX _user
820 #define MEMSUFFIX _kernel
824 void OPPROTO
op_ldfsr(void)
826 PUT_FSR32(env
, *((uint32_t *) &FT0
));
830 void OPPROTO
op_stfsr(void)
832 *((uint32_t *) &FT0
) = GET_FSR32(env
);
835 #ifndef TARGET_SPARC64
836 void OPPROTO
op_rdpsr(void)
841 void OPPROTO
op_wrpsr(void)
847 void OPPROTO
op_wrwim(void)
852 env
->wim
= T0
& ((1 << NWINDOWS
) - 1);
856 void OPPROTO
op_rett(void)
862 /* XXX: use another pointer for %iN registers to avoid slow wrapping
864 void OPPROTO
op_save(void)
867 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
868 if (env
->wim
& (1 << cwp
)) {
869 raise_exception(TT_WIN_OVF
);
875 void OPPROTO
op_restore(void)
878 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
879 if (env
->wim
& (1 << cwp
)) {
880 raise_exception(TT_WIN_UNF
);
886 void OPPROTO
op_rdccr(void)
891 void OPPROTO
op_wrccr(void)
896 void OPPROTO
op_rdtick(void)
898 T0
= 0; // XXX read cycle counter and bit 31
901 void OPPROTO
op_wrtick(void)
903 // XXX write cycle counter and bit 31
906 void OPPROTO
op_rdtpc(void)
908 T0
= env
->tpc
[env
->tl
];
911 void OPPROTO
op_wrtpc(void)
913 env
->tpc
[env
->tl
] = T0
;
916 void OPPROTO
op_rdtnpc(void)
918 T0
= env
->tnpc
[env
->tl
];
921 void OPPROTO
op_wrtnpc(void)
923 env
->tnpc
[env
->tl
] = T0
;
926 void OPPROTO
op_rdtstate(void)
928 T0
= env
->tstate
[env
->tl
];
931 void OPPROTO
op_wrtstate(void)
933 env
->tstate
[env
->tl
] = T0
;
936 void OPPROTO
op_rdtt(void)
938 T0
= env
->tt
[env
->tl
];
941 void OPPROTO
op_wrtt(void)
943 env
->tt
[env
->tl
] = T0
;
946 void OPPROTO
op_rdpstate(void)
951 void OPPROTO
op_wrpstate(void)
956 // CWP handling is reversed in V9, but we still use the V8 register
958 void OPPROTO
op_rdcwp(void)
960 T0
= NWINDOWS
- 1 - env
->cwp
;
963 void OPPROTO
op_wrcwp(void)
965 env
->cwp
= NWINDOWS
- 1 - T0
;
968 /* XXX: use another pointer for %iN registers to avoid slow wrapping
970 void OPPROTO
op_save(void)
973 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
974 if (env
->cansave
== 0) {
975 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
976 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
977 ((env
->wstate
& 0x7) << 2)));
979 if (env
->cleanwin
- env
->canrestore
== 0) {
980 // XXX Clean windows without trap
981 raise_exception(TT_CLRWIN
);
991 void OPPROTO
op_restore(void)
994 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
995 if (env
->canrestore
== 0) {
996 raise_exception(TT_FILL
| (env
->otherwin
!= 0 ?
997 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
998 ((env
->wstate
& 0x7) << 2)));
1008 void OPPROTO
op_exception(void)
1010 env
->exception_index
= PARAM1
;
1014 void OPPROTO
op_trap_T0(void)
1016 env
->exception_index
= TT_TRAP
+ (T0
& 0x7f);
1020 void OPPROTO
op_trapcc_T0(void)
1023 env
->exception_index
= TT_TRAP
+ (T0
& 0x7f);
1029 void OPPROTO
op_fpexception_im(void)
1031 env
->exception_index
= TT_FP_EXCP
;
1032 env
->fsr
&= ~FSR_FTT_MASK
;
1038 void OPPROTO
op_debug(void)
1043 void OPPROTO
op_exit_tb(void)
1048 void OPPROTO
op_eval_ba(void)
1053 void OPPROTO
op_eval_be(void)
1055 T2
= FLAG_SET(PSR_ZERO
);
1058 void OPPROTO
op_eval_ble(void)
1060 target_ulong Z
= FLAG_SET(PSR_ZERO
), N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1065 void OPPROTO
op_eval_bl(void)
1067 target_ulong N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1072 void OPPROTO
op_eval_bleu(void)
1074 target_ulong Z
= FLAG_SET(PSR_ZERO
), C
= FLAG_SET(PSR_CARRY
);
1079 void OPPROTO
op_eval_bcs(void)
1081 T2
= FLAG_SET(PSR_CARRY
);
1084 void OPPROTO
op_eval_bvs(void)
1086 T2
= FLAG_SET(PSR_OVF
);
1089 void OPPROTO
op_eval_bn(void)
1094 void OPPROTO
op_eval_bneg(void)
1096 T2
= FLAG_SET(PSR_NEG
);
1099 void OPPROTO
op_eval_bne(void)
1101 T2
= !FLAG_SET(PSR_ZERO
);
1104 void OPPROTO
op_eval_bg(void)
1106 target_ulong Z
= FLAG_SET(PSR_ZERO
), N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1108 T2
= !(Z
| (N
^ V
));
1111 void OPPROTO
op_eval_bge(void)
1113 target_ulong N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1118 void OPPROTO
op_eval_bgu(void)
1120 target_ulong Z
= FLAG_SET(PSR_ZERO
), C
= FLAG_SET(PSR_CARRY
);
1125 void OPPROTO
op_eval_bcc(void)
1127 T2
= !FLAG_SET(PSR_CARRY
);
1130 void OPPROTO
op_eval_bpos(void)
1132 T2
= !FLAG_SET(PSR_NEG
);
1135 void OPPROTO
op_eval_bvc(void)
1137 T2
= !FLAG_SET(PSR_OVF
);
1140 #ifdef TARGET_SPARC64
1141 void OPPROTO
op_eval_xbe(void)
1143 T2
= XFLAG_SET(PSR_ZERO
);
1146 void OPPROTO
op_eval_xble(void)
1148 target_ulong Z
= XFLAG_SET(PSR_ZERO
), N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1153 void OPPROTO
op_eval_xbl(void)
1155 target_ulong N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1160 void OPPROTO
op_eval_xbleu(void)
1162 target_ulong Z
= XFLAG_SET(PSR_ZERO
), C
= XFLAG_SET(PSR_CARRY
);
1167 void OPPROTO
op_eval_xbcs(void)
1169 T2
= XFLAG_SET(PSR_CARRY
);
1172 void OPPROTO
op_eval_xbvs(void)
1174 T2
= XFLAG_SET(PSR_OVF
);
1177 void OPPROTO
op_eval_xbneg(void)
1179 T2
= XFLAG_SET(PSR_NEG
);
1182 void OPPROTO
op_eval_xbne(void)
1184 T2
= !XFLAG_SET(PSR_ZERO
);
1187 void OPPROTO
op_eval_xbg(void)
1189 target_ulong Z
= XFLAG_SET(PSR_ZERO
), N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1191 T2
= !(Z
| (N
^ V
));
1194 void OPPROTO
op_eval_xbge(void)
1196 target_ulong N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1201 void OPPROTO
op_eval_xbgu(void)
1203 target_ulong Z
= XFLAG_SET(PSR_ZERO
), C
= XFLAG_SET(PSR_CARRY
);
1208 void OPPROTO
op_eval_xbcc(void)
1210 T2
= !XFLAG_SET(PSR_CARRY
);
1213 void OPPROTO
op_eval_xbpos(void)
1215 T2
= !XFLAG_SET(PSR_NEG
);
1218 void OPPROTO
op_eval_xbvc(void)
1220 T2
= !XFLAG_SET(PSR_OVF
);
1225 #define FFLAG_SET(x) (env->fsr & x? 1: 0)
1226 #include "fbranch_template.h"
1228 #ifdef TARGET_SPARC64
1230 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 32))? 1: 0)
1231 #include "fbranch_template.h"
1233 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 34))? 1: 0)
1234 #include "fbranch_template.h"
1236 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 36))? 1: 0)
1237 #include "fbranch_template.h"
1240 #ifdef TARGET_SPARC64
1241 void OPPROTO
op_eval_brz(void)
1246 void OPPROTO
op_eval_brnz(void)
1251 void OPPROTO
op_eval_brlz(void)
1253 T2
= ((int64_t)T0
< 0);
1256 void OPPROTO
op_eval_brlez(void)
1258 T2
= ((int64_t)T0
<= 0);
1261 void OPPROTO
op_eval_brgz(void)
1263 T2
= ((int64_t)T0
> 0);
1266 void OPPROTO
op_eval_brgez(void)
1268 T2
= ((int64_t)T0
>= 0);
1271 void OPPROTO
op_jmp_im64(void)
1276 void OPPROTO
op_movq_npc_im64(void)
1282 void OPPROTO
op_jmp_im(void)
1284 env
->pc
= (uint32_t)PARAM1
;
1287 void OPPROTO
op_movl_npc_im(void)
1289 env
->npc
= (uint32_t)PARAM1
;
1292 void OPPROTO
op_movl_npc_T0(void)
1297 void OPPROTO
op_mov_pc_npc(void)
1302 void OPPROTO
op_next_insn(void)
1305 env
->npc
= env
->npc
+ 4;
1308 void OPPROTO
op_goto_tb0(void)
1310 GOTO_TB(op_goto_tb0
, PARAM1
, 0);
1313 void OPPROTO
op_goto_tb1(void)
1315 GOTO_TB(op_goto_tb1
, PARAM1
, 1);
1318 void OPPROTO
op_jmp_label(void)
1320 GOTO_LABEL_PARAM(1);
1323 void OPPROTO
op_jnz_T2_label(void)
1326 GOTO_LABEL_PARAM(1);
1330 void OPPROTO
op_jz_T2_label(void)
1333 GOTO_LABEL_PARAM(1);
1337 void OPPROTO
op_flush_T0(void)
1342 #define F_OP(name, p) void OPPROTO op_f##name##p(void)
1344 #define F_BINOP(name) \
1347 FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
1351 DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
1360 void OPPROTO
op_fsmuld(void)
1362 DT0
= float64_mul(float32_to_float64(FT0
, &env
->fp_status
),
1363 float32_to_float64(FT1
, &env
->fp_status
),
1367 #define F_HELPER(name) \
1381 FT0
= float32_chs(FT1
);
1391 #ifdef TARGET_SPARC64
1394 DT0
= float64_chs(DT1
);
1402 void OPPROTO
op_fcmps_fcc1(void)
1407 void OPPROTO
op_fcmpd_fcc1(void)
1412 void OPPROTO
op_fcmps_fcc2(void)
1417 void OPPROTO
op_fcmpd_fcc2(void)
1422 void OPPROTO
op_fcmps_fcc3(void)
1427 void OPPROTO
op_fcmpd_fcc3(void)
1433 /* Integer to float conversion. */
1434 #ifdef USE_INT_TO_FLOAT_HELPERS
1439 FT0
= int32_to_float32(*((int32_t *)&FT1
), &env
->fp_status
);
1444 DT0
= int32_to_float64(*((int32_t *)&FT1
), &env
->fp_status
);
1447 #ifdef TARGET_SPARC64
1450 FT0
= int64_to_float32(*((int64_t *)&DT1
), &env
->fp_status
);
1455 DT0
= int64_to_float64(*((int64_t *)&DT1
), &env
->fp_status
);
1461 /* floating point conversion */
1462 void OPPROTO
op_fdtos(void)
1464 FT0
= float64_to_float32(DT1
, &env
->fp_status
);
1467 void OPPROTO
op_fstod(void)
1469 DT0
= float32_to_float64(FT1
, &env
->fp_status
);
1472 /* Float to integer conversion. */
1473 void OPPROTO
op_fstoi(void)
1475 *((int32_t *)&FT0
) = float32_to_int32(FT1
, &env
->fp_status
);
1478 void OPPROTO
op_fdtoi(void)
1480 *((int32_t *)&FT0
) = float64_to_int32(DT1
, &env
->fp_status
);
1483 #ifdef TARGET_SPARC64
1484 void OPPROTO
op_fstox(void)
1486 *((int64_t *)&DT0
) = float32_to_int64(FT1
, &env
->fp_status
);
1489 void OPPROTO
op_fdtox(void)
1491 *((int64_t *)&DT0
) = float64_to_int64(DT1
, &env
->fp_status
);
1494 void OPPROTO
op_fmovs_cc(void)
1500 void OPPROTO
op_fmovd_cc(void)
1506 void OPPROTO
op_mov_cc(void)
1512 void OPPROTO
op_flushw(void)
1514 if (env
->cansave
!= NWINDOWS
- 2) {
1515 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
1516 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
1517 ((env
->wstate
& 0x7) << 2)));
1521 void OPPROTO
op_saved(void)
1524 if (env
->otherwin
== 0)
1531 void OPPROTO
op_restored(void)
1534 if (env
->cleanwin
< NWINDOWS
- 1)
1536 if (env
->otherwin
== 0)
1543 void OPPROTO
op_popc(void)
1548 void OPPROTO
op_done(void)
1553 void OPPROTO
op_retry(void)
1558 void OPPROTO
op_sir(void)
1564 void OPPROTO
op_ld_asi_reg()
1567 helper_ld_asi(env
->asi
, PARAM2
, PARAM3
);
1570 void OPPROTO
op_st_asi_reg()
1573 helper_st_asi(env
->asi
, PARAM2
, PARAM3
);
1577 void OPPROTO
op_ld_asi()
1579 helper_ld_asi(PARAM1
, PARAM2
, PARAM3
);
1582 void OPPROTO
op_st_asi()
1584 helper_st_asi(PARAM1
, PARAM2
, PARAM3
);
1587 #ifdef TARGET_SPARC64
1588 void OPPROTO
op_alignaddr()
1594 env
->gsr
|= tmp
& 7ULL;
1598 void OPPROTO
op_faligndata()
1602 tmp
= (*((uint64_t *)&DT0
)) << ((env
->gsr
& 7) * 8);
1603 tmp
|= (*((uint64_t *)&DT1
)) >> (64 - (env
->gsr
& 7) * 8);
1604 (*((uint64_t *)&DT0
)) = tmp
;