From: Richard Henderson <rth@twiddle.net>
To: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>,
qemu-ppc@nongnu.org, david@gibson.dropbear.id.au
Cc: qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com,
hegdevasant@linux.vnet.ibm.com, sandipandas1990@gmail.com,
ego@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 3/4] target-ppc: add vrldnmi and vrlwmi instructions
Date: Mon, 24 Oct 2016 21:21:04 -0700 [thread overview]
Message-ID: <ac29d42c-018b-f2b7-44f6-cf7d2684fbd8@twiddle.net> (raw)
In-Reply-To: <87wpgx6pfy.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me>
On 10/24/2016 09:08 PM, Nikunj A Dadhania wrote:
> Richard Henderson <rth@twiddle.net> writes:
>
>> On 10/24/2016 02:14 AM, Nikunj A Dadhania wrote:
>>> +#define EXTRACT_BITS(size) \
>>> +static inline uint##size##_t extract_bits_u##size(uint##size##_t reg, \
>>> + uint##size##_t start, \
>>> + uint##size##_t end) \
>>> +{ \
>>> + uint##size##_t nr_mask_bits = end - start + 1; \
>>> + uint##size##_t val = 1; \
>>> + uint##size##_t mask = (val << nr_mask_bits) - 1; \
>>> + uint##size##_t shifted_reg = reg >> ((size - 1) - end); \
>>> + return shifted_reg & mask; \
>>> +}
>>> +
>>> +EXTRACT_BITS(64);
>>> +EXTRACT_BITS(32);
>>
>> We already have extract32 and extract64, which you're (nearly) duplicating.
>
> The bit position number notation is different, because of this using the
> above routine, MSB=0 and LSB=63.
>
> While the below assumes: MSB=63 and LSB=0
>
> static inline uint64_t extract64(uint64_t value, int start, int length)
> {
> assert(start >= 0 && length > 0 && length <= 64 - start);
> return (value >> start) & (~0ULL >> (64 - length));
> }
>
> Let me know if I am missing something here.
Since the arguments to extract_bits_uN are completely under your control, via
the arguments to VRLMI, this is a non-argument. Just change them to
little-endian position + length.
(And, after you do that conversion for vrldmi and vilwmi, you'll see why
big-endian bit numbering is the spawn of the devil. ;-)
r~
next prev parent reply other threads:[~2016-10-25 4:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-24 9:14 [Qemu-devel] [PATCH 0/4] POWER9 TCG enablements - part7 Nikunj A Dadhania
2016-10-24 9:14 ` [Qemu-devel] [PATCH 1/4] target-ppc: add xscmp[eq, gt, ge, ne]dp instructions Nikunj A Dadhania
2016-10-24 9:14 ` [Qemu-devel] [PATCH 2/4] target-ppc: add vmul10[u, eu, cu, ecu]q instructions Nikunj A Dadhania
2016-10-24 16:04 ` Richard Henderson
2016-10-25 2:38 ` David Gibson
2016-10-24 9:14 ` [Qemu-devel] [PATCH 3/4] target-ppc: add vrldnmi and vrlwmi instructions Nikunj A Dadhania
2016-10-24 16:16 ` Richard Henderson
2016-10-25 4:08 ` Nikunj A Dadhania
2016-10-25 4:21 ` Richard Henderson [this message]
2016-10-25 4:44 ` Nikunj A Dadhania
2016-10-25 6:02 ` Nikunj A Dadhania
2016-10-25 16:33 ` Richard Henderson
2016-10-26 4:44 ` Nikunj A Dadhania
2016-10-24 9:15 ` [Qemu-devel] [PATCH 4/4] target-ppc: add vrldnm and vrlwnm instructions Nikunj A Dadhania
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=ac29d42c-018b-f2b7-44f6-cf7d2684fbd8@twiddle.net \
--to=rth@twiddle.net \
--cc=bharata@linux.vnet.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=ego@linux.vnet.ibm.com \
--cc=hegdevasant@linux.vnet.ibm.com \
--cc=nikunj@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sandipandas1990@gmail.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 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).