native
0.0.1
Vectors, masks and wide register packs for C++26
Main Page
Related Pages
Topics
Modules
Namespaces
Concepts
Classes
Files
File List
File Members
Loading...
Searching...
No Matches
targets.h
1
// SPDX-FileCopyrightText: 2026 Edward Kmett <ekmett@gmail.com>
2
// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
3
#pragma once
4
5
// Textual macros only: this header can precede or follow `import native;`.
6
// Its expansions require the exported native ISA metadata. Clang is intentional.
7
#ifndef __clang__
8
#error native source target variants require Clang
9
#endif
10
11
// Register a custom source name with one literal, for example:
12
// #define NATIVE_TARGET_compact "avx2,f16c"
13
// The same literal drives compiler attributes, ISA values and admission.
14
// Only positive feature names in native's registry are accepted; CPU names and
15
// arbitrary C++ aliases cannot be reverse-engineered into compiler attributes.
16
// The empty literal gives scalar metadata; its scope below deliberately applies
17
// no target attribute. Clang reserves "default" for function multiversioning.
18
#define NATIVE_TARGET_scalar ""
19
#define NATIVE_TARGET_avx2 "avx2,fma"
20
#define NATIVE_TARGET_avx512 "avx2,fma,avx512f,avx512dq,avx512bw,avx512vl"
21
#define NATIVE_TARGET_avx512_bf16 "avx2,fma,avx512f,avx512dq,avx512bw,avx512vl,avx512bf16"
22
#define NATIVE_TARGET_avx512_fp16 "avx2,fma,avx512f,avx512dq,avx512bw,avx512vl,avx512fp16"
23
#define NATIVE_TARGET_neon "neon"
24
#define NATIVE_TARGET_neon_fp16 "neon,fullfp16"
25
#define NATIVE_TARGET_neon_bf16 "neon,bf16"
26
27
#define NATIVE_DETAIL_TARGET_CAT_I(a,b) a##b
28
#define NATIVE_DETAIL_TARGET_CAT(a,b) NATIVE_DETAIL_TARGET_CAT_I(a,b)
29
#define NATIVE_DETAIL_TARGET_STRING_I(...) #__VA_ARGS__
30
#define NATIVE_DETAIL_TARGET_STRING(...) NATIVE_DETAIL_TARGET_STRING_I(__VA_ARGS__)
31
#define NATIVE_DETAIL_TARGET_PRAGMA(...) _Pragma(NATIVE_DETAIL_TARGET_STRING(__VA_ARGS__))
32
#define NATIVE_TARGET_STRING(name) NATIVE_DETAIL_TARGET_CAT(NATIVE_TARGET_,name)
33
#define NATIVE_TARGET_ISA(name) \
34
(::native::detail::source_isa<::native::target_features(NATIVE_TARGET_STRING(name))>)
35
36
// The named pragma stack prevents accidentally popping an unrelated user's
37
// clang attribute stack. This does not generate preprocessor #include lines.
38
// Generate outside other ISA target scopes: Clang combines nested requirements,
39
// which predefines cannot observe. Intentional nesting must record the outer
40
// requirements in NATIVE_TARGET_EXTRA_MINIMUM for admission.
41
#define NATIVE_DETAIL_TARGET_SECOND(a,b,...) b
42
#define NATIVE_DETAIL_TARGET_PROBE() unused,1
43
#define NATIVE_DETAIL_TARGET_SCALAR_scalar NATIVE_DETAIL_TARGET_PROBE()
44
#define NATIVE_DETAIL_TARGET_IS_SCALAR_I(...) NATIVE_DETAIL_TARGET_SECOND(__VA_ARGS__,0)
45
#define NATIVE_DETAIL_TARGET_IS_SCALAR(name) \
46
NATIVE_DETAIL_TARGET_IS_SCALAR_I(NATIVE_DETAIL_TARGET_CAT(NATIVE_DETAIL_TARGET_SCALAR_,name))
47
#define NATIVE_DETAIL_TARGET_PUSH_0(name) \
48
NATIVE_DETAIL_TARGET_PRAGMA(clang attribute native_source_target.push(__attribute__((target(NATIVE_TARGET_STRING(name)))), apply_to=function))
49
#define NATIVE_DETAIL_TARGET_PUSH_1(name) \
50
NATIVE_DETAIL_TARGET_PRAGMA(clang attribute native_source_target.push)
51
#define NATIVE_TARGET_PUSH(name) \
52
NATIVE_DETAIL_TARGET_CAT(NATIVE_DETAIL_TARGET_PUSH_,NATIVE_DETAIL_TARGET_IS_SCALAR(name))(name)
53
#define NATIVE_TARGET_POP() NATIVE_DETAIL_TARGET_PRAGMA(clang attribute native_source_target.pop)
54
55
/*
56
Context-aware adaptation of BAD_MAP in
57
https://github.com/ekmett/bad/blob/main/include/bad/macros.hh
58
Copyright (C) 2012 William Swanson, 2021 Edward Kmett.
59
Permission is hereby granted, free of charge, to any person obtaining a copy of
60
this software and associated documentation files (the "Software"), to deal in
61
the Software without restriction, including without limitation the rights to
62
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
63
the Software, and to permit persons to whom the Software is furnished to do so,
64
subject to the following conditions:
65
The above copyright notice and this permission notice shall be included in all
66
copies or substantial portions of the Software.
67
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
71
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
72
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73
Except as contained in this notice, the names of the authors or their
74
institutions shall not be used in advertising or otherwise to promote the sale,
75
use or other dealings in this Software without prior written authorization from
76
the authors.
77
*/
78
#define NATIVE_DETAIL_TARGET_EVAL0(...) __VA_ARGS__
79
#define NATIVE_DETAIL_TARGET_EVAL1(...) NATIVE_DETAIL_TARGET_EVAL0(NATIVE_DETAIL_TARGET_EVAL0(NATIVE_DETAIL_TARGET_EVAL0(__VA_ARGS__)))
80
#define NATIVE_DETAIL_TARGET_EVAL2(...) NATIVE_DETAIL_TARGET_EVAL1(NATIVE_DETAIL_TARGET_EVAL1(NATIVE_DETAIL_TARGET_EVAL1(__VA_ARGS__)))
81
#define NATIVE_DETAIL_TARGET_EVAL3(...) NATIVE_DETAIL_TARGET_EVAL2(NATIVE_DETAIL_TARGET_EVAL2(NATIVE_DETAIL_TARGET_EVAL2(__VA_ARGS__)))
82
#define NATIVE_DETAIL_TARGET_EVAL4(...) NATIVE_DETAIL_TARGET_EVAL3(NATIVE_DETAIL_TARGET_EVAL3(NATIVE_DETAIL_TARGET_EVAL3(__VA_ARGS__)))
83
#define NATIVE_DETAIL_TARGET_EVAL(...) NATIVE_DETAIL_TARGET_EVAL4(NATIVE_DETAIL_TARGET_EVAL4(NATIVE_DETAIL_TARGET_EVAL4(__VA_ARGS__)))
84
#define NATIVE_DETAIL_TARGET_MAP_END(...)
85
#define NATIVE_DETAIL_TARGET_MAP_OUT
86
#define NATIVE_DETAIL_TARGET_MAP_GET_END2() 0, NATIVE_DETAIL_TARGET_MAP_END
87
#define NATIVE_DETAIL_TARGET_MAP_GET_END1(...) NATIVE_DETAIL_TARGET_MAP_GET_END2
88
#define NATIVE_DETAIL_TARGET_MAP_GET_END(...) NATIVE_DETAIL_TARGET_MAP_GET_END1
89
#define NATIVE_DETAIL_TARGET_MAP_NEXT0(test, next, ...) next NATIVE_DETAIL_TARGET_MAP_OUT
90
#define NATIVE_DETAIL_TARGET_MAP_NEXT1(test, next) NATIVE_DETAIL_TARGET_MAP_NEXT0(test, next, 0)
91
#define NATIVE_DETAIL_TARGET_MAP_NEXT(test, next) NATIVE_DETAIL_TARGET_MAP_NEXT1(NATIVE_DETAIL_TARGET_MAP_GET_END test, next)
92
#define NATIVE_DETAIL_TARGET_MAP0(f,c,x,peek,...) f(c,x) NATIVE_DETAIL_TARGET_MAP_NEXT(peek,NATIVE_DETAIL_TARGET_MAP1)(f,c,peek,__VA_ARGS__)
93
#define NATIVE_DETAIL_TARGET_MAP1(f,c,x,peek,...) f(c,x) NATIVE_DETAIL_TARGET_MAP_NEXT(peek,NATIVE_DETAIL_TARGET_MAP0)(f,c,peek,__VA_ARGS__)
94
#define NATIVE_DETAIL_TARGET_MAP(f,c,...) __VA_OPT__(NATIVE_DETAIL_TARGET_EVAL(NATIVE_DETAIL_TARGET_MAP1(f,c,__VA_ARGS__,()()(),()()(),()()(),0)))
95
96
#define NATIVE_DETAIL_TARGET_UNPACK(...) __VA_ARGS__
97
#define NATIVE_DETAIL_TARGET_ISA_ARG(unused,tag) ,NATIVE_TARGET_ISA(tag)
98
99
// A list is a comma-separated sequence of registered target names:
100
// #define targets avx512,avx2
101
// body(name,ISA,...) receives the selected ISA followed by the full ISA pack.
102
// Use target<A,__VA_ARGS__> == target<ISA,__VA_ARGS__> for disjoint overloads.
103
// Keep local register types and instruction requirements within ISA, even when
104
// A carries more features. Definitions need normal C++ ODR rules.
105
// Expand the complete choice pack before mapping bodies, keeping the two uses
106
// of the mapper separate during preprocessor rescanning.
107
#define NATIVE_TARGET_VARIANTS(name,body,...) NATIVE_DETAIL_TARGET_VARIANTS(name,body,__VA_ARGS__)
108
#define NATIVE_DETAIL_TARGET_VARIANTS(name,body,...) \
109
NATIVE_DETAIL_TARGET_EMIT_ALL(name,body, \
110
(NATIVE_DETAIL_TARGET_MAP(NATIVE_DETAIL_TARGET_ISA_ARG,unused,__VA_ARGS__)),__VA_ARGS__)
111
#define NATIVE_DETAIL_TARGET_EMIT_ALL(name,body,choices,...) \
112
NATIVE_DETAIL_TARGET_MAP(NATIVE_DETAIL_TARGET_EMIT,(name,body,choices),__VA_ARGS__)
113
#define NATIVE_DETAIL_TARGET_EMIT(context,tag) \
114
NATIVE_DETAIL_TARGET_EMIT_EXPAND(tag,NATIVE_DETAIL_TARGET_UNPACK context)
115
#define NATIVE_DETAIL_TARGET_EMIT_EXPAND(...) NATIVE_DETAIL_TARGET_EMIT_IMPL(__VA_ARGS__)
116
#define NATIVE_DETAIL_TARGET_EMIT_IMPL(tag,name,body,choices) \
117
NATIVE_TARGET_PUSH(tag) \
118
NATIVE_DETAIL_TARGET_EMIT_BODY(body,name,NATIVE_TARGET_ISA(tag) NATIVE_DETAIL_TARGET_UNPACK choices) \
119
NATIVE_TARGET_POP()
120
#define NATIVE_DETAIL_TARGET_EMIT_BODY(body,...) body(__VA_ARGS__)
121
122
// Snapshot inherited translation-unit features separately from the requested
123
// ISA value. A target attribute adds features; it does not erase the project
124
// minimum. An unregistered stronger minimum is rejected instead of under-admitted.
125
#ifdef __MMX__
126
#define NATIVE_DETAIL_MIN_MMX (::native::isa<>(::native::x86_feature::mmx))
127
#else
128
#define NATIVE_DETAIL_MIN_MMX (::native::isa<>{})
129
#endif
130
#ifdef __SSE__
131
#define NATIVE_DETAIL_MIN_SSE (::native::isa<>(::native::x86_feature::sse))
132
#else
133
#define NATIVE_DETAIL_MIN_SSE (::native::isa<>{})
134
#endif
135
#ifdef __SSE2__
136
#define NATIVE_DETAIL_MIN_SSE2 (::native::isa<>(::native::x86_feature::sse2))
137
#else
138
#define NATIVE_DETAIL_MIN_SSE2 (::native::isa<>{})
139
#endif
140
#ifdef __SSE3__
141
#define NATIVE_DETAIL_MIN_SSE3 (::native::isa<>(::native::x86_feature::sse3))
142
#else
143
#define NATIVE_DETAIL_MIN_SSE3 (::native::isa<>{})
144
#endif
145
#ifdef __SSSE3__
146
#define NATIVE_DETAIL_MIN_SSSE3 (::native::isa<>(::native::x86_feature::ssse3))
147
#else
148
#define NATIVE_DETAIL_MIN_SSSE3 (::native::isa<>{})
149
#endif
150
#ifdef __SSE4_1__
151
#define NATIVE_DETAIL_MIN_SSE41 (::native::isa<>(::native::x86_feature::sse41))
152
#else
153
#define NATIVE_DETAIL_MIN_SSE41 (::native::isa<>{})
154
#endif
155
#ifdef __SSE4_2__
156
#define NATIVE_DETAIL_MIN_SSE42 (::native::isa<>(::native::x86_feature::sse42))
157
#else
158
#define NATIVE_DETAIL_MIN_SSE42 (::native::isa<>{})
159
#endif
160
#ifdef __POPCNT__
161
#define NATIVE_DETAIL_MIN_POPCNT (::native::isa<>(::native::x86_feature::popcnt))
162
#else
163
#define NATIVE_DETAIL_MIN_POPCNT (::native::isa<>{})
164
#endif
165
#ifdef __AVX__
166
#define NATIVE_DETAIL_MIN_AVX (::native::isa<>(::native::x86_feature::avx))
167
#else
168
#define NATIVE_DETAIL_MIN_AVX (::native::isa<>{})
169
#endif
170
#ifdef __AVX2__
171
#define NATIVE_DETAIL_MIN_AVX2 (::native::isa<>(::native::x86_feature::avx2))
172
#else
173
#define NATIVE_DETAIL_MIN_AVX2 (::native::isa<>{})
174
#endif
175
#ifdef __FMA__
176
#define NATIVE_DETAIL_MIN_FMA (::native::isa<>(::native::x86_feature::fma))
177
#else
178
#define NATIVE_DETAIL_MIN_FMA (::native::isa<>{})
179
#endif
180
#ifdef __F16C__
181
#define NATIVE_DETAIL_MIN_F16C (::native::isa<>(::native::x86_feature::f16c))
182
#else
183
#define NATIVE_DETAIL_MIN_F16C (::native::isa<>{})
184
#endif
185
#ifdef __BMI__
186
#define NATIVE_DETAIL_MIN_BMI1 (::native::isa<>(::native::x86_feature::bmi1))
187
#else
188
#define NATIVE_DETAIL_MIN_BMI1 (::native::isa<>{})
189
#endif
190
#ifdef __BMI2__
191
#define NATIVE_DETAIL_MIN_BMI2 (::native::isa<>(::native::x86_feature::bmi2))
192
#else
193
#define NATIVE_DETAIL_MIN_BMI2 (::native::isa<>{})
194
#endif
195
#ifdef __AVX512F__
196
#define NATIVE_DETAIL_MIN_AVX512F (::native::isa<>(::native::x86_feature::avx512f))
197
#else
198
#define NATIVE_DETAIL_MIN_AVX512F (::native::isa<>{})
199
#endif
200
#ifdef __AVX512DQ__
201
#define NATIVE_DETAIL_MIN_AVX512DQ (::native::isa<>(::native::x86_feature::avx512dq))
202
#else
203
#define NATIVE_DETAIL_MIN_AVX512DQ (::native::isa<>{})
204
#endif
205
#ifdef __AVX512BW__
206
#define NATIVE_DETAIL_MIN_AVX512BW (::native::isa<>(::native::x86_feature::avx512bw))
207
#else
208
#define NATIVE_DETAIL_MIN_AVX512BW (::native::isa<>{})
209
#endif
210
#ifdef __AVX512VL__
211
#define NATIVE_DETAIL_MIN_AVX512VL (::native::isa<>(::native::x86_feature::avx512vl))
212
#else
213
#define NATIVE_DETAIL_MIN_AVX512VL (::native::isa<>{})
214
#endif
215
#ifdef __AVX512BF16__
216
#define NATIVE_DETAIL_MIN_AVX512BF16 (::native::isa<>(::native::x86_feature::avx512bf16))
217
#else
218
#define NATIVE_DETAIL_MIN_AVX512BF16 (::native::isa<>{})
219
#endif
220
#ifdef __AVX512FP16__
221
#define NATIVE_DETAIL_MIN_AVX512FP16 (::native::isa<>(::native::x86_feature::avx512fp16))
222
#else
223
#define NATIVE_DETAIL_MIN_AVX512FP16 (::native::isa<>{})
224
#endif
225
#ifdef __AVX512VBMI__
226
#define NATIVE_DETAIL_MIN_AVX512VBMI (::native::isa<>(::native::x86_feature::avx512vbmi))
227
#else
228
#define NATIVE_DETAIL_MIN_AVX512VBMI (::native::isa<>{})
229
#endif
230
#ifdef __AVX512VBMI2__
231
#define NATIVE_DETAIL_MIN_AVX512VBMI2 (::native::isa<>(::native::x86_feature::avx512vbmi2))
232
#else
233
#define NATIVE_DETAIL_MIN_AVX512VBMI2 (::native::isa<>{})
234
#endif
235
#ifdef __AVX512BITALG__
236
#define NATIVE_DETAIL_MIN_AVX512BITALG (::native::isa<>(::native::x86_feature::avx512bitalg))
237
#else
238
#define NATIVE_DETAIL_MIN_AVX512BITALG (::native::isa<>{})
239
#endif
240
#ifdef __AVX512VPOPCNTDQ__
241
#define NATIVE_DETAIL_MIN_AVX512VPOPCNTDQ (::native::isa<>(::native::x86_feature::avx512vpopcntdq))
242
#else
243
#define NATIVE_DETAIL_MIN_AVX512VPOPCNTDQ (::native::isa<>{})
244
#endif
245
#ifdef __AVXVNNI__
246
#define NATIVE_DETAIL_MIN_AVXVNNI (::native::isa<>(::native::x86_feature::avxvnni))
247
#else
248
#define NATIVE_DETAIL_MIN_AVXVNNI (::native::isa<>{})
249
#endif
250
#ifdef __AVX512VNNI__
251
#define NATIVE_DETAIL_MIN_AVX512VNNI (::native::isa<>(::native::x86_feature::avx512vnni))
252
#else
253
#define NATIVE_DETAIL_MIN_AVX512VNNI (::native::isa<>{})
254
#endif
255
#ifdef __AVXVNNIINT8__
256
#define NATIVE_DETAIL_MIN_AVXVNNIINT8 (::native::isa<>(::native::x86_feature::avxvnniint8))
257
#else
258
#define NATIVE_DETAIL_MIN_AVXVNNIINT8 (::native::isa<>{})
259
#endif
260
#ifdef __AVXVNNIINT16__
261
#define NATIVE_DETAIL_MIN_AVXVNNIINT16 (::native::isa<>(::native::x86_feature::avxvnniint16))
262
#else
263
#define NATIVE_DETAIL_MIN_AVXVNNIINT16 (::native::isa<>{})
264
#endif
265
#ifdef __ARM_NEON
266
#define NATIVE_DETAIL_MIN_NEON (::native::isa<>(::native::arm_feature::neon))
267
#else
268
#define NATIVE_DETAIL_MIN_NEON (::native::isa<>{})
269
#endif
270
#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) || defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
271
#define NATIVE_DETAIL_MIN_NEON_FP16 (::native::isa<>(::native::arm_feature::neon_fp16))
272
#else
273
#define NATIVE_DETAIL_MIN_NEON_FP16 (::native::isa<>{})
274
#endif
275
#ifdef __ARM_FEATURE_BF16_VECTOR_ARITHMETIC
276
#define NATIVE_DETAIL_MIN_NEON_BF16 (::native::isa<>(::native::arm_feature::neon_bf16))
277
#else
278
#define NATIVE_DETAIL_MIN_NEON_BF16 (::native::isa<>{})
279
#endif
280
#ifdef __AVXIFMA__
281
#define NATIVE_DETAIL_MIN_AVXIFMA (::native::isa<>(::native::x86_feature::avxifma))
282
#else
283
#define NATIVE_DETAIL_MIN_AVXIFMA (::native::isa<>{})
284
#endif
285
#ifdef __SHA512__
286
#define NATIVE_DETAIL_MIN_X86_SHA512 (::native::isa<>(::native::x86_feature::sha512))
287
#else
288
#define NATIVE_DETAIL_MIN_X86_SHA512 (::native::isa<>{})
289
#endif
290
#ifdef __SM3__
291
#define NATIVE_DETAIL_MIN_X86_SM3 (::native::isa<>(::native::x86_feature::sm3))
292
#else
293
#define NATIVE_DETAIL_MIN_X86_SM3 (::native::isa<>{})
294
#endif
295
#ifdef __SM4__
296
#define NATIVE_DETAIL_MIN_X86_SM4 (::native::isa<>(::native::x86_feature::sm4))
297
#else
298
#define NATIVE_DETAIL_MIN_X86_SM4 (::native::isa<>{})
299
#endif
300
#ifdef __AVXNECONVERT__
301
#define NATIVE_DETAIL_MIN_X86_AVXNECONVERT (::native::isa<>(::native::x86_feature::avxneconvert))
302
#else
303
#define NATIVE_DETAIL_MIN_X86_AVXNECONVERT (::native::isa<>{})
304
#endif
305
#ifdef __ADX__
306
#define NATIVE_DETAIL_MIN_ADX (::native::isa<>(::native::x86_feature::adx))
307
#else
308
#define NATIVE_DETAIL_MIN_ADX (::native::isa<>{})
309
#endif
310
#ifdef __SHA__
311
#define NATIVE_DETAIL_MIN_SHA (::native::isa<>(::native::x86_feature::sha))
312
#else
313
#define NATIVE_DETAIL_MIN_SHA (::native::isa<>{})
314
#endif
315
#ifdef __VAES__
316
#define NATIVE_DETAIL_MIN_VAES (::native::isa<>(::native::x86_feature::vaes))
317
#else
318
#define NATIVE_DETAIL_MIN_VAES (::native::isa<>{})
319
#endif
320
#ifdef __AES__
321
#define NATIVE_DETAIL_MIN_AES (::native::isa<>(::native::x86_feature::aes))
322
#else
323
#define NATIVE_DETAIL_MIN_AES (::native::isa<>{})
324
#endif
325
#ifdef __VPCLMULQDQ__
326
#define NATIVE_DETAIL_MIN_VPCLMULQDQ (::native::isa<>(::native::x86_feature::vpclmulqdq))
327
#else
328
#define NATIVE_DETAIL_MIN_VPCLMULQDQ (::native::isa<>{})
329
#endif
330
#ifdef __PCLMUL__
331
#define NATIVE_DETAIL_MIN_PCLMUL (::native::isa<>(::native::x86_feature::pclmul))
332
#else
333
#define NATIVE_DETAIL_MIN_PCLMUL (::native::isa<>{})
334
#endif
335
#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) && (defined(__x86_64__) || defined(_M_X64))
336
#define NATIVE_DETAIL_MIN_CX16 (::native::isa<>(::native::x86_feature::cx16))
337
#else
338
#define NATIVE_DETAIL_MIN_CX16 (::native::isa<>{})
339
#endif
340
#ifdef __AVX512CD__
341
#define NATIVE_DETAIL_MIN_AVX512CD (::native::isa<>(::native::x86_feature::avx512cd))
342
#else
343
#define NATIVE_DETAIL_MIN_AVX512CD (::native::isa<>{})
344
#endif
345
#ifdef __AVX512IFMA__
346
#define NATIVE_DETAIL_MIN_AVX512IFMA (::native::isa<>(::native::x86_feature::avx512ifma))
347
#else
348
#define NATIVE_DETAIL_MIN_AVX512IFMA (::native::isa<>{})
349
#endif
350
351
#ifdef __LZCNT__
352
#define NATIVE_DETAIL_MIN_LZCNT (::native::isa<>(::native::x86_feature::lzcnt))
353
#else
354
#define NATIVE_DETAIL_MIN_LZCNT (::native::isa<>{})
355
#endif
356
#ifdef __MOVBE__
357
#define NATIVE_DETAIL_MIN_MOVBE (::native::isa<>(::native::x86_feature::movbe))
358
#else
359
#define NATIVE_DETAIL_MIN_MOVBE (::native::isa<>{})
360
#endif
361
#ifdef __LAHF_SAHF__
362
#define NATIVE_DETAIL_MIN_SAHF (::native::isa<>(::native::x86_feature::sahf))
363
#else
364
#define NATIVE_DETAIL_MIN_SAHF (::native::isa<>{})
365
#endif
366
#ifdef __MWAITX__
367
#define NATIVE_DETAIL_MIN_MWAITX (::native::isa<>(::native::x86_feature::mwaitx))
368
#else
369
#define NATIVE_DETAIL_MIN_MWAITX (::native::isa<>{})
370
#endif
371
#ifdef __WAITPKG__
372
#define NATIVE_DETAIL_MIN_WAITPKG (::native::isa<>(::native::x86_feature::waitpkg))
373
#else
374
#define NATIVE_DETAIL_MIN_WAITPKG (::native::isa<>{})
375
#endif
376
#ifdef __CRC32__
377
#define NATIVE_DETAIL_MIN_CRC32 (::native::isa<>(::native::x86_feature::crc32))
378
#else
379
#define NATIVE_DETAIL_MIN_CRC32 (::native::isa<>{})
380
#endif
381
#ifdef __GFNI__
382
#define NATIVE_DETAIL_MIN_GFNI (::native::isa<>(::native::x86_feature::gfni))
383
#else
384
#define NATIVE_DETAIL_MIN_GFNI (::native::isa<>{})
385
#endif
386
#ifdef __ARM_FEATURE_AES
387
#define NATIVE_DETAIL_MIN_ARM_AES (::native::arm_feature::aes&::native::arm_feature::pmull)
388
#else
389
#define NATIVE_DETAIL_MIN_ARM_AES (::native::isa<>{})
390
#endif
391
#ifdef __ARM_FEATURE_SHA2
392
#define NATIVE_DETAIL_MIN_ARM_SHA2 (::native::arm_feature::sha1&::native::arm_feature::sha2)
393
#else
394
#define NATIVE_DETAIL_MIN_ARM_SHA2 (::native::isa<>{})
395
#endif
396
#ifdef __ARM_FEATURE_SHA3
397
#define NATIVE_DETAIL_MIN_ARM_SHA3 (::native::isa<>(::native::arm_feature::sha3))
398
#else
399
#define NATIVE_DETAIL_MIN_ARM_SHA3 (::native::isa<>{})
400
#endif
401
#ifdef __ARM_FEATURE_SHA512
402
#define NATIVE_DETAIL_MIN_ARM_SHA512 (::native::arm_feature::sha1&::native::arm_feature::sha2&::native::arm_feature::sha512)
403
#else
404
#define NATIVE_DETAIL_MIN_ARM_SHA512 (::native::isa<>{})
405
#endif
406
#ifdef __ARM_FEATURE_SM3
407
#define NATIVE_DETAIL_MIN_ARM_SM3 (::native::isa<>(::native::arm_feature::sm3))
408
#else
409
#define NATIVE_DETAIL_MIN_ARM_SM3 (::native::isa<>{})
410
#endif
411
#ifdef __ARM_FEATURE_SM4
412
#define NATIVE_DETAIL_MIN_ARM_SM4 (::native::isa<>(::native::arm_feature::sm4))
413
#else
414
#define NATIVE_DETAIL_MIN_ARM_SM4 (::native::isa<>{})
415
#endif
416
#ifdef __ARM_FEATURE_CRC32
417
#define NATIVE_DETAIL_MIN_ARM_CRC (::native::isa<>(::native::arm_feature::crc))
418
#else
419
#define NATIVE_DETAIL_MIN_ARM_CRC (::native::isa<>{})
420
#endif
421
#ifdef __ARM_FEATURE_ATOMICS
422
#define NATIVE_DETAIL_MIN_ARM_LSE (::native::isa<>(::native::arm_feature::lse))
423
#else
424
#define NATIVE_DETAIL_MIN_ARM_LSE (::native::isa<>{})
425
#endif
426
#ifdef __ARM_FEATURE_QRDMX
427
#define NATIVE_DETAIL_MIN_ARM_RDM (::native::isa<>(::native::arm_feature::rdm))
428
#else
429
#define NATIVE_DETAIL_MIN_ARM_RDM (::native::isa<>{})
430
#endif
431
#ifdef __ARM_FEATURE_FP16_FML
432
#define NATIVE_DETAIL_MIN_ARM_FP16FML (::native::isa<>(::native::arm_feature::fp16fml))
433
#else
434
#define NATIVE_DETAIL_MIN_ARM_FP16FML (::native::isa<>{})
435
#endif
436
#ifdef __ARM_FEATURE_DOTPROD
437
#define NATIVE_DETAIL_MIN_ARM_DOTPROD (::native::isa<>(::native::arm_feature::dotprod))
438
#else
439
#define NATIVE_DETAIL_MIN_ARM_DOTPROD (::native::isa<>{})
440
#endif
441
#ifdef __ARM_FEATURE_COMPLEX
442
#define NATIVE_DETAIL_MIN_ARM_COMPLEX (::native::isa<>(::native::arm_feature::complxnum))
443
#else
444
#define NATIVE_DETAIL_MIN_ARM_COMPLEX (::native::isa<>{})
445
#endif
446
#ifdef __ARM_FEATURE_JCVT
447
#define NATIVE_DETAIL_MIN_ARM_JSCVT (::native::isa<>(::native::arm_feature::jsconv))
448
#else
449
#define NATIVE_DETAIL_MIN_ARM_JSCVT (::native::isa<>{})
450
#endif
451
#ifdef __ARM_FEATURE_RCPC
452
#define NATIVE_DETAIL_MIN_ARM_RCPC (::native::isa<>(::native::arm_feature::rcpc))
453
#else
454
#define NATIVE_DETAIL_MIN_ARM_RCPC (::native::isa<>{})
455
#endif
456
#ifdef __ARM_FEATURE_MATMUL_INT8
457
#define NATIVE_DETAIL_MIN_ARM_I8MM (::native::isa<>(::native::arm_feature::i8mm))
458
#else
459
#define NATIVE_DETAIL_MIN_ARM_I8MM (::native::isa<>{})
460
#endif
461
#ifdef __ARM_FEATURE_PAUTH
462
#define NATIVE_DETAIL_MIN_ARM_PAUTH (::native::isa<>(::native::arm_feature::pauth))
463
#else
464
#define NATIVE_DETAIL_MIN_ARM_PAUTH (::native::isa<>{})
465
#endif
466
467
#ifdef __wasm_simd128__
468
#define NATIVE_DETAIL_MIN_WASM_SIMD128 (::native::isa<>(::native::wasm_feature::simd128))
469
#else
470
#define NATIVE_DETAIL_MIN_WASM_SIMD128 (::native::isa<>{})
471
#endif
472
#ifdef __wasm_relaxed_simd__
473
#define NATIVE_DETAIL_MIN_WASM_RELAXED_SIMD (::native::isa<>(::native::wasm_feature::relaxed_simd))
474
#else
475
#define NATIVE_DETAIL_MIN_WASM_RELAXED_SIMD (::native::isa<>{})
476
#endif
477
478
#if defined(__SSE4A__) || defined(__XOP__) || defined(__FMA4__) || \
479
defined(__AVX512VP2INTERSECT__) || \
480
defined(__AMX_TILE__) || defined(__AMX_INT8__) || defined(__AMX_BF16__) || \
481
defined(__ARM_FEATURE_SVE) || defined(__ARM_FEATURE_SME)
482
#define NATIVE_DETAIL_MIN_UNREGISTERED (::native::target_features("unregistered"))
483
#else
484
#define NATIVE_DETAIL_MIN_UNREGISTERED (::native::isa<>{})
485
#endif
486
487
// Optional additional project contract. This is an ISA value/expression (for
488
// example ::native::target_features("avx2,f16c")), never a CPU-name guess. The ordinary
489
// executable's minimum remains a startup precondition: the selector itself must
490
// already be safe to run. Compiler CPU models can enable features not represented
491
// by predefines; this macro is not an inference engine for arbitrary -mcpu flags.
492
#ifndef NATIVE_TARGET_EXTRA_MINIMUM
493
#define NATIVE_TARGET_EXTRA_MINIMUM (::native::isa<>{})
494
#endif
495
// The current translation unit's known enabled instruction features. Clang has
496
// already resolved command-line implications and explicit negative flags. Do not
497
// apply feature_closure here: it could re-enable a deliberately disabled feature.
498
// This textual expression belongs to the consumer, not a precompiled module.
499
// Function target attributes and target pragmas do not change this snapshot.
500
#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
501
#define NATIVE_DETAIL_BASELINE_NEON_FP16 (::native::isa<>(::native::arm_feature::neon_fp16))
502
#else
503
#define NATIVE_DETAIL_BASELINE_NEON_FP16 (::native::isa<>{})
504
#endif
505
// Some architecture-version macros survive -mgeneral-regs-only. SIMD
506
// operations are available only when the vector register target is enabled.
507
#define NATIVE_DETAIL_MIN_ARM_SIMD_EXTRAS (NATIVE_DETAIL_MIN_NEON_BF16& \
508
NATIVE_DETAIL_MIN_ARM_AES&NATIVE_DETAIL_MIN_ARM_SHA2&NATIVE_DETAIL_MIN_ARM_SHA3&NATIVE_DETAIL_MIN_ARM_SHA512& \
509
NATIVE_DETAIL_MIN_ARM_SM3&NATIVE_DETAIL_MIN_ARM_SM4& \
510
NATIVE_DETAIL_MIN_ARM_RDM&NATIVE_DETAIL_MIN_ARM_FP16FML&NATIVE_DETAIL_MIN_ARM_DOTPROD& \
511
NATIVE_DETAIL_MIN_ARM_COMPLEX&NATIVE_DETAIL_MIN_ARM_I8MM)
512
#ifdef __ARM_NEON
513
#define NATIVE_DETAIL_BASELINE_ARM_SIMD_EXTRAS NATIVE_DETAIL_MIN_ARM_SIMD_EXTRAS
514
#else
515
#define NATIVE_DETAIL_BASELINE_ARM_SIMD_EXTRAS (::native::isa<>{})
516
#endif
517
#if defined(__ARM_FP) && (__ARM_FP & 8)
518
#define NATIVE_DETAIL_BASELINE_ARM_JSCVT NATIVE_DETAIL_MIN_ARM_JSCVT
519
#else
520
#define NATIVE_DETAIL_BASELINE_ARM_JSCVT (::native::isa<>{})
521
#endif
522
#define NATIVE_BASELINE (\
523
NATIVE_DETAIL_MIN_MMX&NATIVE_DETAIL_MIN_SSE&NATIVE_DETAIL_MIN_SSE2&NATIVE_DETAIL_MIN_SSE3& \
524
NATIVE_DETAIL_MIN_SSSE3&NATIVE_DETAIL_MIN_SSE41&NATIVE_DETAIL_MIN_SSE42&NATIVE_DETAIL_MIN_POPCNT& \
525
NATIVE_DETAIL_MIN_AVX&NATIVE_DETAIL_MIN_AVX2&NATIVE_DETAIL_MIN_FMA&NATIVE_DETAIL_MIN_F16C& \
526
NATIVE_DETAIL_MIN_BMI1&NATIVE_DETAIL_MIN_BMI2&NATIVE_DETAIL_MIN_AVX512F&NATIVE_DETAIL_MIN_AVX512DQ& \
527
NATIVE_DETAIL_MIN_AVX512BW&NATIVE_DETAIL_MIN_AVX512VL&NATIVE_DETAIL_MIN_AVX512BF16&NATIVE_DETAIL_MIN_AVX512FP16& \
528
NATIVE_DETAIL_MIN_AVX512VBMI&NATIVE_DETAIL_MIN_AVX512VBMI2& \
529
NATIVE_DETAIL_MIN_AVX512BITALG&NATIVE_DETAIL_MIN_AVX512VPOPCNTDQ& \
530
NATIVE_DETAIL_MIN_AVXVNNI&NATIVE_DETAIL_MIN_AVX512VNNI&NATIVE_DETAIL_MIN_AVXVNNIINT8&NATIVE_DETAIL_MIN_AVXVNNIINT16& \
531
NATIVE_DETAIL_MIN_NEON&NATIVE_DETAIL_BASELINE_NEON_FP16&NATIVE_DETAIL_BASELINE_ARM_SIMD_EXTRAS& \
532
NATIVE_DETAIL_MIN_AES&NATIVE_DETAIL_MIN_SHA&NATIVE_DETAIL_MIN_VAES&NATIVE_DETAIL_MIN_AVXIFMA&NATIVE_DETAIL_MIN_ADX&NATIVE_DETAIL_MIN_X86_SHA512&NATIVE_DETAIL_MIN_X86_SM3&NATIVE_DETAIL_MIN_X86_SM4&NATIVE_DETAIL_MIN_X86_AVXNECONVERT&NATIVE_DETAIL_MIN_PCLMUL&NATIVE_DETAIL_MIN_VPCLMULQDQ&NATIVE_DETAIL_MIN_CX16&NATIVE_DETAIL_MIN_AVX512CD& \
533
NATIVE_DETAIL_MIN_AVX512IFMA&NATIVE_DETAIL_MIN_LZCNT&NATIVE_DETAIL_MIN_MOVBE&NATIVE_DETAIL_MIN_SAHF& \
534
NATIVE_DETAIL_MIN_MWAITX&NATIVE_DETAIL_MIN_WAITPKG&NATIVE_DETAIL_MIN_CRC32&NATIVE_DETAIL_MIN_GFNI& \
535
NATIVE_DETAIL_MIN_ARM_CRC&NATIVE_DETAIL_MIN_ARM_LSE&NATIVE_DETAIL_BASELINE_ARM_JSCVT& \
536
NATIVE_DETAIL_MIN_ARM_RCPC&NATIVE_DETAIL_MIN_ARM_PAUTH& \
537
NATIVE_DETAIL_MIN_WASM_SIMD128&NATIVE_DETAIL_MIN_WASM_RELAXED_SIMD)
538
539
// Source-variant admission retains its conservative inherited minimum and any
540
// additional deployment requirements, separately from the exact known baseline.
541
#define NATIVE_TARGET_MINIMUM (::native::feature_closure(NATIVE_TARGET_EXTRA_MINIMUM& \
542
NATIVE_BASELINE&NATIVE_DETAIL_MIN_NEON_FP16&NATIVE_DETAIL_MIN_ARM_SIMD_EXTRAS& \
543
NATIVE_DETAIL_MIN_ARM_JSCVT&NATIVE_DETAIL_MIN_UNREGISTERED))
544
545
// Admission follows the same order as the compile-time choice pack.
546
#define NATIVE_DETAIL_TARGET_LIST(unused,tag) \
547
+::native::isa_list<::native::target_entry{NATIVE_TARGET_ISA(tag),NATIVE_TARGET_MINIMUM}>{}
548
#define NATIVE_TARGET_LIST(...) \
549
(::native::isa_list<>{} NATIVE_DETAIL_TARGET_MAP(NATIVE_DETAIL_TARGET_LIST,unused,__VA_ARGS__))
src
native
targets.h
Generated by
1.18.0