Debian Codegraph @

libgfortran/acinclude.m4

raw
1 m4_include(../config/acx.m4)
2 m4_include(../config/no-executables.m4)
3 m4_include(../config/math.m4)
4 m4_include(../config/ax_check_define.m4)
5 m4_include(../config/enable.m4)
6 m4_include(../config/cet.m4)
7
8 dnl Check that we have a working GNU Fortran compiler
9 AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [
10 AC_MSG_CHECKING([whether the GNU Fortran compiler is working])
11 AC_LANG_PUSH([Fortran])
12 AC_COMPILE_IFELSE([[
13 program foo
14 real, parameter :: bar = sin (12.34 / 2.5)
15 end program foo]],
16 [AC_MSG_RESULT([yes])],
17 [AC_MSG_RESULT([no])
18 AC_MSG_ERROR([GNU Fortran is not working; please report a bug in http://gcc.gnu.org/bugzilla, attaching $PWD/config.log])
19 ])
20 AC_LANG_POP([Fortran])
21 ])
22
23
24 sinclude(../libtool.m4)
25 dnl The lines below arrange for aclocal not to bring an installed
26 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
27 dnl add a definition of LIBTOOL to Makefile.in.
28 ifelse(,,,[AC_SUBST(LIBTOOL)
29 AC_DEFUN([AM_PROG_LIBTOOL])
30 AC_DEFUN([AC_LIBTOOL_DLOPEN])
31 AC_DEFUN([AC_PROG_LD])
32 ])
33
34 dnl Check whether the target supports hidden visibility.
35 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
36 AC_CACHE_CHECK([whether the target supports hidden visibility],
37 libgfor_cv_have_attribute_visibility, [
38 save_CFLAGS="$CFLAGS"
39 CFLAGS="$CFLAGS -Werror"
40 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void __attribute__((visibility("hidden"))) foo(void) { }]], [])],
41 libgfor_cv_have_attribute_visibility=yes,
42 libgfor_cv_have_attribute_visibility=no)
43 CFLAGS="$save_CFLAGS"])
44 if test $libgfor_cv_have_attribute_visibility = yes; then
45 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
46 [Define to 1 if the target supports __attribute__((visibility(...))).])
47 fi])
48
49 dnl Check whether the target supports symbol aliases.
50 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [
51 AC_CACHE_CHECK([whether the target supports symbol aliases],
52 libgfor_cv_have_attribute_alias, [
53 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
54 void foo(void) { }
55 extern void bar(void) __attribute__((alias("foo")));]],
56 [[bar();]])], libgfor_cv_have_attribute_alias=yes, libgfor_cv_have_attribute_alias=no)])
57 if test $libgfor_cv_have_attribute_alias = yes; then
58 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
59 [Define to 1 if the target supports __attribute__((alias(...))).])
60 fi])
61
62 dnl Check whether the target supports __atomic_fetch_add.
63 AC_DEFUN([LIBGFOR_CHECK_ATOMIC_FETCH_ADD], [
64 AC_CACHE_CHECK([whether the target supports __atomic_fetch_add],
65 libgfor_cv_have_atomic_fetch_add, [
66 AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foovar = 0;]], [[
67 if (foovar <= 0) return __atomic_fetch_add (&foovar, 1, __ATOMIC_ACQ_REL);
68 if (foovar > 10) return __atomic_add_fetch (&foovar, -1, __ATOMIC_ACQ_REL);]])],
69 libgfor_cv_have_atomic_fetch_add=yes, libgfor_cv_have_atomic_fetch_add=no)])
70 if test $libgfor_cv_have_atomic_fetch_add = yes; then
71 AC_DEFINE(HAVE_ATOMIC_FETCH_ADD, 1,
72 [Define to 1 if the target supports __atomic_fetch_add])
73 fi])
74
75 dnl Check for pragma weak.
76 AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [
77 AC_CACHE_CHECK([whether pragma weak works],
78 libgfor_cv_have_pragma_weak, [
79 gfor_save_CFLAGS="$CFLAGS"
80 CFLAGS="$CFLAGS -Wunknown-pragmas"
81 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
82 void foo (void);
83 #pragma weak foo
84 ]], [[if (foo) foo ();]])],
85 libgfor_cv_have_pragma_weak=yes, libgfor_cv_have_pragma_weak=no)])
86 if test $libgfor_cv_have_pragma_weak = yes; then
87 AC_DEFINE(SUPPORTS_WEAK, 1,
88 [Define to 1 if the target supports #pragma weak])
89 fi
90 case "$host" in
91 *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
92 AC_DEFINE(GTHREAD_USE_WEAK, 0,
93 [Define to 0 if the target shouldn't use #pragma weak])
94 ;;
95 esac])
96
97 dnl Check whether target effectively supports weakref
98 AC_DEFUN([LIBGFOR_CHECK_WEAKREF], [
99 AC_CACHE_CHECK([whether the target supports weakref],
100 libgfor_cv_have_weakref, [
101 save_CFLAGS="$CFLAGS"
102 CFLAGS="$CFLAGS -Wunknown-pragmas -Werror"
103 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
104 static int mytoto (int) __attribute__((__weakref__("toto")));
105 ]], [[return (mytoto != 0);]])],
106 libgfor_cv_have_weakref=yes, libgfor_cv_have_weakref=no)
107 CFLAGS="$save_CFLAGS"])
108 if test $libgfor_cv_have_weakref = yes; then
109 AC_DEFINE(SUPPORTS_WEAKREF, 1,
110 [Define to 1 if the target supports weakref])
111 fi])
112
113 dnl Check whether target can unlink a file still open.
114 AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
115 AC_CACHE_CHECK([whether the target can unlink an open file],
116 libgfor_cv_have_unlink_open_file, [
117 AC_RUN_IFELSE([AC_LANG_SOURCE([[
118 #include <errno.h>
119 #include <fcntl.h>
120 #include <unistd.h>
121 #include <sys/stat.h>
122
123 int main ()
124 {
125 int fd;
126
127 fd = open ("testfile", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR);
128 if (fd <= 0)
129 return 0;
130 if (unlink ("testfile") == -1)
131 return 1;
132 write (fd, "This is a test\n", 15);
133 close (fd);
134
135 if (open ("testfile", O_RDONLY) == -1 && errno == ENOENT)
136 return 0;
137 else
138 return 1;
139 }]])], libgfor_cv_have_unlink_open_file=yes, libgfor_cv_have_unlink_open_file=no, [
140 case "${target}" in
141 *mingw*) libgfor_cv_have_unlink_open_file=no ;;
142 *) libgfor_cv_have_unlink_open_file=yes;;
143 esac])])
144 if test x"$libgfor_cv_have_unlink_open_file" = xyes; then
145 AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.])
146 fi])
147
148 dnl Check whether CRLF is the line terminator
149 AC_DEFUN([LIBGFOR_CHECK_CRLF], [
150 AC_CACHE_CHECK([whether the target has CRLF as line terminator],
151 libgfor_cv_have_crlf, [
152 AC_RUN_IFELSE([AC_LANG_SOURCE([[
153 /* This test program should exit with status 0 if system uses a CRLF as
154 line terminator, and status 1 otherwise.
155 Since it is used to check for mingw systems, and should return 0 in any
156 other case, in case of a failure we will not use CRLF. */
157 #include <sys/stat.h>
158 #include <stdlib.h>
159 #include <fcntl.h>
160 #include <stdio.h>
161
162 int main ()
163 {
164 #ifndef O_BINARY
165 exit(1);
166 #else
167 int fd, bytes;
168 char buff[5];
169
170 fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
171 if (fd < 0)
172 exit(1);
173 if (write (fd, "\n", 1) < 0)
174 perror ("write");
175
176 close (fd);
177
178 if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0)
179 exit(1);
180 bytes = read (fd, buff, 5);
181 if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n')
182 exit(0);
183 else
184 exit(1);
185 #endif
186 }]])], libgfor_cv_have_crlf=yes, libgfor_cv_have_crlf=no, [
187 case "${target}" in
188 *mingw*) libgfor_cv_have_crlf=yes ;;
189 *) libgfor_cv_have_crlf=no;;
190 esac])])
191 if test x"$libgfor_cv_have_crlf" = xyes; then
192 AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.])
193 fi])
194
195 dnl Check whether the st_ino and st_dev stat fields taken together uniquely
196 dnl identify the file within the system. This is should be true for POSIX
197 dnl systems; it is known to be false on mingw32.
198 AC_DEFUN([LIBGFOR_CHECK_WORKING_STAT], [
199 AC_CACHE_CHECK([whether the target stat is reliable],
200 libgfor_cv_have_working_stat, [
201 AC_RUN_IFELSE([AC_LANG_SOURCE([[
202 #include <stdio.h>
203 #include <sys/types.h>
204 #include <sys/stat.h>
205 #include <unistd.h>
206
207 int main ()
208 {
209 FILE *f, *g;
210 struct stat st1, st2;
211
212 f = fopen ("foo", "w");
213 g = fopen ("bar", "w");
214 if (stat ("foo", &st1) != 0 || stat ("bar", &st2))
215 return 1;
216 if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
217 return 1;
218 fclose(f);
219 fclose(g);
220 return 0;
221 }]])], libgfor_cv_have_working_stat=yes, libgfor_cv_have_working_stat=no, [
222 case "${target}" in
223 *mingw*) libgfor_cv_have_working_stat=no ;;
224 *) libgfor_cv_have_working_stat=yes;;
225 esac])])
226 if test x"$libgfor_cv_have_working_stat" = xyes; then
227 AC_DEFINE(HAVE_WORKING_STAT, 1, [Define if target has a reliable stat.])
228 fi])
229
230 dnl Checks for fpsetmask function.
231 AC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [
232 AC_CACHE_CHECK([whether fpsetmask is present], libgfor_cv_have_fpsetmask, [
233 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
234 #if HAVE_FLOATINGPOINT_H
235 # include <floatingpoint.h>
236 #endif /* HAVE_FLOATINGPOINT_H */
237 #if HAVE_IEEEFP_H
238 # include <ieeefp.h>
239 #endif /* HAVE_IEEEFP_H */]],[[fpsetmask(0);]])],
240 eval "libgfor_cv_have_fpsetmask=yes", eval "libgfor_cv_have_fpsetmask=no")
241 ])
242 if test x"$libgfor_cv_have_fpsetmask" = xyes; then
243 have_fpsetmask=yes
244 AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.])
245 fi
246 ])
247
248 dnl Check whether we have a mingw that provides a __mingw_snprintf function
249 AC_DEFUN([LIBGFOR_CHECK_MINGW_SNPRINTF], [
250 AC_CACHE_CHECK([whether __mingw_snprintf is present], libgfor_cv_have_mingw_snprintf, [
251 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
252 #include <stdio.h>
253 extern int __mingw_snprintf (char *, size_t, const char *, ...);
254 ]],[[
255 __mingw_snprintf (NULL, 0, "%d\n", 1);
256 ]])],
257 eval "libgfor_cv_have_mingw_snprintf=yes", eval "libgfor_cv_have_mingw_snprintf=no")
258 ])
259 if test x"$libgfor_cv_have_mingw_snprintf" = xyes; then
260 AC_DEFINE(HAVE_MINGW_SNPRINTF, 1, [Define if you have __mingw_snprintf.])
261 fi
262 ])
263
264 dnl Check whether we have a __float128 and _Float128 type
265 AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
266 LIBQUADSPEC=
267 LIBQUADLIB=
268 LIBQUADLIB_DEP=
269 LIBQUADINCLUDE=
270 USE_IEC_60559=no
271
272 if test "x$enable_libquadmath_support" != xno; then
273
274 AC_CACHE_CHECK([whether we have a usable _Float128 type],
275 libgfor_cv_have_float128, [
276 GCC_TRY_COMPILE_OR_LINK([
277 #ifdef __loongarch__
278 #error On LoongArch we should use long double instead; __float128 is only for porting existing code easier.
279 #endif
280
281 _Float128 foo (_Float128 x)
282 {
283 _Complex _Float128 z1, z2;
284
285 z1 = x;
286 z2 = x / 7.F128;
287 z2 /= z1;
288
289 return (_Float128) z2;
290 }
291
292 _Float128 bar (_Float128 x)
293 {
294 return x * __builtin_huge_valf128 ();
295 }
296
297 __float128 baz (__float128 x)
298 {
299 return x * __builtin_huge_valf128 ();
300 }
301 ],[
302 foo (1.2F128);
303 bar (1.2F128);
304 baz (1.2F128);
305 foo (1.2Q);
306 bar (1.2Q);
307 baz (1.2Q);
308 ],[
309 libgfor_cv_have_float128=yes
310 ],[
311 libgfor_cv_have_float128=no
312 ])])
313
314 if test "x$have_iec_60559_libc_support$enable_libquadmath_support$libgfor_cv_have_float128" = xyesdefaultyes; then
315 USE_IEC_60559=yes
316 fi
317
318
319 if test "x$libgfor_cv_have_float128" = xyes; then
320 if test "x$USE_IEC_60559" = xyes; then
321 AC_DEFINE(USE_IEC_60559, 1, [Define if IEC 60559 *f128 APIs should be used for _Float128.])
322 fi
323 AC_DEFINE(HAVE_FLOAT128, 1, [Define if target has usable _Float128 and __float128 types.])
324
325 dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported
326 dnl
327 dnl Turn warnings into error to avoid testsuite breakage. So enable
328 dnl AC_LANG_WERROR, but there's currently (autoconf 2.64) no way to turn
329 dnl it off again. As a workaround, save and restore werror flag like
330 dnl AC_PATH_XTRA.
331 dnl Cf. http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01889.html
332 ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
333 AC_CACHE_CHECK([whether --as-needed/-z ignore works],
334 [libgfor_cv_have_as_needed],
335 [
336 # Test for native Solaris options first.
337 # No whitespace after -z to pass it through -Wl.
338 libgfor_cv_as_needed_option="-zignore"
339 libgfor_cv_no_as_needed_option="-zrecord"
340 save_LDFLAGS="$LDFLAGS"
341 LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option"
342 libgfor_cv_have_as_needed=no
343 AC_LANG_WERROR
344 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
345 [libgfor_cv_have_as_needed=yes],
346 [libgfor_cv_have_as_needed=no])
347 LDFLAGS="$save_LDFLAGS"
348 if test "x$libgfor_cv_have_as_needed" = xno; then
349 libgfor_cv_as_needed_option="--as-needed"
350 libgfor_cv_no_as_needed_option="--no-as-needed"
351 save_LDFLAGS="$LDFLAGS"
352 LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option"
353 libgfor_cv_have_as_needed=no
354 AC_LANG_WERROR
355 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
356 [libgfor_cv_have_as_needed=yes],
357 [libgfor_cv_have_as_needed=no])
358 LDFLAGS="$save_LDFLAGS"
359 fi
360 ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag
361 ])
362
363 dnl Determine -Bstatic ... -Bdynamic etc. support from gfortran -### stderr.
364 touch conftest1.$ac_objext conftest2.$ac_objext
365 LQUADMATH=-lquadmath
366 $FC -static-libgfortran -### -o conftest \
367 conftest1.$ac_objext -lgfortran conftest2.$ac_objext 2>&1 >/dev/null \
368 | grep "conftest1.$ac_objext.*conftest2.$ac_objext" > conftest.cmd
369 if grep "conftest1.$ac_objext.* -Bstatic -lgfortran -Bdynamic .*conftest2.$ac_objext" \
370 conftest.cmd >/dev/null 2>&1; then
371 LQUADMATH="%{static-libquadmath:-Bstatic} -lquadmath %{static-libquadmath:-Bdynamic}"
372 elif grep "conftest1.$ac_objext.* -bstatic -lgfortran -bdynamic .*conftest2.$ac_objext" \
373 conftest.cmd >/dev/null 2>&1; then
374 LQUADMATH="%{static-libquadmath:-bstatic} -lquadmath %{static-libquadmath:-bdynamic}"
375 elif grep "conftest1.$ac_objext.* -aarchive_shared -lgfortran -adefault .*conftest2.$ac_objext" \
376 conftest.cmd >/dev/null 2>&1; then
377 LQUADMATH="%{static-libquadmath:-aarchive_shared} -lquadmath %{static-libquadmath:-adefault}"
378 elif grep "conftest1.$ac_objext.*libgfortran.a .*conftest2.$ac_objext" \
379 conftest.cmd >/dev/null 2>&1; then
380 LQUADMATH="%{static-libquadmath:libquadmath.a%s;:-lquadmath}"
381 fi
382 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest conftest.cmd
383
384 dnl For static libgfortran linkage, depend on libquadmath only if needed.
385 dnl If using *f128 APIs from libc/libm, depend on libquadmath only if needed
386 dnl even for dynamic libgfortran linkage, and don't link libgfortran against
387 dnl -lquadmath.
388 if test "x$libgfor_cv_have_as_needed" = xyes; then
389 if test "x$USE_IEC_60559" = xyes; then
390 LIBQUADSPEC="$libgfor_cv_as_needed_option $LQUADMATH $libgfor_cv_no_as_needed_option"
391 else
392 LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} $LQUADMATH %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
393 fi
394 else
395 LIBQUADSPEC="$LQUADMATH"
396 fi
397 if test "x$USE_IEC_60559" != xyes; then
398 if test -f ../libquadmath/libquadmath.la; then
399 LIBQUADLIB=../libquadmath/libquadmath.la
400 LIBQUADLIB_DEP=../libquadmath/libquadmath.la
401 LIBQUADINCLUDE='-I$(srcdir)/../libquadmath'
402 else
403 LIBQUADLIB="-lquadmath"
404 fi
405 fi
406 else
407 USE_IEC_60559=no
408 fi
409 fi
410
411 dnl For the spec file
412 AC_SUBST(LIBQUADSPEC)
413 AC_SUBST(LIBQUADLIB)
414 AC_SUBST(LIBQUADLIB_DEP)
415 AC_SUBST(LIBQUADINCLUDE)
416 AC_SUBST(USE_IEC_60559)
417 ])
418
419
420 dnl Check whether we have strerror_r
421 AC_DEFUN([LIBGFOR_CHECK_STRERROR_R], [
422 dnl Check for three-argument POSIX version of strerror_r
423 ac_save_CFLAGS="$CFLAGS"
424 CFLAGS="-Wimplicit-function-declaration -Werror"
425 AC_TRY_COMPILE([#define _GNU_SOURCE 1
426 #include <string.h>
427 #include <locale.h>],
428 [char s[128]; strerror_r(5, s, 128);],
429 AC_DEFINE(HAVE_STRERROR_R, 1,
430 [Define if strerror_r is available in <string.h>.]),)
431 CFLAGS="$ac_save_CFLAGS"
432
433 dnl Check for two-argument version of strerror_r (e.g. for VxWorks)
434 ac_save_CFLAGS="$CFLAGS"
435 CFLAGS="-Wimplicit-function-declaration -Werror"
436 AC_TRY_COMPILE([#define _GNU_SOURCE 1
437 #include <string.h>
438 #include <locale.h>],
439 [char s[128]; strerror_r(5, s);],
440 AC_DEFINE(HAVE_STRERROR_R_2ARGS, 1,
441 [Define if strerror_r takes two arguments and is available in <string.h>.]),)
442 CFLAGS="$ac_save_CFLAGS"
443 ])
444
445 dnl Check for AVX
446
447 AC_DEFUN([LIBGFOR_CHECK_AVX], [
448 ac_save_CFLAGS="$CFLAGS"
449 CFLAGS="-O2 -mavx"
450 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
451 void _mm256_zeroall (void)
452 {
453 __builtin_ia32_vzeroall ();
454 }]], [[]])],
455 AC_DEFINE(HAVE_AVX, 1,
456 [Define if AVX instructions can be compiled.]),
457 [])
458 CFLAGS="$ac_save_CFLAGS"
459 ])
460
461 dnl Check for AVX2
462
463 AC_DEFUN([LIBGFOR_CHECK_AVX2], [
464 ac_save_CFLAGS="$CFLAGS"
465 CFLAGS="-O2 -mavx2"
466 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
467 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
468 __v4di
469 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
470 {
471 return __builtin_ia32_andnotsi256 (__X, __Y);
472 }]], [[]])],
473 AC_DEFINE(HAVE_AVX2, 1,
474 [Define if AVX2 instructions can be compiled.]),
475 [])
476 CFLAGS="$ac_save_CFLAGS"
477 ])
478
479 dnl Check for AVX512f
480
481 AC_DEFUN([LIBGFOR_CHECK_AVX512F], [
482 ac_save_CFLAGS="$CFLAGS"
483 CFLAGS="-O2 -mavx512f"
484 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
485 typedef double __m512d __attribute__ ((__vector_size__ (64)));
486 __m512d _mm512_add (__m512d a)
487 {
488 __m512d b = __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
489 /* For -m64/-mx32 also verify that code will work even if
490 the target uses call saved zmm16+ and needs to emit
491 unwind info for them (e.g. on mingw). See PR79127. */
492 #ifdef __x86_64__
493 asm volatile ("" : : : "zmm16", "zmm17", "zmm18", "zmm19");
494 #endif
495 return b;
496 }]], [[]])],
497 AC_DEFINE(HAVE_AVX512F, 1,
498 [Define if AVX512f instructions can be compiled.]),
499 [])
500 CFLAGS="$ac_save_CFLAGS"
501 ])
502
503 dnl Check for FMA3
504 dnl
505 AC_DEFUN([LIBGFOR_CHECK_FMA3], [
506 ac_save_CFLAGS="$CFLAGS"
507 CFLAGS="-O2 -mfma -mno-fma4"
508 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
509 typedef float __m128 __attribute__ ((__vector_size__ (16)));
510 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
511 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
512 {
513 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
514 (__v4sf)__B,
515 (__v4sf)__C);
516 }]], [[]])],
517 AC_DEFINE(HAVE_FMA3, 1,
518 [Define if FMA3 instructions can be compiled.]),
519 [])
520 CFLAGS="$ac_save_CFLAGS"
521 ])
522
523 dnl Check for FMA4
524 dnl
525 AC_DEFUN([LIBGFOR_CHECK_FMA4], [
526 ac_save_CFLAGS="$CFLAGS"
527 CFLAGS="-O2 -mfma4 -mno-fma"
528 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
529 typedef float __m128 __attribute__ ((__vector_size__ (16)));
530 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
531 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
532 {
533 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
534 (__v4sf)__B,
535 (__v4sf)__C);
536 }]], [[]])],
537 AC_DEFINE(HAVE_FMA4, 1,
538 [Define if FMA4 instructions can be compiled.]),
539 [])
540 CFLAGS="$ac_save_CFLAGS"
541 ])
542
543 dnl Check for -mprefer-avx128
544 dnl This also defines an automake conditional.
545 AC_DEFUN([LIBGFOR_CHECK_AVX128], [
546 ac_save_CFLAGS="$CFLAGS"
547 CFLAGS="-O2 -mavx -mprefer-avx128"
548 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
549 void foo()
550 {
551 }]], [[]])],
552 AC_DEFINE(HAVE_AVX128, 1,
553 [Define if -mprefer-avx128 is supported.])
554 AM_CONDITIONAL([HAVE_AVX128],true),
555 [AM_CONDITIONAL([HAVE_AVX128],false)])
556 CFLAGS="$ac_save_CFLAGS"
557 ])
558
559 AC_DEFUN([LIBGFOR_CHECK_MATH_IEEE128],
560 [
561 AC_REQUIRE([GCC_CHECK_LIBM])
562 AC_REQUIRE([GCC_CHECK_MATH_HEADERS])
563 AC_CACHE_CHECK([for $1], [gcc_cv_math_func_$1],
564 [AC_LINK_IFELSE([AC_LANG_SOURCE([
565 _Float128 $1 (_Float128);
566 _Float128 (*ptr)(_Float128) = $1;
567
568 int
569 main ()
570 {
571 return 0;
572 }
573 ])],
574 [gcc_cv_math_func_$1=yes],
575 [gcc_cv_math_func_$1=no])])
576 if test $gcc_cv_math_func_$1 = yes; then
577 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1),[1],
578 [Define to 1 if you have the `$1' function.])
579 fi
580 ])