[PATCH] Make [ex]mmintrin.h usable with -std=c89 -pedantic-errors

Jakub Jelinek jakub@redhat.com
Tue May 31 09:34:00 GMT 2005


On Tue, May 31, 2005 at 04:08:55AM -0400, Jakub Jelinek wrote:
> > Hum, for Altivec, we found we like always inline...  Any reason to not 
> > do that here as well?
> 
> inline doesn't work with -std=c89 -pedantic-errors, __inline or __inline__
> works.
> 
> It is true that <emmintrin.h> is not usable with those switches due to
> other problems (only the last 6 errors fixed by the patch I posted).

The following patch on top of the previous one (inline -> __inline)
makes {,x,e,p}mmintrin.h usable with -std=c89 -pedantic-errors.

Ok for HEAD/4.0?

2005-05-31  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/xmmintrin.h (_mm_setzero_ps, _mm_set_ss, _mm_set1_ps,
	_mm_set_ps, _mm_setr_ps): Add __extension__.
	* config/i386/emmintrin.h (_mm_set_sd, _mm_set1_pd, _mm_set_pd,
	_mm_setr_pd, _mm_setzero_pd, _mm_set_epi64x, _mm_set_epi64x,
	_mm_set_epi32, _mm_set_epi16, _mm_set_epi8, _mm_setzero_si128):
	Likewise.
	(_mm_clflush): Don't use return in void function.

	* gcc.dg/i386-sse-12.c: New test.

--- gcc/config/i386/xmmintrin.h.jj	2005-01-18 13:01:28.000000000 +0100
+++ gcc/config/i386/xmmintrin.h	2005-05-31 10:55:37.000000000 +0200
@@ -90,7 +90,7 @@ enum _mm_hint
 static __inline __m128
 _mm_setzero_ps (void)
 {
-  return (__m128){ 0.0f, 0.0f, 0.0f, 0.0f };
+  return __extension__ (__m128){ 0.0f, 0.0f, 0.0f, 0.0f };
 }
 
 /* Perform the respective operation on the lower SPFP (single-precision
@@ -832,14 +832,14 @@ _MM_SET_FLUSH_ZERO_MODE (unsigned int __
 static __inline __m128
 _mm_set_ss (float __F)
 {
-  return (__m128)(__v4sf){ __F, 0, 0, 0 };
+  return __extension__ (__m128)(__v4sf){ __F, 0, 0, 0 };
 }
 
 /* Create a vector with all four elements equal to F.  */
 static __inline __m128
 _mm_set1_ps (float __F)
 {
-  return (__m128)(__v4sf){ __F, __F, __F, __F };
+  return __extension__ (__m128)(__v4sf){ __F, __F, __F, __F };
 }
 
 static __inline __m128
@@ -894,14 +894,14 @@ _mm_loadr_ps (float const *__P)
 static __inline __m128
 _mm_set_ps (const float __Z, const float __Y, const float __X, const float __W)
 {
-  return (__m128)(__v4sf){ __W, __X, __Y, __Z };
+  return __extension__ (__m128)(__v4sf){ __W, __X, __Y, __Z };
 }
 
 /* Create the vector [W X Y Z].  */
 static __inline __m128
 _mm_setr_ps (float __Z, float __Y, float __X, float __W)
 {
-  return (__m128)(__v4sf){ __Z, __Y, __X, __W };
+  return __extension__ (__m128)(__v4sf){ __Z, __Y, __X, __W };
 }
 
 /* Stores the lower SPFP value.  */
--- gcc/config/i386/emmintrin.h.jj	2005-05-30 17:41:12.000000000 +0200
+++ gcc/config/i386/emmintrin.h	2005-05-31 10:58:07.000000000 +0200
@@ -51,14 +51,14 @@ typedef __v2df __m128d;
 static __inline __m128d
 _mm_set_sd (double __F)
 {
-  return (__m128d){ __F, 0 };
+  return __extension__ (__m128d){ __F, 0 };
 }
 
 /* Create a vector with both elements equal to F.  */
 static __inline __m128d
 _mm_set1_pd (double __F)
 {
-  return (__m128d){ __F, __F };
+  return __extension__ (__m128d){ __F, __F };
 }
 
 static __inline __m128d
@@ -71,21 +71,21 @@ _mm_set_pd1 (double __F)
 static __inline __m128d
 _mm_set_pd (double __W, double __X)
 {
-  return (__m128d){ __X, __W };
+  return __extension__ (__m128d){ __X, __W };
 }
 
 /* Create a vector with the lower value W and upper value X.  */
 static __inline __m128d
 _mm_setr_pd (double __W, double __X)
 {
-  return (__m128d){ __W, __X };
+  return __extension__ (__m128d){ __W, __X };
 }
 
 /* Create a vector of zeros.  */
 static __inline __m128d
 _mm_setzero_pd (void)
 {
-  return (__m128d){ 0.0, 0.0 };
+  return __extension__ (__m128d){ 0.0, 0.0 };
 }
 
 /* Sets the low DPFP value of A from the low value of B.  */
@@ -553,7 +553,7 @@ _mm_ucomineq_sd (__m128d __A, __m128d __
 static __inline __m128i
 _mm_set_epi64x (long long __q1, long long __q0)
 {
-  return (__m128i)(__v2di){ __q0, __q1 };
+  return __extension__ (__m128i)(__v2di){ __q0, __q1 };
 }
 
 static __inline __m128i
@@ -565,14 +565,15 @@ _mm_set_epi64 (__m64 __q1,  __m64 __q0)
 static __inline __m128i
 _mm_set_epi32 (int __q3, int __q2, int __q1, int __q0)
 {
-  return (__m128i)(__v4si){ __q0, __q1, __q2, __q3 };
+  return __extension__ (__m128i)(__v4si){ __q0, __q1, __q2, __q3 };
 }
 
 static __inline __m128i
 _mm_set_epi16 (short __q7, short __q6, short __q5, short __q4,
 	       short __q3, short __q2, short __q1, short __q0)
 {
-  return (__m128i)(__v8hi){ __q0, __q1, __q2, __q3, __q4, __q5, __q6, __q7 };
+  return __extension__ (__m128i)(__v8hi){
+    __q0, __q1, __q2, __q3, __q4, __q5, __q6, __q7 };
 }
 
 static __inline __m128i
@@ -581,7 +582,7 @@ _mm_set_epi8 (char __q15, char __q14, ch
 	      char __q07, char __q06, char __q05, char __q04,
 	      char __q03, char __q02, char __q01, char __q00)
 {
-  return (__m128i)(__v16qi){
+  return __extension__ (__m128i)(__v16qi){
     __q00, __q01, __q02, __q03, __q04, __q05, __q06, __q07,
     __q08, __q09, __q10, __q11, __q12, __q13, __q14, __q15
   };
@@ -712,7 +713,7 @@ _mm_move_epi64 (__m128i __A)
 static __inline __m128i
 _mm_setzero_si128 (void)
 {
-  return (__m128i)(__v4si){ 0, 0, 0, 0 };
+  return __extension__ (__m128i)(__v4si){ 0, 0, 0, 0 };
 }
 
 static __inline __m128d
@@ -1356,7 +1357,7 @@ _mm_stream_pd (double *__A, __m128d __B)
 static __inline void
 _mm_clflush (void const *__A)
 {
-  return __builtin_ia32_clflush (__A);
+  __builtin_ia32_clflush (__A);
 }
 
 static __inline void
--- gcc/testsuite/gcc.dg/i386-sse-12.c.jj	2005-05-31 11:22:27.000000000 +0200
+++ gcc/testsuite/gcc.dg/i386-sse-12.c	2005-05-31 11:23:57.000000000 +0200
@@ -0,0 +1,12 @@
+/* Test that {,x,e,p}mmintrin.h and mm_malloc.h are
+   usable with -std=c89 -pedantic-errors.  */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-std=c89 -pedantic-errors -msse3" } */
+
+#include <mmintrin.h>
+#include <xmmintrin.h>
+#include <emmintrin.h>
+#include <pmmintrin.h>
+#include <mm_malloc.h>
+
+int dummy;

	Jakub



More information about the Gcc-patches mailing list