Skip to content

Commit

Permalink
target/mips: Declare mips_env_set_pc() inlined in "internal.h"
Browse files Browse the repository at this point in the history
Rename set_pc() as mips_env_set_pc(), declare it inlined
and use it in cpu.c and op_helper.c.

Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210428170410.479308-9-f4bug@amsat.org>
  • Loading branch information
philmd committed May 2, 2021
1 parent 4d169b9 commit 533fc64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
8 changes: 1 addition & 7 deletions target/mips/cpu.c
Expand Up @@ -327,14 +327,8 @@ void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
static void mips_cpu_set_pc(CPUState *cs, vaddr value)
{
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;

env->active_tc.PC = value & ~(target_ulong)1;
if (value & 1) {
env->hflags |= MIPS_HFLAG_M16;
} else {
env->hflags &= ~(MIPS_HFLAG_M16);
}
mips_env_set_pc(&cpu->env, value);
}

#ifdef CONFIG_TCG
Expand Down
10 changes: 10 additions & 0 deletions target/mips/internal.h
Expand Up @@ -219,6 +219,16 @@ bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
/* op_helper.c */
void update_pagemask(CPUMIPSState *env, target_ulong arg1, int32_t *pagemask);

static inline void mips_env_set_pc(CPUMIPSState *env, target_ulong value)
{
env->active_tc.PC = value & ~(target_ulong)1;
if (value & 1) {
env->hflags |= MIPS_HFLAG_M16;
} else {
env->hflags &= ~(MIPS_HFLAG_M16);
}
}

static inline void restore_pamask(CPUMIPSState *env)
{
if (env->hflags & MIPS_HFLAG_ELPA) {
Expand Down
16 changes: 3 additions & 13 deletions target/mips/op_helper.c
Expand Up @@ -993,24 +993,14 @@ static void debug_post_eret(CPUMIPSState *env)
}
}

static void set_pc(CPUMIPSState *env, target_ulong error_pc)
{
env->active_tc.PC = error_pc & ~(target_ulong)1;
if (error_pc & 1) {
env->hflags |= MIPS_HFLAG_M16;
} else {
env->hflags &= ~(MIPS_HFLAG_M16);
}
}

static inline void exception_return(CPUMIPSState *env)
{
debug_pre_eret(env);
if (env->CP0_Status & (1 << CP0St_ERL)) {
set_pc(env, env->CP0_ErrorEPC);
mips_env_set_pc(env, env->CP0_ErrorEPC);
env->CP0_Status &= ~(1 << CP0St_ERL);
} else {
set_pc(env, env->CP0_EPC);
mips_env_set_pc(env, env->CP0_EPC);
env->CP0_Status &= ~(1 << CP0St_EXL);
}
compute_hflags(env);
Expand All @@ -1036,7 +1026,7 @@ void helper_deret(CPUMIPSState *env)
env->hflags &= ~MIPS_HFLAG_DM;
compute_hflags(env);

set_pc(env, env->CP0_DEPC);
mips_env_set_pc(env, env->CP0_DEPC);

debug_post_eret(env);
}
Expand Down

0 comments on commit 533fc64

Please sign in to comment.