This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Committed, tc-mmix.c, relax2.s: fix PR binutils/886


Note that ":" at the end of a label definition is considered special and
not part of the label name (despite ':' being in tc_symbol_chars), a
special-casing which is not performed in the MMIX port, thank you.
Well, unless you move that code into a macro and specify the label using
a macro parameter, as "\x:" in the macro.  Then you suddenly notice a
difference: the ":" is now treated as part of the macro parameter *name*.
Somewhat surprising, albeit more consistent with the ":" being in
tc_symbol_chars.  That is, unless you're of the opinion that only
[A-Za-z0-9_] should be accepted in a macro parameter *name*, exactly to
avoid this kind of incompatible macro treatment due to differences in
target symbol handling.  (You may laugh at the thought of assembler macros
portable across targets, but the actual instructions would be macros
themselves, supplied by the port.)  Also tested with the gcc testsuites.

gas:
	* config/tc-mmix.c (mmix_handle_mmixal): Rearrange slightly.
	Handle label-without-colon before ordinary dot-pseudo as an
	ordinary label.  Don't leak memory for label-without-colon alone
	on a line.  Don't mmixal-munge operands for dot-pseudos.


gas/testsuite:
	* gas/mmix/relax2.s: Drop ":" off label definitions.

Index: relax2.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mmix/relax2.s,v
retrieving revision 1.1
diff -p -u -r1.1 relax2.s
--- relax2.s	18 Oct 2003 16:00:21 -0000	1.1
+++ relax2.s	10 May 2005 11:49:40 -0000
@@ -1,33 +1,39 @@
 # PUSHJ stub border-cases: two with either or both stubs unreachable,
 # local symbols, ditto non-local labels, similar with three PUSHJs.
+# Note the absence of ":" on labels: because it's a symbol-character,
+# it's concatenated with the parameter macro name and parsed as "\x:".
+# This happens before gas deals with ":" as it usually does; not being
+# part of the name when ending a label at the beginning of a line.
+# (Since we're LABELS_WITHOUT_COLONS it inserts one for us, but
+# that would be disabled with --gnu-syntax.)

 Main	SWYM

 	.irp x,0,1,2,3,4,5,6,7,8,9,10,11,12

 	.section .text.a\x,"ax"
-aa\x:	.space 4,0
-a\x:	.space 65536*4,0
+aa\x	.space 4,0
+a\x	.space 65536*4,0
 	PUSHJ $33,aa\x
 	PUSHJ $22,a\x
 	.space 65535*4-4*\x

 	.section .text.b\x,"ax"
-bbb\x:	.space 4,0
-bb\x:	.space 4,0
-b\x:	.space 65535*4
+bbb\x	.space 4,0
+bb\x	.space 4,0
+b\x	.space 65535*4
 	PUSHJ $12,bbb\x
 	PUSHJ $13,bb\x
 	PUSHJ $14,b\x
 	.space 65535*4-4*\x

 	.section .text.c\x,"ax"
-c\x:	PUSHJ $100,ca\x
+c\x	PUSHJ $100,ca\x
 	PUSHJ $101,cb\x
 	.space 65535*4-4*\x

 	.section .text.d\x,"ax"
-d\x:	PUSHJ $99,da\x
+d\x	PUSHJ $99,da\x
 	PUSHJ $98,db\x
 	PUSHJ $97,dc\x
 	.space 65535*4-4*\x
Index: tc-mmix.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mmix.c,v
retrieving revision 1.23
diff -p -u -r1.23 tc-mmix.c
--- tc-mmix.c	5 May 2005 09:13:01 -0000	1.23
+++ tc-mmix.c	10 May 2005 11:58:37 -0000
@@ -2900,8 +2900,8 @@ tc_gen_reloc (asection *section ATTRIBUT
 void
 mmix_handle_mmixal (void)
 {
-  char *s0 = input_line_pointer;
-  char *s;
+  char *insn;
+  char *s = input_line_pointer;
   char *label = NULL;
   char c;

@@ -2911,44 +2911,20 @@ mmix_handle_mmixal (void)
   if (mmix_gnu_syntax)
     return;

-  /* If the first character is a '.', then it's a pseudodirective, not a
-     label.  Make GAS not handle label-without-colon on this line.  We
-     also don't do mmixal-specific stuff on this line.  */
-  if (input_line_pointer[0] == '.')
-    {
-      label_without_colon_this_line = 0;
-      return;
-    }
-
-  /* Don't handle empty lines here.  */
-  while (1)
-    {
-      if (*s0 == 0 || is_end_of_line[(unsigned int) *s0])
-	return;
-
-      if (! ISSPACE (*s0))
-	break;
-
-      s0++;
-    }
-
   /* If we're on a line with a label, check if it's a mmixal fb-label.
      Save an indicator and skip the label; it must be set only after all
      fb-labels of expressions are evaluated.  */
-  if (ISDIGIT (input_line_pointer[0])
-      && input_line_pointer[1] == 'H'
-      && ISSPACE (input_line_pointer[2]))
+  if (ISDIGIT (s[0]) && s[1] == 'H' && ISSPACE (s[2]))
     {
-      char *s;
-      current_fb_label = input_line_pointer[0] - '0';
+      current_fb_label = s[0] - '0';

       /* We have to skip the label, but also preserve the newlineness of
 	 the previous character, since the caller checks that.  It's a
 	 mess we blame on the caller.  */
-      input_line_pointer[1] = input_line_pointer[-1];
-      input_line_pointer += 2;
+      s[1] = s[-1];
+      s += 2;
+      input_line_pointer = s;

-      s = input_line_pointer;
       while (*s && ISSPACE (*s) && ! is_end_of_line[(unsigned int) *s])
 	s++;

@@ -2972,32 +2948,61 @@ mmix_handle_mmixal (void)
 			_("[0-9]H labels do not mix with dot-pseudos"));
 	  current_fb_label = -1;
 	}
+
+      /* Back off to the last space before the opcode so we don't handle
+	 the opcode as a label.  */
+      s--;
     }
   else
+    current_fb_label = -1;
+
+  if (*s == '.')
     {
-      current_fb_label = -1;
-      if (is_name_beginner (input_line_pointer[0]))
-	label = input_line_pointer;
-    }
-
-  s0 = input_line_pointer;
-  /* Skip over label.  */
-  while (*s0 && is_part_of_name (*s0))
-    s0++;
-
-  /* Remove trailing ":" off labels, as they'd otherwise be considered
-     part of the name.  But don't do it for local labels.  */
-  if (s0 != input_line_pointer && s0[-1] == ':'
-      && (s0 - 2 != input_line_pointer
-	  || ! ISDIGIT (s0[-2])))
-    s0[-1] = ' ';
-  else if (label != NULL)
+      /* If the first character is a '.', then it's a pseudodirective, not a
+	 label.  Make GAS not handle label-without-colon on this line.  We
+	 also don't do mmixal-specific stuff on this line.  */
+      label_without_colon_this_line = 0;
+      return;
+    }
+
+  if (*s == 0 || is_end_of_line[(unsigned int) *s])
+    /* We avoid handling empty lines here.  */
+    return;
+
+  if (is_name_beginner (*s))
+    label = s;
+
+  /* If there is a label, skip over it.  */
+  while (*s && is_part_of_name (*s))
+    s++;
+
+  /* Find the start of the instruction or pseudo following the label,
+     if there is one.  */
+  for (insn = s;
+       *insn && ISSPACE (*insn) && ! is_end_of_line[(unsigned int) *insn];
+       insn++)
+    /* Empty */
+    ;
+
+  /* Remove a trailing ":" off labels, as they'd otherwise be considered
+     part of the name.  But don't do this for local labels.  */
+  if (s != input_line_pointer && s[-1] == ':'
+      && (s - 2 != input_line_pointer
+	  || ! ISDIGIT (s[-2])))
+    s[-1] = ' ';
+  else if (label != NULL
+	   /* For a lone label on a line, we don't attach it to the next
+	      instruction or MMIXAL-pseudo (getting its alignment).  Thus
+	      is acts like a "normal" :-ended label.  Ditto if it's
+	      followed by a non-MMIXAL pseudo.  */
+	   && !is_end_of_line[(unsigned int) *insn]
+	   && *insn != '.')
     {
       /* For labels that don't end in ":", we save it so we can later give
 	 it the same alignment and address as the associated instruction.  */

       /* Make room for the label including the ending nul.  */
-      int len_0 = s0 - label + 1;
+      int len_0 = s - label + 1;

       /* Save this label on the MMIX symbol obstack.  Saving it on an
 	 obstack is needless for "IS"-pseudos, but it's harmless and we
@@ -3007,14 +3012,10 @@ mmix_handle_mmixal (void)
       pending_label[len_0 - 1] = 0;
     }

-  while (*s0 && ISSPACE (*s0) && ! is_end_of_line[(unsigned int) *s0])
-    s0++;
-
-  if (pending_label != NULL && is_end_of_line[(unsigned int) *s0])
-    /* Whoops, this was actually a lone label on a line.  Like :-ended
-       labels, we don't attach such labels to the next instruction or
-       pseudo.  */
-    pending_label = NULL;
+  /* If we have a non-MMIXAL pseudo, we have not business with the rest of
+     the line.  */
+  if (*insn == '.')
+    return;

   /* Find local labels of operands.  Look for "[0-9][FB]" where the
      characters before and after are not part of words.  Break if a single
@@ -3026,7 +3027,6 @@ mmix_handle_mmixal (void)

   /* First make sure we don't have any of the magic characters on the line
      appearing as input.  */
-  s = s0;
   while (*s)
     {
       c = *s++;
@@ -3037,7 +3037,7 @@ mmix_handle_mmixal (void)
     }

   /* Scan again, this time looking for ';' after operands.  */
-  s = s0;
+  s = insn;

   /* Skip the insn.  */
   while (*s
@@ -3103,7 +3103,7 @@ mmix_handle_mmixal (void)

   /* Make IS into an EQU by replacing it with "= ".  Only match upper-case
      though; let lower-case be a syntax error.  */
-  s = s0;
+  s = insn;
   if (s[0] == 'I' && s[1] == 'S' && ISSPACE (s[2]))
     {
       *s = '=';

brgds, H-P


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