public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] sim: bfin: handle negative left saturated shifts as ashifts [BZ #18407]
Date: Sun, 11 Oct 2015 07:43:00 -0000	[thread overview]
Message-ID: <1444549377-11752-1-git-send-email-vapier@gentoo.org> (raw)

When handling left saturated ashifts with negative immediates, they
should be treated as right ashifts.  This matches hardware behavior.

Committed.

Reported-by: Igor Rayak <igorr@gitatechnologies.com>
---
 sim/bfin/ChangeLog                   |  6 ++++++
 sim/bfin/bfin-sim.c                  |  6 +++++-
 sim/testsuite/sim/bfin/ChangeLog     |  5 +++++
 sim/testsuite/sim/bfin/ashift_left.s | 17 +++++++++++++++++
 4 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 sim/testsuite/sim/bfin/ashift_left.s

diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog
index d0e91b3..2e62a74 100644
--- a/sim/bfin/ChangeLog
+++ b/sim/bfin/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-11  Mike Frysinger  <vapier@gentoo.org>
+
+	PR sim/18407
+	* bfin-sim.c (decode_dsp32shiftimm_0): Call ashiftrt when count
+	is less than 0.
+
 2015-06-24  Mike Frysinger  <vapier@gentoo.org>
 
 	* interp.c (trace_register): Delete.
diff --git a/sim/bfin/bfin-sim.c b/sim/bfin/bfin-sim.c
index 8b19ead..b6acb4e 100644
--- a/sim/bfin/bfin-sim.c
+++ b/sim/bfin/bfin-sim.c
@@ -6083,7 +6083,11 @@ decode_dsp32shiftimm_0 (SIM_CPU *cpu, bu16 iw0, bu16 iw1)
       int count = imm6 (immag);
 
       TRACE_INSN (cpu, "R%i = R%i << %i (S);", dst0, src1, count);
-      STORE (DREG (dst0), lshift (cpu, DREG (src1), count, 32, 1, 1));
+
+      if (count < 0)
+	STORE (DREG (dst0), ashiftrt (cpu, DREG (src1), -count, 32));
+      else
+	STORE (DREG (dst0), lshift (cpu, DREG (src1), count, 32, 1, 1));
     }
   else if (sop == 2 && sopcde == 2)
     {
diff --git a/sim/testsuite/sim/bfin/ChangeLog b/sim/testsuite/sim/bfin/ChangeLog
index 89d2833..4fc604f 100644
--- a/sim/testsuite/sim/bfin/ChangeLog
+++ b/sim/testsuite/sim/bfin/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-11  Mike Frysinger  <vapier@gentoo.org>
+
+	PR sim/18407
+	* ashift_left.s: New test.
+
 2013-12-07  Mike Frysinger  <vapier@gentoo.org>
 
 	* run-tests.sh: Add +x file mode.
diff --git a/sim/testsuite/sim/bfin/ashift_left.s b/sim/testsuite/sim/bfin/ashift_left.s
new file mode 100644
index 0000000..04cfa40
--- /dev/null
+++ b/sim/testsuite/sim/bfin/ashift_left.s
@@ -0,0 +1,17 @@
+# Blackfin testcase for left ashift
+# Dreg = Dreg << imm (S);
+# mach: bfin
+
+	.include "testutils.inc"
+
+	.macro test in:req, shift:req, out:req, opt
+	imm32 r0, \in;
+	r1 = r0 >>> \shift \opt;
+	CHECKREG r1, \out;
+	.endm
+
+	start
+
+test 2, 1, 1, (S);
+
+	pass
-- 
2.5.2

                 reply	other threads:[~2015-10-11  7:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444549377-11752-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).