public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR target/66746: Failure to compile #include <x86intrin.h> with -miamcu
@ 2015-07-03  3:53 H.J. Lu
  2015-07-03  6:16 ` Uros Bizjak
  0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2015-07-03  3:53 UTC (permalink / raw)
  To: gcc-patches; +Cc: ubizjak

x86intrin.h has useful intrinsics for instructions for IA MCU.  This
patch adds __iamcu__ check to x86intrin.h and ia32intrin.h.

OK for trunk?

H.J.
---
gcc/

	PR target/66746
	* config/i386/ia32intrin.h (__crc32b): Don't define if __iamcu__
	is defined.
	(__crc32w): Likewise.
	(__crc32d): Likewise.
	(__rdpmc): Likewise.
	(__rdtscp): Likewise.
	(_rdpmc): Likewise.
	(_rdtscp): Likewise.
	* config/i386/x86intrin.h: Only include ia32intrin.h if __iamcu__
	is defined.

gcc/testsuite/

	PR target/66746
	* gcc.target/i386/pr66746.c: New file.
---
 gcc/config/i386/ia32intrin.h            | 16 +++++++++++++++-
 gcc/config/i386/x86intrin.h             |  5 +++++
 gcc/testsuite/gcc.target/i386/pr66746.c | 10 ++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr66746.c

diff --git a/gcc/config/i386/ia32intrin.h b/gcc/config/i386/ia32intrin.h
index 1f728c8..b8d1c31 100644
--- a/gcc/config/i386/ia32intrin.h
+++ b/gcc/config/i386/ia32intrin.h
@@ -49,6 +49,8 @@ __bswapd (int __X)
   return __builtin_bswap32 (__X);
 }
 
+#ifndef __iamcu__
+
 #ifndef __SSE4_2__
 #pragma GCC push_options
 #pragma GCC target("sse4.2")
@@ -82,6 +84,8 @@ __crc32d (unsigned int __C, unsigned int __V)
 #pragma GCC pop_options
 #endif /* __DISABLE_SSE4_2__ */
 
+#endif /* __iamcu__ */
+
 /* 32bit popcnt */
 extern __inline int
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
@@ -90,6 +94,8 @@ __popcntd (unsigned int __X)
   return __builtin_popcount (__X);
 }
 
+#ifndef __iamcu__
+
 /* rdpmc */
 extern __inline unsigned long long
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
@@ -98,6 +104,8 @@ __rdpmc (int __S)
   return __builtin_ia32_rdpmc (__S);
 }
 
+#endif /* __iamcu__ */
+
 /* rdtsc */
 extern __inline unsigned long long
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
@@ -106,6 +114,8 @@ __rdtsc (void)
   return __builtin_ia32_rdtsc ();
 }
 
+#ifndef __iamcu__
+
 /* rdtscp */
 extern __inline unsigned long long
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
@@ -114,6 +124,8 @@ __rdtscp (unsigned int *__A)
   return __builtin_ia32_rdtscp (__A);
 }
 
+#endif /* __iamcu__ */
+
 /* 8bit rol */
 extern __inline unsigned char
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
@@ -290,9 +302,11 @@ __writeeflags (unsigned int X)
 #define _bit_scan_reverse(a)	__bsrd(a)
 #define _bswap(a)		__bswapd(a)
 #define _popcnt32(a)		__popcntd(a)
+#ifndef __iamcu__
 #define _rdpmc(a)		__rdpmc(a)
-#define _rdtsc()		__rdtsc()
 #define _rdtscp(a)		__rdtscp(a)
+#endif /* __iamcu__ */
+#define _rdtsc()		__rdtsc()
 #define _rotwl(a,b)		__rolw((a), (b))
 #define _rotwr(a,b)		__rorw((a), (b))
 #define _rotl(a,b)		__rold((a), (b))
diff --git a/gcc/config/i386/x86intrin.h b/gcc/config/i386/x86intrin.h
index 6f7b1f6..be0a1a1 100644
--- a/gcc/config/i386/x86intrin.h
+++ b/gcc/config/i386/x86intrin.h
@@ -26,6 +26,8 @@
 
 #include <ia32intrin.h>
 
+#ifndef __iamcu__
+
 #include <mmintrin.h>
 
 #include <xmmintrin.h>
@@ -86,4 +88,7 @@
 #include <xsavecintrin.h>
 
 #include <mwaitxintrin.h>
+
+#endif /* __iamcu__ */
+
 #endif /* _X86INTRIN_H_INCLUDED */
diff --git a/gcc/testsuite/gcc.target/i386/pr66746.c b/gcc/testsuite/gcc.target/i386/pr66746.c
new file mode 100644
index 0000000..3ef77bf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr66746.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O2 -miamcu" } */
+
+/* Defining away "extern" and "__inline" results in all of them being
+   compiled as proper functions.  */
+
+#define extern
+#define __inline
+
+#include <x86intrin.h>
-- 
2.4.3

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

* Re: [PATCH] PR target/66746: Failure to compile #include <x86intrin.h> with -miamcu
  2015-07-03  3:53 [PATCH] PR target/66746: Failure to compile #include <x86intrin.h> with -miamcu H.J. Lu
@ 2015-07-03  6:16 ` Uros Bizjak
  2015-07-08 16:43   ` H.J. Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Uros Bizjak @ 2015-07-03  6:16 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches

On Fri, Jul 3, 2015 at 5:53 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> x86intrin.h has useful intrinsics for instructions for IA MCU.  This
> patch adds __iamcu__ check to x86intrin.h and ia32intrin.h.
>
> OK for trunk?
>
> H.J.
> ---
> gcc/
>
>         PR target/66746
>         * config/i386/ia32intrin.h (__crc32b): Don't define if __iamcu__
>         is defined.
>         (__crc32w): Likewise.
>         (__crc32d): Likewise.
>         (__rdpmc): Likewise.
>         (__rdtscp): Likewise.
>         (_rdpmc): Likewise.
>         (_rdtscp): Likewise.
>         * config/i386/x86intrin.h: Only include ia32intrin.h if __iamcu__
>         is defined.
>
> gcc/testsuite/
>
>         PR target/66746
>         * gcc.target/i386/pr66746.c: New file.

OK.

Thanks,
Uros.

>  gcc/config/i386/ia32intrin.h            | 16 +++++++++++++++-
>  gcc/config/i386/x86intrin.h             |  5 +++++
>  gcc/testsuite/gcc.target/i386/pr66746.c | 10 ++++++++++
>  3 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr66746.c
>
> diff --git a/gcc/config/i386/ia32intrin.h b/gcc/config/i386/ia32intrin.h
> index 1f728c8..b8d1c31 100644
> --- a/gcc/config/i386/ia32intrin.h
> +++ b/gcc/config/i386/ia32intrin.h
> @@ -49,6 +49,8 @@ __bswapd (int __X)
>    return __builtin_bswap32 (__X);
>  }
>
> +#ifndef __iamcu__
> +
>  #ifndef __SSE4_2__
>  #pragma GCC push_options
>  #pragma GCC target("sse4.2")
> @@ -82,6 +84,8 @@ __crc32d (unsigned int __C, unsigned int __V)
>  #pragma GCC pop_options
>  #endif /* __DISABLE_SSE4_2__ */
>
> +#endif /* __iamcu__ */
> +
>  /* 32bit popcnt */
>  extern __inline int
>  __attribute__((__gnu_inline__, __always_inline__, __artificial__))
> @@ -90,6 +94,8 @@ __popcntd (unsigned int __X)
>    return __builtin_popcount (__X);
>  }
>
> +#ifndef __iamcu__
> +
>  /* rdpmc */
>  extern __inline unsigned long long
>  __attribute__((__gnu_inline__, __always_inline__, __artificial__))
> @@ -98,6 +104,8 @@ __rdpmc (int __S)
>    return __builtin_ia32_rdpmc (__S);
>  }
>
> +#endif /* __iamcu__ */
> +
>  /* rdtsc */
>  extern __inline unsigned long long
>  __attribute__((__gnu_inline__, __always_inline__, __artificial__))
> @@ -106,6 +114,8 @@ __rdtsc (void)
>    return __builtin_ia32_rdtsc ();
>  }
>
> +#ifndef __iamcu__
> +
>  /* rdtscp */
>  extern __inline unsigned long long
>  __attribute__((__gnu_inline__, __always_inline__, __artificial__))
> @@ -114,6 +124,8 @@ __rdtscp (unsigned int *__A)
>    return __builtin_ia32_rdtscp (__A);
>  }
>
> +#endif /* __iamcu__ */
> +
>  /* 8bit rol */
>  extern __inline unsigned char
>  __attribute__((__gnu_inline__, __always_inline__, __artificial__))
> @@ -290,9 +302,11 @@ __writeeflags (unsigned int X)
>  #define _bit_scan_reverse(a)   __bsrd(a)
>  #define _bswap(a)              __bswapd(a)
>  #define _popcnt32(a)           __popcntd(a)
> +#ifndef __iamcu__
>  #define _rdpmc(a)              __rdpmc(a)
> -#define _rdtsc()               __rdtsc()
>  #define _rdtscp(a)             __rdtscp(a)
> +#endif /* __iamcu__ */
> +#define _rdtsc()               __rdtsc()
>  #define _rotwl(a,b)            __rolw((a), (b))
>  #define _rotwr(a,b)            __rorw((a), (b))
>  #define _rotl(a,b)             __rold((a), (b))
> diff --git a/gcc/config/i386/x86intrin.h b/gcc/config/i386/x86intrin.h
> index 6f7b1f6..be0a1a1 100644
> --- a/gcc/config/i386/x86intrin.h
> +++ b/gcc/config/i386/x86intrin.h
> @@ -26,6 +26,8 @@
>
>  #include <ia32intrin.h>
>
> +#ifndef __iamcu__
> +
>  #include <mmintrin.h>
>
>  #include <xmmintrin.h>
> @@ -86,4 +88,7 @@
>  #include <xsavecintrin.h>
>
>  #include <mwaitxintrin.h>
> +
> +#endif /* __iamcu__ */
> +
>  #endif /* _X86INTRIN_H_INCLUDED */
> diff --git a/gcc/testsuite/gcc.target/i386/pr66746.c b/gcc/testsuite/gcc.target/i386/pr66746.c
> new file mode 100644
> index 0000000..3ef77bf
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr66746.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile { target ia32 } } */
> +/* { dg-options "-O2 -miamcu" } */
> +
> +/* Defining away "extern" and "__inline" results in all of them being
> +   compiled as proper functions.  */
> +
> +#define extern
> +#define __inline
> +
> +#include <x86intrin.h>
> --
> 2.4.3
>

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

* Re: [PATCH] PR target/66746: Failure to compile #include <x86intrin.h> with -miamcu
  2015-07-03  6:16 ` Uros Bizjak
@ 2015-07-08 16:43   ` H.J. Lu
  2015-07-08 17:56     ` Uros Bizjak
  0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2015-07-08 16:43 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

On Thu, Jul 2, 2015 at 11:16 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Fri, Jul 3, 2015 at 5:53 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> x86intrin.h has useful intrinsics for instructions for IA MCU.  This
>> patch adds __iamcu__ check to x86intrin.h and ia32intrin.h.
>>
>> OK for trunk?
>>
>> H.J.
>> ---
>> gcc/
>>
>>         PR target/66746
>>         * config/i386/ia32intrin.h (__crc32b): Don't define if __iamcu__
>>         is defined.
>>         (__crc32w): Likewise.
>>         (__crc32d): Likewise.
>>         (__rdpmc): Likewise.
>>         (__rdtscp): Likewise.
>>         (_rdpmc): Likewise.
>>         (_rdtscp): Likewise.
>>         * config/i386/x86intrin.h: Only include ia32intrin.h if __iamcu__
>>         is defined.
>>
>> gcc/testsuite/
>>
>>         PR target/66746
>>         * gcc.target/i386/pr66746.c: New file.
>
> OK.
>

It is OK to include <adxintrin.h> for IA MCU since GCC can generate ADX
intrinsics with alternative instuctions if ADX isn't enabled.

OK for trunk?

H.J.
---
PR target/66746
* config/i386/x86intrin.h: Include <adxintrin.h> if
__iamcu__ is defined.

[-- Attachment #2: 0001-Allow-adxintrin.h-for-IA-MCU.patch --]
[-- Type: text/x-patch, Size: 859 bytes --]

From b1c38ef504f92ce6b085a1faace7d85566335654 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 8 Jul 2015 09:36:27 -0700
Subject: [PATCH] Allow <adxintrin.h> for IA MCU

It is OK to include <adxintrin.h> for IA MCU since GCC can generate ADX
intrinsics with alternative instuctions if ADX isn't enabled.

	PR target/66746
	* config/i386/x86intrin.h: Include <adxintrin.h> if
	__iamcu__ is defined.
---
 gcc/config/i386/x86intrin.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/config/i386/x86intrin.h b/gcc/config/i386/x86intrin.h
index be0a1a1..3ff571d 100644
--- a/gcc/config/i386/x86intrin.h
+++ b/gcc/config/i386/x86intrin.h
@@ -75,8 +75,12 @@
 
 #include <xsaveoptintrin.h>
 
+#endif /* __iamcu__ */
+
 #include <adxintrin.h>
 
+#ifndef __iamcu__
+
 #include <clwbintrin.h>
 
 #include <pcommitintrin.h>
-- 
2.4.3


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

* Re: [PATCH] PR target/66746: Failure to compile #include <x86intrin.h> with -miamcu
  2015-07-08 16:43   ` H.J. Lu
@ 2015-07-08 17:56     ` Uros Bizjak
  0 siblings, 0 replies; 4+ messages in thread
From: Uros Bizjak @ 2015-07-08 17:56 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches

On Wed, Jul 8, 2015 at 6:43 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>> x86intrin.h has useful intrinsics for instructions for IA MCU.  This
>>> patch adds __iamcu__ check to x86intrin.h and ia32intrin.h.
>>>
>>> OK for trunk?
>>>
>>> H.J.
>>> ---
>>> gcc/
>>>
>>>         PR target/66746
>>>         * config/i386/ia32intrin.h (__crc32b): Don't define if __iamcu__
>>>         is defined.
>>>         (__crc32w): Likewise.
>>>         (__crc32d): Likewise.
>>>         (__rdpmc): Likewise.
>>>         (__rdtscp): Likewise.
>>>         (_rdpmc): Likewise.
>>>         (_rdtscp): Likewise.
>>>         * config/i386/x86intrin.h: Only include ia32intrin.h if __iamcu__
>>>         is defined.
>>>
>>> gcc/testsuite/
>>>
>>>         PR target/66746
>>>         * gcc.target/i386/pr66746.c: New file.
>>
>> OK.
>>
>
> It is OK to include <adxintrin.h> for IA MCU since GCC can generate ADX
> intrinsics with alternative instuctions if ADX isn't enabled.
>
> OK for trunk?
>
> H.J.
> ---
> PR target/66746
> * config/i386/x86intrin.h: Include <adxintrin.h> if
> __iamcu__ is defined.

Ok if tested properly.

Thanks,
Uros.

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

end of thread, other threads:[~2015-07-08 17:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-03  3:53 [PATCH] PR target/66746: Failure to compile #include <x86intrin.h> with -miamcu H.J. Lu
2015-07-03  6:16 ` Uros Bizjak
2015-07-08 16:43   ` H.J. Lu
2015-07-08 17:56     ` Uros Bizjak

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