diff mbox series

[27/32] target/cris: Use translator_ld* in cris_fetch

Message ID 20240405102459.462551-28-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: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/cris/translate.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

Comments

Philippe Mathieu-Daudé April 5, 2024, 12:50 p.m. UTC | #1
On 5/4/24 12:24, Richard Henderson wrote:
> Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/cris/translate.c | 25 ++++++++-----------------
>   1 file changed, 8 insertions(+), 17 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Edgar E. Iglesias April 5, 2024, 12:55 p.m. UTC | #2
On Fri, Apr 5, 2024 at 12:25 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>


Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>


> ---
>  target/cris/translate.c | 25 ++++++++-----------------
>  1 file changed, 8 insertions(+), 17 deletions(-)
>
> diff --git a/target/cris/translate.c b/target/cris/translate.c
> index b5410189d4..bb2d6612ba 100644
> --- a/target/cris/translate.c
> +++ b/target/cris/translate.c
> @@ -222,37 +222,28 @@ static int sign_extend(unsigned int val, unsigned
> int width)
>  }
>
>  static int cris_fetch(CPUCRISState *env, DisasContext *dc, uint32_t addr,
> -              unsigned int size, unsigned int sign)
> +                      unsigned int size, bool sign)
>  {
>      int r;
>
>      switch (size) {
>      case 4:
> -    {
> -        r = cpu_ldl_code(env, addr);
> +        r = translator_ldl(env, &dc->base, addr);
>          break;
> -    }
>      case 2:
> -    {
> +        r = translator_lduw(env, &dc->base, addr);
>          if (sign) {
> -            r = cpu_ldsw_code(env, addr);
> -        } else {
> -            r = cpu_lduw_code(env, addr);
> +            r = (int16_t)r;
>          }
>          break;
> -    }
>      case 1:
> -    {
> +        r = translator_ldub(env, &dc->base, addr);
>          if (sign) {
> -            r = cpu_ldsb_code(env, addr);
> -        } else {
> -            r = cpu_ldub_code(env, addr);
> +            r = (int8_t)r;
>          }
>          break;
> -    }
>      default:
> -        cpu_abort(CPU(dc->cpu), "Invalid fetch size %d\n", size);
> -        break;
> +        g_assert_not_reached();
>      }
>      return r;
>  }
> @@ -2868,7 +2859,7 @@ static unsigned int crisv32_decoder(CPUCRISState
> *env, DisasContext *dc)
>      int i;
>
>      /* Load a halfword onto the instruction register.  */
> -        dc->ir = cris_fetch(env, dc, dc->pc, 2, 0);
> +    dc->ir = cris_fetch(env, dc, dc->pc, 2, 0);
>
>      /* Now decode it.  */
>      dc->opcode   = EXTRACT_FIELD(dc->ir, 4, 11);
> --
> 2.34.1
>
>
diff mbox series

Patch

diff --git a/target/cris/translate.c b/target/cris/translate.c
index b5410189d4..bb2d6612ba 100644
--- a/target/cris/translate.c
+++ b/target/cris/translate.c
@@ -222,37 +222,28 @@  static int sign_extend(unsigned int val, unsigned int width)
 }
 
 static int cris_fetch(CPUCRISState *env, DisasContext *dc, uint32_t addr,
-              unsigned int size, unsigned int sign)
+                      unsigned int size, bool sign)
 {
     int r;
 
     switch (size) {
     case 4:
-    {
-        r = cpu_ldl_code(env, addr);
+        r = translator_ldl(env, &dc->base, addr);
         break;
-    }
     case 2:
-    {
+        r = translator_lduw(env, &dc->base, addr);
         if (sign) {
-            r = cpu_ldsw_code(env, addr);
-        } else {
-            r = cpu_lduw_code(env, addr);
+            r = (int16_t)r;
         }
         break;
-    }
     case 1:
-    {
+        r = translator_ldub(env, &dc->base, addr);
         if (sign) {
-            r = cpu_ldsb_code(env, addr);
-        } else {
-            r = cpu_ldub_code(env, addr);
+            r = (int8_t)r;
         }
         break;
-    }
     default:
-        cpu_abort(CPU(dc->cpu), "Invalid fetch size %d\n", size);
-        break;
+        g_assert_not_reached();
     }
     return r;
 }
@@ -2868,7 +2859,7 @@  static unsigned int crisv32_decoder(CPUCRISState *env, DisasContext *dc)
     int i;
 
     /* Load a halfword onto the instruction register.  */
-        dc->ir = cris_fetch(env, dc, dc->pc, 2, 0);
+    dc->ir = cris_fetch(env, dc, dc->pc, 2, 0);
 
     /* Now decode it.  */
     dc->opcode   = EXTRACT_FIELD(dc->ir, 4, 11);