Skip to content

Commit bc7edcc

Browse files
rth7680pm215
authored andcommitted
target/arm: Merge disas_a64_insn into aarch64_tr_translate_insn
It is confusing to have different exits from translation for various conditions in separate functions. Merge disas_a64_insn into its only caller. Standardize on the "s" name for the DisasContext, as the code from disas_a64_insn had more instances. Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]>
1 parent 520d162 commit bc7edcc

File tree

1 file changed

+109
-115
lines changed

1 file changed

+109
-115
lines changed

target/arm/translate-a64.c

Lines changed: 109 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -14649,113 +14649,6 @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype)
1464914649
return false;
1465014650
}
1465114651

14652-
/* C3.1 A64 instruction index by encoding */
14653-
static void disas_a64_insn(CPUARMState *env, DisasContext *s)
14654-
{
14655-
uint32_t insn;
14656-
14657-
s->pc_curr = s->base.pc_next;
14658-
insn = arm_ldl_code(env, s->base.pc_next, s->sctlr_b);
14659-
s->insn = insn;
14660-
s->base.pc_next += 4;
14661-
14662-
s->fp_access_checked = false;
14663-
s->sve_access_checked = false;
14664-
14665-
if (s->pstate_il) {
14666-
/*
14667-
* Illegal execution state. This has priority over BTI
14668-
* exceptions, but comes after instruction abort exceptions.
14669-
*/
14670-
gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
14671-
syn_illegalstate(), default_exception_el(s));
14672-
return;
14673-
}
14674-
14675-
if (dc_isar_feature(aa64_bti, s)) {
14676-
if (s->base.num_insns == 1) {
14677-
/*
14678-
* At the first insn of the TB, compute s->guarded_page.
14679-
* We delayed computing this until successfully reading
14680-
* the first insn of the TB, above. This (mostly) ensures
14681-
* that the softmmu tlb entry has been populated, and the
14682-
* page table GP bit is available.
14683-
*
14684-
* Note that we need to compute this even if btype == 0,
14685-
* because this value is used for BR instructions later
14686-
* where ENV is not available.
14687-
*/
14688-
s->guarded_page = is_guarded_page(env, s);
14689-
14690-
/* First insn can have btype set to non-zero. */
14691-
tcg_debug_assert(s->btype >= 0);
14692-
14693-
/*
14694-
* Note that the Branch Target Exception has fairly high
14695-
* priority -- below debugging exceptions but above most
14696-
* everything else. This allows us to handle this now
14697-
* instead of waiting until the insn is otherwise decoded.
14698-
*/
14699-
if (s->btype != 0
14700-
&& s->guarded_page
14701-
&& !btype_destination_ok(insn, s->bt, s->btype)) {
14702-
gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
14703-
syn_btitrap(s->btype),
14704-
default_exception_el(s));
14705-
return;
14706-
}
14707-
} else {
14708-
/* Not the first insn: btype must be 0. */
14709-
tcg_debug_assert(s->btype == 0);
14710-
}
14711-
}
14712-
14713-
switch (extract32(insn, 25, 4)) {
14714-
case 0x0: case 0x1: case 0x3: /* UNALLOCATED */
14715-
unallocated_encoding(s);
14716-
break;
14717-
case 0x2:
14718-
if (!dc_isar_feature(aa64_sve, s) || !disas_sve(s, insn)) {
14719-
unallocated_encoding(s);
14720-
}
14721-
break;
14722-
case 0x8: case 0x9: /* Data processing - immediate */
14723-
disas_data_proc_imm(s, insn);
14724-
break;
14725-
case 0xa: case 0xb: /* Branch, exception generation and system insns */
14726-
disas_b_exc_sys(s, insn);
14727-
break;
14728-
case 0x4:
14729-
case 0x6:
14730-
case 0xc:
14731-
case 0xe: /* Loads and stores */
14732-
disas_ldst(s, insn);
14733-
break;
14734-
case 0x5:
14735-
case 0xd: /* Data processing - register */
14736-
disas_data_proc_reg(s, insn);
14737-
break;
14738-
case 0x7:
14739-
case 0xf: /* Data processing - SIMD and floating point */
14740-
disas_data_proc_simd_fp(s, insn);
14741-
break;
14742-
default:
14743-
assert(FALSE); /* all 15 cases should be handled above */
14744-
break;
14745-
}
14746-
14747-
/* if we allocated any temporaries, free them here */
14748-
free_tmp_a64(s);
14749-
14750-
/*
14751-
* After execution of most insns, btype is reset to 0.
14752-
* Note that we set btype == -1 when the insn sets btype.
14753-
*/
14754-
if (s->btype > 0 && s->base.is_jmp != DISAS_NORETURN) {
14755-
reset_btype(s);
14756-
}
14757-
}
14758-
1475914652
static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
1476014653
CPUState *cpu)
1476114654
{
@@ -14857,10 +14750,11 @@ static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
1485714750

1485814751
static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
1485914752
{
14860-
DisasContext *dc = container_of(dcbase, DisasContext, base);
14753+
DisasContext *s = container_of(dcbase, DisasContext, base);
1486114754
CPUARMState *env = cpu->env_ptr;
14755+
uint32_t insn;
1486214756

14863-
if (dc->ss_active && !dc->pstate_ss) {
14757+
if (s->ss_active && !s->pstate_ss) {
1486414758
/* Singlestep state is Active-pending.
1486514759
* If we're in this state at the start of a TB then either
1486614760
* a) we just took an exception to an EL which is being debugged
@@ -14871,14 +14765,114 @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
1487114765
* "did not step an insn" case, and so the syndrome ISV and EX
1487214766
* bits should be zero.
1487314767
*/
14874-
assert(dc->base.num_insns == 1);
14875-
gen_swstep_exception(dc, 0, 0);
14876-
dc->base.is_jmp = DISAS_NORETURN;
14877-
} else {
14878-
disas_a64_insn(env, dc);
14768+
assert(s->base.num_insns == 1);
14769+
gen_swstep_exception(s, 0, 0);
14770+
s->base.is_jmp = DISAS_NORETURN;
14771+
return;
14772+
}
14773+
14774+
s->pc_curr = s->base.pc_next;
14775+
insn = arm_ldl_code(env, s->base.pc_next, s->sctlr_b);
14776+
s->insn = insn;
14777+
s->base.pc_next += 4;
14778+
14779+
s->fp_access_checked = false;
14780+
s->sve_access_checked = false;
14781+
14782+
if (s->pstate_il) {
14783+
/*
14784+
* Illegal execution state. This has priority over BTI
14785+
* exceptions, but comes after instruction abort exceptions.
14786+
*/
14787+
gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
14788+
syn_illegalstate(), default_exception_el(s));
14789+
return;
14790+
}
14791+
14792+
if (dc_isar_feature(aa64_bti, s)) {
14793+
if (s->base.num_insns == 1) {
14794+
/*
14795+
* At the first insn of the TB, compute s->guarded_page.
14796+
* We delayed computing this until successfully reading
14797+
* the first insn of the TB, above. This (mostly) ensures
14798+
* that the softmmu tlb entry has been populated, and the
14799+
* page table GP bit is available.
14800+
*
14801+
* Note that we need to compute this even if btype == 0,
14802+
* because this value is used for BR instructions later
14803+
* where ENV is not available.
14804+
*/
14805+
s->guarded_page = is_guarded_page(env, s);
14806+
14807+
/* First insn can have btype set to non-zero. */
14808+
tcg_debug_assert(s->btype >= 0);
14809+
14810+
/*
14811+
* Note that the Branch Target Exception has fairly high
14812+
* priority -- below debugging exceptions but above most
14813+
* everything else. This allows us to handle this now
14814+
* instead of waiting until the insn is otherwise decoded.
14815+
*/
14816+
if (s->btype != 0
14817+
&& s->guarded_page
14818+
&& !btype_destination_ok(insn, s->bt, s->btype)) {
14819+
gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
14820+
syn_btitrap(s->btype),
14821+
default_exception_el(s));
14822+
return;
14823+
}
14824+
} else {
14825+
/* Not the first insn: btype must be 0. */
14826+
tcg_debug_assert(s->btype == 0);
14827+
}
14828+
}
14829+
14830+
switch (extract32(insn, 25, 4)) {
14831+
case 0x0: case 0x1: case 0x3: /* UNALLOCATED */
14832+
unallocated_encoding(s);
14833+
break;
14834+
case 0x2:
14835+
if (!dc_isar_feature(aa64_sve, s) || !disas_sve(s, insn)) {
14836+
unallocated_encoding(s);
14837+
}
14838+
break;
14839+
case 0x8: case 0x9: /* Data processing - immediate */
14840+
disas_data_proc_imm(s, insn);
14841+
break;
14842+
case 0xa: case 0xb: /* Branch, exception generation and system insns */
14843+
disas_b_exc_sys(s, insn);
14844+
break;
14845+
case 0x4:
14846+
case 0x6:
14847+
case 0xc:
14848+
case 0xe: /* Loads and stores */
14849+
disas_ldst(s, insn);
14850+
break;
14851+
case 0x5:
14852+
case 0xd: /* Data processing - register */
14853+
disas_data_proc_reg(s, insn);
14854+
break;
14855+
case 0x7:
14856+
case 0xf: /* Data processing - SIMD and floating point */
14857+
disas_data_proc_simd_fp(s, insn);
14858+
break;
14859+
default:
14860+
assert(FALSE); /* all 15 cases should be handled above */
14861+
break;
14862+
}
14863+
14864+
/* if we allocated any temporaries, free them here */
14865+
free_tmp_a64(s);
14866+
14867+
/*
14868+
* After execution of most insns, btype is reset to 0.
14869+
* Note that we set btype == -1 when the insn sets btype.
14870+
*/
14871+
if (s->btype > 0 && s->base.is_jmp != DISAS_NORETURN) {
14872+
reset_btype(s);
1487914873
}
1488014874

14881-
translator_loop_temp_check(&dc->base);
14875+
translator_loop_temp_check(&s->base);
1488214876
}
1488314877

1488414878
static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)

0 commit comments

Comments
 (0)