]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: actually implement .noopt
authorJan Beulich <jbeulich@suse.com>
Fri, 2 Feb 2024 07:26:22 +0000 (08:26 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 2 Feb 2024 07:26:22 +0000 (08:26 +0100)
For quite some time we've had support for -O command line options. With
that ignoring at least .noopt isn't really a good idea.

Re-purpose the optimize-3 test for testing this directive's effect as
well.

As to the doc addition - this uses the same text as is there for the
{nooptimize} pseudo-prefix, despite me not being convinced of the "size"
part being fully accurate there (and hence also here).

gas/config/tc-i386.c
gas/doc/c-i386.texi
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/noopt.d [new file with mode: 0644]
gas/testsuite/gas/i386/noopt.s [new file with mode: 0644]
gas/testsuite/gas/i386/optimize-3.d
gas/testsuite/gas/i386/optimize-3.s

index 2e578e2b0d7b95201a04d16940567b7449d59057..e091b864e03100c6b3ba15825a02298a2182823a 100644 (file)
@@ -140,6 +140,7 @@ arch_entry;
 
 static void update_code_flag (int, int);
 static void s_insn (int);
+static void s_noopt (int);
 static void set_code_flag (int);
 static void set_16bit_gcc_code_flag (int);
 static void set_intel_syntax (int);
@@ -1232,7 +1233,7 @@ const pseudo_typeS md_pseudo_table[] =
   {"value", cons, 2},
   {"slong", signed_cons, 4},
   {"insn", s_insn, 0},
-  {"noopt", s_ignore, 0},
+  {"noopt", s_noopt, 0},
   {"optim", s_ignore, 0},
   {"code16gcc", set_16bit_gcc_code_flag, CODE_16BIT},
   {"code16", set_code_flag, CODE_16BIT},
@@ -4999,6 +5000,18 @@ optimize_encoding (void)
     }
 }
 
+static void
+s_noopt (int dummy ATTRIBUTE_UNUSED)
+{
+  if (!is_it_end_of_statement ())
+    as_warn (_("`.noopt' arguments ignored"));
+
+  optimize = 0;
+  optimize_for_space = 0;
+
+  ignore_rest_of_line ();
+}
+
 /* Return non-zero for load instruction.  */
 
 static int
index 063a9e7e9dc10612006028dc3edfdd037558348d..3d2d28feff0f90554c4d07d48d9492c051a3a9d1 100644 (file)
@@ -763,6 +763,10 @@ be suffixed by @code{@{:d@var{n}@}} to specify the size (in bytes).
 This can be combined with an embedded broadcast specifier:
 @samp{8(%eax)@{1to8:d8@}}.
 
+@cindex @code{noopt} directive
+@item .noopt
+Disable instruction size optimization.
+
 @c FIXME: Document other x86 specific directives ?  Eg: .code16gcc,
 
 @end table
index 46689a80fcf8a39c8f6c4ab3cf96ad04ced0d803..2584c69bddc5bcf7918b7abde3a82419b31c9b17 100644 (file)
@@ -615,6 +615,7 @@ if [gas_32_check] then {
     run_list_test "optimize-6a" "-I${srcdir}/$subdir -march=+noavx -al"
     run_dump_test "optimize-6b"
     run_list_test "optimize-7" "-I${srcdir}/$subdir -march=+noavx2 -al"
+    run_dump_test "noopt"
     run_dump_test "lea-optimize"
     run_dump_test "lea16-optimize"
     run_dump_test "lea16-optimize2"
diff --git a/gas/testsuite/gas/i386/noopt.d b/gas/testsuite/gas/i386/noopt.d
new file mode 100644 (file)
index 0000000..940780f
--- /dev/null
@@ -0,0 +1,4 @@
+#as: -Os -I${srcdir}/$subdir
+#objdump: -drw
+#name: .noopt directive
+#dump: optimize-3.d
diff --git a/gas/testsuite/gas/i386/noopt.s b/gas/testsuite/gas/i386/noopt.s
new file mode 100644 (file)
index 0000000..a93c87c
--- /dev/null
@@ -0,0 +1,2 @@
+       .noopt
+       .include "optimize-3.s"
index 3a6fa062161d5f07141afb5d2662a72676828c28..94260983754d4b24428d8e78a16472e1199d98ad 100644 (file)
@@ -1,4 +1,4 @@
-#as: -Os
+#as: -Os --defsym USE_PREFIX=1
 #objdump: -drw
 #name: optimized encoding 3 with -Os
 
index badb89546035bb70888f4c680b25db00d5904d4c..b809b9ffa00b346fc832fa238900f09fa8f3180b 100644 (file)
@@ -1,24 +1,32 @@
 # Check instructions with optimized encoding
 
+       .macro noopt insn:vararg
+       .ifdef USE_PREFIX
+       {nooptimize} \insn
+       .else
+       \insn
+       .endif
+       .endm
+
        .text
 _start:
-       {nooptimize} testl $0x7f, %eax
+       noopt testl $0x7f, %eax
 
-       {nooptimize} lock xchg  %ecx, (%edx)
-       {nooptimize} lock xchg  (%ecx), %edx
+       noopt lock xchg %ecx, (%edx)
+       noopt lock xchg (%ecx), %edx
 
-       {nooptimize} vmovdqa32  %ymm1, %ymm2
-       {nooptimize} vmovdqa64  %ymm1, %ymm2
-       {nooptimize} vmovdqu8   %xmm1, %xmm2
-       {nooptimize} vmovdqu16  %xmm1, %xmm2
-       {nooptimize} vmovdqu32  %xmm1, %xmm2
-       {nooptimize} vmovdqu64  %xmm1, %xmm2
+       noopt vmovdqa32 %ymm1, %ymm2
+       noopt vmovdqa64 %ymm1, %ymm2
+       noopt vmovdqu8  %xmm1, %xmm2
+       noopt vmovdqu16 %xmm1, %xmm2
+       noopt vmovdqu32 %xmm1, %xmm2
+       noopt vmovdqu64 %xmm1, %xmm2
 
-       {nooptimize} vpandd     %xmm2, %xmm3, %xmm4
-       {nooptimize} vpandq     %ymm2, %ymm3, %ymm4
-       {nooptimize} vpandnd    %ymm2, %ymm3, %ymm4
-       {nooptimize} vpandnq    %xmm2, %xmm3, %xmm4
-       {nooptimize} vpord      %xmm2, %xmm3, %xmm4
-       {nooptimize} vporq      %ymm2, %ymm3, %ymm4
-       {nooptimize} vpxord     %ymm2, %ymm3, %ymm4
-       {nooptimize} vpxorq     %xmm2, %xmm3, %xmm4
+       noopt vpandd    %xmm2, %xmm3, %xmm4
+       noopt vpandq    %ymm2, %ymm3, %ymm4
+       noopt vpandnd   %ymm2, %ymm3, %ymm4
+       noopt vpandnq   %xmm2, %xmm3, %xmm4
+       noopt vpord     %xmm2, %xmm3, %xmm4
+       noopt vporq     %ymm2, %ymm3, %ymm4
+       noopt vpxord    %ymm2, %ymm3, %ymm4
+       noopt vpxorq    %xmm2, %xmm3, %xmm4