* [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
* Re: [Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG
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-28 20:01 ` [Qemu-devel] [PATCH v2] " Andreas Färber
0 siblings, 2 replies; 7+ messages in thread
From: Paul Brook @ 2008-10-25 20:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber, Aurélien Jarno
On Saturday 25 October 2008, Andreas Färber wrote:
> + tcg_gen_shri_tl(tmp, tmp, 31);
> + tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, 0, endLabel);
Is this really right for ppc64?
You can easily test the high bit using TCG_COND_LT.
> + 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);
((signed)x >> 31) ^ 0x7fffffff)
is a much more efficient way of implementing this.
Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG
2008-10-25 20:09 ` Paul Brook
@ 2008-10-25 20:25 ` Andreas Färber
2008-10-25 23:29 ` Anthony Liguori
2008-10-28 20:01 ` [Qemu-devel] [PATCH v2] " Andreas Färber
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Färber @ 2008-10-25 20:25 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel, Aurélien Jarno
Am 25.10.2008 um 22:09 schrieb Paul Brook:
> On Saturday 25 October 2008, Andreas Färber wrote:
>> + tcg_gen_shri_tl(tmp, tmp, 31);
>> + tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, 0, endLabel);
>
> Is this really right for ppc64?
http://en.wikipedia.org/wiki/PowerPC_400
says the embedded 400 family is 32-bit.
> You can easily test the high bit using TCG_COND_LT.
>
>> + 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);
>
> ((signed)x >> 31) ^ 0x7fffffff)
> is a much more efficient way of implementing this.
I just translated the original code that's being removed in the
patch. ;)
On second thoughts I am wondering whether we should use a new helper
here instead of TCG instructions? (The Readme mentions 20 instructions
as limit.) Unfortunately I wouldn't know how to yet, it doesn't work
simply calling the old helper, e.g., tcg_gen_helper_0_0(do_40x_rfci);
because the function name is unknown there.
Andreas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG
2008-10-25 20:25 ` Andreas Färber
@ 2008-10-25 23:29 ` Anthony Liguori
2008-10-27 16:05 ` Hollis Blanchard
0 siblings, 1 reply; 7+ messages in thread
From: Anthony Liguori @ 2008-10-25 23:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Hollis Blanchard, Paul Brook, Aurélien Jarno
Andreas Färber wrote:
>
> Am 25.10.2008 um 22:09 schrieb Paul Brook:
>
>> On Saturday 25 October 2008, Andreas Färber wrote:
>>> + tcg_gen_shri_tl(tmp, tmp, 31);
>>> + tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, 0, endLabel);
>>
>> Is this really right for ppc64?
>
> http://en.wikipedia.org/wiki/PowerPC_400
> says the embedded 400 family is 32-bit.
I'm pretty sure it is. Hollis?
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG
2008-10-25 23:29 ` Anthony Liguori
@ 2008-10-27 16:05 ` Hollis Blanchard
0 siblings, 0 replies; 7+ messages in thread
From: Hollis Blanchard @ 2008-10-27 16:05 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Aurélien Jarno, Paul Brook
On Sat, 2008-10-25 at 18:29 -0500, Anthony Liguori wrote:
> Andreas Färber wrote:
> >
> > Am 25.10.2008 um 22:09 schrieb Paul Brook:
> >
> >> On Saturday 25 October 2008, Andreas Färber wrote:
> >>> + tcg_gen_shri_tl(tmp, tmp, 31);
> >>> + tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, 0, endLabel);
> >>
> >> Is this really right for ppc64?
> >
> > http://en.wikipedia.org/wiki/PowerPC_400
> > says the embedded 400 family is 32-bit.
>
> I'm pretty sure it is. Hollis?
It is.
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2] ppc: Convert op_405_check_{sat,satu} to TCG
2008-10-25 20:09 ` Paul Brook
2008-10-25 20:25 ` Andreas Färber
@ 2008-10-28 20:01 ` Andreas Färber
2008-11-01 0:55 ` Aurélien Jarno
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Färber @ 2008-10-28 20:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Paul Brook, Aurélien Jarno
[-- Attachment #1: Type: text/plain, Size: 3100 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>
---
Updated with simplifications suggested by Paul Brook.
Still only compile-tested - please verify whether I got the logic
right.
target-ppc/op.c | 15 ---------------
target-ppc/op_helper.c | 12 ------------
target-ppc/translate.c | 22 ++++++++++++++++++----
3 files changed, 18 insertions(+), 31 deletions(-)
diff --git a/target-ppc/op.c b/target-ppc/op.c
index bcdb11d..f9b1910 100644
--- a/target-ppc/op.c
+++ b/target-ppc/op.c
@@ -1502,12 +1502,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)) {
@@ -1518,15 +1512,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 a977ea4..2a4a70d 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -5106,10 +5106,24 @@ 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_brcondi_tl(TCG_COND_GE, tmp, 0, endLabel);
+
+ tcg_gen_xor_tl(tmp, cpu_T[0], cpu_T[2]);
+ tcg_gen_brcondi_tl(TCG_COND_LT, tmp, 0, endLabel);
+
+ tcg_gen_shri_tl(tmp, cpu_T[2], 31);
+ tcg_gen_xori_tl(cpu_T[0], tmp, 0x7fffffff);
+
+ 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: 3107 bytes --]
From 439fab33c937e05d271e5e7bd6731e799ff4d97b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andreas=20F=C3=A4rber?= <andreas.faerber@web.de>
Date: Tue, 28 Oct 2008 20:51:50 +0100
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 | 22 ++++++++++++++++++----
3 files changed, 18 insertions(+), 31 deletions(-)
diff --git a/target-ppc/op.c b/target-ppc/op.c
index bcdb11d..f9b1910 100644
--- a/target-ppc/op.c
+++ b/target-ppc/op.c
@@ -1502,12 +1502,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)) {
@@ -1518,15 +1512,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 a977ea4..2a4a70d 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -5106,10 +5106,24 @@ 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_brcondi_tl(TCG_COND_GE, tmp, 0, endLabel);
+
+ tcg_gen_xor_tl(tmp, cpu_T[0], cpu_T[2]);
+ tcg_gen_brcondi_tl(TCG_COND_LT, tmp, 0, endLabel);
+
+ tcg_gen_shri_tl(tmp, cpu_T[2], 31);
+ tcg_gen_xori_tl(cpu_T[0], tmp, 0x7fffffff);
+
+ 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 #3: Type: text/plain, Size: 1 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2] ppc: Convert op_405_check_{sat,satu} to TCG
2008-10-28 20:01 ` [Qemu-devel] [PATCH v2] " Andreas Färber
@ 2008-11-01 0:55 ` Aurélien Jarno
0 siblings, 0 replies; 7+ messages in thread
From: Aurélien Jarno @ 2008-11-01 0:55 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel
On Tue, Oct 28, 2008 at 09:01:39PM +0100, Andreas Färber wrote:
> Replace op_405_check_satu with a conditional movi_tl.
>
> Replace {op,do}_405_check_sat with inline TCG instructions.
Thanks, I applied it as part of commit 5591, "target-ppc: convert 405
MAC instructions to TCG"
> Signed-off-by: Andreas Faerber <andreas.faerber@web.de>
> ---
> Updated with simplifications suggested by Paul Brook.
> Still only compile-tested - please verify whether I got the logic
> right.
>
> target-ppc/op.c | 15 ---------------
> target-ppc/op_helper.c | 12 ------------
> target-ppc/translate.c | 22 ++++++++++++++++++----
> 3 files changed, 18 insertions(+), 31 deletions(-)
>
> diff --git a/target-ppc/op.c b/target-ppc/op.c
> index bcdb11d..f9b1910 100644
> --- a/target-ppc/op.c
> +++ b/target-ppc/op.c
> @@ -1502,12 +1502,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)) {
> @@ -1518,15 +1512,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 a977ea4..2a4a70d 100644
> --- a/target-ppc/translate.c
> +++ b/target-ppc/translate.c
> @@ -5106,10 +5106,24 @@ 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_brcondi_tl(TCG_COND_GE, tmp, 0, endLabel);
> +
> + tcg_gen_xor_tl(tmp, cpu_T[0], cpu_T[2]);
> + tcg_gen_brcondi_tl(TCG_COND_LT, tmp, 0, endLabel);
> +
> + tcg_gen_shri_tl(tmp, cpu_T[2], 31);
> + tcg_gen_xori_tl(cpu_T[0], tmp, 0x7fffffff);
> +
> + 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
>
>
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [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).