mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 15:15:38 +00:00
target/sparc: convert to DisasJumpType
Backports commit c5e6ccdf6c8d32d3a45d9dca4d6847dcff741882 from qemu
This commit is contained in:
parent
d26bf1d446
commit
3180dcaa98
|
@ -30,6 +30,8 @@
|
||||||
#include "exec/gen-icount.h"
|
#include "exec/gen-icount.h"
|
||||||
#include "asi.h"
|
#include "asi.h"
|
||||||
|
|
||||||
|
#include "exec/translator.h"
|
||||||
|
|
||||||
#define DYNAMIC_PC 1 /* dynamic pc value */
|
#define DYNAMIC_PC 1 /* dynamic pc value */
|
||||||
#define JUMP_PC 2 /* dynamic pc value which takes only two values
|
#define JUMP_PC 2 /* dynamic pc value which takes only two values
|
||||||
according to jump_pc[T2] */
|
according to jump_pc[T2] */
|
||||||
|
@ -39,7 +41,7 @@ typedef struct DisasContext {
|
||||||
target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */
|
target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */
|
||||||
target_ulong npc; /* next PC: integer or DYNAMIC_PC or JUMP_PC */
|
target_ulong npc; /* next PC: integer or DYNAMIC_PC or JUMP_PC */
|
||||||
target_ulong jump_pc[2]; /* used when JUMP_PC pc value is used */
|
target_ulong jump_pc[2]; /* used when JUMP_PC pc value is used */
|
||||||
int is_br;
|
DisasJumpType is_jmp;
|
||||||
int mem_idx;
|
int mem_idx;
|
||||||
bool fpu_enabled;
|
bool fpu_enabled;
|
||||||
bool address_mask_32bit;
|
bool address_mask_32bit;
|
||||||
|
@ -1069,7 +1071,7 @@ static void gen_branch_a(DisasContext *dc, target_ulong pc1)
|
||||||
gen_set_label(tcg_ctx, l1);
|
gen_set_label(tcg_ctx, l1);
|
||||||
gen_goto_tb(dc, 1, npc + 4, npc + 8);
|
gen_goto_tb(dc, 1, npc + 4, npc + 8);
|
||||||
|
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_branch_n(DisasContext *dc, target_ulong pc1)
|
static void gen_branch_n(DisasContext *dc, target_ulong pc1)
|
||||||
|
@ -1159,7 +1161,7 @@ static void gen_exception(DisasContext *dc, int which)
|
||||||
t = tcg_const_i32(tcg_ctx, which);
|
t = tcg_const_i32(tcg_ctx, which);
|
||||||
gen_helper_raise_exception(tcg_ctx, tcg_ctx->cpu_env, t);
|
gen_helper_raise_exception(tcg_ctx, tcg_ctx->cpu_env, t);
|
||||||
tcg_temp_free_i32(tcg_ctx, t);
|
tcg_temp_free_i32(tcg_ctx, t);
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_check_align(DisasContext *dc, TCGv addr, int mask)
|
static void gen_check_align(DisasContext *dc, TCGv addr, int mask)
|
||||||
|
@ -3531,7 +3533,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
|
||||||
|
|
||||||
if (cond == 8) {
|
if (cond == 8) {
|
||||||
/* An unconditional trap ends the TB. */
|
/* An unconditional trap ends the TB. */
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
goto jmp_insn;
|
goto jmp_insn;
|
||||||
} else {
|
} else {
|
||||||
/* A conditional trap falls through to the next insn. */
|
/* A conditional trap falls through to the next insn. */
|
||||||
|
@ -4511,7 +4513,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
|
||||||
save_state(dc);
|
save_state(dc);
|
||||||
gen_op_next_insn(dc);
|
gen_op_next_insn(dc);
|
||||||
tcg_gen_exit_tb(tcg_ctx, 0);
|
tcg_gen_exit_tb(tcg_ctx, 0);
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
break;
|
break;
|
||||||
case 0x6: /* V9 wrfprs */
|
case 0x6: /* V9 wrfprs */
|
||||||
tcg_gen_xor_tl(tcg_ctx, cpu_tmp0, cpu_src1, cpu_src2);
|
tcg_gen_xor_tl(tcg_ctx, cpu_tmp0, cpu_src1, cpu_src2);
|
||||||
|
@ -4520,7 +4522,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
|
||||||
save_state(dc);
|
save_state(dc);
|
||||||
gen_op_next_insn(dc);
|
gen_op_next_insn(dc);
|
||||||
tcg_gen_exit_tb(tcg_ctx, 0);
|
tcg_gen_exit_tb(tcg_ctx, 0);
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
break;
|
break;
|
||||||
case 0xf: /* V9 sir, nop if user */
|
case 0xf: /* V9 sir, nop if user */
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
#if !defined(CONFIG_USER_ONLY)
|
||||||
|
@ -4648,7 +4650,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
|
||||||
save_state(dc);
|
save_state(dc);
|
||||||
gen_op_next_insn(dc);
|
gen_op_next_insn(dc);
|
||||||
tcg_gen_exit_tb(tcg_ctx, 0);
|
tcg_gen_exit_tb(tcg_ctx, 0);
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -4804,7 +4806,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
|
||||||
save_state(dc);
|
save_state(dc);
|
||||||
gen_op_next_insn(dc);
|
gen_op_next_insn(dc);
|
||||||
tcg_gen_exit_tb(tcg_ctx, 0);
|
tcg_gen_exit_tb(tcg_ctx, 0);
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
break;
|
break;
|
||||||
case 1: // htstate
|
case 1: // htstate
|
||||||
// XXX gen_op_wrhtstate();
|
// XXX gen_op_wrhtstate();
|
||||||
|
@ -5873,7 +5875,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
|
||||||
} else if (dc->npc == JUMP_PC) {
|
} else if (dc->npc == JUMP_PC) {
|
||||||
/* we can do a static jump */
|
/* we can do a static jump */
|
||||||
gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], tcg_ctx->cpu_cond);
|
gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], tcg_ctx->cpu_cond);
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
} else {
|
} else {
|
||||||
dc->pc = dc->npc;
|
dc->pc = dc->npc;
|
||||||
dc->npc = dc->npc + 4;
|
dc->npc = dc->npc + 4;
|
||||||
|
@ -5938,6 +5940,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb)
|
||||||
pc_start = tb->pc;
|
pc_start = tb->pc;
|
||||||
dc->pc = pc_start;
|
dc->pc = pc_start;
|
||||||
last_pc = dc->pc;
|
last_pc = dc->pc;
|
||||||
|
dc->is_jmp = DISAS_NEXT;
|
||||||
dc->npc = (target_ulong) tb->cs_base;
|
dc->npc = (target_ulong) tb->cs_base;
|
||||||
dc->cc_op = CC_OP_DYNAMIC;
|
dc->cc_op = CC_OP_DYNAMIC;
|
||||||
dc->mem_idx = tb->flags & TB_FLAG_MMU_MASK;
|
dc->mem_idx = tb->flags & TB_FLAG_MMU_MASK;
|
||||||
|
@ -6009,7 +6012,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb)
|
||||||
}
|
}
|
||||||
gen_helper_debug(tcg_ctx, tcg_ctx->cpu_env);
|
gen_helper_debug(tcg_ctx, tcg_ctx->cpu_env);
|
||||||
tcg_gen_exit_tb(tcg_ctx, 0);
|
tcg_gen_exit_tb(tcg_ctx, 0);
|
||||||
dc->is_br = 1;
|
dc->is_jmp = DISAS_NORETURN;
|
||||||
goto exit_gen_loop;
|
goto exit_gen_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6028,8 +6031,9 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb)
|
||||||
|
|
||||||
disas_sparc_insn(dc, insn, true);
|
disas_sparc_insn(dc, insn, true);
|
||||||
|
|
||||||
if (dc->is_br)
|
if (dc->is_jmp == DISAS_NORETURN) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* if the next PC is different, we abort now */
|
/* if the next PC is different, we abort now */
|
||||||
if (dc->pc != (last_pc + 4))
|
if (dc->pc != (last_pc + 4))
|
||||||
break;
|
break;
|
||||||
|
@ -6055,7 +6059,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb)
|
||||||
//if (tb->cflags & CF_LAST_IO) {
|
//if (tb->cflags & CF_LAST_IO) {
|
||||||
// gen_io_end();
|
// gen_io_end();
|
||||||
//}
|
//}
|
||||||
if (!dc->is_br) {
|
if (dc->is_jmp != DISAS_NORETURN) {
|
||||||
if (dc->pc != DYNAMIC_PC &&
|
if (dc->pc != DYNAMIC_PC &&
|
||||||
(dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
|
(dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
|
||||||
/* static PC and NPC: we can use direct chaining */
|
/* static PC and NPC: we can use direct chaining */
|
||||||
|
|
Loading…
Reference in a new issue