[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2] ppc: Convert op_405_check_{sat,satu} to TCG
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH v2] ppc: Convert op_405_check_{sat,satu} to TCG |
Date: |
Tue, 28 Oct 2008 21:01:39 +0100 |
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>
---
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
op_405_check_sat.patch
Description: Binary data