From: Andreas Schwab <schwab@suse.de>
To: Kevin Diggs <kevdig@hypersurf.com>
Cc: linuxppc-dev@ozlabs.org, Jeremy Kerr <jk@ozlabs.org>
Subject: Re: inline assembly & r0 SOS
Date: Wed, 06 Aug 2008 10:49:55 +0200 [thread overview]
Message-ID: <jetzdyttn0.fsf@sykes.suse.de> (raw)
In-Reply-To: <48990D0F.6050909@hypersurf.com> (Kevin Diggs's message of "Tue, 05 Aug 2008 19:31:43 -0700")
Kevin Diggs <kevdig@hypersurf.com> 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"
>>> "addi %0,%0,23\n"
>>> "rlwnm %0,%1,%0,30,31\n":
>>> "=r"(ret):
>>> "r"(config),"0"(range)
>>> );
>>
>>
>> Wouldn't this be much simpler in plain C?
>>
> I just knew someone was gonna try to rain on my rlwnm'in fun parade!
> Wonder if the C code can be made to compile down to 3 instructions?
This will do:
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.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2008-08-06 8:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-06 0:20 inline assembly & r0 SOS Kevin Diggs
2008-08-06 0:35 ` Benjamin Herrenschmidt
2008-08-06 0:41 ` Jeremy Kerr
2008-08-06 2:31 ` Kevin Diggs
2008-08-06 8:49 ` Andreas Schwab [this message]
2008-08-06 14:39 ` Segher Boessenkool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jetzdyttn0.fsf@sykes.suse.de \
--to=schwab@suse.de \
--cc=jk@ozlabs.org \
--cc=kevdig@hypersurf.com \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).