diff mbox series

[4/5] target/hppa: fix sed conditions

Message ID 20190211181907.2219-5-svens@stackframe.org
State New
Headers show
Series [1/5] target/hppa: move GETPC to HELPER() functions | expand

Commit Message

Sven Schnelle Feb. 11, 2019, 6:19 p.m. UTC
Now that do_cond() uses sign overflow for some condition matches we
need to roll our own version without sign overflow checks.

Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
 target/hppa/translate.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

Comments

Richard Henderson Feb. 12, 2019, 4:27 a.m. UTC | #1
On 2/11/19 10:19 AM, Sven Schnelle wrote:
> -    f = (orig & 4) / 4;
> -
> -    return do_log_cond(c * 2 + f, res);

Given that this used to reference do_log_cond, and you've fixed do_log_cond,
why is there any reason for a change here?


r~
Sven Schnelle Feb. 14, 2019, 8:10 a.m. UTC | #2
Hi Richard,


On Mon, Feb 11, 2019 at 08:27:32PM -0800, Richard Henderson wrote:
> On 2/11/19 10:19 AM, Sven Schnelle wrote:
> > -    f = (orig & 4) / 4;
> > -
> > -    return do_log_cond(c * 2 + f, res);
> 
> Given that this used to reference do_log_cond, and you've fixed do_log_cond,
> why is there any reason for a change here?

You're right, this patch can be dropped.

Regards
Sven
diff mbox series

Patch

diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index bce8773b1a..d858fabd3a 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -1029,20 +1029,32 @@  static DisasCond do_log_cond(unsigned cf, TCGv_reg res)
 
 /* Similar, but for shift/extract/deposit conditions.  */
 
-static DisasCond do_sed_cond(unsigned orig, TCGv_reg res)
+static DisasCond do_sed_cond(unsigned c, TCGv_reg res)
 {
-    unsigned c, f;
+    DisasCond cond;
+    TCGv_reg tmp;
 
-    /* Convert the compressed condition codes to standard.
-       0-2 are the same as logicals (nv,<,<=), while 3 is OD.
-       4-7 are the reverse of 0-3.  */
-    c = orig & 3;
-    if (c == 3) {
-        c = 7;
+    switch(c & 3) {
+    case 0: /* never */
+        cond = cond_make_f();
+        break;
+    case 1: /* = all bits are zero */
+        cond = cond_make_0(TCG_COND_EQ, res);
+        break;
+    case 2: /* < leftmost bit is 1 */
+        cond = cond_make_0(TCG_COND_LT, res);
+        break;
+    case 3: /* OD rightmost bit is 1 */
+        tmp = tcg_temp_new();
+        tcg_gen_andi_reg(tmp, res, 1);
+        cond = cond_make_0(TCG_COND_NE, tmp);
+        tcg_temp_free(tmp);
+        break;
     }
-    f = (orig & 4) / 4;
-
-    return do_log_cond(c * 2 + f, res);
+    if (c & 4) {
+        cond.c = tcg_invert_cond(cond.c);
+    }
+    return cond;
 }
 
 /* Similar, but for unit conditions.  */