[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: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 03/15] Openrisc: add instructions translation
Date: Sat, 19 May 2012 11:57:11 +0100

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.

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?)

-- PMM

reply via email to

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