lkml.org 
[lkml]   [2019]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRE: [PATCH v2 3/6] powerpc: Convert flush_icache_range & friends to C
On Tue, 2019-09-03 at 11:04 -0500, Segher Boessenkool wrote:
> On Tue, Sep 03, 2019 at 04:28:09PM +0200, Christophe Leroy wrote:
> > Le 03/09/2019 à 15:04, Segher Boessenkool a écrit :
> > > On Tue, Sep 03, 2019 at 03:23:57PM +1000, Alastair D'Silva wrote:
> > > > + asm volatile(
> > > > + " mtctr %2;"
> > > > + " mtmsr %3;"
> > > > + " isync;"
> > > > + "0: dcbst 0, %0;"
> > > > + " addi %0, %0, %4;"
> > > > + " bdnz 0b;"
> > > > + " sync;"
> > > > + " mtctr %2;"
> > > > + "1: icbi 0, %1;"
> > > > + " addi %1, %1, %4;"
> > > > + " bdnz 1b;"
> > > > + " sync;"
> > > > + " mtmsr %5;"
> > > > + " isync;"
> > > > + : "+r" (loop1), "+r" (loop2)
> > > > + : "r" (nb), "r" (msr), "i" (bytes), "r" (msr0)
> > > > + : "ctr", "memory");
> > >
> > > This outputs as one huge assembler statement, all on one
> > > line. That's
> > > going to be fun to read or debug.
> >
> > Do you mean \n has to be added after the ; ?
>
> Something like that. There is no really satisfying way for doing
> huge
> inline asm, and maybe that is a good thing ;-)
>
> Often people write \n\t at the end of each line of inline asm. This
> works
> pretty well (but then there are labels, oh joy).
>
> > > loop1 and/or loop2 can be assigned the same register as msr0 or
> > > nb. They
> > > need to be made earlyclobbers. (msr is fine, all of its reads
> > > are before
> > > any writes to loop1 or loop2; and bytes is fine, it's not a
> > > register).
> >
> > Can you explicit please ? Doesn't '+r' means that they are input
> > and
> > output at the same time ?
>
> That is what + means, yes -- that this output is an input as
> well. It is
> the same to write
>
> asm("mov %1,%0 ; mov %0,42" : "+r"(x), "=r"(y));
> or to write
> asm("mov %1,%0 ; mov %0,42" : "=r"(x), "=r"(y) : "0"(x));
>
> (So not "at the same time" as in "in the same machine instruction",
> but
> more loosely, as in "in the same inline asm statement").
>
> > "to be made earlyclobbers", what does this means exactly ? How to
> > do that ?
>
> You write &, like "+&r" in this case. It means the machine code
> writes
> to this register before it has consumed all asm inputs (remember, GCC
> does not understand (or even parse!) the assembler string).
>
> So just
>
> : "+&r" (loop1), "+&r" (loop2)
>
> will do. (Why are they separate though? It could just be one loop
> var).
>
>

Thanks, I've updated these.

--
Alastair D'Silva
Open Source Developer
Linux Technology Centre, IBM Australia
mob: 0423 762 819

\
 
 \ /
  Last update: 2019-09-04 05:37    [W:0.057 / U:3.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site