[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 43/59] target/sparc: Move sparc_restore_state_to_opc() to cpu.c
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 43/59] target/sparc: Move sparc_restore_state_to_opc() to cpu.c |
Date: |
Fri, 20 Dec 2024 17:15:34 +0100 |
Most targets define their restore_state_to_opc() handler in cpu.c.
In order to keep SPARC aligned, move sparc_restore_state_to_opc()
from translate.c to cpu.c.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20241115152053.66442-4-philmd@linaro.org>
[PMD: Move definitions to new target/sparc/translate.h]
---
target/sparc/cpu.h | 4 ----
target/sparc/translate.h | 17 +++++++++++++++++
target/sparc/cpu.c | 24 ++++++++++++++++++++++++
target/sparc/translate.c | 31 +------------------------------
4 files changed, 42 insertions(+), 34 deletions(-)
create mode 100644 target/sparc/translate.h
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index e9ccec6175f..5c981234bb3 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -607,12 +607,8 @@ int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
uint8_t *buf, int len, bool is_write);
#endif
-
/* translate.c */
void sparc_tcg_init(void);
-void sparc_restore_state_to_opc(CPUState *cs,
- const TranslationBlock *tb,
- const uint64_t *data);
/* fop_helper.c */
target_ulong cpu_get_fsr(CPUSPARCState *);
diff --git a/target/sparc/translate.h b/target/sparc/translate.h
new file mode 100644
index 00000000000..a46fa4f124b
--- /dev/null
+++ b/target/sparc/translate.h
@@ -0,0 +1,17 @@
+/*
+ * QEMU translation definitions for SPARC
+ *
+ * Copyright (c) 2024 Linaro, Ltd
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef SPARC_TRANSLATION_H
+#define SPARC_TRANSLATION_H
+
+/* Dynamic PC, must exit to main loop. */
+#define DYNAMIC_PC 1
+/* Dynamic PC, one of two values according to jump_pc[T2]. */
+#define JUMP_PC 2
+/* Dynamic PC, may lookup next TB. */
+#define DYNAMIC_PC_LOOKUP 3
+
+#endif
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index b11f3248d82..fc0c66afecf 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -27,6 +27,7 @@
#include "qapi/visitor.h"
#include "tcg/tcg.h"
#include "fpu/softfloat.h"
+#include "target/sparc/translate.h"
//#define DEBUG_FEATURES
@@ -751,6 +752,29 @@ void cpu_get_tb_cpu_state(CPUSPARCState *env, vaddr *pc,
*pflags = flags;
}
+static void sparc_restore_state_to_opc(CPUState *cs,
+ const TranslationBlock *tb,
+ const uint64_t *data)
+{
+ CPUSPARCState *env = cpu_env(cs);
+ target_ulong pc = data[0];
+ target_ulong npc = data[1];
+
+ env->pc = pc;
+ if (npc == DYNAMIC_PC) {
+ /* dynamic NPC: already stored */
+ } else if (npc & JUMP_PC) {
+ /* jump PC: use 'cond' and the jump targets of the translation */
+ if (env->cond) {
+ env->npc = npc & ~3;
+ } else {
+ env->npc = pc + 4;
+ }
+ } else {
+ env->npc = npc;
+ }
+}
+
static bool sparc_cpu_has_work(CPUState *cs)
{
return (cs->interrupt_request & CPU_INTERRUPT_HARD) &&
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index 322319a1288..ac063772310 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -30,6 +30,7 @@
#include "exec/log.h"
#include "fpu/softfloat.h"
#include "asi.h"
+#include "target/sparc/translate.h"
#define HELPER_H "helper.h"
#include "exec/helper-info.c.inc"
@@ -101,13 +102,6 @@
# define MAXTL_MASK 0
#endif
-/* Dynamic PC, must exit to main loop. */
-#define DYNAMIC_PC 1
-/* Dynamic PC, one of two values according to jump_pc[T2]. */
-#define JUMP_PC 2
-/* Dynamic PC, may lookup next TB. */
-#define DYNAMIC_PC_LOOKUP 3
-
#define DISAS_EXIT DISAS_TARGET_0
/* global register indexes */
@@ -5881,26 +5875,3 @@ void sparc_tcg_init(void)
gregnames[i]);
}
}
-
-void sparc_restore_state_to_opc(CPUState *cs,
- const TranslationBlock *tb,
- const uint64_t *data)
-{
- CPUSPARCState *env = cpu_env(cs);
- target_ulong pc = data[0];
- target_ulong npc = data[1];
-
- env->pc = pc;
- if (npc == DYNAMIC_PC) {
- /* dynamic NPC: already stored */
- } else if (npc & JUMP_PC) {
- /* jump PC: use 'cond' and the jump targets of the translation */
- if (env->cond) {
- env->npc = npc & ~3;
- } else {
- env->npc = pc + 4;
- }
- } else {
- env->npc = npc;
- }
-}
--
2.47.1
- [PULL 27/59] accel/tcg: Move page_[un]protect() to 'user/page-protection.h', (continued)
- [PULL 27/59] accel/tcg: Move page_[un]protect() to 'user/page-protection.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 28/59] system: Remove unnecessary 'exec/translate-all.h' include, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 31/59] accel/tcg: Move TranslationBlock declarations to 'tb-internal.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 33/59] accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (1/4), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 35/59] accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (3/4), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 36/59] accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (4/4), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 39/59] user: Declare cpu_loop() once in 'user/cpu_loop.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 37/59] user: Forward declare target_cpu_copy_regs structure, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 40/59] user: Move various declarations out of 'exec/exec-all.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 41/59] target/loongarch: Declare loongarch_cpu_dump_state() locally, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 43/59] target/sparc: Move sparc_restore_state_to_opc() to cpu.c,
Philippe Mathieu-Daudé <=
- [PULL 42/59] target/sparc: Uninline cpu_get_tb_cpu_state(), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 44/59] exec/cpu-all: Include 'cpu.h' earlier so MMU_USER_IDX is always defined, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 45/59] accel/tcg: Declare cpu_loop_exit_requested() in 'exec/cpu-common.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 46/59] exec/translation-block: Include missing 'qemu/atomic.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 47/59] qemu/coroutine: Include missing 'qemu/atomic.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 48/59] accel/tcg: Restrict curr_cflags() declaration to 'internal-common.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 49/59] accel/tcg: Move tcg_cflags_has/set() to 'exec/translation-block.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 50/59] accel/tcg: Include missing 'exec/translation-block.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 51/59] accel/tcg: Un-inline translator_is_same_page(), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 52/59] target/xtensa: Remove tswap() calls in semihosting simcall() helper, Philippe Mathieu-Daudé, 2024/12/20