blob: 73eb4b9922cdabf83b35f5387fabedfaed92d834 [file] [log] [blame]
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001// Copyright (c) 2015 The Khronos Group Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a
4// copy of this software and/or associated documentation files (the
5// "Materials"), to deal in the Materials without restriction, including
6// without limitation the rights to use, copy, modify, merge, publish,
7// distribute, sublicense, and/or sell copies of the Materials, and to
8// permit persons to whom the Materials are furnished to do so, subject to
9// the following conditions:
10//
11// The above copyright notice and this permission notice shall be included
12// in all copies or substantial portions of the Materials.
13//
14// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
15// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
16// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
17// https://www.khronos.org/registry/
18//
19// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
26
27#include "operand.h"
28
29#include <assert.h>
30#include <string.h>
31
32static const spv_operand_desc_t sourceLanguageEntries[] = {
33 {"Unknown",
34 SourceLanguageUnknown,
35 SPV_OPCODE_FLAGS_NONE,
36 0,
37 {SPV_OPERAND_TYPE_NONE}},
38 {"ESSL",
39 SourceLanguageESSL,
40 SPV_OPCODE_FLAGS_NONE,
41 0,
42 {SPV_OPERAND_TYPE_NONE}},
43 {"GLSL",
44 SourceLanguageGLSL,
45 SPV_OPCODE_FLAGS_NONE,
46 0,
47 {SPV_OPERAND_TYPE_NONE}},
48 {"OpenCL",
49 SourceLanguageOpenCL,
50 SPV_OPCODE_FLAGS_NONE,
51 0,
52 {SPV_OPERAND_TYPE_NONE}},
53};
54
55static const spv_operand_desc_t executionModelEntries[] = {
56 {"Vertex",
57 ExecutionModelVertex,
58 SPV_OPCODE_FLAGS_CAPABILITIES,
59 CapabilityShader,
60 {SPV_OPERAND_TYPE_NONE}},
61 {"TessellationControl",
62 ExecutionModelTessellationControl,
63 SPV_OPCODE_FLAGS_CAPABILITIES,
64 CapabilityTessellation,
65 {SPV_OPERAND_TYPE_NONE}},
66 {"TessellationEvaluation",
67 ExecutionModelTessellationEvaluation,
68 SPV_OPCODE_FLAGS_CAPABILITIES,
69 CapabilityTessellation,
70 {SPV_OPERAND_TYPE_NONE}},
71 {"Geometry",
72 ExecutionModelGeometry,
73 SPV_OPCODE_FLAGS_CAPABILITIES,
74 CapabilityGeometry,
75 {SPV_OPERAND_TYPE_NONE}},
76 {"Fragment",
77 ExecutionModelFragment,
78 SPV_OPCODE_FLAGS_CAPABILITIES,
79 CapabilityShader,
80 {SPV_OPERAND_TYPE_NONE}},
81 {"GLCompute",
82 ExecutionModelGLCompute,
83 SPV_OPCODE_FLAGS_CAPABILITIES,
84 CapabilityShader,
85 {SPV_OPERAND_TYPE_NONE}},
86 {"Kernel",
87 ExecutionModelKernel,
88 SPV_OPCODE_FLAGS_CAPABILITIES,
89 CapabilityKernel,
90 {SPV_OPERAND_TYPE_NONE}},
91};
92
93static const spv_operand_desc_t addressingModelEntries[] = {
94 {"Logical",
95 AddressingModelLogical,
96 SPV_OPCODE_FLAGS_NONE,
97 0,
98 {SPV_OPERAND_TYPE_NONE}},
99 {"Physical32",
100 AddressingModelPhysical32,
101 SPV_OPCODE_FLAGS_CAPABILITIES,
102 CapabilityAddresses,
103 {SPV_OPERAND_TYPE_NONE}},
104 {"Physical64",
105 AddressingModelPhysical64,
106 SPV_OPCODE_FLAGS_CAPABILITIES,
107 CapabilityAddresses,
108 {SPV_OPERAND_TYPE_NONE}},
109};
110
111static const spv_operand_desc_t memoryModelEntries[] = {
112 {"Simple",
113 MemoryModelSimple,
114 SPV_OPCODE_FLAGS_CAPABILITIES,
115 CapabilityShader,
116 {SPV_OPERAND_TYPE_NONE}},
117 {"GLSL450",
118 MemoryModelGLSL450,
119 SPV_OPCODE_FLAGS_CAPABILITIES,
120 CapabilityShader,
121 {SPV_OPERAND_TYPE_NONE}},
122 {"OpenCL1.2",
123 MemoryModelOpenCL12,
124 SPV_OPCODE_FLAGS_CAPABILITIES,
125 CapabilityKernel,
126 {SPV_OPERAND_TYPE_NONE}},
127 {"OpenCL2.0",
128 MemoryModelOpenCL20,
129 SPV_OPCODE_FLAGS_CAPABILITIES,
130 CapabilityKernel,
131 {SPV_OPERAND_TYPE_NONE}},
132 {"OpenCL2.1",
133 MemoryModelOpenCL21,
134 SPV_OPCODE_FLAGS_CAPABILITIES,
135 CapabilityKernel,
136 {SPV_OPERAND_TYPE_NONE}},
137};
138
139static const spv_operand_desc_t executionModeEntries[] = {
140 {"Invocations",
141 ExecutionModeInvocations,
142 SPV_OPCODE_FLAGS_CAPABILITIES,
143 CapabilityGeometry,
144 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
145 {"SpacingEqual",
146 ExecutionModeSpacingEqual,
147 SPV_OPCODE_FLAGS_CAPABILITIES,
148 CapabilityTessellation,
149 {SPV_OPERAND_TYPE_NONE}},
150 {"SpacingFractionalEven",
151 ExecutionModeSpacingFractionalEven,
152 SPV_OPCODE_FLAGS_CAPABILITIES,
153 CapabilityTessellation,
154 {SPV_OPERAND_TYPE_NONE}},
155 {"SpacingFractionalOdd",
156 ExecutionModeSpacingFractionalOdd,
157 SPV_OPCODE_FLAGS_CAPABILITIES,
158 CapabilityTessellation,
159 {SPV_OPERAND_TYPE_NONE}},
160 {"VertexOrderCw",
161 ExecutionModeVertexOrderCw,
162 SPV_OPCODE_FLAGS_CAPABILITIES,
163 CapabilityTessellation,
164 {SPV_OPERAND_TYPE_NONE}},
165 {"VertexOrderCcw",
166 ExecutionModeVertexOrderCcw,
167 SPV_OPCODE_FLAGS_CAPABILITIES,
168 CapabilityTessellation,
169 {SPV_OPERAND_TYPE_NONE}},
170 {"PixelCenterInteger",
171 ExecutionModePixelCenterInteger,
172 SPV_OPCODE_FLAGS_CAPABILITIES,
173 CapabilityShader,
174 {SPV_OPERAND_TYPE_NONE}},
175 {"OriginUpperLeft",
176 ExecutionModeOriginUpperLeft,
177 SPV_OPCODE_FLAGS_CAPABILITIES,
178 CapabilityShader,
179 {SPV_OPERAND_TYPE_NONE}},
180 {"EarlyFragmentTests",
181 ExecutionModeEarlyFragmentTests,
182 SPV_OPCODE_FLAGS_CAPABILITIES,
183 CapabilityShader,
184 {SPV_OPERAND_TYPE_NONE}},
185 {"PointMode",
186 ExecutionModePointMode,
187 SPV_OPCODE_FLAGS_CAPABILITIES,
188 CapabilityTessellation,
189 {SPV_OPERAND_TYPE_NONE}},
190 {"Xfb",
191 ExecutionModeXfb,
192 SPV_OPCODE_FLAGS_CAPABILITIES,
193 CapabilityShader,
194 {SPV_OPERAND_TYPE_NONE}},
195 {"DepthReplacing",
196 ExecutionModeDepthReplacing,
197 SPV_OPCODE_FLAGS_CAPABILITIES,
198 CapabilityShader,
199 {SPV_OPERAND_TYPE_NONE}},
200 {"DepthAny",
201 ExecutionModeDepthAny,
202 SPV_OPCODE_FLAGS_CAPABILITIES,
203 CapabilityShader,
204 {SPV_OPERAND_TYPE_NONE}},
205 {"DepthGreater",
206 ExecutionModeDepthGreater,
207 SPV_OPCODE_FLAGS_CAPABILITIES,
208 CapabilityShader,
209 {SPV_OPERAND_TYPE_NONE}},
210 {"DepthLess",
211 ExecutionModeDepthLess,
212 SPV_OPCODE_FLAGS_CAPABILITIES,
213 CapabilityShader,
214 {SPV_OPERAND_TYPE_NONE}},
215 {"DepthUnchanged",
216 ExecutionModeDepthUnchanged,
217 SPV_OPCODE_FLAGS_CAPABILITIES,
218 CapabilityShader,
219 {SPV_OPERAND_TYPE_NONE}},
220 {"LocalSize",
221 ExecutionModeLocalSize,
222 SPV_OPCODE_FLAGS_NONE,
223 0,
224 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_LITERAL_NUMBER,
225 SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
226 {"LocalSizeHint",
227 ExecutionModeLocalSizeHint,
228 SPV_OPCODE_FLAGS_CAPABILITIES,
229 CapabilityKernel,
230 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_LITERAL_NUMBER,
231 SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
232 {"InputPoints",
233 ExecutionModeInputPoints,
234 SPV_OPCODE_FLAGS_CAPABILITIES,
235 CapabilityGeometry,
236 {SPV_OPERAND_TYPE_NONE}},
237 {"InputLines",
238 ExecutionModeInputLines,
239 SPV_OPCODE_FLAGS_CAPABILITIES,
240 CapabilityGeometry,
241 {SPV_OPERAND_TYPE_NONE}},
242 {"InputLinesAdjacency",
243 ExecutionModeInputLinesAdjacency,
244 SPV_OPCODE_FLAGS_CAPABILITIES,
245 CapabilityGeometry,
246 {SPV_OPERAND_TYPE_NONE}},
247 {"InputTriangles",
248 ExecutionModeInputTriangles,
249 SPV_OPCODE_FLAGS_CAPABILITIES,
250 CapabilityGeometry | CapabilityTessellation,
251 {SPV_OPERAND_TYPE_NONE}},
252 {"InputTrianglesAdjacency",
253 ExecutionModeInputTrianglesAdjacency,
254 SPV_OPCODE_FLAGS_CAPABILITIES,
255 CapabilityGeometry,
256 {SPV_OPERAND_TYPE_NONE}},
257 {"InputQuads",
258 ExecutionModeInputQuads,
259 SPV_OPCODE_FLAGS_CAPABILITIES,
260 CapabilityTessellation,
261 {SPV_OPERAND_TYPE_NONE}},
262 {"InputIsolines",
263 ExecutionModeInputIsolines,
264 SPV_OPCODE_FLAGS_CAPABILITIES,
265 CapabilityTessellation,
266 {SPV_OPERAND_TYPE_NONE}},
267 {"OutputVertices",
268 ExecutionModeOutputVertices,
269 SPV_OPCODE_FLAGS_CAPABILITIES,
270 CapabilityGeometry | CapabilityTessellation,
271 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
272 {"OutputPoints",
273 ExecutionModeOutputPoints,
274 SPV_OPCODE_FLAGS_CAPABILITIES,
275 CapabilityGeometry,
276 {SPV_OPERAND_TYPE_NONE}},
277 {"OutputLineStrip",
278 ExecutionModeOutputLineStrip,
279 SPV_OPCODE_FLAGS_CAPABILITIES,
280 CapabilityGeometry,
281 {SPV_OPERAND_TYPE_NONE}},
282 {"OutputTriangleStrip",
283 ExecutionModeOutputTriangleStrip,
284 SPV_OPCODE_FLAGS_CAPABILITIES,
285 CapabilityGeometry,
286 {SPV_OPERAND_TYPE_NONE}},
287 {"VecTypeHint",
288 ExecutionModeVecTypeHint,
289 SPV_OPCODE_FLAGS_CAPABILITIES,
290 CapabilityKernel,
291 {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_NONE}},
292 {"ContractionOff",
293 ExecutionModeContractionOff,
294 SPV_OPCODE_FLAGS_CAPABILITIES,
295 CapabilityKernel,
296 {SPV_OPERAND_TYPE_NONE}},
297 {
298 "OriginLowerLeft",
299 ExecutionModeOriginLowerLeft,
300 SPV_OPCODE_FLAGS_CAPABILITIES,
301 CapabilityShader,
302 {SPV_OPERAND_TYPE_NONE},
303 },
304};
305
306static const spv_operand_desc_t storageClassEntries[] = {
307 {"UniformConstant",
308 StorageClassUniformConstant,
309 SPV_OPCODE_FLAGS_NONE,
310 0,
311 {SPV_OPERAND_TYPE_NONE}},
312 {"Input",
313 StorageClassInput,
314 SPV_OPCODE_FLAGS_CAPABILITIES,
315 CapabilityShader,
316 {SPV_OPERAND_TYPE_NONE}},
317 {"Uniform",
318 StorageClassUniform,
319 SPV_OPCODE_FLAGS_CAPABILITIES,
320 CapabilityShader,
321 {SPV_OPERAND_TYPE_NONE}},
322 {"Output",
323 StorageClassOutput,
324 SPV_OPCODE_FLAGS_CAPABILITIES,
325 CapabilityShader,
326 {SPV_OPERAND_TYPE_NONE}},
327 {"WorkgroupLocal",
328 StorageClassWorkgroupLocal,
329 SPV_OPCODE_FLAGS_NONE,
330 0,
331 {SPV_OPERAND_TYPE_NONE}},
332 {"WorkgroupGlobal",
333 StorageClassWorkgroupGlobal,
334 SPV_OPCODE_FLAGS_NONE,
335 0,
336 {SPV_OPERAND_TYPE_NONE}},
337 {"PrivateGlobal",
338 StorageClassPrivateGlobal,
339 SPV_OPCODE_FLAGS_CAPABILITIES,
340 CapabilityShader,
341 {SPV_OPERAND_TYPE_NONE}},
342 {"Function",
343 StorageClassFunction,
344 SPV_OPCODE_FLAGS_NONE,
345 0,
346 {SPV_OPERAND_TYPE_NONE}},
347 {"Generic",
348 StorageClassGeneric,
349 SPV_OPCODE_FLAGS_CAPABILITIES,
350 CapabilityKernel,
351 {SPV_OPERAND_TYPE_NONE}},
352 {"AtomicCounter",
353 StorageClassAtomicCounter,
354 SPV_OPCODE_FLAGS_CAPABILITIES,
355 CapabilityShader,
356 {SPV_OPERAND_TYPE_NONE}},
357};
358
359static const spv_operand_desc_t dimensionalityEntries[] = {
360 {"1D", Dim1D, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}},
361 {"2D", Dim2D, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}},
362 {"3D", Dim3D, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}},
363 {"Cube",
364 DimCube,
365 SPV_OPCODE_FLAGS_CAPABILITIES,
366 CapabilityShader,
367 {SPV_OPERAND_TYPE_NONE}},
368 {"Rect",
369 DimRect,
370 SPV_OPCODE_FLAGS_CAPABILITIES,
371 CapabilityShader,
372 {SPV_OPERAND_TYPE_NONE}},
373 {"Buffer", DimBuffer, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}},
374};
375
376static const spv_operand_desc_t samplerAddressingModeEntries[] = {
377 {"None",
378 SamplerAddressingModeNone,
379 SPV_OPCODE_FLAGS_CAPABILITIES,
380 CapabilityKernel,
381 {SPV_OPERAND_TYPE_NONE}},
382 {"ClampToEdge",
383 SamplerAddressingModeClampToEdge,
384 SPV_OPCODE_FLAGS_CAPABILITIES,
385 CapabilityKernel,
386 {SPV_OPERAND_TYPE_NONE}},
387 {"Clamp",
388 SamplerAddressingModeClamp,
389 SPV_OPCODE_FLAGS_CAPABILITIES,
390 CapabilityKernel,
391 {SPV_OPERAND_TYPE_NONE}},
392 {"Repeat",
393 SamplerAddressingModeRepeat,
394 SPV_OPCODE_FLAGS_CAPABILITIES,
395 CapabilityKernel,
396 {SPV_OPERAND_TYPE_NONE}},
397 {"RepeatMirrored",
398 SamplerAddressingModeRepeatMirrored,
399 SPV_OPCODE_FLAGS_CAPABILITIES,
400 CapabilityKernel,
401 {SPV_OPERAND_TYPE_NONE}},
402};
403
404static const spv_operand_desc_t samplerFilterModeEntries[] = {
405 {"Nearest",
406 SamplerFilterModeNearest,
407 SPV_OPCODE_FLAGS_CAPABILITIES,
408 CapabilityKernel,
409 {SPV_OPERAND_TYPE_NONE}},
410 {"Linear",
411 SamplerFilterModeLinear,
412 SPV_OPCODE_FLAGS_CAPABILITIES,
413 CapabilityKernel,
414 {SPV_OPERAND_TYPE_NONE}},
415};
416
417static const spv_operand_desc_t fpFastMathModeEntries[] = {
418 {"None",
419 FPFastMathModeMaskNone,
420 SPV_OPCODE_FLAGS_NONE,
421 0,
422 {SPV_OPERAND_TYPE_NONE}},
423 {"NotNaN",
424 FPFastMathModeNotNaNMask,
425 SPV_OPCODE_FLAGS_CAPABILITIES,
426 CapabilityKernel,
427 {SPV_OPERAND_TYPE_NONE}},
428 {"NotInf",
429 FPFastMathModeNotInfMask,
430 SPV_OPCODE_FLAGS_CAPABILITIES,
431 CapabilityKernel,
432 {SPV_OPERAND_TYPE_NONE}},
433 {"NSZ",
434 FPFastMathModeNSZMask,
435 SPV_OPCODE_FLAGS_CAPABILITIES,
436 CapabilityKernel,
437 {SPV_OPERAND_TYPE_NONE}},
438 {"AllowRecip",
439 FPFastMathModeAllowRecipMask,
440 SPV_OPCODE_FLAGS_CAPABILITIES,
441 CapabilityKernel,
442 {SPV_OPERAND_TYPE_NONE}},
443 {"Fast",
444 FPFastMathModeFastMask,
445 SPV_OPCODE_FLAGS_CAPABILITIES,
446 CapabilityKernel,
447 {SPV_OPERAND_TYPE_NONE}},
448};
449
450static const spv_operand_desc_t fpRoundingModeEntries[] = {
451 {"RTE",
452 FPRoundingModeRTE,
453 SPV_OPCODE_FLAGS_CAPABILITIES,
454 CapabilityKernel,
455 {SPV_OPERAND_TYPE_NONE}},
456 {"RTZ",
457 FPRoundingModeRTZ,
458 SPV_OPCODE_FLAGS_CAPABILITIES,
459 CapabilityKernel,
460 {SPV_OPERAND_TYPE_NONE}},
461 {"RTP",
462 FPRoundingModeRTP,
463 SPV_OPCODE_FLAGS_CAPABILITIES,
464 CapabilityKernel,
465 {SPV_OPERAND_TYPE_NONE}},
466 {"RTN",
467 FPRoundingModeRTN,
468 SPV_OPCODE_FLAGS_CAPABILITIES,
469 CapabilityKernel,
470 {SPV_OPERAND_TYPE_NONE}},
471};
472
473static const spv_operand_desc_t linkageTypeEntries[] = {
474 {"Export",
475 LinkageTypeExport,
476 SPV_OPCODE_FLAGS_CAPABILITIES,
477 CapabilityLinkage,
478 {SPV_OPERAND_TYPE_NONE}},
479 {"Import",
480 LinkageTypeImport,
481 SPV_OPCODE_FLAGS_CAPABILITIES,
482 CapabilityLinkage,
483 {SPV_OPERAND_TYPE_NONE}},
484};
485
486static const spv_operand_desc_t accessQualifierEntries[] = {
487 {"ReadOnly",
488 AccessQualifierReadOnly,
489 SPV_OPCODE_FLAGS_CAPABILITIES,
490 CapabilityKernel,
491 {SPV_OPERAND_TYPE_NONE}},
492 {"WriteOnly",
493 AccessQualifierWriteOnly,
494 SPV_OPCODE_FLAGS_CAPABILITIES,
495 CapabilityKernel,
496 {SPV_OPERAND_TYPE_NONE}},
497 {"ReadWrite",
498 AccessQualifierReadWrite,
499 SPV_OPCODE_FLAGS_CAPABILITIES,
500 CapabilityKernel,
501 {SPV_OPERAND_TYPE_NONE}},
502};
503
504static const spv_operand_desc_t functionParameterAttributeEntries[] = {
505 {"Zext",
506 FunctionParameterAttributeZext,
507 SPV_OPCODE_FLAGS_CAPABILITIES,
508 CapabilityKernel,
509 {SPV_OPERAND_TYPE_NONE}},
510 {"Sext",
511 FunctionParameterAttributeSext,
512 SPV_OPCODE_FLAGS_CAPABILITIES,
513 CapabilityKernel,
514 {SPV_OPERAND_TYPE_NONE}},
515 {"ByVal",
516 FunctionParameterAttributeByVal,
517 SPV_OPCODE_FLAGS_CAPABILITIES,
518 CapabilityKernel,
519 {SPV_OPERAND_TYPE_NONE}},
520 {"Sret",
521 FunctionParameterAttributeSret,
522 SPV_OPCODE_FLAGS_CAPABILITIES,
523 CapabilityKernel,
524 {SPV_OPERAND_TYPE_NONE}},
525 {"NoAlias",
526 FunctionParameterAttributeNoAlias,
527 SPV_OPCODE_FLAGS_CAPABILITIES,
528 CapabilityKernel,
529 {SPV_OPERAND_TYPE_NONE}},
530 {"NoCapabilityture",
531 FunctionParameterAttributeNoCapture,
532 SPV_OPCODE_FLAGS_CAPABILITIES,
533 CapabilityKernel,
534 {SPV_OPERAND_TYPE_NONE}},
535 {"SVM",
536 FunctionParameterAttributeSVM,
537 SPV_OPCODE_FLAGS_CAPABILITIES,
538 CapabilityKernel,
539 {SPV_OPERAND_TYPE_NONE}},
540 {"NoWrite",
541 FunctionParameterAttributeNoWrite,
542 SPV_OPCODE_FLAGS_CAPABILITIES,
543 CapabilityKernel,
544 {SPV_OPERAND_TYPE_NONE}},
545 {"NoReadWrite",
546 FunctionParameterAttributeNoReadWrite,
547 SPV_OPCODE_FLAGS_CAPABILITIES,
548 CapabilityKernel,
549 {SPV_OPERAND_TYPE_NONE}},
550};
551
552static const spv_operand_desc_t decorationEntries[] = {
553 {"PrecisionLow",
554 DecorationPrecisionLow,
555 SPV_OPCODE_FLAGS_CAPABILITIES,
556 CapabilityShader,
557 {SPV_OPERAND_TYPE_NONE}},
558 {"PrecisionMedium",
559 DecorationPrecisionMedium,
560 SPV_OPCODE_FLAGS_CAPABILITIES,
561 CapabilityShader,
562 {SPV_OPERAND_TYPE_NONE}},
563 {"PrecisionHigh",
564 DecorationPrecisionHigh,
565 SPV_OPCODE_FLAGS_CAPABILITIES,
566 CapabilityShader,
567 {SPV_OPERAND_TYPE_NONE}},
568 {"Block",
569 DecorationBlock,
570 SPV_OPCODE_FLAGS_CAPABILITIES,
571 CapabilityShader,
572 {SPV_OPERAND_TYPE_NONE}},
573 {"BufferBlock",
574 DecorationBufferBlock,
575 SPV_OPCODE_FLAGS_CAPABILITIES,
576 CapabilityShader,
577 {SPV_OPERAND_TYPE_NONE}},
578 {"RowMajor",
579 DecorationRowMajor,
580 SPV_OPCODE_FLAGS_CAPABILITIES,
581 CapabilityMatrix,
582 {SPV_OPERAND_TYPE_NONE}},
583 {"ColMajor",
584 DecorationColMajor,
585 SPV_OPCODE_FLAGS_CAPABILITIES,
586 CapabilityMatrix,
587 {SPV_OPERAND_TYPE_NONE}},
588 {"GLSLShared",
589 DecorationGLSLShared,
590 SPV_OPCODE_FLAGS_CAPABILITIES,
591 CapabilityShader,
592 {SPV_OPERAND_TYPE_NONE}},
593 {"GLSLStd140",
594 DecorationGLSLStd140,
595 SPV_OPCODE_FLAGS_CAPABILITIES,
596 CapabilityShader,
597 {SPV_OPERAND_TYPE_NONE}},
598 {"GLSLStd430",
599 DecorationGLSLStd430,
600 SPV_OPCODE_FLAGS_CAPABILITIES,
601 CapabilityShader,
602 {SPV_OPERAND_TYPE_NONE}},
603 {"GLSLPacked",
604 DecorationGLSLPacked,
605 SPV_OPCODE_FLAGS_CAPABILITIES,
606 CapabilityShader,
607 {SPV_OPERAND_TYPE_NONE}},
608 {"Smooth",
609 DecorationSmooth,
610 SPV_OPCODE_FLAGS_CAPABILITIES,
611 CapabilityShader,
612 {SPV_OPERAND_TYPE_NONE}},
613 {"Noperspective",
614 DecorationNoperspective,
615 SPV_OPCODE_FLAGS_CAPABILITIES,
616 CapabilityShader,
617 {SPV_OPERAND_TYPE_NONE}},
618 {"Flat",
619 DecorationFlat,
620 SPV_OPCODE_FLAGS_CAPABILITIES,
621 CapabilityShader,
622 {SPV_OPERAND_TYPE_NONE}},
623 {"Patch",
624 DecorationPatch,
625 SPV_OPCODE_FLAGS_CAPABILITIES,
626 CapabilityTessellation,
627 {SPV_OPERAND_TYPE_NONE}},
628 {"Centroid",
629 DecorationCentroid,
630 SPV_OPCODE_FLAGS_CAPABILITIES,
631 CapabilityShader,
632 {SPV_OPERAND_TYPE_NONE}},
633 {"Sample",
634 DecorationSample,
635 SPV_OPCODE_FLAGS_CAPABILITIES,
636 CapabilityShader,
637 {SPV_OPERAND_TYPE_NONE}},
638 {"Invariant",
639 DecorationInvariant,
640 SPV_OPCODE_FLAGS_CAPABILITIES,
641 CapabilityShader,
642 {SPV_OPERAND_TYPE_NONE}},
643 {"Restrict",
644 DecorationRestrict,
645 SPV_OPCODE_FLAGS_NONE,
646 0,
647 {SPV_OPERAND_TYPE_NONE}},
648 {"Aliased",
649 DecorationAliased,
650 SPV_OPCODE_FLAGS_NONE,
651 0,
652 {SPV_OPERAND_TYPE_NONE}},
653 {"Volatile",
654 DecorationVolatile,
655 SPV_OPCODE_FLAGS_NONE,
656 0,
657 {SPV_OPERAND_TYPE_NONE}},
658 {"Constant",
659 DecorationConstant,
660 SPV_OPCODE_FLAGS_CAPABILITIES,
661 CapabilityKernel,
662 {SPV_OPERAND_TYPE_NONE}},
663 {"Coherent",
664 DecorationCoherent,
665 SPV_OPCODE_FLAGS_NONE,
666 0,
667 {SPV_OPERAND_TYPE_NONE}},
668 {"Nonwritable",
669 DecorationNonwritable,
670 SPV_OPCODE_FLAGS_NONE,
671 0,
672 {SPV_OPERAND_TYPE_NONE}},
673 {"Nonreadable",
674 DecorationNonreadable,
675 SPV_OPCODE_FLAGS_NONE,
676 0,
677 {SPV_OPERAND_TYPE_NONE}},
678 {"Uniform",
679 DecorationUniform,
680 SPV_OPCODE_FLAGS_CAPABILITIES,
681 CapabilityShader,
682 {SPV_OPERAND_TYPE_NONE}},
683 {"NoStaticUse",
684 DecorationNoStaticUse,
685 SPV_OPCODE_FLAGS_NONE,
686 0,
687 {SPV_OPERAND_TYPE_NONE}},
688 {"CPacked",
689 DecorationCPacked,
690 SPV_OPCODE_FLAGS_CAPABILITIES,
691 CapabilityKernel,
692 {SPV_OPERAND_TYPE_NONE}},
693 {"FPSaturatedConversion",
694 DecorationSaturatedConversion,
695 SPV_OPCODE_FLAGS_CAPABILITIES,
696 CapabilityKernel,
697 {SPV_OPERAND_TYPE_NONE}},
698 {"Stream",
699 DecorationStream,
700 SPV_OPCODE_FLAGS_CAPABILITIES,
701 CapabilityGeometry,
702 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
703 {"Location",
704 DecorationLocation,
705 SPV_OPCODE_FLAGS_CAPABILITIES,
706 CapabilityShader,
707 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
708 {"Component",
709 DecorationComponent,
710 SPV_OPCODE_FLAGS_CAPABILITIES,
711 CapabilityShader,
712 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
713 {"Index",
714 DecorationIndex,
715 SPV_OPCODE_FLAGS_CAPABILITIES,
716 CapabilityShader,
717 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
718 {"Binding",
719 DecorationBinding,
720 SPV_OPCODE_FLAGS_CAPABILITIES,
721 CapabilityShader,
722 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
723 {"DescriptorSet",
724 DecorationDescriptorSet,
725 SPV_OPCODE_FLAGS_CAPABILITIES,
726 CapabilityShader,
727 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
728 {"Offset",
729 DecorationOffset,
730 SPV_OPCODE_FLAGS_NONE,
731 0,
732 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
733 {"Alignment",
734 DecorationAlignment,
735 SPV_OPCODE_FLAGS_NONE,
736 0,
737 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
738 {"XfbBuffer",
739 DecorationXfbBuffer,
740 SPV_OPCODE_FLAGS_CAPABILITIES,
741 CapabilityShader,
742 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
743 {"Stride",
744 DecorationStride,
745 SPV_OPCODE_FLAGS_CAPABILITIES,
746 CapabilityShader,
747 {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}},
748 {"BuiltIn",
749 DecorationBuiltIn,
750 SPV_OPCODE_FLAGS_CAPABILITIES,
751 CapabilityShader,
752 {SPV_OPERAND_TYPE_BUILT_IN, SPV_OPERAND_TYPE_NONE}},
753 {"FuncParamAttr",
754 DecorationFuncParamAttr,
755 SPV_OPCODE_FLAGS_CAPABILITIES,
756 CapabilityKernel,
757 {SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE, SPV_OPERAND_TYPE_NONE}},
758 {"FPRoundingMode",
759 DecorationFPRoundingMode,
760 SPV_OPCODE_FLAGS_CAPABILITIES,
761 CapabilityKernel,
762 {SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_NONE}},
763 {"FPFastMathMode",
764 DecorationFPRoundingMode,
765 SPV_OPCODE_FLAGS_CAPABILITIES,
766 CapabilityKernel,
767 {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, SPV_OPERAND_TYPE_NONE}},
768 {"LinkageAttributes",
769 DecorationLinkageAttributes,
770 SPV_OPCODE_FLAGS_CAPABILITIES,
771 CapabilityLinkage,
772 {SPV_OPERAND_TYPE_LINKAGE_TYPE, SPV_OPERAND_TYPE_NONE}},
773 {
774 "SpecId",
775 DecorationSpecId,
776 SPV_OPCODE_FLAGS_CAPABILITIES,
777 CapabilityShader,
778 {SPV_OPERAND_TYPE_LITERAL_NUMBER},
779 },
780};
781
782static const spv_operand_desc_t builtInEntries[] = {
783 {"Position",
784 BuiltInPosition,
785 SPV_OPCODE_FLAGS_CAPABILITIES,
786 CapabilityShader,
787 {SPV_OPERAND_TYPE_NONE}},
788 {"PointSize",
789 BuiltInPointSize,
790 SPV_OPCODE_FLAGS_CAPABILITIES,
791 CapabilityShader,
792 {SPV_OPERAND_TYPE_NONE}},
793 {"ClipVertex",
794 BuiltInClipVertex,
795 SPV_OPCODE_FLAGS_CAPABILITIES,
796 CapabilityShader,
797 {SPV_OPERAND_TYPE_NONE}},
798 {"ClipDistance",
799 BuiltInClipDistance,
800 SPV_OPCODE_FLAGS_CAPABILITIES,
801 CapabilityShader,
802 {SPV_OPERAND_TYPE_NONE}},
803 {"CullDistance",
804 BuiltInCullDistance,
805 SPV_OPCODE_FLAGS_CAPABILITIES,
806 CapabilityShader,
807 {SPV_OPERAND_TYPE_NONE}},
808 {"VertexId",
809 BuiltInVertexId,
810 SPV_OPCODE_FLAGS_CAPABILITIES,
811 CapabilityShader,
812 {SPV_OPERAND_TYPE_NONE}},
813 {"InstanceId",
814 BuiltInInstanceId,
815 SPV_OPCODE_FLAGS_CAPABILITIES,
816 CapabilityShader,
817 {SPV_OPERAND_TYPE_NONE}},
818 {"PrimitiveId",
819 BuiltInPrimitiveId,
820 SPV_OPCODE_FLAGS_CAPABILITIES,
821 CapabilityGeometry | CapabilityTessellation,
822 {SPV_OPERAND_TYPE_NONE}},
823 {"InvocationId",
824 BuiltInInvocationId,
825 SPV_OPCODE_FLAGS_CAPABILITIES,
826 CapabilityGeometry | CapabilityTessellation,
827 {SPV_OPERAND_TYPE_NONE}},
828 {"Layer",
829 BuiltInLayer,
830 SPV_OPCODE_FLAGS_CAPABILITIES,
831 CapabilityGeometry,
832 {SPV_OPERAND_TYPE_NONE}},
833 {"ViewportIndex",
834 BuiltInViewportIndex,
835 SPV_OPCODE_FLAGS_CAPABILITIES,
836 CapabilityGeometry,
837 {SPV_OPERAND_TYPE_NONE}},
838 {"TessLevelOuter",
839 BuiltInTessLevelOuter,
840 SPV_OPCODE_FLAGS_CAPABILITIES,
841 CapabilityTessellation,
842 {SPV_OPERAND_TYPE_NONE}},
843 {"TessLevelInner",
844 BuiltInTessLevelInner,
845 SPV_OPCODE_FLAGS_CAPABILITIES,
846 CapabilityTessellation,
847 {SPV_OPERAND_TYPE_NONE}},
848 {"TessCoord",
849 BuiltInTessCoord,
850 SPV_OPCODE_FLAGS_CAPABILITIES,
851 CapabilityTessellation,
852 {SPV_OPERAND_TYPE_NONE}},
853 {"PatchVertices",
854 BuiltInPatchVertices,
855 SPV_OPCODE_FLAGS_CAPABILITIES,
856 CapabilityTessellation,
857 {SPV_OPERAND_TYPE_NONE}},
858 {"FragCoord",
859 BuiltInFragCoord,
860 SPV_OPCODE_FLAGS_CAPABILITIES,
861 CapabilityShader,
862 {SPV_OPERAND_TYPE_NONE}},
863 {"PointCoord",
864 BuiltInPointCoord,
865 SPV_OPCODE_FLAGS_CAPABILITIES,
866 CapabilityShader,
867 {SPV_OPERAND_TYPE_NONE}},
868 {"FrontFacing",
869 BuiltInFrontFacing,
870 SPV_OPCODE_FLAGS_CAPABILITIES,
871 CapabilityShader,
872 {SPV_OPERAND_TYPE_NONE}},
873 {"SampleId",
874 BuiltInSampleId,
875 SPV_OPCODE_FLAGS_CAPABILITIES,
876 CapabilityShader,
877 {SPV_OPERAND_TYPE_NONE}},
878 {"SamplePosition",
879 BuiltInSamplePosition,
880 SPV_OPCODE_FLAGS_CAPABILITIES,
881 CapabilityShader,
882 {SPV_OPERAND_TYPE_NONE}},
883 {"SampleMask",
884 BuiltInSampleMask,
885 SPV_OPCODE_FLAGS_CAPABILITIES,
886 CapabilityShader,
887 {SPV_OPERAND_TYPE_NONE}},
888 {"FragColor",
889 BuiltInFragColor,
890 SPV_OPCODE_FLAGS_CAPABILITIES,
891 CapabilityShader,
892 {SPV_OPERAND_TYPE_NONE}},
893 {"FragDepth",
894 BuiltInFragDepth,
895 SPV_OPCODE_FLAGS_CAPABILITIES,
896 CapabilityShader,
897 {SPV_OPERAND_TYPE_NONE}},
898 {"HelperInvocation",
899 BuiltInHelperInvocation,
900 SPV_OPCODE_FLAGS_CAPABILITIES,
901 CapabilityShader,
902 {SPV_OPERAND_TYPE_NONE}},
903 {"NumWorkgroups",
904 BuiltInNumWorkgroups,
905 SPV_OPCODE_FLAGS_NONE,
906 0,
907 {SPV_OPERAND_TYPE_NONE}},
908 {"WorkgroupSize",
909 BuiltInWorkgroupSize,
910 SPV_OPCODE_FLAGS_NONE,
911 0,
912 {SPV_OPERAND_TYPE_NONE}},
913 {"WorkgroupId",
914 BuiltInWorkgroupId,
915 SPV_OPCODE_FLAGS_NONE,
916 0,
917 {SPV_OPERAND_TYPE_NONE}},
918 {"LocalInvocationId",
919 BuiltInLocalInvocationId,
920 SPV_OPCODE_FLAGS_NONE,
921 0,
922 {SPV_OPERAND_TYPE_NONE}},
923 {"GlobalInvocationId",
924 BuiltInGlobalInvocationId,
925 SPV_OPCODE_FLAGS_NONE,
926 0,
927 {SPV_OPERAND_TYPE_NONE}},
928 {"LocalInvocationIndex",
929 BuiltInLocalInvocationId,
930 SPV_OPCODE_FLAGS_CAPABILITIES,
931 CapabilityShader,
932 {SPV_OPERAND_TYPE_NONE}},
933 {"WorkDim",
934 BuiltInWorkDim,
935 SPV_OPCODE_FLAGS_CAPABILITIES,
936 CapabilityKernel,
937 {SPV_OPERAND_TYPE_NONE}},
938 {"GlobalSize",
939 BuiltInGlobalSize,
940 SPV_OPCODE_FLAGS_CAPABILITIES,
941 CapabilityKernel,
942 {SPV_OPERAND_TYPE_NONE}},
943 {"EnqueuedWorkgroupSize",
944 BuiltInEnqueuedWorkgroupSize,
945 SPV_OPCODE_FLAGS_CAPABILITIES,
946 CapabilityKernel,
947 {SPV_OPERAND_TYPE_NONE}},
948 {"GlobalOffset",
949 BuiltInGlobalOffset,
950 SPV_OPCODE_FLAGS_CAPABILITIES,
951 CapabilityKernel,
952 {SPV_OPERAND_TYPE_NONE}},
953 {"GlobalLinearId",
954 BuiltInGlobalLinearId,
955 SPV_OPCODE_FLAGS_CAPABILITIES,
956 CapabilityKernel,
957 {SPV_OPERAND_TYPE_NONE}},
958 {"WorkgroupLinearId",
959 BuiltInWorkgroupLinearId,
960 SPV_OPCODE_FLAGS_CAPABILITIES,
961 CapabilityKernel,
962 {SPV_OPERAND_TYPE_NONE}},
963 {"SubgroupSize",
964 BuiltInSubgroupSize,
965 SPV_OPCODE_FLAGS_CAPABILITIES,
966 CapabilityKernel,
967 {SPV_OPERAND_TYPE_NONE}},
968 {"SubgroupMaxSize",
969 BuiltInSubgroupMaxSize,
970 SPV_OPCODE_FLAGS_CAPABILITIES,
971 CapabilityKernel,
972 {SPV_OPERAND_TYPE_NONE}},
973 {"NumSubgroups",
974 BuiltInNumSubgroups,
975 SPV_OPCODE_FLAGS_CAPABILITIES,
976 CapabilityKernel,
977 {SPV_OPERAND_TYPE_NONE}},
978 {"NumEnqueuedSubgroups",
979 BuiltInNumEnqueuedSubgroups,
980 SPV_OPCODE_FLAGS_CAPABILITIES,
981 CapabilityKernel,
982 {SPV_OPERAND_TYPE_NONE}},
983 {"SubgroupId",
984 BuiltInSampleId,
985 SPV_OPCODE_FLAGS_CAPABILITIES,
986 CapabilityKernel,
987 {SPV_OPERAND_TYPE_NONE}},
988 {"SubgroupLocalInvocationId",
989 BuiltInSubgroupLocalInvocationId,
990 SPV_OPCODE_FLAGS_CAPABILITIES,
991 CapabilityKernel,
992 {SPV_OPERAND_TYPE_NONE}},
993};
994
995static const spv_operand_desc_t selectionControlEntries[] = {
996 {"None",
997 SelectionControlMaskNone,
998 SPV_OPCODE_FLAGS_NONE,
999 0,
1000 {SPV_OPERAND_TYPE_NONE}},
1001 {"Flatten",
1002 SelectionControlFlattenMask,
1003 SPV_OPCODE_FLAGS_NONE,
1004 0,
1005 {SPV_OPERAND_TYPE_NONE}},
1006 {"DontFlatten",
1007 SelectionControlDontFlattenMask,
1008 SPV_OPCODE_FLAGS_NONE,
1009 0,
1010 {SPV_OPERAND_TYPE_NONE}},
1011};
1012
1013static const spv_operand_desc_t loopControlEntries[] = {
1014 {"None",
1015 LoopControlMaskNone,
1016 SPV_OPCODE_FLAGS_NONE,
1017 0,
1018 {SPV_OPERAND_TYPE_NONE}},
1019 {"Unroll",
1020 LoopControlUnrollMask,
1021 SPV_OPCODE_FLAGS_NONE,
1022 0,
1023 {SPV_OPERAND_TYPE_NONE}},
1024 {"DontUnroll",
1025 LoopControlDontUnrollMask,
1026 SPV_OPCODE_FLAGS_NONE,
1027 0,
1028 {SPV_OPERAND_TYPE_NONE}},
1029};
1030
1031static const spv_operand_desc_t functionControlEntries[] = {
1032 {"None",
1033 FunctionControlMaskNone,
1034 SPV_OPCODE_FLAGS_NONE,
1035 0,
1036 {SPV_OPERAND_TYPE_NONE}},
1037 {"InLine",
1038 FunctionControlInlineMask,
1039 SPV_OPCODE_FLAGS_NONE,
1040 0,
1041 {SPV_OPERAND_TYPE_NONE}},
1042 {"DontInline",
1043 FunctionControlDontInlineMask,
1044 SPV_OPCODE_FLAGS_NONE,
1045 0,
1046 {SPV_OPERAND_TYPE_NONE}},
1047 {"Pure",
1048 FunctionControlPureMask,
1049 SPV_OPCODE_FLAGS_NONE,
1050 0,
1051 {SPV_OPERAND_TYPE_NONE}},
1052 {"Const",
1053 FunctionControlConstMask,
1054 SPV_OPCODE_FLAGS_NONE,
1055 0,
1056 {SPV_OPERAND_TYPE_NONE}},
1057};
1058
1059static const spv_operand_desc_t memorySemanticsEntries[] = {
1060 {"None",
1061 MemorySemanticsMaskNone,
1062 SPV_OPCODE_FLAGS_NONE,
1063 0,
1064 {SPV_OPERAND_TYPE_NONE}},
1065 {"Relaxed",
1066 MemorySemanticsRelaxedMask,
1067 SPV_OPCODE_FLAGS_NONE,
1068 0,
1069 {SPV_OPERAND_TYPE_NONE}},
1070 {"SequentiallyConsistent",
1071 MemorySemanticsSequentiallyConsistentMask,
1072 SPV_OPCODE_FLAGS_NONE,
1073 0,
1074 {SPV_OPERAND_TYPE_NONE}},
1075 {"Acquire",
1076 MemorySemanticsAcquireMask,
1077 SPV_OPCODE_FLAGS_NONE,
1078 0,
1079 {SPV_OPERAND_TYPE_NONE}},
1080 {"Release",
1081 MemorySemanticsReleaseMask,
1082 SPV_OPCODE_FLAGS_NONE,
1083 0,
1084 {SPV_OPERAND_TYPE_NONE}},
1085 {"UniformMemory",
1086 MemorySemanticsUniformMemoryMask,
1087 SPV_OPCODE_FLAGS_CAPABILITIES,
1088 CapabilityShader,
1089 {SPV_OPERAND_TYPE_NONE}},
1090 {"SubgroupMemory",
1091 MemorySemanticsSubgroupMemoryMask,
1092 SPV_OPCODE_FLAGS_NONE,
1093 0,
1094 {SPV_OPERAND_TYPE_NONE}},
1095 {"WorkgroupLocalMemory",
1096 MemorySemanticsWorkgroupLocalMemoryMask,
1097 SPV_OPCODE_FLAGS_NONE,
1098 0,
1099 {SPV_OPERAND_TYPE_NONE}},
1100 {"WorkgroupGlobalMemory",
1101 MemorySemanticsWorkgroupGlobalMemoryMask,
1102 SPV_OPCODE_FLAGS_NONE,
1103 0,
1104 {SPV_OPERAND_TYPE_NONE}},
1105 {"AtomicCounterMemory",
1106 MemorySemanticsAtomicCounterMemoryMask,
1107 SPV_OPCODE_FLAGS_CAPABILITIES,
1108 CapabilityShader,
1109 {SPV_OPERAND_TYPE_NONE}},
1110 {
1111 "ImageMemory",
1112 MemorySemanticsImageMemoryMask,
1113 SPV_OPCODE_FLAGS_NONE,
1114 0,
1115 {SPV_OPERAND_TYPE_NONE},
1116 },
1117};
1118
1119static const spv_operand_desc_t memoryAccessEntries[] = {
1120 {"None",
1121 MemoryAccessMaskNone,
1122 SPV_OPCODE_FLAGS_NONE,
1123 0,
1124 {SPV_OPERAND_TYPE_NONE}},
1125 {"Volatile",
1126 MemoryAccessVolatileMask,
1127 SPV_OPCODE_FLAGS_NONE,
1128 0,
1129 {SPV_OPERAND_TYPE_NONE}},
1130 {
1131 "Aligned",
1132 MemoryAccessAlignedMask,
1133 SPV_OPCODE_FLAGS_NONE,
1134 0,
1135 {SPV_OPERAND_TYPE_NONE},
1136 },
1137};
1138
1139static const spv_operand_desc_t scopeEntries[] = {
1140 {"CrossDevice",
1141 ScopeCrossDevice,
1142 SPV_OPCODE_FLAGS_NONE,
1143 0,
1144 {SPV_OPERAND_TYPE_NONE}},
1145 {"Device", ScopeDevice, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}},
1146 {"Workgroup",
1147 ScopeWorkgroup,
1148 SPV_OPCODE_FLAGS_NONE,
1149 0,
1150 {SPV_OPERAND_TYPE_NONE}},
1151 {"Subgroup",
1152 ScopeSubgroup,
1153 SPV_OPCODE_FLAGS_NONE,
1154 0,
1155 {SPV_OPERAND_TYPE_NONE}},
1156 {
1157 "Invocation",
1158 ScopeInvocation,
1159 SPV_OPCODE_FLAGS_NONE,
1160 0,
1161 {SPV_OPERAND_TYPE_NONE},
1162 },
1163};
1164
1165static const spv_operand_desc_t groupOperationEntries[] = {
1166 {"Reduce",
1167 GroupOperationReduce,
1168 SPV_OPCODE_FLAGS_CAPABILITIES,
1169 CapabilityKernel,
1170 {SPV_OPERAND_TYPE_NONE}},
1171 {"InclusiveScan",
1172 GroupOperationInclusiveScan,
1173 SPV_OPCODE_FLAGS_CAPABILITIES,
1174 CapabilityKernel,
1175 {SPV_OPERAND_TYPE_NONE}},
1176 {"ExclusiveScan",
1177 GroupOperationExclusiveScan,
1178 SPV_OPCODE_FLAGS_CAPABILITIES,
1179 CapabilityKernel,
1180 {SPV_OPERAND_TYPE_NONE}},
1181};
1182
1183static const spv_operand_desc_t kernelKernelEnqueueFlagssEntries[] = {
1184 {"NoWait",
1185 KernelEnqueueFlagsNoWait,
1186 SPV_OPCODE_FLAGS_CAPABILITIES,
1187 CapabilityKernel,
1188 {SPV_OPERAND_TYPE_NONE}},
1189 {"WaitKernel",
1190 KernelEnqueueFlagsWaitKernel,
1191 SPV_OPCODE_FLAGS_CAPABILITIES,
1192 CapabilityKernel,
1193 {SPV_OPERAND_TYPE_NONE}},
1194 {"WaitWorkGroup",
1195 KernelEnqueueFlagsWaitWorkGroup,
1196 SPV_OPCODE_FLAGS_CAPABILITIES,
1197 CapabilityKernel,
1198 {SPV_OPERAND_TYPE_NONE}},
1199};
1200
1201static const spv_operand_desc_t kernelProfilingInfoEntries[] = {
1202 {"None",
1203 KernelProfilingInfoMaskNone,
1204 SPV_OPCODE_FLAGS_NONE,
1205 0,
1206 {SPV_OPERAND_TYPE_NONE}},
1207 {"CmdExecTime",
1208 KernelProfilingInfoCmdExecTimeMask,
1209 SPV_OPCODE_FLAGS_CAPABILITIES,
1210 CapabilityKernel,
1211 {SPV_OPERAND_TYPE_NONE}},
1212};
1213
1214static const spv_operand_desc_t capabilityInfoEntries[] = {
1215 {"Matrix",
1216 CapabilityMatrix,
1217 SPV_OPCODE_FLAGS_NONE,
1218 0,
1219 {SPV_OPERAND_TYPE_NONE}},
1220 {"Shader",
1221 CapabilityShader,
1222 SPV_OPCODE_FLAGS_CAPABILITIES,
1223 CapabilityMatrix,
1224 {SPV_OPERAND_TYPE_NONE}},
1225 {"Geometry",
1226 CapabilityGeometry,
1227 SPV_OPCODE_FLAGS_CAPABILITIES,
1228 CapabilityShader,
1229 {SPV_OPERAND_TYPE_NONE}},
1230 {"Tessellation",
1231 CapabilityTessellation,
1232 SPV_OPCODE_FLAGS_CAPABILITIES,
1233 CapabilityShader,
1234 {SPV_OPERAND_TYPE_NONE}},
1235 {"Addresses",
1236 CapabilityAddresses,
1237 SPV_OPCODE_FLAGS_NONE,
1238 0,
1239 {SPV_OPERAND_TYPE_NONE}},
1240 {"Linkage",
1241 CapabilityLinkage,
1242 SPV_OPCODE_FLAGS_NONE,
1243 0,
1244 {SPV_OPERAND_TYPE_NONE}},
1245 {"Kernel",
1246 CapabilityKernel,
1247 SPV_OPCODE_FLAGS_NONE,
1248 0,
1249 {SPV_OPERAND_TYPE_NONE}},
1250 {"Vector16",
1251 CapabilityVector16,
1252 SPV_OPCODE_FLAGS_NONE,
1253 0,
1254 {SPV_OPERAND_TYPE_NONE}},
1255 {"Float16Buffer",
1256 CapabilityFloat16Buffer,
1257 SPV_OPCODE_FLAGS_NONE,
1258 0,
1259 {SPV_OPERAND_TYPE_NONE}},
1260 {"Float16",
1261 CapabilityFloat16,
1262 SPV_OPCODE_FLAGS_NONE,
1263 0,
1264 {SPV_OPERAND_TYPE_NONE}},
1265 {"Float64",
1266 CapabilityFloat64,
1267 SPV_OPCODE_FLAGS_NONE,
1268 0,
1269 {SPV_OPERAND_TYPE_NONE}},
1270 {"Int64",
1271 CapabilityInt64,
1272 SPV_OPCODE_FLAGS_NONE,
1273 0,
1274 {SPV_OPERAND_TYPE_NONE}},
1275 {"Int64Atomics",
1276 CapabilityInt64Atomics,
1277 SPV_OPCODE_FLAGS_NONE,
1278 0,
1279 {SPV_OPERAND_TYPE_NONE}},
1280 {"ImageBasic",
1281 CapabilityImageBasic,
1282 SPV_OPCODE_FLAGS_NONE,
1283 0,
1284 {SPV_OPERAND_TYPE_NONE}},
1285 {"ImageReadWrite",
1286 CapabilityImageReadWrite,
1287 SPV_OPCODE_FLAGS_NONE,
1288 0,
1289 {SPV_OPERAND_TYPE_NONE}},
1290 {"ImageSRGBWrite",
1291 CapabilityImageSRGBWrite,
1292 SPV_OPCODE_FLAGS_NONE,
1293 0,
1294 {SPV_OPERAND_TYPE_NONE}},
1295 {"Pipes",
1296 CapabilityPipes,
1297 SPV_OPCODE_FLAGS_NONE,
1298 0,
1299 {SPV_OPERAND_TYPE_NONE}},
1300 {"Groups",
1301 CapabilityGroups,
1302 SPV_OPCODE_FLAGS_NONE,
1303 0,
1304 {SPV_OPERAND_TYPE_NONE}},
1305 {"DeviceEnqueue",
1306 CapabilityDeviceEnqueue,
1307 SPV_OPCODE_FLAGS_NONE,
1308 0,
1309 {SPV_OPERAND_TYPE_NONE}},
1310};
1311
1312static const spv_operand_desc_group_t opcodeEntryTypes[] = {
1313 {SPV_OPERAND_TYPE_SOURCE_LANGUAGE,
1314 sizeof(sourceLanguageEntries) / sizeof(spv_operand_desc_t),
1315 sourceLanguageEntries},
1316 {SPV_OPERAND_TYPE_EXECUTION_MODEL,
1317 sizeof(executionModelEntries) / sizeof(spv_operand_desc_t),
1318 executionModelEntries},
1319 {SPV_OPERAND_TYPE_ADDRESSING_MODEL,
1320 sizeof(addressingModelEntries) / sizeof(spv_operand_desc_t),
1321 addressingModelEntries},
1322 {SPV_OPERAND_TYPE_MEMORY_MODEL,
1323 sizeof(memoryModelEntries) / sizeof(spv_operand_desc_t),
1324 memoryModelEntries},
1325 {SPV_OPERAND_TYPE_EXECUTION_MODE,
1326 sizeof(executionModeEntries) / sizeof(spv_operand_desc_t),
1327 executionModeEntries},
1328 {SPV_OPERAND_TYPE_STORAGE_CLASS,
1329 sizeof(storageClassEntries) / sizeof(spv_operand_desc_t),
1330 storageClassEntries},
1331 {SPV_OPERAND_TYPE_DIMENSIONALITY,
1332 sizeof(dimensionalityEntries) / sizeof(spv_operand_desc_t),
1333 dimensionalityEntries},
1334 {SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE,
1335 sizeof(samplerAddressingModeEntries) / sizeof(spv_operand_desc_t),
1336 samplerAddressingModeEntries},
1337 {SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE,
1338 sizeof(samplerFilterModeEntries) / sizeof(spv_operand_desc_t),
1339 samplerFilterModeEntries},
1340 {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE,
1341 sizeof(fpFastMathModeEntries) / sizeof(spv_operand_desc_t),
1342 fpFastMathModeEntries},
1343 {SPV_OPERAND_TYPE_FP_ROUNDING_MODE,
1344 sizeof(fpRoundingModeEntries) / sizeof(spv_operand_desc_t),
1345 fpRoundingModeEntries},
1346 {SPV_OPERAND_TYPE_LINKAGE_TYPE,
1347 sizeof(linkageTypeEntries) / sizeof(spv_operand_desc_t),
1348 linkageTypeEntries},
1349 {SPV_OPERAND_TYPE_ACCESS_QUALIFIER,
1350 sizeof(accessQualifierEntries) / sizeof(spv_operand_desc_t),
1351 accessQualifierEntries},
1352 {SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE,
1353 sizeof(functionParameterAttributeEntries) / sizeof(spv_operand_desc_t),
1354 functionParameterAttributeEntries},
1355 {SPV_OPERAND_TYPE_DECORATION,
1356 sizeof(decorationEntries) / sizeof(spv_operand_desc_t), decorationEntries},
1357 {SPV_OPERAND_TYPE_BUILT_IN,
1358 sizeof(builtInEntries) / sizeof(spv_operand_desc_t), builtInEntries},
1359 {SPV_OPERAND_TYPE_SELECTION_CONTROL,
1360 sizeof(selectionControlEntries) / sizeof(spv_operand_desc_t),
1361 selectionControlEntries},
1362 {SPV_OPERAND_TYPE_LOOP_CONTROL,
1363 sizeof(loopControlEntries) / sizeof(spv_operand_desc_t),
1364 loopControlEntries},
1365 {SPV_OPERAND_TYPE_FUNCTION_CONTROL,
1366 sizeof(functionControlEntries) / sizeof(spv_operand_desc_t),
1367 functionControlEntries},
1368 {SPV_OPERAND_TYPE_MEMORY_SEMANTICS,
1369 sizeof(memorySemanticsEntries) / sizeof(spv_operand_desc_t),
1370 memorySemanticsEntries},
1371 {SPV_OPERAND_TYPE_MEMORY_ACCESS,
1372 sizeof(memoryAccessEntries) / sizeof(spv_operand_desc_t),
1373 memoryAccessEntries},
1374 {SPV_OPERAND_TYPE_EXECUTION_SCOPE,
1375 sizeof(scopeEntries) / sizeof(spv_operand_desc_t), scopeEntries},
1376 {SPV_OPERAND_TYPE_GROUP_OPERATION,
1377 sizeof(groupOperationEntries) / sizeof(spv_operand_desc_t),
1378 groupOperationEntries},
1379 {SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS,
1380 sizeof(kernelKernelEnqueueFlagssEntries) / sizeof(spv_operand_desc_t),
1381 kernelKernelEnqueueFlagssEntries},
1382 {SPV_OPERAND_TYPE_KERENL_PROFILING_INFO,
1383 sizeof(kernelProfilingInfoEntries) / sizeof(spv_operand_desc_t),
1384 kernelProfilingInfoEntries},
1385 {SPV_OPERAND_TYPE_CAPABILITY,
1386 sizeof(capabilityInfoEntries) / sizeof(spv_operand_desc_t),
1387 capabilityInfoEntries},
1388};
1389
1390spv_result_t spvOperandTableGet(spv_operand_table *pOperandTable) {
1391 spvCheck(!pOperandTable, return SPV_ERROR_INVALID_POINTER);
1392
1393 static const spv_operand_table_t table = {
1394 sizeof(opcodeEntryTypes) / sizeof(spv_operand_desc_group_t),
1395 opcodeEntryTypes};
1396
1397 *pOperandTable = &table;
1398
1399 return SPV_SUCCESS;
1400}
1401
1402spv_result_t spvOperandTableNameLookup(const spv_operand_table table,
1403 const spv_operand_type_t type,
1404 const char *name,
1405 spv_operand_desc *pEntry) {
1406 spvCheck(!table, return SPV_ERROR_INVALID_TABLE);
1407 spvCheck(!name || !pEntry, return SPV_ERROR_INVALID_POINTER);
1408
1409 const uint64_t nameLength = strlen(name);
1410 for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) {
1411 if (type == table->types[typeIndex].type) {
1412 for (uint64_t operandIndex = 0;
1413 operandIndex < table->types[typeIndex].count; ++operandIndex) {
1414 if (nameLength ==
1415 strlen(table->types[typeIndex].entries[operandIndex].name) &&
1416 !strncmp(table->types[typeIndex].entries[operandIndex].name, name,
1417 strlen(name))) {
1418 *pEntry = &table->types[typeIndex].entries[operandIndex];
1419 return SPV_SUCCESS;
1420 }
1421 }
1422 }
1423 }
1424
1425 return SPV_ERROR_INVALID_LOOKUP;
1426}
1427
1428spv_result_t spvOperandTableValueLookup(const spv_operand_table table,
1429 const spv_operand_type_t type,
1430 const uint32_t value,
1431 spv_operand_desc *pEntry) {
1432 spvCheck(!table, return SPV_ERROR_INVALID_TABLE);
1433 spvCheck(!pEntry, return SPV_ERROR_INVALID_POINTER);
1434
1435 for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) {
1436 if (type == table->types[typeIndex].type) {
1437 for (uint64_t operandIndex = 0;
1438 operandIndex < table->types[typeIndex].count; ++operandIndex) {
1439 if (value == table->types[typeIndex].entries[operandIndex].value) {
1440 *pEntry = &table->types[typeIndex].entries[operandIndex];
1441 return SPV_SUCCESS;
1442 }
1443 }
1444 }
1445 }
1446
1447 return SPV_ERROR_INVALID_LOOKUP;
1448}
1449
1450const char *spvOperandTypeStr(spv_operand_type_t type) {
1451 switch (type) {
1452 case SPV_OPERAND_TYPE_ID:
1453 return "id";
1454 case SPV_OPERAND_TYPE_RESULT_ID:
1455 return "result ID";
1456 case SPV_OPERAND_TYPE_LITERAL:
1457 return "literal";
1458 case SPV_OPERAND_TYPE_LITERAL_NUMBER:
1459 return "literal number";
1460 case SPV_OPERAND_TYPE_LITERAL_STRING:
1461 return "literal string";
1462 case SPV_OPERAND_TYPE_SOURCE_LANGUAGE:
1463 return "source langauge";
1464 case SPV_OPERAND_TYPE_EXECUTION_MODEL:
1465 return "execution model";
1466 case SPV_OPERAND_TYPE_ADDRESSING_MODEL:
1467 return "addressing model";
1468 case SPV_OPERAND_TYPE_MEMORY_MODEL:
1469 return "memory model";
1470 case SPV_OPERAND_TYPE_EXECUTION_MODE:
1471 return "execution mode";
1472 case SPV_OPERAND_TYPE_STORAGE_CLASS:
1473 return "storage class";
1474 case SPV_OPERAND_TYPE_DIMENSIONALITY:
1475 return "dimensionality";
1476 case SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE:
1477 return "addressing mode";
1478 case SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE:
1479 return "sampler filter mode";
1480 case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE:
1481 return "floating pointer fast math mode";
1482 case SPV_OPERAND_TYPE_FP_ROUNDING_MODE:
1483 return "floating point rounding mode";
1484 case SPV_OPERAND_TYPE_LINKAGE_TYPE:
1485 return "linkage type";
1486 case SPV_OPERAND_TYPE_ACCESS_QUALIFIER:
1487 return "access qualifier";
1488 case SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE:
1489 return "function parameter attribute";
1490 case SPV_OPERAND_TYPE_DECORATION:
1491 return "decoration";
1492 case SPV_OPERAND_TYPE_BUILT_IN:
1493 return "built in";
1494 case SPV_OPERAND_TYPE_SELECTION_CONTROL:
1495 return "selection control";
1496 case SPV_OPERAND_TYPE_LOOP_CONTROL:
1497 return "loop control";
1498 case SPV_OPERAND_TYPE_FUNCTION_CONTROL:
1499 return "function control";
1500 case SPV_OPERAND_TYPE_MEMORY_SEMANTICS:
1501 return "memory semantics";
1502 case SPV_OPERAND_TYPE_MEMORY_ACCESS:
1503 return "memory access";
1504 case SPV_OPERAND_TYPE_EXECUTION_SCOPE:
1505 return "execution scope";
1506 case SPV_OPERAND_TYPE_GROUP_OPERATION:
1507 return "group operation";
1508 case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS:
1509 return "kernel enqeue flags";
1510 case SPV_OPERAND_TYPE_KERENL_PROFILING_INFO:
1511 return "kernel profiling info";
1512 case SPV_OPERAND_TYPE_CAPABILITY:
1513 return "capability";
1514 default:
1515 assert(0 && "Unhandled operand type!");
1516 break;
1517 }
1518 return "unknown";
1519}