Re: Odd error with the "X" inline assembly constraint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jan 07, 2024 at 04:10:21PM +0100, David Brown wrote:
> On 05/01/2024 19:46, Segher Boessenkool wrote:
> >>However, when I use just "asm ("" : "+X" (x));", I get an error message
> >>"error: inconsistent operand constraints in an 'asm'".  I have no idea
> >>why this is an issue.
> >
> >The C constraint means "Any operand whatsoever is allowed."  Here you
> >are saying to use it both as input and as output, and GCC does not know
> >how to reload wherever it chose to put it.
> 
> It doesn't need to reload it

The error message is emitted during reloading.

> >"+" really creates two operands, and ties them together.  Writing
> >   asm("oink" : "+X"(bla));
> >is shorthand for
> >   asm("oink" : "=X"(bla) : "0"(bla));
> >
> 
> I don't know if these are /exactly/ the same, but they are certainly 
> similar.

They are the same thing.  The "+" syntactic sugar is modified during
gimplification already, almost nothing in the compiler has to deal with
it.

See "gimplify_asm_expr", see the code after
          /* An input/output operand.  To give the optimizers more
             flexibility, split it into separate input and output
             operands.  */

(Constraints that allow registers get a "0" (or "1" etc.) matching
constraint for the input duplicate, constraints that do not (like "m")
are unmodified.  The output duplicate just gets the "+" changed to "=").


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux