public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeroen Demeyer <jdemeyer@cage.ugent.be>
To: gcc-help@gcc.gnu.org
Subject: Inline assembly constraints question
Date: Mon, 18 Aug 2008 10:34:00 -0000	[thread overview]
Message-ID: <48A937FE.30100@cage.ugent.be> (raw)

Hello,

I have a C++ program (i386 target) which has a piece of inline assembly 
with the following constraints:

asm(/* Some asm code */
     : "=&rm" (n0), "=&r" (n1), "=&r" (n2)
     : "2" (n0), "1" (n1), "g" (n2), "cI" (s)
);

When compiled with g++ 4.1.2 (CXXFLAGS=-O2 -march=pentium4) the operands 
%0 and %5 get the same memory address, even though they refer to 
distinct variables (n0 and n2).  So, is this a bug in g++ 4.1.2 or am I 
doing something wrong?   g++ 3.4.6 and g++ 4.3.1 generate correct code, 
but that does not really prove anything.

In particular I would like to know:
1) Is it allowed to put matching (digit) constraints referring to 
different variables?  This is what I do with %2.  The same register is 
used as input for  variable n0 and as output for variable n2.
2) Is there a way to specify some kind of 'earlyclobber' (&) modifier 
with a memory constraint?  How can I prevent gcc from putting an input 
variable and an unrelated output variable in the same memory location?

Thank you for your time,
Jeroen Demeyer.

             reply	other threads:[~2008-08-18  8:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-18 10:34 Jeroen Demeyer [this message]
2008-08-19 16:59 ` Ian Lance Taylor
2008-08-20 13:47   ` Jeroen Demeyer
2008-08-20 19:31     ` Ian Lance Taylor

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=48A937FE.30100@cage.ugent.be \
    --to=jdemeyer@cage.ugent.be \
    --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).