qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, "Michael Matz" <matz@suse.de>,
	"C Fontana" <claudio.fontana@linaro.org>,
	"Dirk Mueller" <dmueller@suse.de>,
	"Laurent Desnogues" <laurent.desnogues@gmail.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	kvmarm@lists.cs.columbia.edu,
	"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v3 03/12] target-arm: A64: provide functions for accessing FPCR and FPSR
Date: Thu,  5 Dec 2013 12:39:31 +0000	[thread overview]
Message-ID: <1386247180-26994-4-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1386247180-26994-1-git-send-email-peter.maydell@linaro.org>

The information which AArch32 holds in the FPSCR is split for
AArch64 into two logically distinct registers, FPSR and FPCR.
Since they are carefully arranged to use non-overlapping bits,
we leave the underlying state in the same place, and provide
accessor functions which just update the appropriate bits
via vfp_get_fpscr() and vfp_set_fpscr().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
 target-arm/cpu.h |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index ff7aac5..4807354 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -445,6 +445,34 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
 uint32_t vfp_get_fpscr(CPUARMState *env);
 void vfp_set_fpscr(CPUARMState *env, uint32_t val);
 
+/* For A64 the FPSCR is split into two logically distinct registers,
+ * FPCR and FPSR. However since they still use non-overlapping bits
+ * we store the underlying state in fpscr and just mask on read/write.
+ */
+#define FPSR_MASK 0xf800009f
+#define FPCR_MASK 0x07f79f00
+static inline uint32_t vfp_get_fpsr(CPUARMState *env)
+{
+    return vfp_get_fpscr(env) & FPSR_MASK;
+}
+
+static inline void vfp_set_fpsr(CPUARMState *env, uint32_t val)
+{
+    uint32_t new_fpscr = (vfp_get_fpscr(env) & ~FPSR_MASK) | (val & FPSR_MASK);
+    vfp_set_fpscr(env, new_fpscr);
+}
+
+static inline uint32_t vfp_get_fpcr(CPUARMState *env)
+{
+    return vfp_get_fpscr(env) & FPCR_MASK;
+}
+
+static inline void vfp_set_fpcr(CPUARMState *env, uint32_t val)
+{
+    uint32_t new_fpscr = (vfp_get_fpscr(env) & ~FPCR_MASK) | (val & FPCR_MASK);
+    vfp_set_fpscr(env, new_fpscr);
+}
+
 enum arm_cpu_mode {
   ARM_CPU_MODE_USR = 0x10,
   ARM_CPU_MODE_FIQ = 0x11,
-- 
1.7.9.5

  parent reply	other threads:[~2013-12-05 12:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 12:39 [Qemu-devel] [PATCH v3 00/12] target-arm: A64 decoder, foundation plus branches Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 01/12] target-arm: Split A64 from A32/T32 gen_intermediate_code_internal() Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 02/12] target-arm: A64: add set_pc cpu method Peter Maydell
2013-12-05 12:39 ` Peter Maydell [this message]
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 04/12] target-arm: Support fp registers in gdb stub Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 05/12] target-arm: A64: add stubs for a64 specific helpers Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 06/12] target-arm: A64: provide skeleton for a64 insn decoding Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 07/12] target-arm: A64: expand decoding skeleton for system instructions Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 08/12] target-arm: A64: add support for B and BL insns Peter Maydell
2013-12-05 19:34   ` Richard Henderson
2013-12-09 13:49   ` Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 09/12] target-arm: A64: add support for BR, BLR and RET insns Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 10/12] target-arm: A64: add support for conditional branches Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 11/12] target-arm: A64: add support for 'test and branch' imm Peter Maydell
2013-12-05 12:39 ` [Qemu-devel] [PATCH v3 12/12] target-arm: A64: add support for compare and branch imm Peter Maydell
2013-12-05 19:37   ` Richard Henderson
2013-12-17 14:45 ` [Qemu-devel] [PATCH v3 00/12] target-arm: A64 decoder, foundation plus branches 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=1386247180-26994-4-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=claudio.fontana@linaro.org \
    --cc=dmueller@suse.de \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=laurent.desnogues@gmail.com \
    --cc=matz@suse.de \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).