Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1 | // 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 | |
| 32 | static 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 | |
| 55 | static 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 | |
| 93 | static 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 | |
| 111 | static 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}}, |
Lei Zhang | 604e5ce | 2015-08-14 14:46:43 -0400 | [diff] [blame] | 122 | {"OpenCL", |
| 123 | MemoryModelOpenCL, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 124 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 125 | CapabilityKernel, |
| 126 | {SPV_OPERAND_TYPE_NONE}}, |
| 127 | }; |
| 128 | |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 129 | // Execution mode requiring the given capability and having no operands. |
| 130 | #define ExecMode0(mode, cap) \ |
| 131 | #mode, ExecutionMode##mode, SPV_OPCODE_FLAGS_CAPABILITIES, Capability##cap, \ |
| 132 | { \ |
| 133 | SPV_OPERAND_TYPE_NONE \ |
| 134 | } |
| 135 | // Execution mode requiring the given capability and having one literal number |
| 136 | // operand. |
| 137 | #define ExecMode1(mode, cap) \ |
| 138 | #mode, ExecutionMode##mode, SPV_OPCODE_FLAGS_CAPABILITIES, Capability##cap, \ |
| 139 | { \ |
| 140 | SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE \ |
| 141 | } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 142 | static const spv_operand_desc_t executionModeEntries[] = { |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 143 | {ExecMode1(Invocations, Geometry)}, |
| 144 | {ExecMode0(SpacingEqual, Tessellation)}, |
| 145 | {ExecMode0(SpacingFractionalEven, Tessellation)}, |
| 146 | {ExecMode0(SpacingFractionalOdd, Tessellation)}, |
| 147 | {ExecMode0(VertexOrderCw, Tessellation)}, |
| 148 | {ExecMode0(VertexOrderCcw, Tessellation)}, |
| 149 | {ExecMode0(PixelCenterInteger, Shader)}, |
| 150 | {ExecMode0(OriginUpperLeft, Shader)}, |
| 151 | {ExecMode0(OriginLowerLeft, Shader)}, |
| 152 | {ExecMode0(EarlyFragmentTests, Shader)}, |
| 153 | {ExecMode0(PointMode, Tessellation)}, |
Lei Zhang | 863ddbe | 2015-09-23 17:09:01 -0400 | [diff] [blame^] | 154 | {ExecMode0(Xfb, TransformFeedback)}, |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 155 | {ExecMode0(DepthReplacing, Shader)}, |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 156 | {ExecMode0(DepthGreater, Shader)}, |
| 157 | {ExecMode0(DepthLess, Shader)}, |
| 158 | {ExecMode0(DepthUnchanged, Shader)}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 159 | {"LocalSize", |
| 160 | ExecutionModeLocalSize, |
| 161 | SPV_OPCODE_FLAGS_NONE, |
| 162 | 0, |
| 163 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_LITERAL_NUMBER, |
| 164 | SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
| 165 | {"LocalSizeHint", |
| 166 | ExecutionModeLocalSizeHint, |
| 167 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 168 | CapabilityKernel, |
| 169 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_LITERAL_NUMBER, |
| 170 | SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 171 | {ExecMode0(InputPoints, Geometry)}, |
| 172 | {ExecMode0(InputLines, Geometry)}, |
| 173 | {ExecMode0(InputLinesAdjacency, Geometry)}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 174 | {"InputTriangles", |
| 175 | ExecutionModeInputTriangles, |
| 176 | SPV_OPCODE_FLAGS_CAPABILITIES, |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 177 | // TODO(dneto): Capabilities are defined as sequential numbers instead of |
| 178 | // bit masks. They cannot be meaningfully combined with a bitwise OR. |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 179 | CapabilityGeometry | CapabilityTessellation, |
| 180 | {SPV_OPERAND_TYPE_NONE}}, |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 181 | {ExecMode0(InputTrianglesAdjacency, Geometry)}, |
| 182 | {ExecMode0(InputQuads, Tessellation)}, |
| 183 | {ExecMode0(InputIsolines, Tessellation)}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 184 | {"OutputVertices", |
| 185 | ExecutionModeOutputVertices, |
| 186 | SPV_OPCODE_FLAGS_CAPABILITIES, |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 187 | // TODO(dneto): Capabilities are defined as sequential numbers instead of |
| 188 | // bit masks. They cannot be meaningfully combined with a bitwise OR. |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 189 | CapabilityGeometry | CapabilityTessellation, |
| 190 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 191 | {ExecMode0(OutputPoints, Geometry)}, |
| 192 | {ExecMode0(OutputLineStrip, Geometry)}, |
| 193 | {ExecMode0(OutputTriangleStrip, Geometry)}, |
| 194 | {ExecMode1(VecTypeHint, Kernel)}, |
| 195 | {ExecMode0(ContractionOff, Kernel)}, |
| 196 | {ExecMode0(IndependentForwardProgress, Kernel)}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 197 | }; |
Lei Zhang | 85c6f79 | 2015-09-23 15:42:18 -0400 | [diff] [blame] | 198 | #undef ExecMode0 |
| 199 | #undef ExecMode1 |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 200 | |
| 201 | static const spv_operand_desc_t storageClassEntries[] = { |
David Neto | 5494dd4 | 2015-09-15 16:41:38 -0400 | [diff] [blame] | 202 | // TODO(dneto): There are more storage classes in Rev32 and later. |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 203 | {"UniformConstant", |
| 204 | StorageClassUniformConstant, |
| 205 | SPV_OPCODE_FLAGS_NONE, |
| 206 | 0, |
| 207 | {SPV_OPERAND_TYPE_NONE}}, |
| 208 | {"Input", |
| 209 | StorageClassInput, |
| 210 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 211 | CapabilityShader, |
| 212 | {SPV_OPERAND_TYPE_NONE}}, |
| 213 | {"Uniform", |
| 214 | StorageClassUniform, |
| 215 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 216 | CapabilityShader, |
| 217 | {SPV_OPERAND_TYPE_NONE}}, |
| 218 | {"Output", |
| 219 | StorageClassOutput, |
| 220 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 221 | CapabilityShader, |
| 222 | {SPV_OPERAND_TYPE_NONE}}, |
| 223 | {"WorkgroupLocal", |
| 224 | StorageClassWorkgroupLocal, |
| 225 | SPV_OPCODE_FLAGS_NONE, |
| 226 | 0, |
| 227 | {SPV_OPERAND_TYPE_NONE}}, |
| 228 | {"WorkgroupGlobal", |
| 229 | StorageClassWorkgroupGlobal, |
| 230 | SPV_OPCODE_FLAGS_NONE, |
| 231 | 0, |
| 232 | {SPV_OPERAND_TYPE_NONE}}, |
| 233 | {"PrivateGlobal", |
| 234 | StorageClassPrivateGlobal, |
| 235 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 236 | CapabilityShader, |
| 237 | {SPV_OPERAND_TYPE_NONE}}, |
| 238 | {"Function", |
| 239 | StorageClassFunction, |
| 240 | SPV_OPCODE_FLAGS_NONE, |
| 241 | 0, |
| 242 | {SPV_OPERAND_TYPE_NONE}}, |
| 243 | {"Generic", |
| 244 | StorageClassGeneric, |
| 245 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 246 | CapabilityKernel, |
| 247 | {SPV_OPERAND_TYPE_NONE}}, |
David Neto | 9819adf | 2015-09-23 10:19:57 -0400 | [diff] [blame] | 248 | {"PushConstant", |
| 249 | StorageClassPushConstant, |
| 250 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 251 | CapabilityShader, |
| 252 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 253 | {"AtomicCounter", |
| 254 | StorageClassAtomicCounter, |
| 255 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 256 | CapabilityShader, |
| 257 | {SPV_OPERAND_TYPE_NONE}}, |
Lei Zhang | 604e5ce | 2015-08-14 14:46:43 -0400 | [diff] [blame] | 258 | {"Image", |
| 259 | StorageClassImage, |
| 260 | SPV_OPCODE_FLAGS_NONE, |
| 261 | 0, |
| 262 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 263 | }; |
| 264 | |
| 265 | static const spv_operand_desc_t dimensionalityEntries[] = { |
David Neto | aa0c3a5 | 2015-09-23 10:30:06 -0400 | [diff] [blame] | 266 | // TODO(dneto): Update capability dependencies for Rev32 |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 267 | {"1D", Dim1D, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}}, |
| 268 | {"2D", Dim2D, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}}, |
| 269 | {"3D", Dim3D, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}}, |
| 270 | {"Cube", |
| 271 | DimCube, |
| 272 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 273 | CapabilityShader, |
| 274 | {SPV_OPERAND_TYPE_NONE}}, |
| 275 | {"Rect", |
| 276 | DimRect, |
| 277 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 278 | CapabilityShader, |
| 279 | {SPV_OPERAND_TYPE_NONE}}, |
| 280 | {"Buffer", DimBuffer, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}}, |
David Neto | aa0c3a5 | 2015-09-23 10:30:06 -0400 | [diff] [blame] | 281 | {"InputTarget", |
| 282 | DimInputTarget, |
| 283 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 284 | CapabilityInputTarget, |
| 285 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | static const spv_operand_desc_t samplerAddressingModeEntries[] = { |
| 289 | {"None", |
| 290 | SamplerAddressingModeNone, |
| 291 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 292 | CapabilityKernel, |
| 293 | {SPV_OPERAND_TYPE_NONE}}, |
| 294 | {"ClampToEdge", |
| 295 | SamplerAddressingModeClampToEdge, |
| 296 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 297 | CapabilityKernel, |
| 298 | {SPV_OPERAND_TYPE_NONE}}, |
| 299 | {"Clamp", |
| 300 | SamplerAddressingModeClamp, |
| 301 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 302 | CapabilityKernel, |
| 303 | {SPV_OPERAND_TYPE_NONE}}, |
| 304 | {"Repeat", |
| 305 | SamplerAddressingModeRepeat, |
| 306 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 307 | CapabilityKernel, |
| 308 | {SPV_OPERAND_TYPE_NONE}}, |
| 309 | {"RepeatMirrored", |
| 310 | SamplerAddressingModeRepeatMirrored, |
| 311 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 312 | CapabilityKernel, |
| 313 | {SPV_OPERAND_TYPE_NONE}}, |
| 314 | }; |
| 315 | |
| 316 | static const spv_operand_desc_t samplerFilterModeEntries[] = { |
| 317 | {"Nearest", |
| 318 | SamplerFilterModeNearest, |
| 319 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 320 | CapabilityKernel, |
| 321 | {SPV_OPERAND_TYPE_NONE}}, |
| 322 | {"Linear", |
| 323 | SamplerFilterModeLinear, |
| 324 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 325 | CapabilityKernel, |
| 326 | {SPV_OPERAND_TYPE_NONE}}, |
| 327 | }; |
| 328 | |
David Neto | b30a0c5 | 2015-09-16 15:56:43 -0400 | [diff] [blame] | 329 | static const spv_operand_desc_t samplerImageFormatEntries[] = { |
| 330 | // In Rev31, all the cases depend on the Shader capability. |
| 331 | // TODO(dneto): In Rev32, many of these depend on the AdvancedFormats |
| 332 | // capability instead. |
| 333 | #define CASE(NAME) \ |
| 334 | { \ |
| 335 | #NAME, ImageFormat##NAME, SPV_OPCODE_FLAGS_CAPABILITIES, CapabilityShader, \ |
| 336 | { \ |
| 337 | SPV_OPERAND_TYPE_NONE \ |
| 338 | } \ |
| 339 | } |
| 340 | // clang-format off |
| 341 | CASE(Unknown), |
| 342 | CASE(Rgba32f), |
| 343 | CASE(Rgba16f), |
| 344 | CASE(R32f), |
| 345 | CASE(Rgba8), |
| 346 | CASE(Rgba8Snorm), |
| 347 | CASE(Rg32f), |
| 348 | CASE(Rg16f), |
| 349 | CASE(R11fG11fB10f), |
| 350 | CASE(R16f), |
| 351 | CASE(Rgba16), |
| 352 | CASE(Rgb10A2), |
| 353 | CASE(Rg16), |
| 354 | CASE(Rg8), |
| 355 | CASE(R16), |
| 356 | CASE(R8), |
| 357 | CASE(Rgba16Snorm), |
| 358 | CASE(Rg16Snorm), |
| 359 | CASE(Rg8Snorm), |
| 360 | CASE(R16Snorm), |
| 361 | CASE(R8Snorm), |
| 362 | CASE(Rgba32i), |
| 363 | CASE(Rgba16i), |
| 364 | CASE(Rgba8i), |
| 365 | CASE(R32i), |
| 366 | CASE(Rg32i), |
| 367 | CASE(Rg16i), |
| 368 | CASE(Rg8i), |
| 369 | CASE(R16i), |
| 370 | CASE(R8i), |
| 371 | CASE(Rgba32ui), |
| 372 | CASE(Rgba16ui), |
| 373 | CASE(Rgba8ui), |
| 374 | CASE(R32ui), |
| 375 | CASE(Rgb10a2ui), |
| 376 | CASE(Rg32ui), |
| 377 | CASE(Rg16ui), |
| 378 | CASE(Rg8ui), |
| 379 | CASE(R16ui), |
| 380 | CASE(R8ui), |
| 381 | // clang-format on |
| 382 | #undef CASE |
| 383 | }; |
| 384 | |
David Neto | ee1b3bb | 2015-09-18 11:19:18 -0400 | [diff] [blame] | 385 | // Image operand definitions. Each enum value is a mask. When that mask |
| 386 | // bit is set, the instruction should have further ID operands. |
| 387 | // Some mask values depend on a capability. |
| 388 | static const spv_operand_desc_t imageOperandEntries[] = { |
| 389 | // Rev32 and later adds many more enums. |
| 390 | #define CASE(NAME) \ |
| 391 | #NAME, spv::ImageOperands##NAME##Mask, SPV_OPCODE_FLAGS_NONE, 0 |
| 392 | #define CASE_CAP(NAME, CAP) \ |
| 393 | #NAME, spv::ImageOperands##NAME##Mask, SPV_OPCODE_FLAGS_CAPABILITIES, CAP |
| 394 | #define ID SPV_OPERAND_TYPE_ID |
| 395 | #define NONE SPV_OPERAND_TYPE_NONE |
| 396 | {"None", spv::ImageOperandsMaskNone, SPV_OPCODE_FLAGS_NONE, 0, {NONE}}, |
| 397 | {CASE_CAP(Bias, CapabilityShader), {ID, NONE}}, |
| 398 | {CASE(Lod), {ID, NONE}}, |
| 399 | {CASE(Grad), {ID, ID, NONE}}, |
| 400 | {CASE(ConstOffset), {ID, NONE}}, |
| 401 | {CASE_CAP(Offset, CapabilityImageGatherExtended), {ID, NONE}}, |
| 402 | {CASE(ConstOffsets), {ID, NONE}}, |
| 403 | {CASE(Sample), {ID, NONE}}, |
David Neto | 8576c9c | 2015-09-23 14:32:37 -0400 | [diff] [blame] | 404 | {CASE_CAP(MinLod, CapabilityMinLod), {ID, NONE}}, |
David Neto | ee1b3bb | 2015-09-18 11:19:18 -0400 | [diff] [blame] | 405 | #undef CASE |
| 406 | #undef CASE_CAP |
| 407 | #undef ID |
| 408 | #undef NONE |
| 409 | }; |
| 410 | |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 411 | static const spv_operand_desc_t fpFastMathModeEntries[] = { |
| 412 | {"None", |
| 413 | FPFastMathModeMaskNone, |
| 414 | SPV_OPCODE_FLAGS_NONE, |
| 415 | 0, |
| 416 | {SPV_OPERAND_TYPE_NONE}}, |
| 417 | {"NotNaN", |
| 418 | FPFastMathModeNotNaNMask, |
| 419 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 420 | CapabilityKernel, |
| 421 | {SPV_OPERAND_TYPE_NONE}}, |
| 422 | {"NotInf", |
| 423 | FPFastMathModeNotInfMask, |
| 424 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 425 | CapabilityKernel, |
| 426 | {SPV_OPERAND_TYPE_NONE}}, |
| 427 | {"NSZ", |
| 428 | FPFastMathModeNSZMask, |
| 429 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 430 | CapabilityKernel, |
| 431 | {SPV_OPERAND_TYPE_NONE}}, |
| 432 | {"AllowRecip", |
| 433 | FPFastMathModeAllowRecipMask, |
| 434 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 435 | CapabilityKernel, |
| 436 | {SPV_OPERAND_TYPE_NONE}}, |
| 437 | {"Fast", |
| 438 | FPFastMathModeFastMask, |
| 439 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 440 | CapabilityKernel, |
| 441 | {SPV_OPERAND_TYPE_NONE}}, |
| 442 | }; |
| 443 | |
| 444 | static const spv_operand_desc_t fpRoundingModeEntries[] = { |
| 445 | {"RTE", |
| 446 | FPRoundingModeRTE, |
| 447 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 448 | CapabilityKernel, |
| 449 | {SPV_OPERAND_TYPE_NONE}}, |
| 450 | {"RTZ", |
| 451 | FPRoundingModeRTZ, |
| 452 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 453 | CapabilityKernel, |
| 454 | {SPV_OPERAND_TYPE_NONE}}, |
| 455 | {"RTP", |
| 456 | FPRoundingModeRTP, |
| 457 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 458 | CapabilityKernel, |
| 459 | {SPV_OPERAND_TYPE_NONE}}, |
| 460 | {"RTN", |
| 461 | FPRoundingModeRTN, |
| 462 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 463 | CapabilityKernel, |
| 464 | {SPV_OPERAND_TYPE_NONE}}, |
| 465 | }; |
| 466 | |
| 467 | static const spv_operand_desc_t linkageTypeEntries[] = { |
| 468 | {"Export", |
| 469 | LinkageTypeExport, |
| 470 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 471 | CapabilityLinkage, |
| 472 | {SPV_OPERAND_TYPE_NONE}}, |
| 473 | {"Import", |
| 474 | LinkageTypeImport, |
| 475 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 476 | CapabilityLinkage, |
| 477 | {SPV_OPERAND_TYPE_NONE}}, |
| 478 | }; |
| 479 | |
| 480 | static const spv_operand_desc_t accessQualifierEntries[] = { |
| 481 | {"ReadOnly", |
| 482 | AccessQualifierReadOnly, |
| 483 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 484 | CapabilityKernel, |
| 485 | {SPV_OPERAND_TYPE_NONE}}, |
| 486 | {"WriteOnly", |
| 487 | AccessQualifierWriteOnly, |
| 488 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 489 | CapabilityKernel, |
| 490 | {SPV_OPERAND_TYPE_NONE}}, |
| 491 | {"ReadWrite", |
| 492 | AccessQualifierReadWrite, |
| 493 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 494 | CapabilityKernel, |
| 495 | {SPV_OPERAND_TYPE_NONE}}, |
| 496 | }; |
| 497 | |
| 498 | static const spv_operand_desc_t functionParameterAttributeEntries[] = { |
| 499 | {"Zext", |
| 500 | FunctionParameterAttributeZext, |
| 501 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 502 | CapabilityKernel, |
| 503 | {SPV_OPERAND_TYPE_NONE}}, |
| 504 | {"Sext", |
| 505 | FunctionParameterAttributeSext, |
| 506 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 507 | CapabilityKernel, |
| 508 | {SPV_OPERAND_TYPE_NONE}}, |
| 509 | {"ByVal", |
| 510 | FunctionParameterAttributeByVal, |
| 511 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 512 | CapabilityKernel, |
| 513 | {SPV_OPERAND_TYPE_NONE}}, |
| 514 | {"Sret", |
| 515 | FunctionParameterAttributeSret, |
| 516 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 517 | CapabilityKernel, |
| 518 | {SPV_OPERAND_TYPE_NONE}}, |
| 519 | {"NoAlias", |
| 520 | FunctionParameterAttributeNoAlias, |
| 521 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 522 | CapabilityKernel, |
| 523 | {SPV_OPERAND_TYPE_NONE}}, |
David Neto | 37547b2 | 2015-09-10 13:23:11 -0400 | [diff] [blame] | 524 | {"NoCapture", |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 525 | FunctionParameterAttributeNoCapture, |
| 526 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 527 | CapabilityKernel, |
| 528 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 529 | {"NoWrite", |
| 530 | FunctionParameterAttributeNoWrite, |
| 531 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 532 | CapabilityKernel, |
| 533 | {SPV_OPERAND_TYPE_NONE}}, |
| 534 | {"NoReadWrite", |
| 535 | FunctionParameterAttributeNoReadWrite, |
| 536 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 537 | CapabilityKernel, |
| 538 | {SPV_OPERAND_TYPE_NONE}}, |
| 539 | }; |
| 540 | |
| 541 | static const spv_operand_desc_t decorationEntries[] = { |
Lei Zhang | 604e5ce | 2015-08-14 14:46:43 -0400 | [diff] [blame] | 542 | {"RelaxedPrecision", |
| 543 | DecorationRelaxedPrecision, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 544 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 545 | CapabilityShader, |
| 546 | {SPV_OPERAND_TYPE_NONE}}, |
Lei Zhang | 604e5ce | 2015-08-14 14:46:43 -0400 | [diff] [blame] | 547 | { |
| 548 | "SpecId", |
| 549 | DecorationSpecId, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 550 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 551 | CapabilityShader, |
Lei Zhang | 604e5ce | 2015-08-14 14:46:43 -0400 | [diff] [blame] | 552 | {SPV_OPERAND_TYPE_LITERAL_NUMBER}, |
| 553 | }, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 554 | {"Block", |
| 555 | DecorationBlock, |
| 556 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 557 | CapabilityShader, |
| 558 | {SPV_OPERAND_TYPE_NONE}}, |
| 559 | {"BufferBlock", |
| 560 | DecorationBufferBlock, |
| 561 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 562 | CapabilityShader, |
| 563 | {SPV_OPERAND_TYPE_NONE}}, |
| 564 | {"RowMajor", |
| 565 | DecorationRowMajor, |
| 566 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 567 | CapabilityMatrix, |
| 568 | {SPV_OPERAND_TYPE_NONE}}, |
| 569 | {"ColMajor", |
| 570 | DecorationColMajor, |
| 571 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 572 | CapabilityMatrix, |
| 573 | {SPV_OPERAND_TYPE_NONE}}, |
Lei Zhang | 604e5ce | 2015-08-14 14:46:43 -0400 | [diff] [blame] | 574 | {"ArrayStride", |
| 575 | DecorationArrayStride, |
| 576 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 577 | CapabilityShader, |
| 578 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
| 579 | {"MatrixStride", |
| 580 | DecorationMatrixStride, |
| 581 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 582 | CapabilityShader, |
| 583 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 584 | {"GLSLShared", |
| 585 | DecorationGLSLShared, |
| 586 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 587 | CapabilityShader, |
| 588 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 589 | {"GLSLPacked", |
| 590 | DecorationGLSLPacked, |
| 591 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 592 | CapabilityShader, |
| 593 | {SPV_OPERAND_TYPE_NONE}}, |
Lei Zhang | 604e5ce | 2015-08-14 14:46:43 -0400 | [diff] [blame] | 594 | {"CPacked", |
| 595 | DecorationCPacked, |
| 596 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 597 | CapabilityKernel, |
| 598 | {SPV_OPERAND_TYPE_NONE}}, |
| 599 | {"BuiltIn", |
| 600 | DecorationBuiltIn, |
| 601 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 602 | CapabilityShader, |
| 603 | {SPV_OPERAND_TYPE_BUILT_IN, SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 604 | {"Smooth", |
| 605 | DecorationSmooth, |
| 606 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 607 | CapabilityShader, |
| 608 | {SPV_OPERAND_TYPE_NONE}}, |
David Neto | dbaf407 | 2015-09-22 16:23:06 -0400 | [diff] [blame] | 609 | {"NoPerspective", |
| 610 | DecorationNoPerspective, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 611 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 612 | CapabilityShader, |
| 613 | {SPV_OPERAND_TYPE_NONE}}, |
| 614 | {"Flat", |
| 615 | DecorationFlat, |
| 616 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 617 | CapabilityShader, |
| 618 | {SPV_OPERAND_TYPE_NONE}}, |
| 619 | {"Patch", |
| 620 | DecorationPatch, |
| 621 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 622 | CapabilityTessellation, |
| 623 | {SPV_OPERAND_TYPE_NONE}}, |
| 624 | {"Centroid", |
| 625 | DecorationCentroid, |
| 626 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 627 | CapabilityShader, |
| 628 | {SPV_OPERAND_TYPE_NONE}}, |
| 629 | {"Sample", |
| 630 | DecorationSample, |
| 631 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 632 | CapabilityShader, |
| 633 | {SPV_OPERAND_TYPE_NONE}}, |
| 634 | {"Invariant", |
| 635 | DecorationInvariant, |
| 636 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 637 | CapabilityShader, |
| 638 | {SPV_OPERAND_TYPE_NONE}}, |
| 639 | {"Restrict", |
| 640 | DecorationRestrict, |
| 641 | SPV_OPCODE_FLAGS_NONE, |
| 642 | 0, |
| 643 | {SPV_OPERAND_TYPE_NONE}}, |
| 644 | {"Aliased", |
| 645 | DecorationAliased, |
| 646 | SPV_OPCODE_FLAGS_NONE, |
| 647 | 0, |
| 648 | {SPV_OPERAND_TYPE_NONE}}, |
| 649 | {"Volatile", |
| 650 | DecorationVolatile, |
| 651 | SPV_OPCODE_FLAGS_NONE, |
| 652 | 0, |
| 653 | {SPV_OPERAND_TYPE_NONE}}, |
| 654 | {"Constant", |
| 655 | DecorationConstant, |
| 656 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 657 | CapabilityKernel, |
| 658 | {SPV_OPERAND_TYPE_NONE}}, |
| 659 | {"Coherent", |
| 660 | DecorationCoherent, |
| 661 | SPV_OPCODE_FLAGS_NONE, |
| 662 | 0, |
| 663 | {SPV_OPERAND_TYPE_NONE}}, |
David Neto | dbaf407 | 2015-09-22 16:23:06 -0400 | [diff] [blame] | 664 | {"NonWritable", |
| 665 | DecorationNonWritable, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 666 | SPV_OPCODE_FLAGS_NONE, |
| 667 | 0, |
| 668 | {SPV_OPERAND_TYPE_NONE}}, |
David Neto | dbaf407 | 2015-09-22 16:23:06 -0400 | [diff] [blame] | 669 | {"NonReadable", |
| 670 | DecorationNonReadable, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 671 | SPV_OPCODE_FLAGS_NONE, |
| 672 | 0, |
| 673 | {SPV_OPERAND_TYPE_NONE}}, |
| 674 | {"Uniform", |
| 675 | DecorationUniform, |
| 676 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 677 | CapabilityShader, |
| 678 | {SPV_OPERAND_TYPE_NONE}}, |
David Neto | 37547b2 | 2015-09-10 13:23:11 -0400 | [diff] [blame] | 679 | {"SaturatedConversion", |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 680 | DecorationSaturatedConversion, |
| 681 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 682 | CapabilityKernel, |
| 683 | {SPV_OPERAND_TYPE_NONE}}, |
| 684 | {"Stream", |
| 685 | DecorationStream, |
| 686 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 687 | CapabilityGeometry, |
| 688 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
| 689 | {"Location", |
| 690 | DecorationLocation, |
| 691 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 692 | CapabilityShader, |
| 693 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
| 694 | {"Component", |
| 695 | DecorationComponent, |
| 696 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 697 | CapabilityShader, |
| 698 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
| 699 | {"Index", |
| 700 | DecorationIndex, |
| 701 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 702 | CapabilityShader, |
| 703 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
| 704 | {"Binding", |
| 705 | DecorationBinding, |
| 706 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 707 | CapabilityShader, |
| 708 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
| 709 | {"DescriptorSet", |
| 710 | DecorationDescriptorSet, |
| 711 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 712 | CapabilityShader, |
| 713 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
| 714 | {"Offset", |
| 715 | DecorationOffset, |
| 716 | SPV_OPCODE_FLAGS_NONE, |
| 717 | 0, |
| 718 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 719 | {"XfbBuffer", |
| 720 | DecorationXfbBuffer, |
| 721 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 722 | CapabilityShader, |
| 723 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
Lei Zhang | 604e5ce | 2015-08-14 14:46:43 -0400 | [diff] [blame] | 724 | {"XfbStride", |
| 725 | DecorationXfbStride, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 726 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 727 | CapabilityShader, |
| 728 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 729 | {"FuncParamAttr", |
| 730 | DecorationFuncParamAttr, |
| 731 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 732 | CapabilityKernel, |
| 733 | {SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE, SPV_OPERAND_TYPE_NONE}}, |
| 734 | {"FPRoundingMode", |
| 735 | DecorationFPRoundingMode, |
| 736 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 737 | CapabilityKernel, |
| 738 | {SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_NONE}}, |
| 739 | {"FPFastMathMode", |
David Neto | 37547b2 | 2015-09-10 13:23:11 -0400 | [diff] [blame] | 740 | DecorationFPFastMathMode, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 741 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 742 | CapabilityKernel, |
| 743 | {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, SPV_OPERAND_TYPE_NONE}}, |
| 744 | {"LinkageAttributes", |
| 745 | DecorationLinkageAttributes, |
| 746 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 747 | CapabilityLinkage, |
David Neto | 55bdfcb | 2015-09-10 15:51:57 -0400 | [diff] [blame] | 748 | {SPV_OPERAND_TYPE_LITERAL_STRING, SPV_OPERAND_TYPE_LINKAGE_TYPE, SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 749 | }; |
| 750 | |
| 751 | static const spv_operand_desc_t builtInEntries[] = { |
| 752 | {"Position", |
| 753 | BuiltInPosition, |
| 754 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 755 | CapabilityShader, |
| 756 | {SPV_OPERAND_TYPE_NONE}}, |
| 757 | {"PointSize", |
| 758 | BuiltInPointSize, |
| 759 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 760 | CapabilityShader, |
| 761 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 762 | {"ClipDistance", |
| 763 | BuiltInClipDistance, |
| 764 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 765 | CapabilityShader, |
| 766 | {SPV_OPERAND_TYPE_NONE}}, |
| 767 | {"CullDistance", |
| 768 | BuiltInCullDistance, |
| 769 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 770 | CapabilityShader, |
| 771 | {SPV_OPERAND_TYPE_NONE}}, |
| 772 | {"VertexId", |
| 773 | BuiltInVertexId, |
| 774 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 775 | CapabilityShader, |
| 776 | {SPV_OPERAND_TYPE_NONE}}, |
| 777 | {"InstanceId", |
| 778 | BuiltInInstanceId, |
| 779 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 780 | CapabilityShader, |
| 781 | {SPV_OPERAND_TYPE_NONE}}, |
| 782 | {"PrimitiveId", |
| 783 | BuiltInPrimitiveId, |
| 784 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 785 | CapabilityGeometry | CapabilityTessellation, |
| 786 | {SPV_OPERAND_TYPE_NONE}}, |
| 787 | {"InvocationId", |
| 788 | BuiltInInvocationId, |
| 789 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 790 | CapabilityGeometry | CapabilityTessellation, |
| 791 | {SPV_OPERAND_TYPE_NONE}}, |
| 792 | {"Layer", |
| 793 | BuiltInLayer, |
| 794 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 795 | CapabilityGeometry, |
| 796 | {SPV_OPERAND_TYPE_NONE}}, |
| 797 | {"ViewportIndex", |
| 798 | BuiltInViewportIndex, |
| 799 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 800 | CapabilityGeometry, |
| 801 | {SPV_OPERAND_TYPE_NONE}}, |
| 802 | {"TessLevelOuter", |
| 803 | BuiltInTessLevelOuter, |
| 804 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 805 | CapabilityTessellation, |
| 806 | {SPV_OPERAND_TYPE_NONE}}, |
| 807 | {"TessLevelInner", |
| 808 | BuiltInTessLevelInner, |
| 809 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 810 | CapabilityTessellation, |
| 811 | {SPV_OPERAND_TYPE_NONE}}, |
| 812 | {"TessCoord", |
| 813 | BuiltInTessCoord, |
| 814 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 815 | CapabilityTessellation, |
| 816 | {SPV_OPERAND_TYPE_NONE}}, |
| 817 | {"PatchVertices", |
| 818 | BuiltInPatchVertices, |
| 819 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 820 | CapabilityTessellation, |
| 821 | {SPV_OPERAND_TYPE_NONE}}, |
| 822 | {"FragCoord", |
| 823 | BuiltInFragCoord, |
| 824 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 825 | CapabilityShader, |
| 826 | {SPV_OPERAND_TYPE_NONE}}, |
| 827 | {"PointCoord", |
| 828 | BuiltInPointCoord, |
| 829 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 830 | CapabilityShader, |
| 831 | {SPV_OPERAND_TYPE_NONE}}, |
| 832 | {"FrontFacing", |
| 833 | BuiltInFrontFacing, |
| 834 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 835 | CapabilityShader, |
| 836 | {SPV_OPERAND_TYPE_NONE}}, |
| 837 | {"SampleId", |
| 838 | BuiltInSampleId, |
| 839 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 840 | CapabilityShader, |
| 841 | {SPV_OPERAND_TYPE_NONE}}, |
| 842 | {"SamplePosition", |
| 843 | BuiltInSamplePosition, |
| 844 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 845 | CapabilityShader, |
| 846 | {SPV_OPERAND_TYPE_NONE}}, |
| 847 | {"SampleMask", |
| 848 | BuiltInSampleMask, |
| 849 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 850 | CapabilityShader, |
| 851 | {SPV_OPERAND_TYPE_NONE}}, |
| 852 | {"FragColor", |
| 853 | BuiltInFragColor, |
| 854 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 855 | CapabilityShader, |
| 856 | {SPV_OPERAND_TYPE_NONE}}, |
| 857 | {"FragDepth", |
| 858 | BuiltInFragDepth, |
| 859 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 860 | CapabilityShader, |
| 861 | {SPV_OPERAND_TYPE_NONE}}, |
| 862 | {"HelperInvocation", |
| 863 | BuiltInHelperInvocation, |
| 864 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 865 | CapabilityShader, |
| 866 | {SPV_OPERAND_TYPE_NONE}}, |
| 867 | {"NumWorkgroups", |
| 868 | BuiltInNumWorkgroups, |
| 869 | SPV_OPCODE_FLAGS_NONE, |
| 870 | 0, |
| 871 | {SPV_OPERAND_TYPE_NONE}}, |
| 872 | {"WorkgroupSize", |
| 873 | BuiltInWorkgroupSize, |
| 874 | SPV_OPCODE_FLAGS_NONE, |
| 875 | 0, |
| 876 | {SPV_OPERAND_TYPE_NONE}}, |
| 877 | {"WorkgroupId", |
| 878 | BuiltInWorkgroupId, |
| 879 | SPV_OPCODE_FLAGS_NONE, |
| 880 | 0, |
| 881 | {SPV_OPERAND_TYPE_NONE}}, |
| 882 | {"LocalInvocationId", |
| 883 | BuiltInLocalInvocationId, |
| 884 | SPV_OPCODE_FLAGS_NONE, |
| 885 | 0, |
| 886 | {SPV_OPERAND_TYPE_NONE}}, |
| 887 | {"GlobalInvocationId", |
| 888 | BuiltInGlobalInvocationId, |
| 889 | SPV_OPCODE_FLAGS_NONE, |
| 890 | 0, |
| 891 | {SPV_OPERAND_TYPE_NONE}}, |
| 892 | {"LocalInvocationIndex", |
David Neto | 37547b2 | 2015-09-10 13:23:11 -0400 | [diff] [blame] | 893 | BuiltInLocalInvocationIndex, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 894 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 895 | CapabilityShader, |
| 896 | {SPV_OPERAND_TYPE_NONE}}, |
| 897 | {"WorkDim", |
| 898 | BuiltInWorkDim, |
| 899 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 900 | CapabilityKernel, |
| 901 | {SPV_OPERAND_TYPE_NONE}}, |
| 902 | {"GlobalSize", |
| 903 | BuiltInGlobalSize, |
| 904 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 905 | CapabilityKernel, |
| 906 | {SPV_OPERAND_TYPE_NONE}}, |
| 907 | {"EnqueuedWorkgroupSize", |
| 908 | BuiltInEnqueuedWorkgroupSize, |
| 909 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 910 | CapabilityKernel, |
| 911 | {SPV_OPERAND_TYPE_NONE}}, |
| 912 | {"GlobalOffset", |
| 913 | BuiltInGlobalOffset, |
| 914 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 915 | CapabilityKernel, |
| 916 | {SPV_OPERAND_TYPE_NONE}}, |
| 917 | {"GlobalLinearId", |
| 918 | BuiltInGlobalLinearId, |
| 919 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 920 | CapabilityKernel, |
| 921 | {SPV_OPERAND_TYPE_NONE}}, |
| 922 | {"WorkgroupLinearId", |
| 923 | BuiltInWorkgroupLinearId, |
| 924 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 925 | CapabilityKernel, |
| 926 | {SPV_OPERAND_TYPE_NONE}}, |
| 927 | {"SubgroupSize", |
| 928 | BuiltInSubgroupSize, |
| 929 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 930 | CapabilityKernel, |
| 931 | {SPV_OPERAND_TYPE_NONE}}, |
| 932 | {"SubgroupMaxSize", |
| 933 | BuiltInSubgroupMaxSize, |
| 934 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 935 | CapabilityKernel, |
| 936 | {SPV_OPERAND_TYPE_NONE}}, |
| 937 | {"NumSubgroups", |
| 938 | BuiltInNumSubgroups, |
| 939 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 940 | CapabilityKernel, |
| 941 | {SPV_OPERAND_TYPE_NONE}}, |
| 942 | {"NumEnqueuedSubgroups", |
| 943 | BuiltInNumEnqueuedSubgroups, |
| 944 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 945 | CapabilityKernel, |
| 946 | {SPV_OPERAND_TYPE_NONE}}, |
| 947 | {"SubgroupId", |
David Neto | 37547b2 | 2015-09-10 13:23:11 -0400 | [diff] [blame] | 948 | BuiltInSubgroupId, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 949 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 950 | CapabilityKernel, |
| 951 | {SPV_OPERAND_TYPE_NONE}}, |
| 952 | {"SubgroupLocalInvocationId", |
| 953 | BuiltInSubgroupLocalInvocationId, |
| 954 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 955 | CapabilityKernel, |
| 956 | {SPV_OPERAND_TYPE_NONE}}, |
David Neto | 2d1b5e5 | 2015-09-23 15:35:27 -0400 | [diff] [blame] | 957 | {"VertexIndex", |
| 958 | BuiltInVertexIndex, |
| 959 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 960 | CapabilityShader, |
| 961 | {SPV_OPERAND_TYPE_NONE}}, |
| 962 | {"InstanceIndex", |
| 963 | BuiltInInstanceIndex, |
| 964 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 965 | CapabilityShader, |
| 966 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 967 | }; |
| 968 | |
| 969 | static const spv_operand_desc_t selectionControlEntries[] = { |
| 970 | {"None", |
| 971 | SelectionControlMaskNone, |
| 972 | SPV_OPCODE_FLAGS_NONE, |
| 973 | 0, |
| 974 | {SPV_OPERAND_TYPE_NONE}}, |
| 975 | {"Flatten", |
| 976 | SelectionControlFlattenMask, |
| 977 | SPV_OPCODE_FLAGS_NONE, |
| 978 | 0, |
| 979 | {SPV_OPERAND_TYPE_NONE}}, |
| 980 | {"DontFlatten", |
| 981 | SelectionControlDontFlattenMask, |
| 982 | SPV_OPCODE_FLAGS_NONE, |
| 983 | 0, |
| 984 | {SPV_OPERAND_TYPE_NONE}}, |
| 985 | }; |
| 986 | |
| 987 | static const spv_operand_desc_t loopControlEntries[] = { |
| 988 | {"None", |
| 989 | LoopControlMaskNone, |
| 990 | SPV_OPCODE_FLAGS_NONE, |
| 991 | 0, |
| 992 | {SPV_OPERAND_TYPE_NONE}}, |
| 993 | {"Unroll", |
| 994 | LoopControlUnrollMask, |
| 995 | SPV_OPCODE_FLAGS_NONE, |
| 996 | 0, |
| 997 | {SPV_OPERAND_TYPE_NONE}}, |
| 998 | {"DontUnroll", |
| 999 | LoopControlDontUnrollMask, |
| 1000 | SPV_OPCODE_FLAGS_NONE, |
| 1001 | 0, |
| 1002 | {SPV_OPERAND_TYPE_NONE}}, |
| 1003 | }; |
| 1004 | |
| 1005 | static const spv_operand_desc_t functionControlEntries[] = { |
| 1006 | {"None", |
| 1007 | FunctionControlMaskNone, |
| 1008 | SPV_OPCODE_FLAGS_NONE, |
| 1009 | 0, |
| 1010 | {SPV_OPERAND_TYPE_NONE}}, |
David Neto | f4fde6c | 2015-09-14 14:50:37 -0400 | [diff] [blame] | 1011 | {"Inline", |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1012 | FunctionControlInlineMask, |
| 1013 | SPV_OPCODE_FLAGS_NONE, |
| 1014 | 0, |
| 1015 | {SPV_OPERAND_TYPE_NONE}}, |
| 1016 | {"DontInline", |
| 1017 | FunctionControlDontInlineMask, |
| 1018 | SPV_OPCODE_FLAGS_NONE, |
| 1019 | 0, |
| 1020 | {SPV_OPERAND_TYPE_NONE}}, |
| 1021 | {"Pure", |
| 1022 | FunctionControlPureMask, |
| 1023 | SPV_OPCODE_FLAGS_NONE, |
| 1024 | 0, |
| 1025 | {SPV_OPERAND_TYPE_NONE}}, |
| 1026 | {"Const", |
| 1027 | FunctionControlConstMask, |
| 1028 | SPV_OPCODE_FLAGS_NONE, |
| 1029 | 0, |
| 1030 | {SPV_OPERAND_TYPE_NONE}}, |
| 1031 | }; |
| 1032 | |
| 1033 | static const spv_operand_desc_t memorySemanticsEntries[] = { |
| 1034 | {"None", |
| 1035 | MemorySemanticsMaskNone, |
| 1036 | SPV_OPCODE_FLAGS_NONE, |
| 1037 | 0, |
| 1038 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1039 | {"SequentiallyConsistent", |
| 1040 | MemorySemanticsSequentiallyConsistentMask, |
| 1041 | SPV_OPCODE_FLAGS_NONE, |
| 1042 | 0, |
| 1043 | {SPV_OPERAND_TYPE_NONE}}, |
| 1044 | {"Acquire", |
| 1045 | MemorySemanticsAcquireMask, |
| 1046 | SPV_OPCODE_FLAGS_NONE, |
| 1047 | 0, |
| 1048 | {SPV_OPERAND_TYPE_NONE}}, |
| 1049 | {"Release", |
| 1050 | MemorySemanticsReleaseMask, |
| 1051 | SPV_OPCODE_FLAGS_NONE, |
| 1052 | 0, |
| 1053 | {SPV_OPERAND_TYPE_NONE}}, |
| 1054 | {"UniformMemory", |
| 1055 | MemorySemanticsUniformMemoryMask, |
| 1056 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1057 | CapabilityShader, |
| 1058 | {SPV_OPERAND_TYPE_NONE}}, |
| 1059 | {"SubgroupMemory", |
| 1060 | MemorySemanticsSubgroupMemoryMask, |
| 1061 | SPV_OPCODE_FLAGS_NONE, |
| 1062 | 0, |
| 1063 | {SPV_OPERAND_TYPE_NONE}}, |
| 1064 | {"WorkgroupLocalMemory", |
| 1065 | MemorySemanticsWorkgroupLocalMemoryMask, |
| 1066 | SPV_OPCODE_FLAGS_NONE, |
| 1067 | 0, |
| 1068 | {SPV_OPERAND_TYPE_NONE}}, |
| 1069 | {"WorkgroupGlobalMemory", |
| 1070 | MemorySemanticsWorkgroupGlobalMemoryMask, |
| 1071 | SPV_OPCODE_FLAGS_NONE, |
| 1072 | 0, |
| 1073 | {SPV_OPERAND_TYPE_NONE}}, |
| 1074 | {"AtomicCounterMemory", |
| 1075 | MemorySemanticsAtomicCounterMemoryMask, |
| 1076 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1077 | CapabilityShader, |
| 1078 | {SPV_OPERAND_TYPE_NONE}}, |
| 1079 | { |
| 1080 | "ImageMemory", |
| 1081 | MemorySemanticsImageMemoryMask, |
| 1082 | SPV_OPCODE_FLAGS_NONE, |
| 1083 | 0, |
| 1084 | {SPV_OPERAND_TYPE_NONE}, |
| 1085 | }, |
| 1086 | }; |
| 1087 | |
| 1088 | static const spv_operand_desc_t memoryAccessEntries[] = { |
| 1089 | {"None", |
| 1090 | MemoryAccessMaskNone, |
| 1091 | SPV_OPCODE_FLAGS_NONE, |
| 1092 | 0, |
| 1093 | {SPV_OPERAND_TYPE_NONE}}, |
| 1094 | {"Volatile", |
| 1095 | MemoryAccessVolatileMask, |
| 1096 | SPV_OPCODE_FLAGS_NONE, |
| 1097 | 0, |
| 1098 | {SPV_OPERAND_TYPE_NONE}}, |
| 1099 | { |
| 1100 | "Aligned", |
| 1101 | MemoryAccessAlignedMask, |
| 1102 | SPV_OPCODE_FLAGS_NONE, |
| 1103 | 0, |
David Neto | 4a29131 | 2015-09-14 15:08:48 -0400 | [diff] [blame] | 1104 | {SPV_OPERAND_TYPE_LITERAL_NUMBER, SPV_OPERAND_TYPE_NONE}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1105 | }, |
David Neto | 49c299b | 2015-09-23 15:38:59 -0400 | [diff] [blame] | 1106 | {"Nontemporal", |
| 1107 | MemoryAccessNontemporalMask, |
| 1108 | SPV_OPCODE_FLAGS_NONE, |
| 1109 | 0, |
| 1110 | {SPV_OPERAND_TYPE_NONE}}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1111 | }; |
| 1112 | |
| 1113 | static const spv_operand_desc_t scopeEntries[] = { |
| 1114 | {"CrossDevice", |
| 1115 | ScopeCrossDevice, |
| 1116 | SPV_OPCODE_FLAGS_NONE, |
| 1117 | 0, |
| 1118 | {SPV_OPERAND_TYPE_NONE}}, |
| 1119 | {"Device", ScopeDevice, SPV_OPCODE_FLAGS_NONE, 0, {SPV_OPERAND_TYPE_NONE}}, |
| 1120 | {"Workgroup", |
| 1121 | ScopeWorkgroup, |
| 1122 | SPV_OPCODE_FLAGS_NONE, |
| 1123 | 0, |
| 1124 | {SPV_OPERAND_TYPE_NONE}}, |
| 1125 | {"Subgroup", |
| 1126 | ScopeSubgroup, |
| 1127 | SPV_OPCODE_FLAGS_NONE, |
| 1128 | 0, |
| 1129 | {SPV_OPERAND_TYPE_NONE}}, |
| 1130 | { |
| 1131 | "Invocation", |
| 1132 | ScopeInvocation, |
| 1133 | SPV_OPCODE_FLAGS_NONE, |
| 1134 | 0, |
| 1135 | {SPV_OPERAND_TYPE_NONE}, |
| 1136 | }, |
| 1137 | }; |
| 1138 | |
| 1139 | static const spv_operand_desc_t groupOperationEntries[] = { |
| 1140 | {"Reduce", |
| 1141 | GroupOperationReduce, |
| 1142 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1143 | CapabilityKernel, |
| 1144 | {SPV_OPERAND_TYPE_NONE}}, |
| 1145 | {"InclusiveScan", |
| 1146 | GroupOperationInclusiveScan, |
| 1147 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1148 | CapabilityKernel, |
| 1149 | {SPV_OPERAND_TYPE_NONE}}, |
| 1150 | {"ExclusiveScan", |
| 1151 | GroupOperationExclusiveScan, |
| 1152 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1153 | CapabilityKernel, |
| 1154 | {SPV_OPERAND_TYPE_NONE}}, |
| 1155 | }; |
| 1156 | |
| 1157 | static const spv_operand_desc_t kernelKernelEnqueueFlagssEntries[] = { |
| 1158 | {"NoWait", |
| 1159 | KernelEnqueueFlagsNoWait, |
| 1160 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1161 | CapabilityKernel, |
| 1162 | {SPV_OPERAND_TYPE_NONE}}, |
| 1163 | {"WaitKernel", |
| 1164 | KernelEnqueueFlagsWaitKernel, |
| 1165 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1166 | CapabilityKernel, |
| 1167 | {SPV_OPERAND_TYPE_NONE}}, |
| 1168 | {"WaitWorkGroup", |
| 1169 | KernelEnqueueFlagsWaitWorkGroup, |
| 1170 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1171 | CapabilityKernel, |
| 1172 | {SPV_OPERAND_TYPE_NONE}}, |
| 1173 | }; |
| 1174 | |
| 1175 | static const spv_operand_desc_t kernelProfilingInfoEntries[] = { |
| 1176 | {"None", |
| 1177 | KernelProfilingInfoMaskNone, |
| 1178 | SPV_OPCODE_FLAGS_NONE, |
| 1179 | 0, |
| 1180 | {SPV_OPERAND_TYPE_NONE}}, |
| 1181 | {"CmdExecTime", |
| 1182 | KernelProfilingInfoCmdExecTimeMask, |
| 1183 | SPV_OPCODE_FLAGS_CAPABILITIES, |
| 1184 | CapabilityKernel, |
| 1185 | {SPV_OPERAND_TYPE_NONE}}, |
| 1186 | }; |
| 1187 | |
David Neto | d30b233 | 2015-09-23 16:04:24 -0400 | [diff] [blame] | 1188 | // A macro for defining a capability that doesn't depend on another capability. |
| 1189 | #define CASE(NAME) \ |
| 1190 | { \ |
| 1191 | #NAME, Capability##NAME, SPV_OPCODE_FLAGS_NONE, 0, { \ |
| 1192 | SPV_OPERAND_TYPE_NONE \ |
| 1193 | } \ |
| 1194 | } |
| 1195 | |
| 1196 | // A macro for defining a capability that depends on another. |
| 1197 | #define CASE_CAP(NAME, CAP) \ |
| 1198 | { \ |
| 1199 | #NAME, Capability##NAME, SPV_OPCODE_FLAGS_CAPABILITIES, Capability##CAP, { \ |
| 1200 | SPV_OPERAND_TYPE_NONE \ |
| 1201 | } \ |
| 1202 | } |
| 1203 | |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1204 | static const spv_operand_desc_t capabilityInfoEntries[] = { |
David Neto | d30b233 | 2015-09-23 16:04:24 -0400 | [diff] [blame] | 1205 | CASE(Matrix), |
| 1206 | CASE_CAP(Shader, Matrix), |
| 1207 | CASE_CAP(Geometry, Shader), |
| 1208 | CASE_CAP(Tessellation, Shader), |
| 1209 | CASE(Addresses), |
| 1210 | CASE(Linkage), |
| 1211 | CASE(Kernel), |
| 1212 | CASE_CAP(Vector16, Kernel), |
| 1213 | CASE_CAP(Float16Buffer, Kernel), |
| 1214 | CASE_CAP(Float16, Float16Buffer), |
| 1215 | CASE(Float64), |
| 1216 | CASE(Int64), |
| 1217 | CASE_CAP(Int64Atomics, Int64), |
| 1218 | CASE_CAP(ImageBasic, Kernel), |
| 1219 | CASE_CAP(ImageReadWrite, Kernel), |
| 1220 | CASE_CAP(ImageMipmap, Kernel), |
| 1221 | CASE_CAP(ImageSRGBWrite, Kernel), |
| 1222 | CASE_CAP(Pipes, Kernel), |
| 1223 | CASE(Groups), |
| 1224 | CASE_CAP(DeviceEnqueue, Kernel), |
| 1225 | CASE_CAP(LiteralSampler, Kernel), |
| 1226 | CASE_CAP(AtomicStorage, Shader), |
| 1227 | CASE(Int16), |
| 1228 | CASE_CAP(TessellationPointSize, Tessellation), |
| 1229 | CASE_CAP(GeometryPointSize, Geometry), |
| 1230 | CASE_CAP(ImageGatherExtended, Shader), |
| 1231 | CASE_CAP(StorageImageExtendedFormats, Shader), |
| 1232 | CASE_CAP(StorageImageMultisample, Shader), |
| 1233 | CASE_CAP(UniformBufferArrayDynamicIndexing, Shader), |
| 1234 | CASE_CAP(SampledImageArrayDynamicIndexing, Shader), |
| 1235 | CASE_CAP(StorageBufferArrayDynamicIndexing, Shader), |
| 1236 | CASE_CAP(StorageImageArrayDynamicIndexing, Shader), |
| 1237 | CASE_CAP(ClipDistance, Shader), |
| 1238 | CASE_CAP(CullDistance, Shader), |
| 1239 | CASE_CAP(ImageCubeArray, SampledCubeArray), |
| 1240 | CASE_CAP(SampleRateShading, Shader), |
| 1241 | CASE_CAP(ImageRect, SampledRect), |
| 1242 | CASE_CAP(SampledRect, Shader), |
| 1243 | CASE_CAP(GenericPointer, Addresses), |
| 1244 | CASE_CAP(Int8, Kernel), |
| 1245 | CASE_CAP(InputTarget, Shader), |
| 1246 | CASE_CAP(SparseResidency, Shader), |
| 1247 | CASE_CAP(MinLod, Shader), |
| 1248 | CASE_CAP(Sampled1D, Shader), |
| 1249 | CASE_CAP(Image1D, Sampled1D), |
| 1250 | CASE_CAP(SampledCubeArray, Shader), |
| 1251 | CASE_CAP(SampledBuffer, Shader), |
| 1252 | CASE_CAP(ImageBuffer, SampledBuffer), |
| 1253 | CASE_CAP(ImageMSArray, Shader), |
| 1254 | CASE_CAP(AdvancedFormats, Shader), |
| 1255 | CASE_CAP(ImageQuery, Shader), |
| 1256 | CASE_CAP(DerivativeControl, Shader), |
| 1257 | CASE_CAP(InterpolationFunction, Shader), |
| 1258 | CASE_CAP(TransformFeedback, Shader), |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1259 | }; |
David Neto | d30b233 | 2015-09-23 16:04:24 -0400 | [diff] [blame] | 1260 | #undef CASE |
| 1261 | #undef CASE_CAP |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1262 | |
| 1263 | static const spv_operand_desc_group_t opcodeEntryTypes[] = { |
| 1264 | {SPV_OPERAND_TYPE_SOURCE_LANGUAGE, |
| 1265 | sizeof(sourceLanguageEntries) / sizeof(spv_operand_desc_t), |
| 1266 | sourceLanguageEntries}, |
| 1267 | {SPV_OPERAND_TYPE_EXECUTION_MODEL, |
| 1268 | sizeof(executionModelEntries) / sizeof(spv_operand_desc_t), |
| 1269 | executionModelEntries}, |
| 1270 | {SPV_OPERAND_TYPE_ADDRESSING_MODEL, |
| 1271 | sizeof(addressingModelEntries) / sizeof(spv_operand_desc_t), |
| 1272 | addressingModelEntries}, |
| 1273 | {SPV_OPERAND_TYPE_MEMORY_MODEL, |
| 1274 | sizeof(memoryModelEntries) / sizeof(spv_operand_desc_t), |
| 1275 | memoryModelEntries}, |
| 1276 | {SPV_OPERAND_TYPE_EXECUTION_MODE, |
| 1277 | sizeof(executionModeEntries) / sizeof(spv_operand_desc_t), |
| 1278 | executionModeEntries}, |
| 1279 | {SPV_OPERAND_TYPE_STORAGE_CLASS, |
| 1280 | sizeof(storageClassEntries) / sizeof(spv_operand_desc_t), |
| 1281 | storageClassEntries}, |
| 1282 | {SPV_OPERAND_TYPE_DIMENSIONALITY, |
| 1283 | sizeof(dimensionalityEntries) / sizeof(spv_operand_desc_t), |
| 1284 | dimensionalityEntries}, |
| 1285 | {SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE, |
| 1286 | sizeof(samplerAddressingModeEntries) / sizeof(spv_operand_desc_t), |
| 1287 | samplerAddressingModeEntries}, |
| 1288 | {SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE, |
| 1289 | sizeof(samplerFilterModeEntries) / sizeof(spv_operand_desc_t), |
| 1290 | samplerFilterModeEntries}, |
David Neto | b30a0c5 | 2015-09-16 15:56:43 -0400 | [diff] [blame] | 1291 | {SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT, |
| 1292 | sizeof(samplerImageFormatEntries) / sizeof(spv_operand_desc_t), |
| 1293 | samplerImageFormatEntries}, |
David Neto | ee1b3bb | 2015-09-18 11:19:18 -0400 | [diff] [blame] | 1294 | {SPV_OPERAND_TYPE_OPTIONAL_IMAGE, |
| 1295 | sizeof(imageOperandEntries) / sizeof(spv_operand_desc_t), |
| 1296 | imageOperandEntries}, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1297 | {SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, |
| 1298 | sizeof(fpFastMathModeEntries) / sizeof(spv_operand_desc_t), |
| 1299 | fpFastMathModeEntries}, |
| 1300 | {SPV_OPERAND_TYPE_FP_ROUNDING_MODE, |
| 1301 | sizeof(fpRoundingModeEntries) / sizeof(spv_operand_desc_t), |
| 1302 | fpRoundingModeEntries}, |
| 1303 | {SPV_OPERAND_TYPE_LINKAGE_TYPE, |
| 1304 | sizeof(linkageTypeEntries) / sizeof(spv_operand_desc_t), |
| 1305 | linkageTypeEntries}, |
| 1306 | {SPV_OPERAND_TYPE_ACCESS_QUALIFIER, |
| 1307 | sizeof(accessQualifierEntries) / sizeof(spv_operand_desc_t), |
| 1308 | accessQualifierEntries}, |
| 1309 | {SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE, |
| 1310 | sizeof(functionParameterAttributeEntries) / sizeof(spv_operand_desc_t), |
| 1311 | functionParameterAttributeEntries}, |
| 1312 | {SPV_OPERAND_TYPE_DECORATION, |
| 1313 | sizeof(decorationEntries) / sizeof(spv_operand_desc_t), decorationEntries}, |
| 1314 | {SPV_OPERAND_TYPE_BUILT_IN, |
| 1315 | sizeof(builtInEntries) / sizeof(spv_operand_desc_t), builtInEntries}, |
| 1316 | {SPV_OPERAND_TYPE_SELECTION_CONTROL, |
| 1317 | sizeof(selectionControlEntries) / sizeof(spv_operand_desc_t), |
| 1318 | selectionControlEntries}, |
| 1319 | {SPV_OPERAND_TYPE_LOOP_CONTROL, |
| 1320 | sizeof(loopControlEntries) / sizeof(spv_operand_desc_t), |
| 1321 | loopControlEntries}, |
| 1322 | {SPV_OPERAND_TYPE_FUNCTION_CONTROL, |
| 1323 | sizeof(functionControlEntries) / sizeof(spv_operand_desc_t), |
| 1324 | functionControlEntries}, |
| 1325 | {SPV_OPERAND_TYPE_MEMORY_SEMANTICS, |
| 1326 | sizeof(memorySemanticsEntries) / sizeof(spv_operand_desc_t), |
| 1327 | memorySemanticsEntries}, |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 1328 | {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1329 | sizeof(memoryAccessEntries) / sizeof(spv_operand_desc_t), |
| 1330 | memoryAccessEntries}, |
| 1331 | {SPV_OPERAND_TYPE_EXECUTION_SCOPE, |
| 1332 | sizeof(scopeEntries) / sizeof(spv_operand_desc_t), scopeEntries}, |
| 1333 | {SPV_OPERAND_TYPE_GROUP_OPERATION, |
| 1334 | sizeof(groupOperationEntries) / sizeof(spv_operand_desc_t), |
| 1335 | groupOperationEntries}, |
| 1336 | {SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS, |
| 1337 | sizeof(kernelKernelEnqueueFlagssEntries) / sizeof(spv_operand_desc_t), |
| 1338 | kernelKernelEnqueueFlagssEntries}, |
David Neto | 4799482 | 2015-08-27 13:11:01 -0400 | [diff] [blame] | 1339 | {SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1340 | sizeof(kernelProfilingInfoEntries) / sizeof(spv_operand_desc_t), |
| 1341 | kernelProfilingInfoEntries}, |
| 1342 | {SPV_OPERAND_TYPE_CAPABILITY, |
| 1343 | sizeof(capabilityInfoEntries) / sizeof(spv_operand_desc_t), |
| 1344 | capabilityInfoEntries}, |
| 1345 | }; |
| 1346 | |
| 1347 | spv_result_t spvOperandTableGet(spv_operand_table *pOperandTable) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 1348 | if (!pOperandTable) return SPV_ERROR_INVALID_POINTER; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1349 | |
| 1350 | static const spv_operand_table_t table = { |
| 1351 | sizeof(opcodeEntryTypes) / sizeof(spv_operand_desc_group_t), |
| 1352 | opcodeEntryTypes}; |
| 1353 | |
| 1354 | *pOperandTable = &table; |
| 1355 | |
| 1356 | return SPV_SUCCESS; |
| 1357 | } |
| 1358 | |
| 1359 | spv_result_t spvOperandTableNameLookup(const spv_operand_table table, |
| 1360 | const spv_operand_type_t type, |
David Neto | 388c40d | 2015-09-16 16:42:56 -0400 | [diff] [blame] | 1361 | const char* name, |
| 1362 | const size_t nameLength, |
| 1363 | spv_operand_desc* pEntry) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 1364 | if (!table) return SPV_ERROR_INVALID_TABLE; |
| 1365 | if (!name || !pEntry) return SPV_ERROR_INVALID_POINTER; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1366 | |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1367 | for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) { |
| 1368 | if (type == table->types[typeIndex].type) { |
| 1369 | for (uint64_t operandIndex = 0; |
| 1370 | operandIndex < table->types[typeIndex].count; ++operandIndex) { |
| 1371 | if (nameLength == |
| 1372 | strlen(table->types[typeIndex].entries[operandIndex].name) && |
| 1373 | !strncmp(table->types[typeIndex].entries[operandIndex].name, name, |
David Neto | 388c40d | 2015-09-16 16:42:56 -0400 | [diff] [blame] | 1374 | nameLength)) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1375 | *pEntry = &table->types[typeIndex].entries[operandIndex]; |
| 1376 | return SPV_SUCCESS; |
| 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | } |
| 1381 | |
| 1382 | return SPV_ERROR_INVALID_LOOKUP; |
| 1383 | } |
| 1384 | |
| 1385 | spv_result_t spvOperandTableValueLookup(const spv_operand_table table, |
| 1386 | const spv_operand_type_t type, |
| 1387 | const uint32_t value, |
| 1388 | spv_operand_desc *pEntry) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 1389 | if (!table) return SPV_ERROR_INVALID_TABLE; |
| 1390 | if (!pEntry) return SPV_ERROR_INVALID_POINTER; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1391 | |
| 1392 | for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) { |
| 1393 | if (type == table->types[typeIndex].type) { |
| 1394 | for (uint64_t operandIndex = 0; |
| 1395 | operandIndex < table->types[typeIndex].count; ++operandIndex) { |
| 1396 | if (value == table->types[typeIndex].entries[operandIndex].value) { |
| 1397 | *pEntry = &table->types[typeIndex].entries[operandIndex]; |
| 1398 | return SPV_SUCCESS; |
| 1399 | } |
| 1400 | } |
| 1401 | } |
| 1402 | } |
| 1403 | |
| 1404 | return SPV_ERROR_INVALID_LOOKUP; |
| 1405 | } |
| 1406 | |
| 1407 | const char *spvOperandTypeStr(spv_operand_type_t type) { |
| 1408 | switch (type) { |
| 1409 | case SPV_OPERAND_TYPE_ID: |
David Neto | fadbf62 | 2015-09-14 17:07:11 -0400 | [diff] [blame] | 1410 | case SPV_OPERAND_TYPE_OPTIONAL_ID: |
| 1411 | case SPV_OPERAND_TYPE_ID_IN_OPTIONAL_TUPLE: |
| 1412 | return "ID"; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1413 | case SPV_OPERAND_TYPE_RESULT_ID: |
| 1414 | return "result ID"; |
| 1415 | case SPV_OPERAND_TYPE_LITERAL: |
| 1416 | return "literal"; |
| 1417 | case SPV_OPERAND_TYPE_LITERAL_NUMBER: |
| 1418 | return "literal number"; |
Lei Zhang | b41d150 | 2015-09-14 15:22:23 -0400 | [diff] [blame] | 1419 | case SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER: |
| 1420 | return "multiple word literal number"; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1421 | case SPV_OPERAND_TYPE_LITERAL_STRING: |
| 1422 | return "literal string"; |
| 1423 | case SPV_OPERAND_TYPE_SOURCE_LANGUAGE: |
| 1424 | return "source langauge"; |
| 1425 | case SPV_OPERAND_TYPE_EXECUTION_MODEL: |
| 1426 | return "execution model"; |
| 1427 | case SPV_OPERAND_TYPE_ADDRESSING_MODEL: |
| 1428 | return "addressing model"; |
| 1429 | case SPV_OPERAND_TYPE_MEMORY_MODEL: |
| 1430 | return "memory model"; |
| 1431 | case SPV_OPERAND_TYPE_EXECUTION_MODE: |
| 1432 | return "execution mode"; |
| 1433 | case SPV_OPERAND_TYPE_STORAGE_CLASS: |
| 1434 | return "storage class"; |
| 1435 | case SPV_OPERAND_TYPE_DIMENSIONALITY: |
| 1436 | return "dimensionality"; |
| 1437 | case SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE: |
| 1438 | return "addressing mode"; |
| 1439 | case SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE: |
| 1440 | return "sampler filter mode"; |
David Neto | b30a0c5 | 2015-09-16 15:56:43 -0400 | [diff] [blame] | 1441 | case SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT: |
| 1442 | return "sampler image format"; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1443 | case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE: |
| 1444 | return "floating pointer fast math mode"; |
| 1445 | case SPV_OPERAND_TYPE_FP_ROUNDING_MODE: |
| 1446 | return "floating point rounding mode"; |
| 1447 | case SPV_OPERAND_TYPE_LINKAGE_TYPE: |
| 1448 | return "linkage type"; |
| 1449 | case SPV_OPERAND_TYPE_ACCESS_QUALIFIER: |
| 1450 | return "access qualifier"; |
| 1451 | case SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE: |
| 1452 | return "function parameter attribute"; |
| 1453 | case SPV_OPERAND_TYPE_DECORATION: |
| 1454 | return "decoration"; |
| 1455 | case SPV_OPERAND_TYPE_BUILT_IN: |
| 1456 | return "built in"; |
| 1457 | case SPV_OPERAND_TYPE_SELECTION_CONTROL: |
| 1458 | return "selection control"; |
| 1459 | case SPV_OPERAND_TYPE_LOOP_CONTROL: |
| 1460 | return "loop control"; |
| 1461 | case SPV_OPERAND_TYPE_FUNCTION_CONTROL: |
| 1462 | return "function control"; |
| 1463 | case SPV_OPERAND_TYPE_MEMORY_SEMANTICS: |
| 1464 | return "memory semantics"; |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 1465 | case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1466 | return "memory access"; |
| 1467 | case SPV_OPERAND_TYPE_EXECUTION_SCOPE: |
David Neto | fadbf62 | 2015-09-14 17:07:11 -0400 | [diff] [blame] | 1468 | return "execution scope ID"; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1469 | case SPV_OPERAND_TYPE_GROUP_OPERATION: |
| 1470 | return "group operation"; |
| 1471 | case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS: |
| 1472 | return "kernel enqeue flags"; |
David Neto | 4799482 | 2015-08-27 13:11:01 -0400 | [diff] [blame] | 1473 | case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1474 | return "kernel profiling info"; |
| 1475 | case SPV_OPERAND_TYPE_CAPABILITY: |
| 1476 | return "capability"; |
David Neto | ee1b3bb | 2015-09-18 11:19:18 -0400 | [diff] [blame] | 1477 | case SPV_OPERAND_TYPE_OPTIONAL_IMAGE: |
| 1478 | return "image operand"; |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 1479 | case SPV_OPERAND_TYPE_NONE: |
| 1480 | return "NONE"; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1481 | default: |
| 1482 | assert(0 && "Unhandled operand type!"); |
| 1483 | break; |
| 1484 | } |
| 1485 | return "unknown"; |
| 1486 | } |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 1487 | |
| 1488 | void spvPrependOperandTypes(const spv_operand_type_t* types, |
| 1489 | spv_operand_pattern_t* pattern) { |
| 1490 | const spv_operand_type_t* endTypes; |
| 1491 | for (endTypes = types ; *endTypes != SPV_OPERAND_TYPE_NONE ; ++endTypes) |
| 1492 | ; |
| 1493 | pattern->insert(pattern->begin(), types, endTypes); |
| 1494 | } |
| 1495 | |
David Neto | 5bf88fc | 2015-09-17 17:06:10 -0400 | [diff] [blame] | 1496 | void spvPrependOperandTypesForMask(const spv_operand_table operandTable, |
| 1497 | const spv_operand_type_t type, |
| 1498 | const uint32_t mask, |
| 1499 | spv_operand_pattern_t* pattern) { |
| 1500 | // Scan from highest bits to lowest bits because we will prepend in LIFO |
| 1501 | // fashion, and we need the operands for lower order bits to appear first. |
| 1502 | for (uint32_t candidate_bit = (1 << 31); candidate_bit; candidate_bit >>= 1) { |
| 1503 | if (candidate_bit & mask) { |
| 1504 | spv_operand_desc entry = nullptr; |
| 1505 | if (SPV_SUCCESS == spvOperandTableValueLookup(operandTable, type, |
| 1506 | candidate_bit, &entry)) { |
| 1507 | spvPrependOperandTypes(entry->operandTypes, pattern); |
| 1508 | } |
| 1509 | } |
| 1510 | } |
| 1511 | } |
| 1512 | |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 1513 | bool spvOperandIsOptional(spv_operand_type_t type) { |
| 1514 | // Variable means zero or more times. |
| 1515 | if (spvOperandIsVariable(type)) |
| 1516 | return true; |
| 1517 | |
| 1518 | switch (type) { |
| 1519 | case SPV_OPERAND_TYPE_OPTIONAL_ID: |
| 1520 | case SPV_OPERAND_TYPE_OPTIONAL_IMAGE: |
| 1521 | case SPV_OPERAND_TYPE_OPTIONAL_LITERAL: |
| 1522 | case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING: |
| 1523 | case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS: |
| 1524 | case SPV_OPERAND_TYPE_OPTIONAL_EXECUTION_MODE: |
| 1525 | return true; |
| 1526 | default: |
| 1527 | break; |
| 1528 | } |
| 1529 | return false; |
| 1530 | } |
| 1531 | |
| 1532 | bool spvOperandIsVariable(spv_operand_type_t type) { |
| 1533 | switch (type) { |
| 1534 | case SPV_OPERAND_TYPE_VARIABLE_ID: |
| 1535 | case SPV_OPERAND_TYPE_VARIABLE_LITERAL: |
| 1536 | case SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL: |
| 1537 | case SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID: |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 1538 | case SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE: |
| 1539 | return true; |
| 1540 | default: |
| 1541 | break; |
| 1542 | } |
| 1543 | return false; |
| 1544 | } |
| 1545 | |
| 1546 | |
| 1547 | bool spvExpandOperandSequenceOnce(spv_operand_type_t type, |
| 1548 | spv_operand_pattern_t* pattern) { |
| 1549 | switch (type) { |
| 1550 | case SPV_OPERAND_TYPE_VARIABLE_ID: |
| 1551 | pattern->insert(pattern->begin(), {SPV_OPERAND_TYPE_OPTIONAL_ID, type}); |
| 1552 | return true; |
| 1553 | case SPV_OPERAND_TYPE_VARIABLE_LITERAL: |
| 1554 | pattern->insert(pattern->begin(), |
| 1555 | {SPV_OPERAND_TYPE_OPTIONAL_LITERAL, type}); |
| 1556 | return true; |
| 1557 | case SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID: |
| 1558 | // Represents Zero or more (Literal, Id) pairs. |
| 1559 | pattern->insert(pattern->begin(), |
| 1560 | {SPV_OPERAND_TYPE_OPTIONAL_LITERAL, |
| 1561 | SPV_OPERAND_TYPE_ID_IN_OPTIONAL_TUPLE, type}); |
| 1562 | return true; |
| 1563 | case SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL: |
| 1564 | // Represents Zero or more (Id, Literal) pairs. |
| 1565 | pattern->insert(pattern->begin(), |
| 1566 | {SPV_OPERAND_TYPE_OPTIONAL_ID, |
| 1567 | SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE, type}); |
| 1568 | return true; |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 1569 | case SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE: |
| 1570 | pattern->insert(pattern->begin(), {SPV_OPERAND_TYPE_OPTIONAL_EXECUTION_MODE, type}); |
| 1571 | return true; |
| 1572 | default: |
| 1573 | break; |
| 1574 | } |
| 1575 | return false; |
| 1576 | } |
| 1577 | |
| 1578 | spv_operand_type_t spvTakeFirstMatchableOperand(spv_operand_pattern_t* pattern) { |
| 1579 | assert(!pattern->empty()); |
| 1580 | spv_operand_type_t result; |
| 1581 | do { |
| 1582 | result = pattern->front(); |
| 1583 | pattern->pop_front(); |
| 1584 | } while(spvExpandOperandSequenceOnce(result, pattern)); |
| 1585 | return result; |
| 1586 | } |