audio: Wired up new SSE code to build system.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 00e1e46..65d7cc2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -262,6 +262,7 @@ set_option(MMX "Use MMX assembly routines" ${OPT_DEF_ASM})
set_option(3DNOW "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
set_option(SSE "Use SSE assembly routines" ${OPT_DEF_ASM})
set_option(SSE2 "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
+set_option(SSE3 "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
set_option(ALTIVEC "Use Altivec assembly routines" ${OPT_DEF_ASM})
set_option(DISKAUDIO "Support the disk writer audio driver" ON)
set_option(DUMMYAUDIO "Support the dummy audio driver" ON)
@@ -516,8 +517,31 @@ if(ASSEMBLY)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
endif()
+ if(SSE3)
+ set(CMAKE_REQUIRED_FLAGS "-msse3")
+ check_c_source_compiles("
+ #ifdef __MINGW32__
+ #include <_mingw.h>
+ #ifdef __MINGW64_VERSION_MAJOR
+ #include <intrin.h>
+ #else
+ #include <pmmintrin.h>
+ #endif
+ #else
+ #include <pmmintrin.h>
+ #endif
+ #ifndef __SSE3__
+ #error Assembler CPP flag not enabled
+ #endif
+ int main(int argc, char **argv) { }" HAVE_SSE3)
+ if(HAVE_SSE3)
+ list(APPEND EXTRA_CFLAGS "-msse3")
+ endif()
+ set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
+ endif()
+
if(SSEMATH)
- if(SSE OR SSE2)
+ if(SSE OR SSE2 OR SSE3)
if(USE_GCC)
list(APPEND EXTRA_CFLAGS "-mfpmath=387")
endif()
@@ -557,12 +581,13 @@ if(ASSEMBLY)
endif()
set(HAVE_SSE TRUE)
set(HAVE_SSE2 TRUE)
+ set(HAVE_SSE3 TRUE)
set(SDL_ASSEMBLY_ROUTINES 1)
endif()
# TODO:
#else()
# if(USE_GCC OR USE_CLANG)
-# list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
+# list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-sse3" "-mno-mmx")
# endif()
endif()
diff --git a/configure b/configure
index 9c93953..a0ff763 100755
--- a/configure
+++ b/configure
@@ -798,6 +798,7 @@ enable_mmx
enable_3dnow
enable_sse
enable_sse2
+enable_sse3
enable_altivec
enable_oss
enable_alsa
@@ -1527,7 +1528,8 @@ Optional Features:
--enable-mmx use MMX assembly routines [[default=yes]]
--enable-3dnow use 3DNow! assembly routines [[default=yes]]
--enable-sse use SSE assembly routines [[default=yes]]
- --enable-sse2 use SSE2 assembly routines [[default=no]]
+ --enable-sse2 use SSE2 assembly routines [[default=maybe]]
+ --enable-sse3 use SSE3 assembly routines [[default=maybe]]
--enable-altivec use Altivec assembly routines [[default=yes]]
--enable-oss support the OSS audio API [[default=maybe]]
--enable-alsa support the ALSA audio API [[default=yes]]
@@ -17308,6 +17310,63 @@ $as_echo "$have_gcc_sse2" >&6; }
fi
fi
+ # Check whether --enable-sse3 was given.
+if test "${enable_sse3+set}" = set; then :
+ enableval=$enable_sse3;
+else
+ enable_sse3=$default_ssemath
+fi
+
+ if test x$enable_sse3 = xyes; then
+ save_CFLAGS="$CFLAGS"
+ have_gcc_sse3=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -msse3 option" >&5
+$as_echo_n "checking for GCC -msse3 option... " >&6; }
+ sse3_CFLAGS="-msse3"
+ CFLAGS="$save_CFLAGS $sse3_CFLAGS"
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #ifdef __MINGW32__
+ #include <_mingw.h>
+ #ifdef __MINGW64_VERSION_MAJOR
+ #include <intrin.h>
+ #else
+ #include <pmmintrin.h>
+ #endif
+ #else
+ #include <pmmintrin.h>
+ #endif
+ #ifndef __SSE2__
+ #error Assembler CPP flag not enabled
+ #endif
+
+int
+main ()
+{
+
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ have_gcc_sse3=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse3" >&5
+$as_echo "$have_gcc_sse3" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+ if test x$have_gcc_sse3 = xyes; then
+ EXTRA_CFLAGS="$EXTRA_CFLAGS $sse3_CFLAGS"
+ SUMMARY_math="${SUMMARY_math} sse3"
+ fi
+ fi
+
# Check whether --enable-altivec was given.
if test "${enable_altivec+set}" = set; then :
enableval=$enable_altivec;
diff --git a/configure.in b/configure.in
index 073c152..9eacefa 100644
--- a/configure.in
+++ b/configure.in
@@ -593,7 +593,7 @@ AC_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
fi
AC_ARG_ENABLE(sse2,
-AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=no]]]),
+AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]),
, enable_sse2=$default_ssemath)
if test x$enable_sse2 = xyes; then
save_CFLAGS="$CFLAGS"
@@ -629,6 +629,43 @@ AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=no]]]),
fi
fi
+ AC_ARG_ENABLE(sse3,
+AC_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]),
+ , enable_sse3=$default_ssemath)
+ if test x$enable_sse3 = xyes; then
+ save_CFLAGS="$CFLAGS"
+ have_gcc_sse3=no
+ AC_MSG_CHECKING(for GCC -msse3 option)
+ sse3_CFLAGS="-msse3"
+ CFLAGS="$save_CFLAGS $sse3_CFLAGS"
+
+ AC_TRY_COMPILE([
+ #ifdef __MINGW32__
+ #include <_mingw.h>
+ #ifdef __MINGW64_VERSION_MAJOR
+ #include <intrin.h>
+ #else
+ #include <pmmintrin.h>
+ #endif
+ #else
+ #include <pmmintrin.h>
+ #endif
+ #ifndef __SSE2__
+ #error Assembler CPP flag not enabled
+ #endif
+ ],[
+ ],[
+ have_gcc_sse3=yes
+ ])
+ AC_MSG_RESULT($have_gcc_sse3)
+ CFLAGS="$save_CFLAGS"
+
+ if test x$have_gcc_sse3 = xyes; then
+ EXTRA_CFLAGS="$EXTRA_CFLAGS $sse3_CFLAGS"
+ SUMMARY_math="${SUMMARY_math} sse3"
+ fi
+ fi
+
AC_ARG_ENABLE(altivec,
AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
, enable_altivec=yes)
diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h
index 3b260f1..25e2ff4 100644
--- a/include/SDL_cpuinfo.h
+++ b/include/SDL_cpuinfo.h
@@ -61,6 +61,9 @@
#ifdef __SSE2__
#include <emmintrin.h>
#endif
+#ifdef __SSE3__
+#include <pmmintrin.h>
+#endif
#endif
#include "begin_code.h"
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index 85196b1..7a915a6 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -28,13 +28,10 @@
#include "SDL_loadso.h"
#include "SDL_assert.h"
#include "../SDL_dataqueue.h"
-
-/* !!! FIXME: wire this up to the configure script, etc. */
#include "SDL_cpuinfo.h"
-#define HAVE_SSE3_INTRINSICS 0
-#if HAVE_SSE3_INTRINSICS
-#include <pmmintrin.h>
+#ifdef __SSE3__
+#define HAVE_SSE3_INTRINSICS 1
#endif
#if HAVE_SSE3_INTRINSICS
diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c
index 505e25a..91e9c64 100644
--- a/src/audio/SDL_audiotypecvt.c
+++ b/src/audio/SDL_audiotypecvt.c
@@ -28,11 +28,8 @@
/* !!! FIXME: write NEON code. */
#define HAVE_NEON_INTRINSICS 0
-/* !!! FIXME: wire this up to the configure script, etc. */
-#define HAVE_SSE2_INTRINSICS 0
-
-#if HAVE_SSE2_INTRINSICS
-#include <emmintrin.h>
+#ifdef __SSE2__
+#define HAVE_SSE2_INTRINSICS 1
#endif
#if defined(__x86_64__) && HAVE_SSE2_INTRINSICS