public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86: make "-msyntax=intel -mnaked-reg" match ".intel_syntax noprefix"
@ 2024-01-19 10:49 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2024-01-19 10:49 UTC (permalink / raw)
  To: Binutils; +Cc: H.J. Lu, LIU Hao

Adjustments made for the directive (by set_intel_syntax()) need also
making for the command line option. Break out respective code into a new
helper function, to also be invoked during command line processing.
Further also set register_prefix when processing -mnaked-reg.
---
If we wanted to also generalize the bfd_get_symbol_leading_char()
dependency, we'd need to defer processing until at least
tc_init_after_args(), perhaps md_begin().

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2708,6 +2708,16 @@ set_16bit_gcc_code_flag (int new_code_fl
 }
 
 static void
+_set_intel_syntax (int syntax_flag)
+{
+  intel_syntax = syntax_flag;
+
+  expr_set_rank (O_full_ptr, syntax_flag ? 10 : 0);
+
+  register_prefix = allow_naked_reg ? "" : "%";
+}
+
+static void
 set_intel_syntax (int syntax_flag)
 {
   /* Find out if register prefixing is specified.  */
@@ -2729,17 +2739,13 @@ set_intel_syntax (int syntax_flag)
     }
   demand_empty_rest_of_line ();
 
-  intel_syntax = syntax_flag;
-
   if (ask_naked_reg == 0)
-    allow_naked_reg = (intel_syntax
+    allow_naked_reg = (syntax_flag
 		       && (bfd_get_symbol_leading_char (stdoutput) != '\0'));
   else
     allow_naked_reg = (ask_naked_reg < 0);
 
-  expr_set_rank (O_full_ptr, syntax_flag ? 10 : 0);
-
-  register_prefix = allow_naked_reg ? "" : "%";
+  _set_intel_syntax (syntax_flag);
 }
 
 static void
@@ -15212,9 +15218,9 @@ md_parse_option (int c, const char *arg)
 
     case OPTION_MSYNTAX:
       if (strcasecmp (arg, "att") == 0)
-	intel_syntax = 0;
+	_set_intel_syntax (0);
       else if (strcasecmp (arg, "intel") == 0)
-	intel_syntax = 1;
+	_set_intel_syntax (1);
       else
 	as_fatal (_("invalid -msyntax= option: `%s'"), arg);
       break;
@@ -15225,6 +15231,7 @@ md_parse_option (int c, const char *arg)
 
     case OPTION_MNAKED_REG:
       allow_naked_reg = 1;
+      register_prefix = "";
       break;
 
     case OPTION_MSSE2AVX:
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -66,6 +66,7 @@ if [gas_32_check] then {
     run_dump_test "intel16"
     run_list_test "intelbad" ""
     run_dump_test "intelok"
+    run_dump_test "intelok2"
     run_dump_test "prefix"
     run_list_test "prefix32" "-al"
     run_dump_test "insn-32"
--- a/gas/testsuite/gas/i386/intelok.d
+++ b/gas/testsuite/gas/i386/intelok.d
@@ -1,6 +1,6 @@
-#as: -J --divide
+#as: -J --divide --defsym USE_DIRECTIVE=1
 #objdump: -dwMintel
-#name: i386 intel-ok
+#name: i386 intel-ok (directive)
 #warning_output: intelok.e
 
 .*: +file format .*
--- a/gas/testsuite/gas/i386/intelok.e
+++ b/gas/testsuite/gas/i386/intelok.e
@@ -1,2 +1,2 @@
 .*: Assembler messages:
-.*:155: Warning: redundant segment overrides
+.*:157: Warning: redundant segment overrides
--- a/gas/testsuite/gas/i386/intelok.s
+++ b/gas/testsuite/gas/i386/intelok.s
@@ -1,4 +1,6 @@
+	.ifdef USE_DIRECTIVE
 	.intel_syntax noprefix
+	.endif
 	.text
 start:
 
--- /dev/null
+++ b/gas/testsuite/gas/i386/intelok2.d
@@ -0,0 +1,6 @@
+#as: -J --divide -msyntax=intel -mnaked-reg
+#objdump: -dwMintel
+#name: i386 intel-ok (cmdline option)
+#source: intelok.s
+#dump: intelok.d
+#warning_output: intelok.e

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

only message in thread, other threads:[~2024-01-19 10:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19 10:49 [PATCH] x86: make "-msyntax=intel -mnaked-reg" match ".intel_syntax noprefix" 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).