cmake: added support for enabling the ARM SIMD/NEON code.
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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b1c3eba..7e8591d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -329,6 +329,8 @@ 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(ARMSIMD "use SIMD assembly blitters on ARM" ON)
+set_option(ARMNEON "use NEON assembly blitters on ARM" ON)
set_option(DISKAUDIO "Support the disk writer audio driver" ON)
set_option(DUMMYAUDIO "Support the dummy audio driver" ON)
set_option(VIDEO_DIRECTFB "Use DirectFB video driver" OFF)
@@ -671,6 +673,61 @@ if(ASSEMBLY)
endif()
endif()
endif()
+
+ if(ARMSIMD)
+ set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
+ check_c_source_compiles("
+ .text
+ .arch armv6
+ .object_arch armv4
+ .arm
+ .altmacro
+ #ifndef __ARM_EABI__
+ #error EABI is required (to be sure that calling conventions are compatible)
+ #endif
+ pld [r0]
+ uqadd8 r0, r0, r0
+ " ARMSIMD_FOUND)
+ set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
+
+ if(ARMSIMD_FOUND)
+ set(HAVE_ARMSIMD TRUE)
+ set(SDL_ARM_SIMD_BLITTERS 1)
+ file(GLOB ARMSIMD_SOURCES ${SDL2_SOURCE_DIR}/src/video/arm/pixman-arm-simd*.S)
+ set(SOURCE_FILES ${SOURCE_FILES} ${ARMSIMD_SOURCES})
+ set(WARN_ABOUT_ARM_SIMD_ASM_MIT TRUE)
+ endif()
+ endif()
+
+ if(ARMNEON)
+ set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
+ check_c_source_compiles("
+ .text
+ .fpu neon
+ .arch armv7a
+ .object_arch armv4
+ .eabi_attribute 10, 0
+ .arm
+ .altmacro
+ #ifndef __ARM_EABI__
+ #error EABI is required (to be sure that calling conventions are compatible)
+ #endif
+ pld [r0]
+ vmovn.u16 d0, q0
+ " ARMNEON_FOUND)
+ set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
+
+ if(ARMNEON_FOUND)
+ set(HAVE_ARMNEON TRUE)
+ set(SDL_ARM_NEON_BLITTERS 1)
+ file(GLOB ARMNEON_SOURCES ${SDL2_SOURCE_DIR}/src/video/arm/pixman-arm-neon*.S)
+ set(SOURCE_FILES ${SOURCE_FILES} ${ARMNEON_SOURCES})
+ set(WARN_ABOUT_ARM_NEON_ASM_MIT TRUE)
+ endif()
+ endif()
+
elseif(MSVC_VERSION GREATER 1500)
# TODO: SDL_cpuinfo.h needs to support the user's configuration wish
# for MSVC - right now it is always activated
@@ -1927,6 +1984,24 @@ if(UNIX)
message(STATUS "")
endif()
+if(WARN_ABOUT_ARM_SIMD_ASM_MIT)
+ message(STATUS "")
+ message(STATUS "SDL is being built with ARM SIMD optimizations, which")
+ message(STATUS "uses code licensed under the MIT license. If this is a")
+ message(STATUS "problem, please disable that code by rerunning CMake with:")
+ message(STATUS "")
+ message(STATUS " -DARMSIMD=OFF")
+endif()
+
+if(WARN_ABOUT_ARM_NEON_ASM_MIT)
+ message(STATUS "")
+ message(STATUS "SDL is being built with ARM NEON optimizations, which")
+ message(STATUS "uses code licensed under the MIT license. If this is a")
+ message(STATUS "problem, please disable that code by rerunning CMake with:")
+ message(STATUS "")
+ message(STATUS " -DARMNEON=OFF")
+endif()
+
# Ensure that the extra cflags are used at compile time
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index e791aef..34220f3 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -415,6 +415,8 @@
/* Enable assembly routines */
#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
#cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@
+#cmakedefine SDL_ARM_SIMD_BLITTERS @SDL_ARM_SIMD_BLITTERS@
+#cmakedefine SDL_ARM_NEON_BLITTERS @SDL_ARM_NEON_BLITTERS@
/* Enable dynamic libsamplerate support */
#cmakedefine SDL_LIBSAMPLERATE_DYNAMIC @SDL_LIBSAMPLERATE_DYNAMIC@