2022-11-26 20:12:42 +03:00
/*
Simple DirectMedia Layer
2024-01-02 00:15:26 +03:00
Copyright ( C ) 1997 - 2024 Sam Lantinga < slouken @ libsdl . org >
2022-11-26 20:12:42 +03:00
This software is provided ' as - is ' , without any express or implied
warranty . In no event will the authors be held liable for any damages
arising from the use of this software .
Permission is granted to anyone to use this software for any purpose ,
including commercial applications , and to alter it and redistribute it
freely , subject to the following restrictions :
1. The origin of this software must not be misrepresented ; you must not
claim that you wrote the original software . If you use this software
in a product , an acknowledgment in the product documentation would be
appreciated but is not required .
2. Altered source versions must be plainly marked as such , and must not be
misrepresented as being the original software .
3. This notice may not be removed or altered from any source distribution .
*/
2024-05-16 17:44:37 +03:00
/*
2023-11-06 18:26:06 +03:00
* Header file for CPU intrinsics for SDL
2023-01-11 02:50:35 +03:00
*/
2022-11-26 20:12:42 +03:00
# ifndef SDL_intrin_h_
# define SDL_intrin_h_
# include <SDL3/SDL_stdinc.h>
/* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
# if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
# ifdef __clang__
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
so we define the needed ' _m_prefetch ' here as a pseudo - header , until the issue is fixed . */
# ifndef __PRFCHWINTRIN_H
# define __PRFCHWINTRIN_H
static __inline__ void __attribute__ ( ( __always_inline__ , __nodebug__ ) )
_m_prefetch ( void * __P )
{
__builtin_prefetch ( __P , 0 , 3 /* _MM_HINT_T0 */ ) ;
}
# endif /* __PRFCHWINTRIN_H */
# endif /* __clang__ */
# include <intrin.h>
2023-03-19 20:56:24 +03:00
2022-11-26 20:12:42 +03:00
# elif defined(__MINGW64_VERSION_MAJOR)
# include <intrin.h>
2023-02-26 03:51:19 +03:00
# if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON)
2023-03-18 19:15:37 +03:00
# define SDL_NEON_INTRINSICS 1
2022-11-26 20:12:42 +03:00
# include <arm_neon.h>
# endif
2023-03-19 20:56:24 +03:00
2022-11-26 20:12:42 +03:00
# else
2023-03-15 06:56:55 +03:00
/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC to have it included. */
# if defined(__ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC)
2023-03-18 19:15:37 +03:00
# define SDL_ALTIVEC_INTRINSICS 1
2022-11-26 20:12:42 +03:00
# include <altivec.h>
# endif
2023-03-30 21:26:31 +03:00
# ifndef SDL_DISABLE_NEON
# ifdef __ARM_NEON
2023-03-18 19:15:37 +03:00
# define SDL_NEON_INTRINSICS 1
2022-11-26 20:12:42 +03:00
# include <arm_neon.h>
2024-01-24 20:37:00 +03:00
# elif defined(SDL_PLATFORM_WINDOWS)
2022-11-26 20:12:42 +03:00
/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
2023-03-30 21:26:31 +03:00
# ifdef _M_ARM
2023-03-18 19:15:37 +03:00
# define SDL_NEON_INTRINSICS 1
2022-11-26 20:12:42 +03:00
# include <armintr.h>
# include <arm_neon.h>
# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
# endif
# if defined (_M_ARM64)
2023-03-18 19:15:37 +03:00
# define SDL_NEON_INTRINSICS 1
2022-11-26 20:12:42 +03:00
# include <arm64intr.h>
# include <arm64_neon.h>
# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
# define __ARM_ARCH 8
# endif
# endif
# endif
# endif /* compiler version */
2023-03-17 20:57:40 +03:00
# if defined(__clang__) && defined(__has_attribute)
# if __has_attribute(target)
# define SDL_HAS_TARGET_ATTRIBS
# endif
# elif defined(__GNUC__) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */
# define SDL_HAS_TARGET_ATTRIBS
2023-03-21 21:16:24 +03:00
# elif defined(__ICC) && __ICC >= 1600
# define SDL_HAS_TARGET_ATTRIBS
2023-03-17 20:57:40 +03:00
# endif
# ifdef SDL_HAS_TARGET_ATTRIBS
# define SDL_TARGETING(x) __attribute__((target(x)))
# else
# define SDL_TARGETING(x)
# endif
2023-03-30 21:26:31 +03:00
# ifdef __loongarch64
2023-03-30 05:00:48 +03:00
# ifndef SDL_DISABLE_LSX
# define SDL_LSX_INTRINSICS 1
# include <lsxintrin.h>
# endif
# ifndef SDL_DISABLE_LASX
# define SDL_LASX_INTRINSICS 1
# include <lasxintrin.h>
# endif
2022-11-26 20:12:42 +03:00
# endif
2023-03-18 19:15:37 +03:00
2023-03-17 21:45:45 +03:00
# if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
2023-03-19 20:56:24 +03:00
# if ((defined(_MSC_VER) && !defined(_M_X64)) || defined(__MMX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_MMX)
2023-03-18 19:15:37 +03:00
# define SDL_MMX_INTRINSICS 1
# include <mmintrin.h>
# endif
2023-03-19 20:56:24 +03:00
# if (defined(_MSC_VER) || defined(__SSE__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE)
2023-03-18 19:15:37 +03:00
# define SDL_SSE_INTRINSICS 1
# include <xmmintrin.h>
# endif
2023-03-19 20:56:24 +03:00
# if (defined(_MSC_VER) || defined(__SSE2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE2)
2023-03-18 19:15:37 +03:00
# define SDL_SSE2_INTRINSICS 1
# include <emmintrin.h>
# endif
2023-03-19 20:56:24 +03:00
# if (defined(_MSC_VER) || defined(__SSE3__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE3)
2023-03-18 19:15:37 +03:00
# define SDL_SSE3_INTRINSICS 1
# include <pmmintrin.h>
# endif
2023-03-21 18:57:09 +03:00
# if (defined(_MSC_VER) || defined(__SSE4_1__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE4_1)
2023-03-21 01:48:01 +03:00
# define SDL_SSE4_1_INTRINSICS 1
# include <smmintrin.h>
# endif
2023-03-21 18:57:09 +03:00
# if (defined(_MSC_VER) || defined(__SSE4_2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE4_2)
2023-03-21 01:48:01 +03:00
# define SDL_SSE4_2_INTRINSICS 1
# include <nmmintrin.h>
# endif
2023-03-21 20:30:50 +03:00
# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX__) && !defined(SDL_DISABLE_AVX)
# define SDL_DISABLE_AVX /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */
# endif
2024-07-20 01:10:19 +03:00
# if (defined(_MSC_VER) || defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX)
2023-03-21 01:48:01 +03:00
# define SDL_AVX_INTRINSICS 1
# include <immintrin.h>
# endif
2023-03-21 20:30:50 +03:00
# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX2__) && !defined(SDL_DISABLE_AVX2)
# define SDL_DISABLE_AVX2 /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */
# endif
2024-07-20 01:10:19 +03:00
# if (defined(_MSC_VER) || defined(__AVX2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX2)
2023-03-21 14:55:32 +03:00
# define SDL_AVX2_INTRINSICS 1
# include <immintrin.h>
# endif
2023-03-21 20:30:50 +03:00
# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX512F__) && !defined(SDL_DISABLE_AVX512F)
# define SDL_DISABLE_AVX512F /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */
# endif
2024-07-20 01:10:19 +03:00
# if (defined(_MSC_VER) || defined(__AVX512F__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX512F)
2023-03-21 01:48:01 +03:00
# define SDL_AVX512F_INTRINSICS 1
# include <immintrin.h>
# endif
2023-03-18 19:15:37 +03:00
# endif /* defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) */
2022-11-26 20:12:42 +03:00
# endif /* SDL_intrin_h_ */