qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] target/alpha: Access CPUState::cpu_index via helper
@ 2025-09-25  1:04 Philippe Mathieu-Daudé
  2025-10-07  8:19 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-25  1:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Igor Mammedov, Anton Johansson,
	Pierrick Bouvier, Philippe Mathieu-Daudé

CPUState::cpu_index is a target agnostic field, meant
for common code (i.e. accel/ and system/ folders).

Target specific code should use the CPUClass::get_arch_id()
helper, even if there is a 1:1 mapping.

In preparation of generic changes around CPU indexing,
introduce the whoami helper to access the generic
CPUState::cpu_index field.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/alpha/helper.h     | 1 +
 target/alpha/sys_helper.c | 5 +++++
 target/alpha/translate.c  | 3 +--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/target/alpha/helper.h b/target/alpha/helper.h
index d60f2087031..be7c8c5b8a7 100644
--- a/target/alpha/helper.h
+++ b/target/alpha/helper.h
@@ -93,6 +93,7 @@ DEF_HELPER_FLAGS_2(tbis, TCG_CALL_NO_RWG, void, env, i64)
 DEF_HELPER_FLAGS_1(tb_flush, TCG_CALL_NO_RWG, void, env)
 
 DEF_HELPER_1(halt, void, i64)
+DEF_HELPER_1(whami, i64, env)
 
 DEF_HELPER_FLAGS_0(get_vmtime, TCG_CALL_NO_RWG, i64)
 DEF_HELPER_FLAGS_0(get_walltime, TCG_CALL_NO_RWG, i64)
diff --git a/target/alpha/sys_helper.c b/target/alpha/sys_helper.c
index 51e32544287..abd80532483 100644
--- a/target/alpha/sys_helper.c
+++ b/target/alpha/sys_helper.c
@@ -73,3 +73,8 @@ void helper_set_alarm(CPUAlphaState *env, uint64_t expire)
         timer_del(cpu->alarm_timer);
     }
 }
+
+uint64_t HELPER(whami)(CPUAlphaState *env)
+{
+    return env_cpu(env)->cpu_index;
+}
diff --git a/target/alpha/translate.c b/target/alpha/translate.c
index cebab0318cf..8a68b90141f 100644
--- a/target/alpha/translate.c
+++ b/target/alpha/translate.c
@@ -1128,8 +1128,7 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, int palcode)
             break;
         case 0x3C:
             /* WHAMI */
-            tcg_gen_ld32s_i64(ctx->ir[IR_V0], tcg_env,
-                -offsetof(AlphaCPU, env) + offsetof(CPUState, cpu_index));
+            gen_helper_whami(ctx->ir[IR_V0], tcg_env);
             break;
 
         case 0x3E:
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] target/alpha: Access CPUState::cpu_index via helper
  2025-09-25  1:04 [PATCH v2] target/alpha: Access CPUState::cpu_index via helper Philippe Mathieu-Daudé
@ 2025-10-07  8:19 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-07  8:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Igor Mammedov, Anton Johansson,
	Pierrick Bouvier

On 25/9/25 03:04, Philippe Mathieu-Daudé wrote:
> CPUState::cpu_index is a target agnostic field, meant
> for common code (i.e. accel/ and system/ folders).
> 
> Target specific code should use the CPUClass::get_arch_id()
> helper, even if there is a 1:1 mapping.
> 
> In preparation of generic changes around CPU indexing,
> introduce the whoami helper to access the generic
> CPUState::cpu_index field.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Anton Johansson <anjo@rev.ng>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/alpha/helper.h     | 1 +
>   target/alpha/sys_helper.c | 5 +++++
>   target/alpha/translate.c  | 3 +--
>   3 files changed, 7 insertions(+), 2 deletions(-)

Patch queued, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-07  8:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-25  1:04 [PATCH v2] target/alpha: Access CPUState::cpu_index via helper Philippe Mathieu-Daudé
2025-10-07  8:19 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).