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
);
532 #ifdef TARGET_SPARC64
533 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff) ^ -1) &
534 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
535 raise_exception(TT_TOVF
);
537 if ((src1
& 0x03) || (T1
& 0x03))
538 raise_exception(TT_TOVF
);
542 #ifdef TARGET_SPARC64
543 if (!(T0
& 0xffffffff))
544 env
->psr
|= PSR_ZERO
;
545 if ((int32_t) T0
< 0)
547 if ((T0
& 0xffffffff) < (src1
& 0xffffffff))
548 env
->psr
|= PSR_CARRY
;
552 env
->xcc
|= PSR_ZERO
;
553 if ((int64_t) T0
< 0)
556 env
->xcc
|= PSR_CARRY
;
559 env
->psr
|= PSR_ZERO
;
560 if ((int32_t) T0
< 0)
563 env
->psr
|= PSR_CARRY
;
568 void OPPROTO
op_sub_T1_T0(void)
573 void OPPROTO
op_sub_T1_T0_cc(void)
580 #ifdef TARGET_SPARC64
581 if (!(T0
& 0xffffffff))
582 env
->psr
|= PSR_ZERO
;
583 if ((int32_t) T0
< 0)
585 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
586 env
->psr
|= PSR_CARRY
;
587 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
588 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
593 env
->xcc
|= PSR_ZERO
;
594 if ((int64_t) T0
< 0)
597 env
->xcc
|= PSR_CARRY
;
598 if (((src1
^ T1
) & (src1
^ T0
)) & (1ULL << 63))
602 env
->psr
|= PSR_ZERO
;
603 if ((int32_t) T0
< 0)
606 env
->psr
|= PSR_CARRY
;
607 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
613 void OPPROTO
op_subx_T1_T0(void)
615 T0
-= T1
+ FLAG_SET(PSR_CARRY
);
618 void OPPROTO
op_subx_T1_T0_cc(void)
622 if (FLAG_SET(PSR_CARRY
))
626 #ifdef TARGET_SPARC64
627 if ((src1
& 0xffffffff) <= (T1
& 0xffffffff))
628 env
->psr
|= PSR_CARRY
;
631 env
->xcc
|= PSR_CARRY
;
634 env
->psr
|= PSR_CARRY
;
641 #ifdef TARGET_SPARC64
642 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
643 env
->psr
|= PSR_CARRY
;
646 env
->xcc
|= PSR_CARRY
;
649 env
->psr
|= PSR_CARRY
;
652 #ifdef TARGET_SPARC64
653 if (!(T0
& 0xffffffff))
654 env
->psr
|= PSR_ZERO
;
655 if ((int32_t) T0
< 0)
657 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
658 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
662 env
->xcc
|= PSR_ZERO
;
663 if ((int64_t) T0
< 0)
665 if (((src1
^ T1
) & (src1
^ T0
)) & (1ULL << 63))
669 env
->psr
|= PSR_ZERO
;
670 if ((int32_t) T0
< 0)
672 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
678 void OPPROTO
op_tsub_T1_T0_cc(void)
685 #ifdef TARGET_SPARC64
686 if (!(T0
& 0xffffffff))
687 env
->psr
|= PSR_ZERO
;
688 if ((int32_t) T0
< 0)
690 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
691 env
->psr
|= PSR_CARRY
;
692 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
693 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
695 if ((src1
& 0x03) || (T1
& 0x03))
700 env
->xcc
|= PSR_ZERO
;
701 if ((int64_t) T0
< 0)
704 env
->xcc
|= PSR_CARRY
;
705 if (((src1
^ T1
) & (src1
^ T0
)) & (1ULL << 63))
709 env
->psr
|= PSR_ZERO
;
710 if ((int32_t) T0
< 0)
713 env
->psr
|= PSR_CARRY
;
714 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
716 if ((src1
& 0x03) || (T1
& 0x03))
722 void OPPROTO
op_tsub_T1_T0_ccTV(void)
726 if ((T0
& 0x03) || (T1
& 0x03))
727 raise_exception(TT_TOVF
);
732 #ifdef TARGET_SPARC64
733 if ((((src1
& 0xffffffff) ^ (T1
& 0xffffffff)) &
734 ((src1
& 0xffffffff) ^ (T0
& 0xffffffff))) & (1 << 31))
735 raise_exception(TT_TOVF
);
737 if (((src1
^ T1
) & (src1
^ T0
)) & (1 << 31))
738 raise_exception(TT_TOVF
);
742 #ifdef TARGET_SPARC64
743 if (!(T0
& 0xffffffff))
744 env
->psr
|= PSR_ZERO
;
745 if ((int32_t) T0
< 0)
747 if ((src1
& 0xffffffff) < (T1
& 0xffffffff))
748 env
->psr
|= PSR_CARRY
;
752 env
->xcc
|= PSR_ZERO
;
753 if ((int64_t) T0
< 0)
756 env
->xcc
|= PSR_CARRY
;
759 env
->psr
|= PSR_ZERO
;
760 if ((int32_t) T0
< 0)
763 env
->psr
|= PSR_CARRY
;
768 void OPPROTO
op_and_T1_T0(void)
773 void OPPROTO
op_or_T1_T0(void)
778 void OPPROTO
op_xor_T1_T0(void)
783 void OPPROTO
op_andn_T1_T0(void)
788 void OPPROTO
op_orn_T1_T0(void)
793 void OPPROTO
op_xnor_T1_T0(void)
798 void OPPROTO
op_umul_T1_T0(void)
801 res
= (uint64_t) T0
* (uint64_t) T1
;
802 #ifdef TARGET_SPARC64
805 T0
= res
& 0xffffffff;
810 void OPPROTO
op_smul_T1_T0(void)
813 res
= (int64_t) ((int32_t) T0
) * (int64_t) ((int32_t) T1
);
814 #ifdef TARGET_SPARC64
817 T0
= res
& 0xffffffff;
822 void OPPROTO
op_mulscc_T1_T0(void)
824 unsigned int b1
, N
, V
, b2
;
827 N
= FLAG_SET(PSR_NEG
);
828 V
= FLAG_SET(PSR_OVF
);
831 T0
= (b1
<< 31) | (T0
>> 1);
834 /* do addition and update flags */
839 env
->psr
|= PSR_ZERO
;
840 if ((int32_t) T0
< 0)
843 env
->psr
|= PSR_CARRY
;
844 if (((src1
^ T1
^ -1) & (src1
^ T0
)) & (1 << 31))
846 env
->y
= (b2
<< 31) | (env
->y
>> 1);
850 void OPPROTO
op_udiv_T1_T0(void)
855 x0
= T0
| ((uint64_t) (env
->y
) << 32);
859 raise_exception(TT_DIV_ZERO
);
863 if (x0
> 0xffffffff) {
873 void OPPROTO
op_sdiv_T1_T0(void)
878 x0
= T0
| ((int64_t) (env
->y
) << 32);
882 raise_exception(TT_DIV_ZERO
);
886 if ((int32_t) x0
!= x0
) {
887 T0
= x0
< 0? 0x80000000: 0x7fffffff;
896 void OPPROTO
op_div_cc(void)
899 #ifdef TARGET_SPARC64
901 env
->psr
|= PSR_ZERO
;
902 if ((int32_t) T0
< 0)
909 env
->xcc
|= PSR_ZERO
;
910 if ((int64_t) T0
< 0)
914 env
->psr
|= PSR_ZERO
;
915 if ((int32_t) T0
< 0)
923 #ifdef TARGET_SPARC64
924 void OPPROTO
op_mulx_T1_T0(void)
930 void OPPROTO
op_udivx_T1_T0(void)
933 raise_exception(TT_DIV_ZERO
);
939 void OPPROTO
op_sdivx_T1_T0(void)
942 raise_exception(TT_DIV_ZERO
);
944 if (T0
== INT64_MIN
&& T1
== -1)
947 T0
/= (target_long
) T1
;
952 void OPPROTO
op_logic_T0_cc(void)
955 #ifdef TARGET_SPARC64
956 if (!(T0
& 0xffffffff))
957 env
->psr
|= PSR_ZERO
;
958 if ((int32_t) T0
< 0)
963 env
->xcc
|= PSR_ZERO
;
964 if ((int64_t) T0
< 0)
968 env
->psr
|= PSR_ZERO
;
969 if ((int32_t) T0
< 0)
975 void OPPROTO
op_sll(void)
980 #ifdef TARGET_SPARC64
981 void OPPROTO
op_sllx(void)
986 void OPPROTO
op_srl(void)
988 T0
= (T0
& 0xffffffff) >> (T1
& 0x1f);
991 void OPPROTO
op_srlx(void)
996 void OPPROTO
op_sra(void)
998 T0
= ((int32_t) (T0
& 0xffffffff)) >> (T1
& 0x1f);
1001 void OPPROTO
op_srax(void)
1003 T0
= ((int64_t) T0
) >> (T1
& 0x3f);
1006 void OPPROTO
op_srl(void)
1011 void OPPROTO
op_sra(void)
1013 T0
= ((int32_t) T0
) >> (T1
& 0x1f);
1017 /* Load and store */
1018 #define MEMSUFFIX _raw
1020 #if !defined(CONFIG_USER_ONLY)
1021 #define MEMSUFFIX _user
1024 #define MEMSUFFIX _kernel
1028 void OPPROTO
op_ldfsr(void)
1030 PUT_FSR32(env
, *((uint32_t *) &FT0
));
1034 void OPPROTO
op_stfsr(void)
1036 *((uint32_t *) &FT0
) = GET_FSR32(env
);
1039 #ifndef TARGET_SPARC64
1040 void OPPROTO
op_rdpsr(void)
1045 void OPPROTO
op_wrpsr(void)
1051 void OPPROTO
op_wrwim(void)
1056 env
->wim
= T0
& ((1 << NWINDOWS
) - 1);
1060 void OPPROTO
op_rett(void)
1066 /* XXX: use another pointer for %iN registers to avoid slow wrapping
1068 void OPPROTO
op_save(void)
1071 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
1072 if (env
->wim
& (1 << cwp
)) {
1073 raise_exception(TT_WIN_OVF
);
1079 void OPPROTO
op_restore(void)
1082 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
1083 if (env
->wim
& (1 << cwp
)) {
1084 raise_exception(TT_WIN_UNF
);
1090 void OPPROTO
op_rdccr(void)
1095 void OPPROTO
op_wrccr(void)
1100 void OPPROTO
op_rdtick(void)
1102 T0
= do_tick_get_count(env
->tick
);
1105 void OPPROTO
op_wrtick(void)
1107 do_tick_set_count(env
->tick
, T0
);
1110 void OPPROTO
op_wrtick_cmpr(void)
1112 do_tick_set_limit(env
->tick
, T0
);
1115 void OPPROTO
op_rdstick(void)
1117 T0
= do_tick_get_count(env
->stick
);
1120 void OPPROTO
op_wrstick(void)
1122 do_tick_set_count(env
->stick
, T0
);
1123 do_tick_set_count(env
->hstick
, T0
);
1126 void OPPROTO
op_wrstick_cmpr(void)
1128 do_tick_set_limit(env
->stick
, T0
);
1131 void OPPROTO
op_wrhstick_cmpr(void)
1133 do_tick_set_limit(env
->hstick
, T0
);
1136 void OPPROTO
op_rdtpc(void)
1138 T0
= env
->tpc
[env
->tl
];
1141 void OPPROTO
op_wrtpc(void)
1143 env
->tpc
[env
->tl
] = T0
;
1146 void OPPROTO
op_rdtnpc(void)
1148 T0
= env
->tnpc
[env
->tl
];
1151 void OPPROTO
op_wrtnpc(void)
1153 env
->tnpc
[env
->tl
] = T0
;
1156 void OPPROTO
op_rdtstate(void)
1158 T0
= env
->tstate
[env
->tl
];
1161 void OPPROTO
op_wrtstate(void)
1163 env
->tstate
[env
->tl
] = T0
;
1166 void OPPROTO
op_rdtt(void)
1168 T0
= env
->tt
[env
->tl
];
1171 void OPPROTO
op_wrtt(void)
1173 env
->tt
[env
->tl
] = T0
;
1176 void OPPROTO
op_rdpstate(void)
1181 void OPPROTO
op_wrpstate(void)
1186 // CWP handling is reversed in V9, but we still use the V8 register
1188 void OPPROTO
op_rdcwp(void)
1190 T0
= GET_CWP64(env
);
1193 void OPPROTO
op_wrcwp(void)
1198 /* XXX: use another pointer for %iN registers to avoid slow wrapping
1200 void OPPROTO
op_save(void)
1203 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
1204 if (env
->cansave
== 0) {
1205 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
1206 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
1207 ((env
->wstate
& 0x7) << 2)));
1209 if (env
->cleanwin
- env
->canrestore
== 0) {
1210 // XXX Clean windows without trap
1211 raise_exception(TT_CLRWIN
);
1221 void OPPROTO
op_restore(void)
1224 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
1225 if (env
->canrestore
== 0) {
1226 raise_exception(TT_FILL
| (env
->otherwin
!= 0 ?
1227 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
1228 ((env
->wstate
& 0x7) << 2)));
1238 void OPPROTO
op_exception(void)
1240 env
->exception_index
= PARAM1
;
1244 void OPPROTO
op_trap_T0(void)
1246 env
->exception_index
= TT_TRAP
+ (T0
& 0x7f);
1250 void OPPROTO
op_trapcc_T0(void)
1253 env
->exception_index
= TT_TRAP
+ (T0
& 0x7f);
1259 void OPPROTO
op_fpexception_im(void)
1261 env
->exception_index
= TT_FP_EXCP
;
1262 env
->fsr
&= ~FSR_FTT_MASK
;
1268 void OPPROTO
op_debug(void)
1273 void OPPROTO
op_exit_tb(void)
1278 void OPPROTO
op_eval_ba(void)
1283 void OPPROTO
op_eval_be(void)
1285 T2
= FLAG_SET(PSR_ZERO
);
1288 void OPPROTO
op_eval_ble(void)
1290 target_ulong Z
= FLAG_SET(PSR_ZERO
), N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1295 void OPPROTO
op_eval_bl(void)
1297 target_ulong N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1302 void OPPROTO
op_eval_bleu(void)
1304 target_ulong Z
= FLAG_SET(PSR_ZERO
), C
= FLAG_SET(PSR_CARRY
);
1309 void OPPROTO
op_eval_bcs(void)
1311 T2
= FLAG_SET(PSR_CARRY
);
1314 void OPPROTO
op_eval_bvs(void)
1316 T2
= FLAG_SET(PSR_OVF
);
1319 void OPPROTO
op_eval_bn(void)
1324 void OPPROTO
op_eval_bneg(void)
1326 T2
= FLAG_SET(PSR_NEG
);
1329 void OPPROTO
op_eval_bne(void)
1331 T2
= !FLAG_SET(PSR_ZERO
);
1334 void OPPROTO
op_eval_bg(void)
1336 target_ulong Z
= FLAG_SET(PSR_ZERO
), N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1338 T2
= !(Z
| (N
^ V
));
1341 void OPPROTO
op_eval_bge(void)
1343 target_ulong N
= FLAG_SET(PSR_NEG
), V
= FLAG_SET(PSR_OVF
);
1348 void OPPROTO
op_eval_bgu(void)
1350 target_ulong Z
= FLAG_SET(PSR_ZERO
), C
= FLAG_SET(PSR_CARRY
);
1355 void OPPROTO
op_eval_bcc(void)
1357 T2
= !FLAG_SET(PSR_CARRY
);
1360 void OPPROTO
op_eval_bpos(void)
1362 T2
= !FLAG_SET(PSR_NEG
);
1365 void OPPROTO
op_eval_bvc(void)
1367 T2
= !FLAG_SET(PSR_OVF
);
1370 #ifdef TARGET_SPARC64
1371 void OPPROTO
op_eval_xbe(void)
1373 T2
= XFLAG_SET(PSR_ZERO
);
1376 void OPPROTO
op_eval_xble(void)
1378 target_ulong Z
= XFLAG_SET(PSR_ZERO
), N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1383 void OPPROTO
op_eval_xbl(void)
1385 target_ulong N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1390 void OPPROTO
op_eval_xbleu(void)
1392 target_ulong Z
= XFLAG_SET(PSR_ZERO
), C
= XFLAG_SET(PSR_CARRY
);
1397 void OPPROTO
op_eval_xbcs(void)
1399 T2
= XFLAG_SET(PSR_CARRY
);
1402 void OPPROTO
op_eval_xbvs(void)
1404 T2
= XFLAG_SET(PSR_OVF
);
1407 void OPPROTO
op_eval_xbneg(void)
1409 T2
= XFLAG_SET(PSR_NEG
);
1412 void OPPROTO
op_eval_xbne(void)
1414 T2
= !XFLAG_SET(PSR_ZERO
);
1417 void OPPROTO
op_eval_xbg(void)
1419 target_ulong Z
= XFLAG_SET(PSR_ZERO
), N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1421 T2
= !(Z
| (N
^ V
));
1424 void OPPROTO
op_eval_xbge(void)
1426 target_ulong N
= XFLAG_SET(PSR_NEG
), V
= XFLAG_SET(PSR_OVF
);
1431 void OPPROTO
op_eval_xbgu(void)
1433 target_ulong Z
= XFLAG_SET(PSR_ZERO
), C
= XFLAG_SET(PSR_CARRY
);
1438 void OPPROTO
op_eval_xbcc(void)
1440 T2
= !XFLAG_SET(PSR_CARRY
);
1443 void OPPROTO
op_eval_xbpos(void)
1445 T2
= !XFLAG_SET(PSR_NEG
);
1448 void OPPROTO
op_eval_xbvc(void)
1450 T2
= !XFLAG_SET(PSR_OVF
);
1455 #define FFLAG_SET(x) (env->fsr & x? 1: 0)
1456 #include "fbranch_template.h"
1458 #ifdef TARGET_SPARC64
1460 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 32))? 1: 0)
1461 #include "fbranch_template.h"
1463 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 34))? 1: 0)
1464 #include "fbranch_template.h"
1466 #define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 36))? 1: 0)
1467 #include "fbranch_template.h"
1470 #ifdef TARGET_SPARC64
1471 void OPPROTO
op_eval_brz(void)
1476 void OPPROTO
op_eval_brnz(void)
1481 void OPPROTO
op_eval_brlz(void)
1483 T2
= ((int64_t)T0
< 0);
1486 void OPPROTO
op_eval_brlez(void)
1488 T2
= ((int64_t)T0
<= 0);
1491 void OPPROTO
op_eval_brgz(void)
1493 T2
= ((int64_t)T0
> 0);
1496 void OPPROTO
op_eval_brgez(void)
1498 T2
= ((int64_t)T0
>= 0);
1501 void OPPROTO
op_jmp_im64(void)
1506 void OPPROTO
op_movq_npc_im64(void)
1512 void OPPROTO
op_jmp_im(void)
1514 env
->pc
= (uint32_t)PARAM1
;
1517 void OPPROTO
op_movl_npc_im(void)
1519 env
->npc
= (uint32_t)PARAM1
;
1522 void OPPROTO
op_movl_npc_T0(void)
1527 void OPPROTO
op_mov_pc_npc(void)
1532 void OPPROTO
op_next_insn(void)
1535 env
->npc
= env
->npc
+ 4;
1538 void OPPROTO
op_goto_tb0(void)
1540 GOTO_TB(op_goto_tb0
, PARAM1
, 0);
1543 void OPPROTO
op_goto_tb1(void)
1545 GOTO_TB(op_goto_tb1
, PARAM1
, 1);
1548 void OPPROTO
op_jmp_label(void)
1550 GOTO_LABEL_PARAM(1);
1553 void OPPROTO
op_jnz_T2_label(void)
1556 GOTO_LABEL_PARAM(1);
1560 void OPPROTO
op_jz_T2_label(void)
1563 GOTO_LABEL_PARAM(1);
1567 void OPPROTO
op_flush_T0(void)
1572 void OPPROTO
op_clear_ieee_excp_and_FTT(void)
1574 env
->fsr
&= ~(FSR_FTT_MASK
| FSR_CEXC_MASK
);;
1577 #define F_OP(name, p) void OPPROTO op_f##name##p(void)
1579 #define F_BINOP(name) \
1582 set_float_exception_flags(0, &env->fp_status); \
1583 FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
1584 check_ieee_exceptions(); \
1588 set_float_exception_flags(0, &env->fp_status); \
1589 DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
1590 check_ieee_exceptions(); \
1599 void OPPROTO
op_fsmuld(void)
1601 set_float_exception_flags(0, &env
->fp_status
);
1602 DT0
= float64_mul(float32_to_float64(FT0
, &env
->fp_status
),
1603 float32_to_float64(FT1
, &env
->fp_status
),
1605 check_ieee_exceptions();
1608 #define F_HELPER(name) \
1622 FT0
= float32_chs(FT1
);
1633 #ifdef TARGET_SPARC64
1636 DT0
= float64_chs(DT1
);
1644 void OPPROTO
op_fcmps_fcc1(void)
1649 void OPPROTO
op_fcmpd_fcc1(void)
1654 void OPPROTO
op_fcmps_fcc2(void)
1659 void OPPROTO
op_fcmpd_fcc2(void)
1664 void OPPROTO
op_fcmps_fcc3(void)
1669 void OPPROTO
op_fcmpd_fcc3(void)
1674 void OPPROTO
op_fcmpes_fcc1(void)
1679 void OPPROTO
op_fcmped_fcc1(void)
1684 void OPPROTO
op_fcmpes_fcc2(void)
1689 void OPPROTO
op_fcmped_fcc2(void)
1694 void OPPROTO
op_fcmpes_fcc3(void)
1699 void OPPROTO
op_fcmped_fcc3(void)
1706 /* Integer to float conversion. */
1707 #ifdef USE_INT_TO_FLOAT_HELPERS
1712 set_float_exception_flags(0, &env
->fp_status
);
1713 FT0
= int32_to_float32(*((int32_t *)&FT1
), &env
->fp_status
);
1714 check_ieee_exceptions();
1719 set_float_exception_flags(0, &env
->fp_status
);
1720 DT0
= int32_to_float64(*((int32_t *)&FT1
), &env
->fp_status
);
1721 check_ieee_exceptions();
1724 #ifdef TARGET_SPARC64
1727 set_float_exception_flags(0, &env
->fp_status
);
1728 FT0
= int64_to_float32(*((int64_t *)&DT1
), &env
->fp_status
);
1729 check_ieee_exceptions();
1734 set_float_exception_flags(0, &env
->fp_status
);
1735 DT0
= int64_to_float64(*((int64_t *)&DT1
), &env
->fp_status
);
1736 check_ieee_exceptions();
1742 /* floating point conversion */
1743 void OPPROTO
op_fdtos(void)
1745 set_float_exception_flags(0, &env
->fp_status
);
1746 FT0
= float64_to_float32(DT1
, &env
->fp_status
);
1747 check_ieee_exceptions();
1750 void OPPROTO
op_fstod(void)
1752 set_float_exception_flags(0, &env
->fp_status
);
1753 DT0
= float32_to_float64(FT1
, &env
->fp_status
);
1754 check_ieee_exceptions();
1757 /* Float to integer conversion. */
1758 void OPPROTO
op_fstoi(void)
1760 set_float_exception_flags(0, &env
->fp_status
);
1761 *((int32_t *)&FT0
) = float32_to_int32_round_to_zero(FT1
, &env
->fp_status
);
1762 check_ieee_exceptions();
1765 void OPPROTO
op_fdtoi(void)
1767 set_float_exception_flags(0, &env
->fp_status
);
1768 *((int32_t *)&FT0
) = float64_to_int32_round_to_zero(DT1
, &env
->fp_status
);
1769 check_ieee_exceptions();
1772 #ifdef TARGET_SPARC64
1773 void OPPROTO
op_fstox(void)
1775 set_float_exception_flags(0, &env
->fp_status
);
1776 *((int64_t *)&DT0
) = float32_to_int64_round_to_zero(FT1
, &env
->fp_status
);
1777 check_ieee_exceptions();
1780 void OPPROTO
op_fdtox(void)
1782 set_float_exception_flags(0, &env
->fp_status
);
1783 *((int64_t *)&DT0
) = float64_to_int64_round_to_zero(DT1
, &env
->fp_status
);
1784 check_ieee_exceptions();
1787 void OPPROTO
op_fmovs_cc(void)
1793 void OPPROTO
op_fmovd_cc(void)
1799 void OPPROTO
op_mov_cc(void)
1805 void OPPROTO
op_flushw(void)
1807 if (env
->cansave
!= NWINDOWS
- 2) {
1808 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
1809 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
1810 ((env
->wstate
& 0x7) << 2)));
1814 void OPPROTO
op_saved(void)
1817 if (env
->otherwin
== 0)
1824 void OPPROTO
op_restored(void)
1827 if (env
->cleanwin
< NWINDOWS
- 1)
1829 if (env
->otherwin
== 0)
1836 void OPPROTO
op_popc(void)
1841 void OPPROTO
op_done(void)
1846 void OPPROTO
op_retry(void)
1851 void OPPROTO
op_sir(void)
1856 void OPPROTO
op_ld_asi_reg()
1859 helper_ld_asi(env
->asi
, PARAM2
, PARAM3
);
1862 void OPPROTO
op_st_asi_reg()
1865 helper_st_asi(env
->asi
, PARAM2
);
1868 void OPPROTO
op_ldstub_asi_reg() /* XXX: should be atomically */
1873 helper_ld_asi(env
->asi
, 1, 0);
1876 helper_st_asi(env
->asi
, 1);
1880 void OPPROTO
op_swap_asi_reg() /* XXX: should be atomically */
1882 target_ulong tmp1
, tmp2
;
1886 helper_ld_asi(env
->asi
, 4, 0);
1889 helper_st_asi(env
->asi
, 4);
1893 void OPPROTO
op_ldda_asi()
1895 helper_ld_asi(PARAM1
, 8, 0);
1896 T0
= T1
& 0xffffffffUL
;
1900 void OPPROTO
op_ldda_asi_reg()
1903 helper_ld_asi(env
->asi
, 8, 0);
1904 T0
= T1
& 0xffffffffUL
;
1908 void OPPROTO
op_stda_asi()
1911 T1
+= T2
& 0xffffffffUL
;
1912 helper_st_asi(PARAM1
, 8);
1915 void OPPROTO
op_stda_asi_reg()
1919 T1
+= T2
& 0xffffffffUL
;
1920 helper_st_asi(env
->asi
, 8);
1923 void OPPROTO
op_cas_asi() /* XXX: should be atomically */
1927 tmp
= T1
& 0xffffffffUL
;
1928 helper_ld_asi(PARAM1
, 4, 0);
1931 T1
= T2
& 0xffffffffUL
;
1932 helper_st_asi(PARAM1
, 4);
1938 void OPPROTO
op_cas_asi_reg() /* XXX: should be atomically */
1943 tmp
= T1
& 0xffffffffUL
;
1944 helper_ld_asi(env
->asi
, 4, 0);
1947 T1
= T2
& 0xffffffffUL
;
1948 helper_st_asi(env
->asi
, 4);
1954 void OPPROTO
op_casx_asi() /* XXX: should be atomically */
1959 helper_ld_asi(PARAM1
, 8, 0);
1963 helper_st_asi(PARAM1
, 8);
1968 void OPPROTO
op_casx_asi_reg() /* XXX: should be atomically */
1974 helper_ld_asi(env
->asi
, 8, 0);
1978 helper_st_asi(env
->asi
, 8);
1984 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
1985 void OPPROTO
op_ld_asi()
1987 helper_ld_asi(PARAM1
, PARAM2
, PARAM3
);
1990 void OPPROTO
op_st_asi()
1992 helper_st_asi(PARAM1
, PARAM2
);
1995 void OPPROTO
op_ldstub_asi() /* XXX: should be atomically */
1999 helper_ld_asi(PARAM1
, 1, 0);
2002 helper_st_asi(PARAM1
, 1);
2006 void OPPROTO
op_swap_asi() /* XXX: should be atomically */
2008 target_ulong tmp1
, tmp2
;
2011 helper_ld_asi(PARAM1
, 4, 0);
2014 helper_st_asi(PARAM1
, 4);
2019 #ifdef TARGET_SPARC64
2020 // This function uses non-native bit order
2021 #define GET_FIELD(X, FROM, TO) \
2022 ((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1))
2024 // This function uses the order in the manuals, i.e. bit 0 is 2^0
2025 #define GET_FIELD_SP(X, FROM, TO) \
2026 GET_FIELD(X, 63 - (TO), 63 - (FROM))
2028 void OPPROTO
op_array8()
2030 T0
= (GET_FIELD_SP(T0
, 60, 63) << (17 + 2 * T1
)) |
2031 (GET_FIELD_SP(T0
, 39, 39 + T1
- 1) << (17 + T1
)) |
2032 (GET_FIELD_SP(T0
, 17 + T1
- 1, 17) << 17) |
2033 (GET_FIELD_SP(T0
, 56, 59) << 13) | (GET_FIELD_SP(T0
, 35, 38) << 9) |
2034 (GET_FIELD_SP(T0
, 13, 16) << 5) | (((T0
>> 55) & 1) << 4) |
2035 (GET_FIELD_SP(T0
, 33, 34) << 2) | GET_FIELD_SP(T0
, 11, 12);
2038 void OPPROTO
op_array16()
2040 T0
= ((GET_FIELD_SP(T0
, 60, 63) << (17 + 2 * T1
)) |
2041 (GET_FIELD_SP(T0
, 39, 39 + T1
- 1) << (17 + T1
)) |
2042 (GET_FIELD_SP(T0
, 17 + T1
- 1, 17) << 17) |
2043 (GET_FIELD_SP(T0
, 56, 59) << 13) | (GET_FIELD_SP(T0
, 35, 38) << 9) |
2044 (GET_FIELD_SP(T0
, 13, 16) << 5) | (((T0
>> 55) & 1) << 4) |
2045 (GET_FIELD_SP(T0
, 33, 34) << 2) | GET_FIELD_SP(T0
, 11, 12)) << 1;
2048 void OPPROTO
op_array32()
2050 T0
= ((GET_FIELD_SP(T0
, 60, 63) << (17 + 2 * T1
)) |
2051 (GET_FIELD_SP(T0
, 39, 39 + T1
- 1) << (17 + T1
)) |
2052 (GET_FIELD_SP(T0
, 17 + T1
- 1, 17) << 17) |
2053 (GET_FIELD_SP(T0
, 56, 59) << 13) | (GET_FIELD_SP(T0
, 35, 38) << 9) |
2054 (GET_FIELD_SP(T0
, 13, 16) << 5) | (((T0
>> 55) & 1) << 4) |
2055 (GET_FIELD_SP(T0
, 33, 34) << 2) | GET_FIELD_SP(T0
, 11, 12)) << 2;
2058 void OPPROTO
op_alignaddr()
2064 env
->gsr
|= tmp
& 7ULL;
2068 void OPPROTO
op_faligndata()
2072 tmp
= (*((uint64_t *)&DT0
)) << ((env
->gsr
& 7) * 8);
2073 tmp
|= (*((uint64_t *)&DT1
)) >> (64 - (env
->gsr
& 7) * 8);
2074 *((uint64_t *)&DT0
) = tmp
;
2077 void OPPROTO
op_movl_FT0_0(void)
2079 *((uint32_t *)&FT0
) = 0;
2082 void OPPROTO
op_movl_DT0_0(void)
2084 *((uint64_t *)&DT0
) = 0;
2087 void OPPROTO
op_movl_FT0_1(void)
2089 *((uint32_t *)&FT0
) = 0xffffffff;
2092 void OPPROTO
op_movl_DT0_1(void)
2094 *((uint64_t *)&DT0
) = 0xffffffffffffffffULL
;
2097 void OPPROTO
op_fnot(void)
2099 *(uint64_t *)&DT0
= ~*(uint64_t *)&DT1
;
2102 void OPPROTO
op_fnots(void)
2104 *(uint32_t *)&FT0
= ~*(uint32_t *)&FT1
;
2107 void OPPROTO
op_fnor(void)
2109 *(uint64_t *)&DT0
= ~(*(uint64_t *)&DT0
| *(uint64_t *)&DT1
);
2112 void OPPROTO
op_fnors(void)
2114 *(uint32_t *)&FT0
= ~(*(uint32_t *)&FT0
| *(uint32_t *)&FT1
);
2117 void OPPROTO
op_for(void)
2119 *(uint64_t *)&DT0
|= *(uint64_t *)&DT1
;
2122 void OPPROTO
op_fors(void)
2124 *(uint32_t *)&FT0
|= *(uint32_t *)&FT1
;
2127 void OPPROTO
op_fxor(void)
2129 *(uint64_t *)&DT0
^= *(uint64_t *)&DT1
;
2132 void OPPROTO
op_fxors(void)
2134 *(uint32_t *)&FT0
^= *(uint32_t *)&FT1
;
2137 void OPPROTO
op_fand(void)
2139 *(uint64_t *)&DT0
&= *(uint64_t *)&DT1
;
2142 void OPPROTO
op_fands(void)
2144 *(uint32_t *)&FT0
&= *(uint32_t *)&FT1
;
2147 void OPPROTO
op_fornot(void)
2149 *(uint64_t *)&DT0
= *(uint64_t *)&DT0
| ~*(uint64_t *)&DT1
;
2152 void OPPROTO
op_fornots(void)
2154 *(uint32_t *)&FT0
= *(uint32_t *)&FT0
| ~*(uint32_t *)&FT1
;
2157 void OPPROTO
op_fandnot(void)
2159 *(uint64_t *)&DT0
= *(uint64_t *)&DT0
& ~*(uint64_t *)&DT1
;
2162 void OPPROTO
op_fandnots(void)
2164 *(uint32_t *)&FT0
= *(uint32_t *)&FT0
& ~*(uint32_t *)&FT1
;
2167 void OPPROTO
op_fnand(void)
2169 *(uint64_t *)&DT0
= ~(*(uint64_t *)&DT0
& *(uint64_t *)&DT1
);
2172 void OPPROTO
op_fnands(void)
2174 *(uint32_t *)&FT0
= ~(*(uint32_t *)&FT0
& *(uint32_t *)&FT1
);
2177 void OPPROTO
op_fxnor(void)
2179 *(uint64_t *)&DT0
^= ~*(uint64_t *)&DT1
;
2182 void OPPROTO
op_fxnors(void)
2184 *(uint32_t *)&FT0
^= ~*(uint32_t *)&FT1
;
2187 #ifdef WORDS_BIGENDIAN
2188 #define VIS_B64(n) b[7 - (n)]
2189 #define VIS_W64(n) w[3 - (n)]
2190 #define VIS_SW64(n) sw[3 - (n)]
2191 #define VIS_L64(n) l[1 - (n)]
2192 #define VIS_B32(n) b[3 - (n)]
2193 #define VIS_W32(n) w[1 - (n)]
2195 #define VIS_B64(n) b[n]
2196 #define VIS_W64(n) w[n]
2197 #define VIS_SW64(n) sw[n]
2198 #define VIS_L64(n) l[n]
2199 #define VIS_B32(n) b[n]
2200 #define VIS_W32(n) w[n]
2218 void OPPROTO
op_fpmerge(void)
2225 // Reverse calculation order to handle overlap
2226 d
.VIS_B64(7) = s
.VIS_B64(3);
2227 d
.VIS_B64(6) = d
.VIS_B64(3);
2228 d
.VIS_B64(5) = s
.VIS_B64(2);
2229 d
.VIS_B64(4) = d
.VIS_B64(2);
2230 d
.VIS_B64(3) = s
.VIS_B64(1);
2231 d
.VIS_B64(2) = d
.VIS_B64(1);
2232 d
.VIS_B64(1) = s
.VIS_B64(0);
2233 //d.VIS_B64(0) = d.VIS_B64(0);
2238 void OPPROTO
op_fmul8x16(void)
2247 tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \
2248 if ((tmp & 0xff) > 0x7f) \
2250 d.VIS_W64(r) = tmp >> 8;
2261 void OPPROTO
op_fmul8x16al(void)
2270 tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \
2271 if ((tmp & 0xff) > 0x7f) \
2273 d.VIS_W64(r) = tmp >> 8;
2284 void OPPROTO
op_fmul8x16au(void)
2293 tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \
2294 if ((tmp & 0xff) > 0x7f) \
2296 d.VIS_W64(r) = tmp >> 8;
2307 void OPPROTO
op_fmul8sux16(void)
2316 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
2317 if ((tmp & 0xff) > 0x7f) \
2319 d.VIS_W64(r) = tmp >> 8;
2330 void OPPROTO
op_fmul8ulx16(void)
2339 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
2340 if ((tmp & 0xff) > 0x7f) \
2342 d.VIS_W64(r) = tmp >> 8;
2353 void OPPROTO
op_fmuld8sux16(void)
2362 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
2363 if ((tmp & 0xff) > 0x7f) \
2367 // Reverse calculation order to handle overlap
2375 void OPPROTO
op_fmuld8ulx16(void)
2384 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
2385 if ((tmp & 0xff) > 0x7f) \
2389 // Reverse calculation order to handle overlap
2397 void OPPROTO
op_fexpand(void)
2402 s
.l
= (uint32_t)(*(uint64_t *)&DT0
& 0xffffffff);
2404 d
.VIS_L64(0) = s
.VIS_W32(0) << 4;
2405 d
.VIS_L64(1) = s
.VIS_W32(1) << 4;
2406 d
.VIS_L64(2) = s
.VIS_W32(2) << 4;
2407 d
.VIS_L64(3) = s
.VIS_W32(3) << 4;
2412 #define VIS_OP(name, F) \
2413 void OPPROTO name##16(void) \
2420 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0)); \
2421 d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1)); \
2422 d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2)); \
2423 d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3)); \
2428 void OPPROTO name##16s(void) \
2435 d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0)); \
2436 d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1)); \
2441 void OPPROTO name##32(void) \
2448 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0)); \
2449 d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1)); \
2454 void OPPROTO name##32s(void) \
2461 d.l = F(d.l, s.l); \
2466 #define FADD(a, b) ((a) + (b))
2467 #define FSUB(a, b) ((a) - (b))
2468 VIS_OP(op_fpadd
, FADD
)
2469 VIS_OP(op_fpsub
, FSUB
)
2471 #define VIS_CMPOP(name, F) \
2472 void OPPROTO name##16(void) \
2479 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0))? 1: 0; \
2480 d.VIS_W64(0) |= F(d.VIS_W64(1), s.VIS_W64(1))? 2: 0; \
2481 d.VIS_W64(0) |= F(d.VIS_W64(2), s.VIS_W64(2))? 4: 0; \
2482 d.VIS_W64(0) |= F(d.VIS_W64(3), s.VIS_W64(3))? 8: 0; \
2487 void OPPROTO name##32(void) \
2494 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0))? 1: 0; \
2495 d.VIS_L64(0) |= F(d.VIS_L64(1), s.VIS_L64(1))? 2: 0; \
2500 #define FCMPGT(a, b) ((a) > (b))
2501 #define FCMPEQ(a, b) ((a) == (b))
2502 #define FCMPLE(a, b) ((a) <= (b))
2503 #define FCMPNE(a, b) ((a) != (b))
2505 VIS_CMPOP(op_fcmpgt
, FCMPGT
)
2506 VIS_CMPOP(op_fcmpeq
, FCMPEQ
)
2507 VIS_CMPOP(op_fcmple
, FCMPLE
)
2508 VIS_CMPOP(op_fcmpne
, FCMPNE
)
2512 #define CHECK_ALIGN_OP(align) \
2513 void OPPROTO op_check_align_T0_ ## align (void) \
2516 raise_exception(TT_UNALIGNED); \