diff mbox series

[v3,08/30] target/mips: Declare mips_cpu_set_error_pc() inlined in "internal.h"

Message ID 20210419191823.1555482-9-f4bug@amsat.org
State New
Headers show
Series target/mips: Re-org to allow KVM-only builds | expand

Commit Message

Philippe Mathieu-Daudé April 19, 2021, 7:18 p.m. UTC
Rename set_pc() as mips_cpu_set_error_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>
---
 target/mips/internal.h  | 11 +++++++++++
 target/mips/cpu.c       |  8 +-------
 target/mips/op_helper.c | 16 +++-------------
 3 files changed, 15 insertions(+), 20 deletions(-)

Comments

Richard Henderson April 19, 2021, 7:27 p.m. UTC | #1
On 4/19/21 12:18 PM, Philippe Mathieu-Daudé wrote:
> Rename set_pc() as mips_cpu_set_error_pc(), declare it inlined
> and use it in cpu.c and op_helper.c.

Why "error_pc"?  The usage in mips_cpu_set_pc certainly isn't in response to 
any kind of error...


r~
Philippe Mathieu-Daudé April 19, 2021, 8:42 p.m. UTC | #2
On 4/19/21 9:27 PM, Richard Henderson wrote:
> On 4/19/21 12:18 PM, Philippe Mathieu-Daudé wrote:
>> Rename set_pc() as mips_cpu_set_error_pc(), declare it inlined
>> and use it in cpu.c and op_helper.c.
> 
> Why "error_pc"?  The usage in mips_cpu_set_pc certainly isn't in
> response to any kind of error...

Indeed, but I couldn't find any good name. mips_cpu_set_pc() is
already taken, as is cpu_set_pc():

static void mips_cpu_set_pc(CPUState *cs, vaddr value)

mips_cpu_state_set_pc() maybe?
Richard Henderson April 20, 2021, 2:03 p.m. UTC | #3
On 4/19/21 1:42 PM, Philippe Mathieu-Daudé wrote:
> On 4/19/21 9:27 PM, Richard Henderson wrote:
>> On 4/19/21 12:18 PM, Philippe Mathieu-Daudé wrote:
>>> Rename set_pc() as mips_cpu_set_error_pc(), declare it inlined
>>> and use it in cpu.c and op_helper.c.
>>
>> Why "error_pc"?  The usage in mips_cpu_set_pc certainly isn't in
>> response to any kind of error...
> 
> Indeed, but I couldn't find any good name. mips_cpu_set_pc() is
> already taken, as is cpu_set_pc():
> 
> static void mips_cpu_set_pc(CPUState *cs, vaddr value)
> 
> mips_cpu_state_set_pc() maybe?
> 

mips_env_set_pc?  Since cs vs env is the only difference...


r~
diff mbox series

Patch

diff --git a/target/mips/internal.h b/target/mips/internal.h
index 57072a941e7..81671d567d0 100644
--- a/target/mips/internal.h
+++ b/target/mips/internal.h
@@ -219,6 +219,17 @@  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_cpu_set_error_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 restore_pamask(CPUMIPSState *env)
 {
     if (env->hflags & MIPS_HFLAG_ELPA) {
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index 90ae232c8b8..fcbf95c85b9 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -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_cpu_set_error_pc(&cpu->env, value);
 }
 
 #ifdef CONFIG_TCG
diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
index b80e8f75401..f7da8c83aee 100644
--- a/target/mips/op_helper.c
+++ b/target/mips/op_helper.c
@@ -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_cpu_set_error_pc(env, env->CP0_ErrorEPC);
         env->CP0_Status &= ~(1 << CP0St_ERL);
     } else {
-        set_pc(env, env->CP0_EPC);
+        mips_cpu_set_error_pc(env, env->CP0_EPC);
         env->CP0_Status &= ~(1 << CP0St_EXL);
     }
     compute_hflags(env);
@@ -1036,7 +1026,7 @@  void helper_deret(CPUMIPSState *env)
     env->hflags &= ~MIPS_HFLAG_DM;
     compute_hflags(env);
 
-    set_pc(env, env->CP0_DEPC);
+    mips_cpu_set_error_pc(env, env->CP0_DEPC);
 
     debug_post_eret(env);
 }