diff mbox series

[30/32] target/rx: Use translator_ld*

Message ID 20240405102459.462551-31-richard.henderson@linaro.org
State Superseded
Headers show
Series accel/tcg: Improve disassembly for target and plugin | expand

Commit Message

Richard Henderson April 5, 2024, 10:24 a.m. UTC
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/rx/translate.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

Comments

Philippe Mathieu-Daudé April 5, 2024, 12:55 p.m. UTC | #1
On 5/4/24 12:24, Richard Henderson wrote:
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/rx/translate.c | 27 ++++++++++++++-------------
>   1 file changed, 14 insertions(+), 13 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Yoshinori Sato April 8, 2024, 8:53 a.m. UTC | #2
On Fri, 05 Apr 2024 19:24:57 +0900,
Richard Henderson wrote:
> 
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/rx/translate.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/target/rx/translate.c b/target/rx/translate.c
> index 92fb2b43ad..9b81cf20b3 100644
> --- a/target/rx/translate.c
> +++ b/target/rx/translate.c
> @@ -22,7 +22,6 @@
>  #include "cpu.h"
>  #include "exec/exec-all.h"
>  #include "tcg/tcg-op.h"
> -#include "exec/cpu_ldst.h"
>  #include "exec/helper-proto.h"
>  #include "exec/helper-gen.h"
>  #include "exec/translator.h"
> @@ -75,10 +74,10 @@ static TCGv_i64 cpu_acc;
>  
>  /* decoder helper */
>  static uint32_t decode_load_bytes(DisasContext *ctx, uint32_t insn,
> -                           int i, int n)
> +                                  int i, int n)
>  {
>      while (++i <= n) {
> -        uint8_t b = cpu_ldub_code(ctx->env, ctx->base.pc_next++);
> +        uint8_t b = translator_ldub(ctx->env, &ctx->base, ctx->base.pc_next++);
>          insn |= b << (32 - i * 8);
>      }
>      return insn;
> @@ -90,22 +89,24 @@ static uint32_t li(DisasContext *ctx, int sz)
>      CPURXState *env = ctx->env;
>      addr = ctx->base.pc_next;
>  
> -    tcg_debug_assert(sz < 4);
>      switch (sz) {
>      case 1:
>          ctx->base.pc_next += 1;
> -        return cpu_ldsb_code(env, addr);
> +        return (int8_t)translator_ldub(env, &ctx->base, addr);
>      case 2:
>          ctx->base.pc_next += 2;
> -        return cpu_ldsw_code(env, addr);
> +        return (int16_t)translator_lduw(env, &ctx->base, addr);
>      case 3:
>          ctx->base.pc_next += 3;
> -        tmp = cpu_ldsb_code(env, addr + 2) << 16;
> -        tmp |= cpu_lduw_code(env, addr) & 0xffff;
> +        tmp = (int8_t)translator_ldub(env, &ctx->base, addr + 2);
> +        tmp <<= 16;
> +        tmp |= translator_lduw(env, &ctx->base, addr);
>          return tmp;
>      case 0:
>          ctx->base.pc_next += 4;
> -        return cpu_ldl_code(env, addr);
> +        return translator_ldl(env, &ctx->base, addr);
> +    default:
> +        g_assert_not_reached();
>      }
>      return 0;
>  }
> @@ -190,22 +191,22 @@ static inline TCGv rx_index_addr(DisasContext *ctx, TCGv mem,
>  {
>      uint32_t dsp;
>  
> -    tcg_debug_assert(ld < 3);
>      switch (ld) {
>      case 0:
>          return cpu_regs[reg];
>      case 1:
> -        dsp = cpu_ldub_code(ctx->env, ctx->base.pc_next) << size;
> +        dsp = translator_ldub(ctx->env, &ctx->base, ctx->base.pc_next) << size;
>          tcg_gen_addi_i32(mem, cpu_regs[reg], dsp);
>          ctx->base.pc_next += 1;
>          return mem;
>      case 2:
> -        dsp = cpu_lduw_code(ctx->env, ctx->base.pc_next) << size;
> +        dsp = translator_lduw(ctx->env, &ctx->base, ctx->base.pc_next) << size;
>          tcg_gen_addi_i32(mem, cpu_regs[reg], dsp);
>          ctx->base.pc_next += 2;
>          return mem;
> +    default:
> +        g_assert_not_reached();
>      }
> -    return NULL;
>  }
>  
>  static inline MemOp mi_to_mop(unsigned mi)
> -- 
> 2.34.1
> 

Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
diff mbox series

Patch

diff --git a/target/rx/translate.c b/target/rx/translate.c
index 92fb2b43ad..9b81cf20b3 100644
--- a/target/rx/translate.c
+++ b/target/rx/translate.c
@@ -22,7 +22,6 @@ 
 #include "cpu.h"
 #include "exec/exec-all.h"
 #include "tcg/tcg-op.h"
-#include "exec/cpu_ldst.h"
 #include "exec/helper-proto.h"
 #include "exec/helper-gen.h"
 #include "exec/translator.h"
@@ -75,10 +74,10 @@  static TCGv_i64 cpu_acc;
 
 /* decoder helper */
 static uint32_t decode_load_bytes(DisasContext *ctx, uint32_t insn,
-                           int i, int n)
+                                  int i, int n)
 {
     while (++i <= n) {
-        uint8_t b = cpu_ldub_code(ctx->env, ctx->base.pc_next++);
+        uint8_t b = translator_ldub(ctx->env, &ctx->base, ctx->base.pc_next++);
         insn |= b << (32 - i * 8);
     }
     return insn;
@@ -90,22 +89,24 @@  static uint32_t li(DisasContext *ctx, int sz)
     CPURXState *env = ctx->env;
     addr = ctx->base.pc_next;
 
-    tcg_debug_assert(sz < 4);
     switch (sz) {
     case 1:
         ctx->base.pc_next += 1;
-        return cpu_ldsb_code(env, addr);
+        return (int8_t)translator_ldub(env, &ctx->base, addr);
     case 2:
         ctx->base.pc_next += 2;
-        return cpu_ldsw_code(env, addr);
+        return (int16_t)translator_lduw(env, &ctx->base, addr);
     case 3:
         ctx->base.pc_next += 3;
-        tmp = cpu_ldsb_code(env, addr + 2) << 16;
-        tmp |= cpu_lduw_code(env, addr) & 0xffff;
+        tmp = (int8_t)translator_ldub(env, &ctx->base, addr + 2);
+        tmp <<= 16;
+        tmp |= translator_lduw(env, &ctx->base, addr);
         return tmp;
     case 0:
         ctx->base.pc_next += 4;
-        return cpu_ldl_code(env, addr);
+        return translator_ldl(env, &ctx->base, addr);
+    default:
+        g_assert_not_reached();
     }
     return 0;
 }
@@ -190,22 +191,22 @@  static inline TCGv rx_index_addr(DisasContext *ctx, TCGv mem,
 {
     uint32_t dsp;
 
-    tcg_debug_assert(ld < 3);
     switch (ld) {
     case 0:
         return cpu_regs[reg];
     case 1:
-        dsp = cpu_ldub_code(ctx->env, ctx->base.pc_next) << size;
+        dsp = translator_ldub(ctx->env, &ctx->base, ctx->base.pc_next) << size;
         tcg_gen_addi_i32(mem, cpu_regs[reg], dsp);
         ctx->base.pc_next += 1;
         return mem;
     case 2:
-        dsp = cpu_lduw_code(ctx->env, ctx->base.pc_next) << size;
+        dsp = translator_lduw(ctx->env, &ctx->base, ctx->base.pc_next) << size;
         tcg_gen_addi_i32(mem, cpu_regs[reg], dsp);
         ctx->base.pc_next += 2;
         return mem;
+    default:
+        g_assert_not_reached();
     }
-    return NULL;
 }
 
 static inline MemOp mi_to_mop(unsigned mi)