public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Inline assembly constraints question
@ 2008-08-18 10:34 Jeroen Demeyer
  2008-08-19 16:59 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Jeroen Demeyer @ 2008-08-18 10:34 UTC (permalink / raw)
  To: gcc-help

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-20 14:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-18 10:34 Inline assembly constraints question Jeroen Demeyer
2008-08-19 16:59 ` Ian Lance Taylor
2008-08-20 13:47   ` Jeroen Demeyer
2008-08-20 19:31     ` Ian Lance Taylor

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).