qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dongxue Zhang <elta.era@gmail.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Dongxue Zhang <elta.era@gmail.com>,
	aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH V2 2/2] target-mips/translate.c: Add judgement for msb and lsb
Date: Wed, 30 Jul 2014 22:00:25 +0800	[thread overview]
Message-ID: <1406728825-3123-1-git-send-email-elta.era@gmail.com> (raw)

Compare the real msb and lsb, when lsb <= msb, tranlate the code. When
lsb > msb, just fall through and don't raise RI exception.

Signed-off-by: Dongxue Zhang <elta.era@gmail.com>
---
 target-mips/translate.c | 43 ++++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/target-mips/translate.c b/target-mips/translate.c
index c381366..d40a4d3 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -3912,13 +3912,13 @@ static void gen_bitops (DisasContext *ctx, uint32_t opc, int rt,
     gen_load_gpr(t1, rs);
     switch (opc) {
     case OPC_EXT:
-        if (lsb + msb > 31)
-            goto fail;
-        tcg_gen_shri_tl(t0, t1, lsb);
-        if (msb != 31) {
-            tcg_gen_andi_tl(t0, t0, (1 << (msb + 1)) - 1);
-        } else {
-            tcg_gen_ext32s_tl(t0, t0);
+        if (lsb + msb <= 31) {
+            tcg_gen_shri_tl(t0, t1, lsb);
+            if (msb != 31) {
+                tcg_gen_andi_tl(t0, t0, (1 << (msb + 1)) - 1);
+            } else {
+                tcg_gen_ext32s_tl(t0, t0);
+            }
         }
         break;
 #if defined(TARGET_MIPS64)
@@ -3938,28 +3938,33 @@ static void gen_bitops (DisasContext *ctx, uint32_t opc, int rt,
         break;
 #endif
     case OPC_INS:
-        if (lsb > msb)
-            goto fail;
-        gen_load_gpr(t0, rt);
-        tcg_gen_deposit_tl(t0, t0, t1, lsb, msb - lsb + 1);
-        tcg_gen_ext32s_tl(t0, t0);
+        if (lsb <= msb) {
+            gen_load_gpr(t0, rt);
+            tcg_gen_deposit_tl(t0, t0, t1, lsb, msb - lsb + 1);
+            tcg_gen_ext32s_tl(t0, t0);
+        }
         break;
 #if defined(TARGET_MIPS64)
     case OPC_DINSM:
-        gen_load_gpr(t0, rt);
-        tcg_gen_deposit_tl(t0, t0, t1, lsb, msb + 32 - lsb + 1);
+        if (lsb <= (msb + 32)) {
+            gen_load_gpr(t0, rt);
+            tcg_gen_deposit_tl(t0, t0, t1, lsb, msb + 32 - lsb + 1);
+        }
         break;
     case OPC_DINSU:
-        gen_load_gpr(t0, rt);
-        tcg_gen_deposit_tl(t0, t0, t1, lsb + 32, msb - lsb + 1);
+        if (lsb <= msb) {
+            gen_load_gpr(t0, rt);
+            tcg_gen_deposit_tl(t0, t0, t1, lsb + 32, msb - lsb + 1);
+        }
         break;
     case OPC_DINS:
-        gen_load_gpr(t0, rt);
-        tcg_gen_deposit_tl(t0, t0, t1, lsb, msb - lsb + 1);
+        if (lsb <= msb) {
+            gen_load_gpr(t0, rt);
+            tcg_gen_deposit_tl(t0, t0, t1, lsb, msb - lsb + 1);
+        }
         break;
 #endif
     default:
-fail:
         MIPS_INVAL("bitops");
         generate_exception(ctx, EXCP_RI);
         tcg_temp_free(t0);
-- 
1.8.1.2

                 reply	other threads:[~2014-07-30 14:01 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=1406728825-3123-1-git-send-email-elta.era@gmail.com \
    --to=elta.era@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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 NNTP newsgroup(s).