From: Jan Beulich Date: Thu, 18 Aug 2022 07:20:05 +0000 (+0200) Subject: x86: move / quiesce pre-386 non-16-bit warning X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d59a54c2c350ba65c65dde5e2a8976918ac59046;p=binutils-gdb.git 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 --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 ();