Skip to contentSkip to conversation

Hppa fixes patches

GIT PULL Helge Deller 1 participant 5 messages Dec 1

lore
Share & tools
lore
#1 lore raw

[PULL for 11.2 2/4] target/hppa: Defer PA7300LC FCNVFF on NaNs

In reply to Helge Deller

From: "Kirill A. Korinsky" <[email protected]>

QEMU passed PA7300LC FCNVFF NaN operands to SoftFloat, bypassing the deferred assist exercised by OpenBSD/hppa's fmaxmin_test-11.

For a NaN operand, leave the destination intact, record the instruction in ER2 and set FPSR.T so the next active floating point instruction takes assist vector 14 before execution. FSTD FR0 can save the pending status first, clearing T only after the store succeeds.

---
 target/hppa/cpu.h           |   1 +
 target/hppa/fpu_helper.c    |  47 ++++++++++++--
 target/hppa/helper.h        |   4 +-
 target/hppa/int_helper.c    |   4 ++
 target/hppa/translate.c     |  79 +++++++++++++++++------
 tests/qtest/hppa-fpu-test.c | 121 ++++++++++++++++++++++++++++++++++++
 6 files changed, 228 insertions(+), 28 deletions(-)
target/hppa/cpu.h +1 -0
index 7b708a564b..842964074a 100644
@@ -97,6 +97,7 @@
 
 /* Emulated hardware TOC button */
 #define EXCP_TOC                 32 /* TOC = Transfer of control (NMI) */
+#define EXCP_ASSIST_DELAYED      33 /* Internal, delivered through vector 14 */
 
 const char *hppa_exception_name(int excp);
 
target/hppa/fpu_helper.c +41 -6

65 lines not on this page · raw message

target/hppa/helper.h +2 -2
index b99e298ee8..84937ee73f 100644
@@ -40,8 +40,8 @@ DEF_HELPER_FLAGS_3(fmpy_d, TCG_CALL_NO_RWG, f64, env, f64, f64)
 DEF_HELPER_FLAGS_3(fdiv_d, TCG_CALL_NO_RWG, f64, env, f64, f64)
 DEF_HELPER_FLAGS_3(frem_d, TCG_CALL_NO_RWG, f64, env, f64, f64)
 
-DEF_HELPER_FLAGS_2(fcnv_s_d, TCG_CALL_NO_RWG, f64, env, f32)
-DEF_HELPER_FLAGS_2(fcnv_d_s, TCG_CALL_NO_RWG, f32, env, f64)
+DEF_HELPER_FLAGS_4(fcnv_s_d, TCG_CALL_NO_RWG, void, env, f32, i32, i32)
+DEF_HELPER_FLAGS_4(fcnv_d_s, TCG_CALL_NO_RWG, void, env, f64, i32, i32)
 
 DEF_HELPER_FLAGS_2(fcnv_w_s, TCG_CALL_NO_RWG, f32, env, s32)
 DEF_HELPER_FLAGS_2(fcnv_dw_s, TCG_CALL_NO_RWG, f32, env, s64)
target/hppa/int_helper.c +4 -0
index da9c7c6457..8a19232062 100644
@@ -162,6 +162,7 @@ void hppa_cpu_do_interrupt(CPUState *cs)
         case EXCP_COND:
         case EXCP_PRIV_REG:
         case EXCP_PRIV_OPR:
+        case EXCP_ASSIST_DELAYED:
             /* IIR set via translate.c.  */
             break;
 
@@ -223,6 +224,9 @@ void hppa_cpu_do_interrupt(CPUState *cs)
     }
 
     /* step 7 */
+    if (i == EXCP_ASSIST_DELAYED) {
+        i = EXCP_ASSIST;
+    }
     if (i == EXCP_TOC) {
         hwaddr pdc_toc_addr = FIRMWARE_START;
 
target/hppa/translate.c +59 -20

205 lines not on this page · raw message

tests/qtest/hppa-fpu-test.c +121 -0

133 lines not on this page · raw message

Signature · 1 line
2.54.0
#2 lore raw

[PULL for 11.2 4/4] target/hppa: Fix tcg_gen_goto_tb assertion

In reply to Helge Deller

From: "Kirill A. Korinsky" <[email protected]>

On hppa a branch may generate three exits from one block, but qemu has only two slots; the third exit reused slot 0 and badaboom happened. Try to assign a unique slot to avoid the problem.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4835

---
 target/hppa/translate.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
target/hppa/translate.c +15 -11
index c8e2b13c8c..70bc7deabd 100644
@@ -85,6 +85,7 @@ typedef struct DisasContext {
     uint32_t tb_flags;
     int mmu_idx;
     int privilege;
+    unsigned goto_tb_idx;
     uint32_t psw_xb;
     bool psw_n_nonzero;
     bool psw_b_next;
@@ -791,7 +792,8 @@ static bool gen_illegal(DisasContext *ctx)
 static bool use_goto_tb(DisasContext *ctx, const DisasIAQE *f,
                         const DisasIAQE *b)
 {
-    return (!iaqe_variable(f) &&
+    return (ctx->goto_tb_idx <= TB_EXIT_IDXMAX &&
+            !iaqe_variable(f) &&
             (b == NULL || !iaqe_variable(b)) &&
             translator_use_goto_tb(&ctx->base, ctx->iaoq_first + f->disp));
 }
@@ -808,11 +810,13 @@ static bool use_nullify_skip(DisasContext *ctx)
                 & TARGET_PAGE_MASK) == 0);
 }
 
-static void gen_goto_tb(DisasContext *ctx, int which,
+static void gen_goto_tb(DisasContext *ctx,
                         const DisasIAQE *f, const DisasIAQE *b)
 {
     install_iaq_entries(ctx, f, b);
     if (use_goto_tb(ctx, f, b)) {
+        unsigned which = ctx->goto_tb_idx++;
+
         tcg_gen_goto_tb(which);
         tcg_gen_exit_tb(ctx->base.tb, which);
     } else {
@@ -1960,7 +1964,7 @@ static bool do_dbranch(DisasContext *ctx, int64_t disp,
             if (use_nullify_skip(ctx)) {
                 nullify_set(ctx, 0);
                 store_psw_xb(ctx, 0);
-                gen_goto_tb(ctx, 0, &ctx->iaq_j, NULL);
+                gen_goto_tb(ctx, &ctx->iaq_j, NULL);
                 ctx->base.is_jmp = DISAS_NORETURN;
                 return true;
             }
@@ -1975,17 +1979,17 @@ static bool do_dbranch(DisasContext *ctx, int64_t disp,
         if (is_n && use_nullify_skip(ctx)) {
             nullify_set(ctx, 0);
             store_psw_xb(ctx, 0);
-            gen_goto_tb(ctx, 0, &ctx->iaq_j, NULL);
+            gen_goto_tb(ctx, &ctx->iaq_j, NULL);
         } else {
             nullify_set(ctx, is_n);
             store_psw_xb(ctx, PSW_B);
-            gen_goto_tb(ctx, 0, &ctx->iaq_b, &ctx->iaq_j);
+            gen_goto_tb(ctx, &ctx->iaq_b, &ctx->iaq_j);
         }
         nullify_end(ctx);
 
         nullify_set(ctx, 0);
         store_psw_xb(ctx, 0);
-        gen_goto_tb(ctx, 1, &ctx->iaq_b, NULL);
+        gen_goto_tb(ctx, &ctx->iaq_b, NULL);
         ctx->base.is_jmp = DISAS_NORETURN;
     }
     return true;
@@ -2017,7 +2021,7 @@ static bool do_cbranch(DisasContext *ctx, int64_t disp, bool is_n,
         nullify_set(ctx, 0);
         store_psw_xb(ctx, 0);
         next = iaqe_incr(&ctx->iaq_b, 4);
-        gen_goto_tb(ctx, 0, &next, NULL);
+        gen_goto_tb(ctx, &next, NULL);
     } else {
         if (!n && ctx->null_lab) {
             gen_set_label(ctx->null_lab);
@@ -2025,7 +2029,7 @@ static bool do_cbranch(DisasContext *ctx, int64_t disp, bool is_n,
         }
         nullify_set(ctx, n);
         store_psw_xb(ctx, 0);
-        gen_goto_tb(ctx, 0, &ctx->iaq_b, NULL);
+        gen_goto_tb(ctx, &ctx->iaq_b, NULL);
     }
 
     gen_set_label(taken);
@@ -2037,11 +2041,11 @@ static bool do_cbranch(DisasContext *ctx, int64_t disp, bool is_n,
     if (n && use_nullify_skip(ctx)) {
         nullify_set(ctx, 0);
         store_psw_xb(ctx, 0);
-        gen_goto_tb(ctx, 1, &next, NULL);
+        gen_goto_tb(ctx, &next, NULL);
     } else {
         nullify_set(ctx, n);
         store_psw_xb(ctx, PSW_B);
-        gen_goto_tb(ctx, 1, &ctx->iaq_b, &next);
+        gen_goto_tb(ctx, &ctx->iaq_b, &next);
     }
 
     /* Not taken: the branch itself was nullified.  */
@@ -4970,7 +4974,7 @@ static void hppa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
             && (ctx->null_cond.c == TCG_COND_NEVER
                 || ctx->null_cond.c == TCG_COND_ALWAYS)) {
             nullify_set(ctx, ctx->null_cond.c == TCG_COND_ALWAYS);
-            gen_goto_tb(ctx, 0, f, b);
+            gen_goto_tb(ctx, f, b);
             break;
         }
         /* FALLTHRU */
Signature · 1 line
2.54.0
#3 lore raw

[PULL for 11.2 1/4] target/hppa: Emulate FREM

In reply to Helge Deller

From: "Kirill A. Korinsky" <[email protected]>

OpenBSD/hppa's libm remainder tests terminate with SIGILL on FREM because QEMU's HPPA decoder omits class 3 subopcode 4 under both major opcodes, 0x0c and 0x0e, sending both encodings through gen_illegal() to raise EXCP_ILL when the FPU is enabled.

Decode both encodings and compute IEEE remainder in single and double precision with SoftFloat, with qtest coverage for exact result bits at quotient ties under directed rounding and for the FPSR invalid operation flag on zero divisors and infinite dividends.

---
 target/hppa/fpu_helper.c    |  14 +++++
 target/hppa/helper.h        |   2 +
 target/hppa/insns.decode    |   4 ++
 target/hppa/translate.c     |  10 ++++
 tests/qtest/hppa-fpu-test.c | 105 +++++++++++++++++++++++++++++++++++-
 5 files changed, 134 insertions(+), 1 deletion(-)
target/hppa/fpu_helper.c +14 -0
index a0c8c91ee5..f42044cdef 100644
@@ -177,6 +177,13 @@ float32 HELPER(fdiv_s)(CPUHPPAState *env, float32 a, float32 b)
     return ret;
 }
 
+float32 HELPER(frem_s)(CPUHPPAState *env, float32 a, float32 b)
+{
+    float32 ret = float32_rem(a, b, &env->fp_status);
+    update_fr0_op(env, GETPC());
+    return ret;
+}
+
 float64 HELPER(fsqrt_d)(CPUHPPAState *env, float64 arg)
 {
     float64 ret = float64_sqrt(arg, &env->fp_status);
@@ -219,6 +226,13 @@ float64 HELPER(fdiv_d)(CPUHPPAState *env, float64 a, float64 b)
     return ret;
 }
 
+float64 HELPER(frem_d)(CPUHPPAState *env, float64 a, float64 b)
+{
+    float64 ret = float64_rem(a, b, &env->fp_status);
+    update_fr0_op(env, GETPC());
+    return ret;
+}
+
 float64 HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg)
 {
     float64 ret = float32_to_float64(arg, &env->fp_status);
target/hppa/helper.h +2 -0
index f6c7e16f0f..b99e298ee8 100644
@@ -30,6 +30,7 @@ DEF_HELPER_FLAGS_3(fadd_s, TCG_CALL_NO_RWG, f32, env, f32, f32)
 DEF_HELPER_FLAGS_3(fsub_s, TCG_CALL_NO_RWG, f32, env, f32, f32)
 DEF_HELPER_FLAGS_3(fmpy_s, TCG_CALL_NO_RWG, f32, env, f32, f32)
 DEF_HELPER_FLAGS_3(fdiv_s, TCG_CALL_NO_RWG, f32, env, f32, f32)
+DEF_HELPER_FLAGS_3(frem_s, TCG_CALL_NO_RWG, f32, env, f32, f32)
 
 DEF_HELPER_FLAGS_2(fsqrt_d, TCG_CALL_NO_RWG, f64, env, f64)
 DEF_HELPER_FLAGS_2(frnd_d, TCG_CALL_NO_RWG, f64, env, f64)
@@ -37,6 +38,7 @@ DEF_HELPER_FLAGS_3(fadd_d, TCG_CALL_NO_RWG, f64, env, f64, f64)
 DEF_HELPER_FLAGS_3(fsub_d, TCG_CALL_NO_RWG, f64, env, f64, f64)
 DEF_HELPER_FLAGS_3(fmpy_d, TCG_CALL_NO_RWG, f64, env, f64, f64)
 DEF_HELPER_FLAGS_3(fdiv_d, TCG_CALL_NO_RWG, f64, env, f64, f64)
+DEF_HELPER_FLAGS_3(frem_d, TCG_CALL_NO_RWG, f64, env, f64, f64)
 
 DEF_HELPER_FLAGS_2(fcnv_s_d, TCG_CALL_NO_RWG, f64, env, f32)
 DEF_HELPER_FLAGS_2(fcnv_d_s, TCG_CALL_NO_RWG, f32, env, f64)
target/hppa/insns.decode +4 -0
index 135f563c88..ebc290d830 100644
@@ -620,21 +620,25 @@ fadd_f          001100 ..... ..... 000 00 ...... .....  @f0c_3
 fsub_f          001100 ..... ..... 001 00 ...... .....  @f0c_3
 fmpy_f          001100 ..... ..... 010 00 ...... .....  @f0c_3
 fdiv_f          001100 ..... ..... 011 00 ...... .....  @f0c_3
+frem_f          001100 ..... ..... 100 00 ...... .....  @f0c_3
 
 fadd_d          001100 ..... ..... 000 01 ...... .....  @f0c_3
 fsub_d          001100 ..... ..... 001 01 ...... .....  @f0c_3
 fmpy_d          001100 ..... ..... 010 01 ...... .....  @f0c_3
 fdiv_d          001100 ..... ..... 011 01 ...... .....  @f0c_3
+frem_d          001100 ..... ..... 100 01 ...... .....  @f0c_3
 
 fadd_f          001110 ..... ..... 000 ..... ... .....  @f0e_f_3
 fsub_f          001110 ..... ..... 001 ..... ... .....  @f0e_f_3
 fmpy_f          001110 ..... ..... 010 ..... ... .....  @f0e_f_3
 fdiv_f          001110 ..... ..... 011 ..... ... .....  @f0e_f_3
+frem_f          001110 ..... ..... 100 ..... ... .....  @f0e_f_3
 
 fadd_d          001110 ..... ..... 000 ..... ... .....  @f0e_d_3
 fsub_d          001110 ..... ..... 001 ..... ... .....  @f0e_d_3
 fmpy_d          001110 ..... ..... 010 ..... ... .....  @f0e_d_3
 fdiv_d          001110 ..... ..... 011 ..... ... .....  @f0e_d_3
+frem_d          001110 ..... ..... 100 ..... ... .....  @f0e_d_3
 
 xmpyu           001110 ..... ..... 010 .0111 .00 t:5    r1=%ra64 r2=%rb64
 
target/hppa/translate.c +10 -0
index ab3505f9c9..0713112063 100644
@@ -4498,6 +4498,16 @@ static bool trans_fdiv_d(DisasContext *ctx, arg_fclass3 *a)
     return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_fdiv_d);
 }
 
+static bool trans_frem_f(DisasContext *ctx, arg_fclass3 *a)
+{
+    return do_fop_weww(ctx, a->t, a->r1, a->r2, gen_helper_frem_s);
+}
+
+static bool trans_frem_d(DisasContext *ctx, arg_fclass3 *a)
+{
+    return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_frem_d);
+}
+
 static bool trans_xmpyu(DisasContext *ctx, arg_xmpyu *a)
 {
     TCGv_i64 x, y;
tests/qtest/hppa-fpu-test.c +104 -1

121 lines not on this page · raw message

Signature · 1 line
2.54.0
#0 lore raw

From: Helge Deller <[email protected]>

The following changes since commit 9751c62358073580cbf330a4df22077a7c6a407c:

Update version for v11.2.0-rc2 release (2026-11-25 21:39:27 -0800)

are available in the Git repository at:

https://github.com/hdeller/qemu-hppa.git tags/hppa-fixes-pull-request

for you to fetch changes up to bd107c56027e297358af8a12bf1709472f5a77a4:

target/hppa: Fix tcg_gen_goto_tb assertion (2026-12-01 22:42:15 +0100)

----------------------------------------------------------------
target/hppa patches

Add the missing FREM asm instruction to fix OpenBSD, and one fix for goto_tb which prevented boot of some versions of HP-UX 10.20 on B160L (issue #4835).

----------------------------------------------------------------

Kirill A. Korinsky (4):
target/hppa: Emulate FREM
target/hppa: Defer PA7300LC FCNVFF on NaNs
target/hppa: Defer PA7300LC multiply assists
target/hppa: Fix tcg_gen_goto_tb assertion

 target/hppa/cpu.h           |   1 +
 target/hppa/fpu_helper.c    | 173 ++++++++++++++++++-
 target/hppa/helper.h        |  12 +-
 target/hppa/insns.decode    |   4 +
 target/hppa/int_helper.c    |   4 +
 target/hppa/translate.c     | 154 +++++++++++++----
 tests/qtest/hppa-fpu-test.c | 330 +++++++++++++++++++++++++++++++++++-
 7 files changed, 639 insertions(+), 39 deletions(-)
Signature · 1 line
2.54.0
#4 lore raw

[PULL for 11.2 3/4] target/hppa: Defer PA7300LC multiply assists

From: "Kirill A. Korinsky" <[email protected]>

With FPSR.D clear, PA7300LC defers FMPY, FMPYADD and FMPYSUB for certain denormal operands or a result that is tiny after rounding, including exact results that leave IEEE underflow clear. Detect tininess through SoftFloat's output flush flag on a scratch status.

Evaluate both components of FMPYADD and FMPYSUB from the original operands. If either requires an assist, record the instruction in ER2 and set FPSR.T, preserving both destinations and the FPSR exception flags.

OpenBSD/hppa's trig_test-3 takes its expected failure path when tanf encounters the assist, and the full msun regression passes with the original Makefile.

---
 target/hppa/fpu_helper.c    | 116 +++++++++++++++++++++++++++++++++++-
 target/hppa/helper.h        |   6 ++
 target/hppa/translate.c     |  39 ++++++++++++
 tests/qtest/hppa-fpu-test.c | 104 ++++++++++++++++++++++++++++++++
 4 files changed, 264 insertions(+), 1 deletion(-)
target/hppa/fpu_helper.c +115 -1
index 82ad6da34d..1255b4999c 100644
@@ -240,7 +240,25 @@ float64 HELPER(frem_d)(CPUHPPAState *env, float64 a, float64 b)
 #ifndef CONFIG_USER_ONLY
 static void defer_fp_unimplemented(CPUHPPAState *env, uint32_t insn)
 {
-    uint32_t code = (insn >> 26) == 0x0c ? 0x09 : 0x0b;
+    uint32_t code;
+
+    switch (insn >> 26) {
+    case 0x06:
+        code = 0x03;
+        break;
+    case 0x26:
+        code = 0x23;
+        break;
+    case 0x0c:
+        code = 0x09;
+        break;
+    case 0x0e:
+        code = 0x0b;
+        break;
+    default:
+        g_assert_not_reached();
+    }
+
     uint32_t record = deposit32(insn, 26, 6, code);
 
     /* PA7300LC records the original operation in exception register 2. */
@@ -248,6 +266,102 @@ static void defer_fp_unimplemented(CPUHPPAState *env, uint32_t insn)
     env->fr0_shadow |= R_FPSR_T_MASK;
     env->fr[0] = deposit64(env->fr[0], 32, 32, env->fr0_shadow);
 }
+
+static float_status pa1_multiply_status(CPUHPPAState *env)
+{
+    float_status status = env->fp_status;
+
+    if (!(env->fr0_shadow & R_FPSR_D_MASK)) {
+        /* Identify tiny results even when IEEE underflow is not raised. */
+        set_flush_to_zero(true, &status);
+        set_float_ftz_detection(float_ftz_after_rounding, &status);
+    }
+    return status;
+}
+
+static bool pa1_multiply_needs_assist(CPUHPPAState *env,
+                                    const float_status *status, bool single,
+                                    bool multiply, uint64_t a, uint64_t b)
+{
+    if (env->fr0_shadow & R_FPSR_D_MASK) {
+        return false;
+    }
+    if (get_float_exception_flags(status) & float_flag_output_denormal_flushed) {
+        return true;
+    }
+
+    uint64_t sign_mask = single ? INT32_MAX : INT64_MAX;
+    uint64_t min_normal = single ? 0x00800000 : 0x0010000000000000ULL;
+    uint64_t infinity = single ? 0x7f800000 : 0x7ff0000000000000ULL;
+
+    a &= sign_mask;
+    b &= sign_mask;
+    return (a != 0 && a < min_normal && b != infinity &&
+            (!multiply || b != 0)) ||
+           (b != 0 && b < min_normal && a != infinity &&
+            (!multiply || a != 0));
+}
+
+static void pa1_multiply_write_result(CPUHPPAState *env, uint32_t reg,
+                                      bool single, uint64_t result,
+                                      const float_status *status, uintptr_t ra)
+{
+    set_float_exception_flags(get_float_exception_flags(status),
+                              &env->fp_status);
+    update_fr0_op(env, ra);
+    if (single) {
+        unsigned shift = reg & 32 ? 0 : 32;
+
+        reg &= 31;
+        env->fr[reg] = deposit64(env->fr[reg], shift, 32, result);
+    } else {
+        env->fr[reg] = result;
+    }
+}
+
+void HELPER(fmpy_pa1)(CPUHPPAState *env, uint64_t a, uint64_t b,
+                      uint32_t reg, uint32_t insn)
+{
+    bool single = !extract32(insn, 11, 1);
+    float_status status = pa1_multiply_status(env);
+    uint64_t product = single ? float32_mul(a, b, &status)
+                              : float64_mul(a, b, &status);
+
+    if (pa1_multiply_needs_assist(env, &status, single, true, a, b)) {
+        defer_fp_unimplemented(env, insn);
+        return;
+    }
+    pa1_multiply_write_result(env, reg, single, product, &status, GETPC());
+}
+
+void HELPER(fmpyadd_pa1)(CPUHPPAState *env, uint64_t m1, uint64_t m2,
+                        uint64_t a1, uint64_t a2, uint32_t regs, uint32_t insn)
+{
+    bool single = extract32(insn, 5, 1);
+    bool subtract = (insn >> 26) == 0x26;
+    float_status multiply_status = pa1_multiply_status(env);
+    float_status add_status = multiply_status;
+    uint64_t product, sum;
+
+    if (single) {
+        product = float32_mul(m1, m2, &multiply_status);
+        sum = subtract ? float32_sub(a1, a2, &add_status)
+                       : float32_add(a1, a2, &add_status);
+    } else {
+        product = float64_mul(m1, m2, &multiply_status);
+        sum = subtract ? float64_sub(a1, a2, &add_status)
+                       : float64_add(a1, a2, &add_status);
+    }
+
+    if (pa1_multiply_needs_assist(env, &multiply_status, single, true, m1, m2) ||
+        pa1_multiply_needs_assist(env, &add_status, single, false, a1, a2)) {
+        defer_fp_unimplemented(env, insn);
+        return;
+    }
+    pa1_multiply_write_result(env, regs & 63, single, product,
+                              &multiply_status, GETPC());
+    pa1_multiply_write_result(env, regs >> 6, single, sum, &add_status, GETPC());
+}
 #endif
 
 void HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg, uint32_t reg, uint32_t insn)
target/hppa/helper.h +6 -0
index 84937ee73f..a1d1dfffd8 100644
@@ -24,6 +24,12 @@ DEF_HELPER_FLAGS_4(probe, TCG_CALL_NO_WG, tl, env, tl, i32, i32)
 
 DEF_HELPER_FLAGS_1(loaded_fr0, TCG_CALL_NO_RWG, void, env)
 
+#ifndef CONFIG_USER_ONLY
+DEF_HELPER_FLAGS_5(fmpy_pa1, TCG_CALL_NO_RWG, void, env, i64, i64, i32, i32)
+DEF_HELPER_FLAGS_7(fmpyadd_pa1, TCG_CALL_NO_RWG, void, env, i64, i64, i64, i64,
+                   i32, i32)
+#endif
+
 DEF_HELPER_FLAGS_2(fsqrt_s, TCG_CALL_NO_RWG, f32, env, f32)
 DEF_HELPER_FLAGS_2(frnd_s, TCG_CALL_NO_RWG, f32, env, f32)
 DEF_HELPER_FLAGS_3(fadd_s, TCG_CALL_NO_RWG, f32, env, f32, f32)
target/hppa/translate.c +39 -0
index 67670768d1..c8e2b13c8c 100644
@@ -4519,11 +4519,27 @@ static bool trans_fsub_d(DisasContext *ctx, arg_fclass3 *a)
 
 static bool trans_fmpy_f(DisasContext *ctx, arg_fclass3 *a)
 {
+#ifndef CONFIG_USER_ONLY
+    if (!ctx->is_pa20) {
+        fp_nullify_over(ctx);
+        gen_helper_fmpy_pa1(tcg_env, load_frw0_i64(a->r1), load_frw0_i64(a->r2),
+                            tcg_constant_i32(a->t), tcg_constant_i32(ctx->insn));
+        return nullify_end(ctx);
+    }
+#endif
     return do_fop_weww(ctx, a->t, a->r1, a->r2, gen_helper_fmpy_s);
 }
 
 static bool trans_fmpy_d(DisasContext *ctx, arg_fclass3 *a)
 {
+#ifndef CONFIG_USER_ONLY
+    if (!ctx->is_pa20) {
+        fp_nullify_over(ctx);
+        gen_helper_fmpy_pa1(tcg_env, load_frd0(a->r1), load_frd0(a->r2),
+                            tcg_constant_i32(a->t), tcg_constant_i32(ctx->insn));
+        return nullify_end(ctx);
+    }
+#endif
     return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_fmpy_d);
 }
 
@@ -4575,6 +4591,18 @@ static bool do_fmpyadd_s(DisasContext *ctx, arg_mpyadd *a, bool is_sub)
     int rm2 = fmpyadd_s_reg(a->rm2);
     int rm1 = fmpyadd_s_reg(a->rm1);
 
+#ifndef CONFIG_USER_ONLY
+    /* A zero addend field in FMPYADD encodes FMPYCFXT on PA7300LC. */
+    if (!ctx->is_pa20 && (is_sub || a->ra != 0)) {
+        fp_nullify_over(ctx);
+        gen_helper_fmpyadd_pa1(tcg_env,
+                              load_frw0_i64(rm1), load_frw0_i64(rm2),
+                              load_frw0_i64(ta), load_frw0_i64(ra),
+                              tcg_constant_i32((ta << 6) | tm),
+                              tcg_constant_i32(ctx->insn));
+        return nullify_end(ctx);
+    }
+#endif
     nullify_over(ctx);
 
     do_fop_weww(ctx, tm, rm1, rm2, gen_helper_fmpy_s);
@@ -4596,6 +4624,17 @@ static bool trans_fmpysub_f(DisasContext *ctx, arg_mpyadd *a)
 
 static bool do_fmpyadd_d(DisasContext *ctx, arg_mpyadd *a, bool is_sub)
 {
+#ifndef CONFIG_USER_ONLY
+    if (!ctx->is_pa20 && (is_sub || a->ra != 0)) {
+        fp_nullify_over(ctx);
+        gen_helper_fmpyadd_pa1(tcg_env,
+                              load_frd0(a->rm1), load_frd0(a->rm2),
+                              load_frd0(a->ta), load_frd0(a->ra),
+                              tcg_constant_i32((a->ta << 6) | a->tm),
+                              tcg_constant_i32(ctx->insn));
+        return nullify_end(ctx);
+    }
+#endif
     nullify_over(ctx);
 
     do_fop_dedd(ctx, a->tm, a->rm1, a->rm2, gen_helper_fmpy_d);
tests/qtest/hppa-fpu-test.c +104 -0

116 lines not on this page · raw message

Signature · 1 line
2.54.0