[PATCH 06/29] target/arm: extract helper64.h

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 06/29] target/arm: extract helper64.h
Posted by Pierrick Bouvier 1 month ago
This allows to get rid of TARGET_AARCH64 in target/arm/helper.h.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/helper.h            | 6 ------
 target/arm/helper64.h          | 5 +++++
 target/arm/tcg/gengvec64.c     | 1 +
 target/arm/tcg/helper-a64.c    | 1 +
 target/arm/tcg/mte_helper.c    | 1 +
 target/arm/tcg/pauth_helper.c  | 1 +
 target/arm/tcg/sme_helper.c    | 1 +
 target/arm/tcg/sve_helper.c    | 1 +
 target/arm/tcg/translate-a64.c | 1 +
 target/arm/tcg/translate-sme.c | 1 +
 target/arm/tcg/translate-sve.c | 1 +
 target/arm/tcg/translate.c     | 9 +++++++++
 target/arm/tcg/vec_helper.c    | 3 +++
 13 files changed, 26 insertions(+), 6 deletions(-)
 create mode 100644 target/arm/helper64.h

diff --git a/target/arm/helper.h b/target/arm/helper.h
index f340a49a28a..2af4ee4b51b 100644
--- a/target/arm/helper.h
+++ b/target/arm/helper.h
@@ -2,10 +2,4 @@
 
 #include "tcg/helper.h"
 
-#ifdef TARGET_AARCH64
-#include "tcg/helper-a64.h"
-#include "tcg/helper-sve.h"
-#include "tcg/helper-sme.h"
-#endif
-
 #include "tcg/helper-mve.h"
diff --git a/target/arm/helper64.h b/target/arm/helper64.h
new file mode 100644
index 00000000000..b6829779662
--- /dev/null
+++ b/target/arm/helper64.h
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "tcg/helper-a64.h"
+#include "tcg/helper-sve.h"
+#include "tcg/helper-sme.h"
diff --git a/target/arm/tcg/gengvec64.c b/target/arm/tcg/gengvec64.c
index 2429cab1b88..e0276426874 100644
--- a/target/arm/tcg/gengvec64.c
+++ b/target/arm/tcg/gengvec64.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#define HAS_HELPER64
 #include "translate.h"
 #include "translate-a64.h"
 
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
index ba1d775d818..e78bc5acaf4 100644
--- a/target/arm/tcg/helper-a64.c
+++ b/target/arm/tcg/helper-a64.c
@@ -21,6 +21,7 @@
 #include "qemu/units.h"
 #include "cpu.h"
 #include "gdbstub/helpers.h"
+#define HAS_HELPER64
 #include "exec/helper-proto.h"
 #include "qemu/host-utils.h"
 #include "qemu/log.h"
diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c
index bb48fe359b8..3b63fd11eb6 100644
--- a/target/arm/tcg/mte_helper.c
+++ b/target/arm/tcg/mte_helper.c
@@ -31,6 +31,7 @@
 #endif
 #include "accel/tcg/cpu-ldst.h"
 #include "accel/tcg/probe.h"
+#define HAS_HELPER64
 #include "exec/helper-proto.h"
 #include "exec/tlb-flags.h"
 #include "accel/tcg/cpu-ops.h"
diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c
index c591c3052c3..7073023d001 100644
--- a/target/arm/tcg/pauth_helper.c
+++ b/target/arm/tcg/pauth_helper.c
@@ -22,6 +22,7 @@
 #include "internals.h"
 #include "cpu-features.h"
 #include "accel/tcg/cpu-ldst.h"
+#define HAS_HELPER64
 #include "exec/helper-proto.h"
 #include "tcg/tcg-gvec-desc.h"
 #include "qemu/xxhash.h"
diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c
index 075360d8b8a..0ae0f80a892 100644
--- a/target/arm/tcg/sme_helper.c
+++ b/target/arm/tcg/sme_helper.c
@@ -21,6 +21,7 @@
 #include "cpu.h"
 #include "internals.h"
 #include "tcg/tcg-gvec-desc.h"
+#define HAS_HELPER64
 #include "exec/helper-proto.h"
 #include "accel/tcg/cpu-ldst.h"
 #include "accel/tcg/helper-retaddr.h"
diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c
index c442fcb540d..e432a853d96 100644
--- a/target/arm/tcg/sve_helper.c
+++ b/target/arm/tcg/sve_helper.c
@@ -21,6 +21,7 @@
 #include "cpu.h"
 #include "internals.h"
 #include "exec/page-protection.h"
+#define HAS_HELPER64
 #include "exec/helper-proto.h"
 #include "exec/target_page.h"
 #include "exec/tlb-flags.h"
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index cde22a5cca7..b066da37891 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -18,6 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "exec/target_page.h"
+#define HAS_HELPER64
 #include "translate.h"
 #include "translate-a64.h"
 #include "qemu/log.h"
diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c
index 091c56da4f4..f667b4374f9 100644
--- a/target/arm/tcg/translate-sme.c
+++ b/target/arm/tcg/translate-sme.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#define HAS_HELPER64
 #include "translate.h"
 #include "translate-a64.h"
 
diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
index 07b827fa8e8..96bef4bbccd 100644
--- a/target/arm/tcg/translate-sve.c
+++ b/target/arm/tcg/translate-sve.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#define HAS_HELPER64
 #include "translate.h"
 #include "translate-a64.h"
 #include "fpu/softfloat.h"
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
index 63735d97898..8988c852983 100644
--- a/target/arm/tcg/translate.c
+++ b/target/arm/tcg/translate.c
@@ -26,6 +26,9 @@
 #include "arm_ldst.h"
 #include "semihosting/semihost.h"
 #include "cpregs.h"
+#ifdef TARGET_AARCH64
+#define HAS_HELPER64
+#endif
 #include "exec/helper-proto.h"
 #include "exec/target_page.h"
 
@@ -33,6 +36,12 @@
 #include "exec/helper-info.c.inc"
 #undef  HELPER_H
 
+#ifdef TARGET_AARCH64
+#define HELPER_H "helper64.h"
+#include "exec/helper-info.c.inc"
+#undef  HELPER_H
+#endif
+
 #define ENABLE_ARCH_4T    arm_dc_feature(s, ARM_FEATURE_V4T)
 #define ENABLE_ARCH_5     arm_dc_feature(s, ARM_FEATURE_V5)
 /* currently all emulated v5 cores are also v5TE, so don't bother */
diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c
index 33a136b90a6..c85983f5313 100644
--- a/target/arm/tcg/vec_helper.c
+++ b/target/arm/tcg/vec_helper.c
@@ -19,6 +19,9 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
+#ifdef TARGET_AARCH64
+#define HAS_HELPER64
+#endif
 #include "exec/helper-proto.h"
 #include "tcg/tcg-gvec-desc.h"
 #include "fpu/softfloat.h"
-- 
2.47.3
Re: [PATCH 06/29] target/arm: extract helper64.h
Posted by Richard Henderson 1 month ago
On 1/9/26 16:31, Pierrick Bouvier wrote:
> --- a/target/arm/tcg/translate.c
> +++ b/target/arm/tcg/translate.c
> @@ -26,6 +26,9 @@
>   #include "arm_ldst.h"
>   #include "semihosting/semihost.h"
>   #include "cpregs.h"
> +#ifdef TARGET_AARCH64
> +#define HAS_HELPER64
> +#endif
>   #include "exec/helper-proto.h"
>   #include "exec/target_page.h"
>   
> @@ -33,6 +36,12 @@
>   #include "exec/helper-info.c.inc"
>   #undef  HELPER_H
>   
> +#ifdef TARGET_AARCH64
> +#define HELPER_H "helper64.h"
> +#include "exec/helper-info.c.inc"
> +#undef  HELPER_H
> +#endif
> +
>   #define ENABLE_ARCH_4T    arm_dc_feature(s, ARM_FEATURE_V4T)
>   #define ENABLE_ARCH_5     arm_dc_feature(s, ARM_FEATURE_V5)
>   /* currently all emulated v5 cores are also v5TE, so don't bother */

In the ideal case, only the files that require the helper data will include it. So, for 
example, the helper-sme.h data would only be included by translate-sme.c and sme_helper.c, 
etc.

I now see that while I planned for this with how I set up HELPER_H, I didn't follow 
through with the cleanups anywhere.


r~
Re: [PATCH 06/29] target/arm: extract helper64.h
Posted by Pierrick Bouvier 1 month ago
On 1/9/26 1:30 PM, Richard Henderson wrote:
> On 1/9/26 16:31, Pierrick Bouvier wrote:
>> --- a/target/arm/tcg/translate.c
>> +++ b/target/arm/tcg/translate.c
>> @@ -26,6 +26,9 @@
>>    #include "arm_ldst.h"
>>    #include "semihosting/semihost.h"
>>    #include "cpregs.h"
>> +#ifdef TARGET_AARCH64
>> +#define HAS_HELPER64
>> +#endif
>>    #include "exec/helper-proto.h"
>>    #include "exec/target_page.h"
>>    
>> @@ -33,6 +36,12 @@
>>    #include "exec/helper-info.c.inc"
>>    #undef  HELPER_H
>>    
>> +#ifdef TARGET_AARCH64
>> +#define HELPER_H "helper64.h"
>> +#include "exec/helper-info.c.inc"
>> +#undef  HELPER_H
>> +#endif
>> +
>>    #define ENABLE_ARCH_4T    arm_dc_feature(s, ARM_FEATURE_V4T)
>>    #define ENABLE_ARCH_5     arm_dc_feature(s, ARM_FEATURE_V5)
>>    /* currently all emulated v5 cores are also v5TE, so don't bother */
> 
> In the ideal case, only the files that require the helper data will include it. So, for
> example, the helper-sme.h data would only be included by translate-sme.c and sme_helper.c,
> etc.
> 
> I now see that while I planned for this with how I set up HELPER_H, I didn't follow
> through with the cleanups anywhere.
> 

I'm ok to do this if you prefer.

In this case, may I suggest we rename helper to something different and 
let actual names be placeholders for:
#define HELPER_H "helper-impl*.h"
#include "exec/helper-gen.h.inc"
#undef HELPER_H

This way, C files don't have to deal with this, and simply see:
#include "helper.h"

Any other name is welcome is you prefer.

> 
> r~
Re: [PATCH 06/29] target/arm: extract helper64.h
Posted by Richard Henderson 1 month ago
On 1/10/26 08:37, Pierrick Bouvier wrote:
> On 1/9/26 1:30 PM, Richard Henderson wrote:
>> On 1/9/26 16:31, Pierrick Bouvier wrote:
>>> --- a/target/arm/tcg/translate.c
>>> +++ b/target/arm/tcg/translate.c
>>> @@ -26,6 +26,9 @@
>>>    #include "arm_ldst.h"
>>>    #include "semihosting/semihost.h"
>>>    #include "cpregs.h"
>>> +#ifdef TARGET_AARCH64
>>> +#define HAS_HELPER64
>>> +#endif
>>>    #include "exec/helper-proto.h"
>>>    #include "exec/target_page.h"
>>> @@ -33,6 +36,12 @@
>>>    #include "exec/helper-info.c.inc"
>>>    #undef  HELPER_H
>>> +#ifdef TARGET_AARCH64
>>> +#define HELPER_H "helper64.h"
>>> +#include "exec/helper-info.c.inc"
>>> +#undef  HELPER_H
>>> +#endif
>>> +
>>>    #define ENABLE_ARCH_4T    arm_dc_feature(s, ARM_FEATURE_V4T)
>>>    #define ENABLE_ARCH_5     arm_dc_feature(s, ARM_FEATURE_V5)
>>>    /* currently all emulated v5 cores are also v5TE, so don't bother */
>>
>> In the ideal case, only the files that require the helper data will include it. So, for
>> example, the helper-sme.h data would only be included by translate-sme.c and sme_helper.c,
>> etc.
>>
>> I now see that while I planned for this with how I set up HELPER_H, I didn't follow
>> through with the cleanups anywhere.
>>
> 
> I'm ok to do this if you prefer.
> 
> In this case, may I suggest we rename helper to something different and let actual names 
> be placeholders for:
> #define HELPER_H "helper-impl*.h"
> #include "exec/helper-gen.h.inc"
> #undef HELPER_H
> 
> This way, C files don't have to deal with this, and simply see:
> #include "helper.h"
> 
> Any other name is welcome is you prefer.

That sounds fine.  I can't immediately think of better naming.


r~

Re: [PATCH 06/29] target/arm: extract helper64.h
Posted by Philippe Mathieu-Daudé 1 month ago
On 9/1/26 06:31, Pierrick Bouvier wrote:
> This allows to get rid of TARGET_AARCH64 in target/arm/helper.h.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/helper.h            | 6 ------
>   target/arm/helper64.h          | 5 +++++
>   target/arm/tcg/gengvec64.c     | 1 +
>   target/arm/tcg/helper-a64.c    | 1 +
>   target/arm/tcg/mte_helper.c    | 1 +
>   target/arm/tcg/pauth_helper.c  | 1 +
>   target/arm/tcg/sme_helper.c    | 1 +
>   target/arm/tcg/sve_helper.c    | 1 +
>   target/arm/tcg/translate-a64.c | 1 +
>   target/arm/tcg/translate-sme.c | 1 +
>   target/arm/tcg/translate-sve.c | 1 +
>   target/arm/tcg/translate.c     | 9 +++++++++
>   target/arm/tcg/vec_helper.c    | 3 +++
>   13 files changed, 26 insertions(+), 6 deletions(-)
>   create mode 100644 target/arm/helper64.h

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