naga/back/msl/
keywords.rs

1use crate::proc::KeywordSet;
2use crate::racy_lock::RacyLock;
3
4// MSLS - Metal Shading Language Specification:
5// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
6//
7// C++ - Standard for Programming Language C++ (N4431)
8// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4431.pdf
9pub const RESERVED: &[&str] = &[
10    // Undocumented
11    "assert", // found in https://github.com/gfx-rs/wgpu/issues/5347
12    // Standard for Programming Language C++ (N4431): 2.5 Alternative tokens
13    "and",
14    "bitor",
15    "or",
16    "xor",
17    "compl",
18    "bitand",
19    "and_eq",
20    "or_eq",
21    "xor_eq",
22    "not",
23    "not_eq",
24    // Standard for Programming Language C++ (N4431): 2.11 Keywords
25    "alignas",
26    "alignof",
27    "asm",
28    "auto",
29    "bool",
30    "break",
31    "case",
32    "catch",
33    "char",
34    "char16_t",
35    "char32_t",
36    "class",
37    "const",
38    "constexpr",
39    "const_cast",
40    "continue",
41    "decltype",
42    "default",
43    "delete",
44    "do",
45    "double",
46    "dynamic_cast",
47    "else",
48    "enum",
49    "explicit",
50    "export",
51    "extern",
52    "false",
53    "float",
54    "for",
55    "friend",
56    "goto",
57    "if",
58    "inline",
59    "int",
60    "long",
61    "mutable",
62    "namespace",
63    "new",
64    "noexcept",
65    "nullptr",
66    "operator",
67    "private",
68    "protected",
69    "public",
70    "register",
71    "reinterpret_cast",
72    "return",
73    "short",
74    "signed",
75    "sizeof",
76    "static",
77    "static_assert",
78    "static_cast",
79    "struct",
80    "switch",
81    "template",
82    "this",
83    "thread_local",
84    "throw",
85    "true",
86    "try",
87    "typedef",
88    "typeid",
89    "typename",
90    "union",
91    "unsigned",
92    "using",
93    "virtual",
94    "void",
95    "volatile",
96    "wchar_t",
97    "while",
98    // Metal Shading Language Specification: 1.4.4 Restrictions
99    "main",
100    // Metal Shading Language Specification: 2.1 Scalar Data Types
101    "int8_t",
102    "uchar",
103    "uint8_t",
104    "int16_t",
105    "ushort",
106    "uint16_t",
107    "int32_t",
108    "uint",
109    "uint32_t",
110    "int64_t",
111    "uint64_t",
112    "half",
113    "bfloat",
114    "size_t",
115    "ptrdiff_t",
116    // Metal Shading Language Specification: 2.2 Vector Data Types
117    "bool2",
118    "bool3",
119    "bool4",
120    "char2",
121    "char3",
122    "char4",
123    "short2",
124    "short3",
125    "short4",
126    "int2",
127    "int3",
128    "int4",
129    "long2",
130    "long3",
131    "long4",
132    "uchar2",
133    "uchar3",
134    "uchar4",
135    "ushort2",
136    "ushort3",
137    "ushort4",
138    "uint2",
139    "uint3",
140    "uint4",
141    "ulong2",
142    "ulong3",
143    "ulong4",
144    "half2",
145    "half3",
146    "half4",
147    "bfloat2",
148    "bfloat3",
149    "bfloat4",
150    "float2",
151    "float3",
152    "float4",
153    "vec",
154    // Metal Shading Language Specification: 2.2.3 Packed Vector Types
155    "packed_bool2",
156    "packed_bool3",
157    "packed_bool4",
158    "packed_char2",
159    "packed_char3",
160    "packed_char4",
161    "packed_short2",
162    "packed_short3",
163    "packed_short4",
164    "packed_int2",
165    "packed_int3",
166    "packed_int4",
167    "packed_uchar2",
168    "packed_uchar3",
169    "packed_uchar4",
170    "packed_ushort2",
171    "packed_ushort3",
172    "packed_ushort4",
173    "packed_uint2",
174    "packed_uint3",
175    "packed_uint4",
176    "packed_half2",
177    "packed_half3",
178    "packed_half4",
179    "packed_bfloat2",
180    "packed_bfloat3",
181    "packed_bfloat4",
182    "packed_float2",
183    "packed_float3",
184    "packed_float4",
185    "packed_long2",
186    "packed_long3",
187    "packed_long4",
188    "packed_vec",
189    // Metal Shading Language Specification: 2.3 Matrix Data Types
190    "half2x2",
191    "half2x3",
192    "half2x4",
193    "half3x2",
194    "half3x3",
195    "half3x4",
196    "half4x2",
197    "half4x3",
198    "half4x4",
199    "float2x2",
200    "float2x3",
201    "float2x4",
202    "float3x2",
203    "float3x3",
204    "float3x4",
205    "float4x2",
206    "float4x3",
207    "float4x4",
208    "matrix",
209    // Metal Shading Language Specification: 2.6 Atomic Data Types
210    "atomic",
211    "atomic_int",
212    "atomic_uint",
213    "atomic_bool",
214    "atomic_ulong",
215    "atomic_float",
216    // Metal Shading Language Specification: 2.20 Type Conversions and Re-interpreting Data
217    "as_type",
218    // Metal Shading Language Specification: 4 Address Spaces
219    "device",
220    "constant",
221    "thread",
222    "threadgroup",
223    "threadgroup_imageblock",
224    "ray_data",
225    "object_data",
226    // Metal Shading Language Specification: 5.1 Functions
227    "vertex",
228    "fragment",
229    "kernel",
230    // Metal Shading Language Specification: 6.1 Namespace and Header Files
231    "metal",
232    // C99 / C++ extension:
233    "restrict",
234    // Metal reserved types in <metal_types>:
235    "llong",
236    "ullong",
237    "quad",
238    "complex",
239    "imaginary",
240    // Constants in <metal_types>:
241    "CHAR_BIT",
242    "SCHAR_MAX",
243    "SCHAR_MIN",
244    "UCHAR_MAX",
245    "CHAR_MAX",
246    "CHAR_MIN",
247    "USHRT_MAX",
248    "SHRT_MAX",
249    "SHRT_MIN",
250    "UINT_MAX",
251    "INT_MAX",
252    "INT_MIN",
253    "ULONG_MAX",
254    "LONG_MAX",
255    "LONG_MIN",
256    "ULLONG_MAX",
257    "LLONG_MAX",
258    "LLONG_MIN",
259    "FLT_DIG",
260    "FLT_MANT_DIG",
261    "FLT_MAX_10_EXP",
262    "FLT_MAX_EXP",
263    "FLT_MIN_10_EXP",
264    "FLT_MIN_EXP",
265    "FLT_RADIX",
266    "FLT_MAX",
267    "FLT_MIN",
268    "FLT_EPSILON",
269    "FLT_DECIMAL_DIG",
270    "FP_ILOGB0",
271    "FP_ILOGB0",
272    "FP_ILOGBNAN",
273    "FP_ILOGBNAN",
274    "MAXFLOAT",
275    "HUGE_VALF",
276    "INFINITY",
277    "NAN",
278    "M_E_F",
279    "M_LOG2E_F",
280    "M_LOG10E_F",
281    "M_LN2_F",
282    "M_LN10_F",
283    "M_PI_F",
284    "M_PI_2_F",
285    "M_PI_4_F",
286    "M_1_PI_F",
287    "M_2_PI_F",
288    "M_2_SQRTPI_F",
289    "M_SQRT2_F",
290    "M_SQRT1_2_F",
291    "HALF_DIG",
292    "HALF_MANT_DIG",
293    "HALF_MAX_10_EXP",
294    "HALF_MAX_EXP",
295    "HALF_MIN_10_EXP",
296    "HALF_MIN_EXP",
297    "HALF_RADIX",
298    "HALF_MAX",
299    "HALF_MIN",
300    "HALF_EPSILON",
301    "HALF_DECIMAL_DIG",
302    "MAXHALF",
303    "HUGE_VALH",
304    "M_E_H",
305    "M_LOG2E_H",
306    "M_LOG10E_H",
307    "M_LN2_H",
308    "M_LN10_H",
309    "M_PI_H",
310    "M_PI_2_H",
311    "M_PI_4_H",
312    "M_1_PI_H",
313    "M_2_PI_H",
314    "M_2_SQRTPI_H",
315    "M_SQRT2_H",
316    "M_SQRT1_2_H",
317    "DBL_DIG",
318    "DBL_MANT_DIG",
319    "DBL_MAX_10_EXP",
320    "DBL_MAX_EXP",
321    "DBL_MIN_10_EXP",
322    "DBL_MIN_EXP",
323    "DBL_RADIX",
324    "DBL_MAX",
325    "DBL_MIN",
326    "DBL_EPSILON",
327    "DBL_DECIMAL_DIG",
328    "MAXDOUBLE",
329    "HUGE_VAL",
330    "M_E",
331    "M_LOG2E",
332    "M_LOG10E",
333    "M_LN2",
334    "M_LN10",
335    "M_PI",
336    "M_PI_2",
337    "M_PI_4",
338    "M_1_PI",
339    "M_2_PI",
340    "M_2_SQRTPI",
341    "M_SQRT2",
342    "M_SQRT1_2",
343    // Naga utilities
344    "DefaultConstructible",
345    super::writer::FREXP_FUNCTION,
346    super::writer::MODF_FUNCTION,
347    super::writer::ABS_FUNCTION,
348    super::writer::DIV_FUNCTION,
349    super::writer::MOD_FUNCTION,
350    super::writer::NEG_FUNCTION,
351    super::writer::F2I32_FUNCTION,
352    super::writer::F2U32_FUNCTION,
353    super::writer::F2I64_FUNCTION,
354    super::writer::F2U64_FUNCTION,
355    super::writer::IMAGE_LOAD_EXTERNAL_FUNCTION,
356    super::writer::IMAGE_SAMPLE_BASE_CLAMP_TO_EDGE_FUNCTION,
357    super::writer::IMAGE_SIZE_EXTERNAL_FUNCTION,
358    super::writer::ARGUMENT_BUFFER_WRAPPER_STRUCT,
359    super::writer::EXTERNAL_TEXTURE_WRAPPER_STRUCT,
360];
361
362/// The above set of reserved keywords, turned into a cached HashSet. This saves
363/// significant time during [`Namer::reset`](crate::proc::Namer::reset).
364///
365/// See <https://github.com/gfx-rs/wgpu/pull/7338> for benchmarks.
366pub static RESERVED_SET: RacyLock<KeywordSet> = RacyLock::new(|| KeywordSet::from_iter(RESERVED));