From: Richard Henderson <rth@twiddle.net>
To: gang.chen.5i5j@gmail.com, peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org, xili_gchen_5257@hotmail.com
Subject: Re: [Qemu-devel] [PATCH] target-tilegx: Implement v*add and v*sub instructions
Date: Fri, 18 Sep 2015 19:34:32 -0700 [thread overview]
Message-ID: <55FCC9B8.1030606@twiddle.net> (raw)
In-Reply-To: <1442621006-4231-1-git-send-email-gang.chen.5i5j@gmail.com>
On 09/18/2015 05:03 PM, gang.chen.5i5j@gmail.com wrote:
> +uint64_t helper_v1add(uint64_t a, uint64_t b)
> +{
> + uint64_t r = 0;
> + int i;
> +
> + for (i = 0; i < 64; i += 8) {
> + int64_t ae = (int8_t)(a >> i);
> + int64_t be = (int8_t)(b >> i);
> + r |= ((ae + be) & 0xff) << i;
> + }
> + return r;
> +}
> +
> +uint64_t helper_v2add(uint64_t a, uint64_t b)
> +{
> + uint64_t r = 0;
> + int i;
> +
> + for (i = 0; i < 64; i += 16) {
> + int64_t ae = (int16_t)(a >> i);
> + int64_t be = (int16_t)(b >> i);
> + r |= ((ae + be) & 0xffff) << i;
> + }
> + return r;
> +}
There's a trick for this that's more efficient for 4 or more elements per
vector (i.e. good for v2 and v1, but not v4):
a + b = (a & 0x7f7f7f7f) + (b & 0x7f7f7f7f)) ^ ((a ^ b) & 0x80808080)
a - b = (a | 0x80808080) - (b & 0x7f7f7f7f)) ^ ((a ^ ~b) & 0x80808080)
> +uint64_t helper_v4add(uint64_t a, uint64_t b)
> +{
> + uint64_t r = 0;
> + int i;
> +
> + for (i = 0; i < 64; i += 32) {
> + int64_t ae = (int32_t)(a >> i);
> + int64_t be = (int32_t)(b >> i);
> + r |= ((ae + be) & 0xffffffff) << i;
> + }
> + return r;
> +}
I should have mentioned this in the previous patch...
I think probably it would be best to open-code all, or most of, the v4
operations. Something like
static void gen_v4op(TCGv d64, TCGv a64, TCGv b64,
void (*generate)(TCGv_i32, TCGv_i32, TCGv_i32))
{
TCGv_i32 al = tcg_temp_new_i32();
TCGv_i32 ah = tcg_temp_new_i32();
TCGv_i32 bl = tcg_temp_new_i32();
TCGv_i32 bh = tcg_temp_new_i32();
tcg_gen_extr_i64_i32(al, ah, a64);
tcg_gen_extr_i64_i32(bl, bh, b64);
generate(al, al, bl);
generate(ah, ah, bh);
tcg_gen_concat_i32_i64(d64, al, ah);
tcg_temp_free_i32(al);
tcg_temp_free_i32(ah);
tcg_temp_free_i32(bl);
tcg_temp_free_i32(bh);
}
> case OE_RRR(V4ADD, 0, X0):
> case OE_RRR(V4ADD, 0, X1):
> - return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
> + gen_helper_v4add(tdest, tsrca, tsrcb);
And then
gen_v4op(tdest, tsrca, tsrcb, tcg_gen_add_i32);
r~
next prev parent reply other threads:[~2015-09-19 2:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-19 0:03 [Qemu-devel] [PATCH] target-tilegx: Implement v*add and v*sub instructions gang.chen.5i5j
2015-09-19 2:34 ` Richard Henderson [this message]
2015-09-20 22:37 ` Chen Gang
2015-09-22 5:54 ` Chen Gang
2015-09-22 14:45 ` Richard Henderson
2015-09-22 21:41 ` Chen Gang
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=55FCC9B8.1030606@twiddle.net \
--to=rth@twiddle.net \
--cc=gang.chen.5i5j@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=xili_gchen_5257@hotmail.com \
/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.