All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: lvivier@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org,
	groug@kaod.org, qemu-ppc@nongnu.org,
	"Paul A. Clarke" <pc@us.ibm.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PULL 39/42] ppc: Add support for 'mffsl' instruction
Date: Wed, 21 Aug 2019 17:25:39 +1000	[thread overview]
Message-ID: <20190821072542.23090-40-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20190821072542.23090-1-david@gibson.dropbear.id.au>

From: "Paul A. Clarke" <pc@us.ibm.com>

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 'mffsl'.

'mffsl' is identical to 'mffs', except it only returns mode, status, and enable
bits from the FPSCR.

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

Note: I renamed FPSCR_RN to FPSCR_RN0 so I could create an FPSCR_RN mask which
is both bits of the FPSCR rounding mode, as defined in the ISA.

I also fixed a typo in the definition of FPSCR_FR.

Signed-off-by: Paul A. Clarke <pc@us.ibm.com>

v4:
- nit: added some braces to resolve a checkpatch complaint.

v3:
- Changed tcg_gen_and_i64 to tcg_gen_andi_i64, eliminating the need for a
  temporary, per review from Richard Henderson.

v2:
- I found that I copied too much of the 'mffs' implementation.
  The 'Rc' condition code bits are not needed for 'mffsl'.  Removed.
- I now free the (renamed) 'tmask' temporary.
- I now bail early for older ISA to the original 'mffs' implementation.

Message-Id: <1565982203-11048-1-git-send-email-pc@us.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 disas/ppc.c                        |  5 +++++
 target/ppc/cpu.h                   | 15 ++++++++++-----
 target/ppc/fpu_helper.c            |  4 ++--
 target/ppc/translate/fp-impl.inc.c | 22 ++++++++++++++++++++++
 target/ppc/translate/fp-ops.inc.c  |  4 +++-
 5 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/disas/ppc.c b/disas/ppc.c
index a545437de9..63e97cfe1d 100644
--- a/disas/ppc.c
+++ b/disas/ppc.c
@@ -1765,6 +1765,9 @@ extract_tbr (unsigned long insn,
 /* An X_MASK with the RA and RB fields fixed.  */
 #define XRARB_MASK (X_MASK | RA_MASK | RB_MASK)
 
+/* An X form instruction with the RA field fixed.  */
+#define XRA(op, xop, ra) (X((op), (xop)) | (((ra) << 16) & XRA_MASK))
+
 /* An XRARB_MASK, but with the L bit clear.  */
 #define XRLARB_MASK (XRARB_MASK & ~((unsigned long) 1 << 16))
 
@@ -4998,6 +5001,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 { "ddivq",   XRC(63,546,0), X_MASK,	POWER6,		{ FRT, FRA, FRB } },
 { "ddivq.",  XRC(63,546,1), X_MASK,	POWER6,		{ FRT, FRA, FRB } },
 
+{ "mffsl",   XRA(63,583,12), XRARB_MASK,	POWER9,	{ FRT } },
+
 { "mffs",    XRC(63,583,0), XRARB_MASK,	COM,		{ FRT } },
 { "mffs.",   XRC(63,583,1), XRARB_MASK,	COM,		{ FRT } },
 
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 4b35c8e4f4..eaee1a5575 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -591,7 +591,7 @@ enum {
 #define FPSCR_XE     3  /* Floating-point inexact exception enable           */
 #define FPSCR_NI     2  /* Floating-point non-IEEE mode                      */
 #define FPSCR_RN1    1
-#define FPSCR_RN     0  /* Floating-point rounding control                   */
+#define FPSCR_RN0    0  /* Floating-point rounding control                   */
 #define fpscr_fex    (((env->fpscr) >> FPSCR_FEX)    & 0x1)
 #define fpscr_vx     (((env->fpscr) >> FPSCR_VX)     & 0x1)
 #define fpscr_ox     (((env->fpscr) >> FPSCR_OX)     & 0x1)
@@ -614,7 +614,7 @@ enum {
 #define fpscr_ze     (((env->fpscr) >> FPSCR_ZE)     & 0x1)
 #define fpscr_xe     (((env->fpscr) >> FPSCR_XE)     & 0x1)
 #define fpscr_ni     (((env->fpscr) >> FPSCR_NI)     & 0x1)
-#define fpscr_rn     (((env->fpscr) >> FPSCR_RN)     & 0x3)
+#define fpscr_rn     (((env->fpscr) >> FPSCR_RN0)    & 0x3)
 /* Invalid operation exception summary */
 #define fpscr_ix ((env->fpscr) & ((1 << FPSCR_VXSNAN) | (1 << FPSCR_VXISI)  | \
                                   (1 << FPSCR_VXIDI)  | (1 << FPSCR_VXZDZ)  | \
@@ -640,7 +640,7 @@ enum {
 #define FP_VXZDZ        (1ull << FPSCR_VXZDZ)
 #define FP_VXIMZ        (1ull << FPSCR_VXIMZ)
 #define FP_VXVC         (1ull << FPSCR_VXVC)
-#define FP_FR           (1ull << FSPCR_FR)
+#define FP_FR           (1ull << FPSCR_FR)
 #define FP_FI           (1ull << FPSCR_FI)
 #define FP_C            (1ull << FPSCR_C)
 #define FP_FL           (1ull << FPSCR_FL)
@@ -648,7 +648,7 @@ enum {
 #define FP_FE           (1ull << FPSCR_FE)
 #define FP_FU           (1ull << FPSCR_FU)
 #define FP_FPCC         (FP_FL | FP_FG | FP_FE | FP_FU)
-#define FP_FPRF         (FP_C  | FP_FL | FP_FG | FP_FE | FP_FU)
+#define FP_FPRF         (FP_C | FP_FPCC)
 #define FP_VXSOFT       (1ull << FPSCR_VXSOFT)
 #define FP_VXSQRT       (1ull << FPSCR_VXSQRT)
 #define FP_VXCVI        (1ull << FPSCR_VXCVI)
@@ -659,7 +659,12 @@ enum {
 #define FP_XE           (1ull << FPSCR_XE)
 #define FP_NI           (1ull << FPSCR_NI)
 #define FP_RN1          (1ull << FPSCR_RN1)
-#define FP_RN           (1ull << FPSCR_RN)
+#define FP_RN0          (1ull << FPSCR_RN0)
+#define FP_RN           (FP_RN1 | FP_RN0)
+
+#define FP_MODE         FP_RN
+#define FP_ENABLES      (FP_VE | FP_OE | FP_UE | FP_ZE | FP_XE)
+#define FP_STATUS       (FP_FR | FP_FI | FP_FPRF)
 
 /* the exception bits which can be cleared by mcrfs - includes FX */
 #define FP_EX_CLEAR_BITS (FP_FX     | FP_OX     | FP_UX     | FP_ZX     | \
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index f437c88aad..5611cf0156 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -403,7 +403,7 @@ void helper_fpscr_clrbit(CPUPPCState *env, uint32_t bit)
     if (prev == 1) {
         switch (bit) {
         case FPSCR_RN1:
-        case FPSCR_RN:
+        case FPSCR_RN0:
             fpscr_set_rounding_mode(env);
             break;
         case FPSCR_VXSNAN:
@@ -557,7 +557,7 @@ void helper_fpscr_setbit(CPUPPCState *env, uint32_t bit)
             }
             break;
         case FPSCR_RN1:
-        case FPSCR_RN:
+        case FPSCR_RN0:
             fpscr_set_rounding_mode(env);
             break;
         default:
diff --git a/target/ppc/translate/fp-impl.inc.c b/target/ppc/translate/fp-impl.inc.c
index 9dcff947c0..7cd9d8db05 100644
--- a/target/ppc/translate/fp-impl.inc.c
+++ b/target/ppc/translate/fp-impl.inc.c
@@ -617,6 +617,28 @@ static void gen_mffs(DisasContext *ctx)
     tcg_temp_free_i64(t0);
 }
 
+/* mffsl */
+static void gen_mffsl(DisasContext *ctx)
+{
+    TCGv_i64 t0;
+
+    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);
+    /* Mask everything except mode, status, and enables.  */
+    tcg_gen_andi_i64(t0, t0, FP_MODE | FP_STATUS | FP_ENABLES);
+    set_fpr(rD(ctx->opcode), t0);
+    tcg_temp_free_i64(t0);
+}
+
 /* mtfsb0 */
 static void gen_mtfsb0(DisasContext *ctx)
 {
diff --git a/target/ppc/translate/fp-ops.inc.c b/target/ppc/translate/fp-ops.inc.c
index 621f6bfe0c..88ebc2526c 100644
--- a/target/ppc/translate/fp-ops.inc.c
+++ b/target/ppc/translate/fp-ops.inc.c
@@ -104,7 +104,9 @@ GEN_HANDLER_E(fcpsgn, 0x3F, 0x08, 0x00, 0x00000000, PPC_NONE, PPC2_ISA205),
 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(mffs, 0x3F, 0x07, 0x12, 0x001FF800, 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(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),
-- 
2.21.0



  parent reply	other threads:[~2019-08-21  8:08 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21  7:25 [Qemu-devel] [PULL 00/42] ppc-for-4.2 queue 20190821 David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 01/42] spapr: quantify error messages regarding capability settings David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 02/42] spapr_iommu: Fix xlate trace to print translated address David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 03/42] hw: add compat machines for 4.2 David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 04/42] spapr_pci: Allow 2MiB and 16MiB IOMMU pagesizes by default David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 05/42] migration: Do not re-read the clock on pre_save in case of paused guest David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 06/42] target/ppc: Optimize emulation of lvsl and lvsr instructions David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 07/42] target/ppc: Optimize emulation of vsl and vsr instructions David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 08/42] target/ppc: move opcode decode tables to PowerPCCPU David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 09/42] target/ppc: Optimize emulation of vgbbd instruction David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 10/42] target/ppc: Optimize emulation of vclzd instruction David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 11/42] target/ppc: Optimize emulation of vclzw instruction David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 12/42] ppc: fix memory leak in spapr_caps_add_properties David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 13/42] ppc: fix memory leak in spapr_dt_drc() David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 14/42] ppc: fix leak in h_client_architecture_support David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 15/42] spapr: Implement dispatch tracking for tcg David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 16/42] spapr: Implement H_PROD David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 17/42] spapr: Implement H_CONFER David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 18/42] spapr: Implement H_JOIN David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 19/42] docs/specs: initial spec summary for Ultravisor-related hcalls David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 20/42] spapr: initial implementation for H_TPM_COMM/spapr-tpm-proxy David Gibson
2019-09-09 17:23   ` Peter Maydell
2019-09-09 17:51     ` Greg Kurz
2019-08-21  7:25 ` [Qemu-devel] [PULL 21/42] pseries: Update SLOF firmware image David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 22/42] ppc/xive: use an abstract type for XiveNotifier David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 23/42] ppc/xive: Implement TM_PULL_OS_CTX special command David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 24/42] ppc/xive: Provide backlog support David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 25/42] ppc/xive: Provide escalation support David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 26/42] ppc/xive: Provide unconditional " David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 27/42] ppc/xive: Provide silent " David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 28/42] ppc/xive: Improve 'info pic' support David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 29/42] machine: Add wakeup method to MachineClass David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 30/42] i386: use machine class ->wakeup method David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 31/42] spapr: Implement ibm,suspend-me David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 32/42] ppc: remove idle_timer logic David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 33/42] spapr/pci: Consolidate de-allocation of MSIs David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 34/42] spapr/pci: Free MSIs during reset David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 35/42] spapr/irq: Drop spapr_irq_msi_reset() David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 36/42] spapr: Implement better workaround in spapr-vty device David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 37/42] spapr/xive: Mask the EAS when allocating an IRQ David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 38/42] target/ppc: Add Directed Privileged Door-bell Exception State (DPDES) SPR David Gibson
2019-08-21  7:25 ` David Gibson [this message]
2019-08-21  7:25 ` [Qemu-devel] [PULL 40/42] ppc: conform to processor User's Manual for xscvdpspn David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 41/42] ppc: Fix emulated INFINITY and NAN conversions David Gibson
2019-08-21  7:25 ` [Qemu-devel] [PULL 42/42] ppc: Fix emulated single to double denormalized conversions David Gibson
2019-08-21  8:25 ` [Qemu-devel] [PULL 00/42] ppc-for-4.2 queue 20190821 no-reply
2019-08-21 14:18 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190821072542.23090-40-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=aik@ozlabs.ru \
    --cc=groug@kaod.org \
    --cc=lvivier@redhat.com \
    --cc=pc@us.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.