blob: 8e7bea84baf2acb583f392a879eb03e145396c03 [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",
Lei Zhangb36e7042015-10-28 13:40:52 -040034 SpvSourceLanguageUnknown,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010035 0,
36 {SPV_OPERAND_TYPE_NONE}},
37 {"ESSL",
Lei Zhangb36e7042015-10-28 13:40:52 -040038 SpvSourceLanguageESSL,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010039 0,
40 {SPV_OPERAND_TYPE_NONE}},
41 {"GLSL",
Lei Zhangb36e7042015-10-28 13:40:52 -040042 SpvSourceLanguageGLSL,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010043 0,
44 {SPV_OPERAND_TYPE_NONE}},
45 {"OpenCL",
Lei Zhangb36e7042015-10-28 13:40:52 -040046 SpvSourceLanguageOpenCL,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010047 0,
48 {SPV_OPERAND_TYPE_NONE}},
49};
50
51static const spv_operand_desc_t executionModelEntries[] = {
52 {"Vertex",
Lei Zhangb36e7042015-10-28 13:40:52 -040053 SpvExecutionModelVertex,
54 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010055 {SPV_OPERAND_TYPE_NONE}},
56 {"TessellationControl",
Lei Zhangb36e7042015-10-28 13:40:52 -040057 SpvExecutionModelTessellationControl,
58 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010059 {SPV_OPERAND_TYPE_NONE}},
60 {"TessellationEvaluation",
Lei Zhangb36e7042015-10-28 13:40:52 -040061 SpvExecutionModelTessellationEvaluation,
62 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010063 {SPV_OPERAND_TYPE_NONE}},
64 {"Geometry",
Lei Zhangb36e7042015-10-28 13:40:52 -040065 SpvExecutionModelGeometry,
66 SPV_CAPABILITY_AS_MASK(SpvCapabilityGeometry),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010067 {SPV_OPERAND_TYPE_NONE}},
68 {"Fragment",
Lei Zhangb36e7042015-10-28 13:40:52 -040069 SpvExecutionModelFragment,
70 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010071 {SPV_OPERAND_TYPE_NONE}},
72 {"GLCompute",
Lei Zhangb36e7042015-10-28 13:40:52 -040073 SpvExecutionModelGLCompute,
74 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010075 {SPV_OPERAND_TYPE_NONE}},
76 {"Kernel",
Lei Zhangb36e7042015-10-28 13:40:52 -040077 SpvExecutionModelKernel,
78 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010079 {SPV_OPERAND_TYPE_NONE}},
80};
81
82static const spv_operand_desc_t addressingModelEntries[] = {
83 {"Logical",
Lei Zhangb36e7042015-10-28 13:40:52 -040084 SpvAddressingModelLogical,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010085 0,
86 {SPV_OPERAND_TYPE_NONE}},
87 {"Physical32",
Lei Zhangb36e7042015-10-28 13:40:52 -040088 SpvAddressingModelPhysical32,
89 SPV_CAPABILITY_AS_MASK(SpvCapabilityAddresses),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010090 {SPV_OPERAND_TYPE_NONE}},
91 {"Physical64",
Lei Zhangb36e7042015-10-28 13:40:52 -040092 SpvAddressingModelPhysical64,
93 SPV_CAPABILITY_AS_MASK(SpvCapabilityAddresses),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010094 {SPV_OPERAND_TYPE_NONE}},
95};
96
97static const spv_operand_desc_t memoryModelEntries[] = {
98 {"Simple",
Lei Zhangb36e7042015-10-28 13:40:52 -040099 SpvMemoryModelSimple,
100 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100101 {SPV_OPERAND_TYPE_NONE}},
102 {"GLSL450",
Lei Zhangb36e7042015-10-28 13:40:52 -0400103 SpvMemoryModelGLSL450,
104 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100105 {SPV_OPERAND_TYPE_NONE}},
Lei Zhang604e5ce2015-08-14 14:46:43 -0400106 {"OpenCL",
Lei Zhangb36e7042015-10-28 13:40:52 -0400107 SpvMemoryModelOpenCL,
108 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100109 {SPV_OPERAND_TYPE_NONE}},
110};
111
Lei Zhang85c6f792015-09-23 15:42:18 -0400112// Execution mode requiring the given capability and having no operands.
Lei Zhangb36e7042015-10-28 13:40:52 -0400113#define ExecMode0(mode, cap) \
114 #mode, SpvExecutionMode##mode, SPV_CAPABILITY_AS_MASK(SpvCapability##cap), { \
115 SPV_OPERAND_TYPE_NONE \
Lei Zhang85c6f792015-09-23 15:42:18 -0400116 }
117// Execution mode requiring the given capability and having one literal number
118// operand.
Lei Zhangb36e7042015-10-28 13:40:52 -0400119#define ExecMode1(mode, cap) \
120 #mode, SpvExecutionMode##mode, SPV_CAPABILITY_AS_MASK(SpvCapability##cap), { \
121 SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE \
Lei Zhang85c6f792015-09-23 15:42:18 -0400122 }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100123static const spv_operand_desc_t executionModeEntries[] = {
Lei Zhang85c6f792015-09-23 15:42:18 -0400124 {ExecMode1(Invocations, Geometry)},
125 {ExecMode0(SpacingEqual, Tessellation)},
126 {ExecMode0(SpacingFractionalEven, Tessellation)},
127 {ExecMode0(SpacingFractionalOdd, Tessellation)},
128 {ExecMode0(VertexOrderCw, Tessellation)},
129 {ExecMode0(VertexOrderCcw, Tessellation)},
130 {ExecMode0(PixelCenterInteger, Shader)},
131 {ExecMode0(OriginUpperLeft, Shader)},
132 {ExecMode0(OriginLowerLeft, Shader)},
133 {ExecMode0(EarlyFragmentTests, Shader)},
134 {ExecMode0(PointMode, Tessellation)},
Lei Zhang863ddbe2015-09-23 17:09:01 -0400135 {ExecMode0(Xfb, TransformFeedback)},
Lei Zhang85c6f792015-09-23 15:42:18 -0400136 {ExecMode0(DepthReplacing, Shader)},
Lei Zhang85c6f792015-09-23 15:42:18 -0400137 {ExecMode0(DepthGreater, Shader)},
138 {ExecMode0(DepthLess, Shader)},
139 {ExecMode0(DepthUnchanged, Shader)},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100140 {"LocalSize",
Lei Zhangb36e7042015-10-28 13:40:52 -0400141 SpvExecutionModeLocalSize,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100142 0,
Lei Zhang6483bd72015-10-14 17:02:39 -0400143 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_LITERAL_INTEGER,
144 SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100145 {"LocalSizeHint",
Lei Zhangb36e7042015-10-28 13:40:52 -0400146 SpvExecutionModeLocalSizeHint,
147 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Lei Zhang6483bd72015-10-14 17:02:39 -0400148 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_LITERAL_INTEGER,
149 SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Lei Zhang85c6f792015-09-23 15:42:18 -0400150 {ExecMode0(InputPoints, Geometry)},
151 {ExecMode0(InputLines, Geometry)},
152 {ExecMode0(InputLinesAdjacency, Geometry)},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100153 {"InputTriangles",
Lei Zhangb36e7042015-10-28 13:40:52 -0400154 SpvExecutionModeInputTriangles,
155 SPV_CAPABILITY_AS_MASK(SpvCapabilityGeometry) |
156 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100157 {SPV_OPERAND_TYPE_NONE}},
Lei Zhang85c6f792015-09-23 15:42:18 -0400158 {ExecMode0(InputTrianglesAdjacency, Geometry)},
159 {ExecMode0(InputQuads, Tessellation)},
160 {ExecMode0(InputIsolines, Tessellation)},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100161 {"OutputVertices",
Lei Zhangb36e7042015-10-28 13:40:52 -0400162 SpvExecutionModeOutputVertices,
163 SPV_CAPABILITY_AS_MASK(SpvCapabilityGeometry) |
164 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Lei Zhang6483bd72015-10-14 17:02:39 -0400165 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Lei Zhang85c6f792015-09-23 15:42:18 -0400166 {ExecMode0(OutputPoints, Geometry)},
167 {ExecMode0(OutputLineStrip, Geometry)},
168 {ExecMode0(OutputTriangleStrip, Geometry)},
169 {ExecMode1(VecTypeHint, Kernel)},
170 {ExecMode0(ContractionOff, Kernel)},
171 {ExecMode0(IndependentForwardProgress, Kernel)},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100172};
Lei Zhang85c6f792015-09-23 15:42:18 -0400173#undef ExecMode0
174#undef ExecMode1
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100175
176static const spv_operand_desc_t storageClassEntries[] = {
Dejan Mircevski50babb22015-09-29 10:56:32 -0400177 // TODO(dneto): There are more storage classes in Rev32 and later.
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100178 {"UniformConstant",
Lei Zhangb36e7042015-10-28 13:40:52 -0400179 SpvStorageClassUniformConstant,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100180 0,
181 {SPV_OPERAND_TYPE_NONE}},
182 {"Input",
Lei Zhangb36e7042015-10-28 13:40:52 -0400183 SpvStorageClassInput,
184 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100185 {SPV_OPERAND_TYPE_NONE}},
186 {"Uniform",
Lei Zhangb36e7042015-10-28 13:40:52 -0400187 SpvStorageClassUniform,
188 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100189 {SPV_OPERAND_TYPE_NONE}},
190 {"Output",
Lei Zhangb36e7042015-10-28 13:40:52 -0400191 SpvStorageClassOutput,
192 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100193 {SPV_OPERAND_TYPE_NONE}},
194 {"WorkgroupLocal",
Lei Zhangb36e7042015-10-28 13:40:52 -0400195 SpvStorageClassWorkgroupLocal,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100196 0,
197 {SPV_OPERAND_TYPE_NONE}},
198 {"WorkgroupGlobal",
Lei Zhangb36e7042015-10-28 13:40:52 -0400199 SpvStorageClassWorkgroupGlobal,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100200 0,
201 {SPV_OPERAND_TYPE_NONE}},
202 {"PrivateGlobal",
Lei Zhangb36e7042015-10-28 13:40:52 -0400203 SpvStorageClassPrivateGlobal,
204 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100205 {SPV_OPERAND_TYPE_NONE}},
206 {"Function",
Lei Zhangb36e7042015-10-28 13:40:52 -0400207 SpvStorageClassFunction,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100208 0,
209 {SPV_OPERAND_TYPE_NONE}},
210 {"Generic",
Lei Zhangb36e7042015-10-28 13:40:52 -0400211 SpvStorageClassGeneric,
212 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100213 {SPV_OPERAND_TYPE_NONE}},
David Neto9819adf2015-09-23 10:19:57 -0400214 {"PushConstant",
Lei Zhangb36e7042015-10-28 13:40:52 -0400215 SpvStorageClassPushConstant,
216 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
David Neto9819adf2015-09-23 10:19:57 -0400217 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100218 {"AtomicCounter",
Lei Zhangb36e7042015-10-28 13:40:52 -0400219 SpvStorageClassAtomicCounter,
220 SPV_CAPABILITY_AS_MASK(SpvCapabilityAtomicStorage),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100221 {SPV_OPERAND_TYPE_NONE}},
Lei Zhang604e5ce2015-08-14 14:46:43 -0400222 {"Image",
Lei Zhangb36e7042015-10-28 13:40:52 -0400223 SpvStorageClassImage,
Lei Zhang604e5ce2015-08-14 14:46:43 -0400224 0,
225 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100226};
227
228static const spv_operand_desc_t dimensionalityEntries[] = {
David Netoddda85a2015-10-02 17:10:10 -0400229 {"1D",
Lei Zhangb36e7042015-10-28 13:40:52 -0400230 SpvDim1D,
231 SPV_CAPABILITY_AS_MASK(SpvCapabilitySampled1D),
David Netoddda85a2015-10-02 17:10:10 -0400232 {SPV_OPERAND_TYPE_NONE}},
Lei Zhangb36e7042015-10-28 13:40:52 -0400233 {"2D", SpvDim2D, 0, {SPV_OPERAND_TYPE_NONE}},
234 {"3D", SpvDim3D, 0, {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100235 {"Cube",
Lei Zhangb36e7042015-10-28 13:40:52 -0400236 SpvDimCube,
237 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100238 {SPV_OPERAND_TYPE_NONE}},
239 {"Rect",
Lei Zhangb36e7042015-10-28 13:40:52 -0400240 SpvDimRect,
241 SPV_CAPABILITY_AS_MASK(SpvCapabilitySampledRect),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100242 {SPV_OPERAND_TYPE_NONE}},
David Netoddda85a2015-10-02 17:10:10 -0400243 {"Buffer",
Lei Zhangb36e7042015-10-28 13:40:52 -0400244 SpvDimBuffer,
245 SPV_CAPABILITY_AS_MASK(SpvCapabilitySampledBuffer),
David Netoddda85a2015-10-02 17:10:10 -0400246 {SPV_OPERAND_TYPE_NONE}},
David Netoaa0c3a52015-09-23 10:30:06 -0400247 {"InputTarget",
Lei Zhangb36e7042015-10-28 13:40:52 -0400248 SpvDimInputTarget,
249 SPV_CAPABILITY_AS_MASK(SpvCapabilityInputTarget),
David Netoaa0c3a52015-09-23 10:30:06 -0400250 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100251};
252
253static const spv_operand_desc_t samplerAddressingModeEntries[] = {
254 {"None",
Lei Zhangb36e7042015-10-28 13:40:52 -0400255 SpvSamplerAddressingModeNone,
256 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100257 {SPV_OPERAND_TYPE_NONE}},
258 {"ClampToEdge",
Lei Zhangb36e7042015-10-28 13:40:52 -0400259 SpvSamplerAddressingModeClampToEdge,
260 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100261 {SPV_OPERAND_TYPE_NONE}},
262 {"Clamp",
Lei Zhangb36e7042015-10-28 13:40:52 -0400263 SpvSamplerAddressingModeClamp,
264 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100265 {SPV_OPERAND_TYPE_NONE}},
266 {"Repeat",
Lei Zhangb36e7042015-10-28 13:40:52 -0400267 SpvSamplerAddressingModeRepeat,
268 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100269 {SPV_OPERAND_TYPE_NONE}},
270 {"RepeatMirrored",
Lei Zhangb36e7042015-10-28 13:40:52 -0400271 SpvSamplerAddressingModeRepeatMirrored,
272 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100273 {SPV_OPERAND_TYPE_NONE}},
274};
275
276static const spv_operand_desc_t samplerFilterModeEntries[] = {
277 {"Nearest",
Lei Zhangb36e7042015-10-28 13:40:52 -0400278 SpvSamplerFilterModeNearest,
279 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100280 {SPV_OPERAND_TYPE_NONE}},
281 {"Linear",
Lei Zhangb36e7042015-10-28 13:40:52 -0400282 SpvSamplerFilterModeLinear,
283 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100284 {SPV_OPERAND_TYPE_NONE}},
285};
286
David Netob30a0c52015-09-16 15:56:43 -0400287static const spv_operand_desc_t samplerImageFormatEntries[] = {
Lei Zhangb36e7042015-10-28 13:40:52 -0400288#define CASE0(NAME) \
289 { \
290 #NAME, SpvImageFormat##NAME, 0, { SPV_OPERAND_TYPE_NONE } \
David Netoddda85a2015-10-02 17:10:10 -0400291 }
Lei Zhangb36e7042015-10-28 13:40:52 -0400292#define CASE(NAME, CAP) \
293 { \
294 #NAME, SpvImageFormat##NAME, SPV_CAPABILITY_AS_MASK(SpvCapability##CAP), { \
295 SPV_OPERAND_TYPE_NONE \
296 } \
David Netob30a0c52015-09-16 15:56:43 -0400297 }
Dejan Mircevski50babb22015-09-29 10:56:32 -0400298 // clang-format off
David Netoddda85a2015-10-02 17:10:10 -0400299 CASE0(Unknown),
300 CASE(Rgba32f, Shader),
301 CASE(Rgba16f, Shader),
302 CASE(R32f, Shader),
303 CASE(Rgba8, Shader),
304 CASE(Rgba8Snorm, Shader),
305 CASE(Rg32f, AdvancedFormats),
306 CASE(Rg16f, AdvancedFormats),
307 CASE(R11fG11fB10f, AdvancedFormats),
308 CASE(R16f, AdvancedFormats),
309 CASE(Rgba16, AdvancedFormats),
310 CASE(Rgb10A2, AdvancedFormats),
311 CASE(Rg16, AdvancedFormats),
312 CASE(Rg8, AdvancedFormats),
313 CASE(R16, AdvancedFormats),
314 CASE(R8, AdvancedFormats),
315 CASE(Rgba16Snorm, AdvancedFormats),
316 CASE(Rg16Snorm, AdvancedFormats),
317 CASE(Rg8Snorm, AdvancedFormats),
318 CASE(R16Snorm, AdvancedFormats),
319 CASE(R8Snorm, AdvancedFormats),
320 CASE(Rgba32i, Shader),
321 CASE(Rgba16i, Shader),
322 CASE(Rgba8i, Shader),
323 CASE(R32i, Shader),
324 CASE(Rg32i, AdvancedFormats),
325 CASE(Rg16i, AdvancedFormats),
326 CASE(Rg8i, AdvancedFormats),
327 CASE(R16i, AdvancedFormats),
328 CASE(R8i, AdvancedFormats),
329 CASE(Rgba32ui, Shader),
330 CASE(Rgba16ui, Shader),
331 CASE(Rgba8ui, Shader),
332 CASE(R32ui, Shader),
333 CASE(Rgb10a2ui, AdvancedFormats),
334 CASE(Rg32ui, AdvancedFormats),
335 CASE(Rg16ui, AdvancedFormats),
336 CASE(Rg8ui, AdvancedFormats),
337 CASE(R16ui, AdvancedFormats),
338 CASE(R8ui, AdvancedFormats),
Dejan Mircevski50babb22015-09-29 10:56:32 -0400339// clang-format on
David Netob30a0c52015-09-16 15:56:43 -0400340#undef CASE
341};
342
David Netoddda85a2015-10-02 17:10:10 -0400343// All image channel orders depend on the Kernel capability.
David Neto9db3a532015-10-07 16:58:38 -0400344#define CASE(NAME) \
345 { \
Lei Zhangb36e7042015-10-28 13:40:52 -0400346 #NAME, SpvImageChannelOrder##NAME, SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel), \
David Neto9db3a532015-10-07 16:58:38 -0400347 { \
348 SPV_OPERAND_TYPE_NONE \
349 } \
David Netoddda85a2015-10-02 17:10:10 -0400350 }
351static const spv_operand_desc_t imageChannelOrderEntries[] = {
352 CASE(R),
353 CASE(A),
354 CASE(RG),
355 CASE(RA),
356 CASE(RGB),
357 CASE(RGBA),
358 CASE(BGRA),
359 CASE(ARGB),
360 CASE(Intensity),
361 CASE(Luminance),
362 CASE(Rx),
363 CASE(RGx),
364 CASE(RGBx),
365 CASE(Depth),
366 CASE(DepthStencil),
367 CASE(sRGB),
368 CASE(sRGBx),
369 CASE(sRGBA),
370 CASE(sBGRA),
371};
372#undef CASE
373
374// All image channel data types depend on the Kernel capability.
Lei Zhangb36e7042015-10-28 13:40:52 -0400375#define CASE(NAME) \
376 { \
377 #NAME, SpvImageChannelDataType##NAME, \
378 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel), { \
379 SPV_OPERAND_TYPE_NONE \
380 } \
David Netoddda85a2015-10-02 17:10:10 -0400381 }
382static const spv_operand_desc_t imageChannelDataTypeEntries[] = {
383 CASE(SnormInt8),
384 CASE(SnormInt16),
385 CASE(UnormInt8),
386 CASE(UnormInt16),
387 CASE(UnormShort565),
388 CASE(UnormShort555),
389 CASE(UnormInt101010),
390 CASE(SignedInt8),
391 CASE(SignedInt16),
392 CASE(SignedInt32),
393 CASE(UnsignedInt8),
394 CASE(UnsignedInt16),
395 CASE(UnsignedInt32),
396 CASE(HalfFloat),
397 CASE(Float),
398 CASE(UnormInt24),
399};
400#undef CASE
401
David Netoee1b3bb2015-09-18 11:19:18 -0400402// Image operand definitions. Each enum value is a mask. When that mask
403// bit is set, the instruction should have further ID operands.
404// Some mask values depend on a capability.
405static const spv_operand_desc_t imageOperandEntries[] = {
406// Rev32 and later adds many more enums.
407#define CASE(NAME) \
Lei Zhangb36e7042015-10-28 13:40:52 -0400408 #NAME, SpvImageOperands##NAME##Mask, 0
David Netoee1b3bb2015-09-18 11:19:18 -0400409#define CASE_CAP(NAME, CAP) \
Lei Zhangb36e7042015-10-28 13:40:52 -0400410 #NAME, SpvImageOperands##NAME##Mask, CAP
David Netoee1b3bb2015-09-18 11:19:18 -0400411#define ID SPV_OPERAND_TYPE_ID
412#define NONE SPV_OPERAND_TYPE_NONE
Lei Zhangb36e7042015-10-28 13:40:52 -0400413 {"None", SpvImageOperandsMaskNone, 0, {NONE}},
414 {CASE_CAP(Bias, SPV_CAPABILITY_AS_MASK(SpvCapabilityShader)), {ID, NONE}},
David Netoee1b3bb2015-09-18 11:19:18 -0400415 {CASE(Lod), {ID, NONE}},
416 {CASE(Grad), {ID, ID, NONE}},
417 {CASE(ConstOffset), {ID, NONE}},
Lei Zhangb36e7042015-10-28 13:40:52 -0400418 {CASE_CAP(Offset, SPV_CAPABILITY_AS_MASK(SpvCapabilityImageGatherExtended)),
Dejan Mircevski205408b2015-09-30 16:42:34 -0400419 {ID, NONE}},
David Netoee1b3bb2015-09-18 11:19:18 -0400420 {CASE(ConstOffsets), {ID, NONE}},
421 {CASE(Sample), {ID, NONE}},
Lei Zhangb36e7042015-10-28 13:40:52 -0400422 {CASE_CAP(MinLod, SPV_CAPABILITY_AS_MASK(SpvCapabilityMinLod)), {ID, NONE}},
David Netoee1b3bb2015-09-18 11:19:18 -0400423#undef CASE
424#undef CASE_CAP
425#undef ID
426#undef NONE
427};
428
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100429static const spv_operand_desc_t fpFastMathModeEntries[] = {
430 {"None",
Lei Zhangb36e7042015-10-28 13:40:52 -0400431 SpvFPFastMathModeMaskNone,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100432 0,
433 {SPV_OPERAND_TYPE_NONE}},
434 {"NotNaN",
Lei Zhangb36e7042015-10-28 13:40:52 -0400435 SpvFPFastMathModeNotNaNMask,
436 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100437 {SPV_OPERAND_TYPE_NONE}},
438 {"NotInf",
Lei Zhangb36e7042015-10-28 13:40:52 -0400439 SpvFPFastMathModeNotInfMask,
440 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100441 {SPV_OPERAND_TYPE_NONE}},
442 {"NSZ",
Lei Zhangb36e7042015-10-28 13:40:52 -0400443 SpvFPFastMathModeNSZMask,
444 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100445 {SPV_OPERAND_TYPE_NONE}},
446 {"AllowRecip",
Lei Zhangb36e7042015-10-28 13:40:52 -0400447 SpvFPFastMathModeAllowRecipMask,
448 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100449 {SPV_OPERAND_TYPE_NONE}},
450 {"Fast",
Lei Zhangb36e7042015-10-28 13:40:52 -0400451 SpvFPFastMathModeFastMask,
452 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100453 {SPV_OPERAND_TYPE_NONE}},
454};
455
456static const spv_operand_desc_t fpRoundingModeEntries[] = {
457 {"RTE",
Lei Zhangb36e7042015-10-28 13:40:52 -0400458 SpvFPRoundingModeRTE,
459 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100460 {SPV_OPERAND_TYPE_NONE}},
461 {"RTZ",
Lei Zhangb36e7042015-10-28 13:40:52 -0400462 SpvFPRoundingModeRTZ,
463 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100464 {SPV_OPERAND_TYPE_NONE}},
465 {"RTP",
Lei Zhangb36e7042015-10-28 13:40:52 -0400466 SpvFPRoundingModeRTP,
467 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100468 {SPV_OPERAND_TYPE_NONE}},
469 {"RTN",
Lei Zhangb36e7042015-10-28 13:40:52 -0400470 SpvFPRoundingModeRTN,
471 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100472 {SPV_OPERAND_TYPE_NONE}},
473};
474
475static const spv_operand_desc_t linkageTypeEntries[] = {
476 {"Export",
Lei Zhangb36e7042015-10-28 13:40:52 -0400477 SpvLinkageTypeExport,
478 SPV_CAPABILITY_AS_MASK(SpvCapabilityLinkage),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100479 {SPV_OPERAND_TYPE_NONE}},
480 {"Import",
Lei Zhangb36e7042015-10-28 13:40:52 -0400481 SpvLinkageTypeImport,
482 SPV_CAPABILITY_AS_MASK(SpvCapabilityLinkage),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100483 {SPV_OPERAND_TYPE_NONE}},
484};
485
486static const spv_operand_desc_t accessQualifierEntries[] = {
487 {"ReadOnly",
Lei Zhangb36e7042015-10-28 13:40:52 -0400488 SpvAccessQualifierReadOnly,
489 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100490 {SPV_OPERAND_TYPE_NONE}},
491 {"WriteOnly",
Lei Zhangb36e7042015-10-28 13:40:52 -0400492 SpvAccessQualifierWriteOnly,
493 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100494 {SPV_OPERAND_TYPE_NONE}},
495 {"ReadWrite",
Lei Zhangb36e7042015-10-28 13:40:52 -0400496 SpvAccessQualifierReadWrite,
497 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100498 {SPV_OPERAND_TYPE_NONE}},
499};
500
501static const spv_operand_desc_t functionParameterAttributeEntries[] = {
502 {"Zext",
Lei Zhangb36e7042015-10-28 13:40:52 -0400503 SpvFunctionParameterAttributeZext,
504 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100505 {SPV_OPERAND_TYPE_NONE}},
506 {"Sext",
Lei Zhangb36e7042015-10-28 13:40:52 -0400507 SpvFunctionParameterAttributeSext,
508 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100509 {SPV_OPERAND_TYPE_NONE}},
510 {"ByVal",
Lei Zhangb36e7042015-10-28 13:40:52 -0400511 SpvFunctionParameterAttributeByVal,
512 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100513 {SPV_OPERAND_TYPE_NONE}},
514 {"Sret",
Lei Zhangb36e7042015-10-28 13:40:52 -0400515 SpvFunctionParameterAttributeSret,
516 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100517 {SPV_OPERAND_TYPE_NONE}},
518 {"NoAlias",
Lei Zhangb36e7042015-10-28 13:40:52 -0400519 SpvFunctionParameterAttributeNoAlias,
520 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100521 {SPV_OPERAND_TYPE_NONE}},
David Neto37547b22015-09-10 13:23:11 -0400522 {"NoCapture",
Lei Zhangb36e7042015-10-28 13:40:52 -0400523 SpvFunctionParameterAttributeNoCapture,
524 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100525 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100526 {"NoWrite",
Lei Zhangb36e7042015-10-28 13:40:52 -0400527 SpvFunctionParameterAttributeNoWrite,
528 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100529 {SPV_OPERAND_TYPE_NONE}},
530 {"NoReadWrite",
Lei Zhangb36e7042015-10-28 13:40:52 -0400531 SpvFunctionParameterAttributeNoReadWrite,
532 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100533 {SPV_OPERAND_TYPE_NONE}},
534};
535
536static const spv_operand_desc_t decorationEntries[] = {
Lei Zhang604e5ce2015-08-14 14:46:43 -0400537 {"RelaxedPrecision",
Lei Zhangb36e7042015-10-28 13:40:52 -0400538 SpvDecorationRelaxedPrecision,
539 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100540 {SPV_OPERAND_TYPE_NONE}},
Lei Zhang604e5ce2015-08-14 14:46:43 -0400541 {
Dejan Mircevski50babb22015-09-29 10:56:32 -0400542 "SpecId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400543 SpvDecorationSpecId,
544 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang6483bd72015-10-14 17:02:39 -0400545 {SPV_OPERAND_TYPE_LITERAL_INTEGER},
Lei Zhang604e5ce2015-08-14 14:46:43 -0400546 },
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100547 {"Block",
Lei Zhangb36e7042015-10-28 13:40:52 -0400548 SpvDecorationBlock,
549 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100550 {SPV_OPERAND_TYPE_NONE}},
551 {"BufferBlock",
Lei Zhangb36e7042015-10-28 13:40:52 -0400552 SpvDecorationBufferBlock,
553 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100554 {SPV_OPERAND_TYPE_NONE}},
555 {"RowMajor",
Lei Zhangb36e7042015-10-28 13:40:52 -0400556 SpvDecorationRowMajor,
557 SPV_CAPABILITY_AS_MASK(SpvCapabilityMatrix),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100558 {SPV_OPERAND_TYPE_NONE}},
559 {"ColMajor",
Lei Zhangb36e7042015-10-28 13:40:52 -0400560 SpvDecorationColMajor,
561 SPV_CAPABILITY_AS_MASK(SpvCapabilityMatrix),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100562 {SPV_OPERAND_TYPE_NONE}},
Lei Zhang604e5ce2015-08-14 14:46:43 -0400563 {"ArrayStride",
Lei Zhangb36e7042015-10-28 13:40:52 -0400564 SpvDecorationArrayStride,
565 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang6483bd72015-10-14 17:02:39 -0400566 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Lei Zhang604e5ce2015-08-14 14:46:43 -0400567 {"MatrixStride",
Lei Zhangb36e7042015-10-28 13:40:52 -0400568 SpvDecorationMatrixStride,
569 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang6483bd72015-10-14 17:02:39 -0400570 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100571 {"GLSLShared",
Lei Zhangb36e7042015-10-28 13:40:52 -0400572 SpvDecorationGLSLShared,
573 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100574 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100575 {"GLSLPacked",
Lei Zhangb36e7042015-10-28 13:40:52 -0400576 SpvDecorationGLSLPacked,
577 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100578 {SPV_OPERAND_TYPE_NONE}},
Lei Zhang604e5ce2015-08-14 14:46:43 -0400579 {"CPacked",
Lei Zhangb36e7042015-10-28 13:40:52 -0400580 SpvDecorationCPacked,
581 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Lei Zhang604e5ce2015-08-14 14:46:43 -0400582 {SPV_OPERAND_TYPE_NONE}},
583 {"BuiltIn",
Lei Zhangb36e7042015-10-28 13:40:52 -0400584 SpvDecorationBuiltIn,
585 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang604e5ce2015-08-14 14:46:43 -0400586 {SPV_OPERAND_TYPE_BUILT_IN, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100587 {"Smooth",
Lei Zhangb36e7042015-10-28 13:40:52 -0400588 SpvDecorationSmooth,
589 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100590 {SPV_OPERAND_TYPE_NONE}},
David Netodbaf4072015-09-22 16:23:06 -0400591 {"NoPerspective",
Lei Zhangb36e7042015-10-28 13:40:52 -0400592 SpvDecorationNoPerspective,
593 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100594 {SPV_OPERAND_TYPE_NONE}},
595 {"Flat",
Lei Zhangb36e7042015-10-28 13:40:52 -0400596 SpvDecorationFlat,
597 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100598 {SPV_OPERAND_TYPE_NONE}},
599 {"Patch",
Lei Zhangb36e7042015-10-28 13:40:52 -0400600 SpvDecorationPatch,
601 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100602 {SPV_OPERAND_TYPE_NONE}},
603 {"Centroid",
Lei Zhangb36e7042015-10-28 13:40:52 -0400604 SpvDecorationCentroid,
605 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100606 {SPV_OPERAND_TYPE_NONE}},
607 {"Sample",
Lei Zhangb36e7042015-10-28 13:40:52 -0400608 SpvDecorationSample,
609 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100610 {SPV_OPERAND_TYPE_NONE}},
611 {"Invariant",
Lei Zhangb36e7042015-10-28 13:40:52 -0400612 SpvDecorationInvariant,
613 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100614 {SPV_OPERAND_TYPE_NONE}},
615 {"Restrict",
Lei Zhangb36e7042015-10-28 13:40:52 -0400616 SpvDecorationRestrict,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100617 0,
618 {SPV_OPERAND_TYPE_NONE}},
619 {"Aliased",
Lei Zhangb36e7042015-10-28 13:40:52 -0400620 SpvDecorationAliased,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100621 0,
622 {SPV_OPERAND_TYPE_NONE}},
623 {"Volatile",
Lei Zhangb36e7042015-10-28 13:40:52 -0400624 SpvDecorationVolatile,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100625 0,
626 {SPV_OPERAND_TYPE_NONE}},
627 {"Constant",
Lei Zhangb36e7042015-10-28 13:40:52 -0400628 SpvDecorationConstant,
629 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100630 {SPV_OPERAND_TYPE_NONE}},
631 {"Coherent",
Lei Zhangb36e7042015-10-28 13:40:52 -0400632 SpvDecorationCoherent,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100633 0,
634 {SPV_OPERAND_TYPE_NONE}},
David Netodbaf4072015-09-22 16:23:06 -0400635 {"NonWritable",
Lei Zhangb36e7042015-10-28 13:40:52 -0400636 SpvDecorationNonWritable,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100637 0,
638 {SPV_OPERAND_TYPE_NONE}},
David Netodbaf4072015-09-22 16:23:06 -0400639 {"NonReadable",
Lei Zhangb36e7042015-10-28 13:40:52 -0400640 SpvDecorationNonReadable,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100641 0,
642 {SPV_OPERAND_TYPE_NONE}},
643 {"Uniform",
Lei Zhangb36e7042015-10-28 13:40:52 -0400644 SpvDecorationUniform,
645 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100646 {SPV_OPERAND_TYPE_NONE}},
David Neto37547b22015-09-10 13:23:11 -0400647 {"SaturatedConversion",
Lei Zhangb36e7042015-10-28 13:40:52 -0400648 SpvDecorationSaturatedConversion,
649 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100650 {SPV_OPERAND_TYPE_NONE}},
651 {"Stream",
Lei Zhangb36e7042015-10-28 13:40:52 -0400652 SpvDecorationStream,
653 SPV_CAPABILITY_AS_MASK(SpvCapabilityGeometry),
Lei Zhang6483bd72015-10-14 17:02:39 -0400654 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100655 {"Location",
Lei Zhangb36e7042015-10-28 13:40:52 -0400656 SpvDecorationLocation,
657 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang6483bd72015-10-14 17:02:39 -0400658 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100659 {"Component",
Lei Zhangb36e7042015-10-28 13:40:52 -0400660 SpvDecorationComponent,
661 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang6483bd72015-10-14 17:02:39 -0400662 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100663 {"Index",
Lei Zhangb36e7042015-10-28 13:40:52 -0400664 SpvDecorationIndex,
665 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang6483bd72015-10-14 17:02:39 -0400666 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100667 {"Binding",
Lei Zhangb36e7042015-10-28 13:40:52 -0400668 SpvDecorationBinding,
669 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang6483bd72015-10-14 17:02:39 -0400670 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100671 {"DescriptorSet",
Lei Zhangb36e7042015-10-28 13:40:52 -0400672 SpvDecorationDescriptorSet,
673 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Lei Zhang6483bd72015-10-14 17:02:39 -0400674 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100675 {"Offset",
Lei Zhangb36e7042015-10-28 13:40:52 -0400676 SpvDecorationOffset,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100677 0,
Lei Zhang6483bd72015-10-14 17:02:39 -0400678 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100679 {"XfbBuffer",
Lei Zhangb36e7042015-10-28 13:40:52 -0400680 SpvDecorationXfbBuffer,
681 SPV_CAPABILITY_AS_MASK(SpvCapabilityTransformFeedback),
Lei Zhang6483bd72015-10-14 17:02:39 -0400682 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Lei Zhang604e5ce2015-08-14 14:46:43 -0400683 {"XfbStride",
Lei Zhangb36e7042015-10-28 13:40:52 -0400684 SpvDecorationXfbStride,
685 SPV_CAPABILITY_AS_MASK(SpvCapabilityTransformFeedback),
Lei Zhang6483bd72015-10-14 17:02:39 -0400686 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100687 {"FuncParamAttr",
Lei Zhangb36e7042015-10-28 13:40:52 -0400688 SpvDecorationFuncParamAttr,
689 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100690 {SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE, SPV_OPERAND_TYPE_NONE}},
691 {"FPRoundingMode",
Lei Zhangb36e7042015-10-28 13:40:52 -0400692 SpvDecorationFPRoundingMode,
693 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100694 {SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_NONE}},
695 {"FPFastMathMode",
Lei Zhangb36e7042015-10-28 13:40:52 -0400696 SpvDecorationFPFastMathMode,
697 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100698 {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, SPV_OPERAND_TYPE_NONE}},
699 {"LinkageAttributes",
Lei Zhangb36e7042015-10-28 13:40:52 -0400700 SpvDecorationLinkageAttributes,
701 SPV_CAPABILITY_AS_MASK(SpvCapabilityLinkage),
Dejan Mircevski50babb22015-09-29 10:56:32 -0400702 {SPV_OPERAND_TYPE_LITERAL_STRING, SPV_OPERAND_TYPE_LINKAGE_TYPE,
703 SPV_OPERAND_TYPE_NONE}},
David Netod7687982015-09-23 14:59:27 -0400704 {"NoContraction",
Lei Zhangb36e7042015-10-28 13:40:52 -0400705 SpvDecorationNoContraction,
706 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
David Netod7687982015-09-23 14:59:27 -0400707 {SPV_OPERAND_TYPE_NONE}},
708 {"InputTargetIndex",
Lei Zhangb36e7042015-10-28 13:40:52 -0400709 SpvDecorationInputTargetIndex,
710 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader), // TODO(dneto): Should this be
711 // SpvCapabilityInputTarget?
Dejan Mircevski50babb22015-09-29 10:56:32 -0400712 {SPV_OPERAND_TYPE_NONE}}, // TODO(dneto): Should this have a literal
713 // number argument?
David Netod7687982015-09-23 14:59:27 -0400714 {"Alignment",
Lei Zhangb36e7042015-10-28 13:40:52 -0400715 SpvDecorationAlignment,
716 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Lei Zhang6483bd72015-10-14 17:02:39 -0400717 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100718};
719
720static const spv_operand_desc_t builtInEntries[] = {
721 {"Position",
Lei Zhangb36e7042015-10-28 13:40:52 -0400722 SpvBuiltInPosition,
723 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100724 {SPV_OPERAND_TYPE_NONE}},
725 {"PointSize",
Lei Zhangb36e7042015-10-28 13:40:52 -0400726 SpvBuiltInPointSize,
727 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100728 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100729 {"ClipDistance",
Lei Zhangb36e7042015-10-28 13:40:52 -0400730 SpvBuiltInClipDistance,
731 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100732 {SPV_OPERAND_TYPE_NONE}},
733 {"CullDistance",
Lei Zhangb36e7042015-10-28 13:40:52 -0400734 SpvBuiltInCullDistance,
735 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100736 {SPV_OPERAND_TYPE_NONE}},
737 {"VertexId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400738 SpvBuiltInVertexId,
739 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100740 {SPV_OPERAND_TYPE_NONE}},
741 {"InstanceId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400742 SpvBuiltInInstanceId,
743 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100744 {SPV_OPERAND_TYPE_NONE}},
745 {"PrimitiveId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400746 SpvBuiltInPrimitiveId,
747 SPV_CAPABILITY_AS_MASK(SpvCapabilityGeometry) |
748 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100749 {SPV_OPERAND_TYPE_NONE}},
750 {"InvocationId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400751 SpvBuiltInInvocationId,
752 SPV_CAPABILITY_AS_MASK(SpvCapabilityGeometry) |
753 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100754 {SPV_OPERAND_TYPE_NONE}},
755 {"Layer",
Lei Zhangb36e7042015-10-28 13:40:52 -0400756 SpvBuiltInLayer,
757 SPV_CAPABILITY_AS_MASK(SpvCapabilityGeometry),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100758 {SPV_OPERAND_TYPE_NONE}},
759 {"ViewportIndex",
Lei Zhangb36e7042015-10-28 13:40:52 -0400760 SpvBuiltInViewportIndex,
761 SPV_CAPABILITY_AS_MASK(SpvCapabilityGeometry),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100762 {SPV_OPERAND_TYPE_NONE}},
763 {"TessLevelOuter",
Lei Zhangb36e7042015-10-28 13:40:52 -0400764 SpvBuiltInTessLevelOuter,
765 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100766 {SPV_OPERAND_TYPE_NONE}},
767 {"TessLevelInner",
Lei Zhangb36e7042015-10-28 13:40:52 -0400768 SpvBuiltInTessLevelInner,
769 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100770 {SPV_OPERAND_TYPE_NONE}},
771 {"TessCoord",
Lei Zhangb36e7042015-10-28 13:40:52 -0400772 SpvBuiltInTessCoord,
773 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100774 {SPV_OPERAND_TYPE_NONE}},
775 {"PatchVertices",
Lei Zhangb36e7042015-10-28 13:40:52 -0400776 SpvBuiltInPatchVertices,
777 SPV_CAPABILITY_AS_MASK(SpvCapabilityTessellation),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100778 {SPV_OPERAND_TYPE_NONE}},
779 {"FragCoord",
Lei Zhangb36e7042015-10-28 13:40:52 -0400780 SpvBuiltInFragCoord,
781 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100782 {SPV_OPERAND_TYPE_NONE}},
783 {"PointCoord",
Lei Zhangb36e7042015-10-28 13:40:52 -0400784 SpvBuiltInPointCoord,
785 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100786 {SPV_OPERAND_TYPE_NONE}},
787 {"FrontFacing",
Lei Zhangb36e7042015-10-28 13:40:52 -0400788 SpvBuiltInFrontFacing,
789 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100790 {SPV_OPERAND_TYPE_NONE}},
791 {"SampleId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400792 SpvBuiltInSampleId,
793 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100794 {SPV_OPERAND_TYPE_NONE}},
795 {"SamplePosition",
Lei Zhangb36e7042015-10-28 13:40:52 -0400796 SpvBuiltInSamplePosition,
797 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100798 {SPV_OPERAND_TYPE_NONE}},
799 {"SampleMask",
Lei Zhangb36e7042015-10-28 13:40:52 -0400800 SpvBuiltInSampleMask,
801 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100802 {SPV_OPERAND_TYPE_NONE}},
803 {"FragColor",
Lei Zhangb36e7042015-10-28 13:40:52 -0400804 SpvBuiltInFragColor,
805 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100806 {SPV_OPERAND_TYPE_NONE}},
807 {"FragDepth",
Lei Zhangb36e7042015-10-28 13:40:52 -0400808 SpvBuiltInFragDepth,
809 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100810 {SPV_OPERAND_TYPE_NONE}},
811 {"HelperInvocation",
Lei Zhangb36e7042015-10-28 13:40:52 -0400812 SpvBuiltInHelperInvocation,
813 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100814 {SPV_OPERAND_TYPE_NONE}},
815 {"NumWorkgroups",
Lei Zhangb36e7042015-10-28 13:40:52 -0400816 SpvBuiltInNumWorkgroups,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100817 0,
818 {SPV_OPERAND_TYPE_NONE}},
819 {"WorkgroupSize",
Lei Zhangb36e7042015-10-28 13:40:52 -0400820 SpvBuiltInWorkgroupSize,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100821 0,
822 {SPV_OPERAND_TYPE_NONE}},
823 {"WorkgroupId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400824 SpvBuiltInWorkgroupId,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100825 0,
826 {SPV_OPERAND_TYPE_NONE}},
827 {"LocalInvocationId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400828 SpvBuiltInLocalInvocationId,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100829 0,
830 {SPV_OPERAND_TYPE_NONE}},
831 {"GlobalInvocationId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400832 SpvBuiltInGlobalInvocationId,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100833 0,
834 {SPV_OPERAND_TYPE_NONE}},
835 {"LocalInvocationIndex",
Lei Zhangb36e7042015-10-28 13:40:52 -0400836 SpvBuiltInLocalInvocationIndex,
837 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100838 {SPV_OPERAND_TYPE_NONE}},
839 {"WorkDim",
Lei Zhangb36e7042015-10-28 13:40:52 -0400840 SpvBuiltInWorkDim,
841 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100842 {SPV_OPERAND_TYPE_NONE}},
843 {"GlobalSize",
Lei Zhangb36e7042015-10-28 13:40:52 -0400844 SpvBuiltInGlobalSize,
845 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100846 {SPV_OPERAND_TYPE_NONE}},
847 {"EnqueuedWorkgroupSize",
Lei Zhangb36e7042015-10-28 13:40:52 -0400848 SpvBuiltInEnqueuedWorkgroupSize,
849 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100850 {SPV_OPERAND_TYPE_NONE}},
851 {"GlobalOffset",
Lei Zhangb36e7042015-10-28 13:40:52 -0400852 SpvBuiltInGlobalOffset,
853 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100854 {SPV_OPERAND_TYPE_NONE}},
855 {"GlobalLinearId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400856 SpvBuiltInGlobalLinearId,
857 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100858 {SPV_OPERAND_TYPE_NONE}},
859 {"WorkgroupLinearId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400860 SpvBuiltInWorkgroupLinearId,
861 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100862 {SPV_OPERAND_TYPE_NONE}},
863 {"SubgroupSize",
Lei Zhangb36e7042015-10-28 13:40:52 -0400864 SpvBuiltInSubgroupSize,
865 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100866 {SPV_OPERAND_TYPE_NONE}},
867 {"SubgroupMaxSize",
Lei Zhangb36e7042015-10-28 13:40:52 -0400868 SpvBuiltInSubgroupMaxSize,
869 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100870 {SPV_OPERAND_TYPE_NONE}},
871 {"NumSubgroups",
Lei Zhangb36e7042015-10-28 13:40:52 -0400872 SpvBuiltInNumSubgroups,
873 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100874 {SPV_OPERAND_TYPE_NONE}},
875 {"NumEnqueuedSubgroups",
Lei Zhangb36e7042015-10-28 13:40:52 -0400876 SpvBuiltInNumEnqueuedSubgroups,
877 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100878 {SPV_OPERAND_TYPE_NONE}},
879 {"SubgroupId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400880 SpvBuiltInSubgroupId,
881 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100882 {SPV_OPERAND_TYPE_NONE}},
883 {"SubgroupLocalInvocationId",
Lei Zhangb36e7042015-10-28 13:40:52 -0400884 SpvBuiltInSubgroupLocalInvocationId,
885 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100886 {SPV_OPERAND_TYPE_NONE}},
David Neto2d1b5e52015-09-23 15:35:27 -0400887 {"VertexIndex",
Lei Zhangb36e7042015-10-28 13:40:52 -0400888 SpvBuiltInVertexIndex,
889 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
David Neto2d1b5e52015-09-23 15:35:27 -0400890 {SPV_OPERAND_TYPE_NONE}},
891 {"InstanceIndex",
Lei Zhangb36e7042015-10-28 13:40:52 -0400892 SpvBuiltInInstanceIndex,
893 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
David Neto2d1b5e52015-09-23 15:35:27 -0400894 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100895};
896
897static const spv_operand_desc_t selectionControlEntries[] = {
898 {"None",
Lei Zhangb36e7042015-10-28 13:40:52 -0400899 SpvSelectionControlMaskNone,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100900 0,
901 {SPV_OPERAND_TYPE_NONE}},
902 {"Flatten",
Lei Zhangb36e7042015-10-28 13:40:52 -0400903 SpvSelectionControlFlattenMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100904 0,
905 {SPV_OPERAND_TYPE_NONE}},
906 {"DontFlatten",
Lei Zhangb36e7042015-10-28 13:40:52 -0400907 SpvSelectionControlDontFlattenMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100908 0,
909 {SPV_OPERAND_TYPE_NONE}},
910};
911
912static const spv_operand_desc_t loopControlEntries[] = {
913 {"None",
Lei Zhangb36e7042015-10-28 13:40:52 -0400914 SpvLoopControlMaskNone,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100915 0,
916 {SPV_OPERAND_TYPE_NONE}},
917 {"Unroll",
Lei Zhangb36e7042015-10-28 13:40:52 -0400918 SpvLoopControlUnrollMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100919 0,
920 {SPV_OPERAND_TYPE_NONE}},
921 {"DontUnroll",
Lei Zhangb36e7042015-10-28 13:40:52 -0400922 SpvLoopControlDontUnrollMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100923 0,
924 {SPV_OPERAND_TYPE_NONE}},
925};
926
927static const spv_operand_desc_t functionControlEntries[] = {
928 {"None",
Lei Zhangb36e7042015-10-28 13:40:52 -0400929 SpvFunctionControlMaskNone,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100930 0,
931 {SPV_OPERAND_TYPE_NONE}},
David Netof4fde6c2015-09-14 14:50:37 -0400932 {"Inline",
Lei Zhangb36e7042015-10-28 13:40:52 -0400933 SpvFunctionControlInlineMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100934 0,
935 {SPV_OPERAND_TYPE_NONE}},
936 {"DontInline",
Lei Zhangb36e7042015-10-28 13:40:52 -0400937 SpvFunctionControlDontInlineMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100938 0,
939 {SPV_OPERAND_TYPE_NONE}},
940 {"Pure",
Lei Zhangb36e7042015-10-28 13:40:52 -0400941 SpvFunctionControlPureMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100942 0,
943 {SPV_OPERAND_TYPE_NONE}},
944 {"Const",
Lei Zhangb36e7042015-10-28 13:40:52 -0400945 SpvFunctionControlConstMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100946 0,
947 {SPV_OPERAND_TYPE_NONE}},
948};
949
950static const spv_operand_desc_t memorySemanticsEntries[] = {
David Netobfa3d862015-09-25 10:30:27 -0400951 // "Relaxed" should be a synonym for "None".
952 // Put the Relaxed entry first so that the disassembler
953 // will prefer to emit "Relaxed".
954 {"Relaxed",
Lei Zhangb36e7042015-10-28 13:40:52 -0400955 SpvMemorySemanticsMaskNone,
David Netobfa3d862015-09-25 10:30:27 -0400956 0,
957 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100958 {"None",
Lei Zhangb36e7042015-10-28 13:40:52 -0400959 SpvMemorySemanticsMaskNone,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100960 0,
961 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100962 {"SequentiallyConsistent",
Lei Zhangb36e7042015-10-28 13:40:52 -0400963 SpvMemorySemanticsSequentiallyConsistentMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100964 0,
965 {SPV_OPERAND_TYPE_NONE}},
966 {"Acquire",
Lei Zhangb36e7042015-10-28 13:40:52 -0400967 SpvMemorySemanticsAcquireMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100968 0,
969 {SPV_OPERAND_TYPE_NONE}},
970 {"Release",
Lei Zhangb36e7042015-10-28 13:40:52 -0400971 SpvMemorySemanticsReleaseMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100972 0,
973 {SPV_OPERAND_TYPE_NONE}},
974 {"UniformMemory",
Lei Zhangb36e7042015-10-28 13:40:52 -0400975 SpvMemorySemanticsUniformMemoryMask,
976 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100977 {SPV_OPERAND_TYPE_NONE}},
978 {"SubgroupMemory",
Lei Zhangb36e7042015-10-28 13:40:52 -0400979 SpvMemorySemanticsSubgroupMemoryMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100980 0,
981 {SPV_OPERAND_TYPE_NONE}},
982 {"WorkgroupLocalMemory",
Lei Zhangb36e7042015-10-28 13:40:52 -0400983 SpvMemorySemanticsWorkgroupLocalMemoryMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100984 0,
985 {SPV_OPERAND_TYPE_NONE}},
986 {"WorkgroupGlobalMemory",
Lei Zhangb36e7042015-10-28 13:40:52 -0400987 SpvMemorySemanticsWorkgroupGlobalMemoryMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100988 0,
989 {SPV_OPERAND_TYPE_NONE}},
990 {"AtomicCounterMemory",
Lei Zhangb36e7042015-10-28 13:40:52 -0400991 SpvMemorySemanticsAtomicCounterMemoryMask,
992 SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100993 {SPV_OPERAND_TYPE_NONE}},
994 {
Dejan Mircevski50babb22015-09-29 10:56:32 -0400995 "ImageMemory",
Lei Zhangb36e7042015-10-28 13:40:52 -0400996 SpvMemorySemanticsImageMemoryMask,
Dejan Mircevski50babb22015-09-29 10:56:32 -0400997 0,
998 {SPV_OPERAND_TYPE_NONE},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100999 },
1000};
1001
1002static const spv_operand_desc_t memoryAccessEntries[] = {
1003 {"None",
Lei Zhangb36e7042015-10-28 13:40:52 -04001004 SpvMemoryAccessMaskNone,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001005 0,
1006 {SPV_OPERAND_TYPE_NONE}},
1007 {"Volatile",
Lei Zhangb36e7042015-10-28 13:40:52 -04001008 SpvMemoryAccessVolatileMask,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001009 0,
1010 {SPV_OPERAND_TYPE_NONE}},
1011 {
Dejan Mircevski50babb22015-09-29 10:56:32 -04001012 "Aligned",
Lei Zhangb36e7042015-10-28 13:40:52 -04001013 SpvMemoryAccessAlignedMask,
Dejan Mircevski50babb22015-09-29 10:56:32 -04001014 0,
Lei Zhang6483bd72015-10-14 17:02:39 -04001015 {SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001016 },
David Neto49c299b2015-09-23 15:38:59 -04001017 {"Nontemporal",
Lei Zhangb36e7042015-10-28 13:40:52 -04001018 SpvMemoryAccessNontemporalMask,
David Neto49c299b2015-09-23 15:38:59 -04001019 0,
1020 {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001021};
1022
1023static const spv_operand_desc_t scopeEntries[] = {
1024 {"CrossDevice",
Lei Zhangb36e7042015-10-28 13:40:52 -04001025 SpvScopeCrossDevice,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001026 0,
1027 {SPV_OPERAND_TYPE_NONE}},
Lei Zhangb36e7042015-10-28 13:40:52 -04001028 {"Device", SpvScopeDevice, 0, {SPV_OPERAND_TYPE_NONE}},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001029 {"Workgroup",
Lei Zhangb36e7042015-10-28 13:40:52 -04001030 SpvScopeWorkgroup,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001031 0,
1032 {SPV_OPERAND_TYPE_NONE}},
1033 {"Subgroup",
Lei Zhangb36e7042015-10-28 13:40:52 -04001034 SpvScopeSubgroup,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001035 0,
1036 {SPV_OPERAND_TYPE_NONE}},
1037 {
Dejan Mircevski50babb22015-09-29 10:56:32 -04001038 "Invocation",
Lei Zhangb36e7042015-10-28 13:40:52 -04001039 SpvScopeInvocation,
Dejan Mircevski50babb22015-09-29 10:56:32 -04001040 0,
1041 {SPV_OPERAND_TYPE_NONE},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001042 },
1043};
1044
1045static const spv_operand_desc_t groupOperationEntries[] = {
1046 {"Reduce",
Lei Zhangb36e7042015-10-28 13:40:52 -04001047 SpvGroupOperationReduce,
1048 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001049 {SPV_OPERAND_TYPE_NONE}},
1050 {"InclusiveScan",
Lei Zhangb36e7042015-10-28 13:40:52 -04001051 SpvGroupOperationInclusiveScan,
1052 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001053 {SPV_OPERAND_TYPE_NONE}},
1054 {"ExclusiveScan",
Lei Zhangb36e7042015-10-28 13:40:52 -04001055 SpvGroupOperationExclusiveScan,
1056 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001057 {SPV_OPERAND_TYPE_NONE}},
1058};
1059
1060static const spv_operand_desc_t kernelKernelEnqueueFlagssEntries[] = {
1061 {"NoWait",
Lei Zhangb36e7042015-10-28 13:40:52 -04001062 SpvKernelEnqueueFlagsNoWait,
1063 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001064 {SPV_OPERAND_TYPE_NONE}},
1065 {"WaitKernel",
Lei Zhangb36e7042015-10-28 13:40:52 -04001066 SpvKernelEnqueueFlagsWaitKernel,
1067 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001068 {SPV_OPERAND_TYPE_NONE}},
1069 {"WaitWorkGroup",
Lei Zhangb36e7042015-10-28 13:40:52 -04001070 SpvKernelEnqueueFlagsWaitWorkGroup,
1071 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001072 {SPV_OPERAND_TYPE_NONE}},
1073};
1074
1075static const spv_operand_desc_t kernelProfilingInfoEntries[] = {
1076 {"None",
Lei Zhangb36e7042015-10-28 13:40:52 -04001077 SpvKernelProfilingInfoMaskNone,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001078 0,
1079 {SPV_OPERAND_TYPE_NONE}},
1080 {"CmdExecTime",
Lei Zhangb36e7042015-10-28 13:40:52 -04001081 SpvKernelProfilingInfoCmdExecTimeMask,
1082 SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001083 {SPV_OPERAND_TYPE_NONE}},
1084};
1085
David Netod30b2332015-09-23 16:04:24 -04001086// A macro for defining a capability that doesn't depend on another capability.
Lei Zhangb36e7042015-10-28 13:40:52 -04001087#define CASE(NAME) \
1088 { \
1089 #NAME, SpvCapability##NAME, 0, { SPV_OPERAND_TYPE_NONE } \
David Netod30b2332015-09-23 16:04:24 -04001090 }
1091
1092// A macro for defining a capability that depends on another.
Lei Zhangb36e7042015-10-28 13:40:52 -04001093#define CASE_CAP(NAME, CAP) \
1094 { \
1095 #NAME, SpvCapability##NAME, SPV_CAPABILITY_AS_MASK(SpvCapability##CAP), { \
1096 SPV_OPERAND_TYPE_NONE \
1097 } \
David Netod30b2332015-09-23 16:04:24 -04001098 }
1099
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001100static const spv_operand_desc_t capabilityInfoEntries[] = {
David Netod30b2332015-09-23 16:04:24 -04001101 CASE(Matrix),
1102 CASE_CAP(Shader, Matrix),
1103 CASE_CAP(Geometry, Shader),
1104 CASE_CAP(Tessellation, Shader),
1105 CASE(Addresses),
1106 CASE(Linkage),
1107 CASE(Kernel),
1108 CASE_CAP(Vector16, Kernel),
1109 CASE_CAP(Float16Buffer, Kernel),
1110 CASE_CAP(Float16, Float16Buffer),
1111 CASE(Float64),
1112 CASE(Int64),
1113 CASE_CAP(Int64Atomics, Int64),
1114 CASE_CAP(ImageBasic, Kernel),
1115 CASE_CAP(ImageReadWrite, Kernel),
1116 CASE_CAP(ImageMipmap, Kernel),
1117 CASE_CAP(ImageSRGBWrite, Kernel),
1118 CASE_CAP(Pipes, Kernel),
1119 CASE(Groups),
1120 CASE_CAP(DeviceEnqueue, Kernel),
1121 CASE_CAP(LiteralSampler, Kernel),
1122 CASE_CAP(AtomicStorage, Shader),
1123 CASE(Int16),
1124 CASE_CAP(TessellationPointSize, Tessellation),
1125 CASE_CAP(GeometryPointSize, Geometry),
1126 CASE_CAP(ImageGatherExtended, Shader),
1127 CASE_CAP(StorageImageExtendedFormats, Shader),
1128 CASE_CAP(StorageImageMultisample, Shader),
1129 CASE_CAP(UniformBufferArrayDynamicIndexing, Shader),
1130 CASE_CAP(SampledImageArrayDynamicIndexing, Shader),
1131 CASE_CAP(StorageBufferArrayDynamicIndexing, Shader),
1132 CASE_CAP(StorageImageArrayDynamicIndexing, Shader),
1133 CASE_CAP(ClipDistance, Shader),
1134 CASE_CAP(CullDistance, Shader),
1135 CASE_CAP(ImageCubeArray, SampledCubeArray),
1136 CASE_CAP(SampleRateShading, Shader),
1137 CASE_CAP(ImageRect, SampledRect),
1138 CASE_CAP(SampledRect, Shader),
1139 CASE_CAP(GenericPointer, Addresses),
1140 CASE_CAP(Int8, Kernel),
1141 CASE_CAP(InputTarget, Shader),
1142 CASE_CAP(SparseResidency, Shader),
1143 CASE_CAP(MinLod, Shader),
1144 CASE_CAP(Sampled1D, Shader),
1145 CASE_CAP(Image1D, Sampled1D),
1146 CASE_CAP(SampledCubeArray, Shader),
1147 CASE_CAP(SampledBuffer, Shader),
1148 CASE_CAP(ImageBuffer, SampledBuffer),
1149 CASE_CAP(ImageMSArray, Shader),
1150 CASE_CAP(AdvancedFormats, Shader),
1151 CASE_CAP(ImageQuery, Shader),
1152 CASE_CAP(DerivativeControl, Shader),
1153 CASE_CAP(InterpolationFunction, Shader),
1154 CASE_CAP(TransformFeedback, Shader),
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001155};
David Netod30b2332015-09-23 16:04:24 -04001156#undef CASE
1157#undef CASE_CAP
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001158
1159static const spv_operand_desc_group_t opcodeEntryTypes[] = {
1160 {SPV_OPERAND_TYPE_SOURCE_LANGUAGE,
1161 sizeof(sourceLanguageEntries) / sizeof(spv_operand_desc_t),
1162 sourceLanguageEntries},
1163 {SPV_OPERAND_TYPE_EXECUTION_MODEL,
1164 sizeof(executionModelEntries) / sizeof(spv_operand_desc_t),
1165 executionModelEntries},
1166 {SPV_OPERAND_TYPE_ADDRESSING_MODEL,
1167 sizeof(addressingModelEntries) / sizeof(spv_operand_desc_t),
1168 addressingModelEntries},
1169 {SPV_OPERAND_TYPE_MEMORY_MODEL,
1170 sizeof(memoryModelEntries) / sizeof(spv_operand_desc_t),
1171 memoryModelEntries},
1172 {SPV_OPERAND_TYPE_EXECUTION_MODE,
1173 sizeof(executionModeEntries) / sizeof(spv_operand_desc_t),
1174 executionModeEntries},
1175 {SPV_OPERAND_TYPE_STORAGE_CLASS,
1176 sizeof(storageClassEntries) / sizeof(spv_operand_desc_t),
1177 storageClassEntries},
1178 {SPV_OPERAND_TYPE_DIMENSIONALITY,
1179 sizeof(dimensionalityEntries) / sizeof(spv_operand_desc_t),
1180 dimensionalityEntries},
1181 {SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE,
1182 sizeof(samplerAddressingModeEntries) / sizeof(spv_operand_desc_t),
1183 samplerAddressingModeEntries},
1184 {SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE,
1185 sizeof(samplerFilterModeEntries) / sizeof(spv_operand_desc_t),
1186 samplerFilterModeEntries},
David Netob30a0c52015-09-16 15:56:43 -04001187 {SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT,
1188 sizeof(samplerImageFormatEntries) / sizeof(spv_operand_desc_t),
1189 samplerImageFormatEntries},
David Netoddda85a2015-10-02 17:10:10 -04001190 {SPV_OPERAND_TYPE_IMAGE_CHANNEL_ORDER,
1191 sizeof(imageChannelOrderEntries) / sizeof(spv_operand_desc_t),
1192 imageChannelOrderEntries},
1193 {SPV_OPERAND_TYPE_IMAGE_CHANNEL_DATA_TYPE,
1194 sizeof(imageChannelDataTypeEntries) / sizeof(spv_operand_desc_t),
1195 imageChannelDataTypeEntries},
David Netoee1b3bb2015-09-18 11:19:18 -04001196 {SPV_OPERAND_TYPE_OPTIONAL_IMAGE,
1197 sizeof(imageOperandEntries) / sizeof(spv_operand_desc_t),
1198 imageOperandEntries},
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001199 {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE,
1200 sizeof(fpFastMathModeEntries) / sizeof(spv_operand_desc_t),
1201 fpFastMathModeEntries},
1202 {SPV_OPERAND_TYPE_FP_ROUNDING_MODE,
1203 sizeof(fpRoundingModeEntries) / sizeof(spv_operand_desc_t),
1204 fpRoundingModeEntries},
1205 {SPV_OPERAND_TYPE_LINKAGE_TYPE,
1206 sizeof(linkageTypeEntries) / sizeof(spv_operand_desc_t),
1207 linkageTypeEntries},
1208 {SPV_OPERAND_TYPE_ACCESS_QUALIFIER,
1209 sizeof(accessQualifierEntries) / sizeof(spv_operand_desc_t),
1210 accessQualifierEntries},
1211 {SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE,
1212 sizeof(functionParameterAttributeEntries) / sizeof(spv_operand_desc_t),
1213 functionParameterAttributeEntries},
1214 {SPV_OPERAND_TYPE_DECORATION,
1215 sizeof(decorationEntries) / sizeof(spv_operand_desc_t), decorationEntries},
1216 {SPV_OPERAND_TYPE_BUILT_IN,
1217 sizeof(builtInEntries) / sizeof(spv_operand_desc_t), builtInEntries},
1218 {SPV_OPERAND_TYPE_SELECTION_CONTROL,
1219 sizeof(selectionControlEntries) / sizeof(spv_operand_desc_t),
1220 selectionControlEntries},
1221 {SPV_OPERAND_TYPE_LOOP_CONTROL,
1222 sizeof(loopControlEntries) / sizeof(spv_operand_desc_t),
1223 loopControlEntries},
1224 {SPV_OPERAND_TYPE_FUNCTION_CONTROL,
1225 sizeof(functionControlEntries) / sizeof(spv_operand_desc_t),
1226 functionControlEntries},
1227 {SPV_OPERAND_TYPE_MEMORY_SEMANTICS,
1228 sizeof(memorySemanticsEntries) / sizeof(spv_operand_desc_t),
1229 memorySemanticsEntries},
David Neto78c3b432015-08-27 13:03:52 -04001230 {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001231 sizeof(memoryAccessEntries) / sizeof(spv_operand_desc_t),
1232 memoryAccessEntries},
1233 {SPV_OPERAND_TYPE_EXECUTION_SCOPE,
1234 sizeof(scopeEntries) / sizeof(spv_operand_desc_t), scopeEntries},
1235 {SPV_OPERAND_TYPE_GROUP_OPERATION,
1236 sizeof(groupOperationEntries) / sizeof(spv_operand_desc_t),
1237 groupOperationEntries},
1238 {SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS,
1239 sizeof(kernelKernelEnqueueFlagssEntries) / sizeof(spv_operand_desc_t),
1240 kernelKernelEnqueueFlagssEntries},
David Neto47994822015-08-27 13:11:01 -04001241 {SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001242 sizeof(kernelProfilingInfoEntries) / sizeof(spv_operand_desc_t),
1243 kernelProfilingInfoEntries},
1244 {SPV_OPERAND_TYPE_CAPABILITY,
1245 sizeof(capabilityInfoEntries) / sizeof(spv_operand_desc_t),
1246 capabilityInfoEntries},
1247};
1248
Dejan Mircevski50babb22015-09-29 10:56:32 -04001249spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable) {
Lei Zhang40056702015-09-11 14:31:27 -04001250 if (!pOperandTable) return SPV_ERROR_INVALID_POINTER;
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001251
1252 static const spv_operand_table_t table = {
1253 sizeof(opcodeEntryTypes) / sizeof(spv_operand_desc_group_t),
1254 opcodeEntryTypes};
1255
1256 *pOperandTable = &table;
1257
1258 return SPV_SUCCESS;
1259}
1260
1261spv_result_t spvOperandTableNameLookup(const spv_operand_table table,
1262 const spv_operand_type_t type,
David Neto388c40d2015-09-16 16:42:56 -04001263 const char* name,
1264 const size_t nameLength,
1265 spv_operand_desc* pEntry) {
Lei Zhang40056702015-09-11 14:31:27 -04001266 if (!table) return SPV_ERROR_INVALID_TABLE;
1267 if (!name || !pEntry) return SPV_ERROR_INVALID_POINTER;
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001268
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001269 for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) {
1270 if (type == table->types[typeIndex].type) {
1271 for (uint64_t operandIndex = 0;
1272 operandIndex < table->types[typeIndex].count; ++operandIndex) {
1273 if (nameLength ==
1274 strlen(table->types[typeIndex].entries[operandIndex].name) &&
1275 !strncmp(table->types[typeIndex].entries[operandIndex].name, name,
David Neto388c40d2015-09-16 16:42:56 -04001276 nameLength)) {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001277 *pEntry = &table->types[typeIndex].entries[operandIndex];
1278 return SPV_SUCCESS;
1279 }
1280 }
1281 }
1282 }
1283
1284 return SPV_ERROR_INVALID_LOOKUP;
1285}
1286
1287spv_result_t spvOperandTableValueLookup(const spv_operand_table table,
1288 const spv_operand_type_t type,
1289 const uint32_t value,
Dejan Mircevski50babb22015-09-29 10:56:32 -04001290 spv_operand_desc* pEntry) {
Lei Zhang40056702015-09-11 14:31:27 -04001291 if (!table) return SPV_ERROR_INVALID_TABLE;
1292 if (!pEntry) return SPV_ERROR_INVALID_POINTER;
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001293
1294 for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) {
1295 if (type == table->types[typeIndex].type) {
1296 for (uint64_t operandIndex = 0;
1297 operandIndex < table->types[typeIndex].count; ++operandIndex) {
1298 if (value == table->types[typeIndex].entries[operandIndex].value) {
1299 *pEntry = &table->types[typeIndex].entries[operandIndex];
1300 return SPV_SUCCESS;
1301 }
1302 }
1303 }
1304 }
1305
1306 return SPV_ERROR_INVALID_LOOKUP;
1307}
1308
Dejan Mircevski50babb22015-09-29 10:56:32 -04001309const char* spvOperandTypeStr(spv_operand_type_t type) {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001310 switch (type) {
1311 case SPV_OPERAND_TYPE_ID:
David Netofadbf622015-09-14 17:07:11 -04001312 case SPV_OPERAND_TYPE_OPTIONAL_ID:
1313 case SPV_OPERAND_TYPE_ID_IN_OPTIONAL_TUPLE:
1314 return "ID";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001315 case SPV_OPERAND_TYPE_RESULT_ID:
1316 return "result ID";
Lei Zhang6483bd72015-10-14 17:02:39 -04001317 case SPV_OPERAND_TYPE_LITERAL_INTEGER:
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001318 return "literal number";
Lei Zhangb41d1502015-09-14 15:22:23 -04001319 case SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER:
1320 return "multiple word literal number";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001321 case SPV_OPERAND_TYPE_LITERAL_STRING:
1322 return "literal string";
1323 case SPV_OPERAND_TYPE_SOURCE_LANGUAGE:
Dejan Mircevskid2c81cf2015-10-09 11:06:10 -04001324 return "source language";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001325 case SPV_OPERAND_TYPE_EXECUTION_MODEL:
1326 return "execution model";
1327 case SPV_OPERAND_TYPE_ADDRESSING_MODEL:
1328 return "addressing model";
1329 case SPV_OPERAND_TYPE_MEMORY_MODEL:
1330 return "memory model";
1331 case SPV_OPERAND_TYPE_EXECUTION_MODE:
1332 return "execution mode";
1333 case SPV_OPERAND_TYPE_STORAGE_CLASS:
1334 return "storage class";
1335 case SPV_OPERAND_TYPE_DIMENSIONALITY:
1336 return "dimensionality";
1337 case SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE:
1338 return "addressing mode";
1339 case SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE:
1340 return "sampler filter mode";
David Netob30a0c52015-09-16 15:56:43 -04001341 case SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT:
Dejan Mircevski971b3442015-10-13 12:54:47 -04001342 return "image format";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001343 case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE:
Dejan Mircevski355cc0c2015-10-13 15:02:03 -04001344 return "floating-point fast math mode";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001345 case SPV_OPERAND_TYPE_FP_ROUNDING_MODE:
Dejan Mircevski355cc0c2015-10-13 15:02:03 -04001346 return "floating-point rounding mode";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001347 case SPV_OPERAND_TYPE_LINKAGE_TYPE:
1348 return "linkage type";
1349 case SPV_OPERAND_TYPE_ACCESS_QUALIFIER:
1350 return "access qualifier";
1351 case SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE:
1352 return "function parameter attribute";
1353 case SPV_OPERAND_TYPE_DECORATION:
1354 return "decoration";
1355 case SPV_OPERAND_TYPE_BUILT_IN:
Dejan Mircevskid7b0f832015-10-13 15:39:38 -04001356 return "built-in";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001357 case SPV_OPERAND_TYPE_SELECTION_CONTROL:
1358 return "selection control";
1359 case SPV_OPERAND_TYPE_LOOP_CONTROL:
1360 return "loop control";
1361 case SPV_OPERAND_TYPE_FUNCTION_CONTROL:
1362 return "function control";
1363 case SPV_OPERAND_TYPE_MEMORY_SEMANTICS:
1364 return "memory semantics";
David Neto78c3b432015-08-27 13:03:52 -04001365 case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001366 return "memory access";
1367 case SPV_OPERAND_TYPE_EXECUTION_SCOPE:
David Netofadbf622015-09-14 17:07:11 -04001368 return "execution scope ID";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001369 case SPV_OPERAND_TYPE_GROUP_OPERATION:
1370 return "group operation";
1371 case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS:
1372 return "kernel enqeue flags";
David Neto47994822015-08-27 13:11:01 -04001373 case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO:
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001374 return "kernel profiling info";
1375 case SPV_OPERAND_TYPE_CAPABILITY:
1376 return "capability";
David Netoee1b3bb2015-09-18 11:19:18 -04001377 case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
1378 return "image operand";
David Neto78c3b432015-08-27 13:03:52 -04001379 case SPV_OPERAND_TYPE_NONE:
1380 return "NONE";
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001381 default:
1382 assert(0 && "Unhandled operand type!");
1383 break;
1384 }
1385 return "unknown";
1386}
David Neto78c3b432015-08-27 13:03:52 -04001387
1388void spvPrependOperandTypes(const spv_operand_type_t* types,
1389 spv_operand_pattern_t* pattern) {
1390 const spv_operand_type_t* endTypes;
Dejan Mircevski50babb22015-09-29 10:56:32 -04001391 for (endTypes = types; *endTypes != SPV_OPERAND_TYPE_NONE; ++endTypes)
David Neto78c3b432015-08-27 13:03:52 -04001392 ;
1393 pattern->insert(pattern->begin(), types, endTypes);
1394}
1395
David Neto5bf88fc2015-09-17 17:06:10 -04001396void spvPrependOperandTypesForMask(const spv_operand_table operandTable,
1397 const spv_operand_type_t type,
1398 const uint32_t mask,
1399 spv_operand_pattern_t* pattern) {
1400 // Scan from highest bits to lowest bits because we will prepend in LIFO
1401 // fashion, and we need the operands for lower order bits to appear first.
1402 for (uint32_t candidate_bit = (1 << 31); candidate_bit; candidate_bit >>= 1) {
1403 if (candidate_bit & mask) {
1404 spv_operand_desc entry = nullptr;
1405 if (SPV_SUCCESS == spvOperandTableValueLookup(operandTable, type,
1406 candidate_bit, &entry)) {
1407 spvPrependOperandTypes(entry->operandTypes, pattern);
1408 }
1409 }
1410 }
1411}
1412
David Neto78c3b432015-08-27 13:03:52 -04001413bool spvOperandIsOptional(spv_operand_type_t type) {
1414 // Variable means zero or more times.
Dejan Mircevski50babb22015-09-29 10:56:32 -04001415 if (spvOperandIsVariable(type)) return true;
David Neto78c3b432015-08-27 13:03:52 -04001416
1417 switch (type) {
1418 case SPV_OPERAND_TYPE_OPTIONAL_ID:
1419 case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
David Neto561dc4e2015-09-25 14:23:29 -04001420 case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER:
Lei Zhang6483bd72015-10-14 17:02:39 -04001421 case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER:
David Neto78c3b432015-08-27 13:03:52 -04001422 case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING:
1423 case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
1424 case SPV_OPERAND_TYPE_OPTIONAL_EXECUTION_MODE:
Dejan Mircevski903f9d62015-09-28 17:04:39 -04001425 case SPV_OPERAND_TYPE_OPTIONAL_CIV:
David Neto78c3b432015-08-27 13:03:52 -04001426 return true;
1427 default:
1428 break;
1429 }
1430 return false;
1431}
1432
1433bool spvOperandIsVariable(spv_operand_type_t type) {
1434 switch (type) {
1435 case SPV_OPERAND_TYPE_VARIABLE_ID:
Lei Zhang6483bd72015-10-14 17:02:39 -04001436 case SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER:
1437 case SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER:
1438 case SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER_ID:
David Neto78c3b432015-08-27 13:03:52 -04001439 case SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE:
1440 return true;
1441 default:
1442 break;
1443 }
1444 return false;
1445}
1446
David Neto78c3b432015-08-27 13:03:52 -04001447bool spvExpandOperandSequenceOnce(spv_operand_type_t type,
1448 spv_operand_pattern_t* pattern) {
1449 switch (type) {
1450 case SPV_OPERAND_TYPE_VARIABLE_ID:
1451 pattern->insert(pattern->begin(), {SPV_OPERAND_TYPE_OPTIONAL_ID, type});
1452 return true;
Lei Zhang6483bd72015-10-14 17:02:39 -04001453 case SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER:
David Neto78c3b432015-08-27 13:03:52 -04001454 pattern->insert(pattern->begin(),
Lei Zhang6483bd72015-10-14 17:02:39 -04001455 {SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER, type});
David Neto78c3b432015-08-27 13:03:52 -04001456 return true;
Lei Zhang6483bd72015-10-14 17:02:39 -04001457 case SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER_ID:
David Neto561dc4e2015-09-25 14:23:29 -04001458 // Represents Zero or more (Literal number, Id) pairs.
David Neto78c3b432015-08-27 13:03:52 -04001459 pattern->insert(pattern->begin(),
Lei Zhang6483bd72015-10-14 17:02:39 -04001460 {SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER,
David Neto78c3b432015-08-27 13:03:52 -04001461 SPV_OPERAND_TYPE_ID_IN_OPTIONAL_TUPLE, type});
1462 return true;
Lei Zhang6483bd72015-10-14 17:02:39 -04001463 case SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER:
David Neto561dc4e2015-09-25 14:23:29 -04001464 // Represents Zero or more (Id, Literal number) pairs.
Dejan Mircevski50babb22015-09-29 10:56:32 -04001465 pattern->insert(
1466 pattern->begin(),
1467 {SPV_OPERAND_TYPE_OPTIONAL_ID,
Lei Zhang6483bd72015-10-14 17:02:39 -04001468 SPV_OPERAND_TYPE_LITERAL_INTEGER_IN_OPTIONAL_TUPLE, type});
David Neto78c3b432015-08-27 13:03:52 -04001469 return true;
David Neto78c3b432015-08-27 13:03:52 -04001470 case SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE:
Dejan Mircevski50babb22015-09-29 10:56:32 -04001471 pattern->insert(pattern->begin(),
1472 {SPV_OPERAND_TYPE_OPTIONAL_EXECUTION_MODE, type});
David Neto78c3b432015-08-27 13:03:52 -04001473 return true;
1474 default:
1475 break;
1476 }
1477 return false;
1478}
1479
Dejan Mircevski50babb22015-09-29 10:56:32 -04001480spv_operand_type_t spvTakeFirstMatchableOperand(
1481 spv_operand_pattern_t* pattern) {
David Neto78c3b432015-08-27 13:03:52 -04001482 assert(!pattern->empty());
1483 spv_operand_type_t result;
1484 do {
1485 result = pattern->front();
1486 pattern->pop_front();
Dejan Mircevski50babb22015-09-29 10:56:32 -04001487 } while (spvExpandOperandSequenceOnce(result, pattern));
David Neto78c3b432015-08-27 13:03:52 -04001488 return result;
1489}
Dejan Mircevski903f9d62015-09-28 17:04:39 -04001490
Dejan Mircevski897bff92015-09-29 10:38:18 -04001491spv_operand_pattern_t spvAlternatePatternFollowingImmediate(
1492 const spv_operand_pattern_t& pattern) {
1493 spv_operand_pattern_t alternatePattern;
1494 for (const auto& operand : pattern) {
1495 if (operand == SPV_OPERAND_TYPE_RESULT_ID) {
1496 alternatePattern.push_back(operand);
1497 alternatePattern.push_back(SPV_OPERAND_TYPE_OPTIONAL_CIV);
1498 return alternatePattern;
Dejan Mircevski903f9d62015-09-28 17:04:39 -04001499 }
Dejan Mircevski897bff92015-09-29 10:38:18 -04001500 alternatePattern.push_back(SPV_OPERAND_TYPE_OPTIONAL_CIV);
Dejan Mircevski903f9d62015-09-28 17:04:39 -04001501 }
Dejan Mircevski897bff92015-09-29 10:38:18 -04001502 // No result-id found, so just expect CIVs.
1503 return {SPV_OPERAND_TYPE_OPTIONAL_CIV};
Dejan Mircevski903f9d62015-09-28 17:04:39 -04001504}