SDL
3.0
SDL_intrin.h
Go to the documentation of this file.
1
/*
2
Simple DirectMedia Layer
3
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
4
5
This software is provided 'as-is', without any express or implied
6
warranty. In no event will the authors be held liable for any damages
7
arising from the use of this software.
8
9
Permission is granted to anyone to use this software for any purpose,
10
including commercial applications, and to alter it and redistribute it
11
freely, subject to the following restrictions:
12
13
1. The origin of this software must not be misrepresented; you must not
14
claim that you wrote the original software. If you use this software
15
in a product, an acknowledgment in the product documentation would be
16
appreciated but is not required.
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
3. This notice may not be removed or altered from any source distribution.
20
*/
21
22
/*
23
* Header file for CPU intrinsics for SDL
24
*/
25
26
#ifndef SDL_intrin_h_
27
#define SDL_intrin_h_
28
29
#include <
SDL3/SDL_stdinc.h
>
30
31
/* Need to do this here because intrin.h has C++ code in it */
32
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
33
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
34
#ifdef __clang__
35
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
36
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
37
#ifndef __PRFCHWINTRIN_H
38
#define __PRFCHWINTRIN_H
39
static
__inline__
void
__attribute__((__always_inline__, __nodebug__))
40
_m_prefetch(
void
*__P)
41
{
42
__builtin_prefetch (__P, 0, 3
/* _MM_HINT_T0 */
);
43
}
44
#endif
/* __PRFCHWINTRIN_H */
45
#endif
/* __clang__ */
46
#include <intrin.h>
47
48
#elif defined(__MINGW64_VERSION_MAJOR)
49
#include <intrin.h>
50
#if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON)
51
# define SDL_NEON_INTRINSICS 1
52
# include <arm_neon.h>
53
#endif
54
55
#else
56
/* 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. */
57
#if defined(__ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC)
58
#define SDL_ALTIVEC_INTRINSICS 1
59
#include <altivec.h>
60
#endif
61
#ifndef SDL_DISABLE_NEON
62
# ifdef __ARM_NEON
63
# define SDL_NEON_INTRINSICS 1
64
# include <arm_neon.h>
65
# elif defined(SDL_PLATFORM_WINDOWS)
66
/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
67
# ifdef _M_ARM
68
# define SDL_NEON_INTRINSICS 1
69
# include <armintr.h>
70
# include <arm_neon.h>
71
# define __ARM_NEON 1
/* Set __ARM_NEON so that it can be used elsewhere, at compile time */
72
# endif
73
# if defined (_M_ARM64)
74
# define SDL_NEON_INTRINSICS 1
75
# include <arm64intr.h>
76
# include <arm64_neon.h>
77
# define __ARM_NEON 1
/* Set __ARM_NEON so that it can be used elsewhere, at compile time */
78
# define __ARM_ARCH 8
79
# endif
80
# endif
81
#endif
82
#endif
/* compiler version */
83
84
#if defined(__clang__) && defined(__has_attribute)
85
# if __has_attribute(target)
86
# define SDL_HAS_TARGET_ATTRIBS
87
# endif
88
#elif defined(__GNUC__) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4)
/* gcc >= 4.9 */
89
# define SDL_HAS_TARGET_ATTRIBS
90
#elif defined(__ICC) && __ICC >= 1600
91
# define SDL_HAS_TARGET_ATTRIBS
92
#endif
93
94
#ifdef SDL_HAS_TARGET_ATTRIBS
95
# define SDL_TARGETING(x) __attribute__((target(x)))
96
#else
97
# define SDL_TARGETING(x)
98
#endif
99
100
#ifdef __loongarch64
101
# ifndef SDL_DISABLE_LSX
102
# define SDL_LSX_INTRINSICS 1
103
# include <lsxintrin.h>
104
# endif
105
# ifndef SDL_DISABLE_LASX
106
# define SDL_LASX_INTRINSICS 1
107
# include <lasxintrin.h>
108
# endif
109
#endif
110
111
#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
112
# if ((defined(_MSC_VER) && !defined(_M_X64)) || defined(__MMX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_MMX)
113
# define SDL_MMX_INTRINSICS 1
114
# include <mmintrin.h>
115
# endif
116
# if (defined(_MSC_VER) || defined(__SSE__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE)
117
# define SDL_SSE_INTRINSICS 1
118
# include <xmmintrin.h>
119
# endif
120
# if (defined(_MSC_VER) || defined(__SSE2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE2)
121
# define SDL_SSE2_INTRINSICS 1
122
# include <emmintrin.h>
123
# endif
124
# if (defined(_MSC_VER) || defined(__SSE3__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE3)
125
# define SDL_SSE3_INTRINSICS 1
126
# include <pmmintrin.h>
127
# endif
128
# if (defined(_MSC_VER) || defined(__SSE4_1__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE4_1)
129
# define SDL_SSE4_1_INTRINSICS 1
130
# include <smmintrin.h>
131
# endif
132
# if (defined(_MSC_VER) || defined(__SSE4_2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE4_2)
133
# define SDL_SSE4_2_INTRINSICS 1
134
# include <nmmintrin.h>
135
# endif
136
# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX__) && !defined(SDL_DISABLE_AVX)
137
# define SDL_DISABLE_AVX
/* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */
138
# endif
139
# if (defined(_MSC_VER) || defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX)
140
# define SDL_AVX_INTRINSICS 1
141
# include <immintrin.h>
142
# endif
143
# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX2__) && !defined(SDL_DISABLE_AVX2)
144
# define SDL_DISABLE_AVX2
/* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */
145
# endif
146
# if (defined(_MSC_VER) || defined(__AVX2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX2)
147
# define SDL_AVX2_INTRINSICS 1
148
# include <immintrin.h>
149
# endif
150
# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX512F__) && !defined(SDL_DISABLE_AVX512F)
151
# define SDL_DISABLE_AVX512F
/* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */
152
# endif
153
# if (defined(_MSC_VER) || defined(__AVX512F__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX512F)
154
# define SDL_AVX512F_INTRINSICS 1
155
# include <immintrin.h>
156
# endif
157
#endif
/* defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) */
158
159
#endif
/* SDL_intrin_h_ */
__inline__
#define __inline__
Definition
SDL_begin_code.h:120
SDL_stdinc.h
include
SDL3
SDL_intrin.h
Generated by
1.9.8