target/arm: Introduce curr_insn_len

A simple helper to retrieve the length of the current insn.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20221020030641.2066807-2-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2022-10-20 13:06:33 +10:00 committed by Peter Maydell
parent 6b72c5424a
commit 8df8727973
3 changed files with 8 additions and 4 deletions

View File

@ -242,7 +242,7 @@ static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled)
if (s->sme_trap_nonstreaming) { if (s->sme_trap_nonstreaming) {
gen_exception_insn(s, s->pc_curr, EXCP_UDEF, gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
syn_smetrap(SME_ET_Streaming, syn_smetrap(SME_ET_Streaming,
s->base.pc_next - s->pc_curr == 2)); curr_insn_len(s) == 2));
return false; return false;
} }

View File

@ -6650,7 +6650,7 @@ static ISSInfo make_issinfo(DisasContext *s, int rd, bool p, bool w)
/* ISS not valid if writeback */ /* ISS not valid if writeback */
if (p && !w) { if (p && !w) {
ret = rd; ret = rd;
if (s->base.pc_next - s->pc_curr == 2) { if (curr_insn_len(s) == 2) {
ret |= ISSIs16Bit; ret |= ISSIs16Bit;
} }
} else { } else {
@ -9812,8 +9812,7 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
/* nothing more to generate */ /* nothing more to generate */
break; break;
case DISAS_WFI: case DISAS_WFI:
gen_helper_wfi(cpu_env, gen_helper_wfi(cpu_env, tcg_constant_i32(curr_insn_len(dc)));
tcg_constant_i32(dc->base.pc_next - dc->pc_curr));
/* /*
* The helper doesn't necessarily throw an exception, but we * The helper doesn't necessarily throw an exception, but we
* must go back to the main loop to check for interrupts anyway. * must go back to the main loop to check for interrupts anyway.

View File

@ -226,6 +226,11 @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)
s->insn_start = NULL; s->insn_start = NULL;
} }
static inline int curr_insn_len(DisasContext *s)
{
return s->base.pc_next - s->pc_curr;
}
/* is_jmp field values */ /* is_jmp field values */
#define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ #define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */
/* CPU state was modified dynamically; exit to main loop for interrupts. */ /* CPU state was modified dynamically; exit to main loop for interrupts. */