Bug 20145 - Improve x86 .noXXX directives
Summary: Improve x86 .noXXX directives
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.27
: P2 normal
Target Milestone: 2.27
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-25 22:20 UTC by H.J. Lu
Modified: 2016-05-29 15:05 UTC (History)
1 user (show)

See Also:
Host:
Target: x86
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2016-05-25 22:20:02 UTC
X86 assembler should support

.arch .noXXX

to disable XXX instructions and all instructions which depend on
XXX.  We can take a look at  OPTION_MASK_ISA_XXX_UNSETs in
gcc/common/config/i386/i386-common.c.  TODO:

1. Should ".noavx" disable AVX512? Many, if not all, AVX instructions
can be encoded with AVX512. ".arch noavx" can be used to encode AVX
instructions in AVX512.
2. Extend i386-gen.c to generate CPU_ANY_XXX_FLAGS automatically.
3. Should CPU_AVX flags include MMX?
4. Should CPU_AVX flags include SSE?
5. Should CPU_AVX512 flags include MMX?
6. Should CPU_AVX512 flags include SSE?
7. Should CPU_AVX512 flags include AVX?
Comment 1 cvs-commit@gcc.gnu.org 2016-05-27 17:06:51 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1848e567343e9c50979453463f34e0a55ba892eb

commit 1848e567343e9c50979453463f34e0a55ba892eb
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri May 27 10:05:39 2016 -0700

    Update x86 CPU_XXX_FLAGS handling
    
    Support defining CPU_XXX_FLAGS with other CPU_XXX_FLAGS.  Update
    CPU_XXX_FLAGS to enable more bits like x87 and SYSCALL.  Don't enable
    MMX when enabling SSE, AVX or AVX512.  Don't disable AVX nor AVX512 when
    disabling SSE.  Don't disable AVX512 when disabling AVX.  Disable F16C,
    FMA, FMA4 and XOP when disabling AVX.  Add 87, no287, no387, no687,
    nosse2, nosse3, nossse3, nosse4.1, nosse4.2, nosse4 and noavx2 directives
    to x86 assembler.
    
    TODO: Add more .noXXX, like .noavx512f, directives to x86 assembler.
    
    gas/
    
    	PR gas/20145
    	* config/tc-i386.c (cpu_arch): Add 687.
    	(cpu_noarch): Add no287, no387, no687, nosse2, nosse3, nossse3,
    	nosse4.1, nosse4.2, nosse4 and noavx2.
    	(parse_real_register): Check cpuregmmx instead of cpummx for MMX
    	register.  Check cpuregxmm instead of cpusse for XMM register.
    	Check cpuregymm instead of cpuavx for YMM register.  Check
    	cpuregzmm/cpuregmask instead of cpuavx512f for ZMMM/mask register.
    	* doc/c-i386.texi: Mention 687, no287, no387, no687, nosse2,
    	nosse3, nossse3, nosse4.1, nosse4.2, nosse4 and noavx2.
    	* testsuite/gas/i386/arch-10-prefetchw.d (as): Add mmx.
    	* testsuite/gas/i386/arch-10.d (as): Likewise.
    	* testsuite/gas/i386/arch-11.s: Add ".arch .mmx".
    	* testsuite/gas/i386/i386.exp: Pass mmx to assembler for
    	arch-10-3 and arch-10-4.  Run no87-3, nosse-4, nosse-5, noavx-3
    	and noavx-4.
    	* testsuite/gas/i386/no87-3.l: New file.
    	* testsuite/gas/i386/no87-3.s: Likewise.
    	* testsuite/gas/i386/noavx-3.l: Likewise.
    	* testsuite/gas/i386/noavx-3.s: Likewise.
    	* testsuite/gas/i386/noavx-4.d: Likewise.
    	* testsuite/gas/i386/noavx-4.s: Likewise.
    	* testsuite/gas/i386/nosse-4.l: Likewise.
    	* testsuite/gas/i386/nosse-4.s: Likewise.
    	* testsuite/gas/i386/nosse-5.d: Likewise.
    	* testsuite/gas/i386/nosse-5.s: Likewise.
    
    opcodes/
    
    	PR gas/20145
    	* i386-gen.c (cpu_flag_init): Update CPU_XXX_FLAGS.  Remove
    	CpuMMX from CPU_SSE_FLAGS.  Remove AVX and AVX512 bits from
    	CPU_ANY_SSE_FLAGS.  Remove AVX512 bits from CPU_ANY_AVX_FLAGS.
    	Add CPU_XSAVE_FLAGS to CPU_XSAVEOPT_FLAGS, CPU_XSAVE_FLAGS and
    	CpuXSAVEC.  Add CPU_AVX_FLAGS to CpuF16C.  Remove CpuMMX from
    	CPU_AVX512F_FLAGS, CPU_AVX512CD_FLAGS, CPU_AVX512ER_FLAGS,
    	CPU_AVX512PF_FLAGS, CPU_AVX512DQ_FLAGS and CPU_AVX512BW_FLAGS.
    	Add CPU_SSE2_FLAGS to CPU_SHA_FLAGS.   Add CPU_ANY_287_FLAGS,
    	CPU_ANY_387_FLAGS, CPU_ANY_687_FLAGS, CPU_ANY_SSE2_FLAGS,
    	CPU_ANY_SSE3_FLAGS, CPU_ANY_SSSE3_FLAGS, CPU_ANY_SSE4_1_FLAGS,
    	CPU_ANY_SSE4_2_FLAGS and CPU_ANY_AVX2_FLAGS.  Enable CpuRegMMX
    	for MMX.  Enable CpuRegXMM for SSE, AVX and AVX512.  Enable
    	CpuRegYMM for AVX and AVX512VL,  Enable CpuRegZMM and
    	CpuRegMask for AVX512.
    	(cpu_flags): Add CpuRegMMX, CpuRegXMM, CpuRegYMM, CpuRegZMM
    	and CpuRegMask.
    	(set_bitfield_from_cpu_flag_init): New function.
    	(set_bitfield): Remove const on f.  Call
    	set_bitfield_from_cpu_flag_init to handle CPU_XXX_FLAGS.
    	* i386-opc.h (CpuRegMMX): New.
    	(CpuRegXMM): Likewise.
    	(CpuRegYMM): Likewise.
    	(CpuRegZMM): Likewise.
    	(CpuRegMask): Likewise.
    	(i386_cpu_flags): Add cpuregmmx, cpuregxmm, cpuregymm, cpuregzmm
    	and cpuregmask.
    	* i386-init.h: Regenerated.
    	* i386-tbl.h: Likewise.
Comment 2 cvs-commit@gcc.gnu.org 2016-05-29 15:01:21 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=144b71e2a88e02d0b54d4f09cc652f353b46e455

commit 144b71e2a88e02d0b54d4f09cc652f353b46e455
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri May 27 15:41:45 2016 -0700

    Add .noavx512XX directives to x86 assembler
    
    Add .noavx512f, .noavx512cd, .noavx512er, .noavx512pf, .noavx512dq,
    .noavx512bw, .noavx512vl, .noavx512ifma, .noavx512vbmi directives to x86
    assembler.
    
    gas/
    
    	PR gas/20145
    	* config/tc-i386.c (cpu_noarch): Add noavx512f, noavx512cd,
    	noavx512er, noavx512pf, noavx512dq, noavx512bw, noavx512vl,
    	noavx512ifma and noavx512vbmi.
    	* doc/c-i386.texi: Mention noavx512f, noavx512cd, noavx512er,
    	noavx512pf, noavx512dq, noavx512bw, noavx512vl, noavx512ifma
    	and noavx512vbmi.
    	* testsuite/gas/i386/i386.exp: Run noavx512-1 and noavx512-2.
    	* testsuite/gas/i386/noavx512-1.l: New file.
    	* testsuite/gas/i386/noavx512-1.s: Likewise.
    	* testsuite/gas/i386/noavx512-2.l: Likewise.
    	* testsuite/gas/i386/noavx512-2.s: Likewise.
    
    opcodes/
    
    	PR gas/20145
    	* i386-gen.c (cpu_flag_init): Add CPU_ANY_AVX512F_FLAGS,
    	CPU_ANY_AVX512CD_FLAGS, CPU_ANY_AVX512ER_FLAGS,
    	CPU_ANY_AVX512PF_FLAGS, CPU_ANY_AVX512DQ_FLAGS,
    	CPU_ANY_AVX512BW_FLAGS, CPU_ANY_AVX512VL_FLAGS,
    	CPU_ANY_AVX512IFMA_FLAGS and CPU_ANY_AVX512VBMI_FLAGS.
    	* i386-init.h: Regenerated.
Comment 3 H.J. Lu 2016-05-29 15:05:09 UTC
Fixed for 2.27. Please open a new PR if we need more .noXXX directives.