From: Claudio Fontana <claudio.fontana@huawei.com>
To: Richard Henderson <rth@twiddle.net>
Cc: Laurent Desnogues <laurent.desnogues@gmail.com>,
Peter Maydell <peter.maydell@linaro.org>,
Jani Kokkonen <Jani.Kokkonen@huawei.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v3 2/3] tcg/aarch64: implement new TCG target for aarch64
Date: Wed, 29 May 2013 09:44:48 +0200 [thread overview]
Message-ID: <51A5B1F0.2050305@huawei.com> (raw)
In-Reply-To: <51A4D8CB.8060904@twiddle.net>
On 28.05.2013 18:18, Richard Henderson wrote:
> On 05/28/2013 08:28 AM, Claudio Fontana wrote:
>> +static inline void tcg_out_movi_aux(TCGContext *s,
>> + TCGReg rd, uint64_t value)
>> +{
>> + uint32_t half, base, movk = 0, shift = 0;
>> +
>> + /* construct halfwords of the immediate with MOVZ/MOVK with LSL */
>> + /* using MOVZ 0x52800000 | extended reg.. */
>> + base = (value > 0xffffffff) ? 0xd2800000 : 0x52800000;
>> +
>> + do {
>> + int skip_zeros = ctz64(value) & (63 & -16);
>> + value >>= skip_zeros;
>> + shift += skip_zeros << 17;
>> + half = value & 0xffff;
>> + tcg_out32(s, base | movk | shift | half << 5 | rd);
>> + movk = 0x20000000; /* morph next MOVZs into MOVKs */
>> + value >>= 16;
>> + shift += 16 << 17;
>
> This is way more confusing than it needs to be. I don't think you
> should modify VALUE by shifting at all. If you don't do that then
> you don't need to make SHIFT loop carried, since we compute its
> exact correct value every time with the ctz.
>
> Was the only bug in the code that I pasted the lack of the shift-by-17
> when encoding SHIFT into the tcg_out32?
yes, you only forgot to encode the shift in the tcg_out32,
the variation above was an attempt to make it easier to understand.
I agree that the approach that avoids changing value in the right shift
is more concise, I'll go back to that, adding a comment about how the
function works.
>> +static inline void tcg_out_movi(TCGContext *s, TCGType type,
>> + TCGReg rd, tcg_target_long value)
>> +{
>> + if (type == TCG_TYPE_I64) {
>> + tcg_out_movi_aux(s, rd, value);
>> + } else {
>> + tcg_out_movi_aux(s, rd, value & 0xffffffff);
>> + }
>> +}
>
> Any reason you're splitting out tcg_out_movi_aux to a separate function?
tcg_out_movi is an interface with tcg, and as such the prototype is fixed.
I'd rather work with a value that is unsigned, because of the right shift.
Having a separate _aux function does that without the need for adding
another local variable and another operation to understand in the function
with the actual algorithm.
>
>> + tcg_regset_clear(s->reserved_regs);
>> + tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP);
>> + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP);
>> + tcg_regset_set_reg(s->reserved_regs, TCG_REG_X18); /* platform register */
>
> Reserve the frame pointer.
Ok.
> r~
Claudio
next prev parent reply other threads:[~2013-05-29 7:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-28 15:23 [Qemu-devel] [PATCH v3 0/3] ARM aarch64 TCG target Claudio Fontana
2013-05-28 15:26 ` [Qemu-devel] [PATCH v3 1/3] include/elf.h: add aarch64 ELF machine and relocs Claudio Fontana
2013-05-28 15:28 ` [Qemu-devel] [PATCH v3 2/3] tcg/aarch64: implement new TCG target for aarch64 Claudio Fontana
2013-05-28 16:18 ` Richard Henderson
2013-05-29 7:44 ` Claudio Fontana [this message]
2013-05-28 15:30 ` [Qemu-devel] [PATCH v3 3/3] configure: permit compilation on arm aarch64 Claudio Fontana
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=51A5B1F0.2050305@huawei.com \
--to=claudio.fontana@huawei.com \
--cc=Jani.Kokkonen@huawei.com \
--cc=laurent.desnogues@gmail.com \
--cc=peter.maydell@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 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.