Re: inline assembly & r0 SOS

2008-08-06 Thread Segher Boessenkool
unsigned int get_PLL_range(unsigned int range, unsigned int config) { range = range * 8 + 23; return ((config << range) | (config >> (32 - range))) & 3; } The special pattern ((a << n) | (a >> (32 - n))) is recognized by gcc as a rotate operation. It's only valid for 1 <= n <= 31 though

Re: inline assembly & r0 SOS

2008-08-06 Thread Andreas Schwab
Kevin Diggs <[EMAIL PROTECTED]> writes: > Jeremy Kerr wrote: >> Hi Kevin, >> >> >>> /* >>> * Turn r3 (range) into a rotate count for the selected >>>range. * 0 -> 23, 1 -> 31 >>> */ >>> __asm__ __volatile__ ( "slwi %0,%0,3\n" >>> "

Re: inline assembly & r0 SOS

2008-08-05 Thread Kevin Diggs
Jeremy Kerr wrote: Hi Kevin, /* * Turn r3 (range) into a rotate count for the selected range. * 0 -> 23, 1 -> 31 */ __asm__ __volatile__ ( "slwi %0,%0,3\n" "addi %0,%0,23\n" "rlwnm %0,%1,%0,30,31

Re: inline assembly & r0 SOS

2008-08-05 Thread Jeremy Kerr
Hi Kevin, > /* > * Turn r3 (range) into a rotate count for the selected > range. * 0 -> 23, 1 -> 31 > */ > __asm__ __volatile__ ( "slwi %0,%0,3\n" > "addi %0,%0,23\n" > "rlwnm %0,%1,%0,30,31\n"

Re: inline assembly & r0 SOS

2008-08-05 Thread Benjamin Herrenschmidt
On Tue, 2008-08-05 at 17:20 -0700, Kevin Diggs wrote: > Hi, > > thats bad right? Because the "addi 0, 0, 23" will not work as expected > because of the "special property" of r0. FYI: The first three lines > after the "#APP" are from a similar function get_PLL_ratio(). > > Is there a way

inline assembly & r0 SOS

2008-08-05 Thread Kevin Diggs
Hi, If I have: inline unsigned int get_PLL_range(unsigned int range, unsigned int config) { unsigned int ret; /* * Turn r3 (range) into a rotate count for the selected range. * 0 -> 23, 1 -> 31 */ __asm__ __volatile__ ( "slwi %0,%0,3\n"