[PATCH 25/29] target/arm/tcg/arm_ldst.h: use translator_ld*_end variants

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 25/29] target/arm/tcg/arm_ldst.h: use translator_ld*_end variants
Posted by Pierrick Bouvier 1 month ago
This is needed to call this header from common code.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/tcg/arm_ldst.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/target/arm/tcg/arm_ldst.h b/target/arm/tcg/arm_ldst.h
index 0252e3b0ea9..0b49b09958f 100644
--- a/target/arm/tcg/arm_ldst.h
+++ b/target/arm/tcg/arm_ldst.h
@@ -21,13 +21,21 @@
 #define ARM_LDST_H
 
 #include "exec/translator.h"
+#include "target/arm/internals.h"
 #include "qemu/bswap.h"
 
+static inline MemOp arm_memop_endian_swap(bool sctlr_b)
+{
+    MemOp t = target_big_endian() ? MO_BE : MO_LE;
+    bool do_swap = bswap_code(sctlr_b);
+    return t ^ (do_swap * MO_BSWAP);
+}
+
 /* Load an instruction and return it in the standard little-endian order */
 static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
                                     uint64_t addr, bool sctlr_b)
 {
-    return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
+    return translator_ldl_end(env, s, addr, arm_memop_endian_swap(sctlr_b));
 }
 
 /* Ditto, for a halfword (Thumb) instruction */
@@ -41,7 +49,7 @@ static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
         addr ^= 2;
     }
 #endif
-    return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
+    return translator_lduw_end(env, s, addr, arm_memop_endian_swap(sctlr_b));
 }
 
 #endif
-- 
2.47.3
Re: [PATCH 25/29] target/arm/tcg/arm_ldst.h: use translator_ld*_end variants
Posted by Richard Henderson 1 month ago
On 1/9/26 16:31, Pierrick Bouvier wrote:
> This is needed to call this header from common code.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/tcg/arm_ldst.h | 12 ++++++++++--
>   1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/target/arm/tcg/arm_ldst.h b/target/arm/tcg/arm_ldst.h
> index 0252e3b0ea9..0b49b09958f 100644
> --- a/target/arm/tcg/arm_ldst.h
> +++ b/target/arm/tcg/arm_ldst.h
> @@ -21,13 +21,21 @@
>   #define ARM_LDST_H
>   
>   #include "exec/translator.h"
> +#include "target/arm/internals.h"
>   #include "qemu/bswap.h"
>   
> +static inline MemOp arm_memop_endian_swap(bool sctlr_b)
> +{
> +    MemOp t = target_big_endian() ? MO_BE : MO_LE;
> +    bool do_swap = bswap_code(sctlr_b);
> +    return t ^ (do_swap * MO_BSWAP);
> +}
> +
>   /* Load an instruction and return it in the standard little-endian order */
>   static inline uint32_t arm_ldl_code(CPUARMState *env, DisasContextBase *s,
>                                       uint64_t addr, bool sctlr_b)
>   {
> -    return translator_ldl_swap(env, s, addr, bswap_code(sctlr_b));
> +    return translator_ldl_end(env, s, addr, arm_memop_endian_swap(sctlr_b));
>   }
>   
>   /* Ditto, for a halfword (Thumb) instruction */
> @@ -41,7 +49,7 @@ static inline uint16_t arm_lduw_code(CPUARMState *env, DisasContextBase* s,
>           addr ^= 2;
>       }
>   #endif
> -    return translator_lduw_swap(env, s, addr, bswap_code(sctlr_b));
> +    return translator_lduw_end(env, s, addr, arm_memop_endian_swap(sctlr_b));
>   }

Well, yes, but we shouldn't be doing it at this level, we should be replacing bswap_code.


r~