target/sparc: convert to DisasJumpType

Backports commit c5e6ccdf6c8d32d3a45d9dca4d6847dcff741882 from qemu
This commit is contained in:
Emilio G. Cota 2018-05-11 14:03:18 -04:00 committed by Lioncash
parent d26bf1d446
commit 3180dcaa98
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7

View File

@ -30,6 +30,8 @@
#include "exec/gen-icount.h"
#include "asi.h"
#include "exec/translator.h"
#define DYNAMIC_PC 1 /* dynamic pc value */
#define JUMP_PC 2 /* dynamic pc value which takes only two values
according to jump_pc[T2] */
@ -39,7 +41,7 @@ typedef struct DisasContext {
target_ulong pc; /* current Program Counter: integer or DYNAMIC_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 */
int is_br;
DisasJumpType is_jmp;
int mem_idx;
bool fpu_enabled;
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_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)
@ -1159,7 +1161,7 @@ static void gen_exception(DisasContext *dc, int which)
t = tcg_const_i32(tcg_ctx, which);
gen_helper_raise_exception(tcg_ctx, tcg_ctx->cpu_env, 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)
@ -3531,7 +3533,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
if (cond == 8) {
/* An unconditional trap ends the TB. */
dc->is_br = 1;
dc->is_jmp = DISAS_NORETURN;
goto jmp_insn;
} else {
/* 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);
gen_op_next_insn(dc);
tcg_gen_exit_tb(tcg_ctx, 0);
dc->is_br = 1;
dc->is_jmp = DISAS_NORETURN;
break;
case 0x6: /* V9 wrfprs */
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);
gen_op_next_insn(dc);
tcg_gen_exit_tb(tcg_ctx, 0);
dc->is_br = 1;
dc->is_jmp = DISAS_NORETURN;
break;
case 0xf: /* V9 sir, nop if user */
#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);
gen_op_next_insn(dc);
tcg_gen_exit_tb(tcg_ctx, 0);
dc->is_br = 1;
dc->is_jmp = DISAS_NORETURN;
#endif
}
break;
@ -4804,7 +4806,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
save_state(dc);
gen_op_next_insn(dc);
tcg_gen_exit_tb(tcg_ctx, 0);
dc->is_br = 1;
dc->is_jmp = DISAS_NORETURN;
break;
case 1: // htstate
// 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) {
/* we can do a static jump */
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 {
dc->pc = dc->npc;
dc->npc = dc->npc + 4;
@ -5938,6 +5940,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb)
pc_start = tb->pc;
dc->pc = pc_start;
last_pc = dc->pc;
dc->is_jmp = DISAS_NEXT;
dc->npc = (target_ulong) tb->cs_base;
dc->cc_op = CC_OP_DYNAMIC;
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);
tcg_gen_exit_tb(tcg_ctx, 0);
dc->is_br = 1;
dc->is_jmp = DISAS_NORETURN;
goto exit_gen_loop;
}
@ -6028,8 +6031,9 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb)
disas_sparc_insn(dc, insn, true);
if (dc->is_br)
if (dc->is_jmp == DISAS_NORETURN) {
break;
}
/* if the next PC is different, we abort now */
if (dc->pc != (last_pc + 4))
break;
@ -6055,7 +6059,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb)
//if (tb->cflags & CF_LAST_IO) {
// gen_io_end();
//}
if (!dc->is_br) {
if (dc->is_jmp != DISAS_NORETURN) {
if (dc->pc != DYNAMIC_PC &&
(dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
/* static PC and NPC: we can use direct chaining */