Search Linux Wireless

Re: [PATCH 01/11 v3] rt2x00: Calculate register offset during compile time

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

 



On Tuesday 03 June 2008, Harvey Harrison wrote:
> On Tue, 2008-06-03 at 22:45 +0200, Ivo van Doorn wrote:
> > By using __ffs() the register offsets were always calculated
> > at run-time which all FIELD32/FIELD16 definitions were builtin
> > constants. This means we can heavily optimize the register handling
> > by allowing GCC to do all the work during compilation.
> > 
> > Add some compile_ffs() macros to perform the calculation at
> > compile time. After this each rt2x00 module size is reduced
> > by ~2500 bytes. And the stack size of several functions is reduced
> > as well which further limits the number of rt2x00 results in
> > 'make checkstack'.
> > +/*
> > + * Macro's to find first set bit in a variable.
> > + * These macro's behaves the same as the __ffs() function with
> > + * the most important difference that this is done during
> > + * compile-time rather then run-time.
> > + */
> 
> #define const_ffs8(__x) ( \
> 	BUILD_BUG_ON(!__builtin_constant_p(__x));	\
> 	__builtin_choose_expr((__x) & 0x01, 0,		\
> 	__builtin_choose_expr((__x) & 0x02, 1,		\
> 	__builtin_choose_expr((__x) & 0x04, 2,		\
> 	__builtin_choose_expr((__x) & 0x08, 3,		\
> 	__builtin_choose_expr((__x) & 0x10, 4,		\
> 	__builtin_choose_expr((__x) & 0x20, 5,		\
> 	__builtin_choose_expr((__x) & 0x40, 6,		\
> 	__builtin_choose_expr((__x) & 0x80, 7,		\
> 	8)))))))); )
> 
> #define const_ffs16(__x) ( \
> 	__builtin_choose_expr((__x) & 0xff,	\
>  	const_ffs8(__x),			\
> 	const_ffs8((__x) >> 8) + 8); )
> 
> 
> #define const_ffs32(__x) ( \
> 	__builtin_choose_expr((__x) & 0xffff,	\
> 	const_ffs16(__x),			\
> 	const_ffs16((__x) >> 16) + 16); )
> 
> 
> Just a thought.

Thanks for the tipe, that does sound a lot cleaner then the ? : statements,
I did a quick compilation check and it doesn't seem to have any influence.
I'll move the __builtin_choose_expr into rt2x00.git for testing and move
that patch upstream to wireless-2.6 later.

Ivo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux