[PATCH v8 16/20] target/arm/tcg/arm_ldst.h: merge in translate.c

Pierrick Bouvier posted 20 patches 5 days ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Michael Rolnik <mrolnik@gmail.com>, Brian Cain <brian.cain@oss.qualcomm.com>, Helge Deller <deller@gmx.de>, Song Gao <gaosong@loongson.cn>, Laurent Vivier <laurent@vivier.eu>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, 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>, Glenn Miles <milesg@linux.ibm.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu.zevorn@gmail.com>, Yoshinori Sato <yoshinori.sato@nifty.com>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Cornelia Huck <cohuck@redhat.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.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 v8 16/20] target/arm/tcg/arm_ldst.h: merge in translate.c
Posted by Pierrick Bouvier 5 days ago
Only translate.c uses those functions, thus move them back to this file.

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

diff --git a/target/arm/tcg/arm_ldst.h b/target/arm/tcg/arm_ldst.h
index cee0548a1c7..e69de29bb2d 100644
--- a/target/arm/tcg/arm_ldst.h
+++ b/target/arm/tcg/arm_ldst.h
@@ -1,47 +0,0 @@
-/*
- * ARM load/store instructions for code (armeb-user support)
- *
- *  Copyright (c) 2012 CodeSourcery, LLC
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef ARM_LDST_H
-#define ARM_LDST_H
-
-#include "exec/translator.h"
-#include "qemu/bswap.h"
-
-/* Load an instruction and return it in the standard little-endian order */
-static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
-                                    target_ulong addr, bool sctlr_b)
-{
-    return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
-}
-
-/* Ditto, for a halfword (Thumb) instruction */
-static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
-                                     target_ulong addr, bool sctlr_b)
-{
-#ifndef CONFIG_USER_ONLY
-    /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped
-       within each word.  Undo that now.  */
-    if (sctlr_b) {
-        addr ^= 2;
-    }
-#endif
-    return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
-}
-
-#endif
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
index 6ea48efbac2..7fcf0656630 100644
--- a/target/arm/tcg/translate.c
+++ b/target/arm/tcg/translate.c
@@ -25,7 +25,6 @@
 #define TCG_ADDRESS_BITS 32
 #include "tcg/tcg-op-mem.h"
 #include "qemu/log.h"
-#include "arm_ldst.h"
 #include "semihosting/semihost.h"
 #include "cpregs.h"
 #include "exec/target_page.h"
@@ -6280,6 +6279,20 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
     }
 }
 
+/* Ditto, for a halfword (Thumb) instruction */
+static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
+                                     target_ulong addr, bool sctlr_b)
+{
+#ifndef CONFIG_USER_ONLY
+    /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped
+       within each word.  Undo that now.  */
+    if (sctlr_b) {
+        addr ^= 2;
+    }
+#endif
+    return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
+}
+
 static bool insn_crosses_page(CPUARMState *env, DisasContext *s)
 {
     /* Return true if the insn at dc->base.pc_next might cross a page boundary.
@@ -6514,6 +6527,13 @@ static void arm_post_translate_insn(DisasContext *dc)
     }
 }
 
+/* Load an instruction and return it in the standard little-endian order */
+static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
+                                    target_ulong addr, bool sctlr_b)
+{
+    return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
+}
+
 static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
 {
     DisasContext *dc = container_of(dcbase, DisasContext, base);
-- 
2.47.3
Re: [PATCH v8 16/20] target/arm/tcg/arm_ldst.h: merge in translate.c
Posted by Richard Henderson 4 days, 20 hours ago
On 4/7/26 04:26, Pierrick Bouvier wrote:
> Only translate.c uses those functions, thus move them back to this file.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/tcg/arm_ldst.h  | 47 --------------------------------------
>   target/arm/tcg/translate.c | 22 +++++++++++++++++-
>   2 files changed, 21 insertions(+), 48 deletions(-)

You could drop the inline markers with the move.

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


r~

> 
> diff --git a/target/arm/tcg/arm_ldst.h b/target/arm/tcg/arm_ldst.h
> index cee0548a1c7..e69de29bb2d 100644
> --- a/target/arm/tcg/arm_ldst.h
> +++ b/target/arm/tcg/arm_ldst.h
> @@ -1,47 +0,0 @@
> -/*
> - * ARM load/store instructions for code (armeb-user support)
> - *
> - *  Copyright (c) 2012 CodeSourcery, LLC
> - *
> - * This library is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public
> - * License as published by the Free Software Foundation; either
> - * version 2.1 of the License, or (at your option) any later version.
> - *
> - * This library is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -#ifndef ARM_LDST_H
> -#define ARM_LDST_H
> -
> -#include "exec/translator.h"
> -#include "qemu/bswap.h"
> -
> -/* Load an instruction and return it in the standard little-endian order */
> -static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
> -                                    target_ulong addr, bool sctlr_b)
> -{
> -    return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
> -}
> -
> -/* Ditto, for a halfword (Thumb) instruction */
> -static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
> -                                     target_ulong addr, bool sctlr_b)
> -{
> -#ifndef CONFIG_USER_ONLY
> -    /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped
> -       within each word.  Undo that now.  */
> -    if (sctlr_b) {
> -        addr ^= 2;
> -    }
> -#endif
> -    return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
> -}
> -
> -#endif
> diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
> index 6ea48efbac2..7fcf0656630 100644
> --- a/target/arm/tcg/translate.c
> +++ b/target/arm/tcg/translate.c
> @@ -25,7 +25,6 @@
>   #define TCG_ADDRESS_BITS 32
>   #include "tcg/tcg-op-mem.h"
>   #include "qemu/log.h"
> -#include "arm_ldst.h"
>   #include "semihosting/semihost.h"
>   #include "cpregs.h"
>   #include "exec/target_page.h"
> @@ -6280,6 +6279,20 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
>       }
>   }
>   
> +/* Ditto, for a halfword (Thumb) instruction */
> +static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
> +                                     target_ulong addr, bool sctlr_b)
> +{
> +#ifndef CONFIG_USER_ONLY
> +    /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped
> +       within each word.  Undo that now.  */
> +    if (sctlr_b) {
> +        addr ^= 2;
> +    }
> +#endif
> +    return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
> +}
> +
>   static bool insn_crosses_page(CPUARMState *env, DisasContext *s)
>   {
>       /* Return true if the insn at dc->base.pc_next might cross a page boundary.
> @@ -6514,6 +6527,13 @@ static void arm_post_translate_insn(DisasContext *dc)
>       }
>   }
>   
> +/* Load an instruction and return it in the standard little-endian order */
> +static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
> +                                    target_ulong addr, bool sctlr_b)
> +{
> +    return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
> +}
> +
>   static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
>   {
>       DisasContext *dc = container_of(dcbase, DisasContext, base);
Re: [PATCH v8 16/20] target/arm/tcg/arm_ldst.h: merge in translate.c
Posted by Pierrick Bouvier 4 days, 20 hours ago
On 4/6/26 2:48 PM, Richard Henderson wrote:
> On 4/7/26 04:26, Pierrick Bouvier wrote:
>> Only translate.c uses those functions, thus move them back to this file.
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>    target/arm/tcg/arm_ldst.h  | 47 --------------------------------------
>>    target/arm/tcg/translate.c | 22 +++++++++++++++++-
>>    2 files changed, 21 insertions(+), 48 deletions(-)
> 
> You could drop the inline markers with the move.
>

Will do.

> Anyway,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> 
> r~
> 
>>
>> diff --git a/target/arm/tcg/arm_ldst.h b/target/arm/tcg/arm_ldst.h
>> index cee0548a1c7..e69de29bb2d 100644
>> --- a/target/arm/tcg/arm_ldst.h
>> +++ b/target/arm/tcg/arm_ldst.h
>> @@ -1,47 +0,0 @@
>> -/*
>> - * ARM load/store instructions for code (armeb-user support)
>> - *
>> - *  Copyright (c) 2012 CodeSourcery, LLC
>> - *
>> - * This library is free software; you can redistribute it and/or
>> - * modify it under the terms of the GNU Lesser General Public
>> - * License as published by the Free Software Foundation; either
>> - * version 2.1 of the License, or (at your option) any later version.
>> - *
>> - * This library is distributed in the hope that it will be useful,
>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> - * Lesser General Public License for more details.
>> - *
>> - * You should have received a copy of the GNU Lesser General Public
>> - * License along with this library; if not, see <http://www.gnu.org/licenses/>.
>> - */
>> -
>> -#ifndef ARM_LDST_H
>> -#define ARM_LDST_H
>> -
>> -#include "exec/translator.h"
>> -#include "qemu/bswap.h"
>> -
>> -/* Load an instruction and return it in the standard little-endian order */
>> -static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
>> -                                    target_ulong addr, bool sctlr_b)
>> -{
>> -    return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
>> -}
>> -
>> -/* Ditto, for a halfword (Thumb) instruction */
>> -static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
>> -                                     target_ulong addr, bool sctlr_b)
>> -{
>> -#ifndef CONFIG_USER_ONLY
>> -    /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped
>> -       within each word.  Undo that now.  */
>> -    if (sctlr_b) {
>> -        addr ^= 2;
>> -    }
>> -#endif
>> -    return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
>> -}
>> -
>> -#endif
>> diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
>> index 6ea48efbac2..7fcf0656630 100644
>> --- a/target/arm/tcg/translate.c
>> +++ b/target/arm/tcg/translate.c
>> @@ -25,7 +25,6 @@
>>    #define TCG_ADDRESS_BITS 32
>>    #include "tcg/tcg-op-mem.h"
>>    #include "qemu/log.h"
>> -#include "arm_ldst.h"
>>    #include "semihosting/semihost.h"
>>    #include "cpregs.h"
>>    #include "exec/target_page.h"
>> @@ -6280,6 +6279,20 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
>>        }
>>    }
>>    
>> +/* Ditto, for a halfword (Thumb) instruction */
>> +static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
>> +                                     target_ulong addr, bool sctlr_b)
>> +{
>> +#ifndef CONFIG_USER_ONLY
>> +    /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped
>> +       within each word.  Undo that now.  */
>> +    if (sctlr_b) {
>> +        addr ^= 2;
>> +    }
>> +#endif
>> +    return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
>> +}
>> +
>>    static bool insn_crosses_page(CPUARMState *env, DisasContext *s)
>>    {
>>        /* Return true if the insn at dc->base.pc_next might cross a page boundary.
>> @@ -6514,6 +6527,13 @@ static void arm_post_translate_insn(DisasContext *dc)
>>        }
>>    }
>>    
>> +/* Load an instruction and return it in the standard little-endian order */
>> +static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
>> +                                    target_ulong addr, bool sctlr_b)
>> +{
>> +    return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
>> +}
>> +
>>    static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
>>    {
>>        DisasContext *dc = container_of(dcbase, DisasContext, base);
>