[PATCH 28/29] target/arm/tcg/translate.c: remove TARGET_AARCH64

Pierrick Bouvier posted 29 patches 1 month ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Peter Maydell <peter.maydell@linaro.org>, Michael Rolnik <mrolnik@gmail.com>, Brian Cain <brian.cain@oss.qualcomm.com>, Helge Deller <deller@gmx.de>, Zhao Liu <zhao1.liu@intel.com>, Eduardo Habkost <eduardo@habkost.net>, Song Gao <gaosong@loongson.cn>, Laurent Vivier <laurent@vivier.eu>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <arikalo@gmail.com>, Stafford Horne <shorne@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Yoshinori Sato <yoshinori.sato@nifty.com>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Thomas Huth <thuth@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Bastian Koppelmann <kbastian@rumtueddeln.de>, Max Filippov <jcmvbkbc@gmail.com>
There is a newer version of this series
[PATCH 28/29] target/arm/tcg/translate.c: remove TARGET_AARCH64
Posted by Pierrick Bouvier 1 month ago
We now need to stub aarch64_translator_ops. Those ops will never be
called anyway for 32 bit target.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/tcg/stubs32.c   | 2 ++
 target/arm/tcg/translate.c | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/arm/tcg/stubs32.c b/target/arm/tcg/stubs32.c
index c5a0bc61f47..ddb0610992b 100644
--- a/target/arm/tcg/stubs32.c
+++ b/target/arm/tcg/stubs32.c
@@ -15,3 +15,5 @@ void a64_translate_init(void)
 {
     /* Don't initialize for 32 bits. Call site will be fixed later. */
 }
+
+const TranslatorOps aarch64_translator_ops;
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
index 7128c633290..3cd05682ce8 100644
--- a/target/arm/tcg/translate.c
+++ b/target/arm/tcg/translate.c
@@ -6863,11 +6863,9 @@ void arm_translate_code(CPUState *cpu, TranslationBlock *tb,
     if (EX_TBFLAG_AM32(tb_flags, THUMB)) {
         ops = &thumb_translator_ops;
     }
-#ifdef TARGET_AARCH64
     if (EX_TBFLAG_ANY(tb_flags, AARCH64_STATE)) {
         ops = &aarch64_translator_ops;
     }
-#endif
 
     translator_loop(cpu, tb, max_insns, pc, host_pc, ops, &dc.base);
 }
-- 
2.47.3
Re: [PATCH 28/29] target/arm/tcg/translate.c: remove TARGET_AARCH64
Posted by Richard Henderson 1 month ago
On 1/9/26 16:31, Pierrick Bouvier wrote:
> We now need to stub aarch64_translator_ops. Those ops will never be
> called anyway for 32 bit target.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/tcg/stubs32.c   | 2 ++
>   target/arm/tcg/translate.c | 2 --
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/arm/tcg/stubs32.c b/target/arm/tcg/stubs32.c
> index c5a0bc61f47..ddb0610992b 100644
> --- a/target/arm/tcg/stubs32.c
> +++ b/target/arm/tcg/stubs32.c
> @@ -15,3 +15,5 @@ void a64_translate_init(void)
>   {
>       /* Don't initialize for 32 bits. Call site will be fixed later. */
>   }
> +
> +const TranslatorOps aarch64_translator_ops;

This is unused data.


> diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
> index 7128c633290..3cd05682ce8 100644
> --- a/target/arm/tcg/translate.c
> +++ b/target/arm/tcg/translate.c
> @@ -6863,11 +6863,9 @@ void arm_translate_code(CPUState *cpu, TranslationBlock *tb,
>       if (EX_TBFLAG_AM32(tb_flags, THUMB)) {
>           ops = &thumb_translator_ops;
>       }
> -#ifdef TARGET_AARCH64
>       if (EX_TBFLAG_ANY(tb_flags, AARCH64_STATE)) {
>           ops = &aarch64_translator_ops;
>       }
> -#endif
>   
>       translator_loop(cpu, tb, max_insns, pc, host_pc, ops, &dc.base);
>   }

Perhaps better with a function wrapper, making aarch64_translator_ops static.


void aarch64_translate_code(CPUState *cpu, TranslationBlock *tb,
                             int *max_insns, vaddr pc, void *host_pc)
{
     DisasContext dc = { };
     translator_loop(cpu, tb, max_insns, pc, host_pc,
                     &aarch64_translator_ops, &dc.base);
}

void arm_translate_code(CPUState *cpu, TranslationBlock *tb,
                         int *max_insns, vaddr pc, void *host_pc)
{
     CPUARMTBFlags tb_flags = arm_tbflags_from_tb(tb);

     if (EX_TBFLAG_ANY(tb_flags, AARCH64_STATE)) {
         aarch64_translate_code(cpu, tb, max_insns, pc, host_pc);
     } else {
         DisasContext dc = { };
         translator_loop(cpu, tb, max_insns, pc, host_pc,
                         (EX_TBFLAG_AM32(tb_flags, THUMB)
                          ? &thumb_translator_ops
                          : &arm_translator_ops),
                         &dc.base);
     }
}

And then your stub file gets an assert for aarch64_translate_code.


r~
Re: [PATCH 28/29] target/arm/tcg/translate.c: remove TARGET_AARCH64
Posted by Philippe Mathieu-Daudé 1 month ago
On 9/1/26 06:31, Pierrick Bouvier wrote:
> We now need to stub aarch64_translator_ops. Those ops will never be
> called anyway for 32 bit target.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/tcg/stubs32.c   | 2 ++
>   target/arm/tcg/translate.c | 2 --
>   2 files changed, 2 insertions(+), 2 deletions(-)

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