On 9/24/25 10:01, 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é <[email protected]>
---
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..604af4213c9 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(whoami, i64, env)
The PALcode function name doesn't contain the 'O'.
Hooray for 1970's abbreviations still hanging on:
http://www.bitsavers.org/pdf/dec/pdp11/1160/AA-C815A-TC_1160_MIcroprogramming_Tools_V1.0_Nov77.pdf
I think WHAMI was a pdp10 instruction even before that, but I can't find docs.
:-)
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..a757a558900 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(whoami)(CPUAlphaState *env)
+{
+ return env_cpu(env)->cpu_index;
+}
It's a correct transformation of the current code,
though hard to evaluate without further context.
Aside from the extra 'O',
Reviewed-by: Richard Henderson <[email protected]>
r~