Skip to contentSkip to conversation

target/hppa: Fix fid instruction emulation

PATCH Superseded Helge Deller 2 participants 2 messages Oct 27, 2022

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/hppa: Fix fid instruction emulation

The fid instruction (Floating-Point Identify) puts the FPU model and revision into the Status Register. Since those values shouldn't be 0, store values there which a PCX-L2 (for 32-bit) or a PCX-W2 (for 64-bit) would return. Noticed while trying to install MPE/iX.

---
v2: Add ULL to integer constants, enhanced commit message.

target/hppa/insns.decode +2 -4
index c7a7e997f9..3ba5f9885a 100644
@@ -388,10 +388,8 @@ fmpyfadd_d      101110 rm1:5 rm2:5 ... 0 1 ..0 0 0 neg:1 t:5    ra3=%rc32
 
 # Floating point class 0
 
-# FID.  With r = t = 0, which via fcpy puts 0 into fr0.
-# This is machine/revision = 0, which is reserved for simulator.
-fcpy_f          001100 00000 00000 00000 000000 00000   \
-                &fclass01 r=0 t=0
+# FID.  Basically like fcpy with r = t = 0. Puts machine/revision into fr0.
+fid_f           001100 00000 00000 000 00 000000 00000
 
 fcpy_f          001100 ..... ..... 010 00 ...... .....  @f0c_0
 fabs_f          001100 ..... ..... 011 00 ...... .....  @f0c_0
target/hppa/translate.c +11 -0
index d15b9e27c7..981f8ee03d 100644
@@ -3622,6 +3622,17 @@ static void gen_fcpy_f(TCGv_i32 dst, TCGv_env unused, TCGv_i32 src)
     tcg_gen_mov_i32(dst, src);
 }
 
+static bool trans_fid_f(DisasContext *ctx, arg_fid_f *a)
+{
+    nullify_over(ctx);
+#if TARGET_REGISTER_BITS == 64
+    save_frd(0, tcg_const_i64(0x13080000000000ULL)); /* PA8700 (PCX-W2) */
+#else
+    save_frd(0, tcg_const_i64(0x0f080000000000ULL)); /* PA7300LC (PCX-L2) */
+#endif
+    return nullify_end(ctx);
+}
+
 static bool trans_fcpy_f(DisasContext *ctx, arg_fclass01 *a)
 {
     return do_fop_wew(ctx, a->t, a->r, gen_fcpy_f);
Reviewed-by on v2 1/1
#1 lore raw
Quoted 15 lines · Helge Deller

The fid instruction (Floating-Point Identify) puts the FPU model and revision into the Status Register. Since those values shouldn't be 0, store values there which a PCX-L2 (for 32-bit) or a PCX-W2 (for 64-bit) would return. Noticed while trying to install MPE/iX.

---
v2: Add ULL to integer constants, enhanced commit message.

target/hppa/insns.decode +0 -0
index c7a7e997f9..3ba5f9885a 100644

target/hppa/insns.decode fmpyfadd_d 101110 rm1:5 rm2:5 ... 0 1 ..0 0 0 neg:1 t:5 ra3=%rc32 · line 392

Quoted 9 lines
target/hppa/insns.decode +2 -4
@@ -388,10 +388,8 @@ fmpyfadd_d      101110 rm1:5 rm2:5 ... 0 1 ..0 0 0 neg:1 t:5    ra3=%rc32
 
  # Floating point class 0
 
-# FID.  With r = t = 0, which via fcpy puts 0 into fr0.
-# This is machine/revision = 0, which is reserved for simulator.
-fcpy_f          001100 00000 00000 00000 000000 00000   \
-                &fclass01 r=0 t=0
+# FID.  Basically like fcpy with r = t = 0. Puts machine/revision into fr0.
+fid_f           001100 00000 00000 000 00 000000 00000

Need to remove the r = t = 0 comment, because that was for (ab)using trand_fcpy_f to store zero into f0. Now you have a proper trans_fid_f function instead.

Otherwise,

r~