Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-07-08 Thread Blue Swirl
On Sun, Jul 8, 2012 at 11:37 AM, Avi Kivity wrote: > On 06/28/2012 08:58 AM, Markus Armbruster wrote: Better code is an argument only if the effect can be demonstrated. >>> >>> I don't know even for which compilers or CPUs this is true so it's >>> unlikely I could demonstrate it. However

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-07-08 Thread Avi Kivity
On 06/28/2012 08:58 AM, Markus Armbruster wrote: >>> >>> Better code is an argument only if the effect can be demonstrated. >> >> I don't know even for which compilers or CPUs this is true so it's >> unlikely I could demonstrate it. However, googling finds a few >> articles in defense of this. > >

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-28 Thread Blue Swirl
On Thu, Jun 28, 2012 at 5:58 AM, Markus Armbruster wrote: > Blue Swirl writes: > >> On Wed, Jun 27, 2012 at 6:01 AM, Markus Armbruster wrote: >>> Blue Swirl writes: >>> On Tue, Jun 26, 2012 at 6:41 PM, Peter Maydell wrote: > On 26 June 2012 19:25, Blue Swirl wrote: >> On Tu

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-27 Thread Markus Armbruster
Blue Swirl writes: > On Wed, Jun 27, 2012 at 6:01 AM, Markus Armbruster wrote: >> Blue Swirl writes: >> >>> On Tue, Jun 26, 2012 at 6:41 PM, Peter Maydell >>> wrote: On 26 June 2012 19:25, Blue Swirl wrote: > On Tue, Jun 26, 2012 at 6:11 PM, Peter Maydell > wrote: >> On 26

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-27 Thread Blue Swirl
On Wed, Jun 27, 2012 at 6:01 AM, Markus Armbruster wrote: > Blue Swirl writes: > >> On Tue, Jun 26, 2012 at 6:41 PM, Peter Maydell >> wrote: >>> On 26 June 2012 19:25, Blue Swirl wrote: On Tue, Jun 26, 2012 at 6:11 PM, Peter Maydell wrote: > On 26 June 2012 18:58, Blue Swirl w

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-26 Thread Markus Armbruster
Blue Swirl writes: > On Tue, Jun 26, 2012 at 6:41 PM, Peter Maydell > wrote: >> On 26 June 2012 19:25, Blue Swirl wrote: >>> On Tue, Jun 26, 2012 at 6:11 PM, Peter Maydell >>> wrote: On 26 June 2012 18:58, Blue Swirl wrote: > On Mon, Jun 25, 2012 at 7:38 PM, Peter Maydell > w

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-26 Thread Blue Swirl
On Tue, Jun 26, 2012 at 6:41 PM, Peter Maydell wrote: > On 26 June 2012 19:25, Blue Swirl wrote: >> On Tue, Jun 26, 2012 at 6:11 PM, Peter Maydell >> wrote: >>> On 26 June 2012 18:58, Blue Swirl wrote: On Mon, Jun 25, 2012 at 7:38 PM, Peter Maydell wrote: > +static inline uint6

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-26 Thread Peter Maydell
On 26 June 2012 19:25, Blue Swirl wrote: > On Tue, Jun 26, 2012 at 6:11 PM, Peter Maydell > wrote: >> On 26 June 2012 18:58, Blue Swirl wrote: >>> On Mon, Jun 25, 2012 at 7:38 PM, Peter Maydell >>> wrote: +static inline uint64_t field64(uint64_t value, int start, int length) >>> >>> star

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-26 Thread Blue Swirl
On Tue, Jun 26, 2012 at 6:11 PM, Peter Maydell wrote: > On 26 June 2012 18:58, Blue Swirl wrote: >> On Mon, Jun 25, 2012 at 7:38 PM, Peter Maydell >> wrote: >>> +static inline uint64_t field64(uint64_t value, int start, int length) >> >> start and length could be unsigned. > > They could be, bu

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-26 Thread Peter Maydell
On 26 June 2012 18:58, Blue Swirl wrote: > On Mon, Jun 25, 2012 at 7:38 PM, Peter Maydell > wrote: >> +static inline uint64_t field64(uint64_t value, int start, int length) > > start and length could be unsigned. They could be, but is there any reason why they should be? set_bit(), clear_bit()

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-26 Thread Blue Swirl
On Mon, Jun 25, 2012 at 7:38 PM, Peter Maydell wrote: > Add field32() and field64() functions which extract a particular > bit field from a word and return it. Based on an idea by Jia Liu. > > Suggested-by: Jia Liu > Signed-off-by: Peter Maydell > --- > Jia Liu had a function like this in the Op

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-25 Thread Peter Maydell
On 25 June 2012 21:26, malc wrote: > The field32 and field64 are inconsistent w.r.t. grouping, while both are > correct, one has to go through precedence list mentally in the latter > case. Yeah, unintentional and I agree that if you have to think about operator precedence there weren't enough br

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-25 Thread malc
On Mon, 25 Jun 2012, Peter Maydell wrote: > Add field32() and field64() functions which extract a particular > bit field from a word and return it. Based on an idea by Jia Liu. > > Suggested-by: Jia Liu > Signed-off-by: Peter Maydell > --- [..snip..] > +static inline uint64_t field64(uint64_t

[Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields

2012-06-25 Thread Peter Maydell
Add field32() and field64() functions which extract a particular bit field from a word and return it. Based on an idea by Jia Liu. Suggested-by: Jia Liu Signed-off-by: Peter Maydell --- Jia Liu had a function like this in the OpenRISC support patchset; this implementation borrows the API but has