This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

extend.texi patch on how to specify clobbered inputs (was: Re: i386, asm and forbidden spilled registers...)



Two questions on egcs the last few days, and reading the
relevant FM over and over, (gcc.info)Extended Asm, makes me
think something is lacking in the description of how to specify
modified inputs that are not used as output.  It unfortunately
seems to be somewhat logical (even to smart people :-) to infer
from the current extend.texi that you could use a clobber-
description for this (egcs as well as gcc2). 

Everybody(?) is now probably acquainted that the way to validly
write Krister's example (modified but unused "di" and "cx",
<URL:http://www.cygnus.com/ml/egcs/1998-Oct/1285.html>) is
AFAIK:

----------------
static __inline void
insb(int port, void *addr, int cnt)
{
  int dummy1;
  void *dummy2;
        __asm __volatile("cld\n\trepne\n\tinsb"                 :
                         "=c" (dummy1),"=D" (dummy2)            :
                         "d" (port), "1" (addr), "0" (cnt)      :
                         "memory");
}

void
foo(void)
{
  insb(0,0,0);
}
----------------

That is, as output operands as well as input operands.  Don't
forget the volatile specifier, which is important now as this
makes it an asm with only unused outputs, and may otherwise be
removed.  Note that I did not use the "+" specifier, which is
valid for gcc-2.8 as well as egcs, as it is not valid for
gcc-2.7.2, which presumably is an issue to many people.

Enough ranting and lecturing for this small patch ;-)
 The patch and ChangeLog entry for extend.texi, should be
applicable (maybe with some fuzz) to gcc2.  The logical location
for the invalid-clobber-description seems to me to be close to
the clobber-description.  There may be a need to specify that
gcc-2.7.2 accepted the invalid clobbers, but I don't think this
file is the place to write about history.  Authority feelings?

(Using the wording "input and output", to not necessarily mix it
up with "input-output" as used in the "+"-modifier description.)

Sun Nov  1 22:13:20 1998  Hans-Peter Nilsson  <hp@axis.se>

	* extend.texi (Extended Asm): Say it's invalid to describe
	modified inputs as clobbers.

Index: extend.texi
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/extend.texi,v
retrieving revision 1.15
diff -p -c -r1.15 extend.texi
*** extend.texi	1998/10/11 02:21:30	1.15
--- extend.texi	1998/11/01 21:27:15
*************** asm volatile ("movc3 %0,%1,%2"
*** 2404,2409 ****
--- 2404,2415 ----
                : "r0", "r1", "r2", "r3", "r4", "r5");
  @end example
  
+ It is @emph{not} valid to use a clobber description to describe that an
+ input operand is modified, but unused as output.  It has to be specified
+ as an input and output operand anyway.  Note that if there are only
+ unused output operands, you will then also need to specify
+ @code{volatile} for the @code{asm} construct, as described below.
+ 
  If you refer to a particular hardware register from the assembler code,
  you will probably have to list the register after the third colon to
  tell the compiler the register's value is modified.  In some assemblers,


brgds, H-P
-- 
Hans-Peter Nilsson, Axis Communications AB, S - 223 70 LUND, SWEDEN
Hans-Peter.Nilsson@axis.se | Tel +46 462701867,2701800
Fax +46 46136130 | RFC 1855 compliance implemented; report loss of brain.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]