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]

[PATCH] x86: rep prefix handling adjustment


Until now, gas looked just at the first instruction of a series of
identically named ones to determine whether it is a string instruction and
thus accepts the use of a rep prefix. Since that required particular
ordering in the opcode table (without that being said to be so), this
patch adjusts code to have more freedom in the table ordering. At once, it
restricts the set of instructions to choose from to just the string ones
when a rep prefix was specified. As a nice side effect, some diagnostics
get replaced by more meaningful ones.

Built and tested on i686-pc-linux-gnu and x86_64-unknown-linux-gnu.

Jan

gas/
2005-05-06  Jan Beulich  <jbeulich@novell.com>

	* config/tc-i386.c (parse_insn): Consider all matching instructions
	when checking for string instruction after string-only prefix.

--- /home/jbeulich/src/binutils/mainline/2005-05-06/gas/config/tc-i386.c	2005-05-06 08:24:28.000000000 +0200
+++ 2005-05-06/gas/config/tc-i386.c	2005-05-06 11:45:55.861726528 +0200
@@ -1765,12 +1766,24 @@ parse_insn (line, mnemonic)
     }
 
   /* Check for rep/repne without a string instruction.  */
-  if (expecting_string_instruction
-      && !(current_templates->start->opcode_modifier & IsString))
+  if (expecting_string_instruction)
     {
-      as_bad (_("expecting string instruction after `%s'"),
-	      expecting_string_instruction);
-      return NULL;
+      static templates override;
+
+      for (t = current_templates->start; t < current_templates->end; ++t)
+	if (t->opcode_modifier & IsString)
+	  break;
+      if (t >= current_templates->end)
+	{
+	  as_bad (_("expecting string instruction after `%s'"),
+	        expecting_string_instruction);
+	  return NULL;
+	}
+      for (override.start = t; t < current_templates->end; ++t)
+	if (!(t->opcode_modifier & IsString))
+	  break;
+      override.end = t;
+      current_templates = &override;
     }
 
   return l;


Attachment: binutils-mainline-x86-string-prefix.patch
Description: Text document


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