qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG
@ 2008-10-25 19:59 Andreas Färber
  2008-10-25 20:09 ` Paul Brook
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Färber @ 2008-10-25 19:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aurélien Jarno

[-- Attachment #1: Type: text/plain, Size: 3509 bytes --]

Replace op_405_check_satu with a conditional movi_tl.

Replace {op,do}_405_check_sat with inline TCG instructions.

Signed-off-by: Andreas Faerber <andreas.faerber@web.de>

---
  op_405_check_sat is what currently breaks on OSX/ppc with gcc4.
  With this patch applied, the next dyngen breakage is op_40x_rfci.

  Note that since this is a 405 instruction, it is only compile-tested.

  target-ppc/op.c        |   15 ---------------
  target-ppc/op_helper.c |   12 ------------
  target-ppc/translate.c |   31 +++++++++++++++++++++++++++----
  3 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/target-ppc/op.c b/target-ppc/op.c
index 2271ed0..1bb213b 100644
--- a/target-ppc/op.c
+++ b/target-ppc/op.c
@@ -1558,12 +1558,6 @@ void OPPROTO op_405_mullhwu (void)
      RETURN();
  }

-void OPPROTO op_405_check_sat (void)
-{
-    do_405_check_sat();
-    RETURN();
-}
-
  void OPPROTO op_405_check_ovu (void)
  {
      if (likely(T0 >= T2)) {
@@ -1574,15 +1568,6 @@ void OPPROTO op_405_check_ovu (void)
      RETURN();
  }

-void OPPROTO op_405_check_satu (void)
-{
-    if (unlikely(T0 < T2)) {
-        /* Saturate result */
-        T0 = UINT32_MAX;
-    }
-    RETURN();
-}
-
  void OPPROTO op_load_dcr (void)
  {
      do_load_dcr();
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 32b3471..e78ba82 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -1729,18 +1729,6 @@ void do_op_602_mfrom (void)

  / 
*****************************************************************************/
  /* Embedded PowerPC specific helpers */
-void do_405_check_sat (void)
-{
-    if (!likely((((uint32_t)T1 ^ (uint32_t)T2) >> 31) ||
-                !(((uint32_t)T0 ^ (uint32_t)T2) >> 31))) {
-        /* Saturate result */
-        if (T2 >> 31) {
-            T0 = INT32_MIN;
-        } else {
-            T0 = INT32_MAX;
-        }
-    }
-}

  /* XXX: to be improved to check access rights when in user-mode */
  void do_load_dcr (void)
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 8f4591a..b3fc02c 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -5071,10 +5071,33 @@ static always_inline void gen_405_mulladd_insn  
(DisasContext *ctx,
      }
      if (opc3 & 0x02) {
          /* Saturate */
-        if (opc3 & 0x01)
-            gen_op_405_check_sat();
-        else
-            gen_op_405_check_satu();
+        int endLabel = gen_new_label();
+        if (opc3 & 0x01) {
+            TCGv tmp = tcg_temp_new(TCG_TYPE_TL);
+            tcg_gen_xor_tl(tmp, cpu_T[1], cpu_T[2]);
+            tcg_gen_shri_tl(tmp, tmp, 31);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, 0, endLabel);
+
+            tcg_gen_xor_tl(tmp, cpu_T[0], cpu_T[2]);
+            tcg_gen_shri_tl(tmp, tmp, 31);
+            tcg_gen_brcondi_tl(TCG_COND_NE, tmp, 0, endLabel);
+
+            int innerLabel = gen_new_label();
+            tcg_gen_shri_tl(tmp, cpu_T[2], 31);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, 0, innerLabel);
+
+            tcg_gen_movi_tl(cpu_T[0], INT32_MIN);
+            tcg_gen_br(endLabel);
+
+            gen_set_label(innerLabel);
+            tcg_gen_movi_tl(cpu_T[0], INT32_MAX);
+
+            tcg_temp_free(tmp);
+        } else {
+            tcg_gen_brcond_tl(TCG_COND_GEU, cpu_T[0], cpu_T[2],  
endLabel);
+            tcg_gen_movi_tl(cpu_T[0], UINT32_MAX);
+        }
+        gen_set_label(endLabel);
      }
      tcg_gen_mov_tl(cpu_gpr[rt], cpu_T[0]);
      if (unlikely(Rc) != 0) {
-- 
1.5.6.5


[-- Attachment #2: op_405_check_sat.patch --]
[-- Type: application/octet-stream, Size: 3450 bytes --]

From 8846a0e54873ae1504a62fc064c6cd53dde9c04d Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andreas=20F=C3=A4rber?= <andreas.faerber@web.de>
Date: Sat, 25 Oct 2008 21:41:15 +0200
Subject: [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG

---
 target-ppc/op.c        |   15 ---------------
 target-ppc/op_helper.c |   12 ------------
 target-ppc/translate.c |   31 +++++++++++++++++++++++++++----
 3 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/target-ppc/op.c b/target-ppc/op.c
index 2271ed0..1bb213b 100644
--- a/target-ppc/op.c
+++ b/target-ppc/op.c
@@ -1558,12 +1558,6 @@ void OPPROTO op_405_mullhwu (void)
     RETURN();
 }
 
-void OPPROTO op_405_check_sat (void)
-{
-    do_405_check_sat();
-    RETURN();
-}
-
 void OPPROTO op_405_check_ovu (void)
 {
     if (likely(T0 >= T2)) {
@@ -1574,15 +1568,6 @@ void OPPROTO op_405_check_ovu (void)
     RETURN();
 }
 
-void OPPROTO op_405_check_satu (void)
-{
-    if (unlikely(T0 < T2)) {
-        /* Saturate result */
-        T0 = UINT32_MAX;
-    }
-    RETURN();
-}
-
 void OPPROTO op_load_dcr (void)
 {
     do_load_dcr();
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 32b3471..e78ba82 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -1729,18 +1729,6 @@ void do_op_602_mfrom (void)
 
 /*****************************************************************************/
 /* Embedded PowerPC specific helpers */
-void do_405_check_sat (void)
-{
-    if (!likely((((uint32_t)T1 ^ (uint32_t)T2) >> 31) ||
-                !(((uint32_t)T0 ^ (uint32_t)T2) >> 31))) {
-        /* Saturate result */
-        if (T2 >> 31) {
-            T0 = INT32_MIN;
-        } else {
-            T0 = INT32_MAX;
-        }
-    }
-}
 
 /* XXX: to be improved to check access rights when in user-mode */
 void do_load_dcr (void)
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 8f4591a..b3fc02c 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -5071,10 +5071,33 @@ static always_inline void gen_405_mulladd_insn (DisasContext *ctx,
     }
     if (opc3 & 0x02) {
         /* Saturate */
-        if (opc3 & 0x01)
-            gen_op_405_check_sat();
-        else
-            gen_op_405_check_satu();
+        int endLabel = gen_new_label();
+        if (opc3 & 0x01) {
+            TCGv tmp = tcg_temp_new(TCG_TYPE_TL);
+            tcg_gen_xor_tl(tmp, cpu_T[1], cpu_T[2]);
+            tcg_gen_shri_tl(tmp, tmp, 31);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, 0, endLabel);
+
+            tcg_gen_xor_tl(tmp, cpu_T[0], cpu_T[2]);
+            tcg_gen_shri_tl(tmp, tmp, 31);
+            tcg_gen_brcondi_tl(TCG_COND_NE, tmp, 0, endLabel);
+
+            int innerLabel = gen_new_label();
+            tcg_gen_shri_tl(tmp, cpu_T[2], 31);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, 0, innerLabel);
+
+            tcg_gen_movi_tl(cpu_T[0], INT32_MIN);
+            tcg_gen_br(endLabel);
+
+            gen_set_label(innerLabel);
+            tcg_gen_movi_tl(cpu_T[0], INT32_MAX);
+
+            tcg_temp_free(tmp);
+        } else {
+            tcg_gen_brcond_tl(TCG_COND_GEU, cpu_T[0], cpu_T[2], endLabel);
+            tcg_gen_movi_tl(cpu_T[0], UINT32_MAX);
+        }
+        gen_set_label(endLabel);
     }
     tcg_gen_mov_tl(cpu_gpr[rt], cpu_T[0]);
     if (unlikely(Rc) != 0) {
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-11-01  0:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-25 19:59 [Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG Andreas Färber
2008-10-25 20:09 ` Paul Brook
2008-10-25 20:25   ` Andreas Färber
2008-10-25 23:29     ` Anthony Liguori
2008-10-27 16:05       ` Hollis Blanchard
2008-10-28 20:01   ` [Qemu-devel] [PATCH v2] " Andreas Färber
2008-11-01  0:55     ` Aurélien Jarno

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).