Lines Matching full:ctx
507 ctx->pc, ctx->opcode , ## __VA_ARGS__)
516 MIPS_DEBUG("Invalid %s %03x %03x %03x", op, ctx->opcode >> 26, \
517 ctx->opcode & 0x3F, ((ctx->opcode >> 16) & 0x1F)); \
615 static inline void gen_load_fpr64 (DisasContext *ctx, TCGv_i64 t, int reg)
617 if (ctx->hflags & MIPS_HFLAG_F64) {
630 static inline void gen_store_fpr64 (DisasContext *ctx, TCGv_i64 t, int reg)
632 if (ctx->hflags & MIPS_HFLAG_F64) {
751 static inline void save_cpu_state (DisasContext *ctx, int do_save_pc)
753 LOG_DISAS("hflags %08x saved %08x\n", ctx->hflags, ctx->saved_hflags);
754 if (do_save_pc && ctx->pc != ctx->saved_pc) {
755 gen_save_pc(ctx->pc);
756 ctx->saved_pc = ctx->pc;
758 if (ctx->hflags != ctx->saved_hflags) {
759 tcg_gen_movi_i32(hflags, ctx->hflags);
760 ctx->saved_hflags = ctx->hflags;
761 switch (ctx->hflags & MIPS_HFLAG_BMASK) {
767 tcg_gen_movi_tl(btarget, ctx->btarget);
773 static inline void restore_cpu_state (CPUState *env, DisasContext *ctx)
775 ctx->saved_hflags = ctx->hflags;
776 switch (ctx->hflags & MIPS_HFLAG_BMASK) {
782 ctx->btarget = env->btarget;
788 generate_exception_err (DisasContext *ctx, int excp, int err)
792 save_cpu_state(ctx, 1);
799 generate_exception (DisasContext *ctx, int excp)
801 save_cpu_state(ctx, 1);
806 static inline void gen_op_addr_add (DisasContext *ctx, TCGv ret, TCGv arg0, TCGv arg1)
814 if (((ctx->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&
815 !(ctx->hflags & MIPS_HFLAG_UX)) {
821 static inline void check_cp0_enabled(DisasContext *ctx)
823 if (unlikely(!(ctx->hflags & MIPS_HFLAG_CP0)))
824 generate_exception_err(ctx, EXCP_CpU, 0);
827 static inline void check_cp1_enabled(DisasContext *ctx)
829 if (unlikely(!(ctx->hflags & MIPS_HFLAG_FPU)))
830 generate_exception_err(ctx, EXCP_CpU, 1);
837 static inline void check_cop1x(DisasContext *ctx)
839 if (unlikely(!(ctx->hflags & MIPS_HFLAG_COP1X)))
840 generate_exception(ctx, EXCP_RI);
846 static inline void check_cp1_64bitmode(DisasContext *ctx)
848 if (unlikely(~ctx->hflags & (MIPS_HFLAG_F64 | MIPS_HFLAG_COP1X)))
849 generate_exception(ctx, EXCP_RI);
863 static inline void check_cp1_registers(DisasContext *ctx, int regs)
865 if (unlikely(!(ctx->hflags & MIPS_HFLAG_F64) && (regs & 1)))
866 generate_exception(ctx, EXCP_RI);
871 static inline void check_insn(CPUState *env, DisasContext *ctx, int flags)
874 generate_exception(ctx, EXCP_RI);
879 static inline void check_mips_64(DisasContext *ctx)
881 if (unlikely(!(ctx->hflags & MIPS_HFLAG_64)))
882 generate_exception(ctx, EXCP_RI);
887 static inline void op_ldst_##insn(TCGv ret, TCGv arg1, DisasContext *ctx) \
889 tcg_gen_qemu_##fname(ret, arg1, ctx->mem_idx); \
903 static inline void op_ldst_##insn(TCGv arg1, TCGv arg2, DisasContext *ctx) \
905 tcg_gen_qemu_##fname(arg1, arg2, ctx->mem_idx); \
917 static inline void op_ldst_##insn(TCGv ret, TCGv arg1, DisasContext *ctx) \
921 tcg_gen_qemu_##fname(ret, arg1, ctx->mem_idx); \
928 ctx) \
930 gen_helper_2i(insn, ret, arg1, ctx->mem_idx); \
941 static inline void op_ldst_##insn(TCGv arg1, TCGv arg2, int rt, DisasContext *ctx) \
950 generate_exception(ctx, EXCP_AdES); \
965 static inline void op_ldst_##insn(TCGv arg1, TCGv arg2, int rt, DisasContext *ctx) \
968 gen_helper_3i(insn, t0, arg1, arg2, ctx->mem_idx); \
980 static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt,
993 gen_op_addr_add(ctx, t0, cpu_gpr[base], t0);
1000 save_cpu_state(ctx, 0);
1001 op_ldst_lwu(t0, t0, ctx);
1006 save_cpu_state(ctx, 0);
1007 op_ldst_ld(t0, t0, ctx);
1012 save_cpu_state(ctx, 0);
1013 op_ldst_lld(t0, t0, ctx);
1018 save_cpu_state(ctx, 0);
1020 op_ldst_sd(t1, t0, ctx);
1024 save_cpu_state(ctx, 1);
1026 gen_helper_3i(ldl, t1, t1, t0, ctx->mem_idx);
1031 save_cpu_state(ctx, 1);
1033 gen_helper_2i(sdl, t1, t0, ctx->mem_idx);
1037 save_cpu_state(ctx, 1);
1039 gen_helper_3i(ldr, t1, t1, t0, ctx->mem_idx);
1044 save_cpu_state(ctx, 1);
1046 gen_helper_2i(sdr, t1, t0, ctx->mem_idx);
1051 save_cpu_state(ctx, 0);
1052 op_ldst_lw(t0, t0, ctx);
1057 save_cpu_state(ctx, 0);
1059 op_ldst_sw(t1, t0, ctx);
1063 save_cpu_state(ctx, 0);
1064 op_ldst_lh(t0, t0, ctx);
1069 save_cpu_state(ctx, 0);
1071 op_ldst_sh(t1, t0, ctx);
1075 save_cpu_state(ctx, 0);
1076 op_ldst_lhu(t0, t0, ctx);
1081 save_cpu_state(ctx, 0);
1082 op_ldst_lb(t0, t0, ctx);
1087 save_cpu_state(ctx, 0);
1089 op_ldst_sb(t1, t0, ctx);
1093 save_cpu_state(ctx, 0);
1094 op_ldst_lbu(t0, t0, ctx);
1099 save_cpu_state(ctx, 1);
1101 gen_helper_3i(lwl, t1, t1, t0, ctx->mem_idx);
1106 save_cpu_state(ctx, 1);
1108 gen_helper_2i(swl, t1, t0, ctx->mem_idx);
1112 save_cpu_state(ctx, 1);
1114 gen_helper_3i(lwr, t1, t1, t0, ctx->mem_idx);
1119 save_cpu_state(ctx, 1);
1121 gen_helper_2i(swr, t1, t0, ctx->mem_idx);
1125 save_cpu_state(ctx, 1);
1126 op_ldst_ll(t0, t0, ctx);
1137 static void gen_st_cond (DisasContext *ctx, uint32_t opc, int rt,
1151 gen_op_addr_add(ctx, t0, cpu_gpr[base], t0);
1161 save_cpu_state(ctx, 0);
1162 op_ldst_scd(t1, t0, rt, ctx);
1167 save_cpu_state(ctx, 1);
1168 op_ldst_sc(t1, t0, rt, ctx);
1178 static void gen_flt_ldst (DisasContext *ctx, uint32_t opc, int ft,
1190 gen_op_addr_add(ctx, t0, cpu_gpr[base], t0);
1199 tcg_gen_qemu_ld32s(t0, t0, ctx->mem_idx);
1213 tcg_gen_qemu_st32(t1, t0, ctx->mem_idx);
1223 tcg_gen_qemu_ld64(fp0, t0, ctx->mem_idx);
1224 gen_store_fpr64(ctx, fp0, ft);
1233 gen_load_fpr64(ctx, fp0, ft);
1234 tcg_gen_qemu_st64(fp0, t0, ctx->mem_idx);
1241 generate_exception(ctx, EXCP_RI);
1250 static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
1281 generate_exception(ctx, EXCP_OVERFLOW);
1316 generate_exception(ctx, EXCP_OVERFLOW);
1407 static void gen_shift_imm(CPUState *env, DisasContext *ctx, uint32_t opc,
1434 switch ((ctx->opcode >> 21) & 0x1f) {
1470 generate_exception(ctx, EXCP_RI);
1484 switch ((ctx->opcode >> 21) & 0x1f) {
1505 generate_exception(ctx, EXCP_RI);
1518 switch ((ctx->opcode >> 21) & 0x1f) {
1535 generate_exception(ctx, EXCP_RI);
1546 static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
1579 generate_exception(ctx, EXCP_OVERFLOW);
1617 generate_exception(ctx, EXCP_OVERFLOW);
1657 generate_exception(ctx, EXCP_OVERFLOW);
1693 generate_exception(ctx, EXCP_OVERFLOW);
1855 static void gen_shift (CPUState *env, DisasContext *ctx, uint32_t opc,
1886 switch ((ctx->opcode >> 6) & 0x1f) {
1918 generate_exception(ctx, EXCP_RI);
1934 switch ((ctx->opcode >> 6) & 0x1f) {
1954 generate_exception(ctx, EXCP_RI);
1966 static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg)
2002 ctx, uint32_t opc,
2228 generate_exception(ctx, EXCP_RI);
2237 static void gen_mul_vr54xx (DisasContext *ctx, uint32_t opc,
2306 generate_exception(ctx, EXCP_RI);
2317 static void gen_cl (DisasContext *ctx, uint32_t opc,
2355 static void gen_trap (DisasContext *ctx, uint32_t opc,
2401 generate_exception(ctx, EXCP_TRAP);
2441 generate_exception(ctx, EXCP_TRAP);
2448 static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
2451 tb = ctx->tb;
2453 likely(!ctx->singlestep_enabled)) {
2459 if (ctx->singlestep_enabled) {
2460 save_cpu_state(ctx, 0);
2468 static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
2477 if (ctx->hflags & MIPS_HFLAG_BMASK) {
2479 LOG_DISAS("Branch in delay slot at PC 0x" TARGET_FMT_lx "\n", ctx->pc);
2481 generate_exception(ctx, EXCP_RI);
2497 btgt = ctx->pc + 4 + offset;
2516 btgt = ctx->pc + 4 + offset;
2521 btgt = ((ctx->pc + 4) & (int32_t)0xF0000000) | (uint32_t)offset;
2530 generate_exception(ctx, EXCP_RI);
2537 generate_exception(ctx, EXCP_RI);
2550 ctx->hflags |= MIPS_HFLAG_B;
2557 ctx->hflags |= MIPS_HFLAG_B;
2567 tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 8);
2571 tcg_gen_movi_tl(cpu_gpr[31], ctx
2574 ctx->pc += 4;
2581 ctx->pc += 4;
2584 ctx->hflags |= MIPS_HFLAG_B;
2589 ctx->hflags |= MIPS_HFLAG_B;
2593 ctx->hflags |= MIPS_HFLAG_BR;
2598 ctx->hflags |= MIPS_HFLAG_BR;
2603 generate_exception(ctx, EXCP_RI);
2675 ctx->hflags |= MIPS_HFLAG_BC;
2682 ctx->hflags |= MIPS_HFLAG_BL;
2686 generate_exception(ctx, EXCP_RI);
2691 blink, ctx->hflags, btgt);
2693 ctx->btarget = btgt;
2695 tcg_gen_movi_tl(cpu_gpr[blink], ctx->pc + 8);
2704 static void gen_bitops (DisasContext *ctx, uint32_t opc, int rt,
2786 generate_exception(ctx, EXCP_RI);
2796 static void gen_bshfl (DisasContext *ctx, uint32_t op2, int rt, int rd)
2859 generate_exception(ctx, EXCP_RI);
2898 static void gen_mfc0 (CPUState *env, DisasContext *ctx, TCGv arg, int reg, int sel)
2903 check_insn(env, ctx, ISA_MIPS32);
2913 check_insn(env, ctx, ASE_MT);
2918 check_insn(env, ctx, ASE_MT);
2923 check_insn(env, ctx, ASE_MT);
2938 check_insn(env, ctx, ASE_MT);
2943 check_insn(env, ctx, ASE_MT);
2948 check_insn(env, ctx, ASE_MT);
2953 check_insn(env, ctx, ASE_MT);
2958 check_insn(env, ctx, ASE_MT);
2963 check_insn(env, ctx, ASE_MT);
2968 check_insn(env, ctx, ASE_MT);
2984 check_insn(env, ctx, ASE_MT);
2989 check_insn(env, ctx, ASE_MT);
2994 check_insn(env, ctx, ASE_MT);
2999 check_insn(env, ctx, ASE_MT);
3004 check_insn(env, ctx, ASE_MT);
3009 check_insn(env, ctx, ASE_MT);
3014 check_insn(env, ctx, ASE_MT);
3055 check_insn(env, ctx, ISA_MIPS32R2);
3070 check_insn(env, ctx, ISA_MIPS32R2);
3075 check_insn(env, ctx, ISA_MIPS32R2);
3080 check_insn(env, ctx, ISA_MIPS32R2);
3085 check_insn(env, ctx, ISA_MIPS32R2);
3090 check_insn(env, ctx, ISA_MIPS32R2);
3101 check_insn(env, ctx, ISA_MIPS32R2);
3129 ctx->bstate = BS_STOP;
3167 check_insn(env, ctx, ISA_MIPS32R2);
3172 check_insn(env, ctx, ISA_MIPS32R2);
3177 check_insn(env, ctx, ISA_MIPS32R2);
3213 check_insn(env, ctx, ISA_MIPS32R2);
3287 check_insn(env, ctx, ISA_MIPS3);
3472 generate_exception(ctx, EXCP_RI);
3475 static void gen_mtc0 (CPUState *env, DisasContext *ctx, TCGv arg, int reg, int sel)
3480 check_insn(env, ctx, ISA_MIPS32);
3493 check_insn(env, ctx, ASE_MT);
3498 check_insn(env, ctx, ASE_MT);
3503 check_insn(env, ctx, ASE_MT);
3518 check_insn(env, ctx, ASE_MT);
3523 check_insn(env, ctx, ASE_MT);
3528 check_insn(env, ctx, ASE_MT);
3533 check_insn(env, ctx, ASE_MT);
3538 check_insn(env, ctx, ASE_MT);
3543 check_insn(env, ctx, ASE_MT);
3548 check_insn(env, ctx, ASE_MT);
3563 check_insn(env, ctx, ASE_MT);
3568 check_insn(env, ctx, ASE_MT);
3573 check_insn(env, ctx, ASE_MT);
3578 check_insn(env, ctx, ASE_MT);
3583 check_insn(env, ctx, ASE_MT);
3588 check_insn(env, ctx, ASE_MT);
3593 check_insn(env, ctx, ASE_MT);
3632 check_insn(env, ctx, ISA_MIPS32R2);
3647 check_insn(env, ctx, ISA_MIPS32R2);
3652 check_insn(env, ctx, ISA_MIPS32R2);
3657 check_insn(env, ctx, ISA_MIPS32R2);
3662 check_insn(env, ctx, ISA_MIPS32R2);
3667 check_insn(env, ctx, ISA_MIPS32R2);
3678 check_insn(env, ctx, ISA_MIPS32R2);
3725 save_cpu_state(ctx, 1);
3728 gen_save_pc(ctx->pc + 4);
3729 ctx->bstate = BS_EXCP;
3733 check_insn(env, ctx, ISA_MIPS32R2);
3736 ctx->bstate = BS_STOP;
3740 check_insn(env, ctx, ISA_MIPS32R2);
3743 ctx->bstate = BS_STOP;
3747 check_insn(env, ctx
3750 ctx->bstate = BS_STOP;
3760 save_cpu_state(ctx, 1);
3785 check_insn(env, ctx, ISA_MIPS32R2);
3799 ctx->bstate = BS_STOP;
3809 ctx->bstate = BS_STOP;
3864 check_insn(env, ctx, ISA_MIPS3);
3893 gen_save_pc(ctx->pc + 4);
3894 ctx->bstate = BS_EXCP;
3901 ctx->bstate = BS_STOP;
3907 ctx->bstate = BS_STOP;
3911 ctx->bstate = BS_STOP;
3915 ctx->bstate = BS_STOP;
3920 ctx->bstate = BS_STOP;
4052 ctx->bstate = BS_STOP;
4061 ctx->bstate = BS_STOP;
4067 generate_exception(ctx, EXCP_RI);
4071 static void gen_dmfc0 (CPUState *env, DisasContext *ctx, TCGv arg, int reg, int sel)
4076 check_insn(env, ctx, ISA_MIPS64);
4086 check_insn(env, ctx, ASE_MT);
4091 check_insn(env, ctx, ASE_MT);
4096 check_insn(env, ctx, ASE_MT);
4111 check_insn(env, ctx, ASE_MT);
4116 check_insn(env, ctx, ASE_MT);
4121 check_insn(env, ctx, ASE_MT);
4126 check_insn(env, ctx, ASE_MT);
4131 check_insn(env, ctx, ASE_MT);
4136 check_insn(env, ctx, ASE_MT);
4141 check_insn(env, ctx, ASE_MT);
4156 check_insn(env, ctx, ASE_MT);
4161 check_insn(env, ctx, ASE_MT);
4166 check_insn(env, ctx, ASE_MT);
4171 check_insn(env, ctx, ASE_MT);
4176 check_insn(env, ctx, ASE_MT);
4181 check_insn(env, ctx, ASE_MT);
4186 check_insn(env, ctx, ASE_MT);
4225 check_insn(env, ctx, ISA_MIPS32R2);
4240 check_insn(env, ctx, ISA_MIPS32R2);
4245 check_insn(env, ctx, ISA_MIPS32R2);
4250 check_insn(env, ctx, ISA_MIPS32R2);
4255 check_insn(env, ctx, ISA_MIPS32R2);
4260 check_insn(env, ctx, ISA_MIPS32R2);
4271 check_insn(env, ctx, ISA_MIPS32R2);
4298 ctx->bstate = BS_STOP;
4335 check_insn(env, ctx, ISA_MIPS32R2);
4340 check_insn(env, ctx, ISA_MIPS32R2);
4345 check_insn(env, ctx, ISA_MIPS32R2);
4380 check_insn(env, ctx, ISA_MIPS32R2);
4452 check_insn(env, ctx, ISA_MIPS3);
4634 generate_exception(ctx, EXCP_RI);
4637 static void gen_dmtc0 (CPUState *env, DisasContext *ctx, TCGv arg, int reg, int sel)
4642 check_insn(env, ctx, ISA_MIPS64);
4655 check_insn(env, ctx, ASE_MT);
4660 check_insn(env, ctx, ASE_MT);
4665 check_insn(env, ctx, ASE_MT);
4680 check_insn(env, ctx, ASE_MT);
4685 check_insn(env, ctx, ASE_MT);
4690 check_insn(env, ctx, ASE_MT);
4695 check_insn(env, ctx, ASE_MT);
4700 check_insn(env, ctx, ASE_MT);
4705 check_insn(env, ctx, ASE_MT);
4710 check_insn(env, ctx, ASE_MT);
4725 check_insn(env, ctx, ASE_MT);
4730 check_insn(env, ctx, ASE_MT);
4735 check_insn(env, ctx, ASE_MT);
4740 check_insn(env, ctx, ASE_MT);
4745 check_insn(env, ctx, ASE_MT);
4750 check_insn(env, ctx, ASE_MT);
4755 check_insn(env, ctx, ASE_MT);
4794 check_insn(env, ctx, ISA_MIPS32R2);
4809 check_insn(env, ctx, ISA_MIPS32R2);
4814 check_insn(env, ctx, ISA_MIPS32R2);
4819 check_insn(env, ctx, ISA_MIPS32R2);
4824 check_insn(env, ctx, ISA_MIPS32R2);
4829 check_insn(env, ctx, ISA_MIPS32R2);
4840 check_insn(env, ctx, ISA_MIPS32R2);
4863 ctx->bstate = BS_STOP;
4886 ctx->bstate = BS_STOP;
4891 save_cpu_state(ctx, 1);
4894 gen_save_pc(ctx->pc + 4);
4895 ctx->bstate = BS_EXCP;
4899 check_insn(env, ctx, ISA_MIPS32R2);
4902 ctx->bstate = BS_STOP;
4906 check_insn(env, ctx, ISA_MIPS32R2);
4909 ctx->bstate = BS_STOP;
4913 check_insn(env, ctx, ISA_MIPS32R2);
4916 ctx->bstate = BS_STOP;
4926 save_cpu_state(ctx, 1);
4951 check_insn(env, ctx, ISA_MIPS32R2);
4965 ctx->bstate = BS_STOP;
4975 ctx->bstate = BS_STOP;
5020 check_insn(env, ctx, ISA_MIPS3);
5048 gen_save_pc(ctx->pc + 4);
5049 ctx->bstate = BS_EXCP;
5055 ctx->bstate = BS_STOP;
5061 ctx->bstate = BS_STOP;
5067 ctx->bstate = BS_STOP;
5073 ctx->bstate = BS_STOP;
5205 ctx->bstate = BS_STOP;
5214 ctx->bstate = BS_STOP;
5220 generate_exception(ctx, EXCP_RI);
5224 static void gen_mftr(CPUState *env, DisasContext *ctx, int rt, int rd,
5263 gen_mfc0(env, ctx, t0, rt, sel);
5273 gen_mfc0(env, ctx, t0, rt, sel);
5282 gen_mfc0(env, ctx, t0, rt, sel);
5291 gen_mfc0(env, ctx, t0, rt, sel);
5296 gen_mfc0(env, ctx, t0, rt, sel);
5385 generate_exception(ctx, EXCP_RI);
5388 static void gen_mttr(CPUState *env, DisasContext *ctx, int rd, int rt,
5428 gen_mtc0(env, ctx, t0, rd, sel);
5438 gen_mtc0(env, ctx, t0, rd, sel);
5447 gen_mtc0(env, ctx, t0, rd, sel);
5456 gen_mtc0(env, ctx, t0, rd, sel);
5461 gen_mtc0(env, ctx, t0, rd, sel);
5549 generate_exception(ctx, EXCP_RI);
5552 static void gen_cp0 (CPUState *env, DisasContext *ctx, uint32_t opc, int rt, int rd)
5562 gen_mfc0(env, ctx, cpu_gpr[rt], rd, ctx->opcode & 0x7);
5570 gen_mtc0(env, ctx, t0, rd, ctx->opcode & 0x7);
5577 check_insn(env, ctx, ISA_MIPS3);
5582 gen_dmfc0(env, ctx, cpu_gpr[rt], rd, ctx->opcode & 0x7);
5586 check_insn(env, ctx, ISA_MIPS3);
5591 gen_dmtc0(env, ctx, t0, rd, ctx->opcode & 0x7);
5598 check_insn(env, ctx, ASE_MT);
5603 gen_mftr(env, ctx, rt, rd, (ctx->opcode >> 5) & 1,
5604 ctx->opcode & 0x7, (ctx->opcode >> 4) & 1);
5608 check_insn(env, ctx, ASE_MT);
5609 gen_mttr(env, ctx, rd, rt, (ctx->opcode >> 5) & 1,
5610 ctx->opcode & 0x7, (ctx->opcode >> 4) & 1);
5639 check_insn(env, ctx, ISA_MIPS2);
5641 ctx->bstate = BS_EXCP;
5645 check_insn(env, ctx, ISA_MIPS32);
5646 if (!(ctx->hflags & MIPS_HFLAG_DM)) {
5648 generate_exception(ctx, EXCP_RI);
5651 ctx->bstate = BS_EXCP;
5656 check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32);
5658 ctx->pc += 4;
5659 save_cpu_state(ctx, 1);
5660 ctx->pc -= 4;
5662 ctx->bstate = BS_EXCP;
5667 generate_exception(ctx, EXCP_RI);
5675 static void gen_compute_branch1 (CPUState *env, DisasContext *ctx, uint32_t op,
5683 check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32);
5685 btarget = ctx->pc + 4 + offset;
5714 ctx->hflags |= MIPS_HFLAG_BL;
5774 ctx->hflags |= MIPS_HFLAG_BC;
5778 generate_exception (ctx, EXCP_RI);
5782 ctx->hflags, btarget);
5783 ctx->btarget = btarget;
5793 static void gen_cp1 (DisasContext *ctx, uint32_t opc, int rt, int fs)
5833 gen_load_fpr64(ctx, t0, fs);
5839 gen_store_fpr64(ctx, t0, fs);
5867 generate_exception (ctx, EXCP_RI);
5876 static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf)
5924 static inline void gen_movcf_d (DisasContext *ctx, int fs, int fd, int cc, int tf)
5940 gen_load_fpr64(ctx, fp0, fs);
5941 gen_store_fpr64(ctx, fp0, fd);
5973 static void gen_farith (DisasContext *ctx, uint32_t op1,
6014 uint32_t func = ctx->opcode & 0x3f;
6016 switch (ctx->opcode & FOP(0x3f, 0x1f)) {
6121 check_cp1_64bitmode(ctx);
6129 gen_store_fpr64(ctx, fp64, fd);
6135 check_cp1_64bitmode(ctx);
6143 gen_store_fpr64(ctx, fp64, fd);
6149 check_cp1_64bitmode(ctx);
6157 gen_store_fpr64(ctx, fp64, fd);
6163 check_cp1_64bitmode(ctx);
6171 gen_store_fpr64(ctx, fp64, fd);
6257 check_cop1x(ctx);
6269 check_cop1x(ctx);
6281 check_cp1_64bitmode(ctx);
6296 check_cp1_64bitmode(ctx);
6308 check_cp1_64bitmode(ctx);
6320 check_cp1_64bitmode(ctx);
6335 check_cp1_registers(ctx, fd);
6343 gen_store_fpr64(ctx, fp64, fd);
6360 check_cp1_64bitmode(ctx);
6368 gen_store_fpr64(ctx, fp64, fd);
6374 check_cp1_64bitmode(ctx);
6385 gen_store_fpr64(ctx, fp64, fd);
6412 if (ctx->opcode & (1 << 6)) {
6413 check_cop1x(ctx);
6425 check_cp1_registers(ctx, fs | ft | fd);
6430 gen_load_fpr64(ctx, fp0, fs);
6431 gen_load_fpr64(ctx, fp1, ft);
6434 gen_store_fpr64(ctx, fp0, fd);
6441 check_cp1_registers(ctx, fs | ft | fd);
6446 gen_load_fpr64(ctx, fp0, fs);
6447 gen_load_fpr64(ctx, fp1, ft);
6450 gen_store_fpr64(ctx, fp0, fd);
6457 check_cp1_registers(ctx, fs | ft | fd);
6462 gen_load_fpr64(ctx, fp0, fs);
6463 gen_load_fpr64(ctx, fp1, ft);
6466 gen_store_fpr64(ctx, fp0, fd);
6473 check_cp1_registers(ctx, fs | ft | fd);
6478 gen_load_fpr64(ctx, fp0, fs);
6479 gen_load_fpr64(ctx, fp1, ft);
6482 gen_store_fpr64(ctx, fp0, fd);
6489 check_cp1_registers(ctx, fs | fd);
6493 gen_load_fpr64(ctx, fp0, fs);
6495 gen_store_fpr64(ctx, fp0, fd);
6501 check_cp1_registers(ctx, fs | fd);
6505 gen_load_fpr64(ctx, fp0, fs);
6507 gen_store_fpr64(ctx, fp0, fd);
6513 check_cp1_registers(ctx, fs | fd);
6517 gen_load_fpr64(ctx, fp0, fs);
6518 gen_store_fpr64(ctx, fp0, fd);
6524 check_cp1_registers(ctx, fs | fd);
6528 gen_load_fpr64(ctx, fp0, fs);
6530 gen_store_fpr64(ctx, fp0, fd);
6536 check_cp1_64bitmode(ctx);
6540 gen_load_fpr64(ctx, fp0, fs);
6542 gen_store_fpr64(ctx, fp0, fd);
6548 check_cp1_64bitmode(ctx);
6552 gen_load_fpr64(ctx, fp0, fs);
6554 gen_store_fpr64(ctx, fp0, fd);
6560 check_cp1_64bitmode(ctx);
6564 gen_load_fpr64(ctx, fp0, fs);
6566 gen_store_fpr64(ctx, fp0, fd);
6572 check_cp1_64bitmode(ctx);
6576 gen_load_fpr64(ctx, fp0, fs);
6578 gen_store_fpr64(ctx, fp0, fd);
6584 check_cp1_registers(ctx, fs);
6589 gen_load_fpr64(ctx, fp64, fs);
6598 check_cp1_registers(ctx, fs);
6603 gen_load_fpr64(ctx, fp64, fs);
6612 check_cp1_registers(ctx, fs);
6617 gen_load_fpr64(ctx, fp64, fs);
6626 check_cp1_registers(ctx, fs);
6631 gen_load_fpr64(ctx, fp64, fs);
6640 gen_movcf_d(ctx, fs, fd, (ft >> 2) & 0x7, ft & 0x1);
6652 gen_load_fpr64(ctx, fp0, fs);
6653 gen_store_fpr64(ctx, fp0, fd);
6667 gen_load_fpr64(ctx, fp0, fs);
6668 gen_store_fpr64(ctx, fp0, fd);
6676 check_cp1_64bitmode(ctx);
6680 gen_load_fpr64(ctx, fp0, fs);
6682 gen_store_fpr64(ctx, fp0, fd);
6688 check_cp1_64bitmode(ctx);
6692 gen_load_fpr64(ctx, fp0, fs);
6694 gen_store_fpr64(ctx, fp0, fd);
6700 check_cp1_64bitmode(ctx);
6705 gen_load_fpr64(ctx, fp0, fs);
6706 gen_load_fpr64(ctx, fp1, ft);
6709 gen_store_fpr64(ctx, fp0, fd);
6715 check_cp1_64bitmode(ctx);
6719 gen_load_fpr64(ctx, fp0, fs);
6721 gen_store_fpr64(ctx, fp0, fd);
6727 check_cp1_64bitmode(ctx);
6731 gen_load_fpr64(ctx, fp0, fs);
6733 gen_store_fpr64(ctx, fp0, fd);
6739 check_cp1_64bitmode(ctx);
6744 gen_load_fpr64(ctx, fp0, fs);
6745 gen_load_fpr64(ctx, fp1, ft);
6748 gen_store_fpr64(ctx, fp0, fd);
6773 gen_load_fpr64(ctx, fp0, fs);
6774 gen_load_fpr64(ctx, fp1, ft);
6775 if (ctx->opcode & (1 << 6)) {
6776 check_cop1x(ctx);
6777 check_cp1_registers(ctx, fs | ft);
6781 check_cp1_registers(ctx, fs | ft);
6790 check_cp1_registers(ctx, fs);
6795 gen_load_fpr64(ctx, fp64, fs);
6804 check_cp1_registers(ctx, fs);
6809 gen_load_fpr64(ctx, fp64, fs);
6818 check_cp1_64bitmode(ctx);
6822 gen_load_fpr64(ctx, fp0, fs);
6824 gen_store_fpr64(ctx, fp0, fd);
6841 check_cp1_registers(ctx, fd);
6849 gen_store_fpr64(ctx, fp64, fd);
6855 check_cp1_64bitmode(ctx);
6860 gen_load_fpr64(ctx, fp64, fs);
6869 check_cp1_64bitmode(ctx);
6873 gen_load_fpr64(ctx, fp0, fs);
6875 gen_store_fpr64(ctx, fp0, fd);
6881 check_cp1_64bitmode(ctx);
6885 gen_load_fpr64(ctx, fp0, fs);
6887 gen_store_fpr64(ctx, fp0, fd);
6893 check_cp1_64bitmode(ctx);
6898 gen_load_fpr64(ctx, fp0, fs);
6899 gen_load_fpr64(ctx, fp1, ft);
6902 gen_store_fpr64(ctx, fp0, fd);
6908 check_cp1_64bitmode(ctx);
6913 gen_load_fpr64(ctx, fp0, fs);
6914 gen_load_fpr64(ctx, fp1, ft);
6917 gen_store_fpr64(ctx, fp0, fd);
6923 check_cp1_64bitmode(ctx);
6928 gen_load_fpr64(ctx, fp0, fs);
6929 gen_load_fpr64(ctx, fp1, ft);
6932 gen_store_fpr64(ctx, fp0, fd);
6938 check_cp1_64bitmode(ctx);
6942 gen_load_fpr64(ctx, fp0, fs);
6944 gen_store_fpr64(ctx, fp0, fd);
6950 check_cp1_64bitmode(ctx);
6954 gen_load_fpr64(ctx, fp0, fs);
6955 gen_store_fpr64(ctx, fp0, fd);
6961 check_cp1_64bitmode(ctx);
6965 gen_load_fpr64(ctx, fp0, fs);
6967 gen_store_fpr64(ctx, fp0, fd);
6973 check_cp1_64bitmode(ctx);
6978 check_cp1_64bitmode(ctx);
6986 gen_load_fpr64(ctx, fp0, fs);
6987 gen_store_fpr64(ctx, fp0, fd);
6994 check_cp1_64bitmode(ctx);
7002 gen_load_fpr64(ctx, fp0, fs);
7003 gen_store_fpr64(ctx, fp0, fd);
7011 check_cp1_64bitmode(ctx);
7016 gen_load_fpr64(ctx, fp0, ft);
7017 gen_load_fpr64(ctx, fp1, fs);
7020 gen_store_fpr64(ctx, fp0, fd);
7026 check_cp1_64bitmode(ctx);
7031 gen_load_fpr64(ctx, fp0, ft);
7032 gen_load_fpr64(ctx, fp1, fs);
7035 gen_store_fpr64(ctx, fp0, fd);
7041 check_cp1_64bitmode(ctx);
7046 gen_load_fpr64(ctx, fp0, fs);
7047 gen_load_fpr64(ctx, fp1, fd);
7050 gen_store_fpr64(ctx, fp0, fd);
7056 check_cp1_64bitmode(ctx);
7060 gen_load_fpr64(ctx, fp0, fs);
7062 gen_store_fpr64(ctx, fp0, fd);
7068 check_cp1_64bitmode(ctx);
7072 gen_load_fpr64(ctx, fp0, fs);
7074 gen_store_fpr64(ctx, fp0, fd);
7080 check_cp1_64bitmode(ctx);
7085 gen_load_fpr64(ctx, fp0, fs);
7086 gen_load_fpr64(ctx, fp1, ft);
7089 gen_store_fpr64(ctx, fp0, fd);
7095 check_cp1_64bitmode(ctx);
7107 check_cp1_64bitmode(ctx);
7111 gen_load_fpr64(ctx, fp0, fs);
7113 gen_store_fpr64(ctx, fp0, fd);
7119 check_cp1_64bitmode(ctx);
7131 check_cp1_64bitmode(ctx);
7146 check_cp1_64bitmode(ctx);
7161 check_cp1_64bitmode(ctx);
7176 check_cp1_64bitmode(ctx);
7206 check_cp1_64bitmode(ctx);
7211 gen_load_fpr64(ctx, fp0, fs);
7212 gen_load_fpr64(ctx, fp1, ft);
7213 if (ctx->opcode & (1 << 6)) {
7226 generate_exception (ctx, EXCP_RI);
7243 static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc,
7256 gen_op_addr_add(ctx, t0, cpu_gpr[base], t0);
7260 save_cpu_state(ctx, 0);
7263 check_cop1x(ctx);
7267 tcg_gen_qemu_ld32s(t0, t0, ctx->mem_idx);
7275 check_cop1x(ctx);
7276 check_cp1_registers(ctx, fd);
7280 tcg_gen_qemu_ld64(fp0, t0, ctx->mem_idx);
7281 gen_store_fpr64(ctx, fp0, fd);
7287 check_cp1_64bitmode(ctx);
7292 tcg_gen_qemu_ld64(fp0, t0, ctx->mem_idx);
7293 gen_store_fpr64(ctx, fp0, fd);
7299 check_cop1x(ctx);
7306 tcg_gen_qemu_st32(t1, t0, ctx->mem_idx);
7314 check_cop1x(ctx);
7315 check_cp1_registers(ctx, fs);
7319 gen_load_fpr64(ctx, fp0, fs);
7320 tcg_gen_qemu_st64(fp0, t0, ctx->mem_idx);
7327 check_cp1_64bitmode(ctx);
7332 gen_load_fpr64(ctx, fp0, fs);
7333 tcg_gen_qemu_st64(fp0, t0, ctx->mem_idx);
7345 static void gen_flt3_arith (DisasContext *ctx, uint32_t opc,
7352 check_cp1_64bitmode(ctx);
7390 check_cop1x(ctx);
7408 check_cop1x(ctx);
7409 check_cp1_registers(ctx, fd | fs | ft | fr);
7415 gen_load_fpr64(ctx, fp0, fs);
7416 gen_load_fpr64(ctx, fp1, ft);
7417 gen_load_fpr64(ctx, fp2, fr);
7421 gen_store_fpr64(ctx, fp2, fd);
7427 check_cp1_64bitmode(ctx);
7433 gen_load_fpr64(ctx, fp0, fs);
7434 gen_load_fpr64(ctx, fp1, ft);
7435 gen_load_fpr64(ctx, fp2, fr);
7439 gen_store_fpr64(ctx, fp2, fd);
7445 check_cop1x(ctx);
7463 check_cop1x(ctx);
7464 check_cp1_registers(ctx, fd | fs | ft | fr);
7470 gen_load_fpr64(ctx, fp0, fs);
7471 gen_load_fpr64(ctx, fp1, ft);
7472 gen_load_fpr64(ctx, fp2, fr);
7476 gen_store_fpr64(ctx, fp2, fd);
7482 check_cp1_64bitmode(ctx);
7488 gen_load_fpr64(ctx, fp0, fs);
7489 gen_load_fpr64(ctx, fp1, ft);
7490 gen_load_fpr64(ctx, fp2, fr);
7494 gen_store_fpr64(ctx, fp2, fd);
7500 check_cop1x(ctx);
7518 check_cop1x(ctx);
7519 check_cp1_registers(ctx, fd | fs | ft | fr);
7525 gen_load_fpr64(ctx, fp0, fs);
7526 gen_load_fpr64(ctx, fp1, ft);
7527 gen_load_fpr64(ctx, fp2, fr);
7531 gen_store_fpr64(ctx, fp2, fd);
7537 check_cp1_64bitmode(ctx);
7543 gen_load_fpr64(ctx, fp0, fs);
7544 gen_load_fpr64(ctx, fp1, ft);
7545 gen_load_fpr64(ctx, fp2, fr);
7549 gen_store_fpr64(ctx, fp2, fd);
7555 check_cop1x(ctx);
7573 check_cop1x(ctx);
7574 check_cp1_registers(ctx, fd | fs | ft | fr);
7580 gen_load_fpr64(ctx, fp0, fs);
7581 gen_load_fpr64(ctx, fp1, ft);
7582 gen_load_fpr64(ctx, fp2, fr);
7586 gen_store_fpr64(ctx, fp2, fd);
7592 check_cp1_64bitmode(ctx);
7598 gen_load_fpr64(ctx, fp0, fs);
7599 gen_load_fpr64(ctx, fp1, ft);
7600 gen_load_fpr64(ctx, fp2, fr);
7604 gen_store_fpr64(ctx, fp2, fd);
7611 generate_exception (ctx, EXCP_RI);
7628 static void decode_opc (CPUState *env, DisasContext *ctx)
7636 if (ctx->pc & 0x3) {
7637 env->CP0_BadVAddr = ctx->pc;
7638 generate_exception(ctx, EXCP_AdEL);
7643 if ((ctx->hflags & MIPS_HFLAG_BMASK) == MIPS_HFLAG_BL) {
7646 MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4);
7648 tcg_gen_movi_i32(hflags, ctx->hflags & ~MIPS_HFLAG_BMASK);
7649 gen_goto_tb(ctx, 1, ctx->pc + 4);
7654 tcg_gen_debug_insn_start(ctx->pc);
7656 op = MASK_OP_MAJOR(ctx->opcode);
7657 rs = (ctx->opcode >> 21) & 0x1f;
7658 rt = (ctx->opcode >> 16) & 0x1f;
7659 rd = (ctx->opcode >> 11) & 0x1f;
7660 sa = (ctx->opcode >> 6) & 0x1f;
7661 imm = (int16_t)ctx->opcode;
7664 op1 = MASK_SPECIAL(ctx->opcode);
7669 gen_shift_imm(env, ctx, op1, rd, rt, sa);
7673 check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32);
7677 gen_arith(env, ctx, op1, rd, rs, rt);
7682 gen_shift(env, ctx, op1, rd, rs, rt);
7696 check_insn(env, ctx, INSN_VR54XX);
7697 op1 = MASK_MUL_VR54XX(ctx->opcode);
7698 gen_mul_vr54xx(ctx, op1, rd, rs, rt);
7700 gen_muldiv(ctx, op1, rs, rt);
7703 gen_compute_branch(ctx, op1, rs, rd, sa);
7707 gen_trap(ctx, op1, rs, rt, -1);
7711 gen_HILO(ctx, op1, rd);
7715 gen_HILO(ctx, op1, rs);
7720 generate_exception(ctx, EXCP_RI);
7726 generate_exception(ctx, EXCP_SYSCALL);
7727 ctx->bstate = BS_STOP;
7730 generate_exception(ctx, EXCP_BREAK);
7735 generate_exception(ctx, EXCP_RI);
7739 generate_exception(ctx, EXCP_RI);
7747 check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32);
7749 check_cp1_enabled(ctx);
7750 gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7,
7751 (ctx->opcode >> 16) & 1);
7753 generate_exception_err(ctx, EXCP_CpU, 1);
7765 check_insn(env, ctx, ISA_MIPS3);
7766 check_mips_64(ctx);
7767 gen_shift_imm(env, ctx, op1, rd, rt, sa);
7770 check_insn(env, ctx, ISA_MIPS3);
7771 check_mips_64(ctx);
7772 gen_arith(env, ctx, op1, rd, rs, rt);
7777 check_insn(env, ctx, ISA_MIPS3);
7778 check_mips_64(ctx);
7779 gen_shift(env, ctx, op1, rd, rs, rt);
7782 check_insn(env, ctx, ISA_MIPS3);
7783 check_mips_64(ctx);
7784 gen_muldiv(ctx, op1, rs, rt);
7789 generate_exception(ctx, EXCP_RI);
7794 op1 = MASK_SPECIAL2(ctx->opcode);
7798 check_insn(env, ctx, ISA_MIPS32);
7799 gen_muldiv(ctx, op1, rs, rt);
7802 gen_arith(env, ctx, op1, rd, rs, rt);
7806 check_insn(env, ctx, ISA_MIPS32);
7807 gen_cl(ctx, op1, rd, rs);
7813 check_insn(env, ctx, ISA_MIPS32);
7814 if (!(ctx->hflags & MIPS_HFLAG_DM)) {
7815 generate_exception(ctx, EXCP_DBp);
7817 generate_exception(ctx, EXCP_DBp);
7824 check_insn(env, ctx, ISA_MIPS64);
7825 check_mips_64(ctx);
7826 gen_cl(ctx, op1, rd, rs);
7831 generate_exception(ctx, EXCP_RI);
7836 op1 = MASK_SPECIAL3(ctx->opcode);
7840 check_insn(env, ctx, ISA_MIPS32R2);
7841 gen_bitops(ctx, op1, rt, rs, sa, rd);
7844 check_insn(env, ctx, ISA_MIPS32R2);
7845 op2 = MASK_BSHFL(ctx->opcode);
7846 gen_bshfl(ctx, op2, rt, rd);
7849 check_insn(env, ctx, ISA_MIPS32R2);
7855 save_cpu_state(ctx, 1);
7860 save_cpu_state(ctx, 1);
7865 save_cpu_state(ctx, 1);
7870 save_cpu_state(ctx, 1);
7885 generate_exception(ctx, EXCP_RI);
7892 check_insn(env, ctx, ASE_MT);
7905 check_insn(env, ctx, ASE_MT);
7909 save_cpu_state(ctx, 1);
7919 check_insn(env, ctx, ISA_MIPS64R2);
7920 check_mips_64(ctx);
7921 gen_bitops(ctx, op1, rt, rs, sa, rd);
7924 check_insn(env, ctx, ISA_MIPS64R2);
7925 check_mips_64(ctx);
7926 op2 = MASK_DBSHFL(ctx->opcode);
7927 gen_bshfl(ctx, op2, rt, rd);
7932 generate_exception(ctx, EXCP_RI);
7937 op1 = MASK_REGIMM(ctx->opcode);
7941 gen_compute_branch(ctx, op1, rs, -1, imm << 2);
7945 gen_trap(ctx, op1, rs, -1, imm);
7948 check_insn(env, ctx, ISA_MIPS32R2);
7953 generate_exception(ctx, EXCP_RI);
7958 check_cp0_enabled(ctx);
7959 op1 = MASK_CP0(ctx->opcode);
7970 gen_cp0(env, ctx, op1, rt, rd);
7975 gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd);
7983 op2 = MASK_MFMC0(ctx->opcode);
7986 check_insn(env, ctx, ASE_MT);
7991 check_insn(env, ctx, ASE_MT);
7996 check_insn(env, ctx, ASE_MT);
8001 check_insn(env, ctx, ASE_MT);
8006 check_insn(env, ctx, ISA_MIPS32R2);
8007 save_cpu_state(ctx, 1);
8011 ctx->bstate = BS_STOP;
8014 check_insn(env, ctx, ISA_MIPS32R2);
8015 save_cpu_state(ctx, 1);
8019 ctx->bstate = BS_STOP;
8023 generate_exception(ctx, EXCP_RI);
8031 check_insn(env, ctx, ISA_MIPS32R2);
8035 check_insn(env, ctx, ISA_MIPS32R2);
8040 generate_exception(ctx, EXCP_RI);
8046 gen_arith_imm(env, ctx, op, rt, rs, imm);
8059 offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
8060 gen_compute_branch(ctx, op, rs, rt, offset);
8064 gen_compute_branch(ctx, op, rs, rt, imm << 2);
8070 gen_ldst(ctx, op, rt, rs, imm);
8073 gen_st_cond(ctx, op, rt, rs, imm);
8076 check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32);
8080 check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32);
8090 check_cp1_enabled(ctx);
8091 gen_flt_ldst(ctx, op, rt, rs, imm);
8093 generate_exception_err(ctx, EXCP_CpU, 1);
8099 check_cp1_enabled(ctx);
8100 op1 = MASK_CP1(ctx->opcode);
8104 check_insn(env, ctx, ISA_MIPS32R2);
8109 gen_cp1(ctx, op1, rt, rd);
8114 check_insn(env, ctx, ISA_MIPS3);
8115 gen_cp1(ctx, op1, rt, rd);
8120 check_cop1x(ctx);
8121 check_insn(env, ctx, ASE_MIPS3D);
8124 gen_compute_branch1(env, ctx, MASK_BC1(ctx->opcode),
8132 gen_farith(ctx, MASK_CP1_FUNC(ctx->opcode), rt, rd, sa,
8137 generate_exception (ctx, EXCP_RI);
8141 generate_exception_err(ctx, EXCP_CpU, 1);
8152 generate_exception_err(ctx, EXCP_CpU, 2);
8157 check_cp1_enabled(ctx);
8158 op1 = MASK_CP3(ctx->opcode);
8166 gen_flt3_ldst(ctx, op1, sa, rd, rs, rt);
8184 gen_flt3_arith(ctx, op1, sa, rs, rd, rt);
8188 generate_exception (ctx, EXCP_RI);
8192 generate_exception_err(ctx, EXCP_CpU, 1);
8204 check_insn(env, ctx, ISA_MIPS3);
8205 check_mips_64(ctx);
8206 gen_ldst(ctx, op, rt, rs, imm);
8209 check_insn(env, ctx, ISA_MIPS3);
8210 check_mips_64(ctx);
8211 gen_st_cond(ctx, op, rt, rs, imm);
8215 check_insn(env, ctx, ISA_MIPS3);
8216 check_mips_64(ctx);
8217 gen_arith_imm(env, ctx, op, rt, rs, imm);
8221 check_insn(env, ctx, ASE_MIPS16);
8224 check_insn(env, ctx, ASE_MDMX);
8228 generate_exception(ctx, EXCP_RI);
8231 if (ctx->hflags & MIPS_HFLAG_BMASK) {
8232 int hflags = ctx->hflags & MIPS_HFLAG_BMASK;
8234 ctx->hflags &= ~MIPS_HFLAG_BMASK;
8235 ctx->bstate = BS_BRANCH;
8236 save_cpu_state(ctx, 0);
8242 gen_goto_tb(ctx, 0, ctx->btarget);
8247 gen_goto_tb(ctx, 0, ctx->btarget);
8256 gen_goto_tb(ctx, 1, ctx->pc + 4);
8258 gen_goto_tb(ctx, 0, ctx->btarget);
8265 if (ctx->singlestep_enabled) {
8266 save_cpu_state(ctx, 0);
8282 DisasContext ctx;
8295 ctx.pc = pc_start;
8296 ctx.saved_pc = -1;
8297 ctx.singlestep_enabled = env->singlestep_enabled;
8298 ctx.tb = tb;
8299 ctx.bstate = BS_NONE;
8301 ctx.hflags = (uint32_t)tb->flags; /* FIXME: maybe use 64 bits here? */
8302 restore_cpu_state(env, &ctx);
8304 ctx.mem_idx = MIPS_HFLAG_UM;
8306 ctx.mem_idx = ctx.hflags & MIPS_HFLAG_KSU;
8317 LOG_DISAS("\ntb %p idx %d hflags %04x\n", tb, ctx.mem_idx, ctx.hflags);
8319 while (ctx.bstate == BS_NONE) {
8322 if (bp->pc == ctx.pc) {
8323 save_cpu_state(&ctx, 1);
8324 ctx.bstate = BS_BRANCH;
8328 ctx.pc += 4;
8341 gen_opc_pc[lj] = ctx.pc;
8342 gen_opc_hflags[lj] = ctx.hflags & MIPS_HFLAG_BMASK;
8348 ctx.opcode = ldl_code(ctx.pc);
8349 decode_opc(env, &ctx);
8350 ctx.pc += 4;
8357 if (env->singlestep_enabled && (ctx.hflags & MIPS_HFLAG_BMASK) == 0)
8363 if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0 && (ctx.hflags & MIPS_HFLAG_BMASK) == 0)
8377 if (env->singlestep_enabled && ctx.bstate != BS_BRANCH) {
8378 save_cpu_state(&ctx, ctx.bstate == BS_NONE);
8381 switch (ctx.bstate) {
8384 gen_goto_tb(&ctx, 0, ctx.pc);
8387 save_cpu_state(&ctx, 0);
8388 gen_goto_tb(&ctx, 0, ctx.pc);
8408 tb->size = ctx.pc - pc_start;
8415 log_target_disas(pc_start, ctx.pc - pc_start, 0);
8418 qemu_log_mask(CPU_LOG_TB_CPU, "---------------- %d %08x\n", ctx.bstate, ctx.hflags);