blob: de9712412e51f3bd440a4e39ffb72b130d871765 [file] [log] [blame]
Thomas Tsou3eaae802013-08-20 19:31:14 -04001# ===========================================================================
2# http://www.gnu.org/software/autoconf-archive/ax_ext.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
Vadim Yanitskiy61fbf2e2017-05-20 01:08:55 +03007# AX_SSE
Thomas Tsou3eaae802013-08-20 19:31:14 -04008#
9# DESCRIPTION
10#
Vadim Yanitskiy61fbf2e2017-05-20 01:08:55 +030011# Find SIMD extensions supported by compiler. The -m"simdextensionname" is
12# added to SIMD_FLAGS if compiler supports it. For example, if "sse2" is
13# available, then "-msse2" is added to SIMD_FLAGS.
Thomas Tsou3eaae802013-08-20 19:31:14 -040014#
15# This macro calls:
16#
17# AC_SUBST(SIMD_FLAGS)
18#
19# And defines:
20#
Vadim Yanitskiy61fbf2e2017-05-20 01:08:55 +030021# HAVE_SSE3 / HAVE_SSE4.1
Thomas Tsou3eaae802013-08-20 19:31:14 -040022#
23# LICENSE
24#
25# Copyright (c) 2007 Christophe Tournayre <turn3r@users.sourceforge.net>
26# Copyright (c) 2013 Michael Petch <mpetch@capp-sysware.com>
27#
28# Copying and distribution of this file, with or without modification, are
29# permitted in any medium without royalty provided the copyright notice
30# and this notice are preserved. This file is offered as-is, without any
31# warranty.
Philipp Maierf5bf33b2017-03-16 13:12:07 +010032#
33# NOTE: The functionality that requests the cpuid has been stripped because
34# this project detects the CPU capabilities during runtime. However, we
35# still need to check if the compiler supports the requested SIMD flag
Thomas Tsou3eaae802013-08-20 19:31:14 -040036
37#serial 12
38
Philipp Maiere8ae9fc2017-03-20 12:08:42 +010039AC_DEFUN([AX_SSE],
Thomas Tsou3eaae802013-08-20 19:31:14 -040040[
41 AC_REQUIRE([AC_CANONICAL_HOST])
42
Vadim Yanitskiy038fd7f2017-05-20 01:24:04 +030043 AM_CONDITIONAL(HAVE_SSE3, false)
44 AM_CONDITIONAL(HAVE_SSE4_1, false)
45
Thomas Tsou3eaae802013-08-20 19:31:14 -040046 case $host_cpu in
47 i[[3456]]86*|x86_64*|amd64*)
Philipp Maierf5bf33b2017-03-16 13:12:07 +010048 AX_CHECK_COMPILE_FLAG(-msse3, ax_cv_support_sse3_ext=yes, [])
49 if test x"$ax_cv_support_sse3_ext" = x"yes"; then
50 SIMD_FLAGS="$SIMD_FLAGS -msse3"
Vadim Yanitskiy8537b902017-05-20 01:29:32 +030051 AC_DEFINE(HAVE_SSE3,,
52 [Support SSE3 (Streaming SIMD Extensions 3) instructions])
53 AM_CONDITIONAL(HAVE_SSE3, true)
Philipp Maierf5bf33b2017-03-16 13:12:07 +010054 else
Vadim Yanitskiy8537b902017-05-20 01:29:32 +030055 AC_MSG_WARN([Your compiler does not support SSE3 instructions])
Thomas Tsou3eaae802013-08-20 19:31:14 -040056 fi
57
Philipp Maierf5bf33b2017-03-16 13:12:07 +010058 AX_CHECK_COMPILE_FLAG(-msse4.1, ax_cv_support_sse41_ext=yes, [])
59 if test x"$ax_cv_support_sse41_ext" = x"yes"; then
60 SIMD_FLAGS="$SIMD_FLAGS -msse4.1"
Vadim Yanitskiy8537b902017-05-20 01:29:32 +030061 AC_DEFINE(HAVE_SSE4_1,,
62 [Support SSE4.1 (Streaming SIMD Extensions 4.1) instructions])
63 AM_CONDITIONAL(HAVE_SSE4_1, true)
Philipp Maierf5bf33b2017-03-16 13:12:07 +010064 else
Vadim Yanitskiy8537b902017-05-20 01:29:32 +030065 AC_MSG_WARN([Your compiler does not support SSE4.1])
Thomas Tsou3eaae802013-08-20 19:31:14 -040066 fi
Thomas Tsou3eaae802013-08-20 19:31:14 -040067 ;;
68 esac
69
70 AC_SUBST(SIMD_FLAGS)
71])