[PATCH v5 04/12] target/arm/tcg/translate.h: remove TARGET_AARCH64

Pierrick Bouvier posted 12 patches 5 days, 22 hours ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Peter Maydell <peter.maydell@linaro.org>
There is a newer version of this series
[PATCH v5 04/12] target/arm/tcg/translate.h: remove TARGET_AARCH64
Posted by Pierrick Bouvier 5 days, 22 hours ago
We need to stub a64_translate_init and gen_a64_update_pc.
At this point, we don't need to do anything for aarch64_translator_ops
since it's just an external symbol.

We can now include target/arm/tcg/translate.h from common code, since
all target specific bits have been removed, or can be specialized with
specific defines.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/tcg/translate.h | 10 ----------
 target/arm/tcg/stubs32.c   | 17 +++++++++++++++++
 target/arm/tcg/meson.build |  1 +
 3 files changed, 18 insertions(+), 10 deletions(-)
 create mode 100644 target/arm/tcg/stubs32.c

diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h
index e28eac54afb..77fdc5f3a17 100644
--- a/target/arm/tcg/translate.h
+++ b/target/arm/tcg/translate.h
@@ -357,19 +357,9 @@ static inline int curr_insn_len(DisasContext *s)
 /* CPU state was modified dynamically; no need to exit, but do not chain. */
 #define DISAS_UPDATE_NOCHAIN  DISAS_TARGET_10
 
-#ifdef TARGET_AARCH64
 void a64_translate_init(void);
 void gen_a64_update_pc(DisasContext *s, int64_t diff);
 extern const TranslatorOps aarch64_translator_ops;
-#else
-static inline void a64_translate_init(void)
-{
-}
-
-static inline void gen_a64_update_pc(DisasContext *s, int64_t diff)
-{
-}
-#endif
 
 void arm_test_cc(DisasCompare *cmp, int cc);
 void arm_jump_cc(DisasCompare *cmp, TCGLabel *label);
diff --git a/target/arm/tcg/stubs32.c b/target/arm/tcg/stubs32.c
new file mode 100644
index 00000000000..c5a0bc61f47
--- /dev/null
+++ b/target/arm/tcg/stubs32.c
@@ -0,0 +1,17 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "target/arm/tcg/translate.h"
+
+
+void gen_a64_update_pc(DisasContext *s, int64_t diff)
+{
+    g_assert_not_reached();
+}
+
+void a64_translate_init(void)
+{
+    /* Don't initialize for 32 bits. Call site will be fixed later. */
+}
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
index 5f591560551..3e96c77df73 100644
--- a/target/arm/tcg/meson.build
+++ b/target/arm/tcg/meson.build
@@ -21,6 +21,7 @@ gen_a32 = [
 
 arm_ss.add(gen_a32)
 arm_ss.add(when: 'TARGET_AARCH64', if_true: gen_a64)
+arm_ss.add(when: 'TARGET_AARCH64', if_false: files('stubs32.c'))
 
 arm_ss.add(files(
   'cpu32.c',
-- 
2.47.3
Re: [PATCH v5 04/12] target/arm/tcg/translate.h: remove TARGET_AARCH64
Posted by Richard Henderson 3 days, 14 hours ago
On 3/28/26 02:50, Pierrick Bouvier wrote:
> We need to stub a64_translate_init and gen_a64_update_pc.
> At this point, we don't need to do anything for aarch64_translator_ops
> since it's just an external symbol.
> 
> We can now include target/arm/tcg/translate.h from common code, since
> all target specific bits have been removed, or can be specialized with
> specific defines.
> 
> Signed-off-by: Pierrick Bouvier<pierrick.bouvier@linaro.org>
> ---
>   target/arm/tcg/translate.h | 10 ----------
>   target/arm/tcg/stubs32.c   | 17 +++++++++++++++++
>   target/arm/tcg/meson.build |  1 +
>   3 files changed, 18 insertions(+), 10 deletions(-)
>   create mode 100644 target/arm/tcg/stubs32.c

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

t~
Re: [PATCH v5 04/12] target/arm/tcg/translate.h: remove TARGET_AARCH64
Posted by Philippe Mathieu-Daudé 2 days, 21 hours ago
On 30/3/26 03:06, Richard Henderson wrote:
> On 3/28/26 02:50, Pierrick Bouvier wrote:
>> We need to stub a64_translate_init and gen_a64_update_pc.
>> At this point, we don't need to do anything for aarch64_translator_ops
>> since it's just an external symbol.
>>
>> We can now include target/arm/tcg/translate.h from common code, since
>> all target specific bits have been removed, or can be specialized with
>> specific defines.
>>
>> Signed-off-by: Pierrick Bouvier<pierrick.bouvier@linaro.org>
>> ---
>>   target/arm/tcg/translate.h | 10 ----------
>>   target/arm/tcg/stubs32.c   | 17 +++++++++++++++++
>>   target/arm/tcg/meson.build |  1 +
>>   3 files changed, 18 insertions(+), 10 deletions(-)
>>   create mode 100644 target/arm/tcg/stubs32.c
> 
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> t~

o_O

Re: [PATCH v5 04/12] target/arm/tcg/translate.h: remove TARGET_AARCH64
Posted by Philippe Mathieu-Daudé 5 days, 22 hours ago
On 27/3/26 17:50, Pierrick Bouvier wrote:
> We need to stub a64_translate_init and gen_a64_update_pc.
> At this point, we don't need to do anything for aarch64_translator_ops
> since it's just an external symbol.
> 
> We can now include target/arm/tcg/translate.h from common code, since
> all target specific bits have been removed, or can be specialized with
> specific defines.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/tcg/translate.h | 10 ----------
>   target/arm/tcg/stubs32.c   | 17 +++++++++++++++++
>   target/arm/tcg/meson.build |  1 +
>   3 files changed, 18 insertions(+), 10 deletions(-)
>   create mode 100644 target/arm/tcg/stubs32.c


> diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
> index 5f591560551..3e96c77df73 100644
> --- a/target/arm/tcg/meson.build
> +++ b/target/arm/tcg/meson.build
> @@ -21,6 +21,7 @@ gen_a32 = [
>   
>   arm_ss.add(gen_a32)
>   arm_ss.add(when: 'TARGET_AARCH64', if_true: gen_a64)
> +arm_ss.add(when: 'TARGET_AARCH64', if_false: files('stubs32.c'))

Add via stub_ss[]?
Re: [PATCH v5 04/12] target/arm/tcg/translate.h: remove TARGET_AARCH64
Posted by Pierrick Bouvier 5 days, 21 hours ago
On 3/27/26 10:26 AM, Philippe Mathieu-Daudé wrote:
> On 27/3/26 17:50, Pierrick Bouvier wrote:
>> We need to stub a64_translate_init and gen_a64_update_pc.
>> At this point, we don't need to do anything for aarch64_translator_ops
>> since it's just an external symbol.
>>
>> We can now include target/arm/tcg/translate.h from common code, since
>> all target specific bits have been removed, or can be specialized with
>> specific defines.
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>    target/arm/tcg/translate.h | 10 ----------
>>    target/arm/tcg/stubs32.c   | 17 +++++++++++++++++
>>    target/arm/tcg/meson.build |  1 +
>>    3 files changed, 18 insertions(+), 10 deletions(-)
>>    create mode 100644 target/arm/tcg/stubs32.c
> 
> 
>> diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
>> index 5f591560551..3e96c77df73 100644
>> --- a/target/arm/tcg/meson.build
>> +++ b/target/arm/tcg/meson.build
>> @@ -21,6 +21,7 @@ gen_a32 = [
>>    
>>    arm_ss.add(gen_a32)
>>    arm_ss.add(when: 'TARGET_AARCH64', if_true: gen_a64)
>> +arm_ss.add(when: 'TARGET_AARCH64', if_false: files('stubs32.c'))
> 
> Add via stub_ss[]?

Unfortunately, libqemuutil is declared before iterating on targets, so 
stub_ss is not what you expect at this point.

stub_ss = stub_ss.apply({})
It changes its type from source_set to source_configuration.
Even if we used a new variable name, further changes to stub_ss would be 
ignored.

I will write a patch for it, but it's definitely out of the scope of 
this series, so I'll leave the current patch as it is for now.

Regards,
Pierrick

Re: [PATCH v5 04/12] target/arm/tcg/translate.h: remove TARGET_AARCH64
Posted by Philippe Mathieu-Daudé 5 days, 16 hours ago
On 27/3/26 19:31, Pierrick Bouvier wrote:
> On 3/27/26 10:26 AM, Philippe Mathieu-Daudé wrote:
>> On 27/3/26 17:50, Pierrick Bouvier wrote:
>>> We need to stub a64_translate_init and gen_a64_update_pc.
>>> At this point, we don't need to do anything for aarch64_translator_ops
>>> since it's just an external symbol.
>>>
>>> We can now include target/arm/tcg/translate.h from common code, since
>>> all target specific bits have been removed, or can be specialized with
>>> specific defines.
>>>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>> ---
>>>    target/arm/tcg/translate.h | 10 ----------
>>>    target/arm/tcg/stubs32.c   | 17 +++++++++++++++++
>>>    target/arm/tcg/meson.build |  1 +
>>>    3 files changed, 18 insertions(+), 10 deletions(-)
>>>    create mode 100644 target/arm/tcg/stubs32.c
>>
>>
>>> diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
>>> index 5f591560551..3e96c77df73 100644
>>> --- a/target/arm/tcg/meson.build
>>> +++ b/target/arm/tcg/meson.build
>>> @@ -21,6 +21,7 @@ gen_a32 = [
>>>    arm_ss.add(gen_a32)
>>>    arm_ss.add(when: 'TARGET_AARCH64', if_true: gen_a64)
>>> +arm_ss.add(when: 'TARGET_AARCH64', if_false: files('stubs32.c'))
>>
>> Add via stub_ss[]?
> 
> Unfortunately, libqemuutil is declared before iterating on targets, so 
> stub_ss is not what you expect at this point.
> 
> stub_ss = stub_ss.apply({})
> It changes its type from source_set to source_configuration.
> Even if we used a new variable name, further changes to stub_ss would be 
> ignored.
> 
> I will write a patch for it, but it's definitely out of the scope of 
> this series, so I'll leave the current patch as it is for now.

Good you already thought about it :)


Re: [PATCH v5 04/12] target/arm/tcg/translate.h: remove TARGET_AARCH64
Posted by Philippe Mathieu-Daudé 5 days, 22 hours ago
On 27/3/26 17:50, Pierrick Bouvier wrote:
> We need to stub a64_translate_init and gen_a64_update_pc.
> At this point, we don't need to do anything for aarch64_translator_ops
> since it's just an external symbol.
> 
> We can now include target/arm/tcg/translate.h from common code, since
> all target specific bits have been removed, or can be specialized with
> specific defines.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/tcg/translate.h | 10 ----------
>   target/arm/tcg/stubs32.c   | 17 +++++++++++++++++
>   target/arm/tcg/meson.build |  1 +
>   3 files changed, 18 insertions(+), 10 deletions(-)
>   create mode 100644 target/arm/tcg/stubs32.c

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>