From: Richard Henderson <rth@twiddle.net>
To: Jay Foad <jay.foad@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC 01/14] tcg-aarch64: Allow immediate operands to add and sub
Date: Tue, 13 Aug 2013 09:08:48 -0700 [thread overview]
Message-ID: <520A5A10.1050508@twiddle.net> (raw)
In-Reply-To: <CANd1uZ=GNDWNGJED+uTsy5CKSxrD6iUEJp4nMYv_a1pHhSntwg@mail.gmail.com>
On 08/13/2013 01:57 AM, Jay Foad wrote:
>> -static inline void tcg_out_addi(TCGContext *s, int ext,
>> - TCGReg rd, TCGReg rn, unsigned int aimm)
>> +static void tcg_out_addi(TCGContext *s, int ext, TCGReg rd, TCGReg rn,
>> + tcg_target_long aimm)
>> {
>> - /* add immediate aimm unsigned 12bit value (with LSL 0 or 12) */
>> - /* using ADD 0x11000000 | (ext) | (aimm << 10) | (rn << 5) | rd */
>> - unsigned int base = ext ? 0x91000000 : 0x11000000;
>> + enum aarch64_arith_opc opc = ARITH_ADDI;
>> + tcg_target_long lo, hi;
>>
>> - if (aimm <= 0xfff) {
>> - aimm <<= 10;
>> - } else {
>> - /* we can only shift left by 12, on assert we cannot represent */
>> - assert(!(aimm & 0xfff));
>> - assert(aimm <= 0xfff000);
>> - base |= 1 << 22; /* apply LSL 12 */
>> - aimm >>= 2;
>> + if (aimm < 0) {
>> + aimm = -aimm;
>> + opc = ARITH_SUBI;
>> }
>> + hi = aimm & 0xfff000;
>> + lo = aimm & 0xfff;
>> + assert(aimm == hi + lo);
>
> Won't this fail if aimm was -0x1000000 on entry?
Yep, off-by-one thinko on the constraint test.
Should only allow -0xffffff <= x <= 0xffffff.
r~
next prev parent reply other threads:[~2013-08-13 16:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 8:57 [Qemu-devel] [RFC 01/14] tcg-aarch64: Allow immediate operands to add and sub Jay Foad
2013-08-13 16:08 ` Richard Henderson [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-08-12 18:44 [Qemu-devel] [RFC 00/14] tcg aarch64 improvements Richard Henderson
2013-08-12 18:44 ` [Qemu-devel] [RFC 01/14] tcg-aarch64: Allow immediate operands to add and sub 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=520A5A10.1050508@twiddle.net \
--to=rth@twiddle.net \
--cc=jay.foad@gmail.com \
--cc=qemu-devel@nongnu.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 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.