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>,
	"Claudio Fontana" <claudio.fontana@linaro.org>,
	"Dirk Mueller" <dmueller@suse.de>,
	"Will Newton" <will.newton@linaro.org>,
	"Laurent Desnogues" <laurent.desnogues@gmail.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	kvmarm@lists.cs.columbia.edu,
	"Christoffer Dall" <christoffer.dall@linaro.org>,
	"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH 03/21] target-arm: A64: add support for ld/st with reg offset
Date: Tue, 17 Dec 2013 15:12:06 +0000	[thread overview]
Message-ID: <1387293144-11554-4-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1387293144-11554-1-git-send-email-peter.maydell@linaro.org>

From: Alex Bennée <alex@bennee.com>

This adds support for the load/store forms using a register offset.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-arm/translate-a64.c | 144 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 143 insertions(+), 1 deletion(-)

diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
index 3712a6d..742c714 100644
--- a/target-arm/translate-a64.c
+++ b/target-arm/translate-a64.c
@@ -402,6 +402,54 @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size)
     tcg_temp_free_i64(tmphi);
 }
 
+/*
+ * This utility function is for doing register extension with an
+ * optional shift. You will likely want to pass a temporary for the
+ * destination register. See DecodeRegExtend() in the ARM ARM.
+ */
+static void ext_and_shift_reg(TCGv_i64 tcg_out, TCGv_i64 tcg_in,
+                              int option, unsigned int shift)
+{
+    int extsize = extract32(option, 0, 2);
+    bool is_signed = extract32(option, 2, 1);
+
+    if (is_signed) {
+        switch (extsize) {
+        case 0:
+            tcg_gen_ext8s_i64(tcg_out, tcg_in);
+            break;
+        case 1:
+            tcg_gen_ext16s_i64(tcg_out, tcg_in);
+            break;
+        case 2:
+            tcg_gen_ext32s_i64(tcg_out, tcg_in);
+            break;
+        case 3:
+            tcg_gen_mov_i64(tcg_out, tcg_in);
+            break;
+        }
+    } else {
+        switch (extsize) {
+        case 0:
+            tcg_gen_ext8u_i64(tcg_out, tcg_in);
+            break;
+        case 1:
+            tcg_gen_ext16u_i64(tcg_out, tcg_in);
+            break;
+        case 2:
+            tcg_gen_ext32u_i64(tcg_out, tcg_in);
+            break;
+        case 3:
+            tcg_gen_mov_i64(tcg_out, tcg_in);
+            break;
+        }
+    }
+
+    if (shift) {
+        tcg_gen_shli_i64(tcg_out, tcg_out, shift);
+    }
+}
+
 static inline void gen_check_sp_alignment(DisasContext *s)
 {
     /* The AArch64 architecture mandates that (if enabled via PSTATE
@@ -900,6 +948,96 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn)
 }
 
 /*
+ * C3.3.10 Load/store (register offset)
+ *
+ * 31 30 29   27  26 25 24 23 22 21  20  16 15 13 12 11 10 9  5 4  0
+ * +----+-------+---+-----+-----+---+------+-----+--+-----+----+----+
+ * |size| 1 1 1 | V | 0 0 | opc | 1 |  Rm  | opt | S| 1 0 | Rn | Rt |
+ * +----+-------+---+-----+-----+---+------+-----+--+-----+----+----+
+ *
+ * For non-vector:
+ *   size: 00-> byte, 01 -> 16 bit, 10 -> 32bit, 11 -> 64bit
+ *   opc: 00 -> store, 01 -> loadu, 10 -> loads 64, 11 -> loads 32
+ * For vector:
+ *   size is opc<1>:size<1:0> so 100 -> 128 bit; 110 and 111 unallocated
+ *   opc<0>: 0 -> store, 1 -> load
+ * V: 1 -> vector/simd
+ * opt: extend encoding (see DecodeRegExtend)
+ * S: if S=1 then scale (essentially index by sizeof(size))
+ * Rt: register to transfer into/out of
+ * Rn: address register or SP for base
+ * Rm: offset register or ZR for offset
+ */
+static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn)
+{
+    int rt = extract32(insn, 0, 5);
+    int rn = extract32(insn, 5, 5);
+    int shift = extract32(insn, 12, 1);
+    int rm = extract32(insn, 16, 5);
+    int opc = extract32(insn, 22, 2);
+    int opt = extract32(insn, 13, 3);
+    int size = extract32(insn, 30, 2);
+    bool is_signed = false;
+    bool is_store = false;
+    bool is_extended = false;
+    bool is_vector = extract32(insn, 26, 1);
+
+    TCGv_i64 tcg_rm;
+    TCGv_i64 tcg_addr;
+
+    if (extract32(opt, 1, 1) == 0) {
+        unallocated_encoding(s);
+        return;
+    }
+
+    if (is_vector) {
+        size |= (opc & 2) << 1;
+        if (size > 4) {
+            unallocated_encoding(s);
+            return;
+        }
+        is_store = ((opc & 1) == 0);
+    } else {
+        if (size == 3 && opc == 2) {
+            /* PRFM - prefetch */
+            return;
+        }
+        if (opc == 3 && size > 1) {
+            unallocated_encoding(s);
+            return;
+        }
+        is_store = (opc == 0);
+        is_signed = opc & (1<<1);
+        is_extended = (size < 3) && (opc & 1);
+    }
+
+    if (rn == 31) {
+        gen_check_sp_alignment(s);
+    }
+    tcg_addr = read_cpu_reg_sp(s, rn, 1);
+
+    tcg_rm = read_cpu_reg(s, rm, 1);
+    ext_and_shift_reg(tcg_rm, tcg_rm, opt, shift ? size : 0);
+
+    tcg_gen_add_i64(tcg_addr, tcg_addr, tcg_rm);
+
+    if (is_vector) {
+        if (is_store) {
+            do_fp_st(s, rt, tcg_addr, size);
+        } else {
+            do_fp_ld(s, rt, tcg_addr, size);
+        }
+    } else {
+        TCGv_i64 tcg_rt = cpu_reg(s, rt);
+        if (is_store) {
+            do_gpr_st(s, tcg_rt, tcg_addr, size);
+        } else {
+            do_gpr_ld(s, tcg_rt, tcg_addr, size, is_signed, is_extended);
+        }
+    }
+}
+
+/*
  * C3.3.13 Load/store (unsigned immediate)
  *
  * 31 30 29   27  26 25 24 23 22 21        10 9     5
@@ -981,7 +1119,11 @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn)
 {
     switch (extract32(insn, 24, 2)) {
     case 0:
-        unsupported_encoding(s, insn);
+        if (extract32(insn, 21, 1) == 1 && extract32(insn, 10, 2) == 2) {
+            disas_ldst_reg_roffset(s, insn);
+        } else {
+            unsupported_encoding(s, insn);
+        }
         break;
     case 1:
         disas_ldst_reg_unsigned_imm(s, insn);
-- 
1.8.5

  parent reply	other threads:[~2013-12-17 15:27 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-17 15:12 [Qemu-devel] [PATCH 00/21] target-arm: A64 decoder sets 3 and 4: everything but fp & simd Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 01/21] target-arm: A64: add support for ld/st pair Peter Maydell
2013-12-19 16:58   ` Richard Henderson
2013-12-19 17:25     ` Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 02/21] target-arm: A64: add support for ld/st unsigned imm Peter Maydell
2013-12-19 17:46   ` Richard Henderson
2013-12-20 16:08     ` Peter Maydell
2013-12-20 16:26       ` Richard Henderson
2013-12-20 16:29         ` Peter Maydell
2013-12-20 16:44           ` Richard Henderson
2013-12-20 16:52             ` Peter Maydell
2013-12-20 16:57               ` Richard Henderson
2013-12-20 17:16                 ` Peter Maydell
2013-12-17 15:12 ` Peter Maydell [this message]
2013-12-17 15:12 ` [Qemu-devel] [PATCH 04/21] target-arm: A64: add support for ld/st with index Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 05/21] target-arm: A64: add support for add, addi, sub, subi Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 06/21] target-arm: A64: add support for move wide instructions Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 07/21] target-arm: A64: add support for 3 src data proc insns Peter Maydell
2013-12-19 19:29   ` Richard Henderson
2013-12-20 13:18     ` Peter Maydell
2013-12-20 14:10       ` Richard Henderson
2013-12-20 14:19         ` Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 08/21] target-arm: A64: implement SVC, BRK Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 09/21] target-arm: A64: Add decoder skeleton for FP instructions Peter Maydell
2013-12-19 20:00   ` Richard Henderson
2013-12-17 15:12 ` [Qemu-devel] [PATCH 10/21] target-arm: A64: implement FMOV Peter Maydell
2013-12-19 20:18   ` Richard Henderson
2013-12-17 15:12 ` [Qemu-devel] [PATCH 11/21] target-arm: Update generic cpreg code for AArch64 Peter Maydell
2013-12-19  6:01   ` Peter Crosthwaite
2013-12-19  9:11     ` Peter Maydell
2013-12-20  4:24       ` Peter Crosthwaite
2013-12-20 10:00         ` Peter Maydell
2013-12-20 18:16           ` Peter Maydell
2013-12-20 21:41             ` Peter Crosthwaite
2013-12-20 22:07               ` Peter Maydell
2013-12-20 22:16                 ` Peter Maydell
2013-12-22 19:50                   ` Peter Maydell
2013-12-20 22:29                 ` Peter Crosthwaite
2013-12-20 23:04                   ` Peter Maydell
2013-12-20 17:41         ` Peter Maydell
2013-12-20  4:25   ` Peter Crosthwaite
2013-12-20 16:43   ` Peter Maydell
2013-12-20 18:53     ` Christoffer Dall
2013-12-17 15:12 ` [Qemu-devel] [PATCH 12/21] target-arm: Remove ARMCPU/CPUARMState from cpregs APIs used by decoder Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 13/21] target-arm: A64: Implement MRS/MSR/SYS/SYSL Peter Maydell
2013-12-19 20:30   ` Richard Henderson
2013-12-20 13:27     ` Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 14/21] target-arm: A64: Implement minimal set of EL0-visible sysregs Peter Maydell
2013-12-19 20:35   ` Richard Henderson
2013-12-21 22:56   ` Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 15/21] target-arm: Widen thread-local register state fields to 64 bits Peter Maydell
2013-12-19 20:53   ` Richard Henderson
2013-12-19 21:04     ` Peter Maydell
2013-12-19 21:09       ` Richard Henderson
2013-12-17 15:12 ` [Qemu-devel] [PATCH 16/21] target-arm: A64: add support for add/sub with carry Peter Maydell
2013-12-19 20:57   ` Richard Henderson
2013-12-17 15:12 ` [Qemu-devel] [PATCH 17/21] target-arm: A64: add support for conditional compare insns Peter Maydell
2013-12-19 21:04   ` Richard Henderson
2013-12-19 21:23     ` Peter Maydell
2013-12-19 21:26       ` Richard Henderson
2013-12-19 21:31         ` Peter Maydell
2013-12-20 16:19     ` Peter Maydell
2013-12-20 16:22       ` Richard Henderson
2013-12-17 15:12 ` [Qemu-devel] [PATCH 18/21] target-arm: aarch64: add support for ld lit Peter Maydell
2013-12-19 21:07   ` Richard Henderson
2013-12-17 15:12 ` [Qemu-devel] [PATCH 19/21] target-arm: Widen exclusive-access support struct fields to 64 bits Peter Maydell
2013-12-17 15:12 ` [Qemu-devel] [PATCH 20/21] target-arm: A64: support for ld/st/cl exclusive Peter Maydell
2013-12-19 21:15   ` Richard Henderson
2013-12-17 15:12 ` [Qemu-devel] [PATCH 21/21] default-configs: Add config for aarch64-linux-user Peter Maydell
2013-12-19 21:15   ` Richard Henderson

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=1387293144-11554-4-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=christoffer.dall@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 \
    --cc=will.newton@linaro.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 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).