acinclude.m4 17 KB

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