Re: Memory outputs in inline asm

2014-02-26 Thread Andrew Haley
On 02/26/2014 04:43 PM, Segher Boessenkool wrote: > "+r"(p) as well, you're modifying %2. Yes, yes, OK. :-) Andrew.

Re: Memory outputs in inline asm

2014-02-26 Thread Segher Boessenkool
FWIW: > __asm__("\t0:\n" > "\tstr wzr, [%2, #4]!\n" > "\tsub %1, %1, #1\n" > "\tcbnz %1, 0b\n" > : "=m"(*p), "+r"(len) : "r"(p)); "+r"(p) as well, you're modifying %2. Cheers, Segher

Re: Memory outputs in inline asm

2014-02-26 Thread Richard Sandiford
Michael Matz writes: > On Wed, 26 Feb 2014, Richard Biener wrote: >> > "\tstr wzr, [%2, #4]!\n" >> > "\tsub %1, %1, #1\n" >> > "\tcbnz %1, 0b\n" >> > : "=m"(*p), "+r"(len) : "r"(p)); >> > >> > I presume this is wrong because *p only refers to p[0]. Is it >>

Re: Memory outputs in inline asm

2014-02-26 Thread Michael Matz
Hi, On Wed, 26 Feb 2014, Richard Biener wrote: > > "\tstr wzr, [%2, #4]!\n" > > "\tsub %1, %1, #1\n" > > "\tcbnz %1, 0b\n" > > : "=m"(*p), "+r"(len) : "r"(p)); > > > > I presume this is wrong because *p only refers to p[0]. Is it > > possible to tell GCC t

Re: Memory outputs in inline asm

2014-02-26 Thread Andrew Haley
On 02/26/2014 12:24 PM, Richard Biener wrote: > An additional question that immediately pops up here is that > of TBAA - may we use the alias-set of the memory reference > to disambiguate other loads/stores against the asm? I would certainly hope so: I don't think the rule here should be any diffe

Re: Memory outputs in inline asm

2014-02-26 Thread Richard Biener
On Wed, Feb 26, 2014 at 12:10 PM, Andrew Haley wrote: > On 02/26/2014 10:51 AM, Richard Biener wrote: >> But yes, technically you write p[0] here but as "m" merely builds >> an address to the memory I'd say that we have to treat any "m" >> operand as possibly reading from / writing to / clobbering

Re: Memory outputs in inline asm

2014-02-26 Thread Andrew Haley
On 02/26/2014 10:51 AM, Richard Biener wrote: > But yes, technically you write p[0] here but as "m" merely builds > an address to the memory I'd say that we have to treat any "m" > operand as possibly reading from / writing to / clobbering the > whole object that can be refered to using that addres

Re: Memory outputs in inline asm

2014-02-26 Thread Richard Biener
On Wed, Feb 26, 2014 at 11:32 AM, Andrew Haley wrote: > Say you have a pointer: > > int *p; > > and an inline asm that writes to a block of memory > > __asm__("\t0:\n" > "\tstr wzr, [%2, #4]!\n" > "\tsub %1, %1, #1\n" > "\tcbnz %1, 0b\n" > : "=m"(*p), "+r"

Memory outputs in inline asm

2014-02-26 Thread Andrew Haley
Say you have a pointer: int *p; and an inline asm that writes to a block of memory __asm__("\t0:\n" "\tstr wzr, [%2, #4]!\n" "\tsub %1, %1, #1\n" "\tcbnz %1, 0b\n" : "=m"(*p), "+r"(len) : "r"(p)); I presume this is wrong because *p only refers to p[0].