public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: David Brown <david@westcontrol.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Odd error with the "X" inline assembly constraint
Date: Fri, 5 Jan 2024 12:46:12 -0600	[thread overview]
Message-ID: <20240105184612.GE19790@gate.crashing.org> (raw)
In-Reply-To: <un9arr$leo$1@ciao.gmane.io>

On Fri, Jan 05, 2024 at 05:30:51PM +0100, David Brown via Gcc-help 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.

Using "X" for outputs is strange already, fwiw, but tieing it to an
input is, hrm, let's call it "creative" :-)

> I'd imagine that the "X" operand doesn't see much use in real inline 
> assembly

It is used rather often.  But usually for inputs, and (as you found out)
trying to use if for an input and for an output at the same time does
not work reliably.

"+" really creates two operands, and ties them together.  Writing
  asm("oink" : "+X"(bla));
is shorthand for
  asm("oink" : "=X"(bla) : "0"(bla));


Segher

  parent reply	other threads:[~2024-01-05 18:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05 16:30 David Brown
2024-01-05 17:53 ` LIU Hao
2024-01-05 18:46 ` Segher Boessenkool [this message]
2024-01-07 10:04   ` LIU Hao
2024-01-07 15:26     ` David Brown
2024-01-07 18:32     ` Segher Boessenkool
2024-01-08 18:39       ` David Brown
2024-01-07 15:10   ` David Brown
2024-01-07 18:24     ` Segher Boessenkool
2024-01-08 18:48       ` David Brown
2024-01-07 23:18 ` Marc Glisse

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=20240105184612.GE19790@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=david@westcontrol.com \
    --cc=gcc-help@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).