Skip to contentSkip to conversation

ppc: Add support for 'mffsce' instruction

PATCH Superseded Paul A. Clarke 3 participants 4 messages Sep 16, 2019 – Sep 18, 2019

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 ppc: Add support for 'mffsce' instruction

From: "Paul A. Clarke" <[email protected]>

ISA 3.0B added a set of Floating-Point Status and Control Register (FPSCR)
instructions: mffsce, mffscdrn, mffscdrni, mffscrn, mffscrni, mffsl. This patch adds support for 'mffsce' instruction.

'mffsce' is identical to 'mffs', except that it also clears the exception enable bits in the FPSCR.

On CPUs without support for 'mffsce' (below ISA 3.0), the instruction will execute identically to 'mffs'.

---
v2: no changes.

 target/ppc/translate/fp-impl.inc.c | 30 ++++++++++++++++++++++++++++++
 target/ppc/translate/fp-ops.inc.c  |  2 ++
 2 files changed, 32 insertions(+)
target/ppc/translate/fp-impl.inc.c +30 -0
index 59a4faf..34edc45 100644
@@ -639,6 +639,36 @@ static void gen_mffsl(DisasContext *ctx)
     tcg_temp_free_i64(t0);
 }
 
+/* mffsce */
+static void gen_mffsce(DisasContext *ctx)
+{
+    TCGv_i64 t0;
+    TCGv_i32 mask;
+
+    if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) {
+        return gen_mffs(ctx);
+    }
+
+    if (unlikely(!ctx->fpu_enabled)) {
+        gen_exception(ctx, POWERPC_EXCP_FPU);
+        return;
+    }
+
+    t0 = tcg_temp_new_i64();
+
+    gen_reset_fpstatus();
+    tcg_gen_extu_tl_i64(t0, cpu_fpscr);
+    set_fpr(rD(ctx->opcode), t0);
+
+    /* Clear exception enable bits in the FPSCR.  */
+    tcg_gen_andi_i64(t0, t0, ~FP_ENABLES);
+    mask = tcg_const_i32(0x0003);
+    gen_helper_store_fpscr(cpu_env, t0, mask);
+
+    tcg_temp_free_i32(mask);
+    tcg_temp_free_i64(t0);
+}
+
 static void gen_helper_mffscrn(DisasContext *ctx, TCGv_i64 t1)
 {
     TCGv_i64 t0 = tcg_temp_new_i64();
target/ppc/translate/fp-ops.inc.c +2 -0
index f2bcf0e..88fab65 100644
@@ -105,6 +105,8 @@ GEN_HANDLER_E(fmrgew, 0x3F, 0x06, 0x1E, 0x00000001, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(fmrgow, 0x3F, 0x06, 0x1A, 0x00000001, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER(mcrfs, 0x3F, 0x00, 0x02, 0x0063F801, PPC_FLOAT),
 GEN_HANDLER_E_2(mffs, 0x3F, 0x07, 0x12, 0x00, 0x00000000, PPC_FLOAT, PPC_NONE),
+GEN_HANDLER_E_2(mffsce, 0x3F, 0x07, 0x12, 0x01, 0x00000000, PPC_FLOAT,
+    PPC2_ISA300),
 GEN_HANDLER_E_2(mffsl, 0x3F, 0x07, 0x12, 0x18, 0x00000000, PPC_FLOAT,
     PPC2_ISA300),
 GEN_HANDLER_E_2(mffscrn, 0x3F, 0x07, 0x12, 0x16, 0x00000000, PPC_FLOAT,
Signature · 1 line
1.8.3.1
Reviewed-by on v2 2/2
#1 lore raw
Quoted 12 lines · Paul A. Clarke

From: "Paul A. Clarke" <[email protected]>

ISA 3.0B added a set of Floating-Point Status and Control Register (FPSCR)
instructions: mffsce, mffscdrn, mffscdrni, mffscrn, mffscrni, mffsl. This patch adds support for 'mffsce' instruction.

'mffsce' is identical to 'mffs', except that it also clears the exception enable bits in the FPSCR.

On CPUs without support for 'mffsce' (below ISA 3.0), the instruction will execute identically to 'mffs'.

Quoted 7 lines

---
v2: no changes.

 target/ppc/translate/fp-impl.inc.c | 30 ++++++++++++++++++++++++++++++
 target/ppc/translate/fp-ops.inc.c  |  2 ++
 2 files changed, 32 insertions(+)

Didn't I already give a

for this?

r~

#2 lore raw
Quoted 17 lines · Richard Henderson
Quoted 16 lines · Paul A. Clarke

From: "Paul A. Clarke" <[email protected]>

ISA 3.0B added a set of Floating-Point Status and Control Register (FPSCR)
instructions: mffsce, mffscdrn, mffscdrni, mffscrn, mffscrni, mffsl. This patch adds support for 'mffsce' instruction.

'mffsce' is identical to 'mffs', except that it also clears the exception enable bits in the FPSCR.

On CPUs without support for 'mffsce' (below ISA 3.0), the instruction will execute identically to 'mffs'.

---
v2: no changes.

Quoted 8 lines
Quoted 3 lines
 target/ppc/translate/fp-impl.inc.c | 30 ++++++++++++++++++++++++++++++
 target/ppc/translate/fp-ops.inc.c  |  2 ++
 2 files changed, 32 insertions(+)

Didn't I already give a

for this?

You did. Sorry for the confusion. I wasn't sure whether to resend or not, given the dependence on the other patch and David said he would be waiting for the respin.

PC

#3 lore raw
Quoted 22 lines · Paul Clarke
Quoted 21 lines · Richard Henderson
Quoted 19 lines · Paul A. Clarke

From: "Paul A. Clarke" <[email protected]>

ISA 3.0B added a set of Floating-Point Status and Control Register (FPSCR)
instructions: mffsce, mffscdrn, mffscdrni, mffscrn, mffscrni, mffsl. This patch adds support for 'mffsce' instruction.

'mffsce' is identical to 'mffs', except that it also clears the exception enable bits in the FPSCR.

On CPUs without support for 'mffsce' (below ISA 3.0), the instruction will execute identically to 'mffs'.

---
v2: no changes.

 target/ppc/translate/fp-impl.inc.c | 30 ++++++++++++++++++++++++++++++
 target/ppc/translate/fp-ops.inc.c  |  2 ++
 2 files changed, 32 insertions(+)
Quoted 8 lines
Quoted 4 lines

Didn't I already give a

for this?

You did. Sorry for the confusion. I wasn't sure whether to resend or not, given the dependence on the other patch and David said he would be waiting for the respin.

Please resend for my convenience, but you can fold in the previously received R-b lines, assuming the patch isn't changing.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson