* [binutils-gdb] x86: respect ".arch nonop" when selecting which NOPs to emit
@ 2023-10-23 8:34 Jan Beulich
0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-10-23 8:34 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cd75cd859e58ff7161871849c59f01e9df3cdbc3
commit cd75cd859e58ff7161871849c59f01e9df3cdbc3
Author: Jan Beulich <jbeulich@suse.com>
Date: Mon Oct 23 10:32:32 2023 +0200
x86: respect ".arch nonop" when selecting which NOPs to emit
Making GENERIC64 a special case was never correct; prior to the
generalization of ".arch .no*" to cover all ISA extensions other
processor families supporting long NOPs should have been covered as
well. When introducing ".arch .nonops" (among others) it wasn't
apparent that a hidden implication of .cpunop not being possible to
separately turn off existed here. Seeing that the two large case label
blocks in the 2nd switch() already had identical behavior, simply
collapse all of the (useful) case labels into a single "default" one.
Diff:
---
gas/config/tc-i386.c | 35 ++++++---------------------
gas/config/tc-i386.h | 3 +++
gas/testsuite/gas/i386/x86-64-nops-1a-core2.d | 5 ++++
gas/testsuite/gas/i386/x86-64-nops-1a-g64.d | 5 ++++
gas/testsuite/gas/i386/x86-64.exp | 2 ++
5 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index b8df4e949a4..d936252ce88 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -802,7 +802,7 @@ static const char *cpu_arch_name = NULL;
static char *cpu_sub_arch_name = NULL;
/* CPU feature flags. */
-static i386_cpu_flags cpu_arch_flags = CPU_UNKNOWN_FLAGS;
+i386_cpu_flags cpu_arch_flags = CPU_UNKNOWN_FLAGS;
/* If we have selected a cpu we are generating instructions for. */
static int cpu_arch_tune_set = 0;
@@ -1463,7 +1463,8 @@ i386_generate_nops (fragS *fragP, char *where, offsetT count, int limit)
patt = fragP->tc_frag_data.code == CODE_64BIT ? f64_patt : f32_patt;
if (fragP->tc_frag_data.isa == PROCESSOR_UNKNOWN)
{
- /* PROCESSOR_UNKNOWN means that all ISAs may be used. */
+ /* PROCESSOR_UNKNOWN means that all ISAs may be used, unless
+ explicitly disabled. */
switch (fragP->tc_frag_data.tune)
{
case PROCESSOR_UNKNOWN:
@@ -1485,8 +1486,10 @@ i386_generate_nops (fragS *fragP, char *where, offsetT count, int limit)
case PROCESSOR_BD:
case PROCESSOR_ZNVER:
case PROCESSOR_BT:
- patt = alt_patt;
+ if (fragP->tc_frag_data.cpunop)
+ patt = alt_patt;
break;
+
case PROCESSOR_I386:
case PROCESSOR_I486:
case PROCESSOR_PENTIUM:
@@ -1508,35 +1511,13 @@ i386_generate_nops (fragS *fragP, char *where, offsetT count, int limit)
abort ();
break;
- case PROCESSOR_I386:
- case PROCESSOR_I486:
- case PROCESSOR_PENTIUM:
- case PROCESSOR_IAMCU:
- case PROCESSOR_K6:
- case PROCESSOR_ATHLON:
- case PROCESSOR_K8:
- case PROCESSOR_AMDFAM10:
- case PROCESSOR_BD:
- case PROCESSOR_ZNVER:
- case PROCESSOR_BT:
- case PROCESSOR_GENERIC32:
+ default:
/* We use cpu_arch_isa_flags to check if we CAN optimize
with nops. */
if (fragP->tc_frag_data.isa_flags.bitfield.cpunop)
patt = alt_patt;
break;
- case PROCESSOR_PENTIUMPRO:
- case PROCESSOR_PENTIUM4:
- case PROCESSOR_NOCONA:
- case PROCESSOR_CORE:
- case PROCESSOR_CORE2:
- case PROCESSOR_COREI7:
- if (fragP->tc_frag_data.isa_flags.bitfield.cpunop)
- patt = alt_patt;
- break;
- case PROCESSOR_GENERIC64:
- patt = alt_patt;
- break;
+
case PROCESSOR_NONE:
abort ();
}
diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h
index d49a0def3cc..696e519ed49 100644
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -260,6 +260,7 @@ enum processor_type
PROCESSOR_NONE
};
+extern i386_cpu_flags cpu_arch_flags;
extern enum processor_type cpu_arch_tune;
extern enum processor_type cpu_arch_isa;
extern i386_cpu_flags cpu_arch_isa_flags;
@@ -295,6 +296,7 @@ struct i386_tc_frag_data
unsigned int mf_type : 3;
unsigned int classified : 1;
unsigned int branch_type : 3;
+ unsigned int cpunop : 1;
};
/* We need to emit the right NOP pattern in .align frags. This is
@@ -310,6 +312,7 @@ struct i386_tc_frag_data
(FRAGP)->tc_frag_data.isa = cpu_arch_isa; \
(FRAGP)->tc_frag_data.isa_flags = cpu_arch_isa_flags; \
(FRAGP)->tc_frag_data.tune = cpu_arch_tune; \
+ (FRAGP)->tc_frag_data.cpunop = cpu_arch_flags.bitfield.cpunop; \
(FRAGP)->tc_frag_data.code = i386_flag_code; \
(FRAGP)->tc_frag_data.max_bytes = (MAX_BYTES); \
(FRAGP)->tc_frag_data.length = 0; \
diff --git a/gas/testsuite/gas/i386/x86-64-nops-1a-core2.d b/gas/testsuite/gas/i386/x86-64-nops-1a-core2.d
new file mode 100644
index 00000000000..82b32dfbfa1
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-nops-1a-core2.d
@@ -0,0 +1,5 @@
+#as: -march=core2+nonop
+#source: nops-1.s
+#objdump: -drw
+#name: x86-64 -march=core2+nonop nops 1
+#dump: x86-64-nops-1-pentium.d
diff --git a/gas/testsuite/gas/i386/x86-64-nops-1a-g64.d b/gas/testsuite/gas/i386/x86-64-nops-1a-g64.d
new file mode 100644
index 00000000000..cbbe7700828
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-nops-1a-g64.d
@@ -0,0 +1,5 @@
+#as: -march=generic64+nonop
+#source: nops-1.s
+#objdump: -drw
+#name: x86-64 -march=generic64+nonop nops 1
+#dump: x86-64-nops-1-pentium.d
diff --git a/gas/testsuite/gas/i386/x86-64.exp b/gas/testsuite/gas/i386/x86-64.exp
index 3d521f66e35..29909a8a7fa 100644
--- a/gas/testsuite/gas/i386/x86-64.exp
+++ b/gas/testsuite/gas/i386/x86-64.exp
@@ -109,6 +109,8 @@ run_dump_test "x86-64-nops-1-g64"
run_dump_test "x86-64-nops-1-k8"
run_dump_test "x86-64-nops-1-core2"
run_dump_test "x86-64-nops-1-pentium"
+run_dump_test "x86-64-nops-1a-g64"
+run_dump_test "x86-64-nops-1a-core2"
run_dump_test "x86-64-nops-2"
run_dump_test "x86-64-nops-3"
run_dump_test "x86-64-nops-4"
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-23 8:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 8:34 [binutils-gdb] x86: respect ".arch nonop" when selecting which NOPs to emit 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).