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]

asm constraint rule change


The recent asm checking patches have tightened the rules such that output
constraints like "r=" are no longer valid.  The problem is that there is
a largish body of code that writes things that way.  More to the point,
despite all the examples running about the documentation, it does not ever
come out and specify this as a rule.  It merely says 

	... all output operands' constraints must use `='.

So this change is gonna piss some folks off, and with reason.

I suggest we adopt the following patch to loosen this rule again.


r~


	* stmt.c (expand_asm_operands): Accept `=' or `+' at any position.

Index: stmt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/stmt.c,v
retrieving revision 1.50
diff -c -p -d -r1.50 stmt.c
*** stmt.c	1998/10/13 15:25:18	1.50
--- stmt.c	1998/10/17 02:26:57
*************** expand_asm_operands (string, outputs, in
*** 1224,1229 ****
--- 1224,1230 ----
        tree val = TREE_VALUE (tail);
        tree type = TREE_TYPE (val);
        char *constraint;
+       char *p;
        int c_len;
        int j;
        int is_inout = 0;
*************** expand_asm_operands (string, outputs, in
*** 1241,1251 ****
        c_len = TREE_STRING_LENGTH (TREE_PURPOSE (tail)) - 1;
        constraint = TREE_STRING_POINTER (TREE_PURPOSE (tail));
  
!       if (c_len == 0
! 	  || (constraint[0] != '=' && constraint[0] != '+'))
  	{
  	  error ("output operand constraint lacks `='");
  	  return;
  	}
  
        is_inout = constraint[0] == '+';
--- 1242,1268 ----
        c_len = TREE_STRING_LENGTH (TREE_PURPOSE (tail)) - 1;
        constraint = TREE_STRING_POINTER (TREE_PURPOSE (tail));
  
!       /* Allow the `=' or `+' to not be at the beginning of the string,
! 	 since it wasn't explicitly documented that way, and there is a
! 	 large body of code that puts it last.  Swap the character to
! 	 the front, so as not to uglify any place else.  */
!       switch (c_len)
  	{
+ 	default:
+ 	  if ((p = strchr (constraint, '=')) != NULL)
+ 	    break;
+ 	  if ((p = strchr (constraint, '+')) != NULL)
+ 	    break;
+ 	case 0:
  	  error ("output operand constraint lacks `='");
  	  return;
+ 	}
+ 
+       if (p != constraint)
+ 	{
+ 	  j = *p;
+ 	  bcopy (constraint, constraint+1, p-constraint);
+ 	  *constraint = j;
  	}
  
        is_inout = constraint[0] == '+';


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