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.
This commit is contained in:
Chris Robinson 2018-07-16 08:41:56 -07:00
parent ed1f1d2bf3
commit d117a5209f

View File

@ -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)