Skip to contentSkip to conversation

ppc: Add support for 'mffscrn', 'mffscrni' instructions

PATCH Superseded Paul A. Clarke 2 participants 3 messages Sep 12, 2019 – Sep 14, 2019

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ppc: Add support for 'mffscrn', 'mffscrni' instructions

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 'mffscrn' and 'mffscrni' instructions.

'mffscrn' and 'mffscrni' are similar to 'mffsl', except they do not return the status bits (FI, FR, FPRF) and they also set the rounding mode in the FPSCR.

On CPUs without support for 'mffscrn'/'mffscrni' (below ISA 3.0), the instructions will execute identically to 'mffs'.

---
v2:
- Additionally mask status bits from return value.
- Wrap a couple of too-long lines.

 target/ppc/internal.h              |  3 ++
 target/ppc/translate/fp-impl.inc.c | 67 ++++++++++++++++++++++++++++++++++++++
 target/ppc/translate/fp-ops.inc.c  |  4 +++
 3 files changed, 74 insertions(+)
target/ppc/internal.h +3 -0
index d3d327e..15d655b 100644
@@ -157,6 +157,9 @@ EXTRACT_HELPER(FPL, 25, 1);
 EXTRACT_HELPER(FPFLM, 17, 8);
 EXTRACT_HELPER(FPW, 16, 1);
 
+/* mffscrni */
+EXTRACT_HELPER(RM, 11, 2);
+
 /* addpcis */
 EXTRACT_HELPER_SPLIT_3(DX, 10, 6, 6, 5, 16, 1, 1, 0, 0)
 #if defined(TARGET_PPC64)
target/ppc/translate/fp-impl.inc.c +67 -0

73 lines not on this page · raw message

target/ppc/translate/fp-ops.inc.c +4 -0
index 88ebc25..f2bcf0e 100644
@@ -107,6 +107,10 @@ 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(mffsl, 0x3F, 0x07, 0x12, 0x18, 0x00000000, PPC_FLOAT,
     PPC2_ISA300),
+GEN_HANDLER_E_2(mffscrn, 0x3F, 0x07, 0x12, 0x16, 0x00000000, PPC_FLOAT,
+    PPC_NONE),
+GEN_HANDLER_E_2(mffscrni, 0x3F, 0x07, 0x12, 0x17, 0x00000000, PPC_FLOAT,
+    PPC_NONE),
 GEN_HANDLER(mtfsb0, 0x3F, 0x06, 0x02, 0x001FF800, PPC_FLOAT),
 GEN_HANDLER(mtfsb1, 0x3F, 0x06, 0x01, 0x001FF800, PPC_FLOAT),
 GEN_HANDLER(mtfsf, 0x3F, 0x07, 0x16, 0x00000000, PPC_FLOAT),
Signature · 1 line
1.8.3.1
#1 lore raw

target/ppc/translate/fp-impl.inc.c static void gen_mffsl(DisasContext *ctx) · line 649

Quoted 8 lines · Paul A. Clarke
target/ppc/translate/fp-impl.inc.c +8 -0
+static void gen_helper_mffscrn(DisasContext *ctx, TCGv_i64 t1)
+{
+    TCGv_i64 t0 = tcg_temp_new_i64();
+    TCGv_i32 mask = tcg_const_i32(0x0001);
+
+    gen_reset_fpstatus();
+    tcg_gen_extu_tl_i64(t0, cpu_fpscr);
+    tcg_gen_andi_i64(t0, t0, FP_MODE | FP_ENABLES);

Missing the decimal rounding mode (DRN) field at 29:31.

Otherwise,

Reviewed-by
#2 lore raw
Quoted 12 lines · Richard Henderson

target/ppc/translate/fp-impl.inc.c static void gen_mffsl(DisasContext *ctx) · line 649

Quoted 8 lines · Paul A. Clarke
target/ppc/translate/fp-impl.inc.c +8 -0
+static void gen_helper_mffscrn(DisasContext *ctx, TCGv_i64 t1)
+{
+    TCGv_i64 t0 = tcg_temp_new_i64();
+    TCGv_i32 mask = tcg_const_i32(0x0001);
+
+    gen_reset_fpstatus();
+    tcg_gen_extu_tl_i64(t0, cpu_fpscr);
+    tcg_gen_andi_i64(t0, t0, FP_MODE | FP_ENABLES);

Missing the decimal rounding mode (DRN) field at 29:31.

Quoted 1 line

Otherwise,

Dang it, <ctrl-v><ctrl-enter> in the wrong order.

r~