Skip to contentSkip to conversation

target/hppa: add unit conditions for wide mode

PATCH In review Sven Schnelle 2 participants 9 messages Mar 21, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 target/hppa: add unit conditions for wide mode

Wide mode provides two more conditions, add them.

---
 target/hppa/translate.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
target/hppa/translate.c +23 -2
index 8a87996fc1..f493e207e1 100644
@@ -963,11 +963,22 @@ static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res,
 
     switch (cf >> 1) {
     case 0: /* never / TR */
-    case 1: /* undefined */
-    case 5: /* undefined */
         cond = cond_make_f();
         break;
 
+    case 1:
+        if (d) {
+            tmp = tcg_temp_new_i64();
+            tcg_gen_subi_i64(tmp, res, d_repl * 0x00000001u);
+            tcg_gen_andc_i64(tmp, tmp, res);
+            tcg_gen_andi_i64(tmp, tmp, d_repl * 0x80000000u);
+            cond = cond_make_0(TCG_COND_NE, tmp);
+        } else {
+            /* undefined */
+            cond = cond_make_f();
+        }
+        break;
+
     case 2: /* SBZ / NBZ */
         /* See hasless(v,1) from
          * https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
@@ -992,6 +1003,16 @@ static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res,
         cond = cond_make_0(TCG_COND_NE, cb);
         break;
 
+    case 5:
+        if (d) {
+            tcg_gen_andi_i64(cb, cb, d_repl * 0x80000000u);
+            cond = cond_make_0(TCG_COND_NE, cb);
+        } else {
+            /* undefined */
+            cond = cond_make_f();
+        }
+        break;
+
     case 6: /* SBC / NBC */
         tcg_gen_andi_i64(cb, cb, d_repl * 0x80808080u);
         cond = cond_make_0(TCG_COND_NE, cb);
Signature · 1 line
2.43.2
#4 lore raw

PATCH 3/3 target/hppa: add: fix trap on overflow for narrow mode

---
 target/hppa/translate.c | 3 +++
 1 file changed, 3 insertions(+)
target/hppa/translate.c +3 -0
index 4d2b96f876..74a9ea0cd8 100644
@@ -1122,6 +1122,9 @@ static void do_add(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
     if (is_tsv || cond_need_sv(c)) {
         sv = do_add_sv(ctx, dest, in1, in2);
         if (is_tsv) {
+            if (!d) {
+                tcg_gen_ext32s_i64(sv, sv);
+            }
             /* ??? Need to include overflow from shift.  */
             gen_helper_tsv(tcg_env, sv);
         }
Signature · 1 line
2.43.2
#1 lore raw

PATCH 2/3 target/hppa: sub: fix trap on overflow for narrow mode

In reply to Sven Schnelle
---
 target/hppa/translate.c | 3 +++
 1 file changed, 3 insertions(+)
target/hppa/translate.c +3 -0
index f493e207e1..4d2b96f876 100644
@@ -1213,6 +1213,9 @@ static void do_sub(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
     if (is_tsv || cond_need_sv(c)) {
         sv = do_sub_sv(ctx, dest, in1, in2);
         if (is_tsv) {
+            if (!d) {
+                tcg_gen_ext32s_i64(sv, sv);
+            }
             gen_helper_tsv(tcg_env, sv);
         }
     }
Signature · 1 line
2.43.2
Reviewed-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] target/hppa: sub: fix trap on overflow for narrow mode

Quoted 10 lines · Sven Schnelle
---
  target/hppa/translate.c | 3 +++
  1 file changed, 3 insertions(+)
target/hppa/translate.c +0 -0
index f493e207e1..4d2b96f876 100644

target/hppa/translate.c static void do_sub(DisasContext *ctx, unsigned rt, TCGv_i64 in1, · line 1221

Quoted 9 lines
target/hppa/translate.c +3 -0
@@ -1213,6 +1213,9 @@ static void do_sub(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
      if (is_tsv || cond_need_sv(c)) {
          sv = do_sub_sv(ctx, dest, in1, in2);
          if (is_tsv) {
+            if (!d) {
+                tcg_gen_ext32s_i64(sv, sv);
+            }
              gen_helper_tsv(tcg_env, sv);
          }
      }

Difficult to pinpoint exactly which patch should have added this. :-)

r~

Reviewed-by on v1 3/3
#5 lore raw

Re: [PATCH 3/3] target/hppa: add: fix trap on overflow for narrow mode

In reply to Sven Schnelle
Quoted 10 lines · Sven Schnelle
---
  target/hppa/translate.c | 3 +++
  1 file changed, 3 insertions(+)
target/hppa/translate.c +0 -0
index 4d2b96f876..74a9ea0cd8 100644

target/hppa/translate.c static void do_add(DisasContext *ctx, unsigned rt, TCGv_i64 in1, · line 1130

Quoted 9 lines
target/hppa/translate.c +3 -0
@@ -1122,6 +1122,9 @@ static void do_add(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
      if (is_tsv || cond_need_sv(c)) {
          sv = do_add_sv(ctx, dest, in1, in2);
          if (is_tsv) {
+            if (!d) {
+                tcg_gen_ext32s_i64(sv, sv);
+            }
              /* ??? Need to include overflow from shift.  */
              gen_helper_tsv(tcg_env, sv);
          }

r~

Reviewed-by on v1 1/3
#6 lore raw
In reply to Sven Schnelle
Quoted 12 lines · Sven Schnelle

Wide mode provides two more conditions, add them.

---
  target/hppa/translate.c | 25 +++++++++++++++++++++++--
  1 file changed, 23 insertions(+), 2 deletions(-)
target/hppa/translate.c +0 -0
index 8a87996fc1..f493e207e1 100644

target/hppa/translate.c static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res, · line 969

Quoted 9 lines
target/hppa/translate.c +1 -2
@@ -963,11 +963,22 @@ static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res,
 
      switch (cf >> 1) {
      case 0: /* never / TR */
-    case 1: /* undefined */
-    case 5: /* undefined */
          cond = cond_make_f();
          break;
 
+    case 1:

Wants a comment for /* SWZ / NWZ */

target/hppa/translate.c static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res, · line 1006

Quoted 1 line
target/hppa/translate.c +1 -0
+    case 5:

/* SWC / NWC */

r~

#3 lore raw

Re: [PATCH 2/3] target/hppa: sub: fix trap on overflow for narrow mode

In reply to Richard Henderson
Quoted 13 lines · Richard Henderson
Quoted 12 lines · Sven Schnelle
---
  target/hppa/translate.c | 3 +++
  1 file changed, 3 insertions(+)
target/hppa/translate.c +0 -0
index f493e207e1..4d2b96f876 100644
@@ -1213,6 +1213,9 @@ static void do_sub(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
      if (is_tsv || cond_need_sv(c)) {
          sv = do_sub_sv(ctx, dest, in1, in2);
          if (is_tsv) {
Quoted 8 lines

target/hppa/translate.c static void do_sub(DisasContext *ctx, unsigned rt, TCGv_i64 in1, · line 1221

Quoted 6 lines
target/hppa/translate.c +3 -0
+            if (!d) {
+                tcg_gen_ext32s_i64(sv, sv);
+            }
              gen_helper_tsv(tcg_env, sv);
          }
      }

Difficult to pinpoint exactly which patch should have added this. :-)

Yes, after missing the Fixes: tags on all of my patches in the last patchset, i tried add one but wasn't sure either. :-)

Quoted 1 line

Thanks!

#7 lore raw
In reply to Richard Henderson
Quoted 21 lines · Richard Henderson
Quoted 10 lines · Sven Schnelle

Wide mode provides two more conditions, add them.

---
  target/hppa/translate.c | 25 +++++++++++++++++++++++--
  1 file changed, 23 insertions(+), 2 deletions(-)
target/hppa/translate.c +0 -0
index 8a87996fc1..f493e207e1 100644

target/hppa/translate.c static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res, · line 967

Quoted 7 lines
target/hppa/translate.c +0 -2
@@ -963,11 +963,22 @@ static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res,
        switch (cf >> 1) {
      case 0: /* never / TR */
-    case 1: /* undefined */
-    case 5: /* undefined */
          cond = cond_make_f();
          break;
  +    case 1:

Wants a comment for /* SWZ / NWZ */

Quoted 3 lines

target/hppa/translate.c static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res, · line 1006

Quoted 1 line
target/hppa/translate.c +1 -0
+    case 5:

/* SWC / NWC */

Are you going to fix that up, or should i send a v2?

#8 lore raw
Quoted 23 lines · Sven Schnelle
Quoted 21 lines · Richard Henderson
Quoted 10 lines · Sven Schnelle

Wide mode provides two more conditions, add them.

---
   target/hppa/translate.c | 25 +++++++++++++++++++++++--
   1 file changed, 23 insertions(+), 2 deletions(-)
target/hppa/translate.c +0 -0
index 8a87996fc1..f493e207e1 100644

target/hppa/translate.c static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res, · line 967

Quoted 7 lines
target/hppa/translate.c +0 -2
@@ -963,11 +963,22 @@ static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res,
         switch (cf >> 1) {
       case 0: /* never / TR */
-    case 1: /* undefined */
-    case 5: /* undefined */
           cond = cond_make_f();
           break;
   +    case 1:

Wants a comment for /* SWZ / NWZ */

Quoted 5 lines
Quoted 3 lines

target/hppa/translate.c static DisasCond do_unit_cond(unsigned cf, bool d, TCGv_i64 res, · line 1006

Quoted 1 line
target/hppa/translate.c +1 -0
+    case 5:

/* SWC / NWC */

Are you going to fix that up, or should i send a v2?

I'll fix it up.

r~