Kore 3
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#ifndef KORE_SIMD_TYPES_HEADER
2#define KORE_SIMD_TYPES_HEADER
3
4#include <kore3/global.h>
5
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14// Any level of AVX Capability (Could be AVX, AVX2, AVX512, etc.)
15//(Currently) only used for checking existence of earlier SSE instruction sets
16#if defined(__AVX__)
17// Unfortunate situation here
18// MSVC does not provide compiletime macros for the following instruction sets
19// but their existence is implied by AVX and higher
20#define KORE_SSE4_2
21#define KORE_SSE4_1
22#define KORE_SSSE3
23#define KORE_SSE3
24#define KORE_SSE2
25#define KORE_SSE
26
27#else
28
29#if defined(__SSE4_2__)
30#define KORE_SSE4_2
31#endif
32
33#if defined(__SSE4_1__) || defined(KORE_SSE4_2)
34#define KORE_SSE4_1
35#endif
36
37#if defined(__SSSE3__) || defined(KORE_SSE4_1)
38#define KORE_SSSE3
39#endif
40
41#if defined(__SSE3__) || defined(KORE_SSSE3)
42#define KORE_SSE3
43#endif
44
45// SSE2 Capability check
46// Note for Windows:
47// _M_IX86_FP checks SSE2 and SSE for 32bit Windows programs only, and is unset if not a 32bit program.
48// SSE2 and earlier is --guaranteed-- to be active for any 64bit Windows program
49#if defined(__SSE2__) || (_M_IX86_FP == 2) || ((defined(KORE_WINDOWS) || defined(KORE_WINDOWSAPP)) && defined(KORE_64) && !defined(__aarch64__)) || \
50 defined(KORE_SSE3)
51#define KORE_SSE2
52#endif
53
54// SSE Capability check
55#if defined(__SSE__) || _M_IX86_FP == 2 || _M_IX86_FP == 1 || (defined(KORE_WINDOWS) && !defined(__aarch64__)) || \
56 (defined(KORE_WINDOWSAPP) && !defined(__aarch64__)) || (defined(KORE_MACOS) && __x86_64) || defined(KORE_SSE2)
57#define KORE_SSE
58#endif
59
60#endif
61
62// NEON Capability check
63#if defined(KORE_IOS) || defined(KORE_SWITCH) || defined(__aarch64__) || defined(KORE_NEON)
64#define KORE_NEON
65#endif
66
67// No SIMD Capabilities
68#if !defined(KORE_SSE4_2) && !defined(KORE_SSE4_1) && !defined(KORE_SSSE3) && !defined(KORE_SSE3) && !defined(KORE_SSE2) && !defined(KORE_SSE) && \
69 !defined(KORE_NEON)
70
71#define KORE_NOSIMD
72#endif
73
74#define KORE_SHUFFLE_TABLE(LANE_A1, LANE_A2, LANE_B1, LANE_B2) \
75 ((((LANE_B2) & 0x3) << 6) | (((LANE_B1) & 0x3) << 4) | (((LANE_A2) & 0x3) << 2) | (((LANE_A1) & 0x3) << 0))
76
77#if defined(KORE_SSE2)
78
79// SSE_## related headers include earlier revisions, IE
80// SSE2 contains all of SSE
81
82#if defined(KORE_SSE4_2)
83#include <nmmintrin.h>
84#elif defined(KORE_SSE4_1)
85#include <smmintrin.h>
86#elif defined(KORE_SSSE3)
87#include <tmmintrin.h>
88#elif defined(KORE_SSE3)
89#include <pmmintrin.h>
90#else
91#include <emmintrin.h>
92#endif
93
94typedef __m128 kore_float32x4;
95typedef __m128 kore_float32x4_mask;
96
97typedef __m128i kore_int8x16;
98typedef __m128i kore_int8x16_mask;
99typedef __m128i kore_uint8x16;
100typedef __m128i kore_uint8x16_mask;
101typedef __m128i kore_int16x8;
102typedef __m128i kore_int16x8_mask;
103typedef __m128i kore_uint16x8;
104typedef __m128i kore_uint16x8_mask;
105typedef __m128i kore_int32x4;
106typedef __m128i kore_int32x4_mask;
107typedef __m128i kore_uint32x4;
108typedef __m128i kore_uint32x4_mask;
109
110#elif defined(KORE_SSE)
111
112#include <xmmintrin.h>
113
114typedef __m128 kore_float32x4;
115typedef __m128 kore_float32x4_mask;
116
117typedef struct kore_int8x16 {
118 int8_t values[16];
120
121typedef struct kore_uint8x16 {
122 uint8_t values[16];
124
125typedef struct kore_int16x8 {
126 int16_t values[8];
128
129typedef struct kore_uint16x8 {
130 uint16_t values[8];
132
133typedef struct kore_int32x4 {
134 int32_t values[4];
136
137typedef struct kore_uint32x4 {
138 uint32_t values[4];
140
141typedef kore_int8x16 kore_int8x16_mask;
142typedef kore_uint8x16 kore_uint8x16_mask;
143typedef kore_int16x8 kore_int16x8_mask;
144typedef kore_uint16x8 kore_uint16x8_mask;
145typedef kore_int32x4 kore_int32x4_mask;
146typedef kore_uint32x4 kore_uint32x4_mask;
147
148#elif defined(KORE_NEON)
149
150#include <arm_neon.h>
151
152typedef float32x4_t kore_float32x4;
153typedef uint32x4_t kore_float32x4_mask;
154
155typedef int8x16_t kore_int8x16;
156typedef uint8x16_t kore_int8x16_mask;
157typedef uint8x16_t kore_uint8x16;
158typedef uint8x16_t kore_uint8x16_mask;
159typedef int16x8_t kore_int16x8;
160typedef uint16x8_t kore_int16x8_mask;
161typedef uint16x8_t kore_uint16x8;
162typedef uint16x8_t kore_uint16x8_mask;
163typedef int32x4_t kore_int32x4;
164typedef uint32x4_t kore_int32x4_mask;
165typedef uint32x4_t kore_uint32x4;
166typedef uint32x4_t kore_uint32x4_mask;
167
168#else
169
170#include <kore3/math/core.h>
171
172typedef struct kore_float32x4 {
173 float values[4];
175
176typedef kore_float32x4 kore_float32x4_mask;
177
178typedef struct kore_int8x16 {
179 int8_t values[16];
181
182typedef struct kore_uint8x16 {
183 uint8_t values[16];
185
186typedef struct kore_int16x8 {
187 int16_t values[8];
189
190typedef struct kore_uint16x8 {
191 uint16_t values[8];
193
194typedef struct kore_int32x4 {
195 int32_t values[4];
197
198typedef struct kore_uint32x4 {
199 uint32_t values[4];
201
202typedef kore_int8x16 kore_int8x16_mask;
203typedef kore_uint8x16 kore_uint8x16_mask;
204typedef kore_int16x8 kore_int16x8_mask;
205typedef kore_uint16x8 kore_uint16x8_mask;
206typedef kore_int32x4 kore_int32x4_mask;
207typedef kore_uint32x4 kore_uint32x4_mask;
208
209#endif
210
211#ifdef __cplusplus
212}
213#endif
214
215#endif
Just a few very simple additions to math.h.
Provides basic functionality that's used all over the place. There's usually no need to manually incl...
Definition types.h:172
Definition types.h:186
Definition types.h:194
Definition types.h:178
Definition types.h:190
Definition types.h:198
Definition types.h:182