public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] x86: move / quiesce pre-386 non-16-bit warning
@ 2022-08-18  7:20 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2022-08-18  7:20 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d59a54c2c350ba65c65dde5e2a8976918ac59046

commit d59a54c2c350ba65c65dde5e2a8976918ac59046
Author: Jan Beulich <jbeulich@suse.com>
Date:   Thu Aug 18 09:20:05 2022 +0200

    x86: move / quiesce pre-386 non-16-bit warning
    
    Emitting this warning for every insn, including ones having actual
    errors, is annoying. Introduce a boolean variable to emit the warning
    just once on the first insn after .arch may have changed the things, and
    move the warning to output_insn(). (I didn't want to go as far as
    checking whether the .arch actually turned off the i386 bit, but doing
    so would be an option.)

Diff:
---
 gas/config/tc-i386.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 3c0b73f26a6..6598b0e52f1 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -765,6 +765,9 @@ int optimize_align_code = 1;
 /* Non-zero to quieten some warnings.  */
 static int quiet_warnings = 0;
 
+/* Guard to avoid repeated warnings about non-16-bit code on 16-bit CPUs.  */
+static bool pre_386_16bit_warned;
+
 /* CPU name.  */
 static const char *cpu_arch_name = NULL;
 static char *cpu_sub_arch_name = NULL;
@@ -2809,6 +2812,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
 		      cpu_arch_tune = cpu_arch_isa;
 		      cpu_arch_tune_flags = cpu_arch_isa_flags;
 		    }
+		  pre_386_16bit_warned = false;
 		  break;
 		}
 
@@ -5486,12 +5490,7 @@ parse_insn (char *line, char *mnemonic)
     {
       supported |= cpu_flags_match (t);
       if (supported == CPU_FLAGS_PERFECT_MATCH)
-	{
-	  if (!cpu_arch_flags.bitfield.cpui386 && (flag_code != CODE_16BIT))
-	    as_warn (_("use .code16 to ensure correct addressing mode"));
-
-	  return l;
-	}
+	return l;
     }
 
   if (!(supported & CPU_FLAGS_64BIT_MATCH))
@@ -9541,6 +9540,13 @@ output_insn (void)
       fragP->tc_frag_data.max_bytes = max_branch_padding_size;
     }
 
+  if (!cpu_arch_flags.bitfield.cpui386 && (flag_code != CODE_16BIT)
+      && !pre_386_16bit_warned)
+    {
+      as_warn (_("use .code16 to ensure correct addressing mode"));
+      pre_386_16bit_warned = true;
+    }
+
   /* Output jumps.  */
   if (i.tm.opcode_modifier.jump == JUMP)
     output_branch ();

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

only message in thread, other threads:[~2022-08-18  7:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18  7:20 [binutils-gdb] x86: move / quiesce pre-386 non-16-bit warning Jan Beulich

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