Better tracing for conditional branches
authorMichael Meissner <gnu@the-meissners.org>
Tue, 17 Feb 1998 19:38:48 +0000 (19:38 +0000)
committerMichael Meissner <gnu@the-meissners.org>
Tue, 17 Feb 1998 19:38:48 +0000 (19:38 +0000)
sim/tic80/ChangeLog
sim/tic80/cpu.h
sim/tic80/insns
sim/tic80/misc.c

index 3c2258af543b2a914829eaf13d66c4df5994479b..cd494e5148647b4da5f9fb68502a33ac2afac027 100644 (file)
@@ -1,3 +1,13 @@
+Tue Feb 17 14:35:05 1998  Michael Meissner  <meissner@cygnus.com>
+
+       * misc.c (tic80_trace_cond_br): Take size/code arguments, and
+       decode bcond conditions and bbo/bbz comparison bits.
+
+       * cpu.h (tic80_trace_cond_br): Update prototype.
+       (TRACE_COND_PR): Take size/code additional arguments.
+
+       * insns: (bbo/bbz/bcnd): Update call to TRACE_COND_PR.
+
 Tue Feb 17 12:50:27 1998  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * sim-calls.c (sim_store_register, sim_fetch_register): Pass in
index d8cfd0e12f92b88f4b6d5e37dbd9c319342339e3..29da816306d9559e0d96bb6bdd013f2746505b8b 100644 (file)
@@ -175,7 +175,7 @@ extern char *tic80_trace_nop          PARAMS ((int));
 extern char *tic80_trace_sink1   PARAMS ((int, unsigned32));
 extern char *tic80_trace_sink2   PARAMS ((int, unsigned32, unsigned32));
 extern char *tic80_trace_sink3   PARAMS ((int, unsigned32, unsigned32, unsigned32));
-extern char *tic80_trace_cond_br  PARAMS ((int, int, unsigned32, unsigned32));
+extern char *tic80_trace_cond_br  PARAMS ((int, int, unsigned32, unsigned32, int, int));
 extern char *tic80_trace_ucond_br PARAMS ((int, unsigned32));
 extern void tic80_trace_ldst     PARAMS ((SIM_DESC, sim_cpu *, sim_cia, int, int, int, int, unsigned32, unsigned32, unsigned32));
 
@@ -292,12 +292,13 @@ do {                                                                      \
   }                                                                    \
 } while (0)
 
-#define TRACE_COND_BR(indx, jump_p, cond, target)                      \
+#define TRACE_COND_BR(indx, jump_p, cond, target, size, code)          \
 do {                                                                   \
   if (TRACE_BRANCH_P (CPU)) {                                          \
     trace_one_insn (SD, CPU, cia.ip, 1, itable[indx].file,             \
                    itable[indx].line_nr, "branch",                     \
-                   tic80_trace_cond_br (indx, jump_p, cond, target));  \
+                   tic80_trace_cond_br (indx, jump_p, cond, target,    \
+                                        size, code));                  \
   }                                                                    \
 } while (0)
 
@@ -337,7 +338,7 @@ do {                                                                        \
 #define TRACE_SINK1(indx, input)
 #define TRACE_SINK2(indx, input1, input2)
 #define TRACE_SINK3(indx, input1, input2, input3)
-#define TRACE_COND_BR(indx, jump_p, cond, target)
+#define TRACE_COND_BR(indx, jump_p, cond, target, size, code)
 #define TRACE_UCOND_BR(indx, target)
 #define TRACE_LD(m, s, result, addr1, addr2)
 #define TRACE_ST(m, s, value, addr1, addr2)
index 4ffc6c5c13456e2487219a196aa83903e3ef4159..fb05919ac45c4d014eff7daf41397710c1e05564 100644 (file)
          }
        else
          jump_p = 0;
-       TRACE_COND_BR(MY_INDEX, jump_p, bitnum, target);
+       TRACE_COND_BR(MY_INDEX, jump_p, bitnum, target, -1, -1);
        return nia;
 :%s::::A:int A
        if (A)
          }
        else
          jump_p = 0;
-       TRACE_COND_BR(MY_INDEX, jump_p, bitnum, target);
+       TRACE_COND_BR(MY_INDEX, jump_p, bitnum, target, -1, -1);
        return nia;
 31.BITNUM,26.Source,21.0b100100,15.A,14.SignedOffset::::bbz i
 "bbz%s<A> <SignedOffset>, r<Source>, <bitnum>"
          {
            nia = do_branch (_SD, annul, target, 0, NULL);
          }
-       TRACE_COND_BR(MY_INDEX, condition, source, target);
+       TRACE_COND_BR(MY_INDEX, condition, val, target, size, code);
        return nia;
 31.Code,26.Source,21.0b100110,15.A,14.SignedOffset::::bcnd i
 "bcnd%s<A> <SignedOffset>, r<Source>, <Code>"
index f9e4d3cb9277920c82e6a4bc7e2a01c593cccbb5..fc7fbec12b7665e28a1a7f7ca5524c90e6b85862 100644 (file)
@@ -477,24 +477,93 @@ char *
 tic80_trace_cond_br (int indx,
                     int jump_p,
                     unsigned32 cond,
-                    unsigned32 target)
+                    unsigned32 target,
+                    int size,
+                    int code)
 {
+  char *suffix1, *suffix2;
+
   if (!tic80_size_name)
     tic80_init_trace ();
 
+  if (size >= 0 && code >= 0)
+    {                          /* BCND */
+      switch (code)
+       {
+       default: suffix1 = "???"; break;
+       case 0:  suffix1 = "nev"; break;
+       case 1:  suffix1 = "gt0"; break;
+       case 2:  suffix1 = "eq0"; break;
+       case 3:  suffix1 = "ge0"; break;
+       case 4:  suffix1 = "lt0"; break;
+       case 5:  suffix1 = "ne0"; break;
+       case 6:  suffix1 = "le0"; break;
+       case 7:  suffix1 = "alw"; break;
+       }
+
+      switch (size)
+       {
+       default: suffix2 = ".?"; break;
+       case 0:  suffix2 = ".b"; break;
+       case 1:  suffix2 = ".h"; break;
+       case 2:  suffix2 = ".w"; break;
+       }
+
+    } else {                   /* BBO/BBZ */
+
+      suffix2 = "";
+      switch (cond)
+       {
+       default: suffix1 = "??.?"; break;
+       case 29: suffix1 = "hs.w"; break;
+       case 28: suffix1 = "lo.w"; break;
+       case 27: suffix1 = "ls.w"; break;
+       case 26: suffix1 = "hi.w"; break;
+       case 25: suffix1 = "ge.w"; break;
+       case 24: suffix1 = "lt.w"; break;
+       case 23: suffix1 = "le.w"; break;
+       case 22: suffix1 = "gt.w"; break;
+       case 21: suffix1 = "ne.w"; break;
+       case 20: suffix1 = "eq.w"; break;
+       case 19: suffix1 = "hs.h"; break;
+       case 18: suffix1 = "lo.h"; break;
+       case 17: suffix1 = "ls.h"; break;
+       case 16: suffix1 = "hi.h"; break;
+       case 15: suffix1 = "ge.h"; break;
+       case 14: suffix1 = "lt.h"; break;
+       case 13: suffix1 = "le.h"; break;
+       case 12: suffix1 = "gt.h"; break;
+       case 11: suffix1 = "ne.h"; break;
+       case 10: suffix1 = "eq.h"; break;
+       case  9: suffix1 = "hs.b"; break;
+       case  8: suffix1 = "lo.b"; break;
+       case  7: suffix1 = "ls.b"; break;
+       case  6: suffix1 = "hi.b"; break;
+       case  5: suffix1 = "ge.b"; break;
+       case  4: suffix1 = "lt.b"; break;
+       case  3: suffix1 = "le.b"; break;
+       case  2: suffix1 = "gt.b"; break;
+       case  1: suffix1 = "ne.b"; break;
+       case  0: suffix1 = "eq.b"; break;
+       }
+    }
+
   if (jump_p)
     sprintf (tic80_trace_buffer,
-            "%-*s 0x%.*lx %*s 0x%.*lx/%*ld => 0x%.*lx",
+            "%-*s 0x%.*lx %*s 0x%.*lx/%*ld => 0x%.*lx %s%s",
             tic80_size_name, itable[indx].name,
             SIZE_HEX, target, SIZE_DECIMAL, "",
             SIZE_HEX, cond, SIZE_DECIMAL, (long)(signed32)cond,
-            SIZE_HEX, target);
+            SIZE_HEX, target,
+            suffix1, suffix2);
   else
     sprintf (tic80_trace_buffer,
-            "%-*s 0x%.*lx %*s 0x%.*lx/%*ld => [fallthrough]",
+            "%-*s 0x%.*lx %*s 0x%.*lx/%*ld => %-*s %s%s",
             tic80_size_name, itable[indx].name,
             SIZE_HEX, target, SIZE_DECIMAL, "",
-            SIZE_HEX, cond, SIZE_DECIMAL, (long)(signed32)cond);
+            SIZE_HEX, cond, SIZE_DECIMAL, (long)(signed32)cond,
+            SIZE_HEX + 2, "[no jump]",
+            suffix1, suffix2);
 
   return tic80_trace_buffer;
 }