Re: [PATCH-for-9.1 24/27] target/sparc: Convert to TCGCPUOps::get_cpu_state()

2024-03-19 Thread Richard Henderson

On 3/19/24 05:42, Philippe Mathieu-Daudé wrote:

Convert cpu_get_tb_cpu_state() to TCGCPUOps::get_cpu_state().

Signed-off-by: Philippe Mathieu-Daudé
---
  target/sparc/cpu.h   | 37 ++---
  target/sparc/cpu.c   |  1 +
  target/sparc/translate.c | 33 +
  3 files changed, 36 insertions(+), 35 deletions(-)


Again, why translate.c?

r~



[PATCH-for-9.1 24/27] target/sparc: Convert to TCGCPUOps::get_cpu_state()

2024-03-19 Thread Philippe Mathieu-Daudé
Convert cpu_get_tb_cpu_state() to TCGCPUOps::get_cpu_state().

Signed-off-by: Philippe Mathieu-Daudé 
---
 target/sparc/cpu.h   | 37 ++---
 target/sparc/cpu.c   |  1 +
 target/sparc/translate.c | 33 +
 3 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index ae55cd15a4..283c235222 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -614,6 +614,8 @@ void sparc_tcg_init(void);
 void sparc_restore_state_to_opc(CPUState *cs,
 const TranslationBlock *tb,
 const uint64_t *data);
+void sparc_get_cpu_state(CPUSPARCState *env, vaddr *pc,
+ uint64_t *cs_base, uint32_t *pflags);
 
 /* fop_helper.c */
 target_ulong cpu_get_fsr(CPUSPARCState *);
@@ -747,41 +749,6 @@ trap_state* cpu_tsptr(CPUSPARCState* env);
 #define TB_FLAG_HYPER(1 << 7)
 #define TB_FLAG_ASI_SHIFT24
 
-#define TARGET_HAS_CPU_GET_TB_CPU_STATE
-
-static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, vaddr *pc,
-uint64_t *cs_base, uint32_t *pflags)
-{
-uint32_t flags;
-*pc = env->pc;
-*cs_base = env->npc;
-flags = cpu_mmu_index(env_cpu(env), false);
-#ifndef CONFIG_USER_ONLY
-if (cpu_supervisor_mode(env)) {
-flags |= TB_FLAG_SUPER;
-}
-#endif
-#ifdef TARGET_SPARC64
-#ifndef CONFIG_USER_ONLY
-if (cpu_hypervisor_mode(env)) {
-flags |= TB_FLAG_HYPER;
-}
-#endif
-if (env->pstate & PS_AM) {
-flags |= TB_FLAG_AM_ENABLED;
-}
-if ((env->pstate & PS_PEF) && (env->fprs & FPRS_FEF)) {
-flags |= TB_FLAG_FPU_ENABLED;
-}
-flags |= env->asi << TB_FLAG_ASI_SHIFT;
-#else
-if (env->psref) {
-flags |= TB_FLAG_FPU_ENABLED;
-}
-#endif
-*pflags = flags;
-}
-
 static inline bool tb_fpu_enabled(int tb_flags)
 {
 #if defined(CONFIG_USER_ONLY)
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index dc9ead21fc..b74a3f00b7 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -899,6 +899,7 @@ static const TCGCPUOps sparc_tcg_ops = {
 .initialize = sparc_tcg_init,
 .synchronize_from_tb = sparc_cpu_synchronize_from_tb,
 .restore_state_to_opc = sparc_restore_state_to_opc,
+.get_cpu_state = sparc_get_cpu_state,
 
 #ifndef CONFIG_USER_ONLY
 .tlb_fill = sparc_cpu_tlb_fill,
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index 319934d9bd..49958837b8 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -5122,3 +5122,36 @@ void sparc_restore_state_to_opc(CPUState *cs,
 env->npc = npc;
 }
 }
+
+void sparc_get_cpu_state(CPUSPARCState *env, vaddr *pc,
+ uint64_t *cs_base, uint32_t *pflags)
+{
+uint32_t flags;
+*pc = env->pc;
+*cs_base = env->npc;
+flags = cpu_mmu_index(env_cpu(env), false);
+#ifndef CONFIG_USER_ONLY
+if (cpu_supervisor_mode(env)) {
+flags |= TB_FLAG_SUPER;
+}
+#endif
+#ifdef TARGET_SPARC64
+#ifndef CONFIG_USER_ONLY
+if (cpu_hypervisor_mode(env)) {
+flags |= TB_FLAG_HYPER;
+}
+#endif
+if (env->pstate & PS_AM) {
+flags |= TB_FLAG_AM_ENABLED;
+}
+if ((env->pstate & PS_PEF) && (env->fprs & FPRS_FEF)) {
+flags |= TB_FLAG_FPU_ENABLED;
+}
+flags |= env->asi << TB_FLAG_ASI_SHIFT;
+#else
+if (env->psref) {
+flags |= TB_FLAG_FPU_ENABLED;
+}
+#endif
+*pflags = flags;
+}
-- 
2.41.0