]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
target/alpha: Access CPUState::cpu_index via helper
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Wed, 27 Aug 2025 12:07:26 +0000 (14:07 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Thu, 16 Oct 2025 08:33:33 +0000 (10:33 +0200)
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>
Message-Id: <20250925010438.59755-1-philmd@linaro.org>

target/alpha/helper.h
target/alpha/sys_helper.c
target/alpha/translate.c

index 788d2fbf289b90791a2b03c4f2489e6f6a898a4e..954a5c8294cf5e72d2271db3d56568746ebb14a7 100644 (file)
@@ -92,6 +92,7 @@ DEF_HELPER_FLAGS_1(tbia, TCG_CALL_NO_RWG, void, env)
 DEF_HELPER_FLAGS_2(tbis, TCG_CALL_NO_RWG, void, env, i64)
 
 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)
index 87e37605c133f83779e53e0c922f46a26c78e9d3..0e0a619975bd002a869a17dacabd7e6c19d48ede 100644 (file)
@@ -67,3 +67,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;
+}
index a492520075e35ca598ee3555fe05253cb8ee0b10..b1d8a4eb80ae6312e594cfcc650d9f150648d12c 100644 (file)
@@ -1126,8 +1126,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: