x86-64: Use long NOPs for Intel Core processors

Use long NOPs for Intel Core processors since they are faster than
multiple NOPs.  Don't use them for 64-bit processors by default since
Intel Atom processors can only decode 4 prefixes in 1 cycle.

	* config/tc-i386.c (alt64_9): New.
	(alt64_10): Likewise.
	(alt64_11): Likewise.
	(alt64_12): Likewise.
	(alt64_13): Likewise.
	(alt64_14): Likewise.
	(alt64_15): Likewise.
	(alt64_patt): Likewise.
	(i386_generate_nops): Use alt64_patt for Intel Core processors
	in 64-bit mode.
	* testsuite/gas/i386/x86-64-nops-1-core2.d: Expect long NOPs.
	* testsuite/gas/i386/x86-64-nops-4-core2.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-1-core2.d: Replace
	../x86-64-nops-1.d with ../x86-64-nops-1-core2.d.
	* testsuite/gas/i386/ilp32/x86-64-nops-4-core2.d: Replace
	../x86-64-nops-4.d with ../x86-64-nops-4-core2.d.
This commit is contained in:
H.J. Lu 2024-04-01 10:03:11 -07:00
parent 533da9536e
commit bf649e72d3
5 changed files with 397 additions and 9 deletions

View File

@ -1356,6 +1356,25 @@ static const unsigned char *const alt_patt[] = {
f32_1, f32_2, alt_3, alt_4, alt_5, alt_6, alt_7, alt_8,
alt_9, alt_10, alt_11
};
#define alt64_9 (alt64_15 + 6) /* nopq 0L(%rax,%rax,1) */
#define alt64_10 (alt64_15 + 5) /* cs nopq 0L(%rax,%rax,1) */
/* data16 cs nopq 0L(%rax,%rax,1) */
#define alt64_11 (alt64_15 + 4)
/* data16 data16 cs nopq 0L(%rax,%rax,1) */
#define alt64_12 (alt64_15 + 3)
/* data16 data16 data16 cs nopq 0L(%rax,%rax,1) */
#define alt64_13 (alt64_15 + 2)
/* data16 data16 data16 data16 cs nopq 0L(%rax,%rax,1) */
#define alt64_14 (alt64_15 + 1)
/* data16 data16 data16 data16 data16 cs nopq 0L(%rax,%rax,1) */
static const unsigned char alt64_15[] =
{0x66,0x66,0x66,0x66,0x66,0x2e,0x48,
0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
/* Long 64-bit NOPs patterns. */
static const unsigned char *const alt64_patt[] = {
f32_1, f32_2, alt_3, alt_4, alt_5, alt_6, alt_7, alt_8,
alt64_9, alt64_10, alt64_11,alt64_12, alt64_13, alt64_14, alt64_15
};
/* Genenerate COUNT bytes of NOPs to WHERE from PATT with the maximum
size of a single NOP instruction MAX_SINGLE_NOP_SIZE. */
@ -1466,12 +1485,21 @@ i386_generate_nops (fragS *fragP, char *where, offsetT count, int limit)
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.cpunop)
{
if (fragP->tc_frag_data.code == CODE_64BIT)
patt = alt64_patt;
else
patt = alt_patt;
}
break;
case PROCESSOR_PENTIUMPRO:
case PROCESSOR_PENTIUM4:
case PROCESSOR_NOCONA:
case PROCESSOR_GENERIC64:
case PROCESSOR_K6:
case PROCESSOR_ATHLON:
@ -1517,7 +1545,7 @@ i386_generate_nops (fragS *fragP, char *where, offsetT count, int limit)
}
}
if (patt != alt_patt)
if (patt != alt_patt && patt != alt64_patt)
{
max_single_nop_size = patt == f32_patt ? ARRAY_SIZE (f32_patt)
: ARRAY_SIZE (f64_patt);
@ -1526,7 +1554,9 @@ i386_generate_nops (fragS *fragP, char *where, offsetT count, int limit)
}
else
{
max_single_nop_size = sizeof (alt_patt) / sizeof (alt_patt[0]);
max_single_nop_size = patt == alt_patt
? ARRAY_SIZE (alt_patt)
: ARRAY_SIZE (alt64_patt);
/* Limit number of NOPs to 7 for newer processors. */
max_number_of_nops = 7;
}

View File

@ -2,4 +2,4 @@
#as: -mtune=core2
#objdump: -drw
#name: x86-64 (ILP32) -mtune=core2 nops 1
#dump: ../x86-64-nops-1.d
#dump: ../x86-64-nops-1-core2.d

View File

@ -2,4 +2,4 @@
#as: -mtune=core2
#objdump: -drw
#name: x86-64 (ILP32) nops -mtune=core2 4
#dump: ../x86-64-nops-4.d
#dump: ../x86-64-nops-4-core2.d

View File

@ -2,4 +2,156 @@
#source: nops-1.s
#objdump: -drw
#name: x86-64 -mtune=core2 nops 1
#dump: x86-64-nops-1.d
.*: +file format .*
Disassembly of section .text:
0+ <nop15>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+10 <nop14>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+20 <nop13>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+30 <nop12>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+40 <nop11>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 2e 48 0f 1f 84 00 00 00 00 00 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+50 <nop10>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 2e 48 0f 1f 84 00 00 00 00 00 cs nopq (0x)?0\(%rax,%rax,1\)
0+60 <nop9>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 48 0f 1f 84 00 00 00 00 00 nopq (0x)?0\(%rax,%rax,1\)
0+70 <nop8>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 0f 1f 84 00 00 00 00 00 nopl (0x)?0\(%rax,%rax,1\)
0+80 <nop7>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 0f 1f 80 00 00 00 00 nopl (0x)?0\(%rax\)
0+90 <nop6>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 0f 1f 44 00 00 nopw (0x)?0\(%rax,%rax,1\)
0+a0 <nop5>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 0f 1f 44 00 00 nopl (0x)?0\(%rax,%rax,1\)
0+b0 <nop4>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 0f 1f 40 00 nopl (0x)?0\(%rax\)
0+c0 <nop3>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
0+d0 <nop2>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 90 xchg %ax,%ax
#pass

View File

@ -2,4 +2,210 @@
#source: nops-4.s
#objdump: -drw
#name: x86-64 nops -mtune=core2 4
#dump: x86-64-nops-4.d
.*: +file format .*
Disassembly of section .text:
0+ <nop31>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 90 nop
0+20 <nop30>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+40 <nop29>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+60 <nop28>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+80 <nop27>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+a0 <nop26>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 66 2e 48 0f 1f 84 00 00 00 00 00 data16 cs nopq (0x)?0\(%rax,%rax,1\)
0+c0 <nop25>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 2e 48 0f 1f 84 00 00 00 00 00 cs nopq (0x)?0\(%rax,%rax,1\)
0+e0 <nop24>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 48 0f 1f 84 00 00 00 00 00 nopq (0x)?0\(%rax,%rax,1\)
0+100 <nop23>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 0f 1f 84 00 00 00 00 00 nopl (0x)?0\(%rax,%rax,1\)
0+120 <nop22>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 0f 1f 80 00 00 00 00 nopl (0x)?0\(%rax\)
0+140 <nop21>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 66 0f 1f 44 00 00 nopw (0x)?0\(%rax,%rax,1\)
0+160 <nop20>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 0f 1f 44 00 00 nopl (0x)?0\(%rax,%rax,1\)
0+180 <nop19>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 0f 1f 40 00 nopl (0x)?0\(%rax\)
0+1a0 <nop18>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
0+1c0 <nop17>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 66 90 xchg %ax,%ax
0+1e0 <nop16>:
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 90 nop
+[a-f0-9]+: 66 66 66 66 66 2e 48 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 cs nopq (0x)?0\(%rax,%rax,1\)
+[a-f0-9]+: 90 nop
#pass