[PATCH v3 1/3] target/hexagon: Inline translator_ldl()

Philippe Mathieu-Daudé posted 3 patches 1 month, 2 weeks ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Brian Cain <brian.cain@oss.qualcomm.com>
[PATCH v3 1/3] target/hexagon: Inline translator_ldl()
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
translator_ldl() is defined in "exec/translator.h" as:

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> MO_LE
since Hexagon use little-endian order.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/hexagon/translate.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index 8fce219c0de..c37035c4774 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -203,8 +203,9 @@ static int read_packet_words(CPUHexagonState *env, DisasContext *ctx,
     memset(words, 0, PACKET_WORDS_MAX * sizeof(uint32_t));
     for (nwords = 0; !found_end && nwords < PACKET_WORDS_MAX; nwords++) {
         words[nwords] =
-            translator_ldl(env, &ctx->base,
-                           ctx->base.pc_next + nwords * sizeof(uint32_t));
+            translator_ldl_end(env, &ctx->base,
+                               ctx->base.pc_next + nwords * sizeof(uint32_t),
+                               MO_LE);
         found_end = is_packet_end(words[nwords]);
     }
     if (!found_end) {
@@ -966,8 +967,10 @@ static bool pkt_crosses_page(CPUHexagonState *env, DisasContext *ctx)
     int nwords;
 
     for (nwords = 0; !found_end && nwords < PACKET_WORDS_MAX; nwords++) {
-        uint32_t word = translator_ldl(env, &ctx->base,
-                            ctx->base.pc_next + nwords * sizeof(uint32_t));
+        uint32_t word = translator_ldl_end(env, &ctx->base,
+                                           ctx->base.pc_next
+                                           + nwords * sizeof(uint32_t),
+                                           MO_LE);
         found_end = is_packet_end(word);
     }
     uint32_t next_ptr =  ctx->base.pc_next + nwords * sizeof(uint32_t);
-- 
2.52.0


Re: [PATCH v3 1/3] target/hexagon: Inline translator_ldl()
Posted by Brian Cain 1 month ago
On Wed, Dec 24, 2025 at 10:07 AM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> translator_ldl() is defined in "exec/translator.h" as:
>
>   198 static inline uint32_t
>   199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
>   200 {
>   201     return translator_ldl_end(env, db, pc, MO_TE);
>   202 }
>
> Directly use the inlined form, expanding MO_TE -> MO_LE
> since Hexagon use little-endian order.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>

Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>

 target/hexagon/translate.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
> index 8fce219c0de..c37035c4774 100644
> --- a/target/hexagon/translate.c
> +++ b/target/hexagon/translate.c
> @@ -203,8 +203,9 @@ static int read_packet_words(CPUHexagonState *env,
> DisasContext *ctx,
>      memset(words, 0, PACKET_WORDS_MAX * sizeof(uint32_t));
>      for (nwords = 0; !found_end && nwords < PACKET_WORDS_MAX; nwords++) {
>          words[nwords] =
> -            translator_ldl(env, &ctx->base,
> -                           ctx->base.pc_next + nwords * sizeof(uint32_t));
> +            translator_ldl_end(env, &ctx->base,
> +                               ctx->base.pc_next + nwords *
> sizeof(uint32_t),
> +                               MO_LE);
>          found_end = is_packet_end(words[nwords]);
>      }
>      if (!found_end) {
> @@ -966,8 +967,10 @@ static bool pkt_crosses_page(CPUHexagonState *env,
> DisasContext *ctx)
>      int nwords;
>
>      for (nwords = 0; !found_end && nwords < PACKET_WORDS_MAX; nwords++) {
> -        uint32_t word = translator_ldl(env, &ctx->base,
> -                            ctx->base.pc_next + nwords *
> sizeof(uint32_t));
> +        uint32_t word = translator_ldl_end(env, &ctx->base,
> +                                           ctx->base.pc_next
> +                                           + nwords * sizeof(uint32_t),
> +                                           MO_LE);
>          found_end = is_packet_end(word);
>      }
>      uint32_t next_ptr =  ctx->base.pc_next + nwords * sizeof(uint32_t);
> --
> 2.52.0
>
>
Re: [PATCH v3 1/3] target/hexagon: Inline translator_ldl()
Posted by Richard Henderson 1 month ago
On 12/25/25 03:07, Philippe Mathieu-Daudé wrote:
> translator_ldl() is defined in "exec/translator.h" as:
> 
>    198 static inline uint32_t
>    199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
>    200 {
>    201     return translator_ldl_end(env, db, pc, MO_TE);
>    202 }
> 
> Directly use the inlined form, expanding MO_TE -> MO_LE
> since Hexagon use little-endian order.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   target/hexagon/translate.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)

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

r~

Re: [PATCH v3 1/3] target/hexagon: Inline translator_ldl()
Posted by Manos Pitsidianakis 1 month, 1 week ago
On Wed, Dec 24, 2025 at 6:07 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> translator_ldl() is defined in "exec/translator.h" as:
>
>   198 static inline uint32_t
>   199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
>   200 {
>   201     return translator_ldl_end(env, db, pc, MO_TE);
>   202 }
>
> Directly use the inlined form, expanding MO_TE -> MO_LE
> since Hexagon use little-endian order.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>

>  target/hexagon/translate.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
> index 8fce219c0de..c37035c4774 100644
> --- a/target/hexagon/translate.c
> +++ b/target/hexagon/translate.c
> @@ -203,8 +203,9 @@ static int read_packet_words(CPUHexagonState *env, DisasContext *ctx,
>      memset(words, 0, PACKET_WORDS_MAX * sizeof(uint32_t));
>      for (nwords = 0; !found_end && nwords < PACKET_WORDS_MAX; nwords++) {
>          words[nwords] =
> -            translator_ldl(env, &ctx->base,
> -                           ctx->base.pc_next + nwords * sizeof(uint32_t));
> +            translator_ldl_end(env, &ctx->base,
> +                               ctx->base.pc_next + nwords * sizeof(uint32_t),
> +                               MO_LE);
>          found_end = is_packet_end(words[nwords]);
>      }
>      if (!found_end) {
> @@ -966,8 +967,10 @@ static bool pkt_crosses_page(CPUHexagonState *env, DisasContext *ctx)
>      int nwords;
>
>      for (nwords = 0; !found_end && nwords < PACKET_WORDS_MAX; nwords++) {
> -        uint32_t word = translator_ldl(env, &ctx->base,
> -                            ctx->base.pc_next + nwords * sizeof(uint32_t));
> +        uint32_t word = translator_ldl_end(env, &ctx->base,
> +                                           ctx->base.pc_next
> +                                           + nwords * sizeof(uint32_t),
> +                                           MO_LE);
>          found_end = is_packet_end(word);
>      }
>      uint32_t next_ptr =  ctx->base.pc_next + nwords * sizeof(uint32_t);
> --
> 2.52.0
>