5 Copyright (C) 2003-2005 Fabrice Bellard
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 Rest of V9 instructions, VIS instructions
26 NPC/PC static optimisations (use JUMP_TB when possible)
27 Optimize synthetic instructions
43 #define DYNAMIC_PC 1 /* dynamic pc value */
44 #define JUMP_PC 2 /* dynamic pc value which takes only two values
45 according to jump_pc[T2] */
47 typedef struct DisasContext {
48 target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */
49 target_ulong npc; /* next PC: integer or DYNAMIC_PC or JUMP_PC */
50 target_ulong jump_pc[2]; /* used when JUMP_PC pc value is used */
54 struct TranslationBlock *tb;
57 typedef struct sparc_def_t sparc_def_t;
60 const unsigned char *name;
61 target_ulong iu_version;
67 static const sparc_def_t *cpu_sparc_find_by_name(const unsigned char *name);
69 static uint16_t *gen_opc_ptr;
70 static uint32_t *gen_opparam_ptr;
75 #define DEF(s,n,copy_size) INDEX_op_ ## s,
83 // This function uses non-native bit order
84 #define GET_FIELD(X, FROM, TO) \
85 ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
87 // This function uses the order in the manuals, i.e. bit 0 is 2^0
88 #define GET_FIELD_SP(X, FROM, TO) \
89 GET_FIELD(X, 31 - (TO), 31 - (FROM))
91 #define GET_FIELDs(x,a,b) sign_extend (GET_FIELD(x,a,b), (b) - (a) + 1)
92 #define GET_FIELD_SPs(x,a,b) sign_extend (GET_FIELD_SP(x,a,b), ((b) - (a) + 1))
95 #define DFPREG(r) (((r & 1) << 5) | (r & 0x1e))
97 #define DFPREG(r) (r & 0x1e)
100 #ifdef USE_DIRECT_JUMP
103 #define TBPARAM(x) (long)(x)
106 static int sign_extend(int x, int len)
109 return (x << len) >> len;
112 #define IS_IMM (insn & (1<<13))
114 static void disas_sparc_insn(DisasContext * dc);
116 static GenOpFunc * const gen_op_movl_TN_reg[2][32] = {
187 static GenOpFunc * const gen_op_movl_reg_TN[3][32] = {
292 static GenOpFunc1 * const gen_op_movl_TN_im[3] = {
298 // Sign extending version
299 static GenOpFunc1 * const gen_op_movl_TN_sim[3] = {
305 #ifdef TARGET_SPARC64
306 #define GEN32(func, NAME) \
307 static GenOpFunc * const NAME ## _table [64] = { \
308 NAME ## 0, NAME ## 1, NAME ## 2, NAME ## 3, \
309 NAME ## 4, NAME ## 5, NAME ## 6, NAME ## 7, \
310 NAME ## 8, NAME ## 9, NAME ## 10, NAME ## 11, \
311 NAME ## 12, NAME ## 13, NAME ## 14, NAME ## 15, \
312 NAME ## 16, NAME ## 17, NAME ## 18, NAME ## 19, \
313 NAME ## 20, NAME ## 21, NAME ## 22, NAME ## 23, \
314 NAME ## 24, NAME ## 25, NAME ## 26, NAME ## 27, \
315 NAME ## 28, NAME ## 29, NAME ## 30, NAME ## 31, \
316 NAME ## 32, 0, NAME ## 34, 0, NAME ## 36, 0, NAME ## 38, 0, \
317 NAME ## 40, 0, NAME ## 42, 0, NAME ## 44, 0, NAME ## 46, 0, \
318 NAME ## 48, 0, NAME ## 50, 0, NAME ## 52, 0, NAME ## 54, 0, \
319 NAME ## 56, 0, NAME ## 58, 0, NAME ## 60, 0, NAME ## 62, 0, \
321 static inline void func(int n) \
323 NAME ## _table[n](); \
326 #define GEN32(func, NAME) \
327 static GenOpFunc *const NAME ## _table [32] = { \
328 NAME ## 0, NAME ## 1, NAME ## 2, NAME ## 3, \
329 NAME ## 4, NAME ## 5, NAME ## 6, NAME ## 7, \
330 NAME ## 8, NAME ## 9, NAME ## 10, NAME ## 11, \
331 NAME ## 12, NAME ## 13, NAME ## 14, NAME ## 15, \
332 NAME ## 16, NAME ## 17, NAME ## 18, NAME ## 19, \
333 NAME ## 20, NAME ## 21, NAME ## 22, NAME ## 23, \
334 NAME ## 24, NAME ## 25, NAME ## 26, NAME ## 27, \
335 NAME ## 28, NAME ## 29, NAME ## 30, NAME ## 31, \
337 static inline void func(int n) \
339 NAME ## _table[n](); \
343 /* floating point registers moves */
344 GEN32(gen_op_load_fpr_FT0, gen_op_load_fpr_FT0_fprf);
345 GEN32(gen_op_load_fpr_FT1, gen_op_load_fpr_FT1_fprf);
346 GEN32(gen_op_store_FT0_fpr, gen_op_store_FT0_fpr_fprf);
347 GEN32(gen_op_store_FT1_fpr, gen_op_store_FT1_fpr_fprf);
349 GEN32(gen_op_load_fpr_DT0, gen_op_load_fpr_DT0_fprf);
350 GEN32(gen_op_load_fpr_DT1, gen_op_load_fpr_DT1_fprf);
351 GEN32(gen_op_store_DT0_fpr, gen_op_store_DT0_fpr_fprf);
352 GEN32(gen_op_store_DT1_fpr, gen_op_store_DT1_fpr_fprf);
355 #ifdef CONFIG_USER_ONLY
356 #define supervisor(dc) 0
357 #ifdef TARGET_SPARC64
358 #define hypervisor(dc) 0
360 #define gen_op_ldst(name) gen_op_##name##_raw()
362 #define supervisor(dc) (dc->mem_idx >= 1)
363 #ifdef TARGET_SPARC64
364 #define hypervisor(dc) (dc->mem_idx == 2)
365 #define OP_LD_TABLE(width) \
366 static GenOpFunc * const gen_op_##width[] = { \
367 &gen_op_##width##_user, \
368 &gen_op_##width##_kernel, \
369 &gen_op_##width##_hypv, \
372 #define OP_LD_TABLE(width) \
373 static GenOpFunc * const gen_op_##width[] = { \
374 &gen_op_##width##_user, \
375 &gen_op_##width##_kernel, \
378 #define gen_op_ldst(name) (*gen_op_##name[dc->mem_idx])()
381 #ifndef CONFIG_USER_ONLY
399 #ifdef TARGET_SPARC64
408 #ifdef TARGET_SPARC64
409 static inline void gen_ld_asi(int insn, int size, int sign)
414 offset = GET_FIELD(insn, 25, 31);
415 gen_op_ld_asi_reg(offset, size, sign);
417 asi = GET_FIELD(insn, 19, 26);
418 gen_op_ld_asi(asi, size, sign);
422 static inline void gen_st_asi(int insn, int size)
427 offset = GET_FIELD(insn, 25, 31);
428 gen_op_st_asi_reg(offset, size);
430 asi = GET_FIELD(insn, 19, 26);
431 gen_op_st_asi(asi, size);
435 static inline void gen_ldf_asi(int insn, int size)
439 rd = DFPREG(GET_FIELD(insn, 2, 6));
441 offset = GET_FIELD(insn, 25, 31);
442 gen_op_ldf_asi_reg(offset, size, rd);
444 asi = GET_FIELD(insn, 19, 26);
445 gen_op_ldf_asi(asi, size, rd);
449 static inline void gen_stf_asi(int insn, int size)
453 rd = DFPREG(GET_FIELD(insn, 2, 6));
455 offset = GET_FIELD(insn, 25, 31);
456 gen_op_stf_asi_reg(offset, size, rd);
458 asi = GET_FIELD(insn, 19, 26);
459 gen_op_stf_asi(asi, size, rd);
463 static inline void gen_swap_asi(int insn)
468 offset = GET_FIELD(insn, 25, 31);
469 gen_op_swap_asi_reg(offset);
471 asi = GET_FIELD(insn, 19, 26);
472 gen_op_swap_asi(asi);
476 static inline void gen_ldstub_asi(int insn)
481 offset = GET_FIELD(insn, 25, 31);
482 gen_op_ldstub_asi_reg(offset);
484 asi = GET_FIELD(insn, 19, 26);
485 gen_op_ldstub_asi(asi);
489 static inline void gen_ldda_asi(int insn)
494 offset = GET_FIELD(insn, 25, 31);
495 gen_op_ldda_asi_reg(offset);
497 asi = GET_FIELD(insn, 19, 26);
498 gen_op_ldda_asi(asi);
502 static inline void gen_stda_asi(int insn)
507 offset = GET_FIELD(insn, 25, 31);
508 gen_op_stda_asi_reg(offset);
510 asi = GET_FIELD(insn, 19, 26);
511 gen_op_stda_asi(asi);
515 static inline void gen_cas_asi(int insn)
520 offset = GET_FIELD(insn, 25, 31);
521 gen_op_cas_asi_reg(offset);
523 asi = GET_FIELD(insn, 19, 26);
528 static inline void gen_casx_asi(int insn)
533 offset = GET_FIELD(insn, 25, 31);
534 gen_op_casx_asi_reg(offset);
536 asi = GET_FIELD(insn, 19, 26);
537 gen_op_casx_asi(asi);
541 #elif !defined(CONFIG_USER_ONLY)
543 static inline void gen_ld_asi(int insn, int size, int sign)
547 asi = GET_FIELD(insn, 19, 26);
548 gen_op_ld_asi(asi, size, sign);
551 static inline void gen_st_asi(int insn, int size)
555 asi = GET_FIELD(insn, 19, 26);
556 gen_op_st_asi(asi, size);
559 static inline void gen_ldstub_asi(int insn)
563 asi = GET_FIELD(insn, 19, 26);
564 gen_op_ldstub_asi(asi);
567 static inline void gen_swap_asi(int insn)
571 asi = GET_FIELD(insn, 19, 26);
572 gen_op_swap_asi(asi);
575 static inline void gen_ldda_asi(int insn)
579 asi = GET_FIELD(insn, 19, 26);
580 gen_op_ld_asi(asi, 8, 0);
583 static inline void gen_stda_asi(int insn)
587 asi = GET_FIELD(insn, 19, 26);
588 gen_op_st_asi(asi, 8);
592 static inline void gen_movl_imm_TN(int reg, uint32_t imm)
594 gen_op_movl_TN_im[reg](imm);
597 static inline void gen_movl_imm_T1(uint32_t val)
599 gen_movl_imm_TN(1, val);
602 static inline void gen_movl_imm_T0(uint32_t val)
604 gen_movl_imm_TN(0, val);
607 static inline void gen_movl_simm_TN(int reg, int32_t imm)
609 gen_op_movl_TN_sim[reg](imm);
612 static inline void gen_movl_simm_T1(int32_t val)
614 gen_movl_simm_TN(1, val);
617 static inline void gen_movl_simm_T0(int32_t val)
619 gen_movl_simm_TN(0, val);
622 static inline void gen_movl_reg_TN(int reg, int t)
625 gen_op_movl_reg_TN[t][reg] ();
627 gen_movl_imm_TN(t, 0);
630 static inline void gen_movl_reg_T0(int reg)
632 gen_movl_reg_TN(reg, 0);
635 static inline void gen_movl_reg_T1(int reg)
637 gen_movl_reg_TN(reg, 1);
640 static inline void gen_movl_reg_T2(int reg)
642 gen_movl_reg_TN(reg, 2);
645 static inline void gen_movl_TN_reg(int reg, int t)
648 gen_op_movl_TN_reg[t][reg] ();
651 static inline void gen_movl_T0_reg(int reg)
653 gen_movl_TN_reg(reg, 0);
656 static inline void gen_movl_T1_reg(int reg)
658 gen_movl_TN_reg(reg, 1);
661 static inline void gen_jmp_im(target_ulong pc)
663 #ifdef TARGET_SPARC64
664 if (pc == (uint32_t)pc) {
667 gen_op_jmp_im64(pc >> 32, pc);
674 static inline void gen_movl_npc_im(target_ulong npc)
676 #ifdef TARGET_SPARC64
677 if (npc == (uint32_t)npc) {
678 gen_op_movl_npc_im(npc);
680 gen_op_movq_npc_im64(npc >> 32, npc);
683 gen_op_movl_npc_im(npc);
687 static inline void gen_goto_tb(DisasContext *s, int tb_num,
688 target_ulong pc, target_ulong npc)
690 TranslationBlock *tb;
693 if ((pc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK) &&
694 (npc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK)) {
695 /* jump to same page: we can use a direct jump */
697 gen_op_goto_tb0(TBPARAM(tb));
699 gen_op_goto_tb1(TBPARAM(tb));
701 gen_movl_npc_im(npc);
702 gen_op_movl_T0_im((long)tb + tb_num);
705 /* jump to another page: currently not optimized */
707 gen_movl_npc_im(npc);
713 static inline void gen_branch2(DisasContext *dc, target_ulong pc1,
718 l1 = gen_new_label();
720 gen_op_jz_T2_label(l1);
722 gen_goto_tb(dc, 0, pc1, pc1 + 4);
725 gen_goto_tb(dc, 1, pc2, pc2 + 4);
728 static inline void gen_branch_a(DisasContext *dc, target_ulong pc1,
733 l1 = gen_new_label();
735 gen_op_jz_T2_label(l1);
737 gen_goto_tb(dc, 0, pc2, pc1);
740 gen_goto_tb(dc, 1, pc2 + 4, pc2 + 8);
743 static inline void gen_branch(DisasContext *dc, target_ulong pc,
746 gen_goto_tb(dc, 0, pc, npc);
749 static inline void gen_generic_branch(target_ulong npc1, target_ulong npc2)
753 l1 = gen_new_label();
754 l2 = gen_new_label();
755 gen_op_jz_T2_label(l1);
757 gen_movl_npc_im(npc1);
758 gen_op_jmp_label(l2);
761 gen_movl_npc_im(npc2);
765 /* call this function before using T2 as it may have been set for a jump */
766 static inline void flush_T2(DisasContext * dc)
768 if (dc->npc == JUMP_PC) {
769 gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1]);
770 dc->npc = DYNAMIC_PC;
774 static inline void save_npc(DisasContext * dc)
776 if (dc->npc == JUMP_PC) {
777 gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1]);
778 dc->npc = DYNAMIC_PC;
779 } else if (dc->npc != DYNAMIC_PC) {
780 gen_movl_npc_im(dc->npc);
784 static inline void save_state(DisasContext * dc)
790 static inline void gen_mov_pc_npc(DisasContext * dc)
792 if (dc->npc == JUMP_PC) {
793 gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1]);
796 } else if (dc->npc == DYNAMIC_PC) {
804 static GenOpFunc * const gen_cond[2][16] = {
824 #ifdef TARGET_SPARC64
845 static GenOpFunc * const gen_fcond[4][16] = {
864 #ifdef TARGET_SPARC64
867 gen_op_eval_fbne_fcc1,
868 gen_op_eval_fblg_fcc1,
869 gen_op_eval_fbul_fcc1,
870 gen_op_eval_fbl_fcc1,
871 gen_op_eval_fbug_fcc1,
872 gen_op_eval_fbg_fcc1,
873 gen_op_eval_fbu_fcc1,
875 gen_op_eval_fbe_fcc1,
876 gen_op_eval_fbue_fcc1,
877 gen_op_eval_fbge_fcc1,
878 gen_op_eval_fbuge_fcc1,
879 gen_op_eval_fble_fcc1,
880 gen_op_eval_fbule_fcc1,
881 gen_op_eval_fbo_fcc1,
885 gen_op_eval_fbne_fcc2,
886 gen_op_eval_fblg_fcc2,
887 gen_op_eval_fbul_fcc2,
888 gen_op_eval_fbl_fcc2,
889 gen_op_eval_fbug_fcc2,
890 gen_op_eval_fbg_fcc2,
891 gen_op_eval_fbu_fcc2,
893 gen_op_eval_fbe_fcc2,
894 gen_op_eval_fbue_fcc2,
895 gen_op_eval_fbge_fcc2,
896 gen_op_eval_fbuge_fcc2,
897 gen_op_eval_fble_fcc2,
898 gen_op_eval_fbule_fcc2,
899 gen_op_eval_fbo_fcc2,
903 gen_op_eval_fbne_fcc3,
904 gen_op_eval_fblg_fcc3,
905 gen_op_eval_fbul_fcc3,
906 gen_op_eval_fbl_fcc3,
907 gen_op_eval_fbug_fcc3,
908 gen_op_eval_fbg_fcc3,
909 gen_op_eval_fbu_fcc3,
911 gen_op_eval_fbe_fcc3,
912 gen_op_eval_fbue_fcc3,
913 gen_op_eval_fbge_fcc3,
914 gen_op_eval_fbuge_fcc3,
915 gen_op_eval_fble_fcc3,
916 gen_op_eval_fbule_fcc3,
917 gen_op_eval_fbo_fcc3,
924 #ifdef TARGET_SPARC64
925 static void gen_cond_reg(int cond)
951 /* XXX: potentially incorrect if dynamic npc */
952 static void do_branch(DisasContext * dc, int32_t offset, uint32_t insn, int cc)
954 unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
955 target_ulong target = dc->pc + offset;
958 /* unconditional not taken */
960 dc->pc = dc->npc + 4;
961 dc->npc = dc->pc + 4;
964 dc->npc = dc->pc + 4;
966 } else if (cond == 0x8) {
967 /* unconditional taken */
970 dc->npc = dc->pc + 4;
977 gen_cond[cc][cond]();
979 gen_branch_a(dc, target, dc->npc);
983 dc->jump_pc[0] = target;
984 dc->jump_pc[1] = dc->npc + 4;
990 /* XXX: potentially incorrect if dynamic npc */
991 static void do_fbranch(DisasContext * dc, int32_t offset, uint32_t insn, int cc)
993 unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
994 target_ulong target = dc->pc + offset;
997 /* unconditional not taken */
999 dc->pc = dc->npc + 4;
1000 dc->npc = dc->pc + 4;
1003 dc->npc = dc->pc + 4;
1005 } else if (cond == 0x8) {
1006 /* unconditional taken */
1009 dc->npc = dc->pc + 4;
1016 gen_fcond[cc][cond]();
1018 gen_branch_a(dc, target, dc->npc);
1022 dc->jump_pc[0] = target;
1023 dc->jump_pc[1] = dc->npc + 4;
1029 #ifdef TARGET_SPARC64
1030 /* XXX: potentially incorrect if dynamic npc */
1031 static void do_branch_reg(DisasContext * dc, int32_t offset, uint32_t insn)
1033 unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29));
1034 target_ulong target = dc->pc + offset;
1039 gen_branch_a(dc, target, dc->npc);
1043 dc->jump_pc[0] = target;
1044 dc->jump_pc[1] = dc->npc + 4;
1049 static GenOpFunc * const gen_fcmps[4] = {
1056 static GenOpFunc * const gen_fcmpd[4] = {
1063 static GenOpFunc * const gen_fcmpes[4] = {
1070 static GenOpFunc * const gen_fcmped[4] = {
1079 static int gen_trap_ifnofpu(DisasContext * dc)
1081 #if !defined(CONFIG_USER_ONLY)
1082 if (!dc->fpu_enabled) {
1084 gen_op_exception(TT_NFPU_INSN);
1092 /* before an instruction, dc->pc must be static */
1093 static void disas_sparc_insn(DisasContext * dc)
1095 unsigned int insn, opc, rs1, rs2, rd;
1097 insn = ldl_code(dc->pc);
1098 opc = GET_FIELD(insn, 0, 1);
1100 rd = GET_FIELD(insn, 2, 6);
1102 case 0: /* branches/sethi */
1104 unsigned int xop = GET_FIELD(insn, 7, 9);
1107 #ifdef TARGET_SPARC64
1108 case 0x1: /* V9 BPcc */
1112 target = GET_FIELD_SP(insn, 0, 18);
1113 target = sign_extend(target, 18);
1115 cc = GET_FIELD_SP(insn, 20, 21);
1117 do_branch(dc, target, insn, 0);
1119 do_branch(dc, target, insn, 1);
1124 case 0x3: /* V9 BPr */
1126 target = GET_FIELD_SP(insn, 0, 13) |
1127 (GET_FIELD_SP(insn, 20, 21) << 14);
1128 target = sign_extend(target, 16);
1130 rs1 = GET_FIELD(insn, 13, 17);
1131 gen_movl_reg_T0(rs1);
1132 do_branch_reg(dc, target, insn);
1135 case 0x5: /* V9 FBPcc */
1137 int cc = GET_FIELD_SP(insn, 20, 21);
1138 if (gen_trap_ifnofpu(dc))
1140 target = GET_FIELD_SP(insn, 0, 18);
1141 target = sign_extend(target, 19);
1143 do_fbranch(dc, target, insn, cc);
1147 case 0x7: /* CBN+x */
1152 case 0x2: /* BN+x */
1154 target = GET_FIELD(insn, 10, 31);
1155 target = sign_extend(target, 22);
1157 do_branch(dc, target, insn, 0);
1160 case 0x6: /* FBN+x */
1162 if (gen_trap_ifnofpu(dc))
1164 target = GET_FIELD(insn, 10, 31);
1165 target = sign_extend(target, 22);
1167 do_fbranch(dc, target, insn, 0);
1170 case 0x4: /* SETHI */
1175 uint32_t value = GET_FIELD(insn, 10, 31);
1176 gen_movl_imm_T0(value << 10);
1177 gen_movl_T0_reg(rd);
1182 case 0x0: /* UNIMPL */
1191 target_long target = GET_FIELDs(insn, 2, 31) << 2;
1193 #ifdef TARGET_SPARC64
1194 if (dc->pc == (uint32_t)dc->pc) {
1195 gen_op_movl_T0_im(dc->pc);
1197 gen_op_movq_T0_im64(dc->pc >> 32, dc->pc);
1200 gen_op_movl_T0_im(dc->pc);
1202 gen_movl_T0_reg(15);
1208 case 2: /* FPU & Logical Operations */
1210 unsigned int xop = GET_FIELD(insn, 7, 12);
1211 if (xop == 0x3a) { /* generate trap */
1214 rs1 = GET_FIELD(insn, 13, 17);
1215 gen_movl_reg_T0(rs1);
1217 rs2 = GET_FIELD(insn, 25, 31);
1221 gen_movl_simm_T1(rs2);
1227 rs2 = GET_FIELD(insn, 27, 31);
1231 gen_movl_reg_T1(rs2);
1237 cond = GET_FIELD(insn, 3, 6);
1241 } else if (cond != 0) {
1242 #ifdef TARGET_SPARC64
1244 int cc = GET_FIELD_SP(insn, 11, 12);
1248 gen_cond[0][cond]();
1250 gen_cond[1][cond]();
1256 gen_cond[0][cond]();
1265 } else if (xop == 0x28) {
1266 rs1 = GET_FIELD(insn, 13, 17);
1269 #ifndef TARGET_SPARC64
1270 case 0x01 ... 0x0e: /* undefined in the SPARCv8
1271 manual, rdy on the microSPARC
1273 case 0x0f: /* stbar in the SPARCv8 manual,
1274 rdy on the microSPARC II */
1275 case 0x10 ... 0x1f: /* implementation-dependent in the
1276 SPARCv8 manual, rdy on the
1279 gen_op_movtl_T0_env(offsetof(CPUSPARCState, y));
1280 gen_movl_T0_reg(rd);
1282 #ifdef TARGET_SPARC64
1283 case 0x2: /* V9 rdccr */
1285 gen_movl_T0_reg(rd);
1287 case 0x3: /* V9 rdasi */
1288 gen_op_movl_T0_env(offsetof(CPUSPARCState, asi));
1289 gen_movl_T0_reg(rd);
1291 case 0x4: /* V9 rdtick */
1293 gen_movl_T0_reg(rd);
1295 case 0x5: /* V9 rdpc */
1296 if (dc->pc == (uint32_t)dc->pc) {
1297 gen_op_movl_T0_im(dc->pc);
1299 gen_op_movq_T0_im64(dc->pc >> 32, dc->pc);
1301 gen_movl_T0_reg(rd);
1303 case 0x6: /* V9 rdfprs */
1304 gen_op_movl_T0_env(offsetof(CPUSPARCState, fprs));
1305 gen_movl_T0_reg(rd);
1307 case 0xf: /* V9 membar */
1308 break; /* no effect */
1309 case 0x13: /* Graphics Status */
1310 if (gen_trap_ifnofpu(dc))
1312 gen_op_movtl_T0_env(offsetof(CPUSPARCState, gsr));
1313 gen_movl_T0_reg(rd);
1315 case 0x17: /* Tick compare */
1316 gen_op_movtl_T0_env(offsetof(CPUSPARCState, tick_cmpr));
1317 gen_movl_T0_reg(rd);
1319 case 0x18: /* System tick */
1321 gen_movl_T0_reg(rd);
1323 case 0x19: /* System tick compare */
1324 gen_op_movtl_T0_env(offsetof(CPUSPARCState, stick_cmpr));
1325 gen_movl_T0_reg(rd);
1327 case 0x10: /* Performance Control */
1328 case 0x11: /* Performance Instrumentation Counter */
1329 case 0x12: /* Dispatch Control */
1330 case 0x14: /* Softint set, WO */
1331 case 0x15: /* Softint clear, WO */
1332 case 0x16: /* Softint write */
1337 #if !defined(CONFIG_USER_ONLY)
1338 } else if (xop == 0x29) { /* rdpsr / UA2005 rdhpr */
1339 #ifndef TARGET_SPARC64
1340 if (!supervisor(dc))
1344 if (!hypervisor(dc))
1346 rs1 = GET_FIELD(insn, 13, 17);
1349 // gen_op_rdhpstate();
1352 // gen_op_rdhtstate();
1355 gen_op_movl_T0_env(offsetof(CPUSPARCState, hintp));
1358 gen_op_movl_T0_env(offsetof(CPUSPARCState, htba));
1361 gen_op_movl_T0_env(offsetof(CPUSPARCState, hver));
1363 case 31: // hstick_cmpr
1364 gen_op_movl_env_T0(offsetof(CPUSPARCState, hstick_cmpr));
1370 gen_movl_T0_reg(rd);
1372 } else if (xop == 0x2a) { /* rdwim / V9 rdpr */
1373 if (!supervisor(dc))
1375 #ifdef TARGET_SPARC64
1376 rs1 = GET_FIELD(insn, 13, 17);
1394 gen_op_movtl_T0_env(offsetof(CPUSPARCState, tbr));
1400 gen_op_movl_T0_env(offsetof(CPUSPARCState, tl));
1403 gen_op_movl_T0_env(offsetof(CPUSPARCState, psrpil));
1409 gen_op_movl_T0_env(offsetof(CPUSPARCState, cansave));
1411 case 11: // canrestore
1412 gen_op_movl_T0_env(offsetof(CPUSPARCState, canrestore));
1414 case 12: // cleanwin
1415 gen_op_movl_T0_env(offsetof(CPUSPARCState, cleanwin));
1417 case 13: // otherwin
1418 gen_op_movl_T0_env(offsetof(CPUSPARCState, otherwin));
1421 gen_op_movl_T0_env(offsetof(CPUSPARCState, wstate));
1423 case 16: // UA2005 gl
1424 gen_op_movl_T0_env(offsetof(CPUSPARCState, gl));
1426 case 26: // UA2005 strand status
1427 if (!hypervisor(dc))
1429 gen_op_movl_T0_env(offsetof(CPUSPARCState, ssr));
1432 gen_op_movtl_T0_env(offsetof(CPUSPARCState, version));
1439 gen_op_movl_T0_env(offsetof(CPUSPARCState, wim));
1441 gen_movl_T0_reg(rd);
1443 } else if (xop == 0x2b) { /* rdtbr / V9 flushw */
1444 #ifdef TARGET_SPARC64
1447 if (!supervisor(dc))
1449 gen_op_movtl_T0_env(offsetof(CPUSPARCState, tbr));
1450 gen_movl_T0_reg(rd);
1454 } else if (xop == 0x34) { /* FPU Operations */
1455 if (gen_trap_ifnofpu(dc))
1457 gen_op_clear_ieee_excp_and_FTT();
1458 rs1 = GET_FIELD(insn, 13, 17);
1459 rs2 = GET_FIELD(insn, 27, 31);
1460 xop = GET_FIELD(insn, 18, 26);
1462 case 0x1: /* fmovs */
1463 gen_op_load_fpr_FT0(rs2);
1464 gen_op_store_FT0_fpr(rd);
1466 case 0x5: /* fnegs */
1467 gen_op_load_fpr_FT1(rs2);
1469 gen_op_store_FT0_fpr(rd);
1471 case 0x9: /* fabss */
1472 gen_op_load_fpr_FT1(rs2);
1474 gen_op_store_FT0_fpr(rd);
1476 case 0x29: /* fsqrts */
1477 gen_op_load_fpr_FT1(rs2);
1479 gen_op_store_FT0_fpr(rd);
1481 case 0x2a: /* fsqrtd */
1482 gen_op_load_fpr_DT1(DFPREG(rs2));
1484 gen_op_store_DT0_fpr(DFPREG(rd));
1486 case 0x2b: /* fsqrtq */
1489 gen_op_load_fpr_FT0(rs1);
1490 gen_op_load_fpr_FT1(rs2);
1492 gen_op_store_FT0_fpr(rd);
1495 gen_op_load_fpr_DT0(DFPREG(rs1));
1496 gen_op_load_fpr_DT1(DFPREG(rs2));
1498 gen_op_store_DT0_fpr(DFPREG(rd));
1500 case 0x43: /* faddq */
1503 gen_op_load_fpr_FT0(rs1);
1504 gen_op_load_fpr_FT1(rs2);
1506 gen_op_store_FT0_fpr(rd);
1509 gen_op_load_fpr_DT0(DFPREG(rs1));
1510 gen_op_load_fpr_DT1(DFPREG(rs2));
1512 gen_op_store_DT0_fpr(DFPREG(rd));
1514 case 0x47: /* fsubq */
1517 gen_op_load_fpr_FT0(rs1);
1518 gen_op_load_fpr_FT1(rs2);
1520 gen_op_store_FT0_fpr(rd);
1523 gen_op_load_fpr_DT0(DFPREG(rs1));
1524 gen_op_load_fpr_DT1(DFPREG(rs2));
1526 gen_op_store_DT0_fpr(rd);
1528 case 0x4b: /* fmulq */
1531 gen_op_load_fpr_FT0(rs1);
1532 gen_op_load_fpr_FT1(rs2);
1534 gen_op_store_FT0_fpr(rd);
1537 gen_op_load_fpr_DT0(DFPREG(rs1));
1538 gen_op_load_fpr_DT1(DFPREG(rs2));
1540 gen_op_store_DT0_fpr(DFPREG(rd));
1542 case 0x4f: /* fdivq */
1545 gen_op_load_fpr_FT0(rs1);
1546 gen_op_load_fpr_FT1(rs2);
1548 gen_op_store_DT0_fpr(DFPREG(rd));
1550 case 0x6e: /* fdmulq */
1553 gen_op_load_fpr_FT1(rs2);
1555 gen_op_store_FT0_fpr(rd);
1558 gen_op_load_fpr_DT1(DFPREG(rs2));
1560 gen_op_store_FT0_fpr(rd);
1562 case 0xc7: /* fqtos */
1565 gen_op_load_fpr_FT1(rs2);
1567 gen_op_store_DT0_fpr(DFPREG(rd));
1570 gen_op_load_fpr_FT1(rs2);
1572 gen_op_store_DT0_fpr(DFPREG(rd));
1574 case 0xcb: /* fqtod */
1576 case 0xcc: /* fitoq */
1578 case 0xcd: /* fstoq */
1580 case 0xce: /* fdtoq */
1583 gen_op_load_fpr_FT1(rs2);
1585 gen_op_store_FT0_fpr(rd);
1588 gen_op_load_fpr_DT1(rs2);
1590 gen_op_store_FT0_fpr(rd);
1592 case 0xd3: /* fqtoi */
1594 #ifdef TARGET_SPARC64
1595 case 0x2: /* V9 fmovd */
1596 gen_op_load_fpr_DT0(DFPREG(rs2));
1597 gen_op_store_DT0_fpr(DFPREG(rd));
1599 case 0x6: /* V9 fnegd */
1600 gen_op_load_fpr_DT1(DFPREG(rs2));
1602 gen_op_store_DT0_fpr(DFPREG(rd));
1604 case 0xa: /* V9 fabsd */
1605 gen_op_load_fpr_DT1(DFPREG(rs2));
1607 gen_op_store_DT0_fpr(DFPREG(rd));
1609 case 0x81: /* V9 fstox */
1610 gen_op_load_fpr_FT1(rs2);
1612 gen_op_store_DT0_fpr(DFPREG(rd));
1614 case 0x82: /* V9 fdtox */
1615 gen_op_load_fpr_DT1(DFPREG(rs2));
1617 gen_op_store_DT0_fpr(DFPREG(rd));
1619 case 0x84: /* V9 fxtos */
1620 gen_op_load_fpr_DT1(DFPREG(rs2));
1622 gen_op_store_FT0_fpr(rd);
1624 case 0x88: /* V9 fxtod */
1625 gen_op_load_fpr_DT1(DFPREG(rs2));
1627 gen_op_store_DT0_fpr(DFPREG(rd));
1629 case 0x3: /* V9 fmovq */
1630 case 0x7: /* V9 fnegq */
1631 case 0xb: /* V9 fabsq */
1632 case 0x83: /* V9 fqtox */
1633 case 0x8c: /* V9 fxtoq */
1639 } else if (xop == 0x35) { /* FPU Operations */
1640 #ifdef TARGET_SPARC64
1643 if (gen_trap_ifnofpu(dc))
1645 gen_op_clear_ieee_excp_and_FTT();
1646 rs1 = GET_FIELD(insn, 13, 17);
1647 rs2 = GET_FIELD(insn, 27, 31);
1648 xop = GET_FIELD(insn, 18, 26);
1649 #ifdef TARGET_SPARC64
1650 if ((xop & 0x11f) == 0x005) { // V9 fmovsr
1651 cond = GET_FIELD_SP(insn, 14, 17);
1652 gen_op_load_fpr_FT0(rd);
1653 gen_op_load_fpr_FT1(rs2);
1654 rs1 = GET_FIELD(insn, 13, 17);
1655 gen_movl_reg_T0(rs1);
1659 gen_op_store_FT0_fpr(rd);
1661 } else if ((xop & 0x11f) == 0x006) { // V9 fmovdr
1662 cond = GET_FIELD_SP(insn, 14, 17);
1663 gen_op_load_fpr_DT0(rd);
1664 gen_op_load_fpr_DT1(rs2);
1666 rs1 = GET_FIELD(insn, 13, 17);
1667 gen_movl_reg_T0(rs1);
1670 gen_op_store_DT0_fpr(rd);
1672 } else if ((xop & 0x11f) == 0x007) { // V9 fmovqr
1677 #ifdef TARGET_SPARC64
1678 case 0x001: /* V9 fmovscc %fcc0 */
1679 cond = GET_FIELD_SP(insn, 14, 17);
1680 gen_op_load_fpr_FT0(rd);
1681 gen_op_load_fpr_FT1(rs2);
1683 gen_fcond[0][cond]();
1685 gen_op_store_FT0_fpr(rd);
1687 case 0x002: /* V9 fmovdcc %fcc0 */
1688 cond = GET_FIELD_SP(insn, 14, 17);
1689 gen_op_load_fpr_DT0(rd);
1690 gen_op_load_fpr_DT1(rs2);
1692 gen_fcond[0][cond]();
1694 gen_op_store_DT0_fpr(rd);
1696 case 0x003: /* V9 fmovqcc %fcc0 */
1698 case 0x041: /* V9 fmovscc %fcc1 */
1699 cond = GET_FIELD_SP(insn, 14, 17);
1700 gen_op_load_fpr_FT0(rd);
1701 gen_op_load_fpr_FT1(rs2);
1703 gen_fcond[1][cond]();
1705 gen_op_store_FT0_fpr(rd);
1707 case 0x042: /* V9 fmovdcc %fcc1 */
1708 cond = GET_FIELD_SP(insn, 14, 17);
1709 gen_op_load_fpr_DT0(rd);
1710 gen_op_load_fpr_DT1(rs2);
1712 gen_fcond[1][cond]();
1714 gen_op_store_DT0_fpr(rd);
1716 case 0x043: /* V9 fmovqcc %fcc1 */
1718 case 0x081: /* V9 fmovscc %fcc2 */
1719 cond = GET_FIELD_SP(insn, 14, 17);
1720 gen_op_load_fpr_FT0(rd);
1721 gen_op_load_fpr_FT1(rs2);
1723 gen_fcond[2][cond]();
1725 gen_op_store_FT0_fpr(rd);
1727 case 0x082: /* V9 fmovdcc %fcc2 */
1728 cond = GET_FIELD_SP(insn, 14, 17);
1729 gen_op_load_fpr_DT0(rd);
1730 gen_op_load_fpr_DT1(rs2);
1732 gen_fcond[2][cond]();
1734 gen_op_store_DT0_fpr(rd);
1736 case 0x083: /* V9 fmovqcc %fcc2 */
1738 case 0x0c1: /* V9 fmovscc %fcc3 */
1739 cond = GET_FIELD_SP(insn, 14, 17);
1740 gen_op_load_fpr_FT0(rd);
1741 gen_op_load_fpr_FT1(rs2);
1743 gen_fcond[3][cond]();
1745 gen_op_store_FT0_fpr(rd);
1747 case 0x0c2: /* V9 fmovdcc %fcc3 */
1748 cond = GET_FIELD_SP(insn, 14, 17);
1749 gen_op_load_fpr_DT0(rd);
1750 gen_op_load_fpr_DT1(rs2);
1752 gen_fcond[3][cond]();
1754 gen_op_store_DT0_fpr(rd);
1756 case 0x0c3: /* V9 fmovqcc %fcc3 */
1758 case 0x101: /* V9 fmovscc %icc */
1759 cond = GET_FIELD_SP(insn, 14, 17);
1760 gen_op_load_fpr_FT0(rd);
1761 gen_op_load_fpr_FT1(rs2);
1763 gen_cond[0][cond]();
1765 gen_op_store_FT0_fpr(rd);
1767 case 0x102: /* V9 fmovdcc %icc */
1768 cond = GET_FIELD_SP(insn, 14, 17);
1769 gen_op_load_fpr_DT0(rd);
1770 gen_op_load_fpr_DT1(rs2);
1772 gen_cond[0][cond]();
1774 gen_op_store_DT0_fpr(rd);
1776 case 0x103: /* V9 fmovqcc %icc */
1778 case 0x181: /* V9 fmovscc %xcc */
1779 cond = GET_FIELD_SP(insn, 14, 17);
1780 gen_op_load_fpr_FT0(rd);
1781 gen_op_load_fpr_FT1(rs2);
1783 gen_cond[1][cond]();
1785 gen_op_store_FT0_fpr(rd);
1787 case 0x182: /* V9 fmovdcc %xcc */
1788 cond = GET_FIELD_SP(insn, 14, 17);
1789 gen_op_load_fpr_DT0(rd);
1790 gen_op_load_fpr_DT1(rs2);
1792 gen_cond[1][cond]();
1794 gen_op_store_DT0_fpr(rd);
1796 case 0x183: /* V9 fmovqcc %xcc */
1799 case 0x51: /* V9 %fcc */
1800 gen_op_load_fpr_FT0(rs1);
1801 gen_op_load_fpr_FT1(rs2);
1802 #ifdef TARGET_SPARC64
1803 gen_fcmps[rd & 3]();
1808 case 0x52: /* V9 %fcc */
1809 gen_op_load_fpr_DT0(DFPREG(rs1));
1810 gen_op_load_fpr_DT1(DFPREG(rs2));
1811 #ifdef TARGET_SPARC64
1812 gen_fcmpd[rd & 3]();
1817 case 0x53: /* fcmpq */
1819 case 0x55: /* fcmpes, V9 %fcc */
1820 gen_op_load_fpr_FT0(rs1);
1821 gen_op_load_fpr_FT1(rs2);
1822 #ifdef TARGET_SPARC64
1823 gen_fcmpes[rd & 3]();
1828 case 0x56: /* fcmped, V9 %fcc */
1829 gen_op_load_fpr_DT0(DFPREG(rs1));
1830 gen_op_load_fpr_DT1(DFPREG(rs2));
1831 #ifdef TARGET_SPARC64
1832 gen_fcmped[rd & 3]();
1837 case 0x57: /* fcmpeq */
1843 } else if (xop == 0x2) {
1846 rs1 = GET_FIELD(insn, 13, 17);
1848 // or %g0, x, y -> mov T1, x; mov y, T1
1849 if (IS_IMM) { /* immediate */
1850 rs2 = GET_FIELDs(insn, 19, 31);
1851 gen_movl_simm_T1(rs2);
1852 } else { /* register */
1853 rs2 = GET_FIELD(insn, 27, 31);
1854 gen_movl_reg_T1(rs2);
1856 gen_movl_T1_reg(rd);
1858 gen_movl_reg_T0(rs1);
1859 if (IS_IMM) { /* immediate */
1860 // or x, #0, y -> mov T1, x; mov y, T1
1861 rs2 = GET_FIELDs(insn, 19, 31);
1863 gen_movl_simm_T1(rs2);
1866 } else { /* register */
1867 // or x, %g0, y -> mov T1, x; mov y, T1
1868 rs2 = GET_FIELD(insn, 27, 31);
1870 gen_movl_reg_T1(rs2);
1874 gen_movl_T0_reg(rd);
1877 #ifdef TARGET_SPARC64
1878 } else if (xop == 0x25) { /* sll, V9 sllx */
1879 rs1 = GET_FIELD(insn, 13, 17);
1880 gen_movl_reg_T0(rs1);
1881 if (IS_IMM) { /* immediate */
1882 rs2 = GET_FIELDs(insn, 20, 31);
1883 gen_movl_simm_T1(rs2);
1884 } else { /* register */
1885 rs2 = GET_FIELD(insn, 27, 31);
1886 gen_movl_reg_T1(rs2);
1888 if (insn & (1 << 12))
1892 gen_movl_T0_reg(rd);
1893 } else if (xop == 0x26) { /* srl, V9 srlx */
1894 rs1 = GET_FIELD(insn, 13, 17);
1895 gen_movl_reg_T0(rs1);
1896 if (IS_IMM) { /* immediate */
1897 rs2 = GET_FIELDs(insn, 20, 31);
1898 gen_movl_simm_T1(rs2);
1899 } else { /* register */
1900 rs2 = GET_FIELD(insn, 27, 31);
1901 gen_movl_reg_T1(rs2);
1903 if (insn & (1 << 12))
1907 gen_movl_T0_reg(rd);
1908 } else if (xop == 0x27) { /* sra, V9 srax */
1909 rs1 = GET_FIELD(insn, 13, 17);
1910 gen_movl_reg_T0(rs1);
1911 if (IS_IMM) { /* immediate */
1912 rs2 = GET_FIELDs(insn, 20, 31);
1913 gen_movl_simm_T1(rs2);
1914 } else { /* register */
1915 rs2 = GET_FIELD(insn, 27, 31);
1916 gen_movl_reg_T1(rs2);
1918 if (insn & (1 << 12))
1922 gen_movl_T0_reg(rd);
1924 } else if (xop < 0x36) {
1925 rs1 = GET_FIELD(insn, 13, 17);
1926 gen_movl_reg_T0(rs1);
1927 if (IS_IMM) { /* immediate */
1928 rs2 = GET_FIELDs(insn, 19, 31);
1929 gen_movl_simm_T1(rs2);
1930 } else { /* register */
1931 rs2 = GET_FIELD(insn, 27, 31);
1932 gen_movl_reg_T1(rs2);
1935 switch (xop & ~0x10) {
1938 gen_op_add_T1_T0_cc();
1945 gen_op_logic_T0_cc();
1950 gen_op_logic_T0_cc();
1955 gen_op_logic_T0_cc();
1959 gen_op_sub_T1_T0_cc();
1964 gen_op_andn_T1_T0();
1966 gen_op_logic_T0_cc();
1971 gen_op_logic_T0_cc();
1974 gen_op_xnor_T1_T0();
1976 gen_op_logic_T0_cc();
1980 gen_op_addx_T1_T0_cc();
1982 gen_op_addx_T1_T0();
1984 #ifdef TARGET_SPARC64
1985 case 0x9: /* V9 mulx */
1986 gen_op_mulx_T1_T0();
1990 gen_op_umul_T1_T0();
1992 gen_op_logic_T0_cc();
1995 gen_op_smul_T1_T0();
1997 gen_op_logic_T0_cc();
2001 gen_op_subx_T1_T0_cc();
2003 gen_op_subx_T1_T0();
2005 #ifdef TARGET_SPARC64
2006 case 0xd: /* V9 udivx */
2007 gen_op_udivx_T1_T0();
2011 gen_op_udiv_T1_T0();
2016 gen_op_sdiv_T1_T0();
2023 gen_movl_T0_reg(rd);
2026 case 0x20: /* taddcc */
2027 gen_op_tadd_T1_T0_cc();
2028 gen_movl_T0_reg(rd);
2030 case 0x21: /* tsubcc */
2031 gen_op_tsub_T1_T0_cc();
2032 gen_movl_T0_reg(rd);
2034 case 0x22: /* taddcctv */
2036 gen_op_tadd_T1_T0_ccTV();
2037 gen_movl_T0_reg(rd);
2039 case 0x23: /* tsubcctv */
2041 gen_op_tsub_T1_T0_ccTV();
2042 gen_movl_T0_reg(rd);
2044 case 0x24: /* mulscc */
2045 gen_op_mulscc_T1_T0();
2046 gen_movl_T0_reg(rd);
2048 #ifndef TARGET_SPARC64
2049 case 0x25: /* sll */
2051 gen_movl_T0_reg(rd);
2053 case 0x26: /* srl */
2055 gen_movl_T0_reg(rd);
2057 case 0x27: /* sra */
2059 gen_movl_T0_reg(rd);
2067 gen_op_movtl_env_T0(offsetof(CPUSPARCState, y));
2069 #ifndef TARGET_SPARC64
2070 case 0x01 ... 0x0f: /* undefined in the
2074 case 0x10 ... 0x1f: /* implementation-dependent
2080 case 0x2: /* V9 wrccr */
2084 case 0x3: /* V9 wrasi */
2086 gen_op_movl_env_T0(offsetof(CPUSPARCState, asi));
2088 case 0x6: /* V9 wrfprs */
2090 gen_op_movl_env_T0(offsetof(CPUSPARCState, fprs));
2097 case 0xf: /* V9 sir, nop if user */
2098 #if !defined(CONFIG_USER_ONLY)
2103 case 0x13: /* Graphics Status */
2104 if (gen_trap_ifnofpu(dc))
2107 gen_op_movtl_env_T0(offsetof(CPUSPARCState, gsr));
2109 case 0x17: /* Tick compare */
2110 #if !defined(CONFIG_USER_ONLY)
2111 if (!supervisor(dc))
2115 gen_op_movtl_env_T0(offsetof(CPUSPARCState, tick_cmpr));
2116 gen_op_wrtick_cmpr();
2118 case 0x18: /* System tick */
2119 #if !defined(CONFIG_USER_ONLY)
2120 if (!supervisor(dc))
2126 case 0x19: /* System tick compare */
2127 #if !defined(CONFIG_USER_ONLY)
2128 if (!supervisor(dc))
2132 gen_op_movtl_env_T0(offsetof(CPUSPARCState, stick_cmpr));
2133 gen_op_wrstick_cmpr();
2136 case 0x10: /* Performance Control */
2137 case 0x11: /* Performance Instrumentation Counter */
2138 case 0x12: /* Dispatch Control */
2139 case 0x14: /* Softint set */
2140 case 0x15: /* Softint clear */
2141 case 0x16: /* Softint write */
2148 #if !defined(CONFIG_USER_ONLY)
2149 case 0x31: /* wrpsr, V9 saved, restored */
2151 if (!supervisor(dc))
2153 #ifdef TARGET_SPARC64
2161 case 2: /* UA2005 allclean */
2162 case 3: /* UA2005 otherw */
2163 case 4: /* UA2005 normalw */
2164 case 5: /* UA2005 invalw */
2180 case 0x32: /* wrwim, V9 wrpr */
2182 if (!supervisor(dc))
2185 #ifdef TARGET_SPARC64
2203 gen_op_movtl_env_T0(offsetof(CPUSPARCState, tbr));
2214 gen_op_movl_env_T0(offsetof(CPUSPARCState, tl));
2217 gen_op_movl_env_T0(offsetof(CPUSPARCState, psrpil));
2223 gen_op_movl_env_T0(offsetof(CPUSPARCState, cansave));
2225 case 11: // canrestore
2226 gen_op_movl_env_T0(offsetof(CPUSPARCState, canrestore));
2228 case 12: // cleanwin
2229 gen_op_movl_env_T0(offsetof(CPUSPARCState, cleanwin));
2231 case 13: // otherwin
2232 gen_op_movl_env_T0(offsetof(CPUSPARCState, otherwin));
2235 gen_op_movl_env_T0(offsetof(CPUSPARCState, wstate));
2237 case 16: // UA2005 gl
2238 gen_op_movl_env_T0(offsetof(CPUSPARCState, gl));
2240 case 26: // UA2005 strand status
2241 if (!hypervisor(dc))
2243 gen_op_movl_env_T0(offsetof(CPUSPARCState, ssr));
2253 case 0x33: /* wrtbr, UA2005 wrhpr */
2255 #ifndef TARGET_SPARC64
2256 if (!supervisor(dc))
2259 gen_op_movtl_env_T0(offsetof(CPUSPARCState, tbr));
2261 if (!hypervisor(dc))
2266 // XXX gen_op_wrhpstate();
2274 // XXX gen_op_wrhtstate();
2277 gen_op_movl_env_T0(offsetof(CPUSPARCState, hintp));
2280 gen_op_movl_env_T0(offsetof(CPUSPARCState, htba));
2282 case 31: // hstick_cmpr
2283 gen_op_movtl_env_T0(offsetof(CPUSPARCState, hstick_cmpr));
2284 gen_op_wrhstick_cmpr();
2286 case 6: // hver readonly
2294 #ifdef TARGET_SPARC64
2295 case 0x2c: /* V9 movcc */
2297 int cc = GET_FIELD_SP(insn, 11, 12);
2298 int cond = GET_FIELD_SP(insn, 14, 17);
2299 if (IS_IMM) { /* immediate */
2300 rs2 = GET_FIELD_SPs(insn, 0, 10);
2301 gen_movl_simm_T1(rs2);
2304 rs2 = GET_FIELD_SP(insn, 0, 4);
2305 gen_movl_reg_T1(rs2);
2307 gen_movl_reg_T0(rd);
2309 if (insn & (1 << 18)) {
2311 gen_cond[0][cond]();
2313 gen_cond[1][cond]();
2317 gen_fcond[cc][cond]();
2320 gen_movl_T0_reg(rd);
2323 case 0x2d: /* V9 sdivx */
2324 gen_op_sdivx_T1_T0();
2325 gen_movl_T0_reg(rd);
2327 case 0x2e: /* V9 popc */
2329 if (IS_IMM) { /* immediate */
2330 rs2 = GET_FIELD_SPs(insn, 0, 12);
2331 gen_movl_simm_T1(rs2);
2332 // XXX optimize: popc(constant)
2335 rs2 = GET_FIELD_SP(insn, 0, 4);
2336 gen_movl_reg_T1(rs2);
2339 gen_movl_T0_reg(rd);
2341 case 0x2f: /* V9 movr */
2343 int cond = GET_FIELD_SP(insn, 10, 12);
2344 rs1 = GET_FIELD(insn, 13, 17);
2346 gen_movl_reg_T0(rs1);
2348 if (IS_IMM) { /* immediate */
2349 rs2 = GET_FIELD_SPs(insn, 0, 9);
2350 gen_movl_simm_T1(rs2);
2353 rs2 = GET_FIELD_SP(insn, 0, 4);
2354 gen_movl_reg_T1(rs2);
2356 gen_movl_reg_T0(rd);
2358 gen_movl_T0_reg(rd);
2366 } else if (xop == 0x36) { /* UltraSparc shutdown, VIS, V8 CPop1 */
2367 #ifdef TARGET_SPARC64
2368 int opf = GET_FIELD_SP(insn, 5, 13);
2369 rs1 = GET_FIELD(insn, 13, 17);
2370 rs2 = GET_FIELD(insn, 27, 31);
2371 if (gen_trap_ifnofpu(dc))
2375 case 0x000: /* VIS I edge8cc */
2376 case 0x001: /* VIS II edge8n */
2377 case 0x002: /* VIS I edge8lcc */
2378 case 0x003: /* VIS II edge8ln */
2379 case 0x004: /* VIS I edge16cc */
2380 case 0x005: /* VIS II edge16n */
2381 case 0x006: /* VIS I edge16lcc */
2382 case 0x007: /* VIS II edge16ln */
2383 case 0x008: /* VIS I edge32cc */
2384 case 0x009: /* VIS II edge32n */
2385 case 0x00a: /* VIS I edge32lcc */
2386 case 0x00b: /* VIS II edge32ln */
2389 case 0x010: /* VIS I array8 */
2390 gen_movl_reg_T0(rs1);
2391 gen_movl_reg_T1(rs2);
2393 gen_movl_T0_reg(rd);
2395 case 0x012: /* VIS I array16 */
2396 gen_movl_reg_T0(rs1);
2397 gen_movl_reg_T1(rs2);
2399 gen_movl_T0_reg(rd);
2401 case 0x014: /* VIS I array32 */
2402 gen_movl_reg_T0(rs1);
2403 gen_movl_reg_T1(rs2);
2405 gen_movl_T0_reg(rd);
2407 case 0x018: /* VIS I alignaddr */
2408 gen_movl_reg_T0(rs1);
2409 gen_movl_reg_T1(rs2);
2411 gen_movl_T0_reg(rd);
2413 case 0x019: /* VIS II bmask */
2414 case 0x01a: /* VIS I alignaddrl */
2417 case 0x020: /* VIS I fcmple16 */
2418 gen_op_load_fpr_DT0(rs1);
2419 gen_op_load_fpr_DT1(rs2);
2421 gen_op_store_DT0_fpr(rd);
2423 case 0x022: /* VIS I fcmpne16 */
2424 gen_op_load_fpr_DT0(rs1);
2425 gen_op_load_fpr_DT1(rs2);
2427 gen_op_store_DT0_fpr(rd);
2429 case 0x024: /* VIS I fcmple32 */
2430 gen_op_load_fpr_DT0(rs1);
2431 gen_op_load_fpr_DT1(rs2);
2433 gen_op_store_DT0_fpr(rd);
2435 case 0x026: /* VIS I fcmpne32 */
2436 gen_op_load_fpr_DT0(rs1);
2437 gen_op_load_fpr_DT1(rs2);
2439 gen_op_store_DT0_fpr(rd);
2441 case 0x028: /* VIS I fcmpgt16 */
2442 gen_op_load_fpr_DT0(rs1);
2443 gen_op_load_fpr_DT1(rs2);
2445 gen_op_store_DT0_fpr(rd);
2447 case 0x02a: /* VIS I fcmpeq16 */
2448 gen_op_load_fpr_DT0(rs1);
2449 gen_op_load_fpr_DT1(rs2);
2451 gen_op_store_DT0_fpr(rd);
2453 case 0x02c: /* VIS I fcmpgt32 */
2454 gen_op_load_fpr_DT0(rs1);
2455 gen_op_load_fpr_DT1(rs2);
2457 gen_op_store_DT0_fpr(rd);
2459 case 0x02e: /* VIS I fcmpeq32 */
2460 gen_op_load_fpr_DT0(rs1);
2461 gen_op_load_fpr_DT1(rs2);
2463 gen_op_store_DT0_fpr(rd);
2465 case 0x031: /* VIS I fmul8x16 */
2466 gen_op_load_fpr_DT0(rs1);
2467 gen_op_load_fpr_DT1(rs2);
2469 gen_op_store_DT0_fpr(rd);
2471 case 0x033: /* VIS I fmul8x16au */
2472 gen_op_load_fpr_DT0(rs1);
2473 gen_op_load_fpr_DT1(rs2);
2474 gen_op_fmul8x16au();
2475 gen_op_store_DT0_fpr(rd);
2477 case 0x035: /* VIS I fmul8x16al */
2478 gen_op_load_fpr_DT0(rs1);
2479 gen_op_load_fpr_DT1(rs2);
2480 gen_op_fmul8x16al();
2481 gen_op_store_DT0_fpr(rd);
2483 case 0x036: /* VIS I fmul8sux16 */
2484 gen_op_load_fpr_DT0(rs1);
2485 gen_op_load_fpr_DT1(rs2);
2486 gen_op_fmul8sux16();
2487 gen_op_store_DT0_fpr(rd);
2489 case 0x037: /* VIS I fmul8ulx16 */
2490 gen_op_load_fpr_DT0(rs1);
2491 gen_op_load_fpr_DT1(rs2);
2492 gen_op_fmul8ulx16();
2493 gen_op_store_DT0_fpr(rd);
2495 case 0x038: /* VIS I fmuld8sux16 */
2496 gen_op_load_fpr_DT0(rs1);
2497 gen_op_load_fpr_DT1(rs2);
2498 gen_op_fmuld8sux16();
2499 gen_op_store_DT0_fpr(rd);
2501 case 0x039: /* VIS I fmuld8ulx16 */
2502 gen_op_load_fpr_DT0(rs1);
2503 gen_op_load_fpr_DT1(rs2);
2504 gen_op_fmuld8ulx16();
2505 gen_op_store_DT0_fpr(rd);
2507 case 0x03a: /* VIS I fpack32 */
2508 case 0x03b: /* VIS I fpack16 */
2509 case 0x03d: /* VIS I fpackfix */
2510 case 0x03e: /* VIS I pdist */
2513 case 0x048: /* VIS I faligndata */
2514 gen_op_load_fpr_DT0(rs1);
2515 gen_op_load_fpr_DT1(rs2);
2516 gen_op_faligndata();
2517 gen_op_store_DT0_fpr(rd);
2519 case 0x04b: /* VIS I fpmerge */
2520 gen_op_load_fpr_DT0(rs1);
2521 gen_op_load_fpr_DT1(rs2);
2523 gen_op_store_DT0_fpr(rd);
2525 case 0x04c: /* VIS II bshuffle */
2528 case 0x04d: /* VIS I fexpand */
2529 gen_op_load_fpr_DT0(rs1);
2530 gen_op_load_fpr_DT1(rs2);
2532 gen_op_store_DT0_fpr(rd);
2534 case 0x050: /* VIS I fpadd16 */
2535 gen_op_load_fpr_DT0(rs1);
2536 gen_op_load_fpr_DT1(rs2);
2538 gen_op_store_DT0_fpr(rd);
2540 case 0x051: /* VIS I fpadd16s */
2541 gen_op_load_fpr_FT0(rs1);
2542 gen_op_load_fpr_FT1(rs2);
2544 gen_op_store_FT0_fpr(rd);
2546 case 0x052: /* VIS I fpadd32 */
2547 gen_op_load_fpr_DT0(rs1);
2548 gen_op_load_fpr_DT1(rs2);
2550 gen_op_store_DT0_fpr(rd);
2552 case 0x053: /* VIS I fpadd32s */
2553 gen_op_load_fpr_FT0(rs1);
2554 gen_op_load_fpr_FT1(rs2);
2556 gen_op_store_FT0_fpr(rd);
2558 case 0x054: /* VIS I fpsub16 */
2559 gen_op_load_fpr_DT0(rs1);
2560 gen_op_load_fpr_DT1(rs2);
2562 gen_op_store_DT0_fpr(rd);
2564 case 0x055: /* VIS I fpsub16s */
2565 gen_op_load_fpr_FT0(rs1);
2566 gen_op_load_fpr_FT1(rs2);
2568 gen_op_store_FT0_fpr(rd);
2570 case 0x056: /* VIS I fpsub32 */
2571 gen_op_load_fpr_DT0(rs1);
2572 gen_op_load_fpr_DT1(rs2);
2574 gen_op_store_DT0_fpr(rd);
2576 case 0x057: /* VIS I fpsub32s */
2577 gen_op_load_fpr_FT0(rs1);
2578 gen_op_load_fpr_FT1(rs2);
2580 gen_op_store_FT0_fpr(rd);
2582 case 0x060: /* VIS I fzero */
2583 gen_op_movl_DT0_0();
2584 gen_op_store_DT0_fpr(rd);
2586 case 0x061: /* VIS I fzeros */
2587 gen_op_movl_FT0_0();
2588 gen_op_store_FT0_fpr(rd);
2590 case 0x062: /* VIS I fnor */
2591 gen_op_load_fpr_DT0(rs1);
2592 gen_op_load_fpr_DT1(rs2);
2594 gen_op_store_DT0_fpr(rd);
2596 case 0x063: /* VIS I fnors */
2597 gen_op_load_fpr_FT0(rs1);
2598 gen_op_load_fpr_FT1(rs2);
2600 gen_op_store_FT0_fpr(rd);
2602 case 0x064: /* VIS I fandnot2 */
2603 gen_op_load_fpr_DT1(rs1);
2604 gen_op_load_fpr_DT0(rs2);
2606 gen_op_store_DT0_fpr(rd);
2608 case 0x065: /* VIS I fandnot2s */
2609 gen_op_load_fpr_FT1(rs1);
2610 gen_op_load_fpr_FT0(rs2);
2612 gen_op_store_FT0_fpr(rd);
2614 case 0x066: /* VIS I fnot2 */
2615 gen_op_load_fpr_DT1(rs2);
2617 gen_op_store_DT0_fpr(rd);
2619 case 0x067: /* VIS I fnot2s */
2620 gen_op_load_fpr_FT1(rs2);
2622 gen_op_store_FT0_fpr(rd);
2624 case 0x068: /* VIS I fandnot1 */
2625 gen_op_load_fpr_DT0(rs1);
2626 gen_op_load_fpr_DT1(rs2);
2628 gen_op_store_DT0_fpr(rd);
2630 case 0x069: /* VIS I fandnot1s */
2631 gen_op_load_fpr_FT0(rs1);
2632 gen_op_load_fpr_FT1(rs2);
2634 gen_op_store_FT0_fpr(rd);
2636 case 0x06a: /* VIS I fnot1 */
2637 gen_op_load_fpr_DT1(rs1);
2639 gen_op_store_DT0_fpr(rd);
2641 case 0x06b: /* VIS I fnot1s */
2642 gen_op_load_fpr_FT1(rs1);
2644 gen_op_store_FT0_fpr(rd);
2646 case 0x06c: /* VIS I fxor */
2647 gen_op_load_fpr_DT0(rs1);
2648 gen_op_load_fpr_DT1(rs2);
2650 gen_op_store_DT0_fpr(rd);
2652 case 0x06d: /* VIS I fxors */
2653 gen_op_load_fpr_FT0(rs1);
2654 gen_op_load_fpr_FT1(rs2);
2656 gen_op_store_FT0_fpr(rd);
2658 case 0x06e: /* VIS I fnand */
2659 gen_op_load_fpr_DT0(rs1);
2660 gen_op_load_fpr_DT1(rs2);
2662 gen_op_store_DT0_fpr(rd);
2664 case 0x06f: /* VIS I fnands */
2665 gen_op_load_fpr_FT0(rs1);
2666 gen_op_load_fpr_FT1(rs2);
2668 gen_op_store_FT0_fpr(rd);
2670 case 0x070: /* VIS I fand */
2671 gen_op_load_fpr_DT0(rs1);
2672 gen_op_load_fpr_DT1(rs2);
2674 gen_op_store_DT0_fpr(rd);
2676 case 0x071: /* VIS I fands */
2677 gen_op_load_fpr_FT0(rs1);
2678 gen_op_load_fpr_FT1(rs2);
2680 gen_op_store_FT0_fpr(rd);
2682 case 0x072: /* VIS I fxnor */
2683 gen_op_load_fpr_DT0(rs1);
2684 gen_op_load_fpr_DT1(rs2);
2686 gen_op_store_DT0_fpr(rd);
2688 case 0x073: /* VIS I fxnors */
2689 gen_op_load_fpr_FT0(rs1);
2690 gen_op_load_fpr_FT1(rs2);
2692 gen_op_store_FT0_fpr(rd);
2694 case 0x074: /* VIS I fsrc1 */
2695 gen_op_load_fpr_DT0(rs1);
2696 gen_op_store_DT0_fpr(rd);
2698 case 0x075: /* VIS I fsrc1s */
2699 gen_op_load_fpr_FT0(rs1);
2700 gen_op_store_FT0_fpr(rd);
2702 case 0x076: /* VIS I fornot2 */
2703 gen_op_load_fpr_DT1(rs1);
2704 gen_op_load_fpr_DT0(rs2);
2706 gen_op_store_DT0_fpr(rd);
2708 case 0x077: /* VIS I fornot2s */
2709 gen_op_load_fpr_FT1(rs1);
2710 gen_op_load_fpr_FT0(rs2);
2712 gen_op_store_FT0_fpr(rd);
2714 case 0x078: /* VIS I fsrc2 */
2715 gen_op_load_fpr_DT0(rs2);
2716 gen_op_store_DT0_fpr(rd);
2718 case 0x079: /* VIS I fsrc2s */
2719 gen_op_load_fpr_FT0(rs2);
2720 gen_op_store_FT0_fpr(rd);
2722 case 0x07a: /* VIS I fornot1 */
2723 gen_op_load_fpr_DT0(rs1);
2724 gen_op_load_fpr_DT1(rs2);
2726 gen_op_store_DT0_fpr(rd);
2728 case 0x07b: /* VIS I fornot1s */
2729 gen_op_load_fpr_FT0(rs1);
2730 gen_op_load_fpr_FT1(rs2);
2732 gen_op_store_FT0_fpr(rd);
2734 case 0x07c: /* VIS I for */
2735 gen_op_load_fpr_DT0(rs1);
2736 gen_op_load_fpr_DT1(rs2);
2738 gen_op_store_DT0_fpr(rd);
2740 case 0x07d: /* VIS I fors */
2741 gen_op_load_fpr_FT0(rs1);
2742 gen_op_load_fpr_FT1(rs2);
2744 gen_op_store_FT0_fpr(rd);
2746 case 0x07e: /* VIS I fone */
2747 gen_op_movl_DT0_1();
2748 gen_op_store_DT0_fpr(rd);
2750 case 0x07f: /* VIS I fones */
2751 gen_op_movl_FT0_1();
2752 gen_op_store_FT0_fpr(rd);
2754 case 0x080: /* VIS I shutdown */
2755 case 0x081: /* VIS II siam */
2764 } else if (xop == 0x37) { /* V8 CPop2, V9 impdep2 */
2765 #ifdef TARGET_SPARC64
2770 #ifdef TARGET_SPARC64
2771 } else if (xop == 0x39) { /* V9 return */
2772 rs1 = GET_FIELD(insn, 13, 17);
2774 gen_movl_reg_T0(rs1);
2775 if (IS_IMM) { /* immediate */
2776 rs2 = GET_FIELDs(insn, 19, 31);
2780 gen_movl_simm_T1(rs2);
2785 } else { /* register */
2786 rs2 = GET_FIELD(insn, 27, 31);
2790 gen_movl_reg_T1(rs2);
2798 gen_op_check_align_T0_3();
2799 gen_op_movl_npc_T0();
2800 dc->npc = DYNAMIC_PC;
2804 rs1 = GET_FIELD(insn, 13, 17);
2805 gen_movl_reg_T0(rs1);
2806 if (IS_IMM) { /* immediate */
2807 rs2 = GET_FIELDs(insn, 19, 31);
2811 gen_movl_simm_T1(rs2);
2816 } else { /* register */
2817 rs2 = GET_FIELD(insn, 27, 31);
2821 gen_movl_reg_T1(rs2);
2828 case 0x38: /* jmpl */
2831 #ifdef TARGET_SPARC64
2832 if (dc->pc == (uint32_t)dc->pc) {
2833 gen_op_movl_T1_im(dc->pc);
2835 gen_op_movq_T1_im64(dc->pc >> 32, dc->pc);
2838 gen_op_movl_T1_im(dc->pc);
2840 gen_movl_T1_reg(rd);
2843 gen_op_check_align_T0_3();
2844 gen_op_movl_npc_T0();
2845 dc->npc = DYNAMIC_PC;
2848 #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
2849 case 0x39: /* rett, V9 return */
2851 if (!supervisor(dc))
2854 gen_op_check_align_T0_3();
2855 gen_op_movl_npc_T0();
2856 dc->npc = DYNAMIC_PC;
2861 case 0x3b: /* flush */
2864 case 0x3c: /* save */
2867 gen_movl_T0_reg(rd);
2869 case 0x3d: /* restore */
2872 gen_movl_T0_reg(rd);
2874 #if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)
2875 case 0x3e: /* V9 done/retry */
2879 if (!supervisor(dc))
2881 dc->npc = DYNAMIC_PC;
2882 dc->pc = DYNAMIC_PC;
2886 if (!supervisor(dc))
2888 dc->npc = DYNAMIC_PC;
2889 dc->pc = DYNAMIC_PC;
2905 case 3: /* load/store instructions */
2907 unsigned int xop = GET_FIELD(insn, 7, 12);
2908 rs1 = GET_FIELD(insn, 13, 17);
2910 gen_movl_reg_T0(rs1);
2911 if (xop == 0x3c || xop == 0x3e)
2913 rs2 = GET_FIELD(insn, 27, 31);
2914 gen_movl_reg_T1(rs2);
2916 else if (IS_IMM) { /* immediate */
2917 rs2 = GET_FIELDs(insn, 19, 31);
2921 gen_movl_simm_T1(rs2);
2926 } else { /* register */
2927 rs2 = GET_FIELD(insn, 27, 31);
2931 gen_movl_reg_T1(rs2);
2937 if (xop < 4 || (xop > 7 && xop < 0x14 && xop != 0x0e) ||
2938 (xop > 0x17 && xop <= 0x1d ) ||
2939 (xop > 0x2c && xop <= 0x33) || xop == 0x1f || xop == 0x3d) {
2941 case 0x0: /* load word */
2942 gen_op_check_align_T0_3();
2943 #ifndef TARGET_SPARC64
2949 case 0x1: /* load unsigned byte */
2952 case 0x2: /* load unsigned halfword */
2953 gen_op_check_align_T0_1();
2956 case 0x3: /* load double word */
2959 gen_op_check_align_T0_7();
2961 gen_movl_T0_reg(rd + 1);
2963 case 0x9: /* load signed byte */
2966 case 0xa: /* load signed halfword */
2967 gen_op_check_align_T0_1();
2970 case 0xd: /* ldstub -- XXX: should be atomically */
2971 gen_op_ldst(ldstub);
2973 case 0x0f: /* swap register with memory. Also atomically */
2974 gen_op_check_align_T0_3();
2975 gen_movl_reg_T1(rd);
2978 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
2979 case 0x10: /* load word alternate */
2980 #ifndef TARGET_SPARC64
2983 if (!supervisor(dc))
2986 gen_op_check_align_T0_3();
2987 gen_ld_asi(insn, 4, 0);
2989 case 0x11: /* load unsigned byte alternate */
2990 #ifndef TARGET_SPARC64
2993 if (!supervisor(dc))
2996 gen_ld_asi(insn, 1, 0);
2998 case 0x12: /* load unsigned halfword alternate */
2999 #ifndef TARGET_SPARC64
3002 if (!supervisor(dc))
3005 gen_op_check_align_T0_1();
3006 gen_ld_asi(insn, 2, 0);
3008 case 0x13: /* load double word alternate */
3009 #ifndef TARGET_SPARC64
3012 if (!supervisor(dc))
3017 gen_op_check_align_T0_7();
3019 gen_movl_T0_reg(rd + 1);
3021 case 0x19: /* load signed byte alternate */
3022 #ifndef TARGET_SPARC64
3025 if (!supervisor(dc))
3028 gen_ld_asi(insn, 1, 1);
3030 case 0x1a: /* load signed halfword alternate */
3031 #ifndef TARGET_SPARC64
3034 if (!supervisor(dc))
3037 gen_op_check_align_T0_1();
3038 gen_ld_asi(insn, 2, 1);
3040 case 0x1d: /* ldstuba -- XXX: should be atomically */
3041 #ifndef TARGET_SPARC64
3044 if (!supervisor(dc))
3047 gen_ldstub_asi(insn);
3049 case 0x1f: /* swap reg with alt. memory. Also atomically */
3050 #ifndef TARGET_SPARC64
3053 if (!supervisor(dc))
3056 gen_op_check_align_T0_3();
3057 gen_movl_reg_T1(rd);
3061 #ifndef TARGET_SPARC64
3062 case 0x30: /* ldc */
3063 case 0x31: /* ldcsr */
3064 case 0x33: /* lddc */
3068 #ifdef TARGET_SPARC64
3069 case 0x08: /* V9 ldsw */
3070 gen_op_check_align_T0_3();
3073 case 0x0b: /* V9 ldx */
3074 gen_op_check_align_T0_7();
3077 case 0x18: /* V9 ldswa */
3078 gen_op_check_align_T0_3();
3079 gen_ld_asi(insn, 4, 1);
3081 case 0x1b: /* V9 ldxa */
3082 gen_op_check_align_T0_7();
3083 gen_ld_asi(insn, 8, 0);
3085 case 0x2d: /* V9 prefetch, no effect */
3087 case 0x30: /* V9 ldfa */
3088 gen_op_check_align_T0_3();
3089 gen_ldf_asi(insn, 4);
3091 case 0x33: /* V9 lddfa */
3092 gen_op_check_align_T0_3();
3093 gen_ldf_asi(insn, 8);
3095 case 0x3d: /* V9 prefetcha, no effect */
3097 case 0x32: /* V9 ldqfa */
3103 gen_movl_T1_reg(rd);
3104 #ifdef TARGET_SPARC64
3107 } else if (xop >= 0x20 && xop < 0x24) {
3108 if (gen_trap_ifnofpu(dc))
3111 case 0x20: /* load fpreg */
3112 gen_op_check_align_T0_3();
3114 gen_op_store_FT0_fpr(rd);
3116 case 0x21: /* load fsr */
3117 gen_op_check_align_T0_3();
3121 case 0x22: /* load quad fpreg */
3123 case 0x23: /* load double fpreg */
3124 gen_op_check_align_T0_7();
3126 gen_op_store_DT0_fpr(DFPREG(rd));
3131 } else if (xop < 8 || (xop >= 0x14 && xop < 0x18) || \
3132 xop == 0xe || xop == 0x1e) {
3133 gen_movl_reg_T1(rd);
3136 gen_op_check_align_T0_3();
3143 gen_op_check_align_T0_1();
3149 gen_op_check_align_T0_7();
3151 gen_movl_reg_T2(rd + 1);
3154 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
3156 #ifndef TARGET_SPARC64
3159 if (!supervisor(dc))
3162 gen_op_check_align_T0_3();
3163 gen_st_asi(insn, 4);
3166 #ifndef TARGET_SPARC64
3169 if (!supervisor(dc))
3172 gen_st_asi(insn, 1);
3175 #ifndef TARGET_SPARC64
3178 if (!supervisor(dc))
3181 gen_op_check_align_T0_1();
3182 gen_st_asi(insn, 2);
3185 #ifndef TARGET_SPARC64
3188 if (!supervisor(dc))
3193 gen_op_check_align_T0_7();
3195 gen_movl_reg_T2(rd + 1);
3199 #ifdef TARGET_SPARC64
3200 case 0x0e: /* V9 stx */
3201 gen_op_check_align_T0_7();
3204 case 0x1e: /* V9 stxa */
3205 gen_op_check_align_T0_7();
3206 gen_st_asi(insn, 8);
3212 } else if (xop > 0x23 && xop < 0x28) {
3213 if (gen_trap_ifnofpu(dc))
3217 gen_op_check_align_T0_3();
3218 gen_op_load_fpr_FT0(rd);
3221 case 0x25: /* stfsr, V9 stxfsr */
3222 #ifdef CONFIG_USER_ONLY
3223 gen_op_check_align_T0_3();
3228 #if !defined(CONFIG_USER_ONLY)
3229 case 0x26: /* stdfq */
3230 if (!supervisor(dc))
3232 if (gen_trap_ifnofpu(dc))
3237 gen_op_check_align_T0_7();
3238 gen_op_load_fpr_DT0(DFPREG(rd));
3244 } else if (xop > 0x33 && xop < 0x3f) {
3246 #ifdef TARGET_SPARC64
3247 case 0x34: /* V9 stfa */
3248 gen_op_check_align_T0_3();
3249 gen_op_load_fpr_FT0(rd);
3250 gen_stf_asi(insn, 4);
3252 case 0x37: /* V9 stdfa */
3253 gen_op_check_align_T0_3();
3254 gen_op_load_fpr_DT0(DFPREG(rd));
3255 gen_stf_asi(insn, 8);
3257 case 0x3c: /* V9 casa */
3258 gen_op_check_align_T0_3();
3260 gen_movl_reg_T2(rd);
3262 gen_movl_T1_reg(rd);
3264 case 0x3e: /* V9 casxa */
3265 gen_op_check_align_T0_7();
3267 gen_movl_reg_T2(rd);
3269 gen_movl_T1_reg(rd);
3271 case 0x36: /* V9 stqfa */
3274 case 0x34: /* stc */
3275 case 0x35: /* stcsr */
3276 case 0x36: /* stdcq */
3277 case 0x37: /* stdc */
3289 /* default case for non jump instructions */
3290 if (dc->npc == DYNAMIC_PC) {
3291 dc->pc = DYNAMIC_PC;
3293 } else if (dc->npc == JUMP_PC) {
3294 /* we can do a static jump */
3295 gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1]);
3299 dc->npc = dc->npc + 4;
3305 gen_op_exception(TT_ILL_INSN);
3308 #if !defined(CONFIG_USER_ONLY)
3311 gen_op_exception(TT_PRIV_INSN);
3317 gen_op_fpexception_im(FSR_FTT_UNIMPFPOP);
3320 #if !defined(CONFIG_USER_ONLY)
3323 gen_op_fpexception_im(FSR_FTT_SEQ_ERROR);
3327 #ifndef TARGET_SPARC64
3330 gen_op_exception(TT_NCP_INSN);
3336 static inline int gen_intermediate_code_internal(TranslationBlock * tb,
3337 int spc, CPUSPARCState *env)
3339 target_ulong pc_start, last_pc;
3340 uint16_t *gen_opc_end;
3341 DisasContext dc1, *dc = &dc1;
3344 memset(dc, 0, sizeof(DisasContext));
3349 dc->npc = (target_ulong) tb->cs_base;
3350 dc->mem_idx = cpu_mmu_index(env);
3351 dc->fpu_enabled = cpu_fpu_enabled(env);
3352 gen_opc_ptr = gen_opc_buf;
3353 gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
3354 gen_opparam_ptr = gen_opparam_buf;
3358 if (env->nb_breakpoints > 0) {
3359 for(j = 0; j < env->nb_breakpoints; j++) {
3360 if (env->breakpoints[j] == dc->pc) {
3361 if (dc->pc != pc_start)
3373 fprintf(logfile, "Search PC...\n");
3374 j = gen_opc_ptr - gen_opc_buf;
3378 gen_opc_instr_start[lj++] = 0;
3379 gen_opc_pc[lj] = dc->pc;
3380 gen_opc_npc[lj] = dc->npc;
3381 gen_opc_instr_start[lj] = 1;
3385 disas_sparc_insn(dc);
3389 /* if the next PC is different, we abort now */
3390 if (dc->pc != (last_pc + 4))
3392 /* if we reach a page boundary, we stop generation so that the
3393 PC of a TT_TFAULT exception is always in the right page */
3394 if ((dc->pc & (TARGET_PAGE_SIZE - 1)) == 0)
3396 /* if single step mode, we generate only one instruction and
3397 generate an exception */
3398 if (env->singlestep_enabled) {
3404 } while ((gen_opc_ptr < gen_opc_end) &&
3405 (dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32));
3409 if (dc->pc != DYNAMIC_PC &&
3410 (dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
3411 /* static PC and NPC: we can use direct chaining */
3412 gen_branch(dc, dc->pc, dc->npc);
3414 if (dc->pc != DYNAMIC_PC)
3421 *gen_opc_ptr = INDEX_op_end;
3423 j = gen_opc_ptr - gen_opc_buf;
3426 gen_opc_instr_start[lj++] = 0;
3432 gen_opc_jump_pc[0] = dc->jump_pc[0];
3433 gen_opc_jump_pc[1] = dc->jump_pc[1];
3435 tb->size = last_pc + 4 - pc_start;
3438 if (loglevel & CPU_LOG_TB_IN_ASM) {
3439 fprintf(logfile, "--------------\n");
3440 fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
3441 target_disas(logfile, pc_start, last_pc + 4 - pc_start, 0);
3442 fprintf(logfile, "\n");
3443 if (loglevel & CPU_LOG_TB_OP) {
3444 fprintf(logfile, "OP:\n");
3445 dump_ops(gen_opc_buf, gen_opparam_buf);
3446 fprintf(logfile, "\n");
3453 int gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb)
3455 return gen_intermediate_code_internal(tb, 0, env);
3458 int gen_intermediate_code_pc(CPUSPARCState * env, TranslationBlock * tb)
3460 return gen_intermediate_code_internal(tb, 1, env);
3463 extern int ram_size;
3465 void cpu_reset(CPUSPARCState *env)
3470 env->regwptr = env->regbase + (env->cwp * 16);
3471 #if defined(CONFIG_USER_ONLY)
3472 env->user_mode_only = 1;
3473 #ifdef TARGET_SPARC64
3474 env->cleanwin = NWINDOWS - 2;
3475 env->cansave = NWINDOWS - 2;
3476 env->pstate = PS_RMO | PS_PEF | PS_IE;
3477 env->asi = 0x82; // Primary no-fault
3483 #ifdef TARGET_SPARC64
3484 env->pstate = PS_PRIV;
3485 env->hpstate = HS_PRIV;
3486 env->pc = 0x1fff0000000ULL;
3489 env->mmuregs[0] &= ~(MMU_E | MMU_NF);
3490 env->mmuregs[0] |= env->mmu_bm;
3492 env->npc = env->pc + 4;
3496 CPUSPARCState *cpu_sparc_init(const char *cpu_model)
3499 const sparc_def_t *def;
3501 def = cpu_sparc_find_by_name(cpu_model);
3505 env = qemu_mallocz(sizeof(CPUSPARCState));
3509 env->version = def->iu_version;
3510 env->fsr = def->fpu_version;
3511 #if !defined(TARGET_SPARC64)
3512 env->mmu_bm = def->mmu_bm;
3513 env->mmuregs[0] |= def->mmu_version;
3514 cpu_sparc_set_id(env, 0);
3521 void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu)
3523 #if !defined(TARGET_SPARC64)
3524 env->mxccregs[7] = ((cpu + 8) & 0xf) << 24;
3528 static const sparc_def_t sparc_defs[] = {
3529 #ifdef TARGET_SPARC64
3531 .name = "Fujitsu Sparc64",
3532 .iu_version = ((0x04ULL << 48) | (0x02ULL << 32) | (0ULL << 24)
3533 | (MAXTL << 8) | (NWINDOWS - 1)),
3534 .fpu_version = 0x00000000,
3538 .name = "Fujitsu Sparc64 III",
3539 .iu_version = ((0x04ULL << 48) | (0x03ULL << 32) | (0ULL << 24)
3540 | (MAXTL << 8) | (NWINDOWS - 1)),
3541 .fpu_version = 0x00000000,
3545 .name = "Fujitsu Sparc64 IV",
3546 .iu_version = ((0x04ULL << 48) | (0x04ULL << 32) | (0ULL << 24)
3547 | (MAXTL << 8) | (NWINDOWS - 1)),
3548 .fpu_version = 0x00000000,
3552 .name = "Fujitsu Sparc64 V",
3553 .iu_version = ((0x04ULL << 48) | (0x05ULL << 32) | (0x51ULL << 24)
3554 | (MAXTL << 8) | (NWINDOWS - 1)),
3555 .fpu_version = 0x00000000,
3559 .name = "TI UltraSparc I",
3560 .iu_version = ((0x17ULL << 48) | (0x10ULL << 32) | (0x40ULL << 24)
3561 | (MAXTL << 8) | (NWINDOWS - 1)),
3562 .fpu_version = 0x00000000,
3566 .name = "TI UltraSparc II",
3567 .iu_version = ((0x17ULL << 48) | (0x11ULL << 32) | (0x20ULL << 24)
3568 | (MAXTL << 8) | (NWINDOWS - 1)),
3569 .fpu_version = 0x00000000,
3573 .name = "TI UltraSparc IIi",
3574 .iu_version = ((0x17ULL << 48) | (0x12ULL << 32) | (0x91ULL << 24)
3575 | (MAXTL << 8) | (NWINDOWS - 1)),
3576 .fpu_version = 0x00000000,
3580 .name = "TI UltraSparc IIe",
3581 .iu_version = ((0x17ULL << 48) | (0x13ULL << 32) | (0x14ULL << 24)
3582 | (MAXTL << 8) | (NWINDOWS - 1)),
3583 .fpu_version = 0x00000000,
3587 .name = "Sun UltraSparc III",
3588 .iu_version = ((0x3eULL << 48) | (0x14ULL << 32) | (0x34ULL << 24)
3589 | (MAXTL << 8) | (NWINDOWS - 1)),
3590 .fpu_version = 0x00000000,
3594 .name = "Sun UltraSparc III Cu",
3595 .iu_version = ((0x3eULL << 48) | (0x15ULL << 32) | (0x41ULL << 24)
3596 | (MAXTL << 8) | (NWINDOWS - 1)),
3597 .fpu_version = 0x00000000,
3601 .name = "Sun UltraSparc IIIi",
3602 .iu_version = ((0x3eULL << 48) | (0x16ULL << 32) | (0x34ULL << 24)
3603 | (MAXTL << 8) | (NWINDOWS - 1)),
3604 .fpu_version = 0x00000000,
3608 .name = "Sun UltraSparc IV",
3609 .iu_version = ((0x3eULL << 48) | (0x18ULL << 32) | (0x31ULL << 24)
3610 | (MAXTL << 8) | (NWINDOWS - 1)),
3611 .fpu_version = 0x00000000,
3615 .name = "Sun UltraSparc IV+",
3616 .iu_version = ((0x3eULL << 48) | (0x19ULL << 32) | (0x22ULL << 24)
3617 | (MAXTL << 8) | (NWINDOWS - 1)),
3618 .fpu_version = 0x00000000,
3622 .name = "Sun UltraSparc IIIi+",
3623 .iu_version = ((0x3eULL << 48) | (0x22ULL << 32) | (0ULL << 24)
3624 | (MAXTL << 8) | (NWINDOWS - 1)),
3625 .fpu_version = 0x00000000,
3629 .name = "NEC UltraSparc I",
3630 .iu_version = ((0x22ULL << 48) | (0x10ULL << 32) | (0x40ULL << 24)
3631 | (MAXTL << 8) | (NWINDOWS - 1)),
3632 .fpu_version = 0x00000000,
3637 .name = "Fujitsu MB86900",
3638 .iu_version = 0x00 << 24, /* Impl 0, ver 0 */
3639 .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */
3640 .mmu_version = 0x00 << 24, /* Impl 0, ver 0 */
3641 .mmu_bm = 0x00004000,
3644 .name = "Fujitsu MB86904",
3645 .iu_version = 0x04 << 24, /* Impl 0, ver 4 */
3646 .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */
3647 .mmu_version = 0x04 << 24, /* Impl 0, ver 4 */
3648 .mmu_bm = 0x00004000,
3651 .name = "Fujitsu MB86907",
3652 .iu_version = 0x05 << 24, /* Impl 0, ver 5 */
3653 .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */
3654 .mmu_version = 0x05 << 24, /* Impl 0, ver 5 */
3655 .mmu_bm = 0x00004000,
3658 .name = "LSI L64811",
3659 .iu_version = 0x10 << 24, /* Impl 1, ver 0 */
3660 .fpu_version = 1 << 17, /* FPU version 1 (LSI L64814) */
3661 .mmu_version = 0x10 << 24,
3662 .mmu_bm = 0x00004000,
3665 .name = "Cypress CY7C601",
3666 .iu_version = 0x11 << 24, /* Impl 1, ver 1 */
3667 .fpu_version = 3 << 17, /* FPU version 3 (Cypress CY7C602) */
3668 .mmu_version = 0x10 << 24,
3669 .mmu_bm = 0x00004000,
3672 .name = "Cypress CY7C611",
3673 .iu_version = 0x13 << 24, /* Impl 1, ver 3 */
3674 .fpu_version = 3 << 17, /* FPU version 3 (Cypress CY7C602) */
3675 .mmu_version = 0x10 << 24,
3676 .mmu_bm = 0x00004000,
3679 .name = "TI SuperSparc II",
3680 .iu_version = 0x40000000,
3681 .fpu_version = 0 << 17,
3682 .mmu_version = 0x04000000,
3683 .mmu_bm = 0x00002000,
3686 .name = "TI MicroSparc I",
3687 .iu_version = 0x41000000,
3688 .fpu_version = 4 << 17,
3689 .mmu_version = 0x41000000,
3690 .mmu_bm = 0x00004000,
3693 .name = "TI MicroSparc II",
3694 .iu_version = 0x42000000,
3695 .fpu_version = 4 << 17,
3696 .mmu_version = 0x02000000,
3697 .mmu_bm = 0x00004000,
3700 .name = "TI MicroSparc IIep",
3701 .iu_version = 0x42000000,
3702 .fpu_version = 4 << 17,
3703 .mmu_version = 0x04000000,
3704 .mmu_bm = 0x00004000,
3707 .name = "TI SuperSparc 51",
3708 .iu_version = 0x43000000,
3709 .fpu_version = 0 << 17,
3710 .mmu_version = 0x04000000,
3711 .mmu_bm = 0x00002000,
3714 .name = "TI SuperSparc 61",
3715 .iu_version = 0x44000000,
3716 .fpu_version = 0 << 17,
3717 .mmu_version = 0x04000000,
3718 .mmu_bm = 0x00002000,
3721 .name = "Ross RT625",
3722 .iu_version = 0x1e000000,
3723 .fpu_version = 1 << 17,
3724 .mmu_version = 0x1e000000,
3725 .mmu_bm = 0x00004000,
3728 .name = "Ross RT620",
3729 .iu_version = 0x1f000000,
3730 .fpu_version = 1 << 17,
3731 .mmu_version = 0x1f000000,
3732 .mmu_bm = 0x00004000,
3735 .name = "BIT B5010",
3736 .iu_version = 0x20000000,
3737 .fpu_version = 0 << 17, /* B5010/B5110/B5120/B5210 */
3738 .mmu_version = 0x20000000,
3739 .mmu_bm = 0x00004000,
3742 .name = "Matsushita MN10501",
3743 .iu_version = 0x50000000,
3744 .fpu_version = 0 << 17,
3745 .mmu_version = 0x50000000,
3746 .mmu_bm = 0x00004000,
3749 .name = "Weitek W8601",
3750 .iu_version = 0x90 << 24, /* Impl 9, ver 0 */
3751 .fpu_version = 3 << 17, /* FPU version 3 (Weitek WTL3170/2) */
3752 .mmu_version = 0x10 << 24,
3753 .mmu_bm = 0x00004000,
3757 .iu_version = 0xf2000000,
3758 .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */
3759 .mmu_version = 0xf2000000,
3760 .mmu_bm = 0x00004000,
3764 .iu_version = 0xf3000000,
3765 .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */
3766 .mmu_version = 0xf3000000,
3767 .mmu_bm = 0x00004000,
3772 static const sparc_def_t *cpu_sparc_find_by_name(const unsigned char *name)
3776 for (i = 0; i < sizeof(sparc_defs) / sizeof(sparc_def_t); i++) {
3777 if (strcasecmp(name, sparc_defs[i].name) == 0) {
3778 return &sparc_defs[i];
3784 void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
3788 for (i = 0; i < sizeof(sparc_defs) / sizeof(sparc_def_t); i++) {
3789 (*cpu_fprintf)(f, "Sparc %16s IU " TARGET_FMT_lx " FPU %08x MMU %08x\n",
3791 sparc_defs[i].iu_version,
3792 sparc_defs[i].fpu_version,
3793 sparc_defs[i].mmu_version);
3797 #define GET_FLAG(a,b) ((env->psr & a)?b:'-')
3799 void cpu_dump_state(CPUState *env, FILE *f,
3800 int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
3805 cpu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc, env->npc);
3806 cpu_fprintf(f, "General Registers:\n");
3807 for (i = 0; i < 4; i++)
3808 cpu_fprintf(f, "%%g%c: " TARGET_FMT_lx "\t", i + '0', env->gregs[i]);
3809 cpu_fprintf(f, "\n");
3811 cpu_fprintf(f, "%%g%c: " TARGET_FMT_lx "\t", i + '0', env->gregs[i]);
3812 cpu_fprintf(f, "\nCurrent Register Window:\n");
3813 for (x = 0; x < 3; x++) {
3814 for (i = 0; i < 4; i++)
3815 cpu_fprintf(f, "%%%c%d: " TARGET_FMT_lx "\t",
3816 (x == 0 ? 'o' : (x == 1 ? 'l' : 'i')), i,
3817 env->regwptr[i + x * 8]);
3818 cpu_fprintf(f, "\n");
3820 cpu_fprintf(f, "%%%c%d: " TARGET_FMT_lx "\t",
3821 (x == 0 ? 'o' : x == 1 ? 'l' : 'i'), i,
3822 env->regwptr[i + x * 8]);
3823 cpu_fprintf(f, "\n");
3825 cpu_fprintf(f, "\nFloating Point Registers:\n");
3826 for (i = 0; i < 32; i++) {
3828 cpu_fprintf(f, "%%f%02d:", i);
3829 cpu_fprintf(f, " %016lf", env->fpr[i]);
3831 cpu_fprintf(f, "\n");
3833 #ifdef TARGET_SPARC64
3834 cpu_fprintf(f, "pstate: 0x%08x ccr: 0x%02x asi: 0x%02x tl: %d fprs: %d\n",
3835 env->pstate, GET_CCR(env), env->asi, env->tl, env->fprs);
3836 cpu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate %d cleanwin %d cwp %d\n",
3837 env->cansave, env->canrestore, env->otherwin, env->wstate,
3838 env->cleanwin, NWINDOWS - 1 - env->cwp);
3840 cpu_fprintf(f, "psr: 0x%08x -> %c%c%c%c %c%c%c wim: 0x%08x\n", GET_PSR(env),
3841 GET_FLAG(PSR_ZERO, 'Z'), GET_FLAG(PSR_OVF, 'V'),
3842 GET_FLAG(PSR_NEG, 'N'), GET_FLAG(PSR_CARRY, 'C'),
3843 env->psrs?'S':'-', env->psrps?'P':'-',
3844 env->psret?'E':'-', env->wim);
3846 cpu_fprintf(f, "fsr: 0x%08x\n", GET_FSR32(env));
3849 #if defined(CONFIG_USER_ONLY)
3850 target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
3856 extern int get_physical_address (CPUState *env, target_phys_addr_t *physical, int *prot,
3857 int *access_index, target_ulong address, int rw,
3860 target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
3862 target_phys_addr_t phys_addr;
3863 int prot, access_index;
3865 if (get_physical_address(env, &phys_addr, &prot, &access_index, addr, 2, 0) != 0)
3866 if (get_physical_address(env, &phys_addr, &prot, &access_index, addr, 0, 0) != 0)
3868 if (cpu_get_physical_page_desc(phys_addr) == IO_MEM_UNASSIGNED)
3874 void helper_flush(target_ulong addr)
3877 tb_invalidate_page_range(addr, addr + 8);