mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-07-07 23:10:35 +00:00
target/arm: [tcg,a64] Port to translate_insn
Incrementally paves the way towards using the generic instruction translation loop. Backports commit 24299c892cbfe29120f051b6b7d0bcf3e0cc8e85 from qemu
This commit is contained in:
parent
0c4909738d
commit
665192d96f
|
@ -11501,6 +11501,9 @@ static int aarch64_tr_init_disas_context(DisasContextBase *dcbase,
|
||||||
dc->is_ldex = false;
|
dc->is_ldex = false;
|
||||||
dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el);
|
dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el);
|
||||||
|
|
||||||
|
dc->next_page_start =
|
||||||
|
(dc->base.pc_first & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
|
||||||
|
|
||||||
init_tmp_a64_array(dc);
|
init_tmp_a64_array(dc);
|
||||||
|
|
||||||
return max_insns;
|
return max_insns;
|
||||||
|
@ -11540,13 +11543,45 @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
|
||||||
|
{
|
||||||
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
||||||
|
CPUARMState *env = cpu->env_ptr;
|
||||||
|
|
||||||
|
if (dc->ss_active && !dc->pstate_ss) {
|
||||||
|
/* Singlestep state is Active-pending.
|
||||||
|
* If we're in this state at the start of a TB then either
|
||||||
|
* a) we just took an exception to an EL which is being debugged
|
||||||
|
* and this is the first insn in the exception handler
|
||||||
|
* b) debug exceptions were masked and we just unmasked them
|
||||||
|
* without changing EL (eg by clearing PSTATE.D)
|
||||||
|
* In either case we're going to take a swstep exception in the
|
||||||
|
* "did not step an insn" case, and so the syndrome ISV and EX
|
||||||
|
* bits should be zero.
|
||||||
|
*/
|
||||||
|
assert(dc->base.num_insns == 1);
|
||||||
|
gen_exception(dc, EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
|
||||||
|
default_exception_el(dc));
|
||||||
|
dc->base.is_jmp = DISAS_NORETURN;
|
||||||
|
} else {
|
||||||
|
disas_a64_insn(env, dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dc->base.is_jmp == DISAS_NEXT) {
|
||||||
|
if (dc->ss_active || dc->pc >= dc->next_page_start) {
|
||||||
|
dc->base.is_jmp = DISAS_TOO_MANY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dc->base.pc_next = dc->pc;
|
||||||
|
}
|
||||||
|
|
||||||
void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs,
|
void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs,
|
||||||
TranslationBlock *tb)
|
TranslationBlock *tb)
|
||||||
{
|
{
|
||||||
CPUARMState *env = cs->env_ptr;
|
CPUARMState *env = cs->env_ptr;
|
||||||
TCGContext *tcg_ctx = env->uc->tcg_ctx;
|
TCGContext *tcg_ctx = env->uc->tcg_ctx;
|
||||||
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
||||||
target_ulong next_page_start;
|
|
||||||
int max_insns;
|
int max_insns;
|
||||||
bool block_full = false;
|
bool block_full = false;
|
||||||
|
|
||||||
|
@ -11557,7 +11592,6 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs,
|
||||||
dc->base.num_insns = 0;
|
dc->base.num_insns = 0;
|
||||||
dc->base.singlestep_enabled = cs->singlestep_enabled;
|
dc->base.singlestep_enabled = cs->singlestep_enabled;
|
||||||
|
|
||||||
next_page_start = (dc->base.pc_first & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
|
|
||||||
max_insns = dc->base.tb->cflags & CF_COUNT_MASK;
|
max_insns = dc->base.tb->cflags & CF_COUNT_MASK;
|
||||||
if (max_insns == 0) {
|
if (max_insns == 0) {
|
||||||
max_insns = CF_COUNT_MASK;
|
max_insns = CF_COUNT_MASK;
|
||||||
|
@ -11613,41 +11647,24 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs,
|
||||||
// gen_io_start();
|
// gen_io_start();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (dc->ss_active && !dc->pstate_ss) {
|
aarch64_tr_translate_insn(&dc->base, cs);
|
||||||
/* Singlestep state is Active-pending.
|
|
||||||
* If we're in this state at the start of a TB then either
|
|
||||||
* a) we just took an exception to an EL which is being debugged
|
|
||||||
* and this is the first insn in the exception handler
|
|
||||||
* b) debug exceptions were masked and we just unmasked them
|
|
||||||
* without changing EL (eg by clearing PSTATE.D)
|
|
||||||
* In either case we're going to take a swstep exception in the
|
|
||||||
* "did not step an insn" case, and so the syndrome ISV and EX
|
|
||||||
* bits should be zero.
|
|
||||||
*/
|
|
||||||
assert(dc->base.num_insns == 1);
|
|
||||||
gen_exception(dc, EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
|
|
||||||
default_exception_el(dc));
|
|
||||||
dc->base.is_jmp = DISAS_NORETURN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
disas_a64_insn(env, dc);
|
|
||||||
|
|
||||||
if (tcg_check_temp_count()) {
|
if (tcg_check_temp_count()) {
|
||||||
fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n",
|
fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n",
|
||||||
dc->pc);
|
dc->pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dc->base.is_jmp && (tcg_op_buf_full(tcg_ctx) || cs->singlestep_enabled ||
|
||||||
|
/* Unicorn: commented out: singlestep ||*/ dc->base.num_insns >= max_insns)) {
|
||||||
|
dc->base.is_jmp = DISAS_TOO_MANY;
|
||||||
|
}
|
||||||
|
|
||||||
/* Translation stops when a conditional branch is encountered.
|
/* Translation stops when a conditional branch is encountered.
|
||||||
* Otherwise the subsequent code could get translated several times.
|
* Otherwise the subsequent code could get translated several times.
|
||||||
* Also stop translation when a page boundary is reached. This
|
* Also stop translation when a page boundary is reached. This
|
||||||
* ensures prefetch aborts occur at the right place.
|
* ensures prefetch aborts occur at the right place.
|
||||||
*/
|
*/
|
||||||
} while (!dc->base.is_jmp && !tcg_op_buf_full(tcg_ctx) &&
|
} while (!dc->base.is_jmp);
|
||||||
!cs->singlestep_enabled &&
|
|
||||||
!dc->ss_active &&
|
|
||||||
dc->pc < next_page_start &&
|
|
||||||
dc->base.num_insns < max_insns);
|
|
||||||
|
|
||||||
/* if too long translation, save this info */
|
/* if too long translation, save this info */
|
||||||
if (tcg_op_buf_full(tcg_ctx) || dc->base.num_insns >= max_insns) {
|
if (tcg_op_buf_full(tcg_ctx) || dc->base.num_insns >= max_insns) {
|
||||||
|
|
Loading…
Reference in a new issue