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]
Other format: [Raw text]

"+m" constraints bogus?


Hi,
The following bit of documentation:
> From: Satyam Sharma <ssatyam@cse.iitk.ac.in>
> 
> [3/8] i386: bitops: Rectify bogus "+m" constraints
> 
> >From the gcc manual:
> 
>   Extended asm supports input-output or read-write operands. Use the
>   constraint character `+' to indicate such an operand and list it with
>   the output operands. You should only use read-write operands when the
>   constraints for the operand (or the operand in which only some of the
>   bits are to be changed) allow a register.
> 
> So, using the "+" constraint modifier for memory, like "+m" is bogus.
> We must simply specify "=m" which handles the case correctly.

seems to instruct people to use just output constraint for memory
references that are read/write:
> @@ -42,7 +42,7 @@ static inline void set_bit(int nr, volatile unsigned long * addr)
>  {
>  	__asm__ __volatile__( LOCK_PREFIX
>  		"btsl %1,%0"
> -		:"+m" (ADDR)
> +		:"=m" (ADDR)
>  		:"r" (nr));
>  }

Linux kernel is using input/output memory constraints for a while and I
am not quite sure why the documentation above insist on a register.
Obviously having input/output constant is bogus, but for memory the
meaning is clear.  We used to have problems with reload producing
different memory address for input and output variant resulting in ICE,
but I believe this problem has been fixed for a while.  What about
updating docs like this?

Honza

Index: extend.texi
===================================================================
*** extend.texi	(revision 126800)
--- extend.texi	(working copy)
*************** operands.  Use the constraint character 
*** 4224,4230 ****
  operand and list it with the output operands.  You should only use
  read-write operands when the constraints for the operand (or the
  operand in which only some of the bits are to be changed) allow a
! register.
  
  You may, as an alternative, logically split its function into two
  separate operands, one input operand and one write-only output
--- 4224,4230 ----
  operand and list it with the output operands.  You should only use
  read-write operands when the constraints for the operand (or the
  operand in which only some of the bits are to be changed) allow a
! register or memory.
  
  You may, as an alternative, logically split its function into two
  separate operands, one input operand and one write-only output


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