target-mips: Tighten ISA level checks

Tighten ISA level checks down to MIPS II that many of our instructions
are missing.  Also make sure any 64-bit instruction enables are only
applied to 64-bit processors, that is ones that implement at least the
MIPS III ISA.

Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
This commit is contained in:
Maciej W. Rozycki 2014-12-05 18:47:58 +00:00 committed by Leon Alrae
parent 90f12d735d
commit d922445020
3 changed files with 114 additions and 15 deletions

View File

@ -831,9 +831,10 @@ static inline void compute_hflags(CPUMIPSState *env)
env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU; env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU;
} }
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
if (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_UM) || if ((env->insn_flags & ISA_MIPS3) &&
(env->CP0_Status & (1 << CP0St_PX)) || (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_UM) ||
(env->CP0_Status & (1 << CP0St_UX))) { (env->CP0_Status & (1 << CP0St_PX)) ||
(env->CP0_Status & (1 << CP0St_UX)))) {
env->hflags |= MIPS_HFLAG_64; env->hflags |= MIPS_HFLAG_64;
} }

View File

@ -527,7 +527,10 @@ void mips_cpu_do_interrupt(CPUState *cs)
env->CP0_DEPC = exception_resume_pc(env); env->CP0_DEPC = exception_resume_pc(env);
env->hflags &= ~MIPS_HFLAG_BMASK; env->hflags &= ~MIPS_HFLAG_BMASK;
enter_debug_mode: enter_debug_mode:
env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_64 | MIPS_HFLAG_CP0; if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
}
env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU); env->hflags &= ~(MIPS_HFLAG_KSU);
/* EJTAG probe trap enable is not implemented... */ /* EJTAG probe trap enable is not implemented... */
if (!(env->CP0_Status & (1 << CP0St_EXL))) if (!(env->CP0_Status & (1 << CP0St_EXL)))
@ -548,7 +551,10 @@ void mips_cpu_do_interrupt(CPUState *cs)
env->CP0_ErrorEPC = exception_resume_pc(env); env->CP0_ErrorEPC = exception_resume_pc(env);
env->hflags &= ~MIPS_HFLAG_BMASK; env->hflags &= ~MIPS_HFLAG_BMASK;
env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV); env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV);
env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0; if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
}
env->hflags |= MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU); env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL))) if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1U << CP0Ca_BD); env->CP0_Cause &= ~(1U << CP0Ca_BD);
@ -726,7 +732,10 @@ void mips_cpu_do_interrupt(CPUState *cs)
env->CP0_Cause &= ~(1U << CP0Ca_BD); env->CP0_Cause &= ~(1U << CP0Ca_BD);
} }
env->CP0_Status |= (1 << CP0St_EXL); env->CP0_Status |= (1 << CP0St_EXL);
env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0; if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
}
env->hflags |= MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU); env->hflags &= ~(MIPS_HFLAG_KSU);
} }
env->hflags &= ~MIPS_HFLAG_BMASK; env->hflags &= ~MIPS_HFLAG_BMASK;

View File

@ -2398,7 +2398,14 @@ static void gen_cop1_ldst(DisasContext *ctx, uint32_t op, int rt,
{ {
if (ctx->CP0_Config1 & (1 << CP0C1_FP)) { if (ctx->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx); check_cp1_enabled(ctx);
gen_flt_ldst(ctx, op, rt, rs, imm); switch (op) {
case OPC_LDC1:
case OPC_SDC1:
check_insn(ctx, ISA_MIPS2);
/* Fallthrough */
default:
gen_flt_ldst(ctx, op, rt, rs, imm);
}
} else { } else {
generate_exception_err(ctx, EXCP_CpU, 1); generate_exception_err(ctx, EXCP_CpU, 1);
} }
@ -10997,26 +11004,32 @@ static void decode_i64_mips16 (DisasContext *ctx,
{ {
switch (funct) { switch (funct) {
case I64_LDSP: case I64_LDSP:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
offset = extended ? offset : offset << 3; offset = extended ? offset : offset << 3;
gen_ld(ctx, OPC_LD, ry, 29, offset); gen_ld(ctx, OPC_LD, ry, 29, offset);
break; break;
case I64_SDSP: case I64_SDSP:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
offset = extended ? offset : offset << 3; offset = extended ? offset : offset << 3;
gen_st(ctx, OPC_SD, ry, 29, offset); gen_st(ctx, OPC_SD, ry, 29, offset);
break; break;
case I64_SDRASP: case I64_SDRASP:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
offset = extended ? offset : (ctx->opcode & 0xff) << 3; offset = extended ? offset : (ctx->opcode & 0xff) << 3;
gen_st(ctx, OPC_SD, 31, 29, offset); gen_st(ctx, OPC_SD, 31, 29, offset);
break; break;
case I64_DADJSP: case I64_DADJSP:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
offset = extended ? offset : ((int8_t)ctx->opcode) << 3; offset = extended ? offset : ((int8_t)ctx->opcode) << 3;
gen_arith_imm(ctx, OPC_DADDIU, 29, 29, offset); gen_arith_imm(ctx, OPC_DADDIU, 29, 29, offset);
break; break;
case I64_LDPC: case I64_LDPC:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
if (extended && (ctx->hflags & MIPS_HFLAG_BMASK)) { if (extended && (ctx->hflags & MIPS_HFLAG_BMASK)) {
generate_exception(ctx, EXCP_RI); generate_exception(ctx, EXCP_RI);
} else { } else {
@ -11025,16 +11038,19 @@ static void decode_i64_mips16 (DisasContext *ctx,
} }
break; break;
case I64_DADDIU5: case I64_DADDIU5:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
offset = extended ? offset : ((int8_t)(offset << 3)) >> 3; offset = extended ? offset : ((int8_t)(offset << 3)) >> 3;
gen_arith_imm(ctx, OPC_DADDIU, ry, ry, offset); gen_arith_imm(ctx, OPC_DADDIU, ry, ry, offset);
break; break;
case I64_DADDIUPC: case I64_DADDIUPC:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
offset = extended ? offset : offset << 2; offset = extended ? offset : offset << 2;
gen_addiupc(ctx, ry, offset, 1, extended); gen_addiupc(ctx, ry, offset, 1, extended);
break; break;
case I64_DADDIUSP: case I64_DADDIUSP:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
offset = extended ? offset : offset << 2; offset = extended ? offset : offset << 2;
gen_arith_imm(ctx, OPC_DADDIU, ry, 29, offset); gen_arith_imm(ctx, OPC_DADDIU, ry, 29, offset);
@ -11103,6 +11119,7 @@ static int decode_extended_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case M16_OPC_LD: case M16_OPC_LD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_ld(ctx, OPC_LD, ry, rx, offset); gen_ld(ctx, OPC_LD, ry, rx, offset);
break; break;
@ -11147,6 +11164,7 @@ static int decode_extended_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
gen_arith_imm(ctx, OPC_ADDIU, 29, 29, imm); gen_arith_imm(ctx, OPC_ADDIU, 29, 29, imm);
break; break;
case I8_SVRS: case I8_SVRS:
check_insn(ctx, ISA_MIPS32);
{ {
int xsregs = (ctx->opcode >> 24) & 0x7; int xsregs = (ctx->opcode >> 24) & 0x7;
int aregs = (ctx->opcode >> 16) & 0xf; int aregs = (ctx->opcode >> 16) & 0xf;
@ -11180,6 +11198,8 @@ static int decode_extended_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case M16_OPC_SD: case M16_OPC_SD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_st(ctx, OPC_SD, ry, rx, offset); gen_st(ctx, OPC_SD, ry, rx, offset);
break; break;
#endif #endif
@ -11206,6 +11226,8 @@ static int decode_extended_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case M16_OPC_LWU: case M16_OPC_LWU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_ld(ctx, OPC_LWU, ry, rx, offset); gen_ld(ctx, OPC_LWU, ry, rx, offset);
break; break;
#endif #endif
@ -11295,6 +11317,7 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
case 0x1: case 0x1:
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSLL, rx, ry, sa); gen_shift_imm(ctx, OPC_DSLL, rx, ry, sa);
#else #else
@ -11311,6 +11334,7 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case M16_OPC_LD: case M16_OPC_LD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_ld(ctx, OPC_LD, ry, rx, offset << 3); gen_ld(ctx, OPC_LD, ry, rx, offset << 3);
break; break;
@ -11321,6 +11345,7 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
if ((ctx->opcode >> 4) & 1) { if ((ctx->opcode >> 4) & 1) {
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_arith_imm(ctx, OPC_DADDIU, ry, rx, imm); gen_arith_imm(ctx, OPC_DADDIU, ry, rx, imm);
#else #else
@ -11372,6 +11397,7 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
((int8_t)ctx->opcode) << 3); ((int8_t)ctx->opcode) << 3);
break; break;
case I8_SVRS: case I8_SVRS:
check_insn(ctx, ISA_MIPS32);
{ {
int do_ra = ctx->opcode & (1 << 6); int do_ra = ctx->opcode & (1 << 6);
int do_s0 = ctx->opcode & (1 << 5); int do_s0 = ctx->opcode & (1 << 5);
@ -11427,6 +11453,7 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case M16_OPC_SD: case M16_OPC_SD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_st(ctx, OPC_SD, ry, rx, offset << 3); gen_st(ctx, OPC_SD, ry, rx, offset << 3);
break; break;
@ -11454,6 +11481,7 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined (TARGET_MIPS64) #if defined (TARGET_MIPS64)
case M16_OPC_LWU: case M16_OPC_LWU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_ld(ctx, OPC_LWU, ry, rx, offset << 2); gen_ld(ctx, OPC_LWU, ry, rx, offset << 2);
break; break;
@ -11485,10 +11513,12 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case RRR_DADDU: case RRR_DADDU:
mips32_op = OPC_DADDU; mips32_op = OPC_DADDU;
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
break; break;
case RRR_DSUBU: case RRR_DSUBU:
mips32_op = OPC_DSUBU; mips32_op = OPC_DSUBU;
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
break; break;
#endif #endif
@ -11510,6 +11540,10 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
int link = (ctx->opcode >> 6) & 0x1; int link = (ctx->opcode >> 6) & 0x1;
int ra = (ctx->opcode >> 5) & 0x1; int ra = (ctx->opcode >> 5) & 0x1;
if (nd) {
check_insn(ctx, ISA_MIPS32);
}
if (link) { if (link) {
op = OPC_JALR; op = OPC_JALR;
} else { } else {
@ -11551,6 +11585,7 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined (TARGET_MIPS64) #if defined (TARGET_MIPS64)
case RR_DSRL: case RR_DSRL:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSRL, ry, ry, sa); gen_shift_imm(ctx, OPC_DSRL, ry, ry, sa);
break; break;
@ -11577,6 +11612,7 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
gen_HILO(ctx, OPC_MFHI, 0, rx); gen_HILO(ctx, OPC_MFHI, 0, rx);
break; break;
case RR_CNVT: case RR_CNVT:
check_insn(ctx, ISA_MIPS32);
switch (cnvt_op) { switch (cnvt_op) {
case RR_RY_CNVT_ZEB: case RR_RY_CNVT_ZEB:
tcg_gen_ext8u_tl(cpu_gpr[rx], cpu_gpr[rx]); tcg_gen_ext8u_tl(cpu_gpr[rx], cpu_gpr[rx]);
@ -11592,10 +11628,12 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined (TARGET_MIPS64) #if defined (TARGET_MIPS64)
case RR_RY_CNVT_ZEW: case RR_RY_CNVT_ZEW:
check_insn(ctx, ISA_MIPS64);
check_mips_64(ctx); check_mips_64(ctx);
tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]); tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break; break;
case RR_RY_CNVT_SEW: case RR_RY_CNVT_SEW:
check_insn(ctx, ISA_MIPS64);
check_mips_64(ctx); check_mips_64(ctx);
tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]); tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break; break;
@ -11610,18 +11648,22 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined (TARGET_MIPS64) #if defined (TARGET_MIPS64)
case RR_DSRA: case RR_DSRA:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSRA, ry, ry, sa); gen_shift_imm(ctx, OPC_DSRA, ry, ry, sa);
break; break;
case RR_DSLLV: case RR_DSLLV:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_shift(ctx, OPC_DSLLV, ry, rx, ry); gen_shift(ctx, OPC_DSLLV, ry, rx, ry);
break; break;
case RR_DSRLV: case RR_DSRLV:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_shift(ctx, OPC_DSRLV, ry, rx, ry); gen_shift(ctx, OPC_DSRLV, ry, rx, ry);
break; break;
case RR_DSRAV: case RR_DSRAV:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_shift(ctx, OPC_DSRAV, ry, rx, ry); gen_shift(ctx, OPC_DSRAV, ry, rx, ry);
break; break;
@ -11640,18 +11682,22 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
break; break;
#if defined (TARGET_MIPS64) #if defined (TARGET_MIPS64)
case RR_DMULT: case RR_DMULT:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULT, 0, rx, ry); gen_muldiv(ctx, OPC_DMULT, 0, rx, ry);
break; break;
case RR_DMULTU: case RR_DMULTU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULTU, 0, rx, ry); gen_muldiv(ctx, OPC_DMULTU, 0, rx, ry);
break; break;
case RR_DDIV: case RR_DDIV:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIV, 0, rx, ry); gen_muldiv(ctx, OPC_DDIV, 0, rx, ry);
break; break;
case RR_DDIVU: case RR_DDIVU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx); check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIVU, 0, rx, ry); gen_muldiv(ctx, OPC_DDIVU, 0, rx, ry);
break; break;
@ -13216,20 +13262,26 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
/* COP2: Not implemented. */ /* COP2: Not implemented. */
generate_exception_err(ctx, EXCP_CpU, 2); generate_exception_err(ctx, EXCP_CpU, 2);
break; break;
case LWP:
case SWP:
#ifdef TARGET_MIPS64 #ifdef TARGET_MIPS64
case LDP: case LDP:
case SDP: case SDP:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
/* Fallthrough */
#endif #endif
case LWP:
case SWP:
gen_ldst_pair(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12)); gen_ldst_pair(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
break; break;
case LWM32:
case SWM32:
#ifdef TARGET_MIPS64 #ifdef TARGET_MIPS64
case LDM: case LDM:
case SDM: case SDM:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
/* Fallthrough */
#endif #endif
case LWM32:
case SWM32:
gen_ldst_multiple(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12)); gen_ldst_multiple(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
break; break;
default: default:
@ -13653,21 +13705,33 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
goto do_st_lr; goto do_st_lr;
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case LDL: case LDL:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
mips32_op = OPC_LDL; mips32_op = OPC_LDL;
goto do_ld_lr; goto do_ld_lr;
case SDL: case SDL:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
mips32_op = OPC_SDL; mips32_op = OPC_SDL;
goto do_st_lr; goto do_st_lr;
case LDR: case LDR:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
mips32_op = OPC_LDR; mips32_op = OPC_LDR;
goto do_ld_lr; goto do_ld_lr;
case SDR: case SDR:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
mips32_op = OPC_SDR; mips32_op = OPC_SDR;
goto do_st_lr; goto do_st_lr;
case LWU: case LWU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
mips32_op = OPC_LWU; mips32_op = OPC_LWU;
goto do_ld_lr; goto do_ld_lr;
case LLD: case LLD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
mips32_op = OPC_LLD; mips32_op = OPC_LLD;
goto do_ld_lr; goto do_ld_lr;
#endif #endif
@ -13685,6 +13749,8 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
break; break;
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case SCD: case SCD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_st_cond(ctx, OPC_SCD, rt, rs, SIMM(ctx->opcode, 0, 12)); gen_st_cond(ctx, OPC_SCD, rt, rs, SIMM(ctx->opcode, 0, 12));
break; break;
#endif #endif
@ -13794,9 +13860,13 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
goto do_ld; goto do_ld;
#ifdef TARGET_MIPS64 #ifdef TARGET_MIPS64
case LD32: case LD32:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
mips32_op = OPC_LD; mips32_op = OPC_LD;
goto do_ld; goto do_ld;
case SD32: case SD32:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
mips32_op = OPC_SD; mips32_op = OPC_SD;
goto do_st; goto do_st;
#endif #endif
@ -16326,6 +16396,7 @@ static void decode_opc_special(CPUMIPSState *env, DisasContext *ctx)
break; break;
case OPC_TGE ... OPC_TEQ: /* Traps */ case OPC_TGE ... OPC_TEQ: /* Traps */
case OPC_TNE: case OPC_TNE:
check_insn(ctx, ISA_MIPS2);
gen_trap(ctx, op1, rs, rt, -1); gen_trap(ctx, op1, rs, rt, -1);
break; break;
case OPC_LSA: /* OPC_PMON */ case OPC_LSA: /* OPC_PMON */
@ -16350,6 +16421,7 @@ static void decode_opc_special(CPUMIPSState *env, DisasContext *ctx)
generate_exception(ctx, EXCP_BREAK); generate_exception(ctx, EXCP_BREAK);
break; break;
case OPC_SYNC: case OPC_SYNC:
check_insn(ctx, ISA_MIPS2);
/* Treat as NOP. */ /* Treat as NOP. */
break; break;
@ -18396,7 +18468,9 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
case OPC_BGEZL: case OPC_BGEZL:
case OPC_BLTZALL: case OPC_BLTZALL:
case OPC_BGEZALL: case OPC_BGEZALL:
check_insn(ctx, ISA_MIPS2);
check_insn_opc_removed(ctx, ISA_MIPS32R6); check_insn_opc_removed(ctx, ISA_MIPS32R6);
/* Fallthrough */
case OPC_BLTZ: case OPC_BLTZ:
case OPC_BGEZ: case OPC_BGEZ:
gen_compute_branch(ctx, op1, 4, rs, -1, imm << 2, 4); gen_compute_branch(ctx, op1, 4, rs, -1, imm << 2, 4);
@ -18416,6 +18490,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
break; break;
case OPC_TGEI ... OPC_TEQI: /* REGIMM traps */ case OPC_TGEI ... OPC_TEQI: /* REGIMM traps */
case OPC_TNEI: case OPC_TNEI:
check_insn(ctx, ISA_MIPS2);
check_insn_opc_removed(ctx, ISA_MIPS32R6); check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_trap(ctx, op1, rs, -1, imm); gen_trap(ctx, op1, rs, -1, imm);
break; break;
@ -18622,15 +18697,20 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
break; break;
case OPC_BEQL: case OPC_BEQL:
case OPC_BNEL: case OPC_BNEL:
check_insn(ctx, ISA_MIPS2);
check_insn_opc_removed(ctx, ISA_MIPS32R6); check_insn_opc_removed(ctx, ISA_MIPS32R6);
/* Fallthrough */
case OPC_BEQ: case OPC_BEQ:
case OPC_BNE: case OPC_BNE:
gen_compute_branch(ctx, op, 4, rs, rt, imm << 2, 4); gen_compute_branch(ctx, op, 4, rs, rt, imm << 2, 4);
break; break;
case OPC_LWL: /* Load and stores */ case OPC_LL: /* Load and stores */
check_insn(ctx, ISA_MIPS2);
/* Fallthrough */
case OPC_LWL:
case OPC_LWR: case OPC_LWR:
case OPC_LL:
check_insn_opc_removed(ctx, ISA_MIPS32R6); check_insn_opc_removed(ctx, ISA_MIPS32R6);
/* Fallthrough */
case OPC_LB ... OPC_LH: case OPC_LB ... OPC_LH:
case OPC_LW ... OPC_LHU: case OPC_LW ... OPC_LHU:
gen_ld(ctx, op, rt, rs, imm); gen_ld(ctx, op, rt, rs, imm);
@ -18643,6 +18723,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
gen_st(ctx, op, rt, rs, imm); gen_st(ctx, op, rt, rs, imm);
break; break;
case OPC_SC: case OPC_SC:
check_insn(ctx, ISA_MIPS2);
check_insn_opc_removed(ctx, ISA_MIPS32R6); check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_st_cond(ctx, op, rt, rs, imm); gen_st_cond(ctx, op, rt, rs, imm);
break; break;
@ -18686,6 +18767,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
case OPC_DMTC1: case OPC_DMTC1:
check_cp1_enabled(ctx); check_cp1_enabled(ctx);
check_insn(ctx, ISA_MIPS3); check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_cp1(ctx, op1, rt, rd); gen_cp1(ctx, op1, rt, rd);
break; break;
#endif #endif
@ -18859,18 +18941,24 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
check_cp1_enabled(ctx); check_cp1_enabled(ctx);
op1 = MASK_CP3(ctx->opcode); op1 = MASK_CP3(ctx->opcode);
switch (op1) { switch (op1) {
case OPC_LUXC1:
case OPC_SUXC1:
check_insn(ctx, ISA_MIPS5 | ISA_MIPS32R2);
/* Fallthrough */
case OPC_LWXC1: case OPC_LWXC1:
case OPC_LDXC1: case OPC_LDXC1:
case OPC_LUXC1:
case OPC_SWXC1: case OPC_SWXC1:
case OPC_SDXC1: case OPC_SDXC1:
case OPC_SUXC1: check_insn(ctx, ISA_MIPS4 | ISA_MIPS32R2);
gen_flt3_ldst(ctx, op1, sa, rd, rs, rt); gen_flt3_ldst(ctx, op1, sa, rd, rs, rt);
break; break;
case OPC_PREFX: case OPC_PREFX:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32R2);
/* Treat as NOP. */ /* Treat as NOP. */
break; break;
case OPC_ALNV_PS: case OPC_ALNV_PS:
check_insn(ctx, ISA_MIPS5 | ISA_MIPS32R2);
/* Fallthrough */
case OPC_MADD_S: case OPC_MADD_S:
case OPC_MADD_D: case OPC_MADD_D:
case OPC_MADD_PS: case OPC_MADD_PS:
@ -18883,6 +18971,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
case OPC_NMSUB_S: case OPC_NMSUB_S:
case OPC_NMSUB_D: case OPC_NMSUB_D:
case OPC_NMSUB_PS: case OPC_NMSUB_PS:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32R2);
gen_flt3_arith(ctx, op1, sa, rs, rd, rt); gen_flt3_arith(ctx, op1, sa, rs, rd, rt);
break; break;
default: default: