Store error_code then call raise_excp with restore 0. Drop TCG raise_exception and raise_exception_err. Move C raise_exception_err_ra to static inline in internal.h, and remove the cpu.h prototype. Callers include internal.h.
Signed-off-by: Yonggang Luo <[email protected]> --- target/ppc/cpu.h | 3 --- target/ppc/helper.h | 2 -- target/ppc/internal.h | 9 +++++++++ target/ppc/misc_helper.c | 1 + target/ppc/tcg-excp_helper.c | 21 --------------------- target/ppc/timebase_helper.c | 1 + target/ppc/translate.c | 23 ++++++++++------------- 7 files changed, 21 insertions(+), 39 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 3fb51bbeb82..217b4f334e5 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -2819,9 +2819,6 @@ void cpu_write_xer(CPUPPCState *env, target_ulong xer); */ #define is_book3s_arch2x(ctx) (!!((ctx)->insns_flags & PPC_SEGMENT_64B)) -G_NORETURN void raise_exception_err_ra(CPUPPCState *env, uint32_t exception, - uint32_t error_code, uintptr_t raddr); - /* PERFM EBB helper*/ #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) void raise_ebb_perfm_exception(CPUPPCState *env); diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 80d6616bab4..8a804d326ac 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -1,5 +1,3 @@ -DEF_HELPER_FLAGS_3(raise_exception_err, TCG_CALL_NO_WG, noreturn, env, i32, i32) -DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32) DEF_HELPER_FLAGS_4(TW, TCG_CALL_NO_WG, void, env, tl, tl, i32) #if defined(TARGET_PPC64) DEF_HELPER_FLAGS_4(TD, TCG_CALL_NO_WG, void, env, tl, tl, i32) diff --git a/target/ppc/internal.h b/target/ppc/internal.h index a20a0f9f7e0..14c08c23ffc 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -320,8 +320,17 @@ static inline int ger_pack_masks(int pmsk, int ymsk, int xmsk) #ifdef CONFIG_TCG #include "accel/tcg/tb-cpu-state.h" +#include "accel/tcg/cpu-loop.h" TCGTBCPUState ppc_get_tb_cpu_state(CPUState *cs); + +static inline G_NORETURN +void raise_exception_err_ra(CPUPPCState *env, uint32_t excp, + uint32_t err, uintptr_t ra) +{ + env->error_code = err; + cpu_loop_exit_excp(env_cpu(env), excp, ra); +} #endif #endif /* PPC_INTERNAL_H */ diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 0e625cbb704..527af513f92 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" +#include "internal.h" #include "exec/cputlb.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" diff --git a/target/ppc/tcg-excp_helper.c b/target/ppc/tcg-excp_helper.c index 93aedb0c8e2..6289ca7dfd5 100644 --- a/target/ppc/tcg-excp_helper.c +++ b/target/ppc/tcg-excp_helper.c @@ -34,27 +34,6 @@ /*****************************************************************************/ /* Exceptions processing helpers */ -void raise_exception_err_ra(CPUPPCState *env, uint32_t exception, - uint32_t error_code, uintptr_t raddr) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = exception; - env->error_code = error_code; - cpu_loop_exit_restore(cs, raddr); -} - -void helper_raise_exception_err(CPUPPCState *env, uint32_t exception, - uint32_t error_code) -{ - raise_exception_err_ra(env, exception, error_code, 0); -} - -void helper_raise_exception(CPUPPCState *env, uint32_t exception) -{ - raise_exception_err_ra(env, exception, 0, 0); -} - #ifndef CONFIG_USER_ONLY static G_NORETURN void raise_exception_err(CPUPPCState *env, uint32_t exception, diff --git a/target/ppc/timebase_helper.c b/target/ppc/timebase_helper.c index 7209b418fb6..d0986ff261a 100644 --- a/target/ppc/timebase_helper.c +++ b/target/ppc/timebase_helper.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" +#include "internal.h" #include "hw/ppc/ppc.h" #include "exec/helper-proto.h" #include "qemu/log.h" diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 467b8f3d4ec..e4695c18728 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -308,12 +308,11 @@ static inline void gen_update_nip(DisasContext *ctx, target_ulong nip) static void gen_exception_err_nip(DisasContext *ctx, uint32_t excp, uint32_t error, target_ulong nip) { - TCGv_i32 t0, t1; - gen_update_nip(ctx, nip); - t0 = tcg_constant_i32(excp); - t1 = tcg_constant_i32(error); - gen_helper_raise_exception_err(tcg_env, t0, t1); + tcg_gen_st_i32(tcg_constant_i32(error), tcg_env, + offsetof(CPUPPCState, error_code)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(excp), + tcg_constant_i32(0)); ctx->base.is_jmp = DISAS_NORETURN; } @@ -330,12 +329,7 @@ static inline void gen_exception_err(DisasContext *ctx, uint32_t excp, static void gen_exception_nip(DisasContext *ctx, uint32_t excp, target_ulong nip) { - TCGv_i32 t0; - - gen_update_nip(ctx, nip); - t0 = tcg_constant_i32(excp); - gen_helper_raise_exception(tcg_env, t0); - ctx->base.is_jmp = DISAS_NORETURN; + gen_exception_err_nip(ctx, excp, 0, nip); } static inline void gen_exception(DisasContext *ctx, uint32_t excp) @@ -377,8 +371,11 @@ static void gen_debug_exception(DisasContext *ctx, bool rfi_type) gen_load_spr(t0, SPR_BOOKE_DBSR); tcg_gen_ori_tl(t0, t0, dbsr); gen_store_spr(SPR_BOOKE_DBSR, t0); - gen_helper_raise_exception(tcg_env, - tcg_constant_i32(POWERPC_EXCP_DEBUG)); + tcg_gen_st_i32(tcg_constant_i32(0), tcg_env, + offsetof(CPUPPCState, error_code)); + gen_helper_raise_excp(tcg_env, + tcg_constant_i32(POWERPC_EXCP_DEBUG), + tcg_constant_i32(0)); ctx->base.is_jmp = DISAS_NORETURN; } else { if (!rfi_type) { /* BookS does not single step rfi type instructions */ -- 2.52.0.windows.1
