aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-07-16 08:41:56 -0700
committerChris Robinson <[email protected]>2018-07-16 08:41:56 -0700
commitd117a5209f390dfe97e072fa9665fdbf449828f5 (patch)
tree56d772b1f67b1925a451c6e1552ebcd430a2c50b /CMakeLists.txt
parented1f1d2bf331110ab6cc55797272eeb968760048 (diff)
On 32-bit targets with SSE, enable SSE/SSE2 codegen by default
Two new CMake options are available for 32-bit targets that accept -msse: ALSOFT_ENABLE_SSE_CODEGEN and ALSOFT_ENABLE_SSE2_CODEGEN, which default to TRUE. This should not affect MSVC, which already defaults to SSE2 codegen.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt28
1 files changed, 28 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c27c6e4e..b7de4a69 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -432,6 +432,30 @@ IF(HAVE_MFPU_NEON_SWITCH)
SET(FPU_NEON_SWITCH "-mfpu=neon")
ENDIF()
+SET(FPMATH_SET "0")
+IF(HAVE_MSSE_SWITCH AND CMAKE_SIZEOF_VOID_P MATCHES "4")
+ OPTION(ALSOFT_ENABLE_SSE_CODEGEN "Enable SSE code generation instead of x87 for 32-bit targets." TRUE)
+ IF(HAVE_MSSE2_SWITCH)
+ OPTION(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE)
+ ENDIF()
+
+ IF(HAVE_MSSE2_SWITCH AND ALSOFT_ENABLE_SSE2_CODEGEN)
+ CHECK_C_COMPILER_FLAG("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
+ IF(ALSOFT_ENABLE_SSE2_CODEGEN AND HAVE_MFPMATH_SSE_2)
+ SET(C_FLAGS ${C_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
+ SET(FPMATH_SET 2)
+ ENDIF()
+ ENDIF()
+ IF(ALSOFT_ENABLE_SSE_CODEGEN AND NOT FPMATH_SET)
+ CHECK_C_COMPILER_FLAG("${SSE_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE)
+ IF(ALSOFT_ENABLE_SSE_CODEGEN AND HAVE_MFPMATH_SSE)
+ SET(C_FLAGS ${C_FLAGS} ${SSE_SWITCH} -mfpmath=sse)
+ SET(FPMATH_SET 1)
+ ENDIF()
+ ENDIF()
+ENDIF()
+
+
CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
int main() {return 0;}" HAVE_GCC_FORMAT)
@@ -1471,6 +1495,10 @@ MESSAGE(STATUS "")
MESSAGE(STATUS "Building with support for CPU extensions:")
MESSAGE(STATUS " ${CPU_EXTS}")
MESSAGE(STATUS "")
+IF(FPMATH_SET)
+ MESSAGE(STATUS "Building with SSE${FPMATH_SET} codegen")
+ MESSAGE(STATUS "")
+ENDIF()
IF(WIN32)
IF(NOT HAVE_DSOUND)