]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/acinclude.m4
* config/microblaze/microblaze.c (microblaze_expand_block_move): Treat
[thirdparty/gcc.git] / libgfortran / acinclude.m4
index 34e14071aebd996d07dc248ac2a0eb2ebe5a8254..5b0c094e71697e73a3845cf1f22fae326dc90c30 100644 (file)
@@ -1,6 +1,9 @@
 m4_include(../config/acx.m4)
 m4_include(../config/no-executables.m4)
 m4_include(../config/math.m4)
+m4_include(../config/ax_check_define.m4)
+m4_include(../config/enable.m4)
+m4_include(../config/cet.m4)
 
 dnl Check that we have a working GNU Fortran compiler
 AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [
@@ -56,17 +59,17 @@ extern void bar(void) __attribute__((alias("foo")));]],
       [Define to 1 if the target supports __attribute__((alias(...))).])
   fi])
 
-dnl Check whether the target supports __sync_fetch_and_add.
-AC_DEFUN([LIBGFOR_CHECK_SYNC_FETCH_AND_ADD], [
-  AC_CACHE_CHECK([whether the target supports __sync_fetch_and_add],
-                libgfor_cv_have_sync_fetch_and_add, [
+dnl Check whether the target supports __atomic_fetch_add.
+AC_DEFUN([LIBGFOR_CHECK_ATOMIC_FETCH_ADD], [
+  AC_CACHE_CHECK([whether the target supports __atomic_fetch_add],
+                libgfor_cv_have_atomic_fetch_add, [
   AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foovar = 0;]], [[
-if (foovar <= 0) return __sync_fetch_and_add (&foovar, 1);
-if (foovar > 10) return __sync_add_and_fetch (&foovar, -1);]])],
-             libgfor_cv_have_sync_fetch_and_add=yes, libgfor_cv_have_sync_fetch_and_add=no)])
-  if test $libgfor_cv_have_sync_fetch_and_add = yes; then
-    AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD, 1,
-             [Define to 1 if the target supports __sync_fetch_and_add])
+if (foovar <= 0) return __atomic_fetch_add (&foovar, 1, __ATOMIC_ACQ_REL);
+if (foovar > 10) return __atomic_add_fetch (&foovar, -1, __ATOMIC_ACQ_REL);]])],
+             libgfor_cv_have_atomic_fetch_add=yes, libgfor_cv_have_atomic_fetch_add=no)])
+  if test $libgfor_cv_have_atomic_fetch_add = yes; then
+    AC_DEFINE(HAVE_ATOMIC_FETCH_ADD, 1,
+             [Define to 1 if the target supports __atomic_fetch_add])
   fi])
 
 dnl Check for pragma weak.
@@ -451,3 +454,59 @@ AC_DEFUN([LIBGFOR_CHECK_AVX512F], [
        [])
   CFLAGS="$ac_save_CFLAGS"
 ])
+
+dnl Check for FMA3
+dnl
+AC_DEFUN([LIBGFOR_CHECK_FMA3], [
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS="-O2 -mfma -mno-fma4"
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        typedef float __m128 __attribute__ ((__vector_size__ (16)));
+       typedef float __v4sf __attribute__ ((__vector_size__ (16)));
+       __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
+       {
+           return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
+                                                    (__v4sf)__B,
+                                                    (__v4sf)__C);
+        }]], [[]])],
+       AC_DEFINE(HAVE_FMA3, 1,
+       [Define if FMA3 instructions can be compiled.]),
+       [])
+  CFLAGS="$ac_save_CFLAGS"
+])
+
+dnl Check for FMA4
+dnl
+AC_DEFUN([LIBGFOR_CHECK_FMA4], [
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS="-O2 -mfma4 -mno-fma"
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        typedef float __m128 __attribute__ ((__vector_size__ (16)));
+       typedef float __v4sf __attribute__ ((__vector_size__ (16)));
+       __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
+       {
+           return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
+                                                    (__v4sf)__B,
+                                                    (__v4sf)__C);
+        }]], [[]])],
+       AC_DEFINE(HAVE_FMA4, 1,
+       [Define if FMA4 instructions can be compiled.]),
+       [])
+  CFLAGS="$ac_save_CFLAGS"
+])
+
+dnl Check for -mprefer-avx128
+dnl This also defines an automake conditional.
+AC_DEFUN([LIBGFOR_CHECK_AVX128], [
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS="-O2 -mavx -mprefer-avx128"
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        void foo()
+       {
+        }]], [[]])],
+       AC_DEFINE(HAVE_AVX128, 1,
+       [Define if -mprefer-avx128 is supported.])
+       AM_CONDITIONAL([HAVE_AVX128],true),
+       [AM_CONDITIONAL([HAVE_AVX128],false)])
+  CFLAGS="$ac_save_CFLAGS"
+])