diff mbox series

[2/4] Generate PTA features from a def file.

Message ID 49b67a87e659777848cb8271d6b52cc246b0d90b.1618993591.git.mliska@suse.cz
State New
Headers show
Series i386: ISA flags and PTA simplification | expand

Commit Message

Martin Liška March 8, 2021, 12:53 p.m. UTC
gcc/ChangeLog:

	* config/i386/i386.h (PTA_*): Remove.
	(enum pta_flag): New.
	(DEF_PTA): Generate PTA_* values from i386.def.
	* wide-int-bitmask.h (WIDE_INT_BITMASK_FROM_NTH): New macro.
	* config/i386/i386.def: New file.
---
 gcc/config/i386/i386.def | 110 +++++++++++++++++++++++++++++++++++++++
 gcc/config/i386/i386.h   | 106 ++++++-------------------------------
 gcc/wide-int-bitmask.h   |   3 ++
 3 files changed, 128 insertions(+), 91 deletions(-)
 create mode 100644 gcc/config/i386/i386.def

Comments

Uros Bizjak April 21, 2021, 10:52 a.m. UTC | #1
On Wed, Apr 21, 2021 at 10:28 AM Martin Liska <mliska@suse.cz> wrote:
>
>
> gcc/ChangeLog:
>
>         * config/i386/i386.h (PTA_*): Remove.
>         (enum pta_flag): New.
>         (DEF_PTA): Generate PTA_* values from i386.def.
>         * wide-int-bitmask.h (WIDE_INT_BITMASK_FROM_NTH): New macro.
>         * config/i386/i386.def: New file.

Shouldn't this file be rather named i386-isa.def?

Otherwise LGTM, but someone have to approve wide-int-bitmask.h change.

Uros.

> ---
>  gcc/config/i386/i386.def | 110 +++++++++++++++++++++++++++++++++++++++
>  gcc/config/i386/i386.h   | 106 ++++++-------------------------------
>  gcc/wide-int-bitmask.h   |   3 ++
>  3 files changed, 128 insertions(+), 91 deletions(-)
>  create mode 100644 gcc/config/i386/i386.def
>
Richard Biener April 21, 2021, 1:03 p.m. UTC | #2
On Wed, Apr 21, 2021 at 2:09 PM Uros Bizjak via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Wed, Apr 21, 2021 at 10:28 AM Martin Liska <mliska@suse.cz> wrote:
> >
> >
> > gcc/ChangeLog:
> >
> >         * config/i386/i386.h (PTA_*): Remove.
> >         (enum pta_flag): New.
> >         (DEF_PTA): Generate PTA_* values from i386.def.
> >         * wide-int-bitmask.h (WIDE_INT_BITMASK_FROM_NTH): New macro.
> >         * config/i386/i386.def: New file.
>
> Shouldn't this file be rather named i386-isa.def?
>
> Otherwise LGTM, but someone have to approve wide-int-bitmask.h change.

Hmm, such macro isn't "nice" and as it seems you could have inlined it
at the single use in the source file?

> Uros.
>
> > ---
> >  gcc/config/i386/i386.def | 110 +++++++++++++++++++++++++++++++++++++++
> >  gcc/config/i386/i386.h   | 106 ++++++-------------------------------
> >  gcc/wide-int-bitmask.h   |   3 ++
> >  3 files changed, 128 insertions(+), 91 deletions(-)
> >  create mode 100644 gcc/config/i386/i386.def
> >
Martin Liška April 21, 2021, 2:08 p.m. UTC | #3
On 4/21/21 3:03 PM, Richard Biener wrote:
> On Wed, Apr 21, 2021 at 2:09 PM Uros Bizjak via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> On Wed, Apr 21, 2021 at 10:28 AM Martin Liska <mliska@suse.cz> wrote:
>>>
>>>
>>> gcc/ChangeLog:
>>>
>>>         * config/i386/i386.h (PTA_*): Remove.
>>>         (enum pta_flag): New.
>>>         (DEF_PTA): Generate PTA_* values from i386.def.
>>>         * wide-int-bitmask.h (WIDE_INT_BITMASK_FROM_NTH): New macro.
>>>         * config/i386/i386.def: New file.
>>
>> Shouldn't this file be rather named i386-isa.def?
>>
>> Otherwise LGTM, but someone have to approve wide-int-bitmask.h change.
> 
> Hmm, such macro isn't "nice" and as it seems you could have inlined it
> at the single use in the source file?

I would use a static method, but that doesn't work with constexpr (at least not
in -std=c++11).

Let's move the macro to the usage place.

Thanks,
Martin

> 
>> Uros.
>>
>>> ---
>>>  gcc/config/i386/i386.def | 110 +++++++++++++++++++++++++++++++++++++++
>>>  gcc/config/i386/i386.h   | 106 ++++++-------------------------------
>>>  gcc/wide-int-bitmask.h   |   3 ++
>>>  3 files changed, 128 insertions(+), 91 deletions(-)
>>>  create mode 100644 gcc/config/i386/i386.def
>>>
diff mbox series

Patch

diff --git a/gcc/config/i386/i386.def b/gcc/config/i386/i386.def
new file mode 100644
index 00000000000..a0d46cbc892
--- /dev/null
+++ b/gcc/config/i386/i386.def
@@ -0,0 +1,110 @@ 
+/* Definition for processor table alias flags.
+   Copyright (C) 2001-2021 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+DEF_PTA(3DNOW)
+DEF_PTA(3DNOW_A)
+DEF_PTA(64BIT)
+DEF_PTA(ABM)
+DEF_PTA(AES)
+DEF_PTA(AVX)
+DEF_PTA(BMI)
+DEF_PTA(CX16)
+DEF_PTA(F16C)
+DEF_PTA(FMA)
+DEF_PTA(FMA4)
+DEF_PTA(FSGSBASE)
+DEF_PTA(LWP)
+DEF_PTA(LZCNT)
+DEF_PTA(MMX)
+DEF_PTA(MOVBE)
+DEF_PTA(NO_SAHF)
+DEF_PTA(PCLMUL)
+DEF_PTA(POPCNT)
+DEF_PTA(PREFETCH_SSE)
+DEF_PTA(RDRND)
+DEF_PTA(SSE)
+DEF_PTA(SSE2)
+DEF_PTA(SSE3)
+DEF_PTA(SSE4_1)
+DEF_PTA(SSE4_2)
+DEF_PTA(SSE4A)
+DEF_PTA(SSSE3)
+DEF_PTA(TBM)
+DEF_PTA(XOP)
+DEF_PTA(AVX2)
+DEF_PTA(BMI2)
+DEF_PTA(RTM)
+DEF_PTA(HLE)
+DEF_PTA(PRFCHW)
+DEF_PTA(RDSEED)
+DEF_PTA(ADX)
+DEF_PTA(FXSR)
+DEF_PTA(XSAVE)
+DEF_PTA(XSAVEOPT)
+DEF_PTA(AVX512F)
+DEF_PTA(AVX512ER)
+DEF_PTA(AVX512PF)
+DEF_PTA(AVX512CD)
+DEF_PTA(NO_TUNE)
+DEF_PTA(SHA)
+DEF_PTA(PREFETCHWT1)
+DEF_PTA(CLFLUSHOPT)
+DEF_PTA(XSAVEC)
+DEF_PTA(XSAVES)
+DEF_PTA(AVX512DQ)
+DEF_PTA(AVX512BW)
+DEF_PTA(AVX512VL)
+DEF_PTA(AVX512IFMA)
+DEF_PTA(AVX512VBMI)
+DEF_PTA(CLWB)
+DEF_PTA(MWAITX)
+DEF_PTA(CLZERO)
+DEF_PTA(NO_80387)
+DEF_PTA(PKU)
+DEF_PTA(AVX5124VNNIW)
+DEF_PTA(AVX5124FMAPS)
+DEF_PTA(AVX512VPOPCNTDQ)
+DEF_PTA(SGX)
+DEF_PTA(AVX512VNNI)
+DEF_PTA(GFNI)
+DEF_PTA(VAES)
+DEF_PTA(AVX512VBMI2)
+DEF_PTA(VPCLMULQDQ)
+DEF_PTA(AVX512BITALG)
+DEF_PTA(RDPID)
+DEF_PTA(PCONFIG)
+DEF_PTA(WBNOINVD)
+DEF_PTA(AVX512VP2INTERSECT)
+DEF_PTA(PTWRITE)
+DEF_PTA(AVX512BF16)
+DEF_PTA(WAITPKG)
+DEF_PTA(MOVDIRI)
+DEF_PTA(MOVDIR64B)
+DEF_PTA(ENQCMD)
+DEF_PTA(CLDEMOTE)
+DEF_PTA(SERIALIZE)
+DEF_PTA(TSXLDTRK)
+DEF_PTA(AMX_TILE)
+DEF_PTA(AMX_INT8)
+DEF_PTA(AMX_BF16)
+DEF_PTA(UINTR)
+DEF_PTA(HRESET)
+DEF_PTA(KL)
+DEF_PTA(WIDEKL)
+DEF_PTA(AVXVNNI)
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 97700d797a7..cee5190f0c7 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2413,97 +2413,21 @@  extern const char *const processor_names[];
 
 #include "wide-int-bitmask.h"
 
-constexpr wide_int_bitmask PTA_3DNOW (HOST_WIDE_INT_1U << 0);
-constexpr wide_int_bitmask PTA_3DNOW_A (HOST_WIDE_INT_1U << 1);
-constexpr wide_int_bitmask PTA_64BIT (HOST_WIDE_INT_1U << 2);
-constexpr wide_int_bitmask PTA_ABM (HOST_WIDE_INT_1U << 3);
-constexpr wide_int_bitmask PTA_AES (HOST_WIDE_INT_1U << 4);
-constexpr wide_int_bitmask PTA_AVX (HOST_WIDE_INT_1U << 5);
-constexpr wide_int_bitmask PTA_BMI (HOST_WIDE_INT_1U << 6);
-constexpr wide_int_bitmask PTA_CX16 (HOST_WIDE_INT_1U << 7);
-constexpr wide_int_bitmask PTA_F16C (HOST_WIDE_INT_1U << 8);
-constexpr wide_int_bitmask PTA_FMA (HOST_WIDE_INT_1U << 9);
-constexpr wide_int_bitmask PTA_FMA4 (HOST_WIDE_INT_1U << 10);
-constexpr wide_int_bitmask PTA_FSGSBASE (HOST_WIDE_INT_1U << 11);
-constexpr wide_int_bitmask PTA_LWP (HOST_WIDE_INT_1U << 12);
-constexpr wide_int_bitmask PTA_LZCNT (HOST_WIDE_INT_1U << 13);
-constexpr wide_int_bitmask PTA_MMX (HOST_WIDE_INT_1U << 14);
-constexpr wide_int_bitmask PTA_MOVBE (HOST_WIDE_INT_1U << 15);
-constexpr wide_int_bitmask PTA_NO_SAHF (HOST_WIDE_INT_1U << 16);
-constexpr wide_int_bitmask PTA_PCLMUL (HOST_WIDE_INT_1U << 17);
-constexpr wide_int_bitmask PTA_POPCNT (HOST_WIDE_INT_1U << 18);
-constexpr wide_int_bitmask PTA_PREFETCH_SSE (HOST_WIDE_INT_1U << 19);
-constexpr wide_int_bitmask PTA_RDRND (HOST_WIDE_INT_1U << 20);
-constexpr wide_int_bitmask PTA_SSE (HOST_WIDE_INT_1U << 21);
-constexpr wide_int_bitmask PTA_SSE2 (HOST_WIDE_INT_1U << 22);
-constexpr wide_int_bitmask PTA_SSE3 (HOST_WIDE_INT_1U << 23);
-constexpr wide_int_bitmask PTA_SSE4_1 (HOST_WIDE_INT_1U << 24);
-constexpr wide_int_bitmask PTA_SSE4_2 (HOST_WIDE_INT_1U << 25);
-constexpr wide_int_bitmask PTA_SSE4A (HOST_WIDE_INT_1U << 26);
-constexpr wide_int_bitmask PTA_SSSE3 (HOST_WIDE_INT_1U << 27);
-constexpr wide_int_bitmask PTA_TBM (HOST_WIDE_INT_1U << 28);
-constexpr wide_int_bitmask PTA_XOP (HOST_WIDE_INT_1U << 29);
-constexpr wide_int_bitmask PTA_AVX2 (HOST_WIDE_INT_1U << 30);
-constexpr wide_int_bitmask PTA_BMI2 (HOST_WIDE_INT_1U << 31);
-constexpr wide_int_bitmask PTA_RTM (HOST_WIDE_INT_1U << 32);
-constexpr wide_int_bitmask PTA_HLE (HOST_WIDE_INT_1U << 33);
-constexpr wide_int_bitmask PTA_PRFCHW (HOST_WIDE_INT_1U << 34);
-constexpr wide_int_bitmask PTA_RDSEED (HOST_WIDE_INT_1U << 35);
-constexpr wide_int_bitmask PTA_ADX (HOST_WIDE_INT_1U << 36);
-constexpr wide_int_bitmask PTA_FXSR (HOST_WIDE_INT_1U << 37);
-constexpr wide_int_bitmask PTA_XSAVE (HOST_WIDE_INT_1U << 38);
-constexpr wide_int_bitmask PTA_XSAVEOPT (HOST_WIDE_INT_1U << 39);
-constexpr wide_int_bitmask PTA_AVX512F (HOST_WIDE_INT_1U << 40);
-constexpr wide_int_bitmask PTA_AVX512ER (HOST_WIDE_INT_1U << 41);
-constexpr wide_int_bitmask PTA_AVX512PF (HOST_WIDE_INT_1U << 42);
-constexpr wide_int_bitmask PTA_AVX512CD (HOST_WIDE_INT_1U << 43);
-constexpr wide_int_bitmask PTA_NO_TUNE (HOST_WIDE_INT_1U << 44);
-constexpr wide_int_bitmask PTA_SHA (HOST_WIDE_INT_1U << 45);
-constexpr wide_int_bitmask PTA_PREFETCHWT1 (HOST_WIDE_INT_1U << 46);
-constexpr wide_int_bitmask PTA_CLFLUSHOPT (HOST_WIDE_INT_1U << 47);
-constexpr wide_int_bitmask PTA_XSAVEC (HOST_WIDE_INT_1U << 48);
-constexpr wide_int_bitmask PTA_XSAVES (HOST_WIDE_INT_1U << 49);
-constexpr wide_int_bitmask PTA_AVX512DQ (HOST_WIDE_INT_1U << 50);
-constexpr wide_int_bitmask PTA_AVX512BW (HOST_WIDE_INT_1U << 51);
-constexpr wide_int_bitmask PTA_AVX512VL (HOST_WIDE_INT_1U << 52);
-constexpr wide_int_bitmask PTA_AVX512IFMA (HOST_WIDE_INT_1U << 53);
-constexpr wide_int_bitmask PTA_AVX512VBMI (HOST_WIDE_INT_1U << 54);
-constexpr wide_int_bitmask PTA_CLWB (HOST_WIDE_INT_1U << 55);
-constexpr wide_int_bitmask PTA_MWAITX (HOST_WIDE_INT_1U << 56);
-constexpr wide_int_bitmask PTA_CLZERO (HOST_WIDE_INT_1U << 57);
-constexpr wide_int_bitmask PTA_NO_80387 (HOST_WIDE_INT_1U << 58);
-constexpr wide_int_bitmask PTA_PKU (HOST_WIDE_INT_1U << 59);
-constexpr wide_int_bitmask PTA_AVX5124VNNIW (HOST_WIDE_INT_1U << 60);
-constexpr wide_int_bitmask PTA_AVX5124FMAPS (HOST_WIDE_INT_1U << 61);
-constexpr wide_int_bitmask PTA_AVX512VPOPCNTDQ (HOST_WIDE_INT_1U << 62);
-constexpr wide_int_bitmask PTA_SGX (HOST_WIDE_INT_1U << 63);
-constexpr wide_int_bitmask PTA_AVX512VNNI (0, HOST_WIDE_INT_1U);
-constexpr wide_int_bitmask PTA_GFNI (0, HOST_WIDE_INT_1U << 1);
-constexpr wide_int_bitmask PTA_VAES (0, HOST_WIDE_INT_1U << 2);
-constexpr wide_int_bitmask PTA_AVX512VBMI2 (0, HOST_WIDE_INT_1U << 3);
-constexpr wide_int_bitmask PTA_VPCLMULQDQ (0, HOST_WIDE_INT_1U << 4);
-constexpr wide_int_bitmask PTA_AVX512BITALG (0, HOST_WIDE_INT_1U << 5);
-constexpr wide_int_bitmask PTA_RDPID (0, HOST_WIDE_INT_1U << 6);
-constexpr wide_int_bitmask PTA_PCONFIG (0, HOST_WIDE_INT_1U << 7);
-constexpr wide_int_bitmask PTA_WBNOINVD (0, HOST_WIDE_INT_1U << 8);
-constexpr wide_int_bitmask PTA_AVX512VP2INTERSECT (0, HOST_WIDE_INT_1U << 9);
-constexpr wide_int_bitmask PTA_PTWRITE (0, HOST_WIDE_INT_1U << 10);
-constexpr wide_int_bitmask PTA_AVX512BF16 (0, HOST_WIDE_INT_1U << 11);
-constexpr wide_int_bitmask PTA_WAITPKG (0, HOST_WIDE_INT_1U << 12);
-constexpr wide_int_bitmask PTA_MOVDIRI (0, HOST_WIDE_INT_1U << 13);
-constexpr wide_int_bitmask PTA_MOVDIR64B (0, HOST_WIDE_INT_1U << 14);
-constexpr wide_int_bitmask PTA_ENQCMD (0, HOST_WIDE_INT_1U << 15);
-constexpr wide_int_bitmask PTA_CLDEMOTE (0, HOST_WIDE_INT_1U << 16);
-constexpr wide_int_bitmask PTA_SERIALIZE (0, HOST_WIDE_INT_1U << 17);
-constexpr wide_int_bitmask PTA_TSXLDTRK (0, HOST_WIDE_INT_1U << 18);
-constexpr wide_int_bitmask PTA_AMX_TILE (0, HOST_WIDE_INT_1U << 19);
-constexpr wide_int_bitmask PTA_AMX_INT8 (0, HOST_WIDE_INT_1U << 20);
-constexpr wide_int_bitmask PTA_AMX_BF16 (0, HOST_WIDE_INT_1U << 21);
-constexpr wide_int_bitmask PTA_UINTR (0, HOST_WIDE_INT_1U << 22);
-constexpr wide_int_bitmask PTA_HRESET (0, HOST_WIDE_INT_1U << 23);
-constexpr wide_int_bitmask PTA_KL (0, HOST_WIDE_INT_1U << 24);
-constexpr wide_int_bitmask PTA_WIDEKL (0, HOST_WIDE_INT_1U << 25);
-constexpr wide_int_bitmask PTA_AVXVNNI (0, HOST_WIDE_INT_1U << 26);
+enum pta_flag
+{
+#define DEF_PTA(NAME) _ ## NAME,
+#include "i386.def"
+#undef DEF_PTA
+  END_PTA
+};
+
+/* wide_int_bitmask can handle only 128 flags.  */
+STATIC_ASSERT (END_PTA <= 128);
+
+#define DEF_PTA(NAME) constexpr wide_int_bitmask PTA_ ## NAME \
+  = WIDE_INT_BITMASK_FROM_NTH ((pta_flag) _ ## NAME);
+#include "i386.def"
+#undef DEF_PTA
 
 constexpr wide_int_bitmask PTA_X86_64_BASELINE = PTA_64BIT | PTA_MMX | PTA_SSE
   | PTA_SSE2 | PTA_NO_SAHF | PTA_FXSR;
diff --git a/gcc/wide-int-bitmask.h b/gcc/wide-int-bitmask.h
index 763d0f68644..820dd3aa407 100644
--- a/gcc/wide-int-bitmask.h
+++ b/gcc/wide-int-bitmask.h
@@ -38,6 +38,9 @@  public:
   uint64_t low, high;
 };
 
+#define WIDE_INT_BITMASK_FROM_NTH(N) (N < 64 ? wide_int_bitmask (0, 1ULL << N) \
+				      : wide_int_bitmask (1ULL << (N - 64), 0))
+
 constexpr
 wide_int_bitmask::wide_int_bitmask ()
 : low (0), high (0)