public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7154] i386: Fix up z operand modifier diagnostics on inline-asm [PR109458]
@ 2023-04-12 14:54 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-04-12 14:54 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4073ce2c4e5584c1be58fbe76dd66285de2529bb

commit r13-7154-g4073ce2c4e5584c1be58fbe76dd66285de2529bb
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Apr 12 16:53:23 2023 +0200

    i386: Fix up z operand modifier diagnostics on inline-asm [PR109458]
    
    On the following testcase, we emit weird diagnostics.
    User used the z modifier, but diagnostics talks about Z instead.
    This is because z is implemented by doing some stuff and then falling
    through into the Z case.
    
    The following patch adjusts the Z diagnostics, such that it prints whatever
    modifier user actually uses in places which could happen with either
    modifier.
    
    Furthermore, in case of the non-integer operand used with operand code %<z%>
    warning the warning location was incorrect (and of function), so I've used
    warning_for_asm to get it a proper location in case it is a user inline-asm.
    
    2023-04-12  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/109458
            * config/i386/i386.cc: Include rtl-error.h.
            (ix86_print_operand): For z modifier warning, use warning_for_asm
            if this_is_asm_operands.  For Z modifier errors, use %c and code
            instead of hardcoded Z.
    
            * gcc.target/i386/pr109458.c: New test.

Diff:
---
 gcc/config/i386/i386.cc                  | 14 +++++++++++---
 gcc/testsuite/gcc.target/i386/pr109458.c | 13 +++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 2581b800a06..fbd33a6bfd1 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -96,6 +96,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "i386-expand.h"
 #include "i386-features.h"
 #include "function-abi.h"
+#include "rtl-error.h"
 
 /* This file should be included last.  */
 #include "target-def.h"
@@ -13218,7 +13219,13 @@ ix86_print_operand (FILE *file, rtx x, int code)
 	    }
 
 	  if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
-	    warning (0, "non-integer operand used with operand code %<z%>");
+	    {
+	      if (this_is_asm_operands)
+		warning_for_asm (this_is_asm_operands,
+				 "non-integer operand used with operand code %<z%>");
+	      else
+		warning (0, "non-integer operand used with operand code %<z%>");
+	    }
 	  /* FALLTHRU */
 
 	case 'Z':
@@ -13281,11 +13288,12 @@ ix86_print_operand (FILE *file, rtx x, int code)
 	  else
 	    {
 	      output_operand_lossage ("invalid operand type used with "
-				      "operand code 'Z'");
+				      "operand code '%c'", code);
 	      return;
 	    }
 
-	  output_operand_lossage ("invalid operand size for operand code 'Z'");
+	  output_operand_lossage ("invalid operand size for operand code '%c'",
+				  code);
 	  return;
 
 	case 'd':
diff --git a/gcc/testsuite/gcc.target/i386/pr109458.c b/gcc/testsuite/gcc.target/i386/pr109458.c
new file mode 100644
index 00000000000..abd0ed22211
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr109458.c
@@ -0,0 +1,13 @@
+/* PR target/109458 */
+/* { dg-do compile } */
+/* { dg-options "-msse2" } */
+
+void
+foo (_Float16 x)
+{
+  asm volatile ("# %z0" : : "i" (42));	/* { dg-error "invalid 'asm': invalid operand type used with operand code 'z'" } */
+  asm volatile ("# %Z0" : : "i" (42));	/* { dg-error "invalid 'asm': invalid operand type used with operand code 'Z'" } */
+  asm volatile ("# %z0" : : "x" (x));	/* { dg-error "invalid 'asm': invalid operand size for operand code 'z'" } */
+					/* { dg-warning "non-integer operand used with operand code 'z'" "" { target *-*-* } .-1 } */
+  asm volatile ("# %Z0" : : "x" (x));	/* { dg-error "invalid 'asm': invalid operand size for operand code 'Z'" } */
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-12 14:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 14:54 [gcc r13-7154] i386: Fix up z operand modifier diagnostics on inline-asm [PR109458] Jakub Jelinek

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).