public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86: prefer specific error messages over more generic ones
@ 2012-07-24 14:25 Jan Beulich
  2012-07-30 16:14 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2012-07-24 14:25 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1650 bytes --]

At the point where check_VecOperands()/VEX_check_operands() get run,
all other instruction attributes already matched, so any mismatch here
will tell the user more precisely what is wrong than using an eventual
(and very likely to occur) more generic error encountered on a
subsequent iteration through the template matching loop.

2012-07-24  Jan Beulich <jbeulich@suse.com>

	* config/tc-i386.c (match_template): New local variable
	'specific_error'. Set it from i.error after failed
	check_VecOperands or VEX_check_operands. Use it if set in
	preference to i.error when actually issuing disagnostic.

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -4015,6 +4015,7 @@ match_template (void)
   unsigned int j;
   unsigned int found_cpu_match;
   unsigned int check_register;
+  enum i386_error specific_error = 0;
 
 #if MAX_OPERANDS != 5
 # error "MAX_OPERANDS must be 5."
@@ -4311,13 +4312,12 @@ check_reverse:
 	  continue;
 	}
 
-      /* Check if vector operands are valid.  */
-      if (check_VecOperands (t))
-	continue;
-
-      /* Check if VEX operands are valid.  */
-      if (VEX_check_operands (t))
-	continue;
+      /* Check if vector and VEX operands are valid.  */
+      if (check_VecOperands (t) || VEX_check_operands (t))
+	{
+	  specific_error = i.error;
+	  continue;
+	}
 
       /* We've found a match; break out of loop.  */
       break;
@@ -4327,7 +4327,7 @@ check_reverse:
     {
       /* We found no match.  */
       const char *err_msg;
-      switch (i.error)
+      switch (specific_error ? specific_error : i.error)
 	{
 	default:
 	  abort ();




[-- Attachment #2: binutils-mainline-x86-specific-error.patch --]
[-- Type: text/plain, Size: 1644 bytes --]

At the point where check_VecOperands()/VEX_check_operands() get run,
all other instruction attributes already matched, so any mismatch here
will tell the user more precisely what is wrong than using an eventual
(and very likely to occur) more generic error encountered on a
subsequent iteration through the template matching loop.

2012-07-24  Jan Beulich <jbeulich@suse.com>

	* config/tc-i386.c (match_template): New local variable
	'specific_error'. Set it from i.error after failed
	check_VecOperands or VEX_check_operands. Use it if set in
	preference to i.error when actually issuing disagnostic.

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -4015,6 +4015,7 @@ match_template (void)
   unsigned int j;
   unsigned int found_cpu_match;
   unsigned int check_register;
+  enum i386_error specific_error = 0;
 
 #if MAX_OPERANDS != 5
 # error "MAX_OPERANDS must be 5."
@@ -4311,13 +4312,12 @@ check_reverse:
 	  continue;
 	}
 
-      /* Check if vector operands are valid.  */
-      if (check_VecOperands (t))
-	continue;
-
-      /* Check if VEX operands are valid.  */
-      if (VEX_check_operands (t))
-	continue;
+      /* Check if vector and VEX operands are valid.  */
+      if (check_VecOperands (t) || VEX_check_operands (t))
+	{
+	  specific_error = i.error;
+	  continue;
+	}
 
       /* We've found a match; break out of loop.  */
       break;
@@ -4327,7 +4327,7 @@ check_reverse:
     {
       /* We found no match.  */
       const char *err_msg;
-      switch (i.error)
+      switch (specific_error ? specific_error : i.error)
 	{
 	default:
 	  abort ();

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86: prefer specific error messages over more generic ones
  2012-07-24 14:25 [PATCH] x86: prefer specific error messages over more generic ones Jan Beulich
@ 2012-07-30 16:14 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2012-07-30 16:14 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On Tue, Jul 24, 2012 at 7:24 AM, Jan Beulich <JBeulich@suse.com> wrote:
> At the point where check_VecOperands()/VEX_check_operands() get run,
> all other instruction attributes already matched, so any mismatch here
> will tell the user more precisely what is wrong than using an eventual
> (and very likely to occur) more generic error encountered on a
> subsequent iteration through the template matching loop.
>
> 2012-07-24  Jan Beulich <jbeulich@suse.com>
>
>         * config/tc-i386.c (match_template): New local variable
>         'specific_error'. Set it from i.error after failed
>         check_VecOperands or VEX_check_operands. Use it if set in
>         preference to i.error when actually issuing disagnostic.
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -4015,6 +4015,7 @@ match_template (void)
>    unsigned int j;
>    unsigned int found_cpu_match;
>    unsigned int check_register;
> +  enum i386_error specific_error = 0;
>
>  #if MAX_OPERANDS != 5
>  # error "MAX_OPERANDS must be 5."
> @@ -4311,13 +4312,12 @@ check_reverse:
>           continue;
>         }
>
> -      /* Check if vector operands are valid.  */
> -      if (check_VecOperands (t))
> -       continue;
> -
> -      /* Check if VEX operands are valid.  */
> -      if (VEX_check_operands (t))
> -       continue;
> +      /* Check if vector and VEX operands are valid.  */
> +      if (check_VecOperands (t) || VEX_check_operands (t))
> +       {
> +         specific_error = i.error;
> +         continue;
> +       }
>
>        /* We've found a match; break out of loop.  */
>        break;
> @@ -4327,7 +4327,7 @@ check_reverse:
>      {
>        /* We found no match.  */
>        const char *err_msg;
> -      switch (i.error)
> +      switch (specific_error ? specific_error : i.error)
>         {
>         default:
>           abort ();

OK.  Please update testsuite if needed.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-30 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-24 14:25 [PATCH] x86: prefer specific error messages over more generic ones Jan Beulich
2012-07-30 16:14 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).