ppc inline asm syntax

5 messages, 4 authors, 2007-01-13 · open the first message on its own page

ppc inline asm syntax

From: yuraxa <hidden>
Date: 2007-01-13 11:41:42

Hi, i'm writing some inline assembly for ppc.
Grepping linux src code for examples i found syntax that i can't
understand, but as i can see it's frequently used.  For example:

__asm__ __volatile__("lwz%U1%X1 %0,%1;\n"
                              "twi 0,%0,0;\n"
                              "isync" : "=r" (ret) : "m" (*addr));

Can you explain me please  howto interpret 'lwz%U1%X1'  format string
in the assembler template line? Some other of them are:

'stw%U0%X0'   etc...

I can't find any help on this topic on the web.

Thanks a'lot,
Yury.

Re: ppc inline asm syntax

From: Andreas Schwab <hidden>
Date: 2007-01-13 13:20:25

yuraxa [off-list ref] writes:
Hi, i'm writing some inline assembly for ppc.
Grepping linux src code for examples i found syntax that i can't
understand, but as i can see it's frequently used.
There is some documentation in the GCC internals manual, see
<http://gcc.gnu.org/onlinedocs/gccint/Output-Template.html>.  The ppc
specific operand modifiers are only documented in the GCC source, see
print_operand in
<http://gcc.gnu.org/viewcvs/trunk/gcc/config/rs6000/rs6000.c?view=markup>.

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."

Re: ppc inline asm syntax

From: yuraxa <hidden>
Date: 2007-01-13 18:28:42

quoted
Hi, i'm writing some inline assembly for ppc.
Grepping linux src code for examples i found syntax that i can't
understand, but as i can see it's frequently used.
There is some documentation in the GCC internals manual, see
<http://gcc.gnu.org/onlinedocs/gccint/Output-Template.html>.  The ppc
specific operand modifiers are only documented in the GCC source, see
print_operand in
<http://gcc.gnu.org/viewcvs/trunk/gcc/config/rs6000/rs6000.c?view=markup>.

Andreas.
Thanks a'lot, It helps! But may be you'll be so graceful to explain
more precisely?
I don't quite understand how the final string will look like...
For 'U' operand modifier the comment is:
/* Print `u' if this has an auto-increment or auto-decrement.  */
But for 'X' operand modifier there is no comment at all.

Thanks in advance,
Yury.

Re: ppc inline asm syntax

From: Alan Modra <hidden>
Date: 2007-01-13 23:09:20

On Sat, Jan 13, 2007 at 07:28:39PM +0100, yuraxa wrote:
But for 'X' operand modifier there is no comment at all.
Are you afraid to look at code?  Three lines!  It prints an 'x' if the
operand is an indexed address.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Re: ppc inline asm syntax

From: Paul Mackerras <hidden>
Date: 2007-01-13 23:48:01

yuraxa writes:
Thanks a'lot, It helps! But may be you'll be so graceful to explain
more precisely?
I don't quite understand how the final string will look like...
For 'U' operand modifier the comment is:
/* Print `u' if this has an auto-increment or auto-decrement.  */
But for 'X' operand modifier there is no comment at all.
'X' turns into "x" if gcc wants to use indexed addressing mode, or
nothing if gcc wants to use base + offset mode.

I agree that the gcc documentation of the details of inline assembly
for each specific architecture is woeful.  I have found it useful in
the past to get hold of the gcc source code and look in rs6000.md for
examples of what can be done.

Paul.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help