[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG |
Date: |
Sat, 25 Oct 2008 21:59:09 +0200 |
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 <address@hidden>
---
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
op_405_check_sat.patch
Description: Binary data
- [Qemu-devel] [PATCH] ppc: Convert op_405_check_{sat,satu} to TCG,
Andreas Färber <=