diff mbox

[6/9] target-cris: reduce v32isms from v10 log dumps

Message ID 1473076452-19795-6-git-send-email-rabin.vincent@axis.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rabin Vincent Sept. 5, 2016, 11:54 a.m. UTC
From: Hans-Peter Nilsson <hp@axis.com>

Use the correct register names for v10 and don't dump support function
registers for pre-v32.

Signed-off-by: Hans-Peter Nilsson <hp@axis.com>
Signed-off-by: Rabin Vincent <rabinv@axis.com>
---
 target-cris/translate.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

Comments

Edgar E. Iglesias Sept. 12, 2016, 10:59 p.m. UTC | #1
On Mon, Sep 05, 2016 at 01:54:09PM +0200, Rabin Vincent wrote:
> From: Hans-Peter Nilsson <hp@axis.com>
> 
> Use the correct register names for v10 and don't dump support function
> registers for pre-v32.
> 
> Signed-off-by: Hans-Peter Nilsson <hp@axis.com>
> Signed-off-by: Rabin Vincent <rabinv@axis.com>
> ---
>  target-cris/translate.c | 36 +++++++++++++++++++++++-------------
>  1 file changed, 23 insertions(+), 13 deletions(-)
> 
> diff --git a/target-cris/translate.c b/target-cris/translate.c
> index c280e24..a4512b5 100644
> --- a/target-cris/translate.c
> +++ b/target-cris/translate.c
> @@ -140,14 +140,14 @@ static void gen_BUG(DisasContext *dc, const char *file, int line)
>      cpu_abort(CPU(dc->cpu), "%s:%d\n", file, line);
>  }
>  
> -static const char *regnames[] =
> +static const char *regnames_v32[] =
>  {
>      "$r0", "$r1", "$r2", "$r3",
>      "$r4", "$r5", "$r6", "$r7",
>      "$r8", "$r9", "$r10", "$r11",
>      "$r12", "$r13", "$sp", "$acr",
>  };
> -static const char *pregnames[] =
> +static const char *pregnames_v32[] =
>  {
>      "$bz", "$vr", "$pid", "$srs",
>      "$wz", "$exs", "$eda", "$mof",
> @@ -3336,12 +3336,20 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
>  {
>      CRISCPU *cpu = CRIS_CPU(cs);
>      CPUCRISState *env = &cpu->env;
> +    const char **regnames;
> +    const char **pregnames;
>      int i;
> -    uint32_t srs;
>  
>      if (!env || !f) {
>          return;
>      }
> +    if (env->pregs[PR_VR] < 32) {
> +        pregnames = pregnames_v10;
> +        regnames = regnames_v10;
> +    } else {
> +        pregnames = pregnames_v32;
> +        regnames = regnames_v32;
> +    }
>  
>      cpu_fprintf(f, "PC=%x CCS=%x btaken=%d btarget=%x\n"
>              "cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n",
> @@ -3363,14 +3371,16 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
>              cpu_fprintf(f, "\n");
>          }
>      }
> -    srs = env->pregs[PR_SRS];
> -    cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
> -    if (srs < ARRAY_SIZE(env->sregs)) {
> -        for (i = 0; i < 16; i++) {
> -            cpu_fprintf(f, "s%2.2d=%8.8x ",
> -                    i, env->sregs[srs][i]);
> -            if ((i + 1) % 4 == 0) {
> -                cpu_fprintf(f, "\n");
> +    if (env->pregs[PR_SRS] >= 32) {


did you mean env->pregs[PR_VR] >= 32 here?


> +        uint32_t srs = env->pregs[PR_SRS];
> +        cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
> +        if (srs < ARRAY_SIZE(env->sregs)) {
> +            for (i = 0; i < 16; i++) {
> +                cpu_fprintf(f, "s%2.2d=%8.8x ",
> +                        i, env->sregs[srs][i]);
> +                if ((i + 1) % 4 == 0) {
> +                    cpu_fprintf(f, "\n");
> +                }
>              }
>          }
>      }
> @@ -3415,12 +3425,12 @@ void cris_initialize_tcg(void)
>      for (i = 0; i < 16; i++) {
>          cpu_R[i] = tcg_global_mem_new(cpu_env,
>                                        offsetof(CPUCRISState, regs[i]),
> -                                      regnames[i]);
> +                                      regnames_v32[i]);
>      }
>      for (i = 0; i < 16; i++) {
>          cpu_PR[i] = tcg_global_mem_new(cpu_env,
>                                         offsetof(CPUCRISState, pregs[i]),
> -                                       pregnames[i]);
> +                                       pregnames_v32[i]);
>      }
>  }
>  
> -- 
> 2.1.4
>
diff mbox

Patch

diff --git a/target-cris/translate.c b/target-cris/translate.c
index c280e24..a4512b5 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -140,14 +140,14 @@  static void gen_BUG(DisasContext *dc, const char *file, int line)
     cpu_abort(CPU(dc->cpu), "%s:%d\n", file, line);
 }
 
-static const char *regnames[] =
+static const char *regnames_v32[] =
 {
     "$r0", "$r1", "$r2", "$r3",
     "$r4", "$r5", "$r6", "$r7",
     "$r8", "$r9", "$r10", "$r11",
     "$r12", "$r13", "$sp", "$acr",
 };
-static const char *pregnames[] =
+static const char *pregnames_v32[] =
 {
     "$bz", "$vr", "$pid", "$srs",
     "$wz", "$exs", "$eda", "$mof",
@@ -3336,12 +3336,20 @@  void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
 {
     CRISCPU *cpu = CRIS_CPU(cs);
     CPUCRISState *env = &cpu->env;
+    const char **regnames;
+    const char **pregnames;
     int i;
-    uint32_t srs;
 
     if (!env || !f) {
         return;
     }
+    if (env->pregs[PR_VR] < 32) {
+        pregnames = pregnames_v10;
+        regnames = regnames_v10;
+    } else {
+        pregnames = pregnames_v32;
+        regnames = regnames_v32;
+    }
 
     cpu_fprintf(f, "PC=%x CCS=%x btaken=%d btarget=%x\n"
             "cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n",
@@ -3363,14 +3371,16 @@  void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
             cpu_fprintf(f, "\n");
         }
     }
-    srs = env->pregs[PR_SRS];
-    cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
-    if (srs < ARRAY_SIZE(env->sregs)) {
-        for (i = 0; i < 16; i++) {
-            cpu_fprintf(f, "s%2.2d=%8.8x ",
-                    i, env->sregs[srs][i]);
-            if ((i + 1) % 4 == 0) {
-                cpu_fprintf(f, "\n");
+    if (env->pregs[PR_SRS] >= 32) {
+        uint32_t srs = env->pregs[PR_SRS];
+        cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
+        if (srs < ARRAY_SIZE(env->sregs)) {
+            for (i = 0; i < 16; i++) {
+                cpu_fprintf(f, "s%2.2d=%8.8x ",
+                        i, env->sregs[srs][i]);
+                if ((i + 1) % 4 == 0) {
+                    cpu_fprintf(f, "\n");
+                }
             }
         }
     }
@@ -3415,12 +3425,12 @@  void cris_initialize_tcg(void)
     for (i = 0; i < 16; i++) {
         cpu_R[i] = tcg_global_mem_new(cpu_env,
                                       offsetof(CPUCRISState, regs[i]),
-                                      regnames[i]);
+                                      regnames_v32[i]);
     }
     for (i = 0; i < 16; i++) {
         cpu_PR[i] = tcg_global_mem_new(cpu_env,
                                        offsetof(CPUCRISState, pregs[i]),
-                                       pregnames[i]);
+                                       pregnames_v32[i]);
     }
 }