From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <rth@twiddle.net>
Cc: Peter Maydell <peter.maydell@linaro.org>,
patches@linaro.org, Michael Matz <matz@suse.de>,
qemu-devel@nongnu.org,
Claudio Fontana <claudio.fontana@linaro.org>,
Dirk Mueller <dmueller@suse.de>,
Will Newton <will.newton@linaro.org>,
Laurent Desnogues <laurent.desnogues@gmail.com>,
kvmarm@lists.cs.columbia.edu,
Christoffer Dall <christoffer.dall@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 4/9] target-arm: A64: add support for ld/st with reg offset
Date: Tue, 10 Dec 2013 14:16:10 +0000 [thread overview]
Message-ID: <87siu06bbp.fsf@linaro.org> (raw)
In-Reply-To: <52A6318B.4070609@twiddle.net>
rth@twiddle.net writes:
> On 12/09/2013 10:12 AM, Peter Maydell wrote:
>> From: Alex Bennée <alex.bennee@linaro.org>
>>
>> This adds support for the load/store forms using a register offset.
>>
<snip>
>> +/*
>> + * 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 handle_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);
>> + }
>> + is_store = ((opc & 1) == 0);
>> + } else {
>> + if (size == 3 && opc == 2) {
>> + /* PRFM - prefetch */
>> + 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);
>> + }
>> + }
>> +}
>
> I wonder if it would be better to merge this function with the one from the
> previous patch. There are only 3-4 lines that are different.
I was trying to avoid having it jump through special cases when decoding
the instruction where Rm, opt, S class with the imm field in the other
form. But certainly there is an argument for the rest of the common code
to be shared (size/opc decoding and final tcg_addr based load/store).
However my preference unless there is a strong objection would be to
clean that up in later patches. For one thing the more instructions each
patch handles the longer it takes to run the instruction validation on
the rather slow models to have good coverage of the decoder!
>
>
> r~
--
Alex Bennée
QEMU/KVM Hacker for Linaro
next prev parent reply other threads:[~2013-12-10 14:16 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
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 [this message]
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=87siu06bbp.fsf@linaro.org \
--to=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=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).