Fix warnings that would be caused by ld flag --warn-common
[qemu/mini2440/sniper_sniper_test.git] / target-ppc / op.c
blob64166595cfc58c1d8bb5f3abff641d8706a623c7
1 /*
2 * PowerPC emulation micro-operations for qemu.
4 * Copyright (c) 2003-2007 Jocelyn Mayer
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
21 //#define DEBUG_OP
23 #include "config.h"
24 #include "exec.h"
25 #include "host-utils.h"
26 #include "helper_regs.h"
27 #include "op_helper.h"
29 void OPPROTO op_print_mem_EA (void)
31 do_print_mem_EA(T0);
32 RETURN();
35 /* PowerPC state maintenance operations */
36 /* set_Rc0 */
37 void OPPROTO op_set_Rc0 (void)
39 env->crf[0] = T0 | xer_so;
40 RETURN();
43 /* Generate exceptions */
44 void OPPROTO op_raise_exception_err (void)
46 do_raise_exception_err(PARAM1, PARAM2);
49 void OPPROTO op_debug (void)
51 do_raise_exception(EXCP_DEBUG);
54 /* Load/store special registers */
55 void OPPROTO op_load_cr (void)
57 do_load_cr();
58 RETURN();
61 void OPPROTO op_store_cr (void)
63 do_store_cr(PARAM1);
64 RETURN();
67 void OPPROTO op_load_xer_cr (void)
69 T0 = (xer_so << 3) | (xer_ov << 2) | (xer_ca << 1);
70 RETURN();
73 void OPPROTO op_clear_xer_ov (void)
75 xer_so = 0;
76 xer_ov = 0;
77 RETURN();
80 void OPPROTO op_clear_xer_ca (void)
82 xer_ca = 0;
83 RETURN();
86 void OPPROTO op_load_xer_bc (void)
88 T1 = xer_bc;
89 RETURN();
92 void OPPROTO op_store_xer_bc (void)
94 xer_bc = T0;
95 RETURN();
98 void OPPROTO op_load_xer (void)
100 T0 = hreg_load_xer(env);
101 RETURN();
104 void OPPROTO op_store_xer (void)
106 hreg_store_xer(env, T0);
107 RETURN();
110 #if defined(TARGET_PPC64)
111 void OPPROTO op_store_pri (void)
113 do_store_pri(PARAM1);
114 RETURN();
116 #endif
118 #if !defined(CONFIG_USER_ONLY)
119 /* Segment registers load and store */
120 void OPPROTO op_load_sr (void)
122 T0 = env->sr[T1];
123 RETURN();
126 void OPPROTO op_store_sr (void)
128 do_store_sr(env, T1, T0);
129 RETURN();
132 #if defined(TARGET_PPC64)
133 void OPPROTO op_load_slb (void)
135 T0 = ppc_load_slb(env, T1);
136 RETURN();
139 void OPPROTO op_store_slb (void)
141 ppc_store_slb(env, T1, T0);
142 RETURN();
144 #endif /* defined(TARGET_PPC64) */
146 void OPPROTO op_load_sdr1 (void)
148 T0 = env->sdr1;
149 RETURN();
152 void OPPROTO op_store_sdr1 (void)
154 do_store_sdr1(env, T0);
155 RETURN();
158 #if defined (TARGET_PPC64)
159 void OPPROTO op_load_asr (void)
161 T0 = env->asr;
162 RETURN();
165 void OPPROTO op_store_asr (void)
167 ppc_store_asr(env, T0);
168 RETURN();
170 #endif
172 void OPPROTO op_load_msr (void)
174 T0 = env->msr;
175 RETURN();
178 void OPPROTO op_store_msr (void)
180 do_store_msr();
181 RETURN();
184 #if defined (TARGET_PPC64)
185 void OPPROTO op_store_msr_32 (void)
187 T0 = (env->msr & ~0xFFFFFFFFULL) | (T0 & 0xFFFFFFFF);
188 do_store_msr();
189 RETURN();
191 #endif
193 void OPPROTO op_update_riee (void)
195 /* We don't call do_store_msr here as we won't trigger
196 * any special case nor change hflags
198 T0 &= (1 << MSR_RI) | (1 << MSR_EE);
199 env->msr &= ~(1 << MSR_RI) | (1 << MSR_EE);
200 env->msr |= T0;
201 RETURN();
203 #endif
205 /* SPR */
206 void OPPROTO op_load_spr (void)
208 T0 = env->spr[PARAM1];
209 RETURN();
212 void OPPROTO op_store_spr (void)
214 env->spr[PARAM1] = T0;
215 RETURN();
218 void OPPROTO op_load_dump_spr (void)
220 T0 = ppc_load_dump_spr(PARAM1);
221 RETURN();
224 void OPPROTO op_store_dump_spr (void)
226 ppc_store_dump_spr(PARAM1, T0);
227 RETURN();
230 void OPPROTO op_mask_spr (void)
232 env->spr[PARAM1] &= ~T0;
233 RETURN();
236 void OPPROTO op_load_tbl (void)
238 T0 = cpu_ppc_load_tbl(env);
239 RETURN();
242 void OPPROTO op_load_tbu (void)
244 T0 = cpu_ppc_load_tbu(env);
245 RETURN();
248 void OPPROTO op_load_atbl (void)
250 T0 = cpu_ppc_load_atbl(env);
251 RETURN();
254 void OPPROTO op_load_atbu (void)
256 T0 = cpu_ppc_load_atbu(env);
257 RETURN();
260 #if !defined(CONFIG_USER_ONLY)
261 void OPPROTO op_store_tbl (void)
263 cpu_ppc_store_tbl(env, T0);
264 RETURN();
267 void OPPROTO op_store_tbu (void)
269 cpu_ppc_store_tbu(env, T0);
270 RETURN();
273 void OPPROTO op_store_atbl (void)
275 cpu_ppc_store_atbl(env, T0);
276 RETURN();
279 void OPPROTO op_store_atbu (void)
281 cpu_ppc_store_atbu(env, T0);
282 RETURN();
285 void OPPROTO op_load_decr (void)
287 T0 = cpu_ppc_load_decr(env);
288 RETURN();
291 void OPPROTO op_store_decr (void)
293 cpu_ppc_store_decr(env, T0);
294 RETURN();
297 void OPPROTO op_load_ibat (void)
299 T0 = env->IBAT[PARAM1][PARAM2];
300 RETURN();
303 void OPPROTO op_store_ibatu (void)
305 do_store_ibatu(env, PARAM1, T0);
306 RETURN();
309 void OPPROTO op_store_ibatl (void)
311 #if 1
312 env->IBAT[1][PARAM1] = T0;
313 #else
314 do_store_ibatl(env, PARAM1, T0);
315 #endif
316 RETURN();
319 void OPPROTO op_load_dbat (void)
321 T0 = env->DBAT[PARAM1][PARAM2];
322 RETURN();
325 void OPPROTO op_store_dbatu (void)
327 do_store_dbatu(env, PARAM1, T0);
328 RETURN();
331 void OPPROTO op_store_dbatl (void)
333 #if 1
334 env->DBAT[1][PARAM1] = T0;
335 #else
336 do_store_dbatl(env, PARAM1, T0);
337 #endif
338 RETURN();
340 #endif /* !defined(CONFIG_USER_ONLY) */
342 /* FPSCR */
343 #ifdef CONFIG_SOFTFLOAT
344 void OPPROTO op_reset_fpstatus (void)
346 env->fp_status.float_exception_flags = 0;
347 RETURN();
349 #endif
351 void OPPROTO op_compute_fprf (void)
353 do_compute_fprf(PARAM1);
354 RETURN();
357 #ifdef CONFIG_SOFTFLOAT
358 void OPPROTO op_float_check_status (void)
360 do_float_check_status();
361 RETURN();
363 #else
364 void OPPROTO op_float_check_status (void)
366 if (env->exception_index == POWERPC_EXCP_PROGRAM &&
367 (env->error_code & POWERPC_EXCP_FP)) {
368 /* Differred floating-point exception after target FPR update */
369 if (msr_fe0 != 0 || msr_fe1 != 0)
370 do_raise_exception_err(env->exception_index, env->error_code);
372 RETURN();
374 #endif
376 void OPPROTO op_load_fpscr_FT0 (void)
378 /* The 32 MSB of the target fpr are undefined.
379 * They'll be zero...
381 CPU_DoubleU u;
383 u.l.upper = 0;
384 u.l.lower = env->fpscr;
385 FT0 = u.d;
386 RETURN();
389 void OPPROTO op_load_fpscr_T0 (void)
391 T0 = (env->fpscr >> PARAM1) & 0xF;
392 RETURN();
395 void OPPROTO op_load_fpcc (void)
397 T0 = fpscr_fpcc;
398 RETURN();
401 void OPPROTO op_fpscr_resetbit (void)
403 env->fpscr &= PARAM1;
404 RETURN();
407 void OPPROTO op_fpscr_setbit (void)
409 do_fpscr_setbit(PARAM1);
410 RETURN();
413 void OPPROTO op_store_fpscr (void)
415 do_store_fpscr(PARAM1);
416 RETURN();
419 /* Branch */
420 void OPPROTO op_setlr (void)
422 env->lr = (uint32_t)PARAM1;
423 RETURN();
426 #if defined (TARGET_PPC64)
427 void OPPROTO op_setlr_64 (void)
429 env->lr = ((uint64_t)PARAM1 << 32) | (uint64_t)PARAM2;
430 RETURN();
432 #endif
434 void OPPROTO op_jz_T0 (void)
436 if (!T0)
437 GOTO_LABEL_PARAM(1);
438 RETURN();
441 void OPPROTO op_btest_T1 (void)
443 if (T0) {
444 env->nip = (uint32_t)(T1 & ~3);
445 } else {
446 env->nip = (uint32_t)PARAM1;
448 RETURN();
451 #if defined (TARGET_PPC64)
452 void OPPROTO op_btest_T1_64 (void)
454 if (T0) {
455 env->nip = (uint64_t)(T1 & ~3);
456 } else {
457 env->nip = ((uint64_t)PARAM1 << 32) | (uint64_t)PARAM2;
459 RETURN();
461 #endif
463 void OPPROTO op_movl_T1_ctr (void)
465 T1 = env->ctr;
466 RETURN();
469 void OPPROTO op_movl_T1_lr (void)
471 T1 = env->lr;
472 RETURN();
475 /* tests with result in T0 */
476 void OPPROTO op_test_ctr (void)
478 T0 = (uint32_t)env->ctr;
479 RETURN();
482 #if defined(TARGET_PPC64)
483 void OPPROTO op_test_ctr_64 (void)
485 T0 = (uint64_t)env->ctr;
486 RETURN();
488 #endif
490 void OPPROTO op_test_ctr_true (void)
492 T0 = ((uint32_t)env->ctr != 0 && (T0 & PARAM1) != 0);
493 RETURN();
496 #if defined(TARGET_PPC64)
497 void OPPROTO op_test_ctr_true_64 (void)
499 T0 = ((uint64_t)env->ctr != 0 && (T0 & PARAM1) != 0);
500 RETURN();
502 #endif
504 void OPPROTO op_test_ctr_false (void)
506 T0 = ((uint32_t)env->ctr != 0 && (T0 & PARAM1) == 0);
507 RETURN();
510 #if defined(TARGET_PPC64)
511 void OPPROTO op_test_ctr_false_64 (void)
513 T0 = ((uint64_t)env->ctr != 0 && (T0 & PARAM1) == 0);
514 RETURN();
516 #endif
518 void OPPROTO op_test_ctrz (void)
520 T0 = ((uint32_t)env->ctr == 0);
521 RETURN();
524 #if defined(TARGET_PPC64)
525 void OPPROTO op_test_ctrz_64 (void)
527 T0 = ((uint64_t)env->ctr == 0);
528 RETURN();
530 #endif
532 void OPPROTO op_test_ctrz_true (void)
534 T0 = ((uint32_t)env->ctr == 0 && (T0 & PARAM1) != 0);
535 RETURN();
538 #if defined(TARGET_PPC64)
539 void OPPROTO op_test_ctrz_true_64 (void)
541 T0 = ((uint64_t)env->ctr == 0 && (T0 & PARAM1) != 0);
542 RETURN();
544 #endif
546 void OPPROTO op_test_ctrz_false (void)
548 T0 = ((uint32_t)env->ctr == 0 && (T0 & PARAM1) == 0);
549 RETURN();
552 #if defined(TARGET_PPC64)
553 void OPPROTO op_test_ctrz_false_64 (void)
555 T0 = ((uint64_t)env->ctr == 0 && (T0 & PARAM1) == 0);
556 RETURN();
558 #endif
560 void OPPROTO op_test_true (void)
562 T0 = (T0 & PARAM1);
563 RETURN();
566 void OPPROTO op_test_false (void)
568 T0 = ((T0 & PARAM1) == 0);
569 RETURN();
572 /* CTR maintenance */
573 void OPPROTO op_dec_ctr (void)
575 env->ctr--;
576 RETURN();
579 /*** Integer arithmetic ***/
580 /* add */
581 void OPPROTO op_check_addo (void)
583 xer_ov = (((uint32_t)T2 ^ (uint32_t)T1 ^ UINT32_MAX) &
584 ((uint32_t)T2 ^ (uint32_t)T0)) >> 31;
585 xer_so |= xer_ov;
586 RETURN();
589 #if defined(TARGET_PPC64)
590 void OPPROTO op_check_addo_64 (void)
592 xer_ov = (((uint64_t)T2 ^ (uint64_t)T1 ^ UINT64_MAX) &
593 ((uint64_t)T2 ^ (uint64_t)T0)) >> 63;
594 xer_so |= xer_ov;
595 RETURN();
597 #endif
599 /* add carrying */
600 void OPPROTO op_check_addc (void)
602 if (likely((uint32_t)T0 >= (uint32_t)T2)) {
603 xer_ca = 0;
604 } else {
605 xer_ca = 1;
607 RETURN();
610 #if defined(TARGET_PPC64)
611 void OPPROTO op_check_addc_64 (void)
613 if (likely((uint64_t)T0 >= (uint64_t)T2)) {
614 xer_ca = 0;
615 } else {
616 xer_ca = 1;
618 RETURN();
620 #endif
622 /* add extended */
623 void OPPROTO op_adde (void)
625 do_adde();
626 RETURN();
629 #if defined(TARGET_PPC64)
630 void OPPROTO op_adde_64 (void)
632 do_adde_64();
633 RETURN();
635 #endif
637 /* add to minus one extended */
638 void OPPROTO op_add_me (void)
640 T0 += xer_ca + (-1);
641 if (likely((uint32_t)T1 != 0))
642 xer_ca = 1;
643 else
644 xer_ca = 0;
645 RETURN();
648 #if defined(TARGET_PPC64)
649 void OPPROTO op_add_me_64 (void)
651 T0 += xer_ca + (-1);
652 if (likely((uint64_t)T1 != 0))
653 xer_ca = 1;
654 else
655 xer_ca = 0;
656 RETURN();
658 #endif
660 void OPPROTO op_addmeo (void)
662 do_addmeo();
663 RETURN();
666 void OPPROTO op_addmeo_64 (void)
668 do_addmeo();
669 RETURN();
672 /* add to zero extended */
673 void OPPROTO op_add_ze (void)
675 T0 += xer_ca;
676 RETURN();
679 /* divide word */
680 void OPPROTO op_divw (void)
682 if (unlikely(((int32_t)T0 == INT32_MIN && (int32_t)T1 == (int32_t)-1) ||
683 (int32_t)T1 == 0)) {
684 T0 = (int32_t)(UINT32_MAX * ((uint32_t)T0 >> 31));
685 } else {
686 T0 = (int32_t)T0 / (int32_t)T1;
688 RETURN();
691 #if defined(TARGET_PPC64)
692 void OPPROTO op_divd (void)
694 if (unlikely(((int64_t)T0 == INT64_MIN && (int64_t)T1 == (int64_t)-1LL) ||
695 (int64_t)T1 == 0)) {
696 T0 = (int64_t)(UINT64_MAX * ((uint64_t)T0 >> 63));
697 } else {
698 T0 = (int64_t)T0 / (int64_t)T1;
700 RETURN();
702 #endif
704 void OPPROTO op_divwo (void)
706 do_divwo();
707 RETURN();
710 #if defined(TARGET_PPC64)
711 void OPPROTO op_divdo (void)
713 do_divdo();
714 RETURN();
716 #endif
718 /* divide word unsigned */
719 void OPPROTO op_divwu (void)
721 if (unlikely(T1 == 0)) {
722 T0 = 0;
723 } else {
724 T0 = (uint32_t)T0 / (uint32_t)T1;
726 RETURN();
729 #if defined(TARGET_PPC64)
730 void OPPROTO op_divdu (void)
732 if (unlikely(T1 == 0)) {
733 T0 = 0;
734 } else {
735 T0 /= T1;
737 RETURN();
739 #endif
741 void OPPROTO op_divwuo (void)
743 do_divwuo();
744 RETURN();
747 #if defined(TARGET_PPC64)
748 void OPPROTO op_divduo (void)
750 do_divduo();
751 RETURN();
753 #endif
755 /* multiply high word */
756 void OPPROTO op_mulhw (void)
758 T0 = ((int64_t)((int32_t)T0) * (int64_t)((int32_t)T1)) >> 32;
759 RETURN();
762 #if defined(TARGET_PPC64)
763 void OPPROTO op_mulhd (void)
765 uint64_t tl, th;
767 muls64(&tl, &th, T0, T1);
768 T0 = th;
769 RETURN();
771 #endif
773 /* multiply high word unsigned */
774 void OPPROTO op_mulhwu (void)
776 T0 = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1) >> 32;
777 RETURN();
780 #if defined(TARGET_PPC64)
781 void OPPROTO op_mulhdu (void)
783 uint64_t tl, th;
785 mulu64(&tl, &th, T0, T1);
786 T0 = th;
787 RETURN();
789 #endif
791 /* multiply low immediate */
792 void OPPROTO op_mulli (void)
794 T0 = ((int32_t)T0 * (int32_t)PARAM1);
795 RETURN();
798 /* multiply low word */
799 void OPPROTO op_mullw (void)
801 T0 = (int32_t)(T0 * T1);
802 RETURN();
805 #if defined(TARGET_PPC64)
806 void OPPROTO op_mulld (void)
808 T0 *= T1;
809 RETURN();
811 #endif
813 void OPPROTO op_mullwo (void)
815 do_mullwo();
816 RETURN();
819 #if defined(TARGET_PPC64)
820 void OPPROTO op_mulldo (void)
822 do_mulldo();
823 RETURN();
825 #endif
827 /* negate */
828 void OPPROTO op_neg (void)
830 if (likely(T0 != INT32_MIN)) {
831 T0 = -(int32_t)T0;
833 RETURN();
836 #if defined(TARGET_PPC64)
837 void OPPROTO op_neg_64 (void)
839 if (likely(T0 != INT64_MIN)) {
840 T0 = -(int64_t)T0;
842 RETURN();
844 #endif
846 void OPPROTO op_nego (void)
848 do_nego();
849 RETURN();
852 #if defined(TARGET_PPC64)
853 void OPPROTO op_nego_64 (void)
855 do_nego_64();
856 RETURN();
858 #endif
860 /* subtract from carrying */
861 void OPPROTO op_check_subfc (void)
863 if (likely((uint32_t)T0 > (uint32_t)T1)) {
864 xer_ca = 0;
865 } else {
866 xer_ca = 1;
868 RETURN();
871 #if defined(TARGET_PPC64)
872 void OPPROTO op_check_subfc_64 (void)
874 if (likely((uint64_t)T0 > (uint64_t)T1)) {
875 xer_ca = 0;
876 } else {
877 xer_ca = 1;
879 RETURN();
881 #endif
883 /* subtract from extended */
884 void OPPROTO op_subfe (void)
886 do_subfe();
887 RETURN();
890 #if defined(TARGET_PPC64)
891 void OPPROTO op_subfe_64 (void)
893 do_subfe_64();
894 RETURN();
896 #endif
898 /* subtract from immediate carrying */
899 void OPPROTO op_subfic (void)
901 T0 = (int32_t)PARAM1 + ~T0 + 1;
902 if ((uint32_t)T0 <= (uint32_t)PARAM1) {
903 xer_ca = 1;
904 } else {
905 xer_ca = 0;
907 RETURN();
910 #if defined(TARGET_PPC64)
911 void OPPROTO op_subfic_64 (void)
913 T0 = (int64_t)PARAM1 + ~T0 + 1;
914 if ((uint64_t)T0 <= (uint64_t)PARAM1) {
915 xer_ca = 1;
916 } else {
917 xer_ca = 0;
919 RETURN();
921 #endif
923 /* subtract from minus one extended */
924 void OPPROTO op_subfme (void)
926 T0 = ~T0 + xer_ca - 1;
927 if (likely((uint32_t)T0 != UINT32_MAX))
928 xer_ca = 1;
929 else
930 xer_ca = 0;
931 RETURN();
934 #if defined(TARGET_PPC64)
935 void OPPROTO op_subfme_64 (void)
937 T0 = ~T0 + xer_ca - 1;
938 if (likely((uint64_t)T0 != UINT64_MAX))
939 xer_ca = 1;
940 else
941 xer_ca = 0;
942 RETURN();
944 #endif
946 void OPPROTO op_subfmeo (void)
948 do_subfmeo();
949 RETURN();
952 #if defined(TARGET_PPC64)
953 void OPPROTO op_subfmeo_64 (void)
955 do_subfmeo_64();
956 RETURN();
958 #endif
960 /* subtract from zero extended */
961 void OPPROTO op_subfze (void)
963 T1 = ~T0;
964 T0 = T1 + xer_ca;
965 if ((uint32_t)T0 < (uint32_t)T1) {
966 xer_ca = 1;
967 } else {
968 xer_ca = 0;
970 RETURN();
973 #if defined(TARGET_PPC64)
974 void OPPROTO op_subfze_64 (void)
976 T1 = ~T0;
977 T0 = T1 + xer_ca;
978 if ((uint64_t)T0 < (uint64_t)T1) {
979 xer_ca = 1;
980 } else {
981 xer_ca = 0;
983 RETURN();
985 #endif
987 void OPPROTO op_subfzeo (void)
989 do_subfzeo();
990 RETURN();
993 #if defined(TARGET_PPC64)
994 void OPPROTO op_subfzeo_64 (void)
996 do_subfzeo_64();
997 RETURN();
999 #endif
1001 /*** Integer comparison ***/
1002 /* compare */
1003 void OPPROTO op_cmp (void)
1005 if ((int32_t)T0 < (int32_t)T1) {
1006 T0 = 0x08;
1007 } else if ((int32_t)T0 > (int32_t)T1) {
1008 T0 = 0x04;
1009 } else {
1010 T0 = 0x02;
1012 T0 |= xer_so;
1013 RETURN();
1016 #if defined(TARGET_PPC64)
1017 void OPPROTO op_cmp_64 (void)
1019 if ((int64_t)T0 < (int64_t)T1) {
1020 T0 = 0x08;
1021 } else if ((int64_t)T0 > (int64_t)T1) {
1022 T0 = 0x04;
1023 } else {
1024 T0 = 0x02;
1026 T0 |= xer_so;
1027 RETURN();
1029 #endif
1031 /* compare immediate */
1032 void OPPROTO op_cmpi (void)
1034 if ((int32_t)T0 < (int32_t)PARAM1) {
1035 T0 = 0x08;
1036 } else if ((int32_t)T0 > (int32_t)PARAM1) {
1037 T0 = 0x04;
1038 } else {
1039 T0 = 0x02;
1041 T0 |= xer_so;
1042 RETURN();
1045 #if defined(TARGET_PPC64)
1046 void OPPROTO op_cmpi_64 (void)
1048 if ((int64_t)T0 < (int64_t)((int32_t)PARAM1)) {
1049 T0 = 0x08;
1050 } else if ((int64_t)T0 > (int64_t)((int32_t)PARAM1)) {
1051 T0 = 0x04;
1052 } else {
1053 T0 = 0x02;
1055 T0 |= xer_so;
1056 RETURN();
1058 #endif
1060 /* compare logical */
1061 void OPPROTO op_cmpl (void)
1063 if ((uint32_t)T0 < (uint32_t)T1) {
1064 T0 = 0x08;
1065 } else if ((uint32_t)T0 > (uint32_t)T1) {
1066 T0 = 0x04;
1067 } else {
1068 T0 = 0x02;
1070 T0 |= xer_so;
1071 RETURN();
1074 #if defined(TARGET_PPC64)
1075 void OPPROTO op_cmpl_64 (void)
1077 if ((uint64_t)T0 < (uint64_t)T1) {
1078 T0 = 0x08;
1079 } else if ((uint64_t)T0 > (uint64_t)T1) {
1080 T0 = 0x04;
1081 } else {
1082 T0 = 0x02;
1084 T0 |= xer_so;
1085 RETURN();
1087 #endif
1089 /* compare logical immediate */
1090 void OPPROTO op_cmpli (void)
1092 if ((uint32_t)T0 < (uint32_t)PARAM1) {
1093 T0 = 0x08;
1094 } else if ((uint32_t)T0 > (uint32_t)PARAM1) {
1095 T0 = 0x04;
1096 } else {
1097 T0 = 0x02;
1099 T0 |= xer_so;
1100 RETURN();
1103 #if defined(TARGET_PPC64)
1104 void OPPROTO op_cmpli_64 (void)
1106 if ((uint64_t)T0 < (uint64_t)PARAM1) {
1107 T0 = 0x08;
1108 } else if ((uint64_t)T0 > (uint64_t)PARAM1) {
1109 T0 = 0x04;
1110 } else {
1111 T0 = 0x02;
1113 T0 |= xer_so;
1114 RETURN();
1116 #endif
1118 void OPPROTO op_isel (void)
1120 if (T0)
1121 T0 = T1;
1122 else
1123 T0 = T2;
1124 RETURN();
1127 void OPPROTO op_popcntb (void)
1129 do_popcntb();
1130 RETURN();
1133 #if defined(TARGET_PPC64)
1134 void OPPROTO op_popcntb_64 (void)
1136 do_popcntb_64();
1137 RETURN();
1139 #endif
1141 /*** Integer logical ***/
1142 /* and */
1143 void OPPROTO op_and (void)
1145 T0 &= T1;
1146 RETURN();
1149 /* andc */
1150 void OPPROTO op_andc (void)
1152 T0 &= ~T1;
1153 RETURN();
1156 /* count leading zero */
1157 void OPPROTO op_cntlzw (void)
1159 do_cntlzw();
1160 RETURN();
1163 #if defined(TARGET_PPC64)
1164 void OPPROTO op_cntlzd (void)
1166 do_cntlzd();
1167 RETURN();
1169 #endif
1171 /* eqv */
1172 void OPPROTO op_eqv (void)
1174 T0 = ~(T0 ^ T1);
1175 RETURN();
1178 /* extend sign byte */
1179 void OPPROTO op_extsb (void)
1181 #if defined (TARGET_PPC64)
1182 T0 = (int64_t)((int8_t)T0);
1183 #else
1184 T0 = (int32_t)((int8_t)T0);
1185 #endif
1186 RETURN();
1189 /* extend sign half word */
1190 void OPPROTO op_extsh (void)
1192 #if defined (TARGET_PPC64)
1193 T0 = (int64_t)((int16_t)T0);
1194 #else
1195 T0 = (int32_t)((int16_t)T0);
1196 #endif
1197 RETURN();
1200 #if defined (TARGET_PPC64)
1201 void OPPROTO op_extsw (void)
1203 T0 = (int64_t)((int32_t)T0);
1204 RETURN();
1206 #endif
1208 /* nand */
1209 void OPPROTO op_nand (void)
1211 T0 = ~(T0 & T1);
1212 RETURN();
1215 /* nor */
1216 void OPPROTO op_nor (void)
1218 T0 = ~(T0 | T1);
1219 RETURN();
1222 /* or */
1223 void OPPROTO op_or (void)
1225 T0 |= T1;
1226 RETURN();
1229 /* orc */
1230 void OPPROTO op_orc (void)
1232 T0 |= ~T1;
1233 RETURN();
1236 /* ori */
1237 void OPPROTO op_ori (void)
1239 T0 |= (uint32_t)PARAM1;
1240 RETURN();
1243 /* xor */
1244 void OPPROTO op_xor (void)
1246 T0 ^= T1;
1247 RETURN();
1250 /* xori */
1251 void OPPROTO op_xori (void)
1253 T0 ^= (uint32_t)PARAM1;
1254 RETURN();
1257 /*** Integer rotate ***/
1258 void OPPROTO op_rotl32_T0_T1 (void)
1260 T0 = rotl32(T0, T1 & 0x1F);
1261 RETURN();
1264 void OPPROTO op_rotli32_T0 (void)
1266 T0 = rotl32(T0, PARAM1);
1267 RETURN();
1270 #if defined(TARGET_PPC64)
1271 void OPPROTO op_rotl64_T0_T1 (void)
1273 T0 = rotl64(T0, T1 & 0x3F);
1274 RETURN();
1277 void OPPROTO op_rotli64_T0 (void)
1279 T0 = rotl64(T0, PARAM1);
1280 RETURN();
1282 #endif
1284 /*** Integer shift ***/
1285 /* shift left word */
1286 void OPPROTO op_slw (void)
1288 if (T1 & 0x20) {
1289 T0 = 0;
1290 } else {
1291 T0 = (uint32_t)(T0 << T1);
1293 RETURN();
1296 #if defined(TARGET_PPC64)
1297 void OPPROTO op_sld (void)
1299 if (T1 & 0x40) {
1300 T0 = 0;
1301 } else {
1302 T0 = T0 << T1;
1304 RETURN();
1306 #endif
1308 /* shift right algebraic word */
1309 void OPPROTO op_sraw (void)
1311 do_sraw();
1312 RETURN();
1315 #if defined(TARGET_PPC64)
1316 void OPPROTO op_srad (void)
1318 do_srad();
1319 RETURN();
1321 #endif
1323 /* shift right algebraic word immediate */
1324 void OPPROTO op_srawi (void)
1326 uint32_t mask = (uint32_t)PARAM2;
1328 T0 = (int32_t)T0 >> PARAM1;
1329 if ((int32_t)T1 < 0 && (T1 & mask) != 0) {
1330 xer_ca = 1;
1331 } else {
1332 xer_ca = 0;
1334 RETURN();
1337 #if defined(TARGET_PPC64)
1338 void OPPROTO op_sradi (void)
1340 uint64_t mask = ((uint64_t)PARAM2 << 32) | (uint64_t)PARAM3;
1342 T0 = (int64_t)T0 >> PARAM1;
1343 if ((int64_t)T1 < 0 && ((uint64_t)T1 & mask) != 0) {
1344 xer_ca = 1;
1345 } else {
1346 xer_ca = 0;
1348 RETURN();
1350 #endif
1352 /* shift right word */
1353 void OPPROTO op_srw (void)
1355 if (T1 & 0x20) {
1356 T0 = 0;
1357 } else {
1358 T0 = (uint32_t)T0 >> T1;
1360 RETURN();
1363 #if defined(TARGET_PPC64)
1364 void OPPROTO op_srd (void)
1366 if (T1 & 0x40) {
1367 T0 = 0;
1368 } else {
1369 T0 = (uint64_t)T0 >> T1;
1371 RETURN();
1373 #endif
1375 void OPPROTO op_sl_T0_T1 (void)
1377 T0 = T0 << T1;
1378 RETURN();
1381 void OPPROTO op_sli_T0 (void)
1383 T0 = T0 << PARAM1;
1384 RETURN();
1387 void OPPROTO op_sli_T1 (void)
1389 T1 = T1 << PARAM1;
1390 RETURN();
1393 void OPPROTO op_srl_T0_T1 (void)
1395 T0 = (uint32_t)T0 >> T1;
1396 RETURN();
1399 #if defined(TARGET_PPC64)
1400 void OPPROTO op_srl_T0_T1_64 (void)
1402 T0 = (uint32_t)T0 >> T1;
1403 RETURN();
1405 #endif
1407 void OPPROTO op_srli_T0 (void)
1409 T0 = (uint32_t)T0 >> PARAM1;
1410 RETURN();
1413 #if defined(TARGET_PPC64)
1414 void OPPROTO op_srli_T0_64 (void)
1416 T0 = (uint64_t)T0 >> PARAM1;
1417 RETURN();
1419 #endif
1421 void OPPROTO op_srli_T1 (void)
1423 T1 = (uint32_t)T1 >> PARAM1;
1424 RETURN();
1427 #if defined(TARGET_PPC64)
1428 void OPPROTO op_srli_T1_64 (void)
1430 T1 = (uint64_t)T1 >> PARAM1;
1431 RETURN();
1433 #endif
1435 /*** Floating-Point arithmetic ***/
1436 /* fadd - fadd. */
1437 void OPPROTO op_fadd (void)
1439 #if USE_PRECISE_EMULATION
1440 do_fadd();
1441 #else
1442 FT0 = float64_add(FT0, FT1, &env->fp_status);
1443 #endif
1444 RETURN();
1447 /* fsub - fsub. */
1448 void OPPROTO op_fsub (void)
1450 #if USE_PRECISE_EMULATION
1451 do_fsub();
1452 #else
1453 FT0 = float64_sub(FT0, FT1, &env->fp_status);
1454 #endif
1455 RETURN();
1458 /* fmul - fmul. */
1459 void OPPROTO op_fmul (void)
1461 #if USE_PRECISE_EMULATION
1462 do_fmul();
1463 #else
1464 FT0 = float64_mul(FT0, FT1, &env->fp_status);
1465 #endif
1466 RETURN();
1469 /* fdiv - fdiv. */
1470 void OPPROTO op_fdiv (void)
1472 #if USE_PRECISE_EMULATION
1473 do_fdiv();
1474 #else
1475 FT0 = float64_div(FT0, FT1, &env->fp_status);
1476 #endif
1477 RETURN();
1480 /* fsqrt - fsqrt. */
1481 void OPPROTO op_fsqrt (void)
1483 do_fsqrt();
1484 RETURN();
1487 /* fre - fre. */
1488 void OPPROTO op_fre (void)
1490 do_fre();
1491 RETURN();
1494 /* fres - fres. */
1495 void OPPROTO op_fres (void)
1497 do_fres();
1498 RETURN();
1501 /* frsqrte - frsqrte. */
1502 void OPPROTO op_frsqrte (void)
1504 do_frsqrte();
1505 RETURN();
1508 /* fsel - fsel. */
1509 void OPPROTO op_fsel (void)
1511 do_fsel();
1512 RETURN();
1515 /*** Floating-Point multiply-and-add ***/
1516 /* fmadd - fmadd. */
1517 void OPPROTO op_fmadd (void)
1519 #if USE_PRECISE_EMULATION
1520 do_fmadd();
1521 #else
1522 FT0 = float64_mul(FT0, FT1, &env->fp_status);
1523 FT0 = float64_add(FT0, FT2, &env->fp_status);
1524 #endif
1525 RETURN();
1528 /* fmsub - fmsub. */
1529 void OPPROTO op_fmsub (void)
1531 #if USE_PRECISE_EMULATION
1532 do_fmsub();
1533 #else
1534 FT0 = float64_mul(FT0, FT1, &env->fp_status);
1535 FT0 = float64_sub(FT0, FT2, &env->fp_status);
1536 #endif
1537 RETURN();
1540 /* fnmadd - fnmadd. - fnmadds - fnmadds. */
1541 void OPPROTO op_fnmadd (void)
1543 do_fnmadd();
1544 RETURN();
1547 /* fnmsub - fnmsub. */
1548 void OPPROTO op_fnmsub (void)
1550 do_fnmsub();
1551 RETURN();
1554 /*** Floating-Point round & convert ***/
1555 /* frsp - frsp. */
1556 void OPPROTO op_frsp (void)
1558 #if USE_PRECISE_EMULATION
1559 do_frsp();
1560 #else
1561 FT0 = float64_to_float32(FT0, &env->fp_status);
1562 #endif
1563 RETURN();
1566 /* fctiw - fctiw. */
1567 void OPPROTO op_fctiw (void)
1569 do_fctiw();
1570 RETURN();
1573 /* fctiwz - fctiwz. */
1574 void OPPROTO op_fctiwz (void)
1576 do_fctiwz();
1577 RETURN();
1580 #if defined(TARGET_PPC64)
1581 /* fcfid - fcfid. */
1582 void OPPROTO op_fcfid (void)
1584 do_fcfid();
1585 RETURN();
1588 /* fctid - fctid. */
1589 void OPPROTO op_fctid (void)
1591 do_fctid();
1592 RETURN();
1595 /* fctidz - fctidz. */
1596 void OPPROTO op_fctidz (void)
1598 do_fctidz();
1599 RETURN();
1601 #endif
1603 void OPPROTO op_frin (void)
1605 do_frin();
1606 RETURN();
1609 void OPPROTO op_friz (void)
1611 do_friz();
1612 RETURN();
1615 void OPPROTO op_frip (void)
1617 do_frip();
1618 RETURN();
1621 void OPPROTO op_frim (void)
1623 do_frim();
1624 RETURN();
1627 /*** Floating-Point compare ***/
1628 /* fcmpu */
1629 void OPPROTO op_fcmpu (void)
1631 do_fcmpu();
1632 RETURN();
1635 /* fcmpo */
1636 void OPPROTO op_fcmpo (void)
1638 do_fcmpo();
1639 RETURN();
1642 /*** Floating-point move ***/
1643 /* fabs */
1644 void OPPROTO op_fabs (void)
1646 FT0 = float64_abs(FT0);
1647 RETURN();
1650 /* fnabs */
1651 void OPPROTO op_fnabs (void)
1653 FT0 = float64_abs(FT0);
1654 FT0 = float64_chs(FT0);
1655 RETURN();
1658 /* fneg */
1659 void OPPROTO op_fneg (void)
1661 FT0 = float64_chs(FT0);
1662 RETURN();
1665 /* Load and store */
1666 #define MEMSUFFIX _raw
1667 #include "op_helper.h"
1668 #include "op_mem.h"
1669 #if !defined(CONFIG_USER_ONLY)
1670 #define MEMSUFFIX _user
1671 #include "op_helper.h"
1672 #include "op_mem.h"
1673 #define MEMSUFFIX _kernel
1674 #include "op_helper.h"
1675 #include "op_mem.h"
1676 #define MEMSUFFIX _hypv
1677 #include "op_helper.h"
1678 #include "op_mem.h"
1679 #endif
1681 /* Special op to check and maybe clear reservation */
1682 void OPPROTO op_check_reservation (void)
1684 if ((uint32_t)env->reserve == (uint32_t)(T0 & ~0x00000003))
1685 env->reserve = (target_ulong)-1ULL;
1686 RETURN();
1689 #if defined(TARGET_PPC64)
1690 void OPPROTO op_check_reservation_64 (void)
1692 if ((uint64_t)env->reserve == (uint64_t)(T0 & ~0x00000003))
1693 env->reserve = (target_ulong)-1ULL;
1694 RETURN();
1696 #endif
1698 void OPPROTO op_wait (void)
1700 env->halted = 1;
1701 RETURN();
1704 /* Return from interrupt */
1705 #if !defined(CONFIG_USER_ONLY)
1706 void OPPROTO op_rfi (void)
1708 do_rfi();
1709 RETURN();
1712 #if defined(TARGET_PPC64)
1713 void OPPROTO op_rfid (void)
1715 do_rfid();
1716 RETURN();
1719 void OPPROTO op_hrfid (void)
1721 do_hrfid();
1722 RETURN();
1724 #endif
1726 /* Exception vectors */
1727 void OPPROTO op_store_excp_prefix (void)
1729 T0 &= env->ivpr_mask;
1730 env->excp_prefix = T0;
1731 RETURN();
1734 void OPPROTO op_store_excp_vector (void)
1736 T0 &= env->ivor_mask;
1737 env->excp_vectors[PARAM1] = T0;
1738 RETURN();
1740 #endif
1742 /* Trap word */
1743 void OPPROTO op_tw (void)
1745 do_tw(PARAM1);
1746 RETURN();
1749 #if defined(TARGET_PPC64)
1750 void OPPROTO op_td (void)
1752 do_td(PARAM1);
1753 RETURN();
1755 #endif
1757 #if !defined(CONFIG_USER_ONLY)
1758 /* tlbia */
1759 void OPPROTO op_tlbia (void)
1761 ppc_tlb_invalidate_all(env);
1762 RETURN();
1765 /* tlbie */
1766 void OPPROTO op_tlbie (void)
1768 ppc_tlb_invalidate_one(env, (uint32_t)T0);
1769 RETURN();
1772 #if defined(TARGET_PPC64)
1773 void OPPROTO op_tlbie_64 (void)
1775 ppc_tlb_invalidate_one(env, T0);
1776 RETURN();
1778 #endif
1780 #if defined(TARGET_PPC64)
1781 void OPPROTO op_slbia (void)
1783 ppc_slb_invalidate_all(env);
1784 RETURN();
1787 void OPPROTO op_slbie (void)
1789 ppc_slb_invalidate_one(env, (uint32_t)T0);
1790 RETURN();
1793 void OPPROTO op_slbie_64 (void)
1795 ppc_slb_invalidate_one(env, T0);
1796 RETURN();
1798 #endif
1799 #endif
1801 #if !defined(CONFIG_USER_ONLY)
1802 /* PowerPC 602/603/755 software TLB load instructions */
1803 void OPPROTO op_6xx_tlbld (void)
1805 do_load_6xx_tlb(0);
1806 RETURN();
1809 void OPPROTO op_6xx_tlbli (void)
1811 do_load_6xx_tlb(1);
1812 RETURN();
1815 /* PowerPC 74xx software TLB load instructions */
1816 void OPPROTO op_74xx_tlbld (void)
1818 do_load_74xx_tlb(0);
1819 RETURN();
1822 void OPPROTO op_74xx_tlbli (void)
1824 do_load_74xx_tlb(1);
1825 RETURN();
1827 #endif
1829 /* 601 specific */
1830 void OPPROTO op_load_601_rtcl (void)
1832 T0 = cpu_ppc601_load_rtcl(env);
1833 RETURN();
1836 void OPPROTO op_load_601_rtcu (void)
1838 T0 = cpu_ppc601_load_rtcu(env);
1839 RETURN();
1842 #if !defined(CONFIG_USER_ONLY)
1843 void OPPROTO op_store_601_rtcl (void)
1845 cpu_ppc601_store_rtcl(env, T0);
1846 RETURN();
1849 void OPPROTO op_store_601_rtcu (void)
1851 cpu_ppc601_store_rtcu(env, T0);
1852 RETURN();
1855 void OPPROTO op_store_hid0_601 (void)
1857 do_store_hid0_601();
1858 RETURN();
1861 void OPPROTO op_load_601_bat (void)
1863 T0 = env->IBAT[PARAM1][PARAM2];
1864 RETURN();
1867 void OPPROTO op_store_601_batl (void)
1869 do_store_ibatl_601(env, PARAM1, T0);
1870 RETURN();
1873 void OPPROTO op_store_601_batu (void)
1875 do_store_ibatu_601(env, PARAM1, T0);
1876 RETURN();
1878 #endif /* !defined(CONFIG_USER_ONLY) */
1880 /* PowerPC 601 specific instructions (POWER bridge) */
1881 /* XXX: those micro-ops need tests ! */
1882 void OPPROTO op_POWER_abs (void)
1884 if ((int32_t)T0 == INT32_MIN)
1885 T0 = INT32_MAX;
1886 else if ((int32_t)T0 < 0)
1887 T0 = -T0;
1888 RETURN();
1891 void OPPROTO op_POWER_abso (void)
1893 do_POWER_abso();
1894 RETURN();
1897 void OPPROTO op_POWER_clcs (void)
1899 do_POWER_clcs();
1900 RETURN();
1903 void OPPROTO op_POWER_div (void)
1905 do_POWER_div();
1906 RETURN();
1909 void OPPROTO op_POWER_divo (void)
1911 do_POWER_divo();
1912 RETURN();
1915 void OPPROTO op_POWER_divs (void)
1917 do_POWER_divs();
1918 RETURN();
1921 void OPPROTO op_POWER_divso (void)
1923 do_POWER_divso();
1924 RETURN();
1927 void OPPROTO op_POWER_doz (void)
1929 if ((int32_t)T1 > (int32_t)T0)
1930 T0 = T1 - T0;
1931 else
1932 T0 = 0;
1933 RETURN();
1936 void OPPROTO op_POWER_dozo (void)
1938 do_POWER_dozo();
1939 RETURN();
1942 void OPPROTO op_load_xer_cmp (void)
1944 T2 = xer_cmp;
1945 RETURN();
1948 void OPPROTO op_POWER_maskg (void)
1950 do_POWER_maskg();
1951 RETURN();
1954 void OPPROTO op_POWER_maskir (void)
1956 T0 = (T0 & ~T2) | (T1 & T2);
1957 RETURN();
1960 void OPPROTO op_POWER_mul (void)
1962 uint64_t tmp;
1964 tmp = (uint64_t)T0 * (uint64_t)T1;
1965 env->spr[SPR_MQ] = tmp >> 32;
1966 T0 = tmp;
1967 RETURN();
1970 void OPPROTO op_POWER_mulo (void)
1972 do_POWER_mulo();
1973 RETURN();
1976 void OPPROTO op_POWER_nabs (void)
1978 if (T0 > 0)
1979 T0 = -T0;
1980 RETURN();
1983 void OPPROTO op_POWER_nabso (void)
1985 /* nabs never overflows */
1986 if (T0 > 0)
1987 T0 = -T0;
1988 xer_ov = 0;
1989 RETURN();
1992 /* XXX: factorise POWER rotates... */
1993 void OPPROTO op_POWER_rlmi (void)
1995 T0 = rotl32(T0, T2) & PARAM1;
1996 T0 |= T1 & (uint32_t)PARAM2;
1997 RETURN();
2000 void OPPROTO op_POWER_rrib (void)
2002 T2 &= 0x1FUL;
2003 T0 = rotl32(T0 & INT32_MIN, T2);
2004 T0 |= T1 & ~rotl32(INT32_MIN, T2);
2005 RETURN();
2008 void OPPROTO op_POWER_sle (void)
2010 T1 &= 0x1FUL;
2011 env->spr[SPR_MQ] = rotl32(T0, T1);
2012 T0 = T0 << T1;
2013 RETURN();
2016 void OPPROTO op_POWER_sleq (void)
2018 uint32_t tmp = env->spr[SPR_MQ];
2020 T1 &= 0x1FUL;
2021 env->spr[SPR_MQ] = rotl32(T0, T1);
2022 T0 = T0 << T1;
2023 T0 |= tmp >> (32 - T1);
2024 RETURN();
2027 void OPPROTO op_POWER_sllq (void)
2029 uint32_t msk = UINT32_MAX;
2031 msk = msk << (T1 & 0x1FUL);
2032 if (T1 & 0x20UL)
2033 msk = ~msk;
2034 T1 &= 0x1FUL;
2035 T0 = (T0 << T1) & msk;
2036 T0 |= env->spr[SPR_MQ] & ~msk;
2037 RETURN();
2040 void OPPROTO op_POWER_slq (void)
2042 uint32_t msk = UINT32_MAX, tmp;
2044 msk = msk << (T1 & 0x1FUL);
2045 if (T1 & 0x20UL)
2046 msk = ~msk;
2047 T1 &= 0x1FUL;
2048 tmp = rotl32(T0, T1);
2049 T0 = tmp & msk;
2050 env->spr[SPR_MQ] = tmp;
2051 RETURN();
2054 void OPPROTO op_POWER_sraq (void)
2056 env->spr[SPR_MQ] = rotl32(T0, 32 - (T1 & 0x1FUL));
2057 if (T1 & 0x20UL)
2058 T0 = UINT32_MAX;
2059 else
2060 T0 = (int32_t)T0 >> T1;
2061 RETURN();
2064 void OPPROTO op_POWER_sre (void)
2066 T1 &= 0x1FUL;
2067 env->spr[SPR_MQ] = rotl32(T0, 32 - T1);
2068 T0 = (int32_t)T0 >> T1;
2069 RETURN();
2072 void OPPROTO op_POWER_srea (void)
2074 T1 &= 0x1FUL;
2075 env->spr[SPR_MQ] = T0 >> T1;
2076 T0 = (int32_t)T0 >> T1;
2077 RETURN();
2080 void OPPROTO op_POWER_sreq (void)
2082 uint32_t tmp;
2083 int32_t msk;
2085 T1 &= 0x1FUL;
2086 msk = INT32_MIN >> T1;
2087 tmp = env->spr[SPR_MQ];
2088 env->spr[SPR_MQ] = rotl32(T0, 32 - T1);
2089 T0 = T0 >> T1;
2090 T0 |= tmp & msk;
2091 RETURN();
2094 void OPPROTO op_POWER_srlq (void)
2096 uint32_t tmp;
2097 int32_t msk;
2099 msk = INT32_MIN >> (T1 & 0x1FUL);
2100 if (T1 & 0x20UL)
2101 msk = ~msk;
2102 T1 &= 0x1FUL;
2103 tmp = env->spr[SPR_MQ];
2104 env->spr[SPR_MQ] = rotl32(T0, 32 - T1);
2105 T0 = T0 >> T1;
2106 T0 &= msk;
2107 T0 |= tmp & ~msk;
2108 RETURN();
2111 void OPPROTO op_POWER_srq (void)
2113 T1 &= 0x1FUL;
2114 env->spr[SPR_MQ] = rotl32(T0, 32 - T1);
2115 T0 = T0 >> T1;
2116 RETURN();
2119 /* POWER instructions not implemented in PowerPC 601 */
2120 #if !defined(CONFIG_USER_ONLY)
2121 void OPPROTO op_POWER_mfsri (void)
2123 T1 = T0 >> 28;
2124 T0 = env->sr[T1];
2125 RETURN();
2128 void OPPROTO op_POWER_rac (void)
2130 do_POWER_rac();
2131 RETURN();
2134 void OPPROTO op_POWER_rfsvc (void)
2136 do_POWER_rfsvc();
2137 RETURN();
2139 #endif
2141 /* PowerPC 602 specific instruction */
2142 #if !defined(CONFIG_USER_ONLY)
2143 void OPPROTO op_602_mfrom (void)
2145 do_op_602_mfrom();
2146 RETURN();
2148 #endif
2150 /* PowerPC 4xx specific micro-ops */
2151 void OPPROTO op_405_add_T0_T2 (void)
2153 T0 = (int32_t)T0 + (int32_t)T2;
2154 RETURN();
2157 void OPPROTO op_405_mulchw (void)
2159 T0 = ((int16_t)T0) * ((int16_t)(T1 >> 16));
2160 RETURN();
2163 void OPPROTO op_405_mulchwu (void)
2165 T0 = ((uint16_t)T0) * ((uint16_t)(T1 >> 16));
2166 RETURN();
2169 void OPPROTO op_405_mulhhw (void)
2171 T0 = ((int16_t)(T0 >> 16)) * ((int16_t)(T1 >> 16));
2172 RETURN();
2175 void OPPROTO op_405_mulhhwu (void)
2177 T0 = ((uint16_t)(T0 >> 16)) * ((uint16_t)(T1 >> 16));
2178 RETURN();
2181 void OPPROTO op_405_mullhw (void)
2183 T0 = ((int16_t)T0) * ((int16_t)T1);
2184 RETURN();
2187 void OPPROTO op_405_mullhwu (void)
2189 T0 = ((uint16_t)T0) * ((uint16_t)T1);
2190 RETURN();
2193 void OPPROTO op_405_check_sat (void)
2195 do_405_check_sat();
2196 RETURN();
2199 void OPPROTO op_405_check_ovu (void)
2201 if (likely(T0 >= T2)) {
2202 xer_ov = 0;
2203 } else {
2204 xer_ov = 1;
2205 xer_so = 1;
2207 RETURN();
2210 void OPPROTO op_405_check_satu (void)
2212 if (unlikely(T0 < T2)) {
2213 /* Saturate result */
2214 T0 = UINT32_MAX;
2216 RETURN();
2219 void OPPROTO op_load_dcr (void)
2221 do_load_dcr();
2222 RETURN();
2225 void OPPROTO op_store_dcr (void)
2227 do_store_dcr();
2228 RETURN();
2231 #if !defined(CONFIG_USER_ONLY)
2232 /* Return from critical interrupt :
2233 * same as rfi, except nip & MSR are loaded from SRR2/3 instead of SRR0/1
2235 void OPPROTO op_40x_rfci (void)
2237 do_40x_rfci();
2238 RETURN();
2241 void OPPROTO op_rfci (void)
2243 do_rfci();
2244 RETURN();
2247 void OPPROTO op_rfdi (void)
2249 do_rfdi();
2250 RETURN();
2253 void OPPROTO op_rfmci (void)
2255 do_rfmci();
2256 RETURN();
2259 void OPPROTO op_wrte (void)
2261 /* We don't call do_store_msr here as we won't trigger
2262 * any special case nor change hflags
2264 T0 &= 1 << MSR_EE;
2265 env->msr &= ~(1 << MSR_EE);
2266 env->msr |= T0;
2267 RETURN();
2270 void OPPROTO op_440_tlbre (void)
2272 do_440_tlbre(PARAM1);
2273 RETURN();
2276 void OPPROTO op_440_tlbsx (void)
2278 T0 = ppcemb_tlb_search(env, T0, env->spr[SPR_440_MMUCR] & 0xFF);
2279 RETURN();
2282 void OPPROTO op_4xx_tlbsx_check (void)
2284 int tmp;
2286 tmp = xer_so;
2287 if ((int)T0 != -1)
2288 tmp |= 0x02;
2289 env->crf[0] = tmp;
2290 RETURN();
2293 void OPPROTO op_440_tlbwe (void)
2295 do_440_tlbwe(PARAM1);
2296 RETURN();
2299 void OPPROTO op_4xx_tlbre_lo (void)
2301 do_4xx_tlbre_lo();
2302 RETURN();
2305 void OPPROTO op_4xx_tlbre_hi (void)
2307 do_4xx_tlbre_hi();
2308 RETURN();
2311 void OPPROTO op_4xx_tlbsx (void)
2313 T0 = ppcemb_tlb_search(env, T0, env->spr[SPR_40x_PID]);
2314 RETURN();
2317 void OPPROTO op_4xx_tlbwe_lo (void)
2319 do_4xx_tlbwe_lo();
2320 RETURN();
2323 void OPPROTO op_4xx_tlbwe_hi (void)
2325 do_4xx_tlbwe_hi();
2326 RETURN();
2328 #endif
2330 /* SPR micro-ops */
2331 /* 440 specific */
2332 void OPPROTO op_440_dlmzb (void)
2334 do_440_dlmzb();
2335 RETURN();
2338 void OPPROTO op_440_dlmzb_update_Rc (void)
2340 if (T0 == 8)
2341 T0 = 0x2;
2342 else if (T0 < 4)
2343 T0 = 0x4;
2344 else
2345 T0 = 0x8;
2346 RETURN();
2349 #if !defined(CONFIG_USER_ONLY)
2350 void OPPROTO op_store_pir (void)
2352 env->spr[SPR_PIR] = T0 & 0x0000000FUL;
2353 RETURN();
2356 void OPPROTO op_load_403_pb (void)
2358 do_load_403_pb(PARAM1);
2359 RETURN();
2362 void OPPROTO op_store_403_pb (void)
2364 do_store_403_pb(PARAM1);
2365 RETURN();
2368 void OPPROTO op_load_40x_pit (void)
2370 T0 = load_40x_pit(env);
2371 RETURN();
2374 void OPPROTO op_store_40x_pit (void)
2376 store_40x_pit(env, T0);
2377 RETURN();
2380 void OPPROTO op_store_40x_dbcr0 (void)
2382 store_40x_dbcr0(env, T0);
2383 RETURN();
2386 void OPPROTO op_store_40x_sler (void)
2388 store_40x_sler(env, T0);
2389 RETURN();
2392 void OPPROTO op_store_booke_tcr (void)
2394 store_booke_tcr(env, T0);
2395 RETURN();
2398 void OPPROTO op_store_booke_tsr (void)
2400 store_booke_tsr(env, T0);
2401 RETURN();
2403 #endif /* !defined(CONFIG_USER_ONLY) */
2405 /* SPE extension */
2406 void OPPROTO op_splatw_T1_64 (void)
2408 T1_64 = (T1_64 << 32) | (T1_64 & 0x00000000FFFFFFFFULL);
2409 RETURN();
2412 void OPPROTO op_splatwi_T0_64 (void)
2414 uint64_t tmp = PARAM1;
2416 T0_64 = (tmp << 32) | tmp;
2417 RETURN();
2420 void OPPROTO op_splatwi_T1_64 (void)
2422 uint64_t tmp = PARAM1;
2424 T1_64 = (tmp << 32) | tmp;
2425 RETURN();
2428 void OPPROTO op_extsh_T1_64 (void)
2430 T1_64 = (int32_t)((int16_t)T1_64);
2431 RETURN();
2434 void OPPROTO op_sli16_T1_64 (void)
2436 T1_64 = T1_64 << 16;
2437 RETURN();
2440 void OPPROTO op_sli32_T1_64 (void)
2442 T1_64 = T1_64 << 32;
2443 RETURN();
2446 void OPPROTO op_srli32_T1_64 (void)
2448 T1_64 = T1_64 >> 32;
2449 RETURN();
2452 void OPPROTO op_evsel (void)
2454 do_evsel();
2455 RETURN();
2458 void OPPROTO op_evaddw (void)
2460 do_evaddw();
2461 RETURN();
2464 void OPPROTO op_evsubfw (void)
2466 do_evsubfw();
2467 RETURN();
2470 void OPPROTO op_evneg (void)
2472 do_evneg();
2473 RETURN();
2476 void OPPROTO op_evabs (void)
2478 do_evabs();
2479 RETURN();
2482 void OPPROTO op_evextsh (void)
2484 T0_64 = ((uint64_t)((int32_t)(int16_t)(T0_64 >> 32)) << 32) |
2485 (uint64_t)((int32_t)(int16_t)T0_64);
2486 RETURN();
2489 void OPPROTO op_evextsb (void)
2491 T0_64 = ((uint64_t)((int32_t)(int8_t)(T0_64 >> 32)) << 32) |
2492 (uint64_t)((int32_t)(int8_t)T0_64);
2493 RETURN();
2496 void OPPROTO op_evcntlzw (void)
2498 do_evcntlzw();
2499 RETURN();
2502 void OPPROTO op_evrndw (void)
2504 do_evrndw();
2505 RETURN();
2508 void OPPROTO op_brinc (void)
2510 do_brinc();
2511 RETURN();
2514 void OPPROTO op_evcntlsw (void)
2516 do_evcntlsw();
2517 RETURN();
2520 void OPPROTO op_evand (void)
2522 T0_64 &= T1_64;
2523 RETURN();
2526 void OPPROTO op_evandc (void)
2528 T0_64 &= ~T1_64;
2529 RETURN();
2532 void OPPROTO op_evor (void)
2534 T0_64 |= T1_64;
2535 RETURN();
2538 void OPPROTO op_evxor (void)
2540 T0_64 ^= T1_64;
2541 RETURN();
2544 void OPPROTO op_eveqv (void)
2546 T0_64 = ~(T0_64 ^ T1_64);
2547 RETURN();
2550 void OPPROTO op_evnor (void)
2552 T0_64 = ~(T0_64 | T1_64);
2553 RETURN();
2556 void OPPROTO op_evorc (void)
2558 T0_64 |= ~T1_64;
2559 RETURN();
2562 void OPPROTO op_evnand (void)
2564 T0_64 = ~(T0_64 & T1_64);
2565 RETURN();
2568 void OPPROTO op_evsrws (void)
2570 do_evsrws();
2571 RETURN();
2574 void OPPROTO op_evsrwu (void)
2576 do_evsrwu();
2577 RETURN();
2580 void OPPROTO op_evslw (void)
2582 do_evslw();
2583 RETURN();
2586 void OPPROTO op_evrlw (void)
2588 do_evrlw();
2589 RETURN();
2592 void OPPROTO op_evmergelo (void)
2594 T0_64 = (T0_64 << 32) | (T1_64 & 0x00000000FFFFFFFFULL);
2595 RETURN();
2598 void OPPROTO op_evmergehi (void)
2600 T0_64 = (T0_64 & 0xFFFFFFFF00000000ULL) | (T1_64 >> 32);
2601 RETURN();
2604 void OPPROTO op_evmergelohi (void)
2606 T0_64 = (T0_64 << 32) | (T1_64 >> 32);
2607 RETURN();
2610 void OPPROTO op_evmergehilo (void)
2612 T0_64 = (T0_64 & 0xFFFFFFFF00000000ULL) | (T1_64 & 0x00000000FFFFFFFFULL);
2613 RETURN();
2616 void OPPROTO op_evcmpgts (void)
2618 do_evcmpgts();
2619 RETURN();
2622 void OPPROTO op_evcmpgtu (void)
2624 do_evcmpgtu();
2625 RETURN();
2628 void OPPROTO op_evcmplts (void)
2630 do_evcmplts();
2631 RETURN();
2634 void OPPROTO op_evcmpltu (void)
2636 do_evcmpltu();
2637 RETURN();
2640 void OPPROTO op_evcmpeq (void)
2642 do_evcmpeq();
2643 RETURN();
2646 void OPPROTO op_evfssub (void)
2648 do_evfssub();
2649 RETURN();
2652 void OPPROTO op_evfsadd (void)
2654 do_evfsadd();
2655 RETURN();
2658 void OPPROTO op_evfsnabs (void)
2660 do_evfsnabs();
2661 RETURN();
2664 void OPPROTO op_evfsabs (void)
2666 do_evfsabs();
2667 RETURN();
2670 void OPPROTO op_evfsneg (void)
2672 do_evfsneg();
2673 RETURN();
2676 void OPPROTO op_evfsdiv (void)
2678 do_evfsdiv();
2679 RETURN();
2682 void OPPROTO op_evfsmul (void)
2684 do_evfsmul();
2685 RETURN();
2688 void OPPROTO op_evfscmplt (void)
2690 do_evfscmplt();
2691 RETURN();
2694 void OPPROTO op_evfscmpgt (void)
2696 do_evfscmpgt();
2697 RETURN();
2700 void OPPROTO op_evfscmpeq (void)
2702 do_evfscmpeq();
2703 RETURN();
2706 void OPPROTO op_evfscfsi (void)
2708 do_evfscfsi();
2709 RETURN();
2712 void OPPROTO op_evfscfui (void)
2714 do_evfscfui();
2715 RETURN();
2718 void OPPROTO op_evfscfsf (void)
2720 do_evfscfsf();
2721 RETURN();
2724 void OPPROTO op_evfscfuf (void)
2726 do_evfscfuf();
2727 RETURN();
2730 void OPPROTO op_evfsctsi (void)
2732 do_evfsctsi();
2733 RETURN();
2736 void OPPROTO op_evfsctui (void)
2738 do_evfsctui();
2739 RETURN();
2742 void OPPROTO op_evfsctsf (void)
2744 do_evfsctsf();
2745 RETURN();
2748 void OPPROTO op_evfsctuf (void)
2750 do_evfsctuf();
2751 RETURN();
2754 void OPPROTO op_evfsctuiz (void)
2756 do_evfsctuiz();
2757 RETURN();
2760 void OPPROTO op_evfsctsiz (void)
2762 do_evfsctsiz();
2763 RETURN();
2766 void OPPROTO op_evfststlt (void)
2768 do_evfststlt();
2769 RETURN();
2772 void OPPROTO op_evfststgt (void)
2774 do_evfststgt();
2775 RETURN();
2778 void OPPROTO op_evfststeq (void)
2780 do_evfststeq();
2781 RETURN();
2784 void OPPROTO op_efssub (void)
2786 T0_64 = _do_efssub(T0_64, T1_64);
2787 RETURN();
2790 void OPPROTO op_efsadd (void)
2792 T0_64 = _do_efsadd(T0_64, T1_64);
2793 RETURN();
2796 void OPPROTO op_efsnabs (void)
2798 T0_64 = _do_efsnabs(T0_64);
2799 RETURN();
2802 void OPPROTO op_efsabs (void)
2804 T0_64 = _do_efsabs(T0_64);
2805 RETURN();
2808 void OPPROTO op_efsneg (void)
2810 T0_64 = _do_efsneg(T0_64);
2811 RETURN();
2814 void OPPROTO op_efsdiv (void)
2816 T0_64 = _do_efsdiv(T0_64, T1_64);
2817 RETURN();
2820 void OPPROTO op_efsmul (void)
2822 T0_64 = _do_efsmul(T0_64, T1_64);
2823 RETURN();
2826 void OPPROTO op_efscmplt (void)
2828 do_efscmplt();
2829 RETURN();
2832 void OPPROTO op_efscmpgt (void)
2834 do_efscmpgt();
2835 RETURN();
2838 void OPPROTO op_efscfd (void)
2840 do_efscfd();
2841 RETURN();
2844 void OPPROTO op_efscmpeq (void)
2846 do_efscmpeq();
2847 RETURN();
2850 void OPPROTO op_efscfsi (void)
2852 do_efscfsi();
2853 RETURN();
2856 void OPPROTO op_efscfui (void)
2858 do_efscfui();
2859 RETURN();
2862 void OPPROTO op_efscfsf (void)
2864 do_efscfsf();
2865 RETURN();
2868 void OPPROTO op_efscfuf (void)
2870 do_efscfuf();
2871 RETURN();
2874 void OPPROTO op_efsctsi (void)
2876 do_efsctsi();
2877 RETURN();
2880 void OPPROTO op_efsctui (void)
2882 do_efsctui();
2883 RETURN();
2886 void OPPROTO op_efsctsf (void)
2888 do_efsctsf();
2889 RETURN();
2892 void OPPROTO op_efsctuf (void)
2894 do_efsctuf();
2895 RETURN();
2898 void OPPROTO op_efsctsiz (void)
2900 do_efsctsiz();
2901 RETURN();
2904 void OPPROTO op_efsctuiz (void)
2906 do_efsctuiz();
2907 RETURN();
2910 void OPPROTO op_efststlt (void)
2912 T0 = _do_efststlt(T0_64, T1_64);
2913 RETURN();
2916 void OPPROTO op_efststgt (void)
2918 T0 = _do_efststgt(T0_64, T1_64);
2919 RETURN();
2922 void OPPROTO op_efststeq (void)
2924 T0 = _do_efststeq(T0_64, T1_64);
2925 RETURN();
2928 void OPPROTO op_efdsub (void)
2930 CPU_DoubleU u1, u2;
2931 u1.ll = T0_64;
2932 u2.ll = T1_64;
2933 u1.d = float64_sub(u1.d, u2.d, &env->spe_status);
2934 T0_64 = u1.ll;
2935 RETURN();
2938 void OPPROTO op_efdadd (void)
2940 CPU_DoubleU u1, u2;
2941 u1.ll = T0_64;
2942 u2.ll = T1_64;
2943 u1.d = float64_add(u1.d, u2.d, &env->spe_status);
2944 T0_64 = u1.ll;
2945 RETURN();
2948 void OPPROTO op_efdcfsid (void)
2950 do_efdcfsi();
2951 RETURN();
2954 void OPPROTO op_efdcfuid (void)
2956 do_efdcfui();
2957 RETURN();
2960 void OPPROTO op_efdnabs (void)
2962 T0_64 |= 0x8000000000000000ULL;
2963 RETURN();
2966 void OPPROTO op_efdabs (void)
2968 T0_64 &= ~0x8000000000000000ULL;
2969 RETURN();
2972 void OPPROTO op_efdneg (void)
2974 T0_64 ^= 0x8000000000000000ULL;
2975 RETURN();
2978 void OPPROTO op_efddiv (void)
2980 CPU_DoubleU u1, u2;
2981 u1.ll = T0_64;
2982 u2.ll = T1_64;
2983 u1.d = float64_div(u1.d, u2.d, &env->spe_status);
2984 T0_64 = u1.ll;
2985 RETURN();
2988 void OPPROTO op_efdmul (void)
2990 CPU_DoubleU u1, u2;
2991 u1.ll = T0_64;
2992 u2.ll = T1_64;
2993 u1.d = float64_mul(u1.d, u2.d, &env->spe_status);
2994 T0_64 = u1.ll;
2995 RETURN();
2998 void OPPROTO op_efdctsidz (void)
3000 do_efdctsiz();
3001 RETURN();
3004 void OPPROTO op_efdctuidz (void)
3006 do_efdctuiz();
3007 RETURN();
3010 void OPPROTO op_efdcmplt (void)
3012 do_efdcmplt();
3013 RETURN();
3016 void OPPROTO op_efdcmpgt (void)
3018 do_efdcmpgt();
3019 RETURN();
3022 void OPPROTO op_efdcfs (void)
3024 do_efdcfs();
3025 RETURN();
3028 void OPPROTO op_efdcmpeq (void)
3030 do_efdcmpeq();
3031 RETURN();
3034 void OPPROTO op_efdcfsi (void)
3036 do_efdcfsi();
3037 RETURN();
3040 void OPPROTO op_efdcfui (void)
3042 do_efdcfui();
3043 RETURN();
3046 void OPPROTO op_efdcfsf (void)
3048 do_efdcfsf();
3049 RETURN();
3052 void OPPROTO op_efdcfuf (void)
3054 do_efdcfuf();
3055 RETURN();
3058 void OPPROTO op_efdctsi (void)
3060 do_efdctsi();
3061 RETURN();
3064 void OPPROTO op_efdctui (void)
3066 do_efdctui();
3067 RETURN();
3070 void OPPROTO op_efdctsf (void)
3072 do_efdctsf();
3073 RETURN();
3076 void OPPROTO op_efdctuf (void)
3078 do_efdctuf();
3079 RETURN();
3082 void OPPROTO op_efdctuiz (void)
3084 do_efdctuiz();
3085 RETURN();
3088 void OPPROTO op_efdctsiz (void)
3090 do_efdctsiz();
3091 RETURN();
3094 void OPPROTO op_efdtstlt (void)
3096 T0 = _do_efdtstlt(T0_64, T1_64);
3097 RETURN();
3100 void OPPROTO op_efdtstgt (void)
3102 T0 = _do_efdtstgt(T0_64, T1_64);
3103 RETURN();
3106 void OPPROTO op_efdtsteq (void)
3108 T0 = _do_efdtsteq(T0_64, T1_64);
3109 RETURN();