From: Richard Henderson <rth@twiddle.net>
To: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 5/8] target-tricore: Add instructions of RR opcode format, that have 0x4b as the first opcode
Date: Fri, 12 Dec 2014 12:45:49 -0800 [thread overview]
Message-ID: <548B53FD.6020000@twiddle.net> (raw)
In-Reply-To: <1418405504-11175-6-git-send-email-kbastian@mail.uni-paderborn.de>
On 12/12/2014 09:31 AM, Bastian Koppelmann wrote:
> +uint32_t helper_parity(target_ulong r1)
> +{
> + uint32_t ret;
> + uint32_t nOnes, i;
> +
> + ret = 0;
> + nOnes = 0;
> + for (i = 0; i < 8; i++) {
> + ret ^= (r1 & 1);
> + r1 = r1 >> 1;
> + }
> + /* second byte */
> + nOnes = 0;
> + for (i = 0; i < 8; i++) {
> + nOnes ^= (r1 & 1);
> + r1 = r1 >> 1;
> + }
> + ret |= nOnes << 8;
> + /* third byte */
> + nOnes = 0;
> + for (i = 0; i < 8; i++) {
> + nOnes ^= (r1 & 1);
> + r1 = r1 >> 1;
> + }
> + ret |= nOnes << 16;
> + /* fourth byte */
> + nOnes = 0;
> + for (i = 0; i < 8; i++) {
> + nOnes ^= (r1 & 1);
> + r1 = r1 >> 1;
> + }
> + ret |= nOnes << 24;
> +
> + return ret;
> +}
> +
Probably doesn't matter much, but
ret = (ctpop8(r1) & 1)
| ((ctpop8(r1 >> 8) & 1) << 8)
| ((ctpop8(r1 >> 16) & 1) << 16)
| ((ctpop8(r1 >> 24) & 1) << 24);
One could also make a case for adding new helpers that
use __builtin_parity rather than __builtin_popcount.
I usually like to look at things like this and see how
the general infrastructure can be improved...
Otherwise,
Reviewed-by: Richard Henderson <rth@twiddle.net>
r~
next prev parent reply other threads:[~2014-12-12 20:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 17:31 [Qemu-devel] [PATCH 0/8] TriCore add instructions of RR and RR1 opcode format Bastian Koppelmann
2014-12-12 17:31 ` [Qemu-devel] [PATCH 1/8] target-tricore: Change SSOV/SUOV makro name to SSOV32/SUOV32 Bastian Koppelmann
2014-12-12 19:31 ` Richard Henderson
2014-12-12 17:31 ` [Qemu-devel] [PATCH 2/8] target-tricore: Add instructions of RR opcode format, that have 0xb as the first opcode Bastian Koppelmann
2014-12-12 19:49 ` Richard Henderson
2014-12-12 17:31 ` [Qemu-devel] [PATCH 3/8] target-tricore: Add instructions of RR opcode format, that have 0xf " Bastian Koppelmann
2014-12-12 20:04 ` Richard Henderson
2014-12-12 17:31 ` [Qemu-devel] [PATCH 4/8] target-tricore: Add instructions of RR opcode format, that have 0x1 " Bastian Koppelmann
2014-12-12 20:06 ` Richard Henderson
2014-12-12 17:31 ` [Qemu-devel] [PATCH 5/8] target-tricore: Add instructions of RR opcode format, that have 0x4b " Bastian Koppelmann
2014-12-12 20:45 ` Richard Henderson [this message]
2014-12-17 15:43 ` Bastian Koppelmann
2014-12-12 17:31 ` [Qemu-devel] [PATCH 6/8] target-tricore: Add missing 1.6 insn of BOL opcode format Bastian Koppelmann
2014-12-12 20:46 ` Richard Henderson
2014-12-12 17:31 ` [Qemu-devel] [PATCH 7/8] target-tricore: Fix MFCR/MTCR insn and B format offset Bastian Koppelmann
2014-12-12 20:49 ` Richard Henderson
2014-12-12 17:31 ` [Qemu-devel] [PATCH 8/8] target-tricore: Add instructions of RR1 opcode format, that have 0xb3 as first opcode Bastian Koppelmann
2014-12-12 20:53 ` 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=548B53FD.6020000@twiddle.net \
--to=rth@twiddle.net \
--cc=kbastian@mail.uni-paderborn.de \
--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.