qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Peter Maydell <peter.maydell@linaro.org>, 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>
Subject: Re: [Qemu-devel] [PATCH 2/9] target-arm: A64: add support for ldp (load pair)
Date: Mon, 09 Dec 2013 12:25:02 -0800	[thread overview]
Message-ID: <52A6271E.6050704@twiddle.net> (raw)
In-Reply-To: <1386612744-1013-3-git-send-email-peter.maydell@linaro.org>

On 12/09/2013 10:12 AM, Peter Maydell wrote:
> +static void do_gpr_ld(DisasContext *s, TCGv_i64 dest, TCGv_i64 tcg_addr,
> +                      int size, bool is_signed, bool extend)
> +{
> +    switch (size) {
> +    case 0:
> +        if (is_signed) {
> +            tcg_gen_qemu_ld8s(dest, tcg_addr, get_mem_index(s));
> +        } else {
> +            tcg_gen_qemu_ld8u(dest, tcg_addr, get_mem_index(s));
> +        }
> +        break;
> +    case 1:
> +        if (is_signed) {
> +            tcg_gen_qemu_ld16s(dest, tcg_addr, get_mem_index(s));
> +        } else {
> +            tcg_gen_qemu_ld16u(dest, tcg_addr, get_mem_index(s));
> +        }
> +        break;
> +    case 2:
> +        if (is_signed) {
> +            tcg_gen_qemu_ld32s(dest, tcg_addr, get_mem_index(s));
> +        } else {
> +            tcg_gen_qemu_ld32u(dest, tcg_addr, get_mem_index(s));
> +        }
> +        break;
> +    case 3:
> +        tcg_gen_qemu_ld64(dest, tcg_addr, get_mem_index(s));
> +        break;

Likewise, combine all of this with tcg_gen_qemu_ld_i64.

> +    if (extend && is_signed) {
> +        g_assert(size < 3);
> +        tcg_gen_ext32u_i64(dest, dest);
> +    }

Is it worth noticing in size==2 && !extend that is_signed can be forced false
to avoid the extra extension.

> +static void handle_ldp(DisasContext *s, uint32_t insn)
> +{
> +    int rt = extract32(insn, 0, 5);
> +    int rn = extract32(insn, 5, 5);
> +    int rt2 = extract32(insn, 10, 5);
> +    int64_t offset = sextract32(insn, 15, 7);
> +    int idx = extract32(insn, 23, 3);
> +    bool is_signed = false;
> +    bool is_vector = extract32(insn, 26, 1);
> +    int opc = extract32(insn, 30, 2);
> +    int size;
> +    bool postindex = true;
> +    bool wback = false;
> +
> +    TCGv_i64 tcg_rt = cpu_reg(s, rt);
> +    TCGv_i64 tcg_rt2 = cpu_reg(s, rt2);
> +    TCGv_i64 tcg_addr;
> +
> +    if (opc == 3) {
> +        unallocated_encoding(s);
> +        return;
> +    }
> +    if (is_vector) {
> +        size = 2 + opc;
> +    } else {
> +        is_signed = opc & 1;
> +        size = 2 + extract32(opc, 1, 1);
> +    }
> +
> +    switch (idx) {
> +    case 1: /* post-index */
> +        postindex = true;
> +        wback = true;
> +        break;
> +    case 2: /* signed offset, rn not updated */
> +        postindex = false;
> +        break;
> +    case 3: /* STP (pre-index) */
> +        postindex = false;
> +        wback = true;
> +        break;
> +    default: /* Failed decoder tree? */
> +        unallocated_encoding(s);
> +        break;
> +    }
> +
> +    offset <<= size;
> +
> +    if (rn == 31) {
> +        gen_check_sp_alignment(s);
> +    }
> +
> +    tcg_addr = tcg_temp_new_i64();
> +    tcg_gen_mov_i64(tcg_addr, cpu_reg_sp(s, rn));
> +
> +    if (!postindex) {
> +        tcg_gen_addi_i64(tcg_addr, tcg_addr, offset);
> +    }
> +
> +    if (is_vector) {
> +        do_fp_ld(s, rt, tcg_addr, size);
> +    } else {
> +        do_gpr_ld(s, tcg_rt, tcg_addr, size, is_signed, false);
> +    }
> +    tcg_gen_addi_i64(tcg_addr, tcg_addr, 1 << size);
> +    if (is_vector) {
> +        do_fp_ld(s, rt2, tcg_addr, size);
> +    } else {
> +        do_gpr_ld(s, tcg_rt2, tcg_addr, size, is_signed, false);
> +    }
> +
> +    if (wback) {
> +        if (postindex) {
> +            tcg_gen_addi_i64(tcg_addr, tcg_addr, offset - (1 << size));
> +        } else {
> +            tcg_gen_subi_i64(tcg_addr, tcg_addr, 1 << size);
> +        }
> +        tcg_gen_mov_i64(cpu_reg_sp(s, rn), tcg_addr);
> +    }
> +    tcg_temp_free_i64(tcg_addr);
> +}

There's so much overlap with STP, I think these ought not be separate
functions.  Just merge the middle bit where the actual load/store happens.


r~

  reply	other threads:[~2013-12-09 20:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 18:12 [Qemu-devel] [PATCH 0/9] target-arm: A64 decoder set 3: loads, stores, misc integer Peter Maydell
2013-12-09 18:12 ` [Qemu-devel] [PATCH 1/9] target-arm: A64: add support for stp (store pair) Peter Maydell
2013-12-09 20:17   ` Richard Henderson
2013-12-10 14:05     ` Alex Bennée
2013-12-09 18:12 ` [Qemu-devel] [PATCH 2/9] target-arm: A64: add support for ldp (load pair) Peter Maydell
2013-12-09 20:25   ` Richard Henderson [this message]
2013-12-10 13:59     ` Alex Bennée
2013-12-10 16:58       ` Richard Henderson
2013-12-10 17:41         ` Alex Bennée
2013-12-09 18:12 ` [Qemu-devel] [PATCH 3/9] target-arm: A64: add support for ld/st unsigned imm Peter Maydell
2013-12-09 21:02   ` Richard Henderson
2013-12-10 14:09     ` Alex Bennée
2013-12-09 18:12 ` [Qemu-devel] [PATCH 4/9] target-arm: A64: add support for ld/st with reg offset Peter Maydell
2013-12-09 21:09   ` Richard Henderson
2013-12-10 14:16     ` Alex Bennée
2013-12-10 15:59       ` Richard Henderson
2013-12-11 22:01         ` Alex Bennée
2013-12-09 18:12 ` [Qemu-devel] [PATCH 5/9] target-arm: A64: add support for ld/st with index Peter Maydell
2013-12-09 18:12 ` [Qemu-devel] [PATCH 6/9] target-arm: A64: add support for add, addi, sub, subi Peter Maydell
2013-12-09 21:36   ` Richard Henderson
2013-12-09 18:12 ` [Qemu-devel] [PATCH 7/9] target-arm: A64: add support for move wide instructions Peter Maydell
2013-12-09 21:42   ` Richard Henderson
2013-12-09 18:12 ` [Qemu-devel] [PATCH 8/9] target-arm: A64: add support for 3 src data proc insns Peter Maydell
2013-12-09 21:52   ` Richard Henderson
2013-12-09 18:12 ` [Qemu-devel] [PATCH 9/9] target-arm: A64: implement SVC, BRK Peter Maydell
2013-12-09 21:58   ` Richard Henderson
2013-12-09 22:14     ` Peter Maydell
2013-12-09 18:16 ` [Qemu-devel] [PATCH 0/9] target-arm: A64 decoder set 3: loads, stores, misc integer 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=52A6271E.6050704@twiddle.net \
    --to=rth@twiddle.net \
    --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=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --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).