[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 03/15] Openrisc: add instructions translation

From: Blue Swirl
Subject: Re: [Qemu-devel] [PATCH 03/15] Openrisc: add instructions translation
Date: Sat, 19 May 2012 11:29:31 +0000

On Sat, May 19, 2012 at 10:57 AM, Peter Maydell
<address@hidden> wrote:
> On 19 May 2012 11:02, Blue Swirl <address@hidden> wrote:
>>> +static inline uint32_t field(uint32_t val, int start, int length)
>>> +{
>>> +    val >>= start;
>>> +    val &= ~(~0 << length);
>>> +    return val;
>>> +}
>> Nice function, maybe I could use it in Sparc as well if generalized (later).
> We should totally have something like this in our generic bitops
> header file. I've previously worked on a codebase that used something
> similar consistently, and it's much easier to read than code which
> does inline mask-and-shift code.

Yes. A generic method to construct bit field #defines/enums with nice
printout would be nice too. I think I saw something like that in BSD
land, can't remember where.

> We probably want a 64 bit variant (or maybe we can just work
> on uint64_t and trust the compiler to throw away the top halves
> in the 32 bit case?)

For Sparc the it would be used to extract fields from an instruction,
they are always 32 bits. But IA64 would need a 64 bit version.

I'd make two variants, maybe also target_ulong version if ever needed.

> -- PMM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]