sim: bfin: fix sign extension in dsp insns with MM flag
authorMike Frysinger <vapier@gentoo.org>
Sat, 18 Jun 2011 19:42:55 +0000 (19:42 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sat, 18 Jun 2011 19:42:55 +0000 (19:42 +0000)
After testing the hardware with all the different dsp flags, the MM flag
triggers sign extension in all modes.  So drop the limited use of it, and
the local custom helper that was also extending unsigned values.  We also
can see that the flag checks in the mult/mac insns have the same behavior
with sign extending, so add a helper func to keep the logic the same in
both places.

Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
include/opcode/ChangeLog
include/opcode/bfin.h
sim/bfin/ChangeLog
sim/bfin/bfin-sim.c

index f33c0e65c8f16e4e495cc3e5e8ddbd992bb33718..5474c8569ad22c9a1304dd867743f868fad5e2a9 100644 (file)
@@ -1,3 +1,7 @@
+2011-06-18  Robin Getz  <robin.getz@analog.com>
+
+       * bfin.h (is_macmod_signed): New func
+
 2011-06-18  Mike Frysinger  <vapier@gentoo.org>
 
        * bfin.h (is_macmod_pmove): Add missing space before func args.
index 30bb90d26c5c85f5c7f9c4827342a91c77ea2446..26f019381b30f4f6c717bdb92148ff7c38a85442 100755 (executable)
@@ -53,6 +53,12 @@ static inline int is_macmod_hmove (int x)
          || (x == M_TFU) || (x == M_S2RND) || (x == M_ISS2) || (x == M_IH);
 }
 
+static inline int is_macmod_signed (int x)
+{
+  return (x == 0) || (x == M_IS) || (x == M_T) || (x == M_S2RND)
+         || (x == M_ISS2) || (x == M_IH) || (x == M_W32);
+}
+
 /*   dsp32mac
 +----+----+---+---|---+----+----+---|---+---+---+---|---+---+---+---+
 | 1  | 1  | 0 | 0 |.M.| 0  | 0  |.mmod..........|.MM|.P.|.w1|.op1...|
index 72bd3584461d488ed7c028875ed57e596b975e4a..52b75ee6fa52a1699ba3e362f858c184557f9c38 100644 (file)
@@ -1,3 +1,10 @@
+2011-06-18  Robin Getz  <robin.getz@analog.com>
+
+       * bfin-sim.c (decode_multfunc): Call new is_macmod_signed, and
+       allow MM to sign extend all the time.
+       (decode_macfunc): Likewise.  Drop sign extension of unsigned
+       values.
+
 2011-06-18  Robin Getz  <robin.getz@analog.com>
 
        * bfin-sim.c (extract_mult): When mmod is M_IH, change the order
index 5b8d601d7d681bd8370ab28216e6c4f33758e623..017ddcad5121850d13b9576bc60c6d9b93964590 100644 (file)
@@ -1380,8 +1380,8 @@ decode_multfunc (SIM_CPU *cpu, int h0, int h1, int src0, int src1, int mmod,
     }
   val1 = val;
 
-  if (mmod == 0 || mmod == M_IS || mmod == M_T || mmod == M_S2RND
-      || mmod == M_ISS2 || mmod == M_IH || (MM && mmod == M_FU))
+  /* In signed modes, sign extend.  */
+  if (is_macmod_signed (mmod) || MM)
     val1 |= -(val1 & 0x80000000);
 
   if (*psat)
@@ -1579,16 +1579,11 @@ decode_macfunc (SIM_CPU *cpu, int which, int op, int h0, int h1, int src0,
   bu32 sat = 0, tsat, ret;
 
   /* Sign extend accumulator if necessary, otherwise unsigned.  */
-  if (mmod == 0 || mmod == M_T || mmod == M_IS || mmod == M_ISS2
-      || mmod == M_S2RND || mmod == M_IH || mmod == M_W32)
+  if (is_macmod_signed (mmod) || MM)
     acc = get_extended_acc (cpu, which);
   else
     acc = get_unextended_acc (cpu, which);
 
-  if (MM && (mmod == M_T || mmod == M_IS || mmod == M_ISS2
-      || mmod == M_S2RND || mmod == M_IH || mmod == M_W32))
-    acc |= -(acc & 0x80000000);
-
   if (op != 3)
     {
       bu8 sgn0 = (acc >> 31) & 1;
This page took 0.030822 seconds and 4 git commands to generate.