target-mips: extract decode_opc_special* from decode_opc
Creating separate decode functions for special, special2 and special3 instructions to ease adding new R6 instructions and removing legacy instructions. Signed-off-by: Leon Alrae <leon.alrae@imgtec.com> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
4368b29a26
commit
099e5b4d9f
|
@ -14482,43 +14482,16 @@ static void gen_mipsdsp_accinsn(DisasContext *ctx, uint32_t op1, uint32_t op2,
|
||||||
|
|
||||||
/* End MIPSDSP functions. */
|
/* End MIPSDSP functions. */
|
||||||
|
|
||||||
static void decode_opc (CPUMIPSState *env, DisasContext *ctx)
|
static void decode_opc_special(CPUMIPSState *env, DisasContext *ctx)
|
||||||
{
|
{
|
||||||
int32_t offset;
|
|
||||||
int rs, rt, rd, sa;
|
int rs, rt, rd, sa;
|
||||||
uint32_t op, op1, op2;
|
uint32_t op1;
|
||||||
int16_t imm;
|
|
||||||
|
|
||||||
/* make sure instructions are on a word boundary */
|
|
||||||
if (ctx->pc & 0x3) {
|
|
||||||
env->CP0_BadVAddr = ctx->pc;
|
|
||||||
generate_exception(ctx, EXCP_AdEL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Handle blikely not taken case */
|
|
||||||
if ((ctx->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) {
|
|
||||||
int l1 = gen_new_label();
|
|
||||||
|
|
||||||
MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4);
|
|
||||||
tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1);
|
|
||||||
tcg_gen_movi_i32(hflags, ctx->hflags & ~MIPS_HFLAG_BMASK);
|
|
||||||
gen_goto_tb(ctx, 1, ctx->pc + 4);
|
|
||||||
gen_set_label(l1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
|
|
||||||
tcg_gen_debug_insn_start(ctx->pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
op = MASK_OP_MAJOR(ctx->opcode);
|
|
||||||
rs = (ctx->opcode >> 21) & 0x1f;
|
rs = (ctx->opcode >> 21) & 0x1f;
|
||||||
rt = (ctx->opcode >> 16) & 0x1f;
|
rt = (ctx->opcode >> 16) & 0x1f;
|
||||||
rd = (ctx->opcode >> 11) & 0x1f;
|
rd = (ctx->opcode >> 11) & 0x1f;
|
||||||
sa = (ctx->opcode >> 6) & 0x1f;
|
sa = (ctx->opcode >> 6) & 0x1f;
|
||||||
imm = (int16_t)ctx->opcode;
|
|
||||||
switch (op) {
|
|
||||||
case OPC_SPECIAL:
|
|
||||||
op1 = MASK_SPECIAL(ctx->opcode);
|
op1 = MASK_SPECIAL(ctx->opcode);
|
||||||
switch (op1) {
|
switch (op1) {
|
||||||
case OPC_SLL: /* Shift with immediate */
|
case OPC_SLL: /* Shift with immediate */
|
||||||
|
@ -14744,8 +14717,17 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx)
|
||||||
generate_exception(ctx, EXCP_RI);
|
generate_exception(ctx, EXCP_RI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case OPC_SPECIAL2:
|
|
||||||
|
static void decode_opc_special2(CPUMIPSState *env, DisasContext *ctx)
|
||||||
|
{
|
||||||
|
int rs, rt, rd;
|
||||||
|
uint32_t op1;
|
||||||
|
|
||||||
|
rs = (ctx->opcode >> 21) & 0x1f;
|
||||||
|
rt = (ctx->opcode >> 16) & 0x1f;
|
||||||
|
rd = (ctx->opcode >> 11) & 0x1f;
|
||||||
|
|
||||||
op1 = MASK_SPECIAL2(ctx->opcode);
|
op1 = MASK_SPECIAL2(ctx->opcode);
|
||||||
switch (op1) {
|
switch (op1) {
|
||||||
case OPC_MADD ... OPC_MADDU: /* Multiply and add/sub */
|
case OPC_MADD ... OPC_MADDU: /* Multiply and add/sub */
|
||||||
|
@ -14806,8 +14788,19 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx)
|
||||||
generate_exception(ctx, EXCP_RI);
|
generate_exception(ctx, EXCP_RI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case OPC_SPECIAL3:
|
static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)
|
||||||
|
{
|
||||||
|
int rs, rt, rd, sa;
|
||||||
|
uint32_t op1, op2;
|
||||||
|
int16_t imm;
|
||||||
|
|
||||||
|
rs = (ctx->opcode >> 21) & 0x1f;
|
||||||
|
rt = (ctx->opcode >> 16) & 0x1f;
|
||||||
|
rd = (ctx->opcode >> 11) & 0x1f;
|
||||||
|
sa = (ctx->opcode >> 6) & 0x1f;
|
||||||
|
imm = (int16_t)ctx->opcode;
|
||||||
|
|
||||||
op1 = MASK_SPECIAL3(ctx->opcode);
|
op1 = MASK_SPECIAL3(ctx->opcode);
|
||||||
switch (op1) {
|
switch (op1) {
|
||||||
case R6_OPC_LL:
|
case R6_OPC_LL:
|
||||||
|
@ -15386,6 +15379,52 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx)
|
||||||
generate_exception(ctx, EXCP_RI);
|
generate_exception(ctx, EXCP_RI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void decode_opc (CPUMIPSState *env, DisasContext *ctx)
|
||||||
|
{
|
||||||
|
int32_t offset;
|
||||||
|
int rs, rt, rd, sa;
|
||||||
|
uint32_t op, op1;
|
||||||
|
int16_t imm;
|
||||||
|
|
||||||
|
/* make sure instructions are on a word boundary */
|
||||||
|
if (ctx->pc & 0x3) {
|
||||||
|
env->CP0_BadVAddr = ctx->pc;
|
||||||
|
generate_exception(ctx, EXCP_AdEL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle blikely not taken case */
|
||||||
|
if ((ctx->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) {
|
||||||
|
int l1 = gen_new_label();
|
||||||
|
|
||||||
|
MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4);
|
||||||
|
tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1);
|
||||||
|
tcg_gen_movi_i32(hflags, ctx->hflags & ~MIPS_HFLAG_BMASK);
|
||||||
|
gen_goto_tb(ctx, 1, ctx->pc + 4);
|
||||||
|
gen_set_label(l1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
|
||||||
|
tcg_gen_debug_insn_start(ctx->pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
op = MASK_OP_MAJOR(ctx->opcode);
|
||||||
|
rs = (ctx->opcode >> 21) & 0x1f;
|
||||||
|
rt = (ctx->opcode >> 16) & 0x1f;
|
||||||
|
rd = (ctx->opcode >> 11) & 0x1f;
|
||||||
|
sa = (ctx->opcode >> 6) & 0x1f;
|
||||||
|
imm = (int16_t)ctx->opcode;
|
||||||
|
switch (op) {
|
||||||
|
case OPC_SPECIAL:
|
||||||
|
decode_opc_special(env, ctx);
|
||||||
|
break;
|
||||||
|
case OPC_SPECIAL2:
|
||||||
|
decode_opc_special2(env, ctx);
|
||||||
|
break;
|
||||||
|
case OPC_SPECIAL3:
|
||||||
|
decode_opc_special3(env, ctx);
|
||||||
break;
|
break;
|
||||||
case OPC_REGIMM:
|
case OPC_REGIMM:
|
||||||
op1 = MASK_REGIMM(ctx->opcode);
|
op1 = MASK_REGIMM(ctx->opcode);
|
||||||
|
@ -15447,6 +15486,7 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx)
|
||||||
case OPC_MFMC0:
|
case OPC_MFMC0:
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
{
|
{
|
||||||
|
uint32_t op2;
|
||||||
TCGv t0 = tcg_temp_new();
|
TCGv t0 = tcg_temp_new();
|
||||||
|
|
||||||
op2 = MASK_MFMC0(ctx->opcode);
|
op2 = MASK_MFMC0(ctx->opcode);
|
||||||
|
|
Loading…
Reference in a new issue