public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] x86: Add <x86gprintrin.h>
@ 2020-09-23 17:58 H.J. Lu
  2020-10-02 12:51 ` PING: " H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2020-09-23 17:58 UTC (permalink / raw)
  To: gcc-patches

For sources which can't use any vector instructions, <x86intrin.h> and
<immintrin.h> cannot be included for compiler intrinsics:

$ echo "#include <x86intrin.h>" | gcc -S -O2 -mno-sse -mno-mmx -x c -
In file included from /usr/include/stdlib.h:1013,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/mm_malloc.h:27,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/xmmintrin.h:34,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/immintrin.h:29,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/x86intrin.h:32,
                 from <stdin>:1:
/usr/include/bits/stdlib-float.h: In function ‘atof’:
/usr/include/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
$

libgcc/config/i386/shadow-stack-unwind.h has a workaround:

/* NB: We need _get_ssp and _inc_ssp from <cetintrin.h>.  But we can't
   include <x86intrin.h> which ends up including <mm_malloc.h>, which
   includes <stdlib.h> and <errno.h> unconditionally.  But we can't
   include any libc system headers unconditionally from libgcc.  Avoid
   including <mm_malloc.h> here by defining _IMMINTRIN_H_INCLUDED.  */
 #define _IMMINTRIN_H_INCLUDED
 #include <cetintrin.h>
 #undef _IMMINTRIN_H_INCLUDED

Add a standalone intrinsic header file, <x86gprintrin.h>, to provide
integer only intrinsics.  All integer only intrinsics are placed in
<x86gprintrin.h>.  <x86intrin.h> and <immintrin.h> simply include
<x86gprintrin.h>.

Add the FSF copyright to <pconfigintrin.h>, <tsxldtrkintrin.h> and
<wbnoinvdintrin.h>.

gcc/

	PR target/97148
	* config.gcc (extra_headers): Add x86gprintrin.h.
	* config/i386/adxintrin.h: Check _X86GPRINTRIN_H_INCLUDED for
	<x86gprintrin.h>.
	* config/i386/bmi2intrin.h: Likewise.
	* config/i386/bmiintrin.h: Likewise.
	* config/i386/cetintrin.h: Likewise.
	* config/i386/cldemoteintrin.h: Likewise.
	* config/i386/clflushoptintrin.h: Likewise.
	* config/i386/clwbintrin.h: Likewise.
	* config/i386/fxsrintrin.h: Likewise.
	* config/i386/ia32intrin.h: Likewise.
	* config/i386/lwpintrin.h: Likewise.
	* config/i386/lzcntintrin.h: Likewise.
	* config/i386/movdirintrin.h: Likewise.
	* config/i386/pkuintrin.h: Likewise.
	* config/i386/rdseedintrin.h: Likewise.
	* config/i386/rtmintrin.h: Likewise.
	* config/i386/serializeintrin.h: Likewise.
	* config/i386/tbmintrin.h: Likewise.
	* config/i386/waitpkgintrin.h: Likewise.
	* config/i386/xsavecintrin.h: Likewise.
	* config/i386/xsaveintrin.h: Likewise.
	* config/i386/xsaveoptintrin.h: Likewise.
	* config/i386/xsavesintrin.h: Likewise.
	* config/i386/xtestintrin.h: Likewise.
	* config/i386/enqcmdintrin.h: Check _X86GPRINTRIN_H_INCLUDED for
	<x86gprintrin.h>.  Replace <enqcmdntrin.h> with <enqcmdintrin.h>
	in the error message.
	* config/i386/immintrin.h: Include <x86gprintrin.h> instead of
	<fxsrintrin.h>, <xsaveintrin.h>, <xsaveoptintrin.h>,
	<xsavesintrin.h>, <xsavecintrin.h>, <lzcntintrin.h>,
	<bmiintrin.h>, <bmi2intrin.h>, <xtestintrin.h>, <cetintrin.h>,
	<movdirintrin.h>, <sgxintrin.h, <pconfigintrin.h>,
	<waitpkgintrin.h>, <cldemoteintrin.h>, <enqcmdintrin.h>,
	<serializeintrin.h>, <tsxldtrkintrin.h>, <adxintrin.h>,
	<clwbintrin.h>, <clflushoptintrin.h>, <wbnoinvdintrin.h> and
	<pkuintrin.h>.
	(_wbinvd): Moved to config/i386/x86gprintrin.h.
	(_rdrand16_step): Likewise.
	(_rdrand32_step): Likewise.
	(_rdpid_u32): Likewise.
	(_readfsbase_u32): Likewise.
	(_readfsbase_u64): Likewise.
	(_readgsbase_u32): Likewise.
	(_readgsbase_u64): Likewise.
	(_writefsbase_u32): Likewise.
	(_writefsbase_u64): Likewise.
	(_writegsbase_u32): Likewise.
	(_writegsbase_u64): Likewise.
	(_rdrand64_step): Likewise.
	(_ptwrite64): Likewise.
	(_ptwrite32): Likewise.
	* config/i386/x86gprintrin.h: New file.
	* config/i386/pconfigintrin.h: Add the FSF copyright.  Check
	_X86GPRINTRIN_H_INCLUDED for <x86gprintrin.h>.
	* config/i386/tsxldtrkintrin.h: Likewise.
	* config/i386/wbnoinvdintrin.h: Likewise.
	* config/i386/x86intrin.h: Include <x86gprintrin.h>.  Don't
	include <ia32intrin.h>, <lwpintrin.h>, <tbmintrin.h>,
	<popcntintrin.h>, <mwaitxintrin.h> and <clzerointrin.h>.

gcc/testsuite/

	* gcc.target/i386/avx-1.c (__builtin_ia32_lwpval32): New to
	support <lwpintrin.h> included in <x86gprintrin.h>.
	(__builtin_ia32_lwpval64): Likewise.
	(__builtin_ia32_lwpins32): Likewise.
	(__builtin_ia32_lwpins64): Likewise.
	(__builtin_ia32_bextri_u32): New to support <tbmintrin.h>
	included in <x86gprintrin.h>.
	(__builtin_ia32_bextri_u64): Likewise.
	* gcc.target/i386/x86gprintrin-1.c: New test.
	* gcc.target/i386/x86gprintrin-2.c: Likewise.
	* gcc.target/i386/x86gprintrin-3.c: Likewise.
	* gcc.target/i386/x86gprintrin-4.c: Likewise.
	* gcc.target/i386/x86gprintrin-4a.c: Likewise.
	* gcc.target/i386/x86gprintrin-5.c: Likewise.
	* gcc.target/i386/x86gprintrin-5a.c: Likewise.
	* gcc.target/i386/x86gprintrin-5b.c: Likewise.
	* gcc.target/i386/x86gprintrin-6.c: Likewise.

libgcc/

	PR target/97148
	* config/i386/shadow-stack-unwind.h: Include <x86gprintrin.h>
	instead of <cetintrin.h>.
---
 gcc/config.gcc                                |   4 +-
 gcc/config/i386/adxintrin.h                   |   4 +-
 gcc/config/i386/bmi2intrin.h                  |   4 +-
 gcc/config/i386/bmiintrin.h                   |   4 +-
 gcc/config/i386/cetintrin.h                   |   4 +-
 gcc/config/i386/cldemoteintrin.h              |   4 +-
 gcc/config/i386/clflushoptintrin.h            |   4 +-
 gcc/config/i386/clwbintrin.h                  |   4 +-
 gcc/config/i386/enqcmdintrin.h                |   4 +-
 gcc/config/i386/fxsrintrin.h                  |   4 +-
 gcc/config/i386/ia32intrin.h                  |   4 +-
 gcc/config/i386/immintrin.h                   | 207 +-------------
 gcc/config/i386/lwpintrin.h                   |   4 +-
 gcc/config/i386/lzcntintrin.h                 |   4 +-
 gcc/config/i386/movdirintrin.h                |   4 +-
 gcc/config/i386/pconfigintrin.h               |  27 +-
 gcc/config/i386/pkuintrin.h                   |   4 +-
 gcc/config/i386/rdseedintrin.h                |   4 +-
 gcc/config/i386/rtmintrin.h                   |   4 +-
 gcc/config/i386/serializeintrin.h             |   4 +-
 gcc/config/i386/tbmintrin.h                   |   4 +-
 gcc/config/i386/tsxldtrkintrin.h              |  27 +-
 gcc/config/i386/waitpkgintrin.h               |   4 +-
 gcc/config/i386/wbnoinvdintrin.h              |  27 +-
 gcc/config/i386/x86gprintrin.h                | 252 ++++++++++++++++++
 gcc/config/i386/x86intrin.h                   |  12 +-
 gcc/config/i386/xsavecintrin.h                |   4 +-
 gcc/config/i386/xsaveintrin.h                 |   4 +-
 gcc/config/i386/xsaveoptintrin.h              |   4 +-
 gcc/config/i386/xsavesintrin.h                |   4 +-
 gcc/config/i386/xtestintrin.h                 |   4 +-
 gcc/testsuite/gcc.target/i386/avx-1.c         |  10 +
 .../gcc.target/i386/x86gprintrin-1.c          |   7 +
 .../gcc.target/i386/x86gprintrin-2.c          |  30 +++
 .../gcc.target/i386/x86gprintrin-3.c          |  15 ++
 .../gcc.target/i386/x86gprintrin-4.c          |  30 +++
 .../gcc.target/i386/x86gprintrin-4a.c         |   7 +
 .../gcc.target/i386/x86gprintrin-5.c          |  32 +++
 .../gcc.target/i386/x86gprintrin-5a.c         |   5 +
 .../gcc.target/i386/x86gprintrin-5b.c         |   5 +
 .../gcc.target/i386/x86gprintrin-6.c          |  11 +
 libgcc/config/i386/shadow-stack-unwind.h      |   9 +-
 42 files changed, 533 insertions(+), 280 deletions(-)
 create mode 100644 gcc/config/i386/x86gprintrin.h
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-4.c
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-4a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-5.c
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-5a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-5b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/x86gprintrin-6.c

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 845f10e48be..260aeae176b 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -412,7 +412,7 @@ i[34567]86-*-*)
 		       waitpkgintrin.h cldemoteintrin.h avx512bf16vlintrin.h
 		       avx512bf16intrin.h enqcmdintrin.h serializeintrin.h
 		       avx512vp2intersectintrin.h avx512vp2intersectvlintrin.h
-		       tsxldtrkintrin.h"
+		       tsxldtrkintrin.h x86gprintrin.h"
 	;;
 x86_64-*-*)
 	cpu_type=i386
@@ -447,7 +447,7 @@ x86_64-*-*)
 		       waitpkgintrin.h cldemoteintrin.h avx512bf16vlintrin.h
 		       avx512bf16intrin.h enqcmdintrin.h serializeintrin.h
 		       avx512vp2intersectintrin.h avx512vp2intersectvlintrin.h
-		       tsxldtrkintrin.h"
+		       tsxldtrkintrin.h x86gprintrin.h"
 	;;
 ia64-*-*)
 	extra_headers=ia64intrin.h
diff --git a/gcc/config/i386/adxintrin.h b/gcc/config/i386/adxintrin.h
index 6c15417828c..6dffe45ff9f 100644
--- a/gcc/config/i386/adxintrin.h
+++ b/gcc/config/i386/adxintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <adxintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <adxintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _ADXINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/bmi2intrin.h b/gcc/config/i386/bmi2intrin.h
index c5de9ebc295..9fdd08cc5a1 100644
--- a/gcc/config/i386/bmi2intrin.h
+++ b/gcc/config/i386/bmi2intrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <bmi2intrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _BMI2INTRIN_H_INCLUDED
diff --git a/gcc/config/i386/bmiintrin.h b/gcc/config/i386/bmiintrin.h
index 8ba6e5b9a64..5bd712abbb2 100644
--- a/gcc/config/i386/bmiintrin.h
+++ b/gcc/config/i386/bmiintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <bmiintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _BMIINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/cetintrin.h b/gcc/config/i386/cetintrin.h
index 095bbe004ed..81c4d724b43 100644
--- a/gcc/config/i386/cetintrin.h
+++ b/gcc/config/i386/cetintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <cetintrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <cetintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _CETINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/cldemoteintrin.h b/gcc/config/i386/cldemoteintrin.h
index 8c0feca7eef..0c31c359a96 100644
--- a/gcc/config/i386/cldemoteintrin.h
+++ b/gcc/config/i386/cldemoteintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <cldemoteintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <cldemoteintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _CLDEMOTE_H_INCLUDED
diff --git a/gcc/config/i386/clflushoptintrin.h b/gcc/config/i386/clflushoptintrin.h
index 037f04412da..a3697f06755 100644
--- a/gcc/config/i386/clflushoptintrin.h
+++ b/gcc/config/i386/clflushoptintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <clflushoptintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <clflushoptintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _CLFLUSHOPTINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/clwbintrin.h b/gcc/config/i386/clwbintrin.h
index 84d09395d84..3f839621946 100644
--- a/gcc/config/i386/clwbintrin.h
+++ b/gcc/config/i386/clwbintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <clwbintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <clwbintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _CLWBINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/enqcmdintrin.h b/gcc/config/i386/enqcmdintrin.h
index 4b2efcb9a20..59be638aa3b 100644
--- a/gcc/config/i386/enqcmdintrin.h
+++ b/gcc/config/i386/enqcmdintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <enqcmdntrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <enqcmdintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _ENQCMDNTRIN_H_INCLUDED
diff --git a/gcc/config/i386/fxsrintrin.h b/gcc/config/i386/fxsrintrin.h
index fde05a71905..6e059df96d6 100644
--- a/gcc/config/i386/fxsrintrin.h
+++ b/gcc/config/i386/fxsrintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <fxsrintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <fxsrintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _FXSRINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/ia32intrin.h b/gcc/config/i386/ia32intrin.h
index fd29797a9fd..3568d1f4c7f 100644
--- a/gcc/config/i386/ia32intrin.h
+++ b/gcc/config/i386/ia32intrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _X86INTRIN_H_INCLUDED
-# error "Never use <ia32intrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <ia32intrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 /* 32bit bsf */
diff --git a/gcc/config/i386/immintrin.h b/gcc/config/i386/immintrin.h
index b660d0d9040..7e5c9f696d5 100644
--- a/gcc/config/i386/immintrin.h
+++ b/gcc/config/i386/immintrin.h
@@ -24,6 +24,8 @@
 #ifndef _IMMINTRIN_H_INCLUDED
 #define _IMMINTRIN_H_INCLUDED
 
+#include <x86gprintrin.h>
+
 #include <mmintrin.h>
 
 #include <xmmintrin.h>
@@ -38,16 +40,6 @@
 
 #include <wmmintrin.h>
 
-#include <fxsrintrin.h>
-
-#include <xsaveintrin.h>
-
-#include <xsaveoptintrin.h>
-
-#include <xsavesintrin.h>
-
-#include <xsavecintrin.h>
-
 #include <avxintrin.h>
 
 #include <avx2intrin.h>
@@ -102,217 +94,22 @@
 
 #include <shaintrin.h>
 
-#include <lzcntintrin.h>
-
-#include <bmiintrin.h>
-
-#include <bmi2intrin.h>
-
 #include <fmaintrin.h>
 
 #include <f16cintrin.h>
 
 #include <rtmintrin.h>
 
-#include <xtestintrin.h>
-
-#include <cetintrin.h>
-
 #include <gfniintrin.h>
 
 #include <vaesintrin.h>
 
 #include <vpclmulqdqintrin.h>
 
-#include <movdirintrin.h>
-
-#include <sgxintrin.h>
-
-#include <pconfigintrin.h>
-
-#include <waitpkgintrin.h>
-
-#include <cldemoteintrin.h>
-
 #include <avx512bf16vlintrin.h>
 
 #include <avx512bf16intrin.h>
 
-#include <enqcmdintrin.h>
-
-#include <serializeintrin.h>
-
-#include <tsxldtrkintrin.h>
-
-#include <rdseedintrin.h>
-
 #include <prfchwintrin.h>
 
-#include <adxintrin.h>
-
-#include <clwbintrin.h>
-
-#include <clflushoptintrin.h>
-
-#include <wbnoinvdintrin.h>
-
-#include <pkuintrin.h>
-
-extern __inline void
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_wbinvd (void)
-{
-  __builtin_ia32_wbinvd ();
-}
-
-#ifndef __RDRND__
-#pragma GCC push_options
-#pragma GCC target("rdrnd")
-#define __DISABLE_RDRND__
-#endif /* __RDRND__ */
-extern __inline int
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_rdrand16_step (unsigned short *__P)
-{
-  return __builtin_ia32_rdrand16_step (__P);
-}
-
-extern __inline int
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_rdrand32_step (unsigned int *__P)
-{
-  return __builtin_ia32_rdrand32_step (__P);
-}
-#ifdef __DISABLE_RDRND__
-#undef __DISABLE_RDRND__
-#pragma GCC pop_options
-#endif /* __DISABLE_RDRND__ */
-
-#ifndef __RDPID__
-#pragma GCC push_options
-#pragma GCC target("rdpid")
-#define __DISABLE_RDPID__
-#endif /* __RDPID__ */
-extern __inline unsigned int
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_rdpid_u32 (void)
-{
-  return __builtin_ia32_rdpid ();
-}
-#ifdef __DISABLE_RDPID__
-#undef __DISABLE_RDPID__
-#pragma GCC pop_options
-#endif /* __DISABLE_RDPID__ */
-
-#ifdef  __x86_64__
-
-#ifndef __FSGSBASE__
-#pragma GCC push_options
-#pragma GCC target("fsgsbase")
-#define __DISABLE_FSGSBASE__
-#endif /* __FSGSBASE__ */
-extern __inline unsigned int
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_readfsbase_u32 (void)
-{
-  return __builtin_ia32_rdfsbase32 ();
-}
-
-extern __inline unsigned long long
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_readfsbase_u64 (void)
-{
-  return __builtin_ia32_rdfsbase64 ();
-}
-
-extern __inline unsigned int
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_readgsbase_u32 (void)
-{
-  return __builtin_ia32_rdgsbase32 ();
-}
-
-extern __inline unsigned long long
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_readgsbase_u64 (void)
-{
-  return __builtin_ia32_rdgsbase64 ();
-}
-
-extern __inline void
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_writefsbase_u32 (unsigned int __B)
-{
-  __builtin_ia32_wrfsbase32 (__B);
-}
-
-extern __inline void
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_writefsbase_u64 (unsigned long long __B)
-{
-  __builtin_ia32_wrfsbase64 (__B);
-}
-
-extern __inline void
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_writegsbase_u32 (unsigned int __B)
-{
-  __builtin_ia32_wrgsbase32 (__B);
-}
-
-extern __inline void
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_writegsbase_u64 (unsigned long long __B)
-{
-  __builtin_ia32_wrgsbase64 (__B);
-}
-#ifdef __DISABLE_FSGSBASE__
-#undef __DISABLE_FSGSBASE__
-#pragma GCC pop_options
-#endif /* __DISABLE_FSGSBASE__ */
-
-#ifndef __RDRND__
-#pragma GCC push_options
-#pragma GCC target("rdrnd")
-#define __DISABLE_RDRND__
-#endif /* __RDRND__ */
-extern __inline int
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_rdrand64_step (unsigned long long *__P)
-{
-  return __builtin_ia32_rdrand64_step (__P);
-}
-#ifdef __DISABLE_RDRND__
-#undef __DISABLE_RDRND__
-#pragma GCC pop_options
-#endif /* __DISABLE_RDRND__ */
-
-#endif /* __x86_64__  */
-
-#ifndef __PTWRITE__
-#pragma GCC push_options
-#pragma GCC target("ptwrite")
-#define __DISABLE_PTWRITE__
-#endif
-
-#ifdef __x86_64__
-extern __inline void
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_ptwrite64 (unsigned long long __B)
-{
-  __builtin_ia32_ptwrite64 (__B);
-}
-#endif /* __x86_64__ */
-
-extern __inline void
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_ptwrite32 (unsigned __B)
-{
-  __builtin_ia32_ptwrite32 (__B);
-}
-#ifdef __DISABLE_PTWRITE__
-#undef __DISABLE_PTWRITE__
-#pragma GCC pop_options
-#endif /* __DISABLE_PTWRITE__ */
-
 #endif /* _IMMINTRIN_H_INCLUDED */
diff --git a/gcc/config/i386/lwpintrin.h b/gcc/config/i386/lwpintrin.h
index d7c3acb96f4..0b5c8bbf42f 100644
--- a/gcc/config/i386/lwpintrin.h
+++ b/gcc/config/i386/lwpintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _X86INTRIN_H_INCLUDED
-# error "Never use <lwpintrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <lwpintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _LWPINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/lzcntintrin.h b/gcc/config/i386/lzcntintrin.h
index 1863a58d199..6d00e9f137d 100644
--- a/gcc/config/i386/lzcntintrin.h
+++ b/gcc/config/i386/lzcntintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <lzcntintrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <lzcntintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 
diff --git a/gcc/config/i386/movdirintrin.h b/gcc/config/i386/movdirintrin.h
index e7f374abf2c..b2f8406a43c 100644
--- a/gcc/config/i386/movdirintrin.h
+++ b/gcc/config/i386/movdirintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <movdirintrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <movdirintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _MOVDIRINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/pconfigintrin.h b/gcc/config/i386/pconfigintrin.h
index d2a3261e470..31c493a912b 100644
--- a/gcc/config/i386/pconfigintrin.h
+++ b/gcc/config/i386/pconfigintrin.h
@@ -1,5 +1,28 @@
-#ifndef _IMMINTRIN_H_INCLUDED
-#error "Never use <pconfigintrin.h> directly; include <immintrin.h> instead."
+/* Copyright (C) 2018-2020 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.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <pconfigintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _PCONFIGINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/pkuintrin.h b/gcc/config/i386/pkuintrin.h
index 684091402e3..0d2dd5170a3 100644
--- a/gcc/config/i386/pkuintrin.h
+++ b/gcc/config/i386/pkuintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <pkuintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <pkuintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _PKUINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/rdseedintrin.h b/gcc/config/i386/rdseedintrin.h
index efc7cea3837..168053aedd8 100644
--- a/gcc/config/i386/rdseedintrin.h
+++ b/gcc/config/i386/rdseedintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <rdseedintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <rdseedintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _RDSEEDINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/rtmintrin.h b/gcc/config/i386/rtmintrin.h
index 463a98973ee..436e5178c47 100644
--- a/gcc/config/i386/rtmintrin.h
+++ b/gcc/config/i386/rtmintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _IMMINTRIN_H_INCLUDED
-# error "Never use <rtmintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <rtmintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _RTMINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/serializeintrin.h b/gcc/config/i386/serializeintrin.h
index 0c35b9ed1fa..95f26d6f4ac 100644
--- a/gcc/config/i386/serializeintrin.h
+++ b/gcc/config/i386/serializeintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <serializeintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <serializeintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _SERIALIZE_H_INCLUDED
diff --git a/gcc/config/i386/tbmintrin.h b/gcc/config/i386/tbmintrin.h
index c8a9d77fa2c..e03bf910e13 100644
--- a/gcc/config/i386/tbmintrin.h
+++ b/gcc/config/i386/tbmintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _X86INTRIN_H_INCLUDED
-# error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <tbmintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _TBMINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/tsxldtrkintrin.h b/gcc/config/i386/tsxldtrkintrin.h
index 08b76a9c40f..eab36d03c90 100644
--- a/gcc/config/i386/tsxldtrkintrin.h
+++ b/gcc/config/i386/tsxldtrkintrin.h
@@ -1,5 +1,28 @@
-#if !defined _IMMINTRIN_H_INCLUDED
-#error "Never use <tsxldtrkintrin.h> directly; include <immintrin.h> instead."
+/* Copyright (C) 2020 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.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <tsxldtrkintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _TSXLDTRKINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/waitpkgintrin.h b/gcc/config/i386/waitpkgintrin.h
index 5dbcde3a5c7..5046c986054 100644
--- a/gcc/config/i386/waitpkgintrin.h
+++ b/gcc/config/i386/waitpkgintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <waitpkgintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <waitpkgintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _WAITPKG_H_INCLUDED
diff --git a/gcc/config/i386/wbnoinvdintrin.h b/gcc/config/i386/wbnoinvdintrin.h
index 5393698c6bb..7089e619018 100644
--- a/gcc/config/i386/wbnoinvdintrin.h
+++ b/gcc/config/i386/wbnoinvdintrin.h
@@ -1,5 +1,28 @@
-#ifndef _IMMINTRIN_H_INCLUDED
-#error "Never use <wbnoinvdintrin.h> directly; include <immintrin.h> instead."
+/* Copyright (C) 2018-2020 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.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <wbnoinvdintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _WBNOINVDINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/x86gprintrin.h b/gcc/config/i386/x86gprintrin.h
new file mode 100644
index 00000000000..ecfb1c0e67f
--- /dev/null
+++ b/gcc/config/i386/x86gprintrin.h
@@ -0,0 +1,252 @@
+/* Copyright (C) 2020 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.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _X86GPRINTRIN_H_INCLUDED
+#define _X86GPRINTRIN_H_INCLUDED
+
+#include <ia32intrin.h>
+
+#ifndef __iamcu__
+
+#include <stddef.h>
+
+#include <adxintrin.h>
+
+#include <bmiintrin.h>
+
+#include <bmi2intrin.h>
+
+#include <cetintrin.h>
+
+#include <cldemoteintrin.h>
+
+#include <clflushoptintrin.h>
+
+#include <clwbintrin.h>
+
+#include <clzerointrin.h>
+
+#include <enqcmdintrin.h>
+
+#include <fxsrintrin.h>
+
+#include <lzcntintrin.h>
+
+#include <lwpintrin.h>
+
+#include <movdirintrin.h>
+
+#include <mwaitxintrin.h>
+
+#include <pconfigintrin.h>
+
+#include <popcntintrin.h>
+
+#include <pkuintrin.h>
+
+#include <rdseedintrin.h>
+
+#include <rtmintrin.h>
+
+#include <serializeintrin.h>
+
+#include <sgxintrin.h>
+
+#include <tbmintrin.h>
+
+#include <tsxldtrkintrin.h>
+
+#include <waitpkgintrin.h>
+
+#include <wbnoinvdintrin.h>
+
+#include <xsaveintrin.h>
+
+#include <xsavecintrin.h>
+
+#include <xsaveoptintrin.h>
+
+#include <xsavesintrin.h>
+
+#include <xtestintrin.h>
+
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_wbinvd (void)
+{
+  __builtin_ia32_wbinvd ();
+}
+
+#ifndef __RDRND__
+#pragma GCC push_options
+#pragma GCC target("rdrnd")
+#define __DISABLE_RDRND__
+#endif /* __RDRND__ */
+extern __inline int
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_rdrand16_step (unsigned short *__P)
+{
+  return __builtin_ia32_rdrand16_step (__P);
+}
+
+extern __inline int
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_rdrand32_step (unsigned int *__P)
+{
+  return __builtin_ia32_rdrand32_step (__P);
+}
+#ifdef __DISABLE_RDRND__
+#undef __DISABLE_RDRND__
+#pragma GCC pop_options
+#endif /* __DISABLE_RDRND__ */
+
+#ifndef __RDPID__
+#pragma GCC push_options
+#pragma GCC target("rdpid")
+#define __DISABLE_RDPID__
+#endif /* __RDPID__ */
+extern __inline unsigned int
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_rdpid_u32 (void)
+{
+  return __builtin_ia32_rdpid ();
+}
+#ifdef __DISABLE_RDPID__
+#undef __DISABLE_RDPID__
+#pragma GCC pop_options
+#endif /* __DISABLE_RDPID__ */
+
+#ifdef  __x86_64__
+
+#ifndef __FSGSBASE__
+#pragma GCC push_options
+#pragma GCC target("fsgsbase")
+#define __DISABLE_FSGSBASE__
+#endif /* __FSGSBASE__ */
+extern __inline unsigned int
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_readfsbase_u32 (void)
+{
+  return __builtin_ia32_rdfsbase32 ();
+}
+
+extern __inline unsigned long long
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_readfsbase_u64 (void)
+{
+  return __builtin_ia32_rdfsbase64 ();
+}
+
+extern __inline unsigned int
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_readgsbase_u32 (void)
+{
+  return __builtin_ia32_rdgsbase32 ();
+}
+
+extern __inline unsigned long long
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_readgsbase_u64 (void)
+{
+  return __builtin_ia32_rdgsbase64 ();
+}
+
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_writefsbase_u32 (unsigned int __B)
+{
+  __builtin_ia32_wrfsbase32 (__B);
+}
+
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_writefsbase_u64 (unsigned long long __B)
+{
+  __builtin_ia32_wrfsbase64 (__B);
+}
+
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_writegsbase_u32 (unsigned int __B)
+{
+  __builtin_ia32_wrgsbase32 (__B);
+}
+
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_writegsbase_u64 (unsigned long long __B)
+{
+  __builtin_ia32_wrgsbase64 (__B);
+}
+#ifdef __DISABLE_FSGSBASE__
+#undef __DISABLE_FSGSBASE__
+#pragma GCC pop_options
+#endif /* __DISABLE_FSGSBASE__ */
+
+#ifndef __RDRND__
+#pragma GCC push_options
+#pragma GCC target("rdrnd")
+#define __DISABLE_RDRND__
+#endif /* __RDRND__ */
+extern __inline int
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_rdrand64_step (unsigned long long *__P)
+{
+  return __builtin_ia32_rdrand64_step (__P);
+}
+#ifdef __DISABLE_RDRND__
+#undef __DISABLE_RDRND__
+#pragma GCC pop_options
+#endif /* __DISABLE_RDRND__ */
+
+#endif /* __x86_64__  */
+
+#ifndef __PTWRITE__
+#pragma GCC push_options
+#pragma GCC target("ptwrite")
+#define __DISABLE_PTWRITE__
+#endif
+
+#ifdef __x86_64__
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_ptwrite64 (unsigned long long __B)
+{
+  __builtin_ia32_ptwrite64 (__B);
+}
+#endif /* __x86_64__ */
+
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_ptwrite32 (unsigned __B)
+{
+  __builtin_ia32_ptwrite32 (__B);
+}
+#ifdef __DISABLE_PTWRITE__
+#undef __DISABLE_PTWRITE__
+#pragma GCC pop_options
+#endif /* __DISABLE_PTWRITE__ */
+
+#endif /* __iamcu__ */
+
+#endif /* _X86GPRINTRIN_H_INCLUDED.  */
diff --git a/gcc/config/i386/x86intrin.h b/gcc/config/i386/x86intrin.h
index 59fdcebc82b..bc6cb40901f 100644
--- a/gcc/config/i386/x86intrin.h
+++ b/gcc/config/i386/x86intrin.h
@@ -24,7 +24,7 @@
 #ifndef _X86INTRIN_H_INCLUDED
 #define _X86INTRIN_H_INCLUDED
 
-#include <ia32intrin.h>
+#include <x86gprintrin.h>
 
 #ifndef __iamcu__
 
@@ -37,16 +37,6 @@
 
 #include <xopintrin.h>
 
-#include <lwpintrin.h>
-
-#include <tbmintrin.h>
-
-#include <popcntintrin.h>
-
-#include <mwaitxintrin.h>
-
-#include <clzerointrin.h>
-
 #endif /* __iamcu__ */
 
 #endif /* _X86INTRIN_H_INCLUDED */
diff --git a/gcc/config/i386/xsavecintrin.h b/gcc/config/i386/xsavecintrin.h
index 039e2155288..06c9f367cde 100644
--- a/gcc/config/i386/xsavecintrin.h
+++ b/gcc/config/i386/xsavecintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <xsavecintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <xsavecintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _XSAVECINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/xsaveintrin.h b/gcc/config/i386/xsaveintrin.h
index 9f0b8bb0cc9..f9cac0d422e 100644
--- a/gcc/config/i386/xsaveintrin.h
+++ b/gcc/config/i386/xsaveintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <xsaveintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <xsaveintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _XSAVEINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/xsaveoptintrin.h b/gcc/config/i386/xsaveoptintrin.h
index 9da3297fe4e..4f2756b9fd6 100644
--- a/gcc/config/i386/xsaveoptintrin.h
+++ b/gcc/config/i386/xsaveoptintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <xsaveoptintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <xsaveoptintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _XSAVEOPTINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/xsavesintrin.h b/gcc/config/i386/xsavesintrin.h
index 264f1c4098f..629a1f375a4 100644
--- a/gcc/config/i386/xsavesintrin.h
+++ b/gcc/config/i386/xsavesintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if !defined _IMMINTRIN_H_INCLUDED
-# error "Never use <xsavesintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <xsavesintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _XSAVESINTRIN_H_INCLUDED
diff --git a/gcc/config/i386/xtestintrin.h b/gcc/config/i386/xtestintrin.h
index cb187e4dc77..757cc345108 100644
--- a/gcc/config/i386/xtestintrin.h
+++ b/gcc/config/i386/xtestintrin.h
@@ -21,8 +21,8 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _IMMINTRIN_H_INCLUDED
-# error "Never use <xtestintrin.h> directly; include <immintrin.h> instead."
+#ifndef _X86GPRINTRIN_H_INCLUDED
+# error "Never use <xtestintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _XTESTINTRIN_H_INCLUDED
diff --git a/gcc/testsuite/gcc.target/i386/avx-1.c b/gcc/testsuite/gcc.target/i386/avx-1.c
index 3600a7abe91..2dbed1cc943 100644
--- a/gcc/testsuite/gcc.target/i386/avx-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx-1.c
@@ -680,6 +680,16 @@
 #define __builtin_ia32_vpclmulqdq_v2di(A, B, C)  __builtin_ia32_vpclmulqdq_v2di(A, B, 1) 
 #define __builtin_ia32_vpclmulqdq_v8di(A, B, C)  __builtin_ia32_vpclmulqdq_v8di(A, B, 1) 
 
+/* lwpintrin.h */
+#define __builtin_ia32_lwpval32(D2, D1, F) __builtin_ia32_lwpval32 (D2, D1, 1)
+#define __builtin_ia32_lwpval64(D2, D1, F) __builtin_ia32_lwpval64 (D2, D1, 1)
+#define __builtin_ia32_lwpins32(D2, D1, F) __builtin_ia32_lwpins32 (D2, D1, 1)
+#define __builtin_ia32_lwpins64(D2, D1, F) __builtin_ia32_lwpins64 (D2, D1, 1)
+
+/* tbmintrin.h */
+#define __builtin_ia32_bextri_u32(X, Y) __builtin_ia32_bextri_u32 (X, 1)
+#define __builtin_ia32_bextri_u64(X, Y) __builtin_ia32_bextri_u64 (X, 1)
+
 #include <wmmintrin.h>
 #include <immintrin.h>
 #include <mm3dnow.h>
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-1.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-1.c
new file mode 100644
index 00000000000..d9c759bde4e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-1.c
@@ -0,0 +1,7 @@
+/* Test that <x86gprintrin.h> is usable with -O -std=c89 -pedantic-errors.  */
+/* { dg-do compile } */
+/* { dg-options "-O -std=c89 -pedantic-errors -march=x86-64 -madx -mbmi -mbmi2 -mcldemote -mclflushopt -mclwb -mclzero -menqcmd -mfsgsbase -mfxsr -mlzcnt -mlwp -mmovdiri -mmwaitx -mpconfig -mpopcnt -mpku -mptwrite -mrdpid -mrdrnd -mrdseed -mrtm -mserialize -msgx -mshstk -mtbm -mtsxldtrk -mwaitpkg -mwbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-sse -mno-mmx" } */
+
+#include <x86gprintrin.h>
+
+int dummy;
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-2.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-2.c
new file mode 100644
index 00000000000..5ea47726405
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-2.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Werror-implicit-function-declaration -march=x86-64 -madx -mbmi -mbmi2 -mcldemote -mclflushopt -mclwb -mclzero -menqcmd -mfsgsbase -mfxsr -mlzcnt -mlwp -mmovdiri -mmwaitx -mpconfig -mpopcnt -mpku -mptwrite -mrdpid -mrdrnd -mrdseed -mrtm -mserialize -msgx -mshstk -mtbm -mtsxldtrk -mwaitpkg -mwbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-sse -mno-mmx" } */
+/* { dg-add-options bind_pic_locally } */
+
+/* Test that the intrinsics in <x86gprintrin.h> compile with optimization.
+   All of them are defined as inline functions that reference the proper
+   builtin functions.
+
+   Defining away "extern" and "__inline" results in all of them being
+   compiled as proper functions.  */
+
+#define extern
+#define __inline
+
+/* Following intrinsics require immediate arguments. */
+
+/* lwpintrin.h */
+#define __builtin_ia32_lwpval32(D2, D1, F) __builtin_ia32_lwpval32 (D2, D1, 1)
+#define __builtin_ia32_lwpval64(D2, D1, F) __builtin_ia32_lwpval64 (D2, D1, 1)
+#define __builtin_ia32_lwpins32(D2, D1, F) __builtin_ia32_lwpins32 (D2, D1, 1)
+#define __builtin_ia32_lwpins64(D2, D1, F) __builtin_ia32_lwpins64 (D2, D1, 1)
+
+/* tbmintrin.h */
+#define __builtin_ia32_bextri_u32(X, Y) __builtin_ia32_bextri_u32 (X, 1)
+#define __builtin_ia32_bextri_u64(X, Y) __builtin_ia32_bextri_u64 (X, 1)
+
+/* rtmintrin.h */
+#define __builtin_ia32_xabort(N) __builtin_ia32_xabort(1)
+
+#include <x86gprintrin.h>
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-3.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-3.c
new file mode 100644
index 00000000000..01d3f7878b0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -Werror-implicit-function-declaration -march=x86-64 -madx -mbmi -mbmi2 -mcldemote -mclflushopt -mclwb -mclzero -menqcmd -mfsgsbase -mfxsr -mlzcnt -mlwp -mmovdiri -mmwaitx -mpconfig -mpopcnt -mpku -mptwrite -mrdpid -mrdrnd -mrdseed -mrtm -mserialize -msgx -mshstk -mtbm -mtsxldtrk -mwaitpkg -mwbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-sse -mno-mmx" } */
+/* { dg-add-options bind_pic_locally } */
+
+/* Test that the intrinsics in <x86gprintrin.h> compile without optimization.
+   All of them are defined as inline functions that reference the proper
+   builtin functions.
+
+   Defining away "extern" and "__inline" results in all of them being compiled
+   as proper functions.  */
+
+#define extern
+#define __inline
+
+#include <x86gprintrin.h>
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-4.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-4.c
new file mode 100644
index 00000000000..053f07bc17f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-4.c
@@ -0,0 +1,30 @@
+/* Same as x86gprintrin-3.c, except converted to use #pragma GCC option.  */
+/* { dg-do compile } */
+/* { dg-options "-O0 -Werror-implicit-function-declaration -march=x86-64 -mno-sse -mno-mmx" } */
+/* { dg-add-options bind_pic_locally } */
+
+/* Test that the intrinsics in <x86gprintrin.h> compile without optimization.
+   All of them are defined as inline functions that reference the proper
+   builtin functions.
+
+   Defining away "extern" and "__inline" results in all of them being
+   compiled as proper functions.  */
+
+#define extern
+#define __inline
+
+#ifndef DIFFERENT_PRAGMAS
+#pragma GCC target ("adx,bmi,bmi2,fsgsbase,fxsr,lwp,lzcnt,popcnt,rdrnd,rdseed,tbm,rtm,serialize,tsxldtrk,xsaveopt")
+#endif
+
+/* popcnintrin.h (POPCNT).  */
+#ifdef DIFFERENT_PRAGMAS
+#pragma GCC target ("popcnt")
+#endif
+#include <popcntintrin.h>
+
+/* x86intrin.h (LWP/BMI/BMI2/TBM/LZCNT). */
+#ifdef DIFFERENT_PRAGMAS
+#pragma GCC target ("lwp,bmi,bmi2,tbm,lzcnt")
+#endif
+#include <x86gprintrin.h>
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-4a.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-4a.c
new file mode 100644
index 00000000000..f6e9c70ebb5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-4a.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -Werror-implicit-function-declaration -march=k8" } */
+/* { dg-add-options bind_pic_locally } */
+
+#define DIFFERENT_PRAGMAS
+
+#include "x86gprintrin-4.c"
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-5.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-5.c
new file mode 100644
index 00000000000..fe9c5c770ae
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-5.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Werror-implicit-function-declaration -march=x86-64 -mno-sse -mno-mmx" } */
+/* { dg-add-options bind_pic_locally } */
+
+/* Test that the intrinsics in <x86gprintrin.h> compile with optimization.
+   All of them are defined as inline functions that reference the proper
+   builtin functions.
+
+   Defining away "extern" and "__inline" results in all of them being
+   compiled as proper functions.  */
+
+#define extern
+#define __inline
+
+/* Following intrinsics require immediate arguments. */
+
+/* lwpintrin.h */
+#define __builtin_ia32_lwpval32(D2, D1, F) __builtin_ia32_lwpval32 (D2, D1, 1)
+#define __builtin_ia32_lwpval64(D2, D1, F) __builtin_ia32_lwpval64 (D2, D1, 1)
+#define __builtin_ia32_lwpins32(D2, D1, F) __builtin_ia32_lwpins32 (D2, D1, 1)
+#define __builtin_ia32_lwpins64(D2, D1, F) __builtin_ia32_lwpins64 (D2, D1, 1)
+
+/* tbmintrin.h */
+#define __builtin_ia32_bextri_u32(X, Y) __builtin_ia32_bextr_u32 (X, 1)
+#define __builtin_ia32_bextri_u64(X, Y) __builtin_ia32_bextr_u64 (X, 1)
+
+/* rtmintrin.h */
+#define __builtin_ia32_xabort(M) __builtin_ia32_xabort(1)
+
+#pragma GCC target ("adx,bmi,bmi2,clflushopt,clwb,clzero,enqcmd,fsgsbase,fxsr,lwp,lzcnt,mwaitx,pconfig,pku,popcnt,rdpid,rdrnd,rdseed,tbm,rtm,serialize,sgx,tsxldtrk,xsavec,xsaveopt,xsaves,wbnoinvd")
+
+#include <x86gprintrin.h>
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-5a.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-5a.c
new file mode 100644
index 00000000000..6670a252c22
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-5a.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -Werror-implicit-function-declaration -march=k8 -mno-sse -mno-mmx" } */
+/* { dg-add-options bind_pic_locally } */
+
+#include "x86gprintrin-5.c"
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-5b.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-5b.c
new file mode 100644
index 00000000000..f76bb2424ea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-5b.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -Werror-implicit-function-declaration -march=k8 -funsigned-char -mno-sse -mno-mmx" } */
+/* { dg-add-options bind_pic_locally } */
+
+#include "x86gprintrin-5.c"
diff --git a/gcc/testsuite/gcc.target/i386/x86gprintrin-6.c b/gcc/testsuite/gcc.target/i386/x86gprintrin-6.c
new file mode 100644
index 00000000000..40e84dc3d74
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/x86gprintrin-6.c
@@ -0,0 +1,11 @@
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O2 -miamcu" } */
+/* { dg-add-options bind_pic_locally } */
+
+/* Defining away "extern" and "__inline" results in all of them being
+   compiled as proper functions.  */
+
+#define extern
+#define __inline
+
+#include <x86gprintrin.h>
diff --git a/libgcc/config/i386/shadow-stack-unwind.h b/libgcc/config/i386/shadow-stack-unwind.h
index 201b2153113..ff979da6f10 100644
--- a/libgcc/config/i386/shadow-stack-unwind.h
+++ b/libgcc/config/i386/shadow-stack-unwind.h
@@ -22,14 +22,7 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-/* NB: We need _get_ssp and _inc_ssp from <cetintrin.h>.  But we can't
-   include <x86intrin.h> which ends up including <mm_malloc.h>, which
-   includes <stdlib.h> and <errno.h> unconditionally.  But we can't
-   include any libc system headers unconditionally from libgcc.  Avoid
-   including <mm_malloc.h> here by defining _IMMINTRIN_H_INCLUDED.  */
-#define _IMMINTRIN_H_INCLUDED
-#include <cetintrin.h>
-#undef _IMMINTRIN_H_INCLUDED
+#include <x86gprintrin.h>
 
 /* Unwind the shadow stack for EH.  */
 #undef _Unwind_Frames_Extra
-- 
2.26.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* PING: [PATCH] x86: Add <x86gprintrin.h>
  2020-09-23 17:58 [PATCH] x86: Add <x86gprintrin.h> H.J. Lu
@ 2020-10-02 12:51 ` H.J. Lu
  2020-10-08 12:12   ` PING^2 " H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2020-10-02 12:51 UTC (permalink / raw)
  To: GCC Patches, Jeffrey Law, Richard Biener, Jakub Jelinek, Jan Hubicka

On Wed, Sep 23, 2020 at 10:58 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> For sources which can't use any vector instructions, <x86intrin.h> and
> <immintrin.h> cannot be included for compiler intrinsics:
>
> $ echo "#include <x86intrin.h>" | gcc -S -O2 -mno-sse -mno-mmx -x c -
> In file included from /usr/include/stdlib.h:1013,
>                  from /usr/lib/gcc/x86_64-redhat-linux/10/include/mm_malloc.h:27,
>                  from /usr/lib/gcc/x86_64-redhat-linux/10/include/xmmintrin.h:34,
>                  from /usr/lib/gcc/x86_64-redhat-linux/10/include/immintrin.h:29,
>                  from /usr/lib/gcc/x86_64-redhat-linux/10/include/x86intrin.h:32,
>                  from <stdin>:1:
> /usr/include/bits/stdlib-float.h: In function ‘atof’:
> /usr/include/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
>    26 | {
>       | ^
> $
>
> libgcc/config/i386/shadow-stack-unwind.h has a workaround:
>
> /* NB: We need _get_ssp and _inc_ssp from <cetintrin.h>.  But we can't
>    include <x86intrin.h> which ends up including <mm_malloc.h>, which
>    includes <stdlib.h> and <errno.h> unconditionally.  But we can't
>    include any libc system headers unconditionally from libgcc.  Avoid
>    including <mm_malloc.h> here by defining _IMMINTRIN_H_INCLUDED.  */
>  #define _IMMINTRIN_H_INCLUDED
>  #include <cetintrin.h>
>  #undef _IMMINTRIN_H_INCLUDED
>
> Add a standalone intrinsic header file, <x86gprintrin.h>, to provide
> integer only intrinsics.  All integer only intrinsics are placed in
> <x86gprintrin.h>.  <x86intrin.h> and <immintrin.h> simply include
> <x86gprintrin.h>.
>
> Add the FSF copyright to <pconfigintrin.h>, <tsxldtrkintrin.h> and
> <wbnoinvdintrin.h>.
>
> gcc/
>
>         PR target/97148
>         * config.gcc (extra_headers): Add x86gprintrin.h.
>         * config/i386/adxintrin.h: Check _X86GPRINTRIN_H_INCLUDED for
>         <x86gprintrin.h>.
>         * config/i386/bmi2intrin.h: Likewise.
>         * config/i386/bmiintrin.h: Likewise.
>         * config/i386/cetintrin.h: Likewise.
>         * config/i386/cldemoteintrin.h: Likewise.
>         * config/i386/clflushoptintrin.h: Likewise.
>         * config/i386/clwbintrin.h: Likewise.
>         * config/i386/fxsrintrin.h: Likewise.
>         * config/i386/ia32intrin.h: Likewise.
>         * config/i386/lwpintrin.h: Likewise.
>         * config/i386/lzcntintrin.h: Likewise.
>         * config/i386/movdirintrin.h: Likewise.
>         * config/i386/pkuintrin.h: Likewise.
>         * config/i386/rdseedintrin.h: Likewise.
>         * config/i386/rtmintrin.h: Likewise.
>         * config/i386/serializeintrin.h: Likewise.
>         * config/i386/tbmintrin.h: Likewise.
>         * config/i386/waitpkgintrin.h: Likewise.
>         * config/i386/xsavecintrin.h: Likewise.
>         * config/i386/xsaveintrin.h: Likewise.
>         * config/i386/xsaveoptintrin.h: Likewise.
>         * config/i386/xsavesintrin.h: Likewise.
>         * config/i386/xtestintrin.h: Likewise.
>         * config/i386/enqcmdintrin.h: Check _X86GPRINTRIN_H_INCLUDED for
>         <x86gprintrin.h>.  Replace <enqcmdntrin.h> with <enqcmdintrin.h>
>         in the error message.
>         * config/i386/immintrin.h: Include <x86gprintrin.h> instead of
>         <fxsrintrin.h>, <xsaveintrin.h>, <xsaveoptintrin.h>,
>         <xsavesintrin.h>, <xsavecintrin.h>, <lzcntintrin.h>,
>         <bmiintrin.h>, <bmi2intrin.h>, <xtestintrin.h>, <cetintrin.h>,
>         <movdirintrin.h>, <sgxintrin.h, <pconfigintrin.h>,
>         <waitpkgintrin.h>, <cldemoteintrin.h>, <enqcmdintrin.h>,
>         <serializeintrin.h>, <tsxldtrkintrin.h>, <adxintrin.h>,
>         <clwbintrin.h>, <clflushoptintrin.h>, <wbnoinvdintrin.h> and
>         <pkuintrin.h>.
>         (_wbinvd): Moved to config/i386/x86gprintrin.h.
>         (_rdrand16_step): Likewise.
>         (_rdrand32_step): Likewise.
>         (_rdpid_u32): Likewise.
>         (_readfsbase_u32): Likewise.
>         (_readfsbase_u64): Likewise.
>         (_readgsbase_u32): Likewise.
>         (_readgsbase_u64): Likewise.
>         (_writefsbase_u32): Likewise.
>         (_writefsbase_u64): Likewise.
>         (_writegsbase_u32): Likewise.
>         (_writegsbase_u64): Likewise.
>         (_rdrand64_step): Likewise.
>         (_ptwrite64): Likewise.
>         (_ptwrite32): Likewise.
>         * config/i386/x86gprintrin.h: New file.
>         * config/i386/pconfigintrin.h: Add the FSF copyright.  Check
>         _X86GPRINTRIN_H_INCLUDED for <x86gprintrin.h>.
>         * config/i386/tsxldtrkintrin.h: Likewise.
>         * config/i386/wbnoinvdintrin.h: Likewise.
>         * config/i386/x86intrin.h: Include <x86gprintrin.h>.  Don't
>         include <ia32intrin.h>, <lwpintrin.h>, <tbmintrin.h>,
>         <popcntintrin.h>, <mwaitxintrin.h> and <clzerointrin.h>.
>
> gcc/testsuite/
>
>         * gcc.target/i386/avx-1.c (__builtin_ia32_lwpval32): New to
>         support <lwpintrin.h> included in <x86gprintrin.h>.
>         (__builtin_ia32_lwpval64): Likewise.
>         (__builtin_ia32_lwpins32): Likewise.
>         (__builtin_ia32_lwpins64): Likewise.
>         (__builtin_ia32_bextri_u32): New to support <tbmintrin.h>
>         included in <x86gprintrin.h>.
>         (__builtin_ia32_bextri_u64): Likewise.
>         * gcc.target/i386/x86gprintrin-1.c: New test.
>         * gcc.target/i386/x86gprintrin-2.c: Likewise.
>         * gcc.target/i386/x86gprintrin-3.c: Likewise.
>         * gcc.target/i386/x86gprintrin-4.c: Likewise.
>         * gcc.target/i386/x86gprintrin-4a.c: Likewise.
>         * gcc.target/i386/x86gprintrin-5.c: Likewise.
>         * gcc.target/i386/x86gprintrin-5a.c: Likewise.
>         * gcc.target/i386/x86gprintrin-5b.c: Likewise.
>         * gcc.target/i386/x86gprintrin-6.c: Likewise.
>
> libgcc/
>
>         PR target/97148
>         * config/i386/shadow-stack-unwind.h: Include <x86gprintrin.h>
>         instead of <cetintrin.h>.

PING:

https://gcc.gnu.org/pipermail/gcc-patches/2020-September/554642.html


-- 
H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* PING^2 [PATCH] x86: Add <x86gprintrin.h>
  2020-10-02 12:51 ` PING: " H.J. Lu
@ 2020-10-08 12:12   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2020-10-08 12:12 UTC (permalink / raw)
  To: GCC Patches, Jeffrey Law, Richard Biener, Jakub Jelinek, Jan Hubicka

On Fri, Oct 2, 2020 at 5:51 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Wed, Sep 23, 2020 at 10:58 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > For sources which can't use any vector instructions, <x86intrin.h> and
> > <immintrin.h> cannot be included for compiler intrinsics:
> >
> > $ echo "#include <x86intrin.h>" | gcc -S -O2 -mno-sse -mno-mmx -x c -
> > In file included from /usr/include/stdlib.h:1013,
> >                  from /usr/lib/gcc/x86_64-redhat-linux/10/include/mm_malloc.h:27,
> >                  from /usr/lib/gcc/x86_64-redhat-linux/10/include/xmmintrin.h:34,
> >                  from /usr/lib/gcc/x86_64-redhat-linux/10/include/immintrin.h:29,
> >                  from /usr/lib/gcc/x86_64-redhat-linux/10/include/x86intrin.h:32,
> >                  from <stdin>:1:
> > /usr/include/bits/stdlib-float.h: In function ‘atof’:
> > /usr/include/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
> >    26 | {
> >       | ^
> > $
> >
> > libgcc/config/i386/shadow-stack-unwind.h has a workaround:
> >
> > /* NB: We need _get_ssp and _inc_ssp from <cetintrin.h>.  But we can't
> >    include <x86intrin.h> which ends up including <mm_malloc.h>, which
> >    includes <stdlib.h> and <errno.h> unconditionally.  But we can't
> >    include any libc system headers unconditionally from libgcc.  Avoid
> >    including <mm_malloc.h> here by defining _IMMINTRIN_H_INCLUDED.  */
> >  #define _IMMINTRIN_H_INCLUDED
> >  #include <cetintrin.h>
> >  #undef _IMMINTRIN_H_INCLUDED
> >
> > Add a standalone intrinsic header file, <x86gprintrin.h>, to provide
> > integer only intrinsics.  All integer only intrinsics are placed in
> > <x86gprintrin.h>.  <x86intrin.h> and <immintrin.h> simply include
> > <x86gprintrin.h>.
> >
> > Add the FSF copyright to <pconfigintrin.h>, <tsxldtrkintrin.h> and
> > <wbnoinvdintrin.h>.
> >
> > gcc/
> >
> >         PR target/97148
> >         * config.gcc (extra_headers): Add x86gprintrin.h.
> >         * config/i386/adxintrin.h: Check _X86GPRINTRIN_H_INCLUDED for
> >         <x86gprintrin.h>.
> >         * config/i386/bmi2intrin.h: Likewise.
> >         * config/i386/bmiintrin.h: Likewise.
> >         * config/i386/cetintrin.h: Likewise.
> >         * config/i386/cldemoteintrin.h: Likewise.
> >         * config/i386/clflushoptintrin.h: Likewise.
> >         * config/i386/clwbintrin.h: Likewise.
> >         * config/i386/fxsrintrin.h: Likewise.
> >         * config/i386/ia32intrin.h: Likewise.
> >         * config/i386/lwpintrin.h: Likewise.
> >         * config/i386/lzcntintrin.h: Likewise.
> >         * config/i386/movdirintrin.h: Likewise.
> >         * config/i386/pkuintrin.h: Likewise.
> >         * config/i386/rdseedintrin.h: Likewise.
> >         * config/i386/rtmintrin.h: Likewise.
> >         * config/i386/serializeintrin.h: Likewise.
> >         * config/i386/tbmintrin.h: Likewise.
> >         * config/i386/waitpkgintrin.h: Likewise.
> >         * config/i386/xsavecintrin.h: Likewise.
> >         * config/i386/xsaveintrin.h: Likewise.
> >         * config/i386/xsaveoptintrin.h: Likewise.
> >         * config/i386/xsavesintrin.h: Likewise.
> >         * config/i386/xtestintrin.h: Likewise.
> >         * config/i386/enqcmdintrin.h: Check _X86GPRINTRIN_H_INCLUDED for
> >         <x86gprintrin.h>.  Replace <enqcmdntrin.h> with <enqcmdintrin.h>
> >         in the error message.
> >         * config/i386/immintrin.h: Include <x86gprintrin.h> instead of
> >         <fxsrintrin.h>, <xsaveintrin.h>, <xsaveoptintrin.h>,
> >         <xsavesintrin.h>, <xsavecintrin.h>, <lzcntintrin.h>,
> >         <bmiintrin.h>, <bmi2intrin.h>, <xtestintrin.h>, <cetintrin.h>,
> >         <movdirintrin.h>, <sgxintrin.h, <pconfigintrin.h>,
> >         <waitpkgintrin.h>, <cldemoteintrin.h>, <enqcmdintrin.h>,
> >         <serializeintrin.h>, <tsxldtrkintrin.h>, <adxintrin.h>,
> >         <clwbintrin.h>, <clflushoptintrin.h>, <wbnoinvdintrin.h> and
> >         <pkuintrin.h>.
> >         (_wbinvd): Moved to config/i386/x86gprintrin.h.
> >         (_rdrand16_step): Likewise.
> >         (_rdrand32_step): Likewise.
> >         (_rdpid_u32): Likewise.
> >         (_readfsbase_u32): Likewise.
> >         (_readfsbase_u64): Likewise.
> >         (_readgsbase_u32): Likewise.
> >         (_readgsbase_u64): Likewise.
> >         (_writefsbase_u32): Likewise.
> >         (_writefsbase_u64): Likewise.
> >         (_writegsbase_u32): Likewise.
> >         (_writegsbase_u64): Likewise.
> >         (_rdrand64_step): Likewise.
> >         (_ptwrite64): Likewise.
> >         (_ptwrite32): Likewise.
> >         * config/i386/x86gprintrin.h: New file.
> >         * config/i386/pconfigintrin.h: Add the FSF copyright.  Check
> >         _X86GPRINTRIN_H_INCLUDED for <x86gprintrin.h>.
> >         * config/i386/tsxldtrkintrin.h: Likewise.
> >         * config/i386/wbnoinvdintrin.h: Likewise.
> >         * config/i386/x86intrin.h: Include <x86gprintrin.h>.  Don't
> >         include <ia32intrin.h>, <lwpintrin.h>, <tbmintrin.h>,
> >         <popcntintrin.h>, <mwaitxintrin.h> and <clzerointrin.h>.
> >
> > gcc/testsuite/
> >
> >         * gcc.target/i386/avx-1.c (__builtin_ia32_lwpval32): New to
> >         support <lwpintrin.h> included in <x86gprintrin.h>.
> >         (__builtin_ia32_lwpval64): Likewise.
> >         (__builtin_ia32_lwpins32): Likewise.
> >         (__builtin_ia32_lwpins64): Likewise.
> >         (__builtin_ia32_bextri_u32): New to support <tbmintrin.h>
> >         included in <x86gprintrin.h>.
> >         (__builtin_ia32_bextri_u64): Likewise.
> >         * gcc.target/i386/x86gprintrin-1.c: New test.
> >         * gcc.target/i386/x86gprintrin-2.c: Likewise.
> >         * gcc.target/i386/x86gprintrin-3.c: Likewise.
> >         * gcc.target/i386/x86gprintrin-4.c: Likewise.
> >         * gcc.target/i386/x86gprintrin-4a.c: Likewise.
> >         * gcc.target/i386/x86gprintrin-5.c: Likewise.
> >         * gcc.target/i386/x86gprintrin-5a.c: Likewise.
> >         * gcc.target/i386/x86gprintrin-5b.c: Likewise.
> >         * gcc.target/i386/x86gprintrin-6.c: Likewise.
> >
> > libgcc/
> >
> >         PR target/97148
> >         * config/i386/shadow-stack-unwind.h: Include <x86gprintrin.h>
> >         instead of <cetintrin.h>.
>
> PING:
>
> https://gcc.gnu.org/pipermail/gcc-patches/2020-September/554642.html
>

There are no codegen changes.  I will check it in tomorrow if there
are objections.

-- 
H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-08 12:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-23 17:58 [PATCH] x86: Add <x86gprintrin.h> H.J. Lu
2020-10-02 12:51 ` PING: " H.J. Lu
2020-10-08 12:12   ` PING^2 " H.J. Lu

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).