mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 19:38:14 +00:00
cmake: use 'TargetConditionals.h' on Apple for SIMD tests
This commit is contained in:

committed by
Anonymous Maarten

parent
1e7d3b51de
commit
e15e2808f2
@@ -683,7 +683,7 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -mmmx")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -mmmx")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <mmintrin.h>
|
#include <mmintrin.h>
|
||||||
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
||||||
for (; size >= 2; size -= 2, dest += 2, a += 2, b += 2) {
|
for (; size >= 2; size -= 2, dest += 2, a += 2, b += 2) {
|
||||||
@@ -693,7 +693,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
ints_add((int*)0, (int*)0, (int*)0, 0);
|
ints_add((int*)0, (int*)0, (int*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_MMX)
|
}]==] COMPILER_SUPPORTS_MMX)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_MMX)
|
if(COMPILER_SUPPORTS_MMX)
|
||||||
set(HAVE_MMX TRUE)
|
set(HAVE_MMX TRUE)
|
||||||
@@ -704,7 +704,7 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -msse")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <xmmintrin.h>
|
#include <xmmintrin.h>
|
||||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||||
@@ -714,7 +714,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_SSE)
|
}]==] COMPILER_SUPPORTS_SSE)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_SSE)
|
if(COMPILER_SUPPORTS_SSE)
|
||||||
set(HAVE_SSE TRUE)
|
set(HAVE_SSE TRUE)
|
||||||
@@ -725,7 +725,7 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse2")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -msse2")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <emmintrin.h>
|
#include <emmintrin.h>
|
||||||
void doubles_add(double *dest, double *a, double *b, unsigned size) {
|
void doubles_add(double *dest, double *a, double *b, unsigned size) {
|
||||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||||
@@ -735,7 +735,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
doubles_add((double*)0, (double*)0, (double*)0, 0);
|
doubles_add((double*)0, (double*)0, (double*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_SSE2)
|
}]==] COMPILER_SUPPORTS_SSE2)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_SSE2)
|
if(COMPILER_SUPPORTS_SSE2)
|
||||||
set(HAVE_SSE2 TRUE)
|
set(HAVE_SSE2 TRUE)
|
||||||
@@ -746,7 +746,7 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse3")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -msse3")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <pmmintrin.h>
|
#include <pmmintrin.h>
|
||||||
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
||||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||||
@@ -756,7 +756,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
ints_add((int*)0, (int*)0, (int*)0, 0);
|
ints_add((int*)0, (int*)0, (int*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_SSE3)
|
}]==] COMPILER_SUPPORTS_SSE3)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_SSE3)
|
if(COMPILER_SUPPORTS_SSE3)
|
||||||
set(HAVE_SSE3 TRUE)
|
set(HAVE_SSE3 TRUE)
|
||||||
@@ -767,7 +767,7 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.1")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.1")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <smmintrin.h>
|
#include <smmintrin.h>
|
||||||
void ints_mul(int *dest, int *a, int *b, unsigned size) {
|
void ints_mul(int *dest, int *a, int *b, unsigned size) {
|
||||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||||
@@ -777,7 +777,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
ints_mul((int*)0, (int*)0, (int*)0, 0);
|
ints_mul((int*)0, (int*)0, (int*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_SSE4_1)
|
}]==] COMPILER_SUPPORTS_SSE4_1)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_SSE4_1)
|
if(COMPILER_SUPPORTS_SSE4_1)
|
||||||
set(HAVE_SSE4_1 TRUE)
|
set(HAVE_SSE4_1 TRUE)
|
||||||
@@ -788,14 +788,14 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.2")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.2")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <nmmintrin.h>
|
#include <nmmintrin.h>
|
||||||
__m128i bitmask;
|
__m128i bitmask;
|
||||||
char data[16];
|
char data[16];
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), _mm_loadu_si128((void*)data));
|
bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), _mm_loadu_si128((void*)data));
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_SSE4_2)
|
}]==] COMPILER_SUPPORTS_SSE4_2)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_SSE4_2)
|
if(COMPILER_SUPPORTS_SSE4_2)
|
||||||
set(HAVE_SSE4_2 TRUE)
|
set(HAVE_SSE4_2 TRUE)
|
||||||
@@ -806,7 +806,7 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||||
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
|
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
|
||||||
@@ -816,7 +816,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_AVX)
|
}]==] COMPILER_SUPPORTS_AVX)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_AVX)
|
if(COMPILER_SUPPORTS_AVX)
|
||||||
set(HAVE_AVX TRUE)
|
set(HAVE_AVX TRUE)
|
||||||
@@ -827,7 +827,7 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx2")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx2")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
||||||
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
|
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
|
||||||
@@ -837,7 +837,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
ints_add((int*)0, (int*)0, (int*)0, 0);
|
ints_add((int*)0, (int*)0, (int*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_AVX2)
|
}]==] COMPILER_SUPPORTS_AVX2)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_AVX2)
|
if(COMPILER_SUPPORTS_AVX2)
|
||||||
set(HAVE_AVX2 TRUE)
|
set(HAVE_AVX2 TRUE)
|
||||||
@@ -848,7 +848,7 @@ if(SDL_ASSEMBLY)
|
|||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx512f")
|
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx512f")
|
||||||
endif()
|
endif()
|
||||||
check_c_source_compiles("
|
check_x86_source_compiles([==[
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||||
for (; size >= 16; size -= 16, dest += 16, a += 16, b += 16) {
|
for (; size >= 16; size -= 16, dest += 16, a += 16, b += 16) {
|
||||||
@@ -858,7 +858,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_AVX512F)
|
}]==] COMPILER_SUPPORTS_AVX512F)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
if(COMPILER_SUPPORTS_AVX512F)
|
if(COMPILER_SUPPORTS_AVX512F)
|
||||||
set(HAVE_AVX512F TRUE)
|
set(HAVE_AVX512F TRUE)
|
||||||
@@ -866,7 +866,7 @@ if(SDL_ASSEMBLY)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SDL_ARMNEON)
|
if(SDL_ARMNEON)
|
||||||
check_c_source_compiles("
|
check_arm_source_compiles([==[
|
||||||
#include <arm_neon.h>
|
#include <arm_neon.h>
|
||||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||||
@@ -876,8 +876,7 @@ if(SDL_ASSEMBLY)
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}" COMPILER_SUPPORTS_ARMNEON)
|
}]==] COMPILER_SUPPORTS_ARMNEON)
|
||||||
|
|
||||||
if(COMPILER_SUPPORTS_ARMNEON)
|
if(COMPILER_SUPPORTS_ARMNEON)
|
||||||
set(HAVE_ARMNEON TRUE)
|
set(HAVE_ARMNEON TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
@@ -160,3 +160,65 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(check_x86_source_compiles BODY VAR)
|
||||||
|
if(ARGN)
|
||||||
|
message(FATAL_ERROR "Unknown arguments: ${ARGN}")
|
||||||
|
endif()
|
||||||
|
if(APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES)
|
||||||
|
set(test_conditional 1)
|
||||||
|
else()
|
||||||
|
set(test_conditional 0)
|
||||||
|
endif()
|
||||||
|
check_c_source_compiles("
|
||||||
|
#if ${test_conditional}
|
||||||
|
# include \"TargetConditionals.h\"
|
||||||
|
# if TARGET_CPU_X86 || TARGET_CPU_X86_64
|
||||||
|
# define test_enabled 1
|
||||||
|
# else
|
||||||
|
# define test_enabled 0
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define test_enabled 1
|
||||||
|
#endif
|
||||||
|
#if test_enabled
|
||||||
|
${BODY}
|
||||||
|
#else
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif" ${VAR})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(check_arm_source_compiles BODY VAR)
|
||||||
|
if(ARGN)
|
||||||
|
message(FATAL_ERROR "Unknown arguments: ${ARGN}")
|
||||||
|
endif()
|
||||||
|
if(APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES)
|
||||||
|
set(test_conditional 1)
|
||||||
|
else()
|
||||||
|
set(test_conditional 0)
|
||||||
|
endif()
|
||||||
|
check_c_source_compiles("
|
||||||
|
#if ${test_conditional}
|
||||||
|
# include \"TargetConditionals.h\"
|
||||||
|
# if TARGET_CPU_ARM || TARGET_CPU_ARM64
|
||||||
|
# define test_enabled 1
|
||||||
|
# else
|
||||||
|
# define test_enabled 0
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define test_enabled 1
|
||||||
|
#endif
|
||||||
|
#if test_enabled
|
||||||
|
${BODY}
|
||||||
|
#else
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif" ${VAR})
|
||||||
|
endfunction()
|
||||||
|
Reference in New Issue
Block a user