public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@aknet.ru>
To: Andrew Haley <aph@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: clobbering input args in inline asm
Date: Sat, 29 Apr 2006 09:44:00 -0000	[thread overview]
Message-ID: <4453358D.8060600@aknet.ru> (raw)
In-Reply-To: <17491.10538.514085.559389@zapata.pink>

Hi.

Andrew Haley wrote:
> The clobber list is for physical register names such as "ebx", not for
> operands.
Yes, that's why my question was not "why it still
doesn't work", but rather "what does the "0" mean, when
put in the clobber list?" gcc accepts it there, and I
wasn't able to find anywhere in the docs, what does it
mean.

> This is wrong: you're clobbering one of the inputs without telling
> gcc.
Yes, but the problem is, the way to tell this to gcc
looks very strange to me. Here's only what I've been
able to find in the docs:
---
There is no way for you to specify that an input
operand is modified without also specifying it as an output
operand.  Note that if all the output operands you specify are for this
purpose (and hence unused), you will then also need to specify
|volatile| for the |asm| construct, as described below, to
prevent GCC from deleting the |asm| statement as unused.
---
A quick googling shows many people are confused with that, too.
I am just curious, why there wasn't a better solution to such a
problem? gcc wants me to add the dummy output var for that, and
googling reveals some discussion that a better syntax was simply
not found. But IMHO, allowing "&" modifier in the input list is
the most natural way of expressing that the input is being
clobbered after the value is taken.

> Assuming you actually want the output, it should be:
No, what I really want, is an input. I.e. I want to put the
input in %%ebx. But then, after I already used it, I want to
re-use %%ebx in an asm code. And here's the gotcha: re-using
%%ebx also alters the input operand, but not always - that
depends on an optimization level. I find that counter-intuitive,
hence the questions.

  reply	other threads:[~2006-04-29  9:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-28 22:35 Stas Sergeev
2006-04-29  8:51 ` Andrew Haley
2006-04-29  9:44   ` Stas Sergeev [this message]
2006-05-02 10:44     ` Andrew Haley
2006-05-02 19:21       ` Stas Sergeev
2006-05-02 19:53         ` Andrew Haley

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=4453358D.8060600@aknet.ru \
    --to=stsp@aknet.ru \
    --cc=aph@redhat.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).