Inline do_raise_exception as it's used by other arch. Use the shared raise_excp_restore helper for translated exceptions and adapt the logging C exception path to cpu_raise_excp() or cpu_raise_excp_restore() according to the return-address contract.
Signed-off-by: Yonggang Luo <[email protected]> --- target/loongarch/internals.h | 12 +++++++++--- target/loongarch/tcg/helper.h | 2 -- target/loongarch/tcg/op_helper.c | 6 ------ target/loongarch/tcg/tcg_cpu.c | 10 ++++------ target/loongarch/tcg/translate.c | 2 +- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h index ff956823fd7..885d516fe52 100644 --- a/target/loongarch/internals.h +++ b/target/loongarch/internals.h @@ -19,9 +19,15 @@ void loongarch_translate_init(void); void loongarch_translate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, vaddr pc, void *host_pc); -void G_NORETURN do_raise_exception(CPULoongArchState *env, - uint32_t exception, - uintptr_t pc); +void G_NORETURN loongarch_do_raise_exception(CPULoongArchState *env, + uint32_t exception, + uintptr_t pc); +static inline void G_NORETURN do_raise_exception(CPULoongArchState *env, + uint32_t exception, + uintptr_t pc) +{ + loongarch_do_raise_exception(env, exception, pc); +} #ifdef CONFIG_TCG int ieee_ex_to_loongarch(int xcpt); diff --git a/target/loongarch/tcg/helper.h b/target/loongarch/tcg/helper.h index e76c73c7755..e3a7bc9e9da 100644 --- a/target/loongarch/tcg/helper.h +++ b/target/loongarch/tcg/helper.h @@ -3,8 +3,6 @@ * Copyright (c) 2021 Loongson Technology Corporation Limited */ -DEF_HELPER_2(raise_exception, noreturn, env, i32) - DEF_HELPER_FLAGS_3(asrtle_d, TCG_CALL_NO_WG, void, env, tl, tl) DEF_HELPER_FLAGS_3(asrtgt_d, TCG_CALL_NO_WG, void, env, tl, tl) diff --git a/target/loongarch/tcg/op_helper.c b/target/loongarch/tcg/op_helper.c index f98fe4d4a16..109417b7503 100644 --- a/target/loongarch/tcg/op_helper.c +++ b/target/loongarch/tcg/op_helper.c @@ -16,12 +16,6 @@ #include <zlib.h> /* for crc32 */ #include "cpu-csr.h" -/* Exceptions helpers */ -void helper_raise_exception(CPULoongArchState *env, uint32_t exception) -{ - do_raise_exception(env, exception, GETPC()); -} - /* loongarch assert op */ void helper_asrtle_d(CPULoongArchState *env, target_ulong rj, target_ulong rk) { diff --git a/target/loongarch/tcg/tcg_cpu.c b/target/loongarch/tcg/tcg_cpu.c index 4b1d44a1644..0a1115721c0 100644 --- a/target/loongarch/tcg/tcg_cpu.c +++ b/target/loongarch/tcg/tcg_cpu.c @@ -59,9 +59,9 @@ static const char *loongarch_exception_name(int32_t exception) return "Unknown"; } -void G_NORETURN do_raise_exception(CPULoongArchState *env, - uint32_t exception, - uintptr_t pc) +void G_NORETURN loongarch_do_raise_exception(CPULoongArchState *env, + uint32_t exception, + uintptr_t pc) { CPUState *cs = env_cpu(env); @@ -69,9 +69,7 @@ void G_NORETURN do_raise_exception(CPULoongArchState *env, __func__, exception, loongarch_exception_name(exception)); - cs->exception_index = exception; - - cpu_loop_exit_restore(cs, pc); + cpu_raise_excp_restore(cs, exception, pc); } #ifndef CONFIG_USER_ONLY diff --git a/target/loongarch/tcg/translate.c b/target/loongarch/tcg/translate.c index 124dce62695..b7e8ce8a653 100644 --- a/target/loongarch/tcg/translate.c +++ b/target/loongarch/tcg/translate.c @@ -95,7 +95,7 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) void generate_exception(DisasContext *ctx, int excp) { tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); - gen_helper_raise_exception(tcg_env, tcg_constant_i32(excp)); + gen_helper_raise_excp_restore(tcg_env, tcg_constant_i32(excp)); ctx->base.is_jmp = DISAS_NORETURN; } -- 2.52.0.windows.1
