x86: Rewrite NOP generation for fill and alignment
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 7 Mar 2018 12:18:45 +0000 (04:18 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 7 Mar 2018 12:18:56 +0000 (04:18 -0800)
commit3ae729d5a4f63740ed9a778960b17c2912b0bbdd
treeb186f154a1e58be2c572eaeef8e593715736467b
parent52fe4420b771a0f3b4fc7c6535bbd6e9b279f775
x86: Rewrite NOP generation for fill and alignment

Rewrite NOP generation for fill and code alignment by:

1. Add a 11-byte NOP with another 0x66 prefix.
2. Remove the multi-byte NOP entries which consist of 2 instructions.
3. Select proper NOPs based on ISA and processor tuning.
4. Generate multiple NOPs with the longer NOPs first followed by the
shorter NOP.
5. Use jump for larger NOP padding:
   a. > 8 bytes (2 NOPs) in 16-bit mode.
   b. > 14 bytes (2 NOPs) for older processors.
   c. > 77 bytes (7 NOPs) for newer processors.
6. Update MAX_MEM_FOR_RS_ALIGN_CODE to 4095.

PR gas/22874
* config/tc-i386.c (f32_5): Removed.
(f32_8): Likewise.
(f32_9): Likewise.
(f32_10): Likewise.
(f32_11): Likewise.
(f32_12): Likewise.
(f32_13): Likewise.
(f32_14): Likewise.
(f16_5): Likewise.
(f16_6): Likewise.
(f16_7): Likewise.
(f16_8): Likewise.
(jump_31): Likewise.
(alt64_11): Likewise.
(alt64_patt): Likewise.
(jump_disp8): New.
(jump32_disp32): Likewise.
(jump16_disp32): Likewise.
(alt_11): Likewise.
(f32_patt): Updated.
(f16_patt): Likewise.
(alt_patt): Add alt_11.
(i386_align_code): Merged with ...
(i386_generate_nops): This.  Rewritten.
(fits_in_imm7): Moved before i386_generate_nops.
(fits_in_imm31): Likewise.
* config/tc-i386.h (MAX_MEM_FOR_RS_ALIGN_CODE): Updated to
4095.
(i386_align_code): Removed.
(HANDLE_ALIGN): Rewritten with i386_generate_nops.
* doc/as.texinfo: Update limits of control byte for x86 .nops
directive.
* testsuite/gas/i386/i386.exp: Run nops-7 and x86-64-nops-7.
* gas/testsuite/gas/i386/noavx-3.l: Updated.
* gas/testsuite/gas/i386/nop-1.d: Likewise.
* gas/testsuite/gas/i386/nop-1.s: Likewise.
* gas/testsuite/gas/i386/nop-2.d: Likewise.
* gas/testsuite/gas/i386/nop-2.s: Likewise.
* gas/testsuite/gas/i386/nop-3.d: Likewise.
* gas/testsuite/gas/i386/nop-4.d: Likewise.
* gas/testsuite/gas/i386/nop-5.d: Likewise.
* gas/testsuite/gas/i386/nop-5.s: Likewise.
* gas/testsuite/gas/i386/nop-6.d: Likewise.
* gas/testsuite/gas/i386/nop-bad-1.l: Likewise.
* gas/testsuite/gas/i386/nops-1-core2.d: Likewise.
* gas/testsuite/gas/i386/nops-1-i386-i686.d: Likewise.
* gas/testsuite/gas/i386/nops-1-i386.d: Likewise.
* gas/testsuite/gas/i386/nops-1-i686.d: Likewise.
* gas/testsuite/gas/i386/nops-1-k8.d: Likewise.
* gas/testsuite/gas/i386/nops-1.d: Likewise.
* gas/testsuite/gas/i386/nops-2-core2.d: Likewise.
* gas/testsuite/gas/i386/nops-2-i386.d: Likewise.
* gas/testsuite/gas/i386/nops-2.d: Likewise.
* gas/testsuite/gas/i386/nops-3-i386.d: Likewise.
* gas/testsuite/gas/i386/nops-3-i686.d: Likewise.
* gas/testsuite/gas/i386/nops-3.d: Likewise.
* gas/testsuite/gas/i386/nops-4-i386.d: Likewise.
* gas/testsuite/gas/i386/nops-4-i686.d: Likewise.
* gas/testsuite/gas/i386/nops-4.d: Likewise.
* gas/testsuite/gas/i386/nops-4a-i686.d: Likewise.
* gas/testsuite/gas/i386/nops-5-i686.d: Likewise.
* gas/testsuite/gas/i386/nops-5.d: Likewise.
* gas/testsuite/gas/i386/nops-6.d: Likewise.
* gas/testsuite/gas/i386/nops16-1.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nop-1.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nop-2.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nop-5.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-1-core2.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-1-g64.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-1-k8.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-1-pentium.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-1.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-2.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-3.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-4-core2.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-4-k8.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-4.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-5-k8.d: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-5.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-1-core2.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-1-k8.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-1-pentium.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-1.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-2.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-3.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-4-core2.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-4-k8.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-4.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-5-k8.d: Likewise.
* gas/testsuite/gas/i386/ilp32/x86-64-nops-5.d: Likewise.
* gas/testsuite/gas/i386/nops-7.d: New file.
* gas/testsuite/gas/i386/nops-7.s: Likewise.
* gas/testsuite/gas/i386/x86-64-nops-7.d: Likewise.
65 files changed:
gas/ChangeLog
gas/config/tc-i386.c
gas/config/tc-i386.h
gas/doc/as.texinfo
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/ilp32/x86-64-nops-1-core2.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-1-k8.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-1-pentium.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-1.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-2.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-3.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-4-core2.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-4-k8.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-4.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-5-k8.d
gas/testsuite/gas/i386/ilp32/x86-64-nops-5.d
gas/testsuite/gas/i386/noavx-3.l
gas/testsuite/gas/i386/nop-1.d
gas/testsuite/gas/i386/nop-1.s
gas/testsuite/gas/i386/nop-2.d
gas/testsuite/gas/i386/nop-2.s
gas/testsuite/gas/i386/nop-3.d
gas/testsuite/gas/i386/nop-4.d
gas/testsuite/gas/i386/nop-5.d
gas/testsuite/gas/i386/nop-5.s
gas/testsuite/gas/i386/nop-6.d
gas/testsuite/gas/i386/nop-bad-1.l
gas/testsuite/gas/i386/nops-1-core2.d
gas/testsuite/gas/i386/nops-1-i386-i686.d
gas/testsuite/gas/i386/nops-1-i386.d
gas/testsuite/gas/i386/nops-1-i686.d
gas/testsuite/gas/i386/nops-1-k8.d
gas/testsuite/gas/i386/nops-1.d
gas/testsuite/gas/i386/nops-2-core2.d
gas/testsuite/gas/i386/nops-2-i386.d
gas/testsuite/gas/i386/nops-2.d
gas/testsuite/gas/i386/nops-3-i386.d
gas/testsuite/gas/i386/nops-3-i686.d
gas/testsuite/gas/i386/nops-3.d
gas/testsuite/gas/i386/nops-4-i386.d
gas/testsuite/gas/i386/nops-4-i686.d
gas/testsuite/gas/i386/nops-4.d
gas/testsuite/gas/i386/nops-4a-i686.d
gas/testsuite/gas/i386/nops-5-i686.d
gas/testsuite/gas/i386/nops-5.d
gas/testsuite/gas/i386/nops-6.d
gas/testsuite/gas/i386/nops-7.d [new file with mode: 0644]
gas/testsuite/gas/i386/nops-7.s [new file with mode: 0644]
gas/testsuite/gas/i386/nops16-1.d
gas/testsuite/gas/i386/x86-64-nop-1.d
gas/testsuite/gas/i386/x86-64-nop-2.d
gas/testsuite/gas/i386/x86-64-nop-5.d
gas/testsuite/gas/i386/x86-64-nops-1-core2.d
gas/testsuite/gas/i386/x86-64-nops-1-g64.d
gas/testsuite/gas/i386/x86-64-nops-1-k8.d
gas/testsuite/gas/i386/x86-64-nops-1-pentium.d
gas/testsuite/gas/i386/x86-64-nops-1.d
gas/testsuite/gas/i386/x86-64-nops-2.d
gas/testsuite/gas/i386/x86-64-nops-3.d
gas/testsuite/gas/i386/x86-64-nops-4-core2.d
gas/testsuite/gas/i386/x86-64-nops-4-k8.d
gas/testsuite/gas/i386/x86-64-nops-4.d
gas/testsuite/gas/i386/x86-64-nops-5-k8.d
gas/testsuite/gas/i386/x86-64-nops-5.d
gas/testsuite/gas/i386/x86-64-nops-7.d [new file with mode: 0644]