[PATCH 29/29] target/arm/tcg/translate.c: make compilation unit common

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 29/29] target/arm/tcg/translate.c: make compilation unit common
Posted by Pierrick Bouvier 1 month ago
We can finally make translate.c common.

This is the only file using TCGv as well, so we need to set .tcgv_type
in arm_get_tb_cpu_state() accordingly, to not break bisection with this
series. Indeed, we will now have a different TCGv type at runtime when
calling gen_aa32_*_internal_*() compared to before for aarch64 targets.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/tcg/hflags.c    | 1 +
 target/arm/tcg/translate.c | 1 +
 target/arm/tcg/meson.build | 7 ++++++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c
index 5c9b9bec3b2..2b06b75b581 100644
--- a/target/arm/tcg/hflags.c
+++ b/target/arm/tcg/hflags.c
@@ -693,5 +693,6 @@ TCGTBCPUState arm_get_tb_cpu_state(CPUState *cs)
         .pc = pc,
         .flags = flags.flags,
         .cs_base = flags.flags2,
+        .tcgv_type = is_a64(env) ? TCGV_TYPE_I64 : TCGV_TYPE_I32
     };
 }
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
index 3cd05682ce8..1bd763025e8 100644
--- a/target/arm/tcg/translate.c
+++ b/target/arm/tcg/translate.c
@@ -20,6 +20,7 @@
  */
 #include "qemu/osdep.h"
 
+#define TARGET_ADDRESS_BITS 32
 #include "translate.h"
 #include "translate-a32.h"
 #include "qemu/log.h"
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
index a2a636ef14a..9d50f8b5001 100644
--- a/target/arm/tcg/meson.build
+++ b/target/arm/tcg/meson.build
@@ -25,7 +25,6 @@ arm_ss.add(when: 'TARGET_AARCH64', if_false: files('stubs32.c'))
 
 arm_ss.add(files(
   'cpu32.c',
-  'translate.c',
   'm_helper.c',
   'mve_helper.c',
 ))
@@ -55,6 +54,10 @@ arm_common_ss.add(files(
 ))
 
 arm_common_system_ss.add(
+  decodetree.process('a32.decode', extra_args: '--static-decode=disas_a32'),
+  decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'),
+  decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'),
+  decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']),
   decodetree.process('vfp.decode', extra_args: '--decode=disas_vfp'),
   decodetree.process('vfp-uncond.decode', extra_args: '--decode=disas_vfp_uncond'),
   decodetree.process('mve.decode', extra_args: '--decode=disas_mve'),
@@ -71,6 +74,7 @@ arm_common_system_ss.add(
   'psci.c',
   'tlb_helper.c',
   'tlb-insns.c',
+  'translate.c',
   'translate-m-nocp.c',
   'translate-mve.c',
   'translate-neon.c',
@@ -84,6 +88,7 @@ arm_user_ss.add(files(
   'neon_helper.c',
   'op_helper.c',
   'tlb_helper.c',
+  'translate.c',
   'translate-m-nocp.c',
   'translate-mve.c',
   'translate-neon.c',
-- 
2.47.3
Re: [PATCH 29/29] target/arm/tcg/translate.c: make compilation unit common
Posted by Richard Henderson 1 month ago
On 1/9/26 16:31, Pierrick Bouvier wrote:
> We can finally make translate.c common.
> 
> This is the only file using TCGv as well, so we need to set .tcgv_type
> in arm_get_tb_cpu_state() accordingly, to not break bisection with this
> series. Indeed, we will now have a different TCGv type at runtime when
> calling gen_aa32_*_internal_*() compared to before for aarch64 targets.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/tcg/hflags.c    | 1 +
>   target/arm/tcg/translate.c | 1 +
>   target/arm/tcg/meson.build | 7 ++++++-
>   3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c
> index 5c9b9bec3b2..2b06b75b581 100644
> --- a/target/arm/tcg/hflags.c
> +++ b/target/arm/tcg/hflags.c
> @@ -693,5 +693,6 @@ TCGTBCPUState arm_get_tb_cpu_state(CPUState *cs)
>           .pc = pc,
>           .flags = flags.flags,
>           .cs_base = flags.flags2,
> +        .tcgv_type = is_a64(env) ? TCGV_TYPE_I64 : TCGV_TYPE_I32
>       };
>   }

Except this,

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


> diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
> index 3cd05682ce8..1bd763025e8 100644
> --- a/target/arm/tcg/translate.c
> +++ b/target/arm/tcg/translate.c
> @@ -20,6 +20,7 @@
>    */
>   #include "qemu/osdep.h"
>   
> +#define TARGET_ADDRESS_BITS 32
>   #include "translate.h"
>   #include "translate-a32.h"
>   #include "qemu/log.h"
> diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
> index a2a636ef14a..9d50f8b5001 100644
> --- a/target/arm/tcg/meson.build
> +++ b/target/arm/tcg/meson.build
> @@ -25,7 +25,6 @@ arm_ss.add(when: 'TARGET_AARCH64', if_false: files('stubs32.c'))
>   
>   arm_ss.add(files(
>     'cpu32.c',
> -  'translate.c',
>     'm_helper.c',
>     'mve_helper.c',
>   ))
> @@ -55,6 +54,10 @@ arm_common_ss.add(files(
>   ))
>   
>   arm_common_system_ss.add(
> +  decodetree.process('a32.decode', extra_args: '--static-decode=disas_a32'),
> +  decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'),
> +  decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'),
> +  decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']),
>     decodetree.process('vfp.decode', extra_args: '--decode=disas_vfp'),
>     decodetree.process('vfp-uncond.decode', extra_args: '--decode=disas_vfp_uncond'),
>     decodetree.process('mve.decode', extra_args: '--decode=disas_mve'),
> @@ -71,6 +74,7 @@ arm_common_system_ss.add(
>     'psci.c',
>     'tlb_helper.c',
>     'tlb-insns.c',
> +  'translate.c',
>     'translate-m-nocp.c',
>     'translate-mve.c',
>     'translate-neon.c',
> @@ -84,6 +88,7 @@ arm_user_ss.add(files(
>     'neon_helper.c',
>     'op_helper.c',
>     'tlb_helper.c',
> +  'translate.c',
>     'translate-m-nocp.c',
>     'translate-mve.c',
>     'translate-neon.c',