• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by gen_spirv_builder_and_parser.py using data from spirv.core.grammar.json.
3 //
4 // Copyright 2021 The ANGLE Project Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style license that can be
6 // found in the LICENSE file.
7 //
8 // spirv_instruction_builder_autogen.cpp:
9 //   Functions to generate SPIR-V binary for each instruction.
10 
11 #include "spirv_instruction_builder_autogen.h"
12 
13 #include <string.h>
14 
15 #include "common/debug.h"
16 
17 namespace angle
18 {
19 namespace spirv
20 {
21 namespace
22 {
MakeLengthOp(size_t length,spv::Op op)23 uint32_t MakeLengthOp(size_t length, spv::Op op)
24 {
25     ASSERT(length <= 0xFFFFu);
26     ASSERT(op <= 0xFFFFu);
27 
28     return static_cast<uint32_t>(length) << 16 | op;
29 }
30 }  // anonymous namespace
31 
WriteSpirvHeader(std::vector<uint32_t> * blob,uint32_t idCount)32 void WriteSpirvHeader(std::vector<uint32_t> *blob, uint32_t idCount)
33 {
34     // Header:
35     //
36     //  - Magic number
37     //  - Version (1.0)
38     //  - ANGLE's Generator number:
39     //     * 24 for tool id (higher 16 bits)
40     //     * 0 for tool version (lower 16 bits))
41     //  - Bound (idCount)
42     //  - 0 (reserved)
43     constexpr uint32_t kANGLEGeneratorId = 24;
44 
45     ASSERT(blob->empty());
46 
47     blob->push_back(spv::MagicNumber);
48     blob->push_back(0x00010000);
49     blob->push_back(kANGLEGeneratorId << 16 | 0);
50     blob->push_back(idCount);
51     blob->push_back(0x00000000);
52 }
53 
WriteNop(Blob * blob)54 void WriteNop(Blob *blob)
55 {
56     const size_t startSize = blob->size();
57     blob->push_back(0);
58 
59     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpNop);
60 }
WriteUndef(Blob * blob,IdResultType idResultType,IdResult idResult)61 void WriteUndef(Blob *blob, IdResultType idResultType, IdResult idResult)
62 {
63     const size_t startSize = blob->size();
64     blob->push_back(0);
65     blob->push_back(idResultType);
66     blob->push_back(idResult);
67     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUndef);
68 }
WriteSourceContinued(Blob * blob,LiteralString continuedSource)69 void WriteSourceContinued(Blob *blob, LiteralString continuedSource)
70 {
71     const size_t startSize = blob->size();
72     blob->push_back(0);
73     {
74         size_t d = blob->size();
75         blob->resize(d + strlen(continuedSource) / 4 + 1, 0);
76         ASSERT(IsLittleEndian());
77         strcpy(reinterpret_cast<char *>(blob->data() + d), continuedSource);
78     }
79     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSourceContinued);
80 }
WriteSource(Blob * blob,spv::SourceLanguage sourceLanguage,LiteralInteger version,const IdRef * file,const LiteralString * source)81 void WriteSource(Blob *blob,
82                  spv::SourceLanguage sourceLanguage,
83                  LiteralInteger version,
84                  const IdRef *file,
85                  const LiteralString *source)
86 {
87     const size_t startSize = blob->size();
88     blob->push_back(0);
89     blob->push_back(sourceLanguage);
90     blob->push_back(version);
91     if (file)
92     {
93         blob->push_back(*file);
94     }
95     if (source)
96     {
97         {
98             size_t d = blob->size();
99             blob->resize(d + strlen(*source) / 4 + 1, 0);
100             ASSERT(IsLittleEndian());
101             strcpy(reinterpret_cast<char *>(blob->data() + d), *source);
102         }
103     }
104     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSource);
105 }
WriteSourceExtension(Blob * blob,LiteralString extension)106 void WriteSourceExtension(Blob *blob, LiteralString extension)
107 {
108     const size_t startSize = blob->size();
109     blob->push_back(0);
110     {
111         size_t d = blob->size();
112         blob->resize(d + strlen(extension) / 4 + 1, 0);
113         ASSERT(IsLittleEndian());
114         strcpy(reinterpret_cast<char *>(blob->data() + d), extension);
115     }
116     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSourceExtension);
117 }
WriteName(Blob * blob,IdRef target,LiteralString name)118 void WriteName(Blob *blob, IdRef target, LiteralString name)
119 {
120     const size_t startSize = blob->size();
121     blob->push_back(0);
122     blob->push_back(target);
123     {
124         size_t d = blob->size();
125         blob->resize(d + strlen(name) / 4 + 1, 0);
126         ASSERT(IsLittleEndian());
127         strcpy(reinterpret_cast<char *>(blob->data() + d), name);
128     }
129     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpName);
130 }
WriteMemberName(Blob * blob,IdRef type,LiteralInteger member,LiteralString name)131 void WriteMemberName(Blob *blob, IdRef type, LiteralInteger member, LiteralString name)
132 {
133     const size_t startSize = blob->size();
134     blob->push_back(0);
135     blob->push_back(type);
136     blob->push_back(member);
137     {
138         size_t d = blob->size();
139         blob->resize(d + strlen(name) / 4 + 1, 0);
140         ASSERT(IsLittleEndian());
141         strcpy(reinterpret_cast<char *>(blob->data() + d), name);
142     }
143     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMemberName);
144 }
WriteString(Blob * blob,IdResult idResult,LiteralString string)145 void WriteString(Blob *blob, IdResult idResult, LiteralString string)
146 {
147     const size_t startSize = blob->size();
148     blob->push_back(0);
149     blob->push_back(idResult);
150     {
151         size_t d = blob->size();
152         blob->resize(d + strlen(string) / 4 + 1, 0);
153         ASSERT(IsLittleEndian());
154         strcpy(reinterpret_cast<char *>(blob->data() + d), string);
155     }
156     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpString);
157 }
WriteLine(Blob * blob,IdRef file,LiteralInteger line,LiteralInteger column)158 void WriteLine(Blob *blob, IdRef file, LiteralInteger line, LiteralInteger column)
159 {
160     const size_t startSize = blob->size();
161     blob->push_back(0);
162     blob->push_back(file);
163     blob->push_back(line);
164     blob->push_back(column);
165     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLine);
166 }
WriteExtension(Blob * blob,LiteralString name)167 void WriteExtension(Blob *blob, LiteralString name)
168 {
169     const size_t startSize = blob->size();
170     blob->push_back(0);
171     {
172         size_t d = blob->size();
173         blob->resize(d + strlen(name) / 4 + 1, 0);
174         ASSERT(IsLittleEndian());
175         strcpy(reinterpret_cast<char *>(blob->data() + d), name);
176     }
177     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExtension);
178 }
WriteExtInstImport(Blob * blob,IdResult idResult,LiteralString name)179 void WriteExtInstImport(Blob *blob, IdResult idResult, LiteralString name)
180 {
181     const size_t startSize = blob->size();
182     blob->push_back(0);
183     blob->push_back(idResult);
184     {
185         size_t d = blob->size();
186         blob->resize(d + strlen(name) / 4 + 1, 0);
187         ASSERT(IsLittleEndian());
188         strcpy(reinterpret_cast<char *>(blob->data() + d), name);
189     }
190     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExtInstImport);
191 }
WriteExtInst(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef set,LiteralExtInstInteger instruction,const IdRefList & operandList)192 void WriteExtInst(Blob *blob,
193                   IdResultType idResultType,
194                   IdResult idResult,
195                   IdRef set,
196                   LiteralExtInstInteger instruction,
197                   const IdRefList &operandList)
198 {
199     const size_t startSize = blob->size();
200     blob->push_back(0);
201     blob->push_back(idResultType);
202     blob->push_back(idResult);
203     blob->push_back(set);
204     blob->push_back(instruction);
205     for (const auto &operand : operandList)
206     {
207         blob->push_back(operand);
208     }
209     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExtInst);
210 }
WriteMemoryModel(Blob * blob,spv::AddressingModel addressingModel,spv::MemoryModel memoryModel)211 void WriteMemoryModel(Blob *blob,
212                       spv::AddressingModel addressingModel,
213                       spv::MemoryModel memoryModel)
214 {
215     const size_t startSize = blob->size();
216     blob->push_back(0);
217     blob->push_back(addressingModel);
218     blob->push_back(memoryModel);
219     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMemoryModel);
220 }
WriteEntryPoint(Blob * blob,spv::ExecutionModel executionModel,IdRef entryPoint,LiteralString name,const IdRefList & interfaceList)221 void WriteEntryPoint(Blob *blob,
222                      spv::ExecutionModel executionModel,
223                      IdRef entryPoint,
224                      LiteralString name,
225                      const IdRefList &interfaceList)
226 {
227     const size_t startSize = blob->size();
228     blob->push_back(0);
229     blob->push_back(executionModel);
230     blob->push_back(entryPoint);
231     {
232         size_t d = blob->size();
233         blob->resize(d + strlen(name) / 4 + 1, 0);
234         ASSERT(IsLittleEndian());
235         strcpy(reinterpret_cast<char *>(blob->data() + d), name);
236     }
237     for (const auto &operand : interfaceList)
238     {
239         blob->push_back(operand);
240     }
241     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEntryPoint);
242 }
WriteExecutionMode(Blob * blob,IdRef entryPoint,spv::ExecutionMode mode,const LiteralIntegerList & operandsList)243 void WriteExecutionMode(Blob *blob,
244                         IdRef entryPoint,
245                         spv::ExecutionMode mode,
246                         const LiteralIntegerList &operandsList)
247 {
248     const size_t startSize = blob->size();
249     blob->push_back(0);
250     blob->push_back(entryPoint);
251     blob->push_back(mode);
252     for (const auto &operand : operandsList)
253     {
254         blob->push_back(operand);
255     }
256     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExecutionMode);
257 }
WriteCapability(Blob * blob,spv::Capability capability)258 void WriteCapability(Blob *blob, spv::Capability capability)
259 {
260     const size_t startSize = blob->size();
261     blob->push_back(0);
262     blob->push_back(capability);
263     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCapability);
264 }
WriteTypeVoid(Blob * blob,IdResult idResult)265 void WriteTypeVoid(Blob *blob, IdResult idResult)
266 {
267     const size_t startSize = blob->size();
268     blob->push_back(0);
269     blob->push_back(idResult);
270     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeVoid);
271 }
WriteTypeBool(Blob * blob,IdResult idResult)272 void WriteTypeBool(Blob *blob, IdResult idResult)
273 {
274     const size_t startSize = blob->size();
275     blob->push_back(0);
276     blob->push_back(idResult);
277     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeBool);
278 }
WriteTypeInt(Blob * blob,IdResult idResult,LiteralInteger width,LiteralInteger signedness)279 void WriteTypeInt(Blob *blob, IdResult idResult, LiteralInteger width, LiteralInteger signedness)
280 {
281     const size_t startSize = blob->size();
282     blob->push_back(0);
283     blob->push_back(idResult);
284     blob->push_back(width);
285     blob->push_back(signedness);
286     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeInt);
287 }
WriteTypeFloat(Blob * blob,IdResult idResult,LiteralInteger width)288 void WriteTypeFloat(Blob *blob, IdResult idResult, LiteralInteger width)
289 {
290     const size_t startSize = blob->size();
291     blob->push_back(0);
292     blob->push_back(idResult);
293     blob->push_back(width);
294     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeFloat);
295 }
WriteTypeVector(Blob * blob,IdResult idResult,IdRef componentType,LiteralInteger componentCount)296 void WriteTypeVector(Blob *blob,
297                      IdResult idResult,
298                      IdRef componentType,
299                      LiteralInteger componentCount)
300 {
301     const size_t startSize = blob->size();
302     blob->push_back(0);
303     blob->push_back(idResult);
304     blob->push_back(componentType);
305     blob->push_back(componentCount);
306     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeVector);
307 }
WriteTypeMatrix(Blob * blob,IdResult idResult,IdRef columnType,LiteralInteger columnCount)308 void WriteTypeMatrix(Blob *blob, IdResult idResult, IdRef columnType, LiteralInteger columnCount)
309 {
310     const size_t startSize = blob->size();
311     blob->push_back(0);
312     blob->push_back(idResult);
313     blob->push_back(columnType);
314     blob->push_back(columnCount);
315     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeMatrix);
316 }
WriteTypeImage(Blob * blob,IdResult idResult,IdRef sampledType,spv::Dim dim,LiteralInteger depth,LiteralInteger arrayed,LiteralInteger mS,LiteralInteger sampled,spv::ImageFormat imageFormat,const spv::AccessQualifier * accessQualifier)317 void WriteTypeImage(Blob *blob,
318                     IdResult idResult,
319                     IdRef sampledType,
320                     spv::Dim dim,
321                     LiteralInteger depth,
322                     LiteralInteger arrayed,
323                     LiteralInteger mS,
324                     LiteralInteger sampled,
325                     spv::ImageFormat imageFormat,
326                     const spv::AccessQualifier *accessQualifier)
327 {
328     const size_t startSize = blob->size();
329     blob->push_back(0);
330     blob->push_back(idResult);
331     blob->push_back(sampledType);
332     blob->push_back(dim);
333     blob->push_back(depth);
334     blob->push_back(arrayed);
335     blob->push_back(mS);
336     blob->push_back(sampled);
337     blob->push_back(imageFormat);
338     if (accessQualifier)
339     {
340         blob->push_back(*accessQualifier);
341     }
342     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeImage);
343 }
WriteTypeSampler(Blob * blob,IdResult idResult)344 void WriteTypeSampler(Blob *blob, IdResult idResult)
345 {
346     const size_t startSize = blob->size();
347     blob->push_back(0);
348     blob->push_back(idResult);
349     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeSampler);
350 }
WriteTypeSampledImage(Blob * blob,IdResult idResult,IdRef imageType)351 void WriteTypeSampledImage(Blob *blob, IdResult idResult, IdRef imageType)
352 {
353     const size_t startSize = blob->size();
354     blob->push_back(0);
355     blob->push_back(idResult);
356     blob->push_back(imageType);
357     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeSampledImage);
358 }
WriteTypeArray(Blob * blob,IdResult idResult,IdRef elementType,IdRef length)359 void WriteTypeArray(Blob *blob, IdResult idResult, IdRef elementType, IdRef length)
360 {
361     const size_t startSize = blob->size();
362     blob->push_back(0);
363     blob->push_back(idResult);
364     blob->push_back(elementType);
365     blob->push_back(length);
366     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeArray);
367 }
WriteTypeRuntimeArray(Blob * blob,IdResult idResult,IdRef elementType)368 void WriteTypeRuntimeArray(Blob *blob, IdResult idResult, IdRef elementType)
369 {
370     const size_t startSize = blob->size();
371     blob->push_back(0);
372     blob->push_back(idResult);
373     blob->push_back(elementType);
374     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeRuntimeArray);
375 }
WriteTypeStruct(Blob * blob,IdResult idResult,const IdRefList & memberList)376 void WriteTypeStruct(Blob *blob, IdResult idResult, const IdRefList &memberList)
377 {
378     const size_t startSize = blob->size();
379     blob->push_back(0);
380     blob->push_back(idResult);
381     for (const auto &operand : memberList)
382     {
383         blob->push_back(operand);
384     }
385     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeStruct);
386 }
WriteTypePointer(Blob * blob,IdResult idResult,spv::StorageClass storageClass,IdRef type)387 void WriteTypePointer(Blob *blob, IdResult idResult, spv::StorageClass storageClass, IdRef type)
388 {
389     const size_t startSize = blob->size();
390     blob->push_back(0);
391     blob->push_back(idResult);
392     blob->push_back(storageClass);
393     blob->push_back(type);
394     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypePointer);
395 }
WriteTypeFunction(Blob * blob,IdResult idResult,IdRef returnType,const IdRefList & parameterList)396 void WriteTypeFunction(Blob *blob,
397                        IdResult idResult,
398                        IdRef returnType,
399                        const IdRefList &parameterList)
400 {
401     const size_t startSize = blob->size();
402     blob->push_back(0);
403     blob->push_back(idResult);
404     blob->push_back(returnType);
405     for (const auto &operand : parameterList)
406     {
407         blob->push_back(operand);
408     }
409     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeFunction);
410 }
WriteConstantTrue(Blob * blob,IdResultType idResultType,IdResult idResult)411 void WriteConstantTrue(Blob *blob, IdResultType idResultType, IdResult idResult)
412 {
413     const size_t startSize = blob->size();
414     blob->push_back(0);
415     blob->push_back(idResultType);
416     blob->push_back(idResult);
417     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstantTrue);
418 }
WriteConstantFalse(Blob * blob,IdResultType idResultType,IdResult idResult)419 void WriteConstantFalse(Blob *blob, IdResultType idResultType, IdResult idResult)
420 {
421     const size_t startSize = blob->size();
422     blob->push_back(0);
423     blob->push_back(idResultType);
424     blob->push_back(idResult);
425     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstantFalse);
426 }
WriteConstant(Blob * blob,IdResultType idResultType,IdResult idResult,LiteralContextDependentNumber value)427 void WriteConstant(Blob *blob,
428                    IdResultType idResultType,
429                    IdResult idResult,
430                    LiteralContextDependentNumber value)
431 {
432     const size_t startSize = blob->size();
433     blob->push_back(0);
434     blob->push_back(idResultType);
435     blob->push_back(idResult);
436     blob->push_back(value);
437     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstant);
438 }
WriteConstantComposite(Blob * blob,IdResultType idResultType,IdResult idResult,const IdRefList & constituentsList)439 void WriteConstantComposite(Blob *blob,
440                             IdResultType idResultType,
441                             IdResult idResult,
442                             const IdRefList &constituentsList)
443 {
444     const size_t startSize = blob->size();
445     blob->push_back(0);
446     blob->push_back(idResultType);
447     blob->push_back(idResult);
448     for (const auto &operand : constituentsList)
449     {
450         blob->push_back(operand);
451     }
452     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstantComposite);
453 }
WriteConstantNull(Blob * blob,IdResultType idResultType,IdResult idResult)454 void WriteConstantNull(Blob *blob, IdResultType idResultType, IdResult idResult)
455 {
456     const size_t startSize = blob->size();
457     blob->push_back(0);
458     blob->push_back(idResultType);
459     blob->push_back(idResult);
460     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstantNull);
461 }
WriteSpecConstantTrue(Blob * blob,IdResultType idResultType,IdResult idResult)462 void WriteSpecConstantTrue(Blob *blob, IdResultType idResultType, IdResult idResult)
463 {
464     const size_t startSize = blob->size();
465     blob->push_back(0);
466     blob->push_back(idResultType);
467     blob->push_back(idResult);
468     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSpecConstantTrue);
469 }
WriteSpecConstantFalse(Blob * blob,IdResultType idResultType,IdResult idResult)470 void WriteSpecConstantFalse(Blob *blob, IdResultType idResultType, IdResult idResult)
471 {
472     const size_t startSize = blob->size();
473     blob->push_back(0);
474     blob->push_back(idResultType);
475     blob->push_back(idResult);
476     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSpecConstantFalse);
477 }
WriteSpecConstant(Blob * blob,IdResultType idResultType,IdResult idResult,LiteralContextDependentNumber value)478 void WriteSpecConstant(Blob *blob,
479                        IdResultType idResultType,
480                        IdResult idResult,
481                        LiteralContextDependentNumber value)
482 {
483     const size_t startSize = blob->size();
484     blob->push_back(0);
485     blob->push_back(idResultType);
486     blob->push_back(idResult);
487     blob->push_back(value);
488     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSpecConstant);
489 }
WriteSpecConstantComposite(Blob * blob,IdResultType idResultType,IdResult idResult,const IdRefList & constituentsList)490 void WriteSpecConstantComposite(Blob *blob,
491                                 IdResultType idResultType,
492                                 IdResult idResult,
493                                 const IdRefList &constituentsList)
494 {
495     const size_t startSize = blob->size();
496     blob->push_back(0);
497     blob->push_back(idResultType);
498     blob->push_back(idResult);
499     for (const auto &operand : constituentsList)
500     {
501         blob->push_back(operand);
502     }
503     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSpecConstantComposite);
504 }
WriteFunction(Blob * blob,IdResultType idResultType,IdResult idResult,spv::FunctionControlMask functionControl,IdRef functionType)505 void WriteFunction(Blob *blob,
506                    IdResultType idResultType,
507                    IdResult idResult,
508                    spv::FunctionControlMask functionControl,
509                    IdRef functionType)
510 {
511     const size_t startSize = blob->size();
512     blob->push_back(0);
513     blob->push_back(idResultType);
514     blob->push_back(idResult);
515     blob->push_back(functionControl);
516     blob->push_back(functionType);
517     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFunction);
518 }
WriteFunctionParameter(Blob * blob,IdResultType idResultType,IdResult idResult)519 void WriteFunctionParameter(Blob *blob, IdResultType idResultType, IdResult idResult)
520 {
521     const size_t startSize = blob->size();
522     blob->push_back(0);
523     blob->push_back(idResultType);
524     blob->push_back(idResult);
525     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFunctionParameter);
526 }
WriteFunctionEnd(Blob * blob)527 void WriteFunctionEnd(Blob *blob)
528 {
529     const size_t startSize = blob->size();
530     blob->push_back(0);
531 
532     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFunctionEnd);
533 }
WriteFunctionCall(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef function,const IdRefList & argumentList)534 void WriteFunctionCall(Blob *blob,
535                        IdResultType idResultType,
536                        IdResult idResult,
537                        IdRef function,
538                        const IdRefList &argumentList)
539 {
540     const size_t startSize = blob->size();
541     blob->push_back(0);
542     blob->push_back(idResultType);
543     blob->push_back(idResult);
544     blob->push_back(function);
545     for (const auto &operand : argumentList)
546     {
547         blob->push_back(operand);
548     }
549     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFunctionCall);
550 }
WriteVariable(Blob * blob,IdResultType idResultType,IdResult idResult,spv::StorageClass storageClass,const IdRef * initializer)551 void WriteVariable(Blob *blob,
552                    IdResultType idResultType,
553                    IdResult idResult,
554                    spv::StorageClass storageClass,
555                    const IdRef *initializer)
556 {
557     const size_t startSize = blob->size();
558     blob->push_back(0);
559     blob->push_back(idResultType);
560     blob->push_back(idResult);
561     blob->push_back(storageClass);
562     if (initializer)
563     {
564         blob->push_back(*initializer);
565     }
566     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVariable);
567 }
WriteImageTexelPointer(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,IdRef sample)568 void WriteImageTexelPointer(Blob *blob,
569                             IdResultType idResultType,
570                             IdResult idResult,
571                             IdRef image,
572                             IdRef coordinate,
573                             IdRef sample)
574 {
575     const size_t startSize = blob->size();
576     blob->push_back(0);
577     blob->push_back(idResultType);
578     blob->push_back(idResult);
579     blob->push_back(image);
580     blob->push_back(coordinate);
581     blob->push_back(sample);
582     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageTexelPointer);
583 }
WriteLoad(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,const spv::MemoryAccessMask * memoryAccess)584 void WriteLoad(Blob *blob,
585                IdResultType idResultType,
586                IdResult idResult,
587                IdRef pointer,
588                const spv::MemoryAccessMask *memoryAccess)
589 {
590     const size_t startSize = blob->size();
591     blob->push_back(0);
592     blob->push_back(idResultType);
593     blob->push_back(idResult);
594     blob->push_back(pointer);
595     if (memoryAccess)
596     {
597         blob->push_back(*memoryAccess);
598     }
599     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLoad);
600 }
WriteStore(Blob * blob,IdRef pointer,IdRef object,const spv::MemoryAccessMask * memoryAccess)601 void WriteStore(Blob *blob, IdRef pointer, IdRef object, const spv::MemoryAccessMask *memoryAccess)
602 {
603     const size_t startSize = blob->size();
604     blob->push_back(0);
605     blob->push_back(pointer);
606     blob->push_back(object);
607     if (memoryAccess)
608     {
609         blob->push_back(*memoryAccess);
610     }
611     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpStore);
612 }
WriteCopyMemory(Blob * blob,IdRef target,IdRef source,const spv::MemoryAccessMask * memoryAccess)613 void WriteCopyMemory(Blob *blob,
614                      IdRef target,
615                      IdRef source,
616                      const spv::MemoryAccessMask *memoryAccess)
617 {
618     const size_t startSize = blob->size();
619     blob->push_back(0);
620     blob->push_back(target);
621     blob->push_back(source);
622     if (memoryAccess)
623     {
624         blob->push_back(*memoryAccess);
625     }
626     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCopyMemory);
627 }
WriteAccessChain(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,const IdRefList & indexesList)628 void WriteAccessChain(Blob *blob,
629                       IdResultType idResultType,
630                       IdResult idResult,
631                       IdRef base,
632                       const IdRefList &indexesList)
633 {
634     const size_t startSize = blob->size();
635     blob->push_back(0);
636     blob->push_back(idResultType);
637     blob->push_back(idResult);
638     blob->push_back(base);
639     for (const auto &operand : indexesList)
640     {
641         blob->push_back(operand);
642     }
643     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAccessChain);
644 }
WriteInBoundsAccessChain(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,const IdRefList & indexesList)645 void WriteInBoundsAccessChain(Blob *blob,
646                               IdResultType idResultType,
647                               IdResult idResult,
648                               IdRef base,
649                               const IdRefList &indexesList)
650 {
651     const size_t startSize = blob->size();
652     blob->push_back(0);
653     blob->push_back(idResultType);
654     blob->push_back(idResult);
655     blob->push_back(base);
656     for (const auto &operand : indexesList)
657     {
658         blob->push_back(operand);
659     }
660     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpInBoundsAccessChain);
661 }
WriteArrayLength(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef structure,LiteralInteger arraymember)662 void WriteArrayLength(Blob *blob,
663                       IdResultType idResultType,
664                       IdResult idResult,
665                       IdRef structure,
666                       LiteralInteger arraymember)
667 {
668     const size_t startSize = blob->size();
669     blob->push_back(0);
670     blob->push_back(idResultType);
671     blob->push_back(idResult);
672     blob->push_back(structure);
673     blob->push_back(arraymember);
674     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpArrayLength);
675 }
WriteDecorate(Blob * blob,IdRef target,spv::Decoration decoration,const LiteralIntegerList & valuesList)676 void WriteDecorate(Blob *blob,
677                    IdRef target,
678                    spv::Decoration decoration,
679                    const LiteralIntegerList &valuesList)
680 {
681     const size_t startSize = blob->size();
682     blob->push_back(0);
683     blob->push_back(target);
684     blob->push_back(decoration);
685     for (const auto &operand : valuesList)
686     {
687         blob->push_back(operand);
688     }
689     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDecorate);
690 }
WriteMemberDecorate(Blob * blob,IdRef structureType,LiteralInteger member,spv::Decoration decoration,const LiteralIntegerList & valuesList)691 void WriteMemberDecorate(Blob *blob,
692                          IdRef structureType,
693                          LiteralInteger member,
694                          spv::Decoration decoration,
695                          const LiteralIntegerList &valuesList)
696 {
697     const size_t startSize = blob->size();
698     blob->push_back(0);
699     blob->push_back(structureType);
700     blob->push_back(member);
701     blob->push_back(decoration);
702     for (const auto &operand : valuesList)
703     {
704         blob->push_back(operand);
705     }
706     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMemberDecorate);
707 }
WriteDecorationGroup(Blob * blob,IdResult idResult)708 void WriteDecorationGroup(Blob *blob, IdResult idResult)
709 {
710     const size_t startSize = blob->size();
711     blob->push_back(0);
712     blob->push_back(idResult);
713     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDecorationGroup);
714 }
WriteGroupDecorate(Blob * blob,IdRef decorationGroup,const IdRefList & targetsList)715 void WriteGroupDecorate(Blob *blob, IdRef decorationGroup, const IdRefList &targetsList)
716 {
717     const size_t startSize = blob->size();
718     blob->push_back(0);
719     blob->push_back(decorationGroup);
720     for (const auto &operand : targetsList)
721     {
722         blob->push_back(operand);
723     }
724     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupDecorate);
725 }
WriteGroupMemberDecorate(Blob * blob,IdRef decorationGroup,const PairIdRefLiteralIntegerList & targetsPairList)726 void WriteGroupMemberDecorate(Blob *blob,
727                               IdRef decorationGroup,
728                               const PairIdRefLiteralIntegerList &targetsPairList)
729 {
730     const size_t startSize = blob->size();
731     blob->push_back(0);
732     blob->push_back(decorationGroup);
733     for (const auto &operand : targetsPairList)
734     {
735         blob->push_back(operand.id);
736         blob->push_back(operand.literal);
737     }
738     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupMemberDecorate);
739 }
WriteVectorExtractDynamic(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector,IdRef index)740 void WriteVectorExtractDynamic(Blob *blob,
741                                IdResultType idResultType,
742                                IdResult idResult,
743                                IdRef vector,
744                                IdRef index)
745 {
746     const size_t startSize = blob->size();
747     blob->push_back(0);
748     blob->push_back(idResultType);
749     blob->push_back(idResult);
750     blob->push_back(vector);
751     blob->push_back(index);
752     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorExtractDynamic);
753 }
WriteVectorInsertDynamic(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector,IdRef component,IdRef index)754 void WriteVectorInsertDynamic(Blob *blob,
755                               IdResultType idResultType,
756                               IdResult idResult,
757                               IdRef vector,
758                               IdRef component,
759                               IdRef index)
760 {
761     const size_t startSize = blob->size();
762     blob->push_back(0);
763     blob->push_back(idResultType);
764     blob->push_back(idResult);
765     blob->push_back(vector);
766     blob->push_back(component);
767     blob->push_back(index);
768     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorInsertDynamic);
769 }
WriteVectorShuffle(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector1,IdRef vector2,const LiteralIntegerList & componentsList)770 void WriteVectorShuffle(Blob *blob,
771                         IdResultType idResultType,
772                         IdResult idResult,
773                         IdRef vector1,
774                         IdRef vector2,
775                         const LiteralIntegerList &componentsList)
776 {
777     const size_t startSize = blob->size();
778     blob->push_back(0);
779     blob->push_back(idResultType);
780     blob->push_back(idResult);
781     blob->push_back(vector1);
782     blob->push_back(vector2);
783     for (const auto &operand : componentsList)
784     {
785         blob->push_back(operand);
786     }
787     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorShuffle);
788 }
WriteCompositeConstruct(Blob * blob,IdResultType idResultType,IdResult idResult,const IdRefList & constituentsList)789 void WriteCompositeConstruct(Blob *blob,
790                              IdResultType idResultType,
791                              IdResult idResult,
792                              const IdRefList &constituentsList)
793 {
794     const size_t startSize = blob->size();
795     blob->push_back(0);
796     blob->push_back(idResultType);
797     blob->push_back(idResult);
798     for (const auto &operand : constituentsList)
799     {
800         blob->push_back(operand);
801     }
802     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCompositeConstruct);
803 }
WriteCompositeExtract(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef composite,const LiteralIntegerList & indexesList)804 void WriteCompositeExtract(Blob *blob,
805                            IdResultType idResultType,
806                            IdResult idResult,
807                            IdRef composite,
808                            const LiteralIntegerList &indexesList)
809 {
810     const size_t startSize = blob->size();
811     blob->push_back(0);
812     blob->push_back(idResultType);
813     blob->push_back(idResult);
814     blob->push_back(composite);
815     for (const auto &operand : indexesList)
816     {
817         blob->push_back(operand);
818     }
819     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCompositeExtract);
820 }
WriteCompositeInsert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef object,IdRef composite,const LiteralIntegerList & indexesList)821 void WriteCompositeInsert(Blob *blob,
822                           IdResultType idResultType,
823                           IdResult idResult,
824                           IdRef object,
825                           IdRef composite,
826                           const LiteralIntegerList &indexesList)
827 {
828     const size_t startSize = blob->size();
829     blob->push_back(0);
830     blob->push_back(idResultType);
831     blob->push_back(idResult);
832     blob->push_back(object);
833     blob->push_back(composite);
834     for (const auto &operand : indexesList)
835     {
836         blob->push_back(operand);
837     }
838     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCompositeInsert);
839 }
WriteCopyObject(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)840 void WriteCopyObject(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
841 {
842     const size_t startSize = blob->size();
843     blob->push_back(0);
844     blob->push_back(idResultType);
845     blob->push_back(idResult);
846     blob->push_back(operand);
847     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCopyObject);
848 }
WriteTranspose(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef matrix)849 void WriteTranspose(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef matrix)
850 {
851     const size_t startSize = blob->size();
852     blob->push_back(0);
853     blob->push_back(idResultType);
854     blob->push_back(idResult);
855     blob->push_back(matrix);
856     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTranspose);
857 }
WriteSampledImage(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef sampler)858 void WriteSampledImage(Blob *blob,
859                        IdResultType idResultType,
860                        IdResult idResult,
861                        IdRef image,
862                        IdRef sampler)
863 {
864     const size_t startSize = blob->size();
865     blob->push_back(0);
866     blob->push_back(idResultType);
867     blob->push_back(idResult);
868     blob->push_back(image);
869     blob->push_back(sampler);
870     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSampledImage);
871 }
WriteImageSampleImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)872 void WriteImageSampleImplicitLod(Blob *blob,
873                                  IdResultType idResultType,
874                                  IdResult idResult,
875                                  IdRef sampledImage,
876                                  IdRef coordinate,
877                                  const spv::ImageOperandsMask *imageOperands,
878                                  const IdRefList &imageOperandIdsList)
879 {
880     const size_t startSize = blob->size();
881     blob->push_back(0);
882     blob->push_back(idResultType);
883     blob->push_back(idResult);
884     blob->push_back(sampledImage);
885     blob->push_back(coordinate);
886     if (imageOperands)
887     {
888         blob->push_back(*imageOperands);
889     }
890     for (const auto &operand : imageOperandIdsList)
891     {
892         blob->push_back(operand);
893     }
894     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleImplicitLod);
895 }
WriteImageSampleExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)896 void WriteImageSampleExplicitLod(Blob *blob,
897                                  IdResultType idResultType,
898                                  IdResult idResult,
899                                  IdRef sampledImage,
900                                  IdRef coordinate,
901                                  spv::ImageOperandsMask imageOperands,
902                                  const IdRefList &imageOperandIdsList)
903 {
904     const size_t startSize = blob->size();
905     blob->push_back(0);
906     blob->push_back(idResultType);
907     blob->push_back(idResult);
908     blob->push_back(sampledImage);
909     blob->push_back(coordinate);
910     blob->push_back(imageOperands);
911     for (const auto &operand : imageOperandIdsList)
912     {
913         blob->push_back(operand);
914     }
915     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleExplicitLod);
916 }
WriteImageSampleDrefImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)917 void WriteImageSampleDrefImplicitLod(Blob *blob,
918                                      IdResultType idResultType,
919                                      IdResult idResult,
920                                      IdRef sampledImage,
921                                      IdRef coordinate,
922                                      IdRef dref,
923                                      const spv::ImageOperandsMask *imageOperands,
924                                      const IdRefList &imageOperandIdsList)
925 {
926     const size_t startSize = blob->size();
927     blob->push_back(0);
928     blob->push_back(idResultType);
929     blob->push_back(idResult);
930     blob->push_back(sampledImage);
931     blob->push_back(coordinate);
932     blob->push_back(dref);
933     if (imageOperands)
934     {
935         blob->push_back(*imageOperands);
936     }
937     for (const auto &operand : imageOperandIdsList)
938     {
939         blob->push_back(operand);
940     }
941     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleDrefImplicitLod);
942 }
WriteImageSampleDrefExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)943 void WriteImageSampleDrefExplicitLod(Blob *blob,
944                                      IdResultType idResultType,
945                                      IdResult idResult,
946                                      IdRef sampledImage,
947                                      IdRef coordinate,
948                                      IdRef dref,
949                                      spv::ImageOperandsMask imageOperands,
950                                      const IdRefList &imageOperandIdsList)
951 {
952     const size_t startSize = blob->size();
953     blob->push_back(0);
954     blob->push_back(idResultType);
955     blob->push_back(idResult);
956     blob->push_back(sampledImage);
957     blob->push_back(coordinate);
958     blob->push_back(dref);
959     blob->push_back(imageOperands);
960     for (const auto &operand : imageOperandIdsList)
961     {
962         blob->push_back(operand);
963     }
964     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleDrefExplicitLod);
965 }
WriteImageSampleProjImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)966 void WriteImageSampleProjImplicitLod(Blob *blob,
967                                      IdResultType idResultType,
968                                      IdResult idResult,
969                                      IdRef sampledImage,
970                                      IdRef coordinate,
971                                      const spv::ImageOperandsMask *imageOperands,
972                                      const IdRefList &imageOperandIdsList)
973 {
974     const size_t startSize = blob->size();
975     blob->push_back(0);
976     blob->push_back(idResultType);
977     blob->push_back(idResult);
978     blob->push_back(sampledImage);
979     blob->push_back(coordinate);
980     if (imageOperands)
981     {
982         blob->push_back(*imageOperands);
983     }
984     for (const auto &operand : imageOperandIdsList)
985     {
986         blob->push_back(operand);
987     }
988     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleProjImplicitLod);
989 }
WriteImageSampleProjExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)990 void WriteImageSampleProjExplicitLod(Blob *blob,
991                                      IdResultType idResultType,
992                                      IdResult idResult,
993                                      IdRef sampledImage,
994                                      IdRef coordinate,
995                                      spv::ImageOperandsMask imageOperands,
996                                      const IdRefList &imageOperandIdsList)
997 {
998     const size_t startSize = blob->size();
999     blob->push_back(0);
1000     blob->push_back(idResultType);
1001     blob->push_back(idResult);
1002     blob->push_back(sampledImage);
1003     blob->push_back(coordinate);
1004     blob->push_back(imageOperands);
1005     for (const auto &operand : imageOperandIdsList)
1006     {
1007         blob->push_back(operand);
1008     }
1009     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleProjExplicitLod);
1010 }
WriteImageSampleProjDrefImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1011 void WriteImageSampleProjDrefImplicitLod(Blob *blob,
1012                                          IdResultType idResultType,
1013                                          IdResult idResult,
1014                                          IdRef sampledImage,
1015                                          IdRef coordinate,
1016                                          IdRef dref,
1017                                          const spv::ImageOperandsMask *imageOperands,
1018                                          const IdRefList &imageOperandIdsList)
1019 {
1020     const size_t startSize = blob->size();
1021     blob->push_back(0);
1022     blob->push_back(idResultType);
1023     blob->push_back(idResult);
1024     blob->push_back(sampledImage);
1025     blob->push_back(coordinate);
1026     blob->push_back(dref);
1027     if (imageOperands)
1028     {
1029         blob->push_back(*imageOperands);
1030     }
1031     for (const auto &operand : imageOperandIdsList)
1032     {
1033         blob->push_back(operand);
1034     }
1035     (*blob)[startSize] =
1036         MakeLengthOp(blob->size() - startSize, spv::OpImageSampleProjDrefImplicitLod);
1037 }
WriteImageSampleProjDrefExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)1038 void WriteImageSampleProjDrefExplicitLod(Blob *blob,
1039                                          IdResultType idResultType,
1040                                          IdResult idResult,
1041                                          IdRef sampledImage,
1042                                          IdRef coordinate,
1043                                          IdRef dref,
1044                                          spv::ImageOperandsMask imageOperands,
1045                                          const IdRefList &imageOperandIdsList)
1046 {
1047     const size_t startSize = blob->size();
1048     blob->push_back(0);
1049     blob->push_back(idResultType);
1050     blob->push_back(idResult);
1051     blob->push_back(sampledImage);
1052     blob->push_back(coordinate);
1053     blob->push_back(dref);
1054     blob->push_back(imageOperands);
1055     for (const auto &operand : imageOperandIdsList)
1056     {
1057         blob->push_back(operand);
1058     }
1059     (*blob)[startSize] =
1060         MakeLengthOp(blob->size() - startSize, spv::OpImageSampleProjDrefExplicitLod);
1061 }
WriteImageFetch(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1062 void WriteImageFetch(Blob *blob,
1063                      IdResultType idResultType,
1064                      IdResult idResult,
1065                      IdRef image,
1066                      IdRef coordinate,
1067                      const spv::ImageOperandsMask *imageOperands,
1068                      const IdRefList &imageOperandIdsList)
1069 {
1070     const size_t startSize = blob->size();
1071     blob->push_back(0);
1072     blob->push_back(idResultType);
1073     blob->push_back(idResult);
1074     blob->push_back(image);
1075     blob->push_back(coordinate);
1076     if (imageOperands)
1077     {
1078         blob->push_back(*imageOperands);
1079     }
1080     for (const auto &operand : imageOperandIdsList)
1081     {
1082         blob->push_back(operand);
1083     }
1084     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageFetch);
1085 }
WriteImageGather(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef component,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1086 void WriteImageGather(Blob *blob,
1087                       IdResultType idResultType,
1088                       IdResult idResult,
1089                       IdRef sampledImage,
1090                       IdRef coordinate,
1091                       IdRef component,
1092                       const spv::ImageOperandsMask *imageOperands,
1093                       const IdRefList &imageOperandIdsList)
1094 {
1095     const size_t startSize = blob->size();
1096     blob->push_back(0);
1097     blob->push_back(idResultType);
1098     blob->push_back(idResult);
1099     blob->push_back(sampledImage);
1100     blob->push_back(coordinate);
1101     blob->push_back(component);
1102     if (imageOperands)
1103     {
1104         blob->push_back(*imageOperands);
1105     }
1106     for (const auto &operand : imageOperandIdsList)
1107     {
1108         blob->push_back(operand);
1109     }
1110     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageGather);
1111 }
WriteImageDrefGather(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1112 void WriteImageDrefGather(Blob *blob,
1113                           IdResultType idResultType,
1114                           IdResult idResult,
1115                           IdRef sampledImage,
1116                           IdRef coordinate,
1117                           IdRef dref,
1118                           const spv::ImageOperandsMask *imageOperands,
1119                           const IdRefList &imageOperandIdsList)
1120 {
1121     const size_t startSize = blob->size();
1122     blob->push_back(0);
1123     blob->push_back(idResultType);
1124     blob->push_back(idResult);
1125     blob->push_back(sampledImage);
1126     blob->push_back(coordinate);
1127     blob->push_back(dref);
1128     if (imageOperands)
1129     {
1130         blob->push_back(*imageOperands);
1131     }
1132     for (const auto &operand : imageOperandIdsList)
1133     {
1134         blob->push_back(operand);
1135     }
1136     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageDrefGather);
1137 }
WriteImageRead(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1138 void WriteImageRead(Blob *blob,
1139                     IdResultType idResultType,
1140                     IdResult idResult,
1141                     IdRef image,
1142                     IdRef coordinate,
1143                     const spv::ImageOperandsMask *imageOperands,
1144                     const IdRefList &imageOperandIdsList)
1145 {
1146     const size_t startSize = blob->size();
1147     blob->push_back(0);
1148     blob->push_back(idResultType);
1149     blob->push_back(idResult);
1150     blob->push_back(image);
1151     blob->push_back(coordinate);
1152     if (imageOperands)
1153     {
1154         blob->push_back(*imageOperands);
1155     }
1156     for (const auto &operand : imageOperandIdsList)
1157     {
1158         blob->push_back(operand);
1159     }
1160     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageRead);
1161 }
WriteImageWrite(Blob * blob,IdRef image,IdRef coordinate,IdRef texel,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1162 void WriteImageWrite(Blob *blob,
1163                      IdRef image,
1164                      IdRef coordinate,
1165                      IdRef texel,
1166                      const spv::ImageOperandsMask *imageOperands,
1167                      const IdRefList &imageOperandIdsList)
1168 {
1169     const size_t startSize = blob->size();
1170     blob->push_back(0);
1171     blob->push_back(image);
1172     blob->push_back(coordinate);
1173     blob->push_back(texel);
1174     if (imageOperands)
1175     {
1176         blob->push_back(*imageOperands);
1177     }
1178     for (const auto &operand : imageOperandIdsList)
1179     {
1180         blob->push_back(operand);
1181     }
1182     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageWrite);
1183 }
WriteImage(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage)1184 void WriteImage(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef sampledImage)
1185 {
1186     const size_t startSize = blob->size();
1187     blob->push_back(0);
1188     blob->push_back(idResultType);
1189     blob->push_back(idResult);
1190     blob->push_back(sampledImage);
1191     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImage);
1192 }
WriteImageQuerySizeLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef levelofDetail)1193 void WriteImageQuerySizeLod(Blob *blob,
1194                             IdResultType idResultType,
1195                             IdResult idResult,
1196                             IdRef image,
1197                             IdRef levelofDetail)
1198 {
1199     const size_t startSize = blob->size();
1200     blob->push_back(0);
1201     blob->push_back(idResultType);
1202     blob->push_back(idResult);
1203     blob->push_back(image);
1204     blob->push_back(levelofDetail);
1205     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQuerySizeLod);
1206 }
WriteImageQuerySize(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image)1207 void WriteImageQuerySize(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef image)
1208 {
1209     const size_t startSize = blob->size();
1210     blob->push_back(0);
1211     blob->push_back(idResultType);
1212     blob->push_back(idResult);
1213     blob->push_back(image);
1214     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQuerySize);
1215 }
WriteImageQueryLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate)1216 void WriteImageQueryLod(Blob *blob,
1217                         IdResultType idResultType,
1218                         IdResult idResult,
1219                         IdRef sampledImage,
1220                         IdRef coordinate)
1221 {
1222     const size_t startSize = blob->size();
1223     blob->push_back(0);
1224     blob->push_back(idResultType);
1225     blob->push_back(idResult);
1226     blob->push_back(sampledImage);
1227     blob->push_back(coordinate);
1228     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQueryLod);
1229 }
WriteImageQueryLevels(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image)1230 void WriteImageQueryLevels(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef image)
1231 {
1232     const size_t startSize = blob->size();
1233     blob->push_back(0);
1234     blob->push_back(idResultType);
1235     blob->push_back(idResult);
1236     blob->push_back(image);
1237     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQueryLevels);
1238 }
WriteImageQuerySamples(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image)1239 void WriteImageQuerySamples(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef image)
1240 {
1241     const size_t startSize = blob->size();
1242     blob->push_back(0);
1243     blob->push_back(idResultType);
1244     blob->push_back(idResult);
1245     blob->push_back(image);
1246     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQuerySamples);
1247 }
WriteConvertFToU(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef floatValue)1248 void WriteConvertFToU(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef floatValue)
1249 {
1250     const size_t startSize = blob->size();
1251     blob->push_back(0);
1252     blob->push_back(idResultType);
1253     blob->push_back(idResult);
1254     blob->push_back(floatValue);
1255     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConvertFToU);
1256 }
WriteConvertFToS(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef floatValue)1257 void WriteConvertFToS(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef floatValue)
1258 {
1259     const size_t startSize = blob->size();
1260     blob->push_back(0);
1261     blob->push_back(idResultType);
1262     blob->push_back(idResult);
1263     blob->push_back(floatValue);
1264     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConvertFToS);
1265 }
WriteConvertSToF(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef signedValue)1266 void WriteConvertSToF(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef signedValue)
1267 {
1268     const size_t startSize = blob->size();
1269     blob->push_back(0);
1270     blob->push_back(idResultType);
1271     blob->push_back(idResult);
1272     blob->push_back(signedValue);
1273     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConvertSToF);
1274 }
WriteConvertUToF(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef unsignedValue)1275 void WriteConvertUToF(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef unsignedValue)
1276 {
1277     const size_t startSize = blob->size();
1278     blob->push_back(0);
1279     blob->push_back(idResultType);
1280     blob->push_back(idResult);
1281     blob->push_back(unsignedValue);
1282     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConvertUToF);
1283 }
WriteUConvert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef unsignedValue)1284 void WriteUConvert(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef unsignedValue)
1285 {
1286     const size_t startSize = blob->size();
1287     blob->push_back(0);
1288     blob->push_back(idResultType);
1289     blob->push_back(idResult);
1290     blob->push_back(unsignedValue);
1291     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUConvert);
1292 }
WriteSConvert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef signedValue)1293 void WriteSConvert(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef signedValue)
1294 {
1295     const size_t startSize = blob->size();
1296     blob->push_back(0);
1297     blob->push_back(idResultType);
1298     blob->push_back(idResult);
1299     blob->push_back(signedValue);
1300     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSConvert);
1301 }
WriteFConvert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef floatValue)1302 void WriteFConvert(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef floatValue)
1303 {
1304     const size_t startSize = blob->size();
1305     blob->push_back(0);
1306     blob->push_back(idResultType);
1307     blob->push_back(idResult);
1308     blob->push_back(floatValue);
1309     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFConvert);
1310 }
WriteQuantizeToF16(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef value)1311 void WriteQuantizeToF16(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef value)
1312 {
1313     const size_t startSize = blob->size();
1314     blob->push_back(0);
1315     blob->push_back(idResultType);
1316     blob->push_back(idResult);
1317     blob->push_back(value);
1318     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpQuantizeToF16);
1319 }
WriteBitcast(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)1320 void WriteBitcast(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
1321 {
1322     const size_t startSize = blob->size();
1323     blob->push_back(0);
1324     blob->push_back(idResultType);
1325     blob->push_back(idResult);
1326     blob->push_back(operand);
1327     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitcast);
1328 }
WriteSNegate(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)1329 void WriteSNegate(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
1330 {
1331     const size_t startSize = blob->size();
1332     blob->push_back(0);
1333     blob->push_back(idResultType);
1334     blob->push_back(idResult);
1335     blob->push_back(operand);
1336     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSNegate);
1337 }
WriteFNegate(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)1338 void WriteFNegate(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
1339 {
1340     const size_t startSize = blob->size();
1341     blob->push_back(0);
1342     blob->push_back(idResultType);
1343     blob->push_back(idResult);
1344     blob->push_back(operand);
1345     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFNegate);
1346 }
WriteIAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1347 void WriteIAdd(Blob *blob,
1348                IdResultType idResultType,
1349                IdResult idResult,
1350                IdRef operand1,
1351                IdRef operand2)
1352 {
1353     const size_t startSize = blob->size();
1354     blob->push_back(0);
1355     blob->push_back(idResultType);
1356     blob->push_back(idResult);
1357     blob->push_back(operand1);
1358     blob->push_back(operand2);
1359     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIAdd);
1360 }
WriteFAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1361 void WriteFAdd(Blob *blob,
1362                IdResultType idResultType,
1363                IdResult idResult,
1364                IdRef operand1,
1365                IdRef operand2)
1366 {
1367     const size_t startSize = blob->size();
1368     blob->push_back(0);
1369     blob->push_back(idResultType);
1370     blob->push_back(idResult);
1371     blob->push_back(operand1);
1372     blob->push_back(operand2);
1373     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFAdd);
1374 }
WriteISub(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1375 void WriteISub(Blob *blob,
1376                IdResultType idResultType,
1377                IdResult idResult,
1378                IdRef operand1,
1379                IdRef operand2)
1380 {
1381     const size_t startSize = blob->size();
1382     blob->push_back(0);
1383     blob->push_back(idResultType);
1384     blob->push_back(idResult);
1385     blob->push_back(operand1);
1386     blob->push_back(operand2);
1387     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpISub);
1388 }
WriteFSub(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1389 void WriteFSub(Blob *blob,
1390                IdResultType idResultType,
1391                IdResult idResult,
1392                IdRef operand1,
1393                IdRef operand2)
1394 {
1395     const size_t startSize = blob->size();
1396     blob->push_back(0);
1397     blob->push_back(idResultType);
1398     blob->push_back(idResult);
1399     blob->push_back(operand1);
1400     blob->push_back(operand2);
1401     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFSub);
1402 }
WriteIMul(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1403 void WriteIMul(Blob *blob,
1404                IdResultType idResultType,
1405                IdResult idResult,
1406                IdRef operand1,
1407                IdRef operand2)
1408 {
1409     const size_t startSize = blob->size();
1410     blob->push_back(0);
1411     blob->push_back(idResultType);
1412     blob->push_back(idResult);
1413     blob->push_back(operand1);
1414     blob->push_back(operand2);
1415     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIMul);
1416 }
WriteFMul(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1417 void WriteFMul(Blob *blob,
1418                IdResultType idResultType,
1419                IdResult idResult,
1420                IdRef operand1,
1421                IdRef operand2)
1422 {
1423     const size_t startSize = blob->size();
1424     blob->push_back(0);
1425     blob->push_back(idResultType);
1426     blob->push_back(idResult);
1427     blob->push_back(operand1);
1428     blob->push_back(operand2);
1429     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFMul);
1430 }
WriteUDiv(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1431 void WriteUDiv(Blob *blob,
1432                IdResultType idResultType,
1433                IdResult idResult,
1434                IdRef operand1,
1435                IdRef operand2)
1436 {
1437     const size_t startSize = blob->size();
1438     blob->push_back(0);
1439     blob->push_back(idResultType);
1440     blob->push_back(idResult);
1441     blob->push_back(operand1);
1442     blob->push_back(operand2);
1443     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUDiv);
1444 }
WriteSDiv(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1445 void WriteSDiv(Blob *blob,
1446                IdResultType idResultType,
1447                IdResult idResult,
1448                IdRef operand1,
1449                IdRef operand2)
1450 {
1451     const size_t startSize = blob->size();
1452     blob->push_back(0);
1453     blob->push_back(idResultType);
1454     blob->push_back(idResult);
1455     blob->push_back(operand1);
1456     blob->push_back(operand2);
1457     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSDiv);
1458 }
WriteFDiv(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1459 void WriteFDiv(Blob *blob,
1460                IdResultType idResultType,
1461                IdResult idResult,
1462                IdRef operand1,
1463                IdRef operand2)
1464 {
1465     const size_t startSize = blob->size();
1466     blob->push_back(0);
1467     blob->push_back(idResultType);
1468     blob->push_back(idResult);
1469     blob->push_back(operand1);
1470     blob->push_back(operand2);
1471     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFDiv);
1472 }
WriteUMod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1473 void WriteUMod(Blob *blob,
1474                IdResultType idResultType,
1475                IdResult idResult,
1476                IdRef operand1,
1477                IdRef operand2)
1478 {
1479     const size_t startSize = blob->size();
1480     blob->push_back(0);
1481     blob->push_back(idResultType);
1482     blob->push_back(idResult);
1483     blob->push_back(operand1);
1484     blob->push_back(operand2);
1485     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUMod);
1486 }
WriteSRem(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1487 void WriteSRem(Blob *blob,
1488                IdResultType idResultType,
1489                IdResult idResult,
1490                IdRef operand1,
1491                IdRef operand2)
1492 {
1493     const size_t startSize = blob->size();
1494     blob->push_back(0);
1495     blob->push_back(idResultType);
1496     blob->push_back(idResult);
1497     blob->push_back(operand1);
1498     blob->push_back(operand2);
1499     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSRem);
1500 }
WriteSMod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1501 void WriteSMod(Blob *blob,
1502                IdResultType idResultType,
1503                IdResult idResult,
1504                IdRef operand1,
1505                IdRef operand2)
1506 {
1507     const size_t startSize = blob->size();
1508     blob->push_back(0);
1509     blob->push_back(idResultType);
1510     blob->push_back(idResult);
1511     blob->push_back(operand1);
1512     blob->push_back(operand2);
1513     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSMod);
1514 }
WriteFRem(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1515 void WriteFRem(Blob *blob,
1516                IdResultType idResultType,
1517                IdResult idResult,
1518                IdRef operand1,
1519                IdRef operand2)
1520 {
1521     const size_t startSize = blob->size();
1522     blob->push_back(0);
1523     blob->push_back(idResultType);
1524     blob->push_back(idResult);
1525     blob->push_back(operand1);
1526     blob->push_back(operand2);
1527     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFRem);
1528 }
WriteFMod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1529 void WriteFMod(Blob *blob,
1530                IdResultType idResultType,
1531                IdResult idResult,
1532                IdRef operand1,
1533                IdRef operand2)
1534 {
1535     const size_t startSize = blob->size();
1536     blob->push_back(0);
1537     blob->push_back(idResultType);
1538     blob->push_back(idResult);
1539     blob->push_back(operand1);
1540     blob->push_back(operand2);
1541     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFMod);
1542 }
WriteVectorTimesScalar(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector,IdRef scalar)1543 void WriteVectorTimesScalar(Blob *blob,
1544                             IdResultType idResultType,
1545                             IdResult idResult,
1546                             IdRef vector,
1547                             IdRef scalar)
1548 {
1549     const size_t startSize = blob->size();
1550     blob->push_back(0);
1551     blob->push_back(idResultType);
1552     blob->push_back(idResult);
1553     blob->push_back(vector);
1554     blob->push_back(scalar);
1555     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorTimesScalar);
1556 }
WriteMatrixTimesScalar(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef matrix,IdRef scalar)1557 void WriteMatrixTimesScalar(Blob *blob,
1558                             IdResultType idResultType,
1559                             IdResult idResult,
1560                             IdRef matrix,
1561                             IdRef scalar)
1562 {
1563     const size_t startSize = blob->size();
1564     blob->push_back(0);
1565     blob->push_back(idResultType);
1566     blob->push_back(idResult);
1567     blob->push_back(matrix);
1568     blob->push_back(scalar);
1569     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMatrixTimesScalar);
1570 }
WriteVectorTimesMatrix(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector,IdRef matrix)1571 void WriteVectorTimesMatrix(Blob *blob,
1572                             IdResultType idResultType,
1573                             IdResult idResult,
1574                             IdRef vector,
1575                             IdRef matrix)
1576 {
1577     const size_t startSize = blob->size();
1578     blob->push_back(0);
1579     blob->push_back(idResultType);
1580     blob->push_back(idResult);
1581     blob->push_back(vector);
1582     blob->push_back(matrix);
1583     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorTimesMatrix);
1584 }
WriteMatrixTimesVector(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef matrix,IdRef vector)1585 void WriteMatrixTimesVector(Blob *blob,
1586                             IdResultType idResultType,
1587                             IdResult idResult,
1588                             IdRef matrix,
1589                             IdRef vector)
1590 {
1591     const size_t startSize = blob->size();
1592     blob->push_back(0);
1593     blob->push_back(idResultType);
1594     blob->push_back(idResult);
1595     blob->push_back(matrix);
1596     blob->push_back(vector);
1597     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMatrixTimesVector);
1598 }
WriteMatrixTimesMatrix(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef leftMatrix,IdRef rightMatrix)1599 void WriteMatrixTimesMatrix(Blob *blob,
1600                             IdResultType idResultType,
1601                             IdResult idResult,
1602                             IdRef leftMatrix,
1603                             IdRef rightMatrix)
1604 {
1605     const size_t startSize = blob->size();
1606     blob->push_back(0);
1607     blob->push_back(idResultType);
1608     blob->push_back(idResult);
1609     blob->push_back(leftMatrix);
1610     blob->push_back(rightMatrix);
1611     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMatrixTimesMatrix);
1612 }
WriteOuterProduct(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector1,IdRef vector2)1613 void WriteOuterProduct(Blob *blob,
1614                        IdResultType idResultType,
1615                        IdResult idResult,
1616                        IdRef vector1,
1617                        IdRef vector2)
1618 {
1619     const size_t startSize = blob->size();
1620     blob->push_back(0);
1621     blob->push_back(idResultType);
1622     blob->push_back(idResult);
1623     blob->push_back(vector1);
1624     blob->push_back(vector2);
1625     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpOuterProduct);
1626 }
WriteDot(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector1,IdRef vector2)1627 void WriteDot(Blob *blob,
1628               IdResultType idResultType,
1629               IdResult idResult,
1630               IdRef vector1,
1631               IdRef vector2)
1632 {
1633     const size_t startSize = blob->size();
1634     blob->push_back(0);
1635     blob->push_back(idResultType);
1636     blob->push_back(idResult);
1637     blob->push_back(vector1);
1638     blob->push_back(vector2);
1639     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDot);
1640 }
WriteIAddCarry(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1641 void WriteIAddCarry(Blob *blob,
1642                     IdResultType idResultType,
1643                     IdResult idResult,
1644                     IdRef operand1,
1645                     IdRef operand2)
1646 {
1647     const size_t startSize = blob->size();
1648     blob->push_back(0);
1649     blob->push_back(idResultType);
1650     blob->push_back(idResult);
1651     blob->push_back(operand1);
1652     blob->push_back(operand2);
1653     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIAddCarry);
1654 }
WriteISubBorrow(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1655 void WriteISubBorrow(Blob *blob,
1656                      IdResultType idResultType,
1657                      IdResult idResult,
1658                      IdRef operand1,
1659                      IdRef operand2)
1660 {
1661     const size_t startSize = blob->size();
1662     blob->push_back(0);
1663     blob->push_back(idResultType);
1664     blob->push_back(idResult);
1665     blob->push_back(operand1);
1666     blob->push_back(operand2);
1667     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpISubBorrow);
1668 }
WriteUMulExtended(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1669 void WriteUMulExtended(Blob *blob,
1670                        IdResultType idResultType,
1671                        IdResult idResult,
1672                        IdRef operand1,
1673                        IdRef operand2)
1674 {
1675     const size_t startSize = blob->size();
1676     blob->push_back(0);
1677     blob->push_back(idResultType);
1678     blob->push_back(idResult);
1679     blob->push_back(operand1);
1680     blob->push_back(operand2);
1681     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUMulExtended);
1682 }
WriteSMulExtended(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1683 void WriteSMulExtended(Blob *blob,
1684                        IdResultType idResultType,
1685                        IdResult idResult,
1686                        IdRef operand1,
1687                        IdRef operand2)
1688 {
1689     const size_t startSize = blob->size();
1690     blob->push_back(0);
1691     blob->push_back(idResultType);
1692     blob->push_back(idResult);
1693     blob->push_back(operand1);
1694     blob->push_back(operand2);
1695     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSMulExtended);
1696 }
WriteAny(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector)1697 void WriteAny(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef vector)
1698 {
1699     const size_t startSize = blob->size();
1700     blob->push_back(0);
1701     blob->push_back(idResultType);
1702     blob->push_back(idResult);
1703     blob->push_back(vector);
1704     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAny);
1705 }
WriteAll(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector)1706 void WriteAll(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef vector)
1707 {
1708     const size_t startSize = blob->size();
1709     blob->push_back(0);
1710     blob->push_back(idResultType);
1711     blob->push_back(idResult);
1712     blob->push_back(vector);
1713     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAll);
1714 }
WriteIsNan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef x)1715 void WriteIsNan(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef x)
1716 {
1717     const size_t startSize = blob->size();
1718     blob->push_back(0);
1719     blob->push_back(idResultType);
1720     blob->push_back(idResult);
1721     blob->push_back(x);
1722     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIsNan);
1723 }
WriteIsInf(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef x)1724 void WriteIsInf(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef x)
1725 {
1726     const size_t startSize = blob->size();
1727     blob->push_back(0);
1728     blob->push_back(idResultType);
1729     blob->push_back(idResult);
1730     blob->push_back(x);
1731     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIsInf);
1732 }
WriteLogicalEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1733 void WriteLogicalEqual(Blob *blob,
1734                        IdResultType idResultType,
1735                        IdResult idResult,
1736                        IdRef operand1,
1737                        IdRef operand2)
1738 {
1739     const size_t startSize = blob->size();
1740     blob->push_back(0);
1741     blob->push_back(idResultType);
1742     blob->push_back(idResult);
1743     blob->push_back(operand1);
1744     blob->push_back(operand2);
1745     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalEqual);
1746 }
WriteLogicalNotEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1747 void WriteLogicalNotEqual(Blob *blob,
1748                           IdResultType idResultType,
1749                           IdResult idResult,
1750                           IdRef operand1,
1751                           IdRef operand2)
1752 {
1753     const size_t startSize = blob->size();
1754     blob->push_back(0);
1755     blob->push_back(idResultType);
1756     blob->push_back(idResult);
1757     blob->push_back(operand1);
1758     blob->push_back(operand2);
1759     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalNotEqual);
1760 }
WriteLogicalOr(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1761 void WriteLogicalOr(Blob *blob,
1762                     IdResultType idResultType,
1763                     IdResult idResult,
1764                     IdRef operand1,
1765                     IdRef operand2)
1766 {
1767     const size_t startSize = blob->size();
1768     blob->push_back(0);
1769     blob->push_back(idResultType);
1770     blob->push_back(idResult);
1771     blob->push_back(operand1);
1772     blob->push_back(operand2);
1773     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalOr);
1774 }
WriteLogicalAnd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1775 void WriteLogicalAnd(Blob *blob,
1776                      IdResultType idResultType,
1777                      IdResult idResult,
1778                      IdRef operand1,
1779                      IdRef operand2)
1780 {
1781     const size_t startSize = blob->size();
1782     blob->push_back(0);
1783     blob->push_back(idResultType);
1784     blob->push_back(idResult);
1785     blob->push_back(operand1);
1786     blob->push_back(operand2);
1787     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalAnd);
1788 }
WriteLogicalNot(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)1789 void WriteLogicalNot(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
1790 {
1791     const size_t startSize = blob->size();
1792     blob->push_back(0);
1793     blob->push_back(idResultType);
1794     blob->push_back(idResult);
1795     blob->push_back(operand);
1796     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalNot);
1797 }
WriteSelect(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef condition,IdRef object1,IdRef object2)1798 void WriteSelect(Blob *blob,
1799                  IdResultType idResultType,
1800                  IdResult idResult,
1801                  IdRef condition,
1802                  IdRef object1,
1803                  IdRef object2)
1804 {
1805     const size_t startSize = blob->size();
1806     blob->push_back(0);
1807     blob->push_back(idResultType);
1808     blob->push_back(idResult);
1809     blob->push_back(condition);
1810     blob->push_back(object1);
1811     blob->push_back(object2);
1812     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSelect);
1813 }
WriteIEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1814 void WriteIEqual(Blob *blob,
1815                  IdResultType idResultType,
1816                  IdResult idResult,
1817                  IdRef operand1,
1818                  IdRef operand2)
1819 {
1820     const size_t startSize = blob->size();
1821     blob->push_back(0);
1822     blob->push_back(idResultType);
1823     blob->push_back(idResult);
1824     blob->push_back(operand1);
1825     blob->push_back(operand2);
1826     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIEqual);
1827 }
WriteINotEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1828 void WriteINotEqual(Blob *blob,
1829                     IdResultType idResultType,
1830                     IdResult idResult,
1831                     IdRef operand1,
1832                     IdRef operand2)
1833 {
1834     const size_t startSize = blob->size();
1835     blob->push_back(0);
1836     blob->push_back(idResultType);
1837     blob->push_back(idResult);
1838     blob->push_back(operand1);
1839     blob->push_back(operand2);
1840     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpINotEqual);
1841 }
WriteUGreaterThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1842 void WriteUGreaterThan(Blob *blob,
1843                        IdResultType idResultType,
1844                        IdResult idResult,
1845                        IdRef operand1,
1846                        IdRef operand2)
1847 {
1848     const size_t startSize = blob->size();
1849     blob->push_back(0);
1850     blob->push_back(idResultType);
1851     blob->push_back(idResult);
1852     blob->push_back(operand1);
1853     blob->push_back(operand2);
1854     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUGreaterThan);
1855 }
WriteSGreaterThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1856 void WriteSGreaterThan(Blob *blob,
1857                        IdResultType idResultType,
1858                        IdResult idResult,
1859                        IdRef operand1,
1860                        IdRef operand2)
1861 {
1862     const size_t startSize = blob->size();
1863     blob->push_back(0);
1864     blob->push_back(idResultType);
1865     blob->push_back(idResult);
1866     blob->push_back(operand1);
1867     blob->push_back(operand2);
1868     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSGreaterThan);
1869 }
WriteUGreaterThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1870 void WriteUGreaterThanEqual(Blob *blob,
1871                             IdResultType idResultType,
1872                             IdResult idResult,
1873                             IdRef operand1,
1874                             IdRef operand2)
1875 {
1876     const size_t startSize = blob->size();
1877     blob->push_back(0);
1878     blob->push_back(idResultType);
1879     blob->push_back(idResult);
1880     blob->push_back(operand1);
1881     blob->push_back(operand2);
1882     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUGreaterThanEqual);
1883 }
WriteSGreaterThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1884 void WriteSGreaterThanEqual(Blob *blob,
1885                             IdResultType idResultType,
1886                             IdResult idResult,
1887                             IdRef operand1,
1888                             IdRef operand2)
1889 {
1890     const size_t startSize = blob->size();
1891     blob->push_back(0);
1892     blob->push_back(idResultType);
1893     blob->push_back(idResult);
1894     blob->push_back(operand1);
1895     blob->push_back(operand2);
1896     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSGreaterThanEqual);
1897 }
WriteULessThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1898 void WriteULessThan(Blob *blob,
1899                     IdResultType idResultType,
1900                     IdResult idResult,
1901                     IdRef operand1,
1902                     IdRef operand2)
1903 {
1904     const size_t startSize = blob->size();
1905     blob->push_back(0);
1906     blob->push_back(idResultType);
1907     blob->push_back(idResult);
1908     blob->push_back(operand1);
1909     blob->push_back(operand2);
1910     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpULessThan);
1911 }
WriteSLessThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1912 void WriteSLessThan(Blob *blob,
1913                     IdResultType idResultType,
1914                     IdResult idResult,
1915                     IdRef operand1,
1916                     IdRef operand2)
1917 {
1918     const size_t startSize = blob->size();
1919     blob->push_back(0);
1920     blob->push_back(idResultType);
1921     blob->push_back(idResult);
1922     blob->push_back(operand1);
1923     blob->push_back(operand2);
1924     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSLessThan);
1925 }
WriteULessThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1926 void WriteULessThanEqual(Blob *blob,
1927                          IdResultType idResultType,
1928                          IdResult idResult,
1929                          IdRef operand1,
1930                          IdRef operand2)
1931 {
1932     const size_t startSize = blob->size();
1933     blob->push_back(0);
1934     blob->push_back(idResultType);
1935     blob->push_back(idResult);
1936     blob->push_back(operand1);
1937     blob->push_back(operand2);
1938     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpULessThanEqual);
1939 }
WriteSLessThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1940 void WriteSLessThanEqual(Blob *blob,
1941                          IdResultType idResultType,
1942                          IdResult idResult,
1943                          IdRef operand1,
1944                          IdRef operand2)
1945 {
1946     const size_t startSize = blob->size();
1947     blob->push_back(0);
1948     blob->push_back(idResultType);
1949     blob->push_back(idResult);
1950     blob->push_back(operand1);
1951     blob->push_back(operand2);
1952     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSLessThanEqual);
1953 }
WriteFOrdEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1954 void WriteFOrdEqual(Blob *blob,
1955                     IdResultType idResultType,
1956                     IdResult idResult,
1957                     IdRef operand1,
1958                     IdRef operand2)
1959 {
1960     const size_t startSize = blob->size();
1961     blob->push_back(0);
1962     blob->push_back(idResultType);
1963     blob->push_back(idResult);
1964     blob->push_back(operand1);
1965     blob->push_back(operand2);
1966     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdEqual);
1967 }
WriteFUnordEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1968 void WriteFUnordEqual(Blob *blob,
1969                       IdResultType idResultType,
1970                       IdResult idResult,
1971                       IdRef operand1,
1972                       IdRef operand2)
1973 {
1974     const size_t startSize = blob->size();
1975     blob->push_back(0);
1976     blob->push_back(idResultType);
1977     blob->push_back(idResult);
1978     blob->push_back(operand1);
1979     blob->push_back(operand2);
1980     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordEqual);
1981 }
WriteFOrdNotEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1982 void WriteFOrdNotEqual(Blob *blob,
1983                        IdResultType idResultType,
1984                        IdResult idResult,
1985                        IdRef operand1,
1986                        IdRef operand2)
1987 {
1988     const size_t startSize = blob->size();
1989     blob->push_back(0);
1990     blob->push_back(idResultType);
1991     blob->push_back(idResult);
1992     blob->push_back(operand1);
1993     blob->push_back(operand2);
1994     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdNotEqual);
1995 }
WriteFUnordNotEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1996 void WriteFUnordNotEqual(Blob *blob,
1997                          IdResultType idResultType,
1998                          IdResult idResult,
1999                          IdRef operand1,
2000                          IdRef operand2)
2001 {
2002     const size_t startSize = blob->size();
2003     blob->push_back(0);
2004     blob->push_back(idResultType);
2005     blob->push_back(idResult);
2006     blob->push_back(operand1);
2007     blob->push_back(operand2);
2008     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordNotEqual);
2009 }
WriteFOrdLessThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2010 void WriteFOrdLessThan(Blob *blob,
2011                        IdResultType idResultType,
2012                        IdResult idResult,
2013                        IdRef operand1,
2014                        IdRef operand2)
2015 {
2016     const size_t startSize = blob->size();
2017     blob->push_back(0);
2018     blob->push_back(idResultType);
2019     blob->push_back(idResult);
2020     blob->push_back(operand1);
2021     blob->push_back(operand2);
2022     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdLessThan);
2023 }
WriteFUnordLessThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2024 void WriteFUnordLessThan(Blob *blob,
2025                          IdResultType idResultType,
2026                          IdResult idResult,
2027                          IdRef operand1,
2028                          IdRef operand2)
2029 {
2030     const size_t startSize = blob->size();
2031     blob->push_back(0);
2032     blob->push_back(idResultType);
2033     blob->push_back(idResult);
2034     blob->push_back(operand1);
2035     blob->push_back(operand2);
2036     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordLessThan);
2037 }
WriteFOrdGreaterThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2038 void WriteFOrdGreaterThan(Blob *blob,
2039                           IdResultType idResultType,
2040                           IdResult idResult,
2041                           IdRef operand1,
2042                           IdRef operand2)
2043 {
2044     const size_t startSize = blob->size();
2045     blob->push_back(0);
2046     blob->push_back(idResultType);
2047     blob->push_back(idResult);
2048     blob->push_back(operand1);
2049     blob->push_back(operand2);
2050     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdGreaterThan);
2051 }
WriteFUnordGreaterThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2052 void WriteFUnordGreaterThan(Blob *blob,
2053                             IdResultType idResultType,
2054                             IdResult idResult,
2055                             IdRef operand1,
2056                             IdRef operand2)
2057 {
2058     const size_t startSize = blob->size();
2059     blob->push_back(0);
2060     blob->push_back(idResultType);
2061     blob->push_back(idResult);
2062     blob->push_back(operand1);
2063     blob->push_back(operand2);
2064     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordGreaterThan);
2065 }
WriteFOrdLessThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2066 void WriteFOrdLessThanEqual(Blob *blob,
2067                             IdResultType idResultType,
2068                             IdResult idResult,
2069                             IdRef operand1,
2070                             IdRef operand2)
2071 {
2072     const size_t startSize = blob->size();
2073     blob->push_back(0);
2074     blob->push_back(idResultType);
2075     blob->push_back(idResult);
2076     blob->push_back(operand1);
2077     blob->push_back(operand2);
2078     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdLessThanEqual);
2079 }
WriteFUnordLessThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2080 void WriteFUnordLessThanEqual(Blob *blob,
2081                               IdResultType idResultType,
2082                               IdResult idResult,
2083                               IdRef operand1,
2084                               IdRef operand2)
2085 {
2086     const size_t startSize = blob->size();
2087     blob->push_back(0);
2088     blob->push_back(idResultType);
2089     blob->push_back(idResult);
2090     blob->push_back(operand1);
2091     blob->push_back(operand2);
2092     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordLessThanEqual);
2093 }
WriteFOrdGreaterThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2094 void WriteFOrdGreaterThanEqual(Blob *blob,
2095                                IdResultType idResultType,
2096                                IdResult idResult,
2097                                IdRef operand1,
2098                                IdRef operand2)
2099 {
2100     const size_t startSize = blob->size();
2101     blob->push_back(0);
2102     blob->push_back(idResultType);
2103     blob->push_back(idResult);
2104     blob->push_back(operand1);
2105     blob->push_back(operand2);
2106     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdGreaterThanEqual);
2107 }
WriteFUnordGreaterThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2108 void WriteFUnordGreaterThanEqual(Blob *blob,
2109                                  IdResultType idResultType,
2110                                  IdResult idResult,
2111                                  IdRef operand1,
2112                                  IdRef operand2)
2113 {
2114     const size_t startSize = blob->size();
2115     blob->push_back(0);
2116     blob->push_back(idResultType);
2117     blob->push_back(idResult);
2118     blob->push_back(operand1);
2119     blob->push_back(operand2);
2120     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordGreaterThanEqual);
2121 }
WriteShiftRightLogical(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef shift)2122 void WriteShiftRightLogical(Blob *blob,
2123                             IdResultType idResultType,
2124                             IdResult idResult,
2125                             IdRef base,
2126                             IdRef shift)
2127 {
2128     const size_t startSize = blob->size();
2129     blob->push_back(0);
2130     blob->push_back(idResultType);
2131     blob->push_back(idResult);
2132     blob->push_back(base);
2133     blob->push_back(shift);
2134     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpShiftRightLogical);
2135 }
WriteShiftRightArithmetic(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef shift)2136 void WriteShiftRightArithmetic(Blob *blob,
2137                                IdResultType idResultType,
2138                                IdResult idResult,
2139                                IdRef base,
2140                                IdRef shift)
2141 {
2142     const size_t startSize = blob->size();
2143     blob->push_back(0);
2144     blob->push_back(idResultType);
2145     blob->push_back(idResult);
2146     blob->push_back(base);
2147     blob->push_back(shift);
2148     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpShiftRightArithmetic);
2149 }
WriteShiftLeftLogical(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef shift)2150 void WriteShiftLeftLogical(Blob *blob,
2151                            IdResultType idResultType,
2152                            IdResult idResult,
2153                            IdRef base,
2154                            IdRef shift)
2155 {
2156     const size_t startSize = blob->size();
2157     blob->push_back(0);
2158     blob->push_back(idResultType);
2159     blob->push_back(idResult);
2160     blob->push_back(base);
2161     blob->push_back(shift);
2162     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpShiftLeftLogical);
2163 }
WriteBitwiseOr(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2164 void WriteBitwiseOr(Blob *blob,
2165                     IdResultType idResultType,
2166                     IdResult idResult,
2167                     IdRef operand1,
2168                     IdRef operand2)
2169 {
2170     const size_t startSize = blob->size();
2171     blob->push_back(0);
2172     blob->push_back(idResultType);
2173     blob->push_back(idResult);
2174     blob->push_back(operand1);
2175     blob->push_back(operand2);
2176     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitwiseOr);
2177 }
WriteBitwiseXor(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2178 void WriteBitwiseXor(Blob *blob,
2179                      IdResultType idResultType,
2180                      IdResult idResult,
2181                      IdRef operand1,
2182                      IdRef operand2)
2183 {
2184     const size_t startSize = blob->size();
2185     blob->push_back(0);
2186     blob->push_back(idResultType);
2187     blob->push_back(idResult);
2188     blob->push_back(operand1);
2189     blob->push_back(operand2);
2190     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitwiseXor);
2191 }
WriteBitwiseAnd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2192 void WriteBitwiseAnd(Blob *blob,
2193                      IdResultType idResultType,
2194                      IdResult idResult,
2195                      IdRef operand1,
2196                      IdRef operand2)
2197 {
2198     const size_t startSize = blob->size();
2199     blob->push_back(0);
2200     blob->push_back(idResultType);
2201     blob->push_back(idResult);
2202     blob->push_back(operand1);
2203     blob->push_back(operand2);
2204     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitwiseAnd);
2205 }
WriteNot(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)2206 void WriteNot(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
2207 {
2208     const size_t startSize = blob->size();
2209     blob->push_back(0);
2210     blob->push_back(idResultType);
2211     blob->push_back(idResult);
2212     blob->push_back(operand);
2213     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpNot);
2214 }
WriteBitFieldInsert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef insert,IdRef offset,IdRef count)2215 void WriteBitFieldInsert(Blob *blob,
2216                          IdResultType idResultType,
2217                          IdResult idResult,
2218                          IdRef base,
2219                          IdRef insert,
2220                          IdRef offset,
2221                          IdRef count)
2222 {
2223     const size_t startSize = blob->size();
2224     blob->push_back(0);
2225     blob->push_back(idResultType);
2226     blob->push_back(idResult);
2227     blob->push_back(base);
2228     blob->push_back(insert);
2229     blob->push_back(offset);
2230     blob->push_back(count);
2231     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitFieldInsert);
2232 }
WriteBitFieldSExtract(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef offset,IdRef count)2233 void WriteBitFieldSExtract(Blob *blob,
2234                            IdResultType idResultType,
2235                            IdResult idResult,
2236                            IdRef base,
2237                            IdRef offset,
2238                            IdRef count)
2239 {
2240     const size_t startSize = blob->size();
2241     blob->push_back(0);
2242     blob->push_back(idResultType);
2243     blob->push_back(idResult);
2244     blob->push_back(base);
2245     blob->push_back(offset);
2246     blob->push_back(count);
2247     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitFieldSExtract);
2248 }
WriteBitFieldUExtract(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef offset,IdRef count)2249 void WriteBitFieldUExtract(Blob *blob,
2250                            IdResultType idResultType,
2251                            IdResult idResult,
2252                            IdRef base,
2253                            IdRef offset,
2254                            IdRef count)
2255 {
2256     const size_t startSize = blob->size();
2257     blob->push_back(0);
2258     blob->push_back(idResultType);
2259     blob->push_back(idResult);
2260     blob->push_back(base);
2261     blob->push_back(offset);
2262     blob->push_back(count);
2263     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitFieldUExtract);
2264 }
WriteBitReverse(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base)2265 void WriteBitReverse(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef base)
2266 {
2267     const size_t startSize = blob->size();
2268     blob->push_back(0);
2269     blob->push_back(idResultType);
2270     blob->push_back(idResult);
2271     blob->push_back(base);
2272     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitReverse);
2273 }
WriteBitCount(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base)2274 void WriteBitCount(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef base)
2275 {
2276     const size_t startSize = blob->size();
2277     blob->push_back(0);
2278     blob->push_back(idResultType);
2279     blob->push_back(idResult);
2280     blob->push_back(base);
2281     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitCount);
2282 }
WriteDPdx(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2283 void WriteDPdx(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2284 {
2285     const size_t startSize = blob->size();
2286     blob->push_back(0);
2287     blob->push_back(idResultType);
2288     blob->push_back(idResult);
2289     blob->push_back(p);
2290     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdx);
2291 }
WriteDPdy(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2292 void WriteDPdy(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2293 {
2294     const size_t startSize = blob->size();
2295     blob->push_back(0);
2296     blob->push_back(idResultType);
2297     blob->push_back(idResult);
2298     blob->push_back(p);
2299     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdy);
2300 }
WriteFwidth(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2301 void WriteFwidth(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2302 {
2303     const size_t startSize = blob->size();
2304     blob->push_back(0);
2305     blob->push_back(idResultType);
2306     blob->push_back(idResult);
2307     blob->push_back(p);
2308     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFwidth);
2309 }
WriteDPdxFine(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2310 void WriteDPdxFine(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2311 {
2312     const size_t startSize = blob->size();
2313     blob->push_back(0);
2314     blob->push_back(idResultType);
2315     blob->push_back(idResult);
2316     blob->push_back(p);
2317     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdxFine);
2318 }
WriteDPdyFine(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2319 void WriteDPdyFine(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2320 {
2321     const size_t startSize = blob->size();
2322     blob->push_back(0);
2323     blob->push_back(idResultType);
2324     blob->push_back(idResult);
2325     blob->push_back(p);
2326     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdyFine);
2327 }
WriteFwidthFine(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2328 void WriteFwidthFine(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2329 {
2330     const size_t startSize = blob->size();
2331     blob->push_back(0);
2332     blob->push_back(idResultType);
2333     blob->push_back(idResult);
2334     blob->push_back(p);
2335     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFwidthFine);
2336 }
WriteDPdxCoarse(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2337 void WriteDPdxCoarse(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2338 {
2339     const size_t startSize = blob->size();
2340     blob->push_back(0);
2341     blob->push_back(idResultType);
2342     blob->push_back(idResult);
2343     blob->push_back(p);
2344     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdxCoarse);
2345 }
WriteDPdyCoarse(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2346 void WriteDPdyCoarse(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2347 {
2348     const size_t startSize = blob->size();
2349     blob->push_back(0);
2350     blob->push_back(idResultType);
2351     blob->push_back(idResult);
2352     blob->push_back(p);
2353     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdyCoarse);
2354 }
WriteFwidthCoarse(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2355 void WriteFwidthCoarse(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2356 {
2357     const size_t startSize = blob->size();
2358     blob->push_back(0);
2359     blob->push_back(idResultType);
2360     blob->push_back(idResult);
2361     blob->push_back(p);
2362     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFwidthCoarse);
2363 }
WriteEmitVertex(Blob * blob)2364 void WriteEmitVertex(Blob *blob)
2365 {
2366     const size_t startSize = blob->size();
2367     blob->push_back(0);
2368 
2369     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEmitVertex);
2370 }
WriteEndPrimitive(Blob * blob)2371 void WriteEndPrimitive(Blob *blob)
2372 {
2373     const size_t startSize = blob->size();
2374     blob->push_back(0);
2375 
2376     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEndPrimitive);
2377 }
WriteEmitStreamVertex(Blob * blob,IdRef stream)2378 void WriteEmitStreamVertex(Blob *blob, IdRef stream)
2379 {
2380     const size_t startSize = blob->size();
2381     blob->push_back(0);
2382     blob->push_back(stream);
2383     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEmitStreamVertex);
2384 }
WriteEndStreamPrimitive(Blob * blob,IdRef stream)2385 void WriteEndStreamPrimitive(Blob *blob, IdRef stream)
2386 {
2387     const size_t startSize = blob->size();
2388     blob->push_back(0);
2389     blob->push_back(stream);
2390     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEndStreamPrimitive);
2391 }
WriteControlBarrier(Blob * blob,IdScope execution,IdScope memory,IdMemorySemantics semantics)2392 void WriteControlBarrier(Blob *blob, IdScope execution, IdScope memory, IdMemorySemantics semantics)
2393 {
2394     const size_t startSize = blob->size();
2395     blob->push_back(0);
2396     blob->push_back(execution);
2397     blob->push_back(memory);
2398     blob->push_back(semantics);
2399     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpControlBarrier);
2400 }
WriteMemoryBarrier(Blob * blob,IdScope memory,IdMemorySemantics semantics)2401 void WriteMemoryBarrier(Blob *blob, IdScope memory, IdMemorySemantics semantics)
2402 {
2403     const size_t startSize = blob->size();
2404     blob->push_back(0);
2405     blob->push_back(memory);
2406     blob->push_back(semantics);
2407     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMemoryBarrier);
2408 }
WriteAtomicLoad(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics)2409 void WriteAtomicLoad(Blob *blob,
2410                      IdResultType idResultType,
2411                      IdResult idResult,
2412                      IdRef pointer,
2413                      IdScope scope,
2414                      IdMemorySemantics semantics)
2415 {
2416     const size_t startSize = blob->size();
2417     blob->push_back(0);
2418     blob->push_back(idResultType);
2419     blob->push_back(idResult);
2420     blob->push_back(pointer);
2421     blob->push_back(scope);
2422     blob->push_back(semantics);
2423     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicLoad);
2424 }
WriteAtomicStore(Blob * blob,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2425 void WriteAtomicStore(Blob *blob,
2426                       IdRef pointer,
2427                       IdScope scope,
2428                       IdMemorySemantics semantics,
2429                       IdRef value)
2430 {
2431     const size_t startSize = blob->size();
2432     blob->push_back(0);
2433     blob->push_back(pointer);
2434     blob->push_back(scope);
2435     blob->push_back(semantics);
2436     blob->push_back(value);
2437     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicStore);
2438 }
WriteAtomicExchange(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2439 void WriteAtomicExchange(Blob *blob,
2440                          IdResultType idResultType,
2441                          IdResult idResult,
2442                          IdRef pointer,
2443                          IdScope scope,
2444                          IdMemorySemantics semantics,
2445                          IdRef value)
2446 {
2447     const size_t startSize = blob->size();
2448     blob->push_back(0);
2449     blob->push_back(idResultType);
2450     blob->push_back(idResult);
2451     blob->push_back(pointer);
2452     blob->push_back(scope);
2453     blob->push_back(semantics);
2454     blob->push_back(value);
2455     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicExchange);
2456 }
WriteAtomicCompareExchange(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics equal,IdMemorySemantics unequal,IdRef value,IdRef comparator)2457 void WriteAtomicCompareExchange(Blob *blob,
2458                                 IdResultType idResultType,
2459                                 IdResult idResult,
2460                                 IdRef pointer,
2461                                 IdScope scope,
2462                                 IdMemorySemantics equal,
2463                                 IdMemorySemantics unequal,
2464                                 IdRef value,
2465                                 IdRef comparator)
2466 {
2467     const size_t startSize = blob->size();
2468     blob->push_back(0);
2469     blob->push_back(idResultType);
2470     blob->push_back(idResult);
2471     blob->push_back(pointer);
2472     blob->push_back(scope);
2473     blob->push_back(equal);
2474     blob->push_back(unequal);
2475     blob->push_back(value);
2476     blob->push_back(comparator);
2477     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicCompareExchange);
2478 }
WriteAtomicIIncrement(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics)2479 void WriteAtomicIIncrement(Blob *blob,
2480                            IdResultType idResultType,
2481                            IdResult idResult,
2482                            IdRef pointer,
2483                            IdScope scope,
2484                            IdMemorySemantics semantics)
2485 {
2486     const size_t startSize = blob->size();
2487     blob->push_back(0);
2488     blob->push_back(idResultType);
2489     blob->push_back(idResult);
2490     blob->push_back(pointer);
2491     blob->push_back(scope);
2492     blob->push_back(semantics);
2493     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicIIncrement);
2494 }
WriteAtomicIDecrement(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics)2495 void WriteAtomicIDecrement(Blob *blob,
2496                            IdResultType idResultType,
2497                            IdResult idResult,
2498                            IdRef pointer,
2499                            IdScope scope,
2500                            IdMemorySemantics semantics)
2501 {
2502     const size_t startSize = blob->size();
2503     blob->push_back(0);
2504     blob->push_back(idResultType);
2505     blob->push_back(idResult);
2506     blob->push_back(pointer);
2507     blob->push_back(scope);
2508     blob->push_back(semantics);
2509     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicIDecrement);
2510 }
WriteAtomicIAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2511 void WriteAtomicIAdd(Blob *blob,
2512                      IdResultType idResultType,
2513                      IdResult idResult,
2514                      IdRef pointer,
2515                      IdScope scope,
2516                      IdMemorySemantics semantics,
2517                      IdRef value)
2518 {
2519     const size_t startSize = blob->size();
2520     blob->push_back(0);
2521     blob->push_back(idResultType);
2522     blob->push_back(idResult);
2523     blob->push_back(pointer);
2524     blob->push_back(scope);
2525     blob->push_back(semantics);
2526     blob->push_back(value);
2527     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicIAdd);
2528 }
WriteAtomicISub(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2529 void WriteAtomicISub(Blob *blob,
2530                      IdResultType idResultType,
2531                      IdResult idResult,
2532                      IdRef pointer,
2533                      IdScope scope,
2534                      IdMemorySemantics semantics,
2535                      IdRef value)
2536 {
2537     const size_t startSize = blob->size();
2538     blob->push_back(0);
2539     blob->push_back(idResultType);
2540     blob->push_back(idResult);
2541     blob->push_back(pointer);
2542     blob->push_back(scope);
2543     blob->push_back(semantics);
2544     blob->push_back(value);
2545     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicISub);
2546 }
WriteAtomicSMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2547 void WriteAtomicSMin(Blob *blob,
2548                      IdResultType idResultType,
2549                      IdResult idResult,
2550                      IdRef pointer,
2551                      IdScope scope,
2552                      IdMemorySemantics semantics,
2553                      IdRef value)
2554 {
2555     const size_t startSize = blob->size();
2556     blob->push_back(0);
2557     blob->push_back(idResultType);
2558     blob->push_back(idResult);
2559     blob->push_back(pointer);
2560     blob->push_back(scope);
2561     blob->push_back(semantics);
2562     blob->push_back(value);
2563     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicSMin);
2564 }
WriteAtomicUMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2565 void WriteAtomicUMin(Blob *blob,
2566                      IdResultType idResultType,
2567                      IdResult idResult,
2568                      IdRef pointer,
2569                      IdScope scope,
2570                      IdMemorySemantics semantics,
2571                      IdRef value)
2572 {
2573     const size_t startSize = blob->size();
2574     blob->push_back(0);
2575     blob->push_back(idResultType);
2576     blob->push_back(idResult);
2577     blob->push_back(pointer);
2578     blob->push_back(scope);
2579     blob->push_back(semantics);
2580     blob->push_back(value);
2581     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicUMin);
2582 }
WriteAtomicSMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2583 void WriteAtomicSMax(Blob *blob,
2584                      IdResultType idResultType,
2585                      IdResult idResult,
2586                      IdRef pointer,
2587                      IdScope scope,
2588                      IdMemorySemantics semantics,
2589                      IdRef value)
2590 {
2591     const size_t startSize = blob->size();
2592     blob->push_back(0);
2593     blob->push_back(idResultType);
2594     blob->push_back(idResult);
2595     blob->push_back(pointer);
2596     blob->push_back(scope);
2597     blob->push_back(semantics);
2598     blob->push_back(value);
2599     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicSMax);
2600 }
WriteAtomicUMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2601 void WriteAtomicUMax(Blob *blob,
2602                      IdResultType idResultType,
2603                      IdResult idResult,
2604                      IdRef pointer,
2605                      IdScope scope,
2606                      IdMemorySemantics semantics,
2607                      IdRef value)
2608 {
2609     const size_t startSize = blob->size();
2610     blob->push_back(0);
2611     blob->push_back(idResultType);
2612     blob->push_back(idResult);
2613     blob->push_back(pointer);
2614     blob->push_back(scope);
2615     blob->push_back(semantics);
2616     blob->push_back(value);
2617     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicUMax);
2618 }
WriteAtomicAnd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2619 void WriteAtomicAnd(Blob *blob,
2620                     IdResultType idResultType,
2621                     IdResult idResult,
2622                     IdRef pointer,
2623                     IdScope scope,
2624                     IdMemorySemantics semantics,
2625                     IdRef value)
2626 {
2627     const size_t startSize = blob->size();
2628     blob->push_back(0);
2629     blob->push_back(idResultType);
2630     blob->push_back(idResult);
2631     blob->push_back(pointer);
2632     blob->push_back(scope);
2633     blob->push_back(semantics);
2634     blob->push_back(value);
2635     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicAnd);
2636 }
WriteAtomicOr(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2637 void WriteAtomicOr(Blob *blob,
2638                    IdResultType idResultType,
2639                    IdResult idResult,
2640                    IdRef pointer,
2641                    IdScope scope,
2642                    IdMemorySemantics semantics,
2643                    IdRef value)
2644 {
2645     const size_t startSize = blob->size();
2646     blob->push_back(0);
2647     blob->push_back(idResultType);
2648     blob->push_back(idResult);
2649     blob->push_back(pointer);
2650     blob->push_back(scope);
2651     blob->push_back(semantics);
2652     blob->push_back(value);
2653     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicOr);
2654 }
WriteAtomicXor(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2655 void WriteAtomicXor(Blob *blob,
2656                     IdResultType idResultType,
2657                     IdResult idResult,
2658                     IdRef pointer,
2659                     IdScope scope,
2660                     IdMemorySemantics semantics,
2661                     IdRef value)
2662 {
2663     const size_t startSize = blob->size();
2664     blob->push_back(0);
2665     blob->push_back(idResultType);
2666     blob->push_back(idResult);
2667     blob->push_back(pointer);
2668     blob->push_back(scope);
2669     blob->push_back(semantics);
2670     blob->push_back(value);
2671     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicXor);
2672 }
WritePhi(Blob * blob,IdResultType idResultType,IdResult idResult,const PairIdRefIdRefList & variableParentPairList)2673 void WritePhi(Blob *blob,
2674               IdResultType idResultType,
2675               IdResult idResult,
2676               const PairIdRefIdRefList &variableParentPairList)
2677 {
2678     const size_t startSize = blob->size();
2679     blob->push_back(0);
2680     blob->push_back(idResultType);
2681     blob->push_back(idResult);
2682     for (const auto &operand : variableParentPairList)
2683     {
2684         blob->push_back(operand.id1);
2685         blob->push_back(operand.id2);
2686     }
2687     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpPhi);
2688 }
WriteLoopMerge(Blob * blob,IdRef mergeBlock,IdRef continueTarget,spv::LoopControlMask loopControl)2689 void WriteLoopMerge(Blob *blob,
2690                     IdRef mergeBlock,
2691                     IdRef continueTarget,
2692                     spv::LoopControlMask loopControl)
2693 {
2694     const size_t startSize = blob->size();
2695     blob->push_back(0);
2696     blob->push_back(mergeBlock);
2697     blob->push_back(continueTarget);
2698     blob->push_back(loopControl);
2699     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLoopMerge);
2700 }
WriteSelectionMerge(Blob * blob,IdRef mergeBlock,spv::SelectionControlMask selectionControl)2701 void WriteSelectionMerge(Blob *blob, IdRef mergeBlock, spv::SelectionControlMask selectionControl)
2702 {
2703     const size_t startSize = blob->size();
2704     blob->push_back(0);
2705     blob->push_back(mergeBlock);
2706     blob->push_back(selectionControl);
2707     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSelectionMerge);
2708 }
WriteLabel(Blob * blob,IdResult idResult)2709 void WriteLabel(Blob *blob, IdResult idResult)
2710 {
2711     const size_t startSize = blob->size();
2712     blob->push_back(0);
2713     blob->push_back(idResult);
2714     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLabel);
2715 }
WriteBranch(Blob * blob,IdRef targetLabel)2716 void WriteBranch(Blob *blob, IdRef targetLabel)
2717 {
2718     const size_t startSize = blob->size();
2719     blob->push_back(0);
2720     blob->push_back(targetLabel);
2721     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBranch);
2722 }
WriteBranchConditional(Blob * blob,IdRef condition,IdRef trueLabel,IdRef falseLabel,const LiteralIntegerList & branchweightsList)2723 void WriteBranchConditional(Blob *blob,
2724                             IdRef condition,
2725                             IdRef trueLabel,
2726                             IdRef falseLabel,
2727                             const LiteralIntegerList &branchweightsList)
2728 {
2729     const size_t startSize = blob->size();
2730     blob->push_back(0);
2731     blob->push_back(condition);
2732     blob->push_back(trueLabel);
2733     blob->push_back(falseLabel);
2734     for (const auto &operand : branchweightsList)
2735     {
2736         blob->push_back(operand);
2737     }
2738     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBranchConditional);
2739 }
WriteSwitch(Blob * blob,IdRef selector,IdRef default_,const PairLiteralIntegerIdRefList & targetPairList)2740 void WriteSwitch(Blob *blob,
2741                  IdRef selector,
2742                  IdRef default_,
2743                  const PairLiteralIntegerIdRefList &targetPairList)
2744 {
2745     const size_t startSize = blob->size();
2746     blob->push_back(0);
2747     blob->push_back(selector);
2748     blob->push_back(default_);
2749     for (const auto &operand : targetPairList)
2750     {
2751         blob->push_back(operand.literal);
2752         blob->push_back(operand.id);
2753     }
2754     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSwitch);
2755 }
WriteKill(Blob * blob)2756 void WriteKill(Blob *blob)
2757 {
2758     const size_t startSize = blob->size();
2759     blob->push_back(0);
2760 
2761     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpKill);
2762 }
WriteReturn(Blob * blob)2763 void WriteReturn(Blob *blob)
2764 {
2765     const size_t startSize = blob->size();
2766     blob->push_back(0);
2767 
2768     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpReturn);
2769 }
WriteReturnValue(Blob * blob,IdRef value)2770 void WriteReturnValue(Blob *blob, IdRef value)
2771 {
2772     const size_t startSize = blob->size();
2773     blob->push_back(0);
2774     blob->push_back(value);
2775     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpReturnValue);
2776 }
WriteUnreachable(Blob * blob)2777 void WriteUnreachable(Blob *blob)
2778 {
2779     const size_t startSize = blob->size();
2780     blob->push_back(0);
2781 
2782     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUnreachable);
2783 }
WriteGroupAll(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,IdRef predicate)2784 void WriteGroupAll(Blob *blob,
2785                    IdResultType idResultType,
2786                    IdResult idResult,
2787                    IdScope execution,
2788                    IdRef predicate)
2789 {
2790     const size_t startSize = blob->size();
2791     blob->push_back(0);
2792     blob->push_back(idResultType);
2793     blob->push_back(idResult);
2794     blob->push_back(execution);
2795     blob->push_back(predicate);
2796     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupAll);
2797 }
WriteGroupAny(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,IdRef predicate)2798 void WriteGroupAny(Blob *blob,
2799                    IdResultType idResultType,
2800                    IdResult idResult,
2801                    IdScope execution,
2802                    IdRef predicate)
2803 {
2804     const size_t startSize = blob->size();
2805     blob->push_back(0);
2806     blob->push_back(idResultType);
2807     blob->push_back(idResult);
2808     blob->push_back(execution);
2809     blob->push_back(predicate);
2810     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupAny);
2811 }
WriteGroupBroadcast(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,IdRef value,IdRef localId)2812 void WriteGroupBroadcast(Blob *blob,
2813                          IdResultType idResultType,
2814                          IdResult idResult,
2815                          IdScope execution,
2816                          IdRef value,
2817                          IdRef localId)
2818 {
2819     const size_t startSize = blob->size();
2820     blob->push_back(0);
2821     blob->push_back(idResultType);
2822     blob->push_back(idResult);
2823     blob->push_back(execution);
2824     blob->push_back(value);
2825     blob->push_back(localId);
2826     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupBroadcast);
2827 }
WriteGroupIAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2828 void WriteGroupIAdd(Blob *blob,
2829                     IdResultType idResultType,
2830                     IdResult idResult,
2831                     IdScope execution,
2832                     spv::GroupOperation operation,
2833                     IdRef x)
2834 {
2835     const size_t startSize = blob->size();
2836     blob->push_back(0);
2837     blob->push_back(idResultType);
2838     blob->push_back(idResult);
2839     blob->push_back(execution);
2840     blob->push_back(operation);
2841     blob->push_back(x);
2842     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupIAdd);
2843 }
WriteGroupFAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2844 void WriteGroupFAdd(Blob *blob,
2845                     IdResultType idResultType,
2846                     IdResult idResult,
2847                     IdScope execution,
2848                     spv::GroupOperation operation,
2849                     IdRef x)
2850 {
2851     const size_t startSize = blob->size();
2852     blob->push_back(0);
2853     blob->push_back(idResultType);
2854     blob->push_back(idResult);
2855     blob->push_back(execution);
2856     blob->push_back(operation);
2857     blob->push_back(x);
2858     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFAdd);
2859 }
WriteGroupFMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2860 void WriteGroupFMin(Blob *blob,
2861                     IdResultType idResultType,
2862                     IdResult idResult,
2863                     IdScope execution,
2864                     spv::GroupOperation operation,
2865                     IdRef x)
2866 {
2867     const size_t startSize = blob->size();
2868     blob->push_back(0);
2869     blob->push_back(idResultType);
2870     blob->push_back(idResult);
2871     blob->push_back(execution);
2872     blob->push_back(operation);
2873     blob->push_back(x);
2874     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFMin);
2875 }
WriteGroupUMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2876 void WriteGroupUMin(Blob *blob,
2877                     IdResultType idResultType,
2878                     IdResult idResult,
2879                     IdScope execution,
2880                     spv::GroupOperation operation,
2881                     IdRef x)
2882 {
2883     const size_t startSize = blob->size();
2884     blob->push_back(0);
2885     blob->push_back(idResultType);
2886     blob->push_back(idResult);
2887     blob->push_back(execution);
2888     blob->push_back(operation);
2889     blob->push_back(x);
2890     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupUMin);
2891 }
WriteGroupSMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2892 void WriteGroupSMin(Blob *blob,
2893                     IdResultType idResultType,
2894                     IdResult idResult,
2895                     IdScope execution,
2896                     spv::GroupOperation operation,
2897                     IdRef x)
2898 {
2899     const size_t startSize = blob->size();
2900     blob->push_back(0);
2901     blob->push_back(idResultType);
2902     blob->push_back(idResult);
2903     blob->push_back(execution);
2904     blob->push_back(operation);
2905     blob->push_back(x);
2906     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupSMin);
2907 }
WriteGroupFMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2908 void WriteGroupFMax(Blob *blob,
2909                     IdResultType idResultType,
2910                     IdResult idResult,
2911                     IdScope execution,
2912                     spv::GroupOperation operation,
2913                     IdRef x)
2914 {
2915     const size_t startSize = blob->size();
2916     blob->push_back(0);
2917     blob->push_back(idResultType);
2918     blob->push_back(idResult);
2919     blob->push_back(execution);
2920     blob->push_back(operation);
2921     blob->push_back(x);
2922     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFMax);
2923 }
WriteGroupUMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2924 void WriteGroupUMax(Blob *blob,
2925                     IdResultType idResultType,
2926                     IdResult idResult,
2927                     IdScope execution,
2928                     spv::GroupOperation operation,
2929                     IdRef x)
2930 {
2931     const size_t startSize = blob->size();
2932     blob->push_back(0);
2933     blob->push_back(idResultType);
2934     blob->push_back(idResult);
2935     blob->push_back(execution);
2936     blob->push_back(operation);
2937     blob->push_back(x);
2938     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupUMax);
2939 }
WriteGroupSMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2940 void WriteGroupSMax(Blob *blob,
2941                     IdResultType idResultType,
2942                     IdResult idResult,
2943                     IdScope execution,
2944                     spv::GroupOperation operation,
2945                     IdRef x)
2946 {
2947     const size_t startSize = blob->size();
2948     blob->push_back(0);
2949     blob->push_back(idResultType);
2950     blob->push_back(idResult);
2951     blob->push_back(execution);
2952     blob->push_back(operation);
2953     blob->push_back(x);
2954     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupSMax);
2955 }
WriteImageSparseSampleImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)2956 void WriteImageSparseSampleImplicitLod(Blob *blob,
2957                                        IdResultType idResultType,
2958                                        IdResult idResult,
2959                                        IdRef sampledImage,
2960                                        IdRef coordinate,
2961                                        const spv::ImageOperandsMask *imageOperands,
2962                                        const IdRefList &imageOperandIdsList)
2963 {
2964     const size_t startSize = blob->size();
2965     blob->push_back(0);
2966     blob->push_back(idResultType);
2967     blob->push_back(idResult);
2968     blob->push_back(sampledImage);
2969     blob->push_back(coordinate);
2970     if (imageOperands)
2971     {
2972         blob->push_back(*imageOperands);
2973     }
2974     for (const auto &operand : imageOperandIdsList)
2975     {
2976         blob->push_back(operand);
2977     }
2978     (*blob)[startSize] =
2979         MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleImplicitLod);
2980 }
WriteImageSparseSampleExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)2981 void WriteImageSparseSampleExplicitLod(Blob *blob,
2982                                        IdResultType idResultType,
2983                                        IdResult idResult,
2984                                        IdRef sampledImage,
2985                                        IdRef coordinate,
2986                                        spv::ImageOperandsMask imageOperands,
2987                                        const IdRefList &imageOperandIdsList)
2988 {
2989     const size_t startSize = blob->size();
2990     blob->push_back(0);
2991     blob->push_back(idResultType);
2992     blob->push_back(idResult);
2993     blob->push_back(sampledImage);
2994     blob->push_back(coordinate);
2995     blob->push_back(imageOperands);
2996     for (const auto &operand : imageOperandIdsList)
2997     {
2998         blob->push_back(operand);
2999     }
3000     (*blob)[startSize] =
3001         MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleExplicitLod);
3002 }
WriteImageSparseSampleDrefImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3003 void WriteImageSparseSampleDrefImplicitLod(Blob *blob,
3004                                            IdResultType idResultType,
3005                                            IdResult idResult,
3006                                            IdRef sampledImage,
3007                                            IdRef coordinate,
3008                                            IdRef dref,
3009                                            const spv::ImageOperandsMask *imageOperands,
3010                                            const IdRefList &imageOperandIdsList)
3011 {
3012     const size_t startSize = blob->size();
3013     blob->push_back(0);
3014     blob->push_back(idResultType);
3015     blob->push_back(idResult);
3016     blob->push_back(sampledImage);
3017     blob->push_back(coordinate);
3018     blob->push_back(dref);
3019     if (imageOperands)
3020     {
3021         blob->push_back(*imageOperands);
3022     }
3023     for (const auto &operand : imageOperandIdsList)
3024     {
3025         blob->push_back(operand);
3026     }
3027     (*blob)[startSize] =
3028         MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleDrefImplicitLod);
3029 }
WriteImageSparseSampleDrefExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)3030 void WriteImageSparseSampleDrefExplicitLod(Blob *blob,
3031                                            IdResultType idResultType,
3032                                            IdResult idResult,
3033                                            IdRef sampledImage,
3034                                            IdRef coordinate,
3035                                            IdRef dref,
3036                                            spv::ImageOperandsMask imageOperands,
3037                                            const IdRefList &imageOperandIdsList)
3038 {
3039     const size_t startSize = blob->size();
3040     blob->push_back(0);
3041     blob->push_back(idResultType);
3042     blob->push_back(idResult);
3043     blob->push_back(sampledImage);
3044     blob->push_back(coordinate);
3045     blob->push_back(dref);
3046     blob->push_back(imageOperands);
3047     for (const auto &operand : imageOperandIdsList)
3048     {
3049         blob->push_back(operand);
3050     }
3051     (*blob)[startSize] =
3052         MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleDrefExplicitLod);
3053 }
WriteImageSparseSampleProjImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3054 void WriteImageSparseSampleProjImplicitLod(Blob *blob,
3055                                            IdResultType idResultType,
3056                                            IdResult idResult,
3057                                            IdRef sampledImage,
3058                                            IdRef coordinate,
3059                                            const spv::ImageOperandsMask *imageOperands,
3060                                            const IdRefList &imageOperandIdsList)
3061 {
3062     const size_t startSize = blob->size();
3063     blob->push_back(0);
3064     blob->push_back(idResultType);
3065     blob->push_back(idResult);
3066     blob->push_back(sampledImage);
3067     blob->push_back(coordinate);
3068     if (imageOperands)
3069     {
3070         blob->push_back(*imageOperands);
3071     }
3072     for (const auto &operand : imageOperandIdsList)
3073     {
3074         blob->push_back(operand);
3075     }
3076     (*blob)[startSize] =
3077         MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleProjImplicitLod);
3078 }
WriteImageSparseSampleProjExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)3079 void WriteImageSparseSampleProjExplicitLod(Blob *blob,
3080                                            IdResultType idResultType,
3081                                            IdResult idResult,
3082                                            IdRef sampledImage,
3083                                            IdRef coordinate,
3084                                            spv::ImageOperandsMask imageOperands,
3085                                            const IdRefList &imageOperandIdsList)
3086 {
3087     const size_t startSize = blob->size();
3088     blob->push_back(0);
3089     blob->push_back(idResultType);
3090     blob->push_back(idResult);
3091     blob->push_back(sampledImage);
3092     blob->push_back(coordinate);
3093     blob->push_back(imageOperands);
3094     for (const auto &operand : imageOperandIdsList)
3095     {
3096         blob->push_back(operand);
3097     }
3098     (*blob)[startSize] =
3099         MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleProjExplicitLod);
3100 }
WriteImageSparseSampleProjDrefImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3101 void WriteImageSparseSampleProjDrefImplicitLod(Blob *blob,
3102                                                IdResultType idResultType,
3103                                                IdResult idResult,
3104                                                IdRef sampledImage,
3105                                                IdRef coordinate,
3106                                                IdRef dref,
3107                                                const spv::ImageOperandsMask *imageOperands,
3108                                                const IdRefList &imageOperandIdsList)
3109 {
3110     const size_t startSize = blob->size();
3111     blob->push_back(0);
3112     blob->push_back(idResultType);
3113     blob->push_back(idResult);
3114     blob->push_back(sampledImage);
3115     blob->push_back(coordinate);
3116     blob->push_back(dref);
3117     if (imageOperands)
3118     {
3119         blob->push_back(*imageOperands);
3120     }
3121     for (const auto &operand : imageOperandIdsList)
3122     {
3123         blob->push_back(operand);
3124     }
3125     (*blob)[startSize] =
3126         MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleProjDrefImplicitLod);
3127 }
WriteImageSparseSampleProjDrefExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)3128 void WriteImageSparseSampleProjDrefExplicitLod(Blob *blob,
3129                                                IdResultType idResultType,
3130                                                IdResult idResult,
3131                                                IdRef sampledImage,
3132                                                IdRef coordinate,
3133                                                IdRef dref,
3134                                                spv::ImageOperandsMask imageOperands,
3135                                                const IdRefList &imageOperandIdsList)
3136 {
3137     const size_t startSize = blob->size();
3138     blob->push_back(0);
3139     blob->push_back(idResultType);
3140     blob->push_back(idResult);
3141     blob->push_back(sampledImage);
3142     blob->push_back(coordinate);
3143     blob->push_back(dref);
3144     blob->push_back(imageOperands);
3145     for (const auto &operand : imageOperandIdsList)
3146     {
3147         blob->push_back(operand);
3148     }
3149     (*blob)[startSize] =
3150         MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleProjDrefExplicitLod);
3151 }
WriteImageSparseFetch(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3152 void WriteImageSparseFetch(Blob *blob,
3153                            IdResultType idResultType,
3154                            IdResult idResult,
3155                            IdRef image,
3156                            IdRef coordinate,
3157                            const spv::ImageOperandsMask *imageOperands,
3158                            const IdRefList &imageOperandIdsList)
3159 {
3160     const size_t startSize = blob->size();
3161     blob->push_back(0);
3162     blob->push_back(idResultType);
3163     blob->push_back(idResult);
3164     blob->push_back(image);
3165     blob->push_back(coordinate);
3166     if (imageOperands)
3167     {
3168         blob->push_back(*imageOperands);
3169     }
3170     for (const auto &operand : imageOperandIdsList)
3171     {
3172         blob->push_back(operand);
3173     }
3174     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseFetch);
3175 }
WriteImageSparseGather(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef component,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3176 void WriteImageSparseGather(Blob *blob,
3177                             IdResultType idResultType,
3178                             IdResult idResult,
3179                             IdRef sampledImage,
3180                             IdRef coordinate,
3181                             IdRef component,
3182                             const spv::ImageOperandsMask *imageOperands,
3183                             const IdRefList &imageOperandIdsList)
3184 {
3185     const size_t startSize = blob->size();
3186     blob->push_back(0);
3187     blob->push_back(idResultType);
3188     blob->push_back(idResult);
3189     blob->push_back(sampledImage);
3190     blob->push_back(coordinate);
3191     blob->push_back(component);
3192     if (imageOperands)
3193     {
3194         blob->push_back(*imageOperands);
3195     }
3196     for (const auto &operand : imageOperandIdsList)
3197     {
3198         blob->push_back(operand);
3199     }
3200     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseGather);
3201 }
WriteImageSparseDrefGather(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3202 void WriteImageSparseDrefGather(Blob *blob,
3203                                 IdResultType idResultType,
3204                                 IdResult idResult,
3205                                 IdRef sampledImage,
3206                                 IdRef coordinate,
3207                                 IdRef dref,
3208                                 const spv::ImageOperandsMask *imageOperands,
3209                                 const IdRefList &imageOperandIdsList)
3210 {
3211     const size_t startSize = blob->size();
3212     blob->push_back(0);
3213     blob->push_back(idResultType);
3214     blob->push_back(idResult);
3215     blob->push_back(sampledImage);
3216     blob->push_back(coordinate);
3217     blob->push_back(dref);
3218     if (imageOperands)
3219     {
3220         blob->push_back(*imageOperands);
3221     }
3222     for (const auto &operand : imageOperandIdsList)
3223     {
3224         blob->push_back(operand);
3225     }
3226     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseDrefGather);
3227 }
WriteImageSparseTexelsResident(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef residentCode)3228 void WriteImageSparseTexelsResident(Blob *blob,
3229                                     IdResultType idResultType,
3230                                     IdResult idResult,
3231                                     IdRef residentCode)
3232 {
3233     const size_t startSize = blob->size();
3234     blob->push_back(0);
3235     blob->push_back(idResultType);
3236     blob->push_back(idResult);
3237     blob->push_back(residentCode);
3238     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseTexelsResident);
3239 }
WriteNoLine(Blob * blob)3240 void WriteNoLine(Blob *blob)
3241 {
3242     const size_t startSize = blob->size();
3243     blob->push_back(0);
3244 
3245     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpNoLine);
3246 }
WriteImageSparseRead(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3247 void WriteImageSparseRead(Blob *blob,
3248                           IdResultType idResultType,
3249                           IdResult idResult,
3250                           IdRef image,
3251                           IdRef coordinate,
3252                           const spv::ImageOperandsMask *imageOperands,
3253                           const IdRefList &imageOperandIdsList)
3254 {
3255     const size_t startSize = blob->size();
3256     blob->push_back(0);
3257     blob->push_back(idResultType);
3258     blob->push_back(idResult);
3259     blob->push_back(image);
3260     blob->push_back(coordinate);
3261     if (imageOperands)
3262     {
3263         blob->push_back(*imageOperands);
3264     }
3265     for (const auto &operand : imageOperandIdsList)
3266     {
3267         blob->push_back(operand);
3268     }
3269     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseRead);
3270 }
WriteGroupIAddNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3271 void WriteGroupIAddNonUniformAMD(Blob *blob,
3272                                  IdResultType idResultType,
3273                                  IdResult idResult,
3274                                  IdScope execution,
3275                                  spv::GroupOperation operation,
3276                                  IdRef x)
3277 {
3278     const size_t startSize = blob->size();
3279     blob->push_back(0);
3280     blob->push_back(idResultType);
3281     blob->push_back(idResult);
3282     blob->push_back(execution);
3283     blob->push_back(operation);
3284     blob->push_back(x);
3285     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupIAddNonUniformAMD);
3286 }
WriteGroupFAddNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3287 void WriteGroupFAddNonUniformAMD(Blob *blob,
3288                                  IdResultType idResultType,
3289                                  IdResult idResult,
3290                                  IdScope execution,
3291                                  spv::GroupOperation operation,
3292                                  IdRef x)
3293 {
3294     const size_t startSize = blob->size();
3295     blob->push_back(0);
3296     blob->push_back(idResultType);
3297     blob->push_back(idResult);
3298     blob->push_back(execution);
3299     blob->push_back(operation);
3300     blob->push_back(x);
3301     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFAddNonUniformAMD);
3302 }
WriteGroupFMinNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3303 void WriteGroupFMinNonUniformAMD(Blob *blob,
3304                                  IdResultType idResultType,
3305                                  IdResult idResult,
3306                                  IdScope execution,
3307                                  spv::GroupOperation operation,
3308                                  IdRef x)
3309 {
3310     const size_t startSize = blob->size();
3311     blob->push_back(0);
3312     blob->push_back(idResultType);
3313     blob->push_back(idResult);
3314     blob->push_back(execution);
3315     blob->push_back(operation);
3316     blob->push_back(x);
3317     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFMinNonUniformAMD);
3318 }
WriteGroupUMinNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3319 void WriteGroupUMinNonUniformAMD(Blob *blob,
3320                                  IdResultType idResultType,
3321                                  IdResult idResult,
3322                                  IdScope execution,
3323                                  spv::GroupOperation operation,
3324                                  IdRef x)
3325 {
3326     const size_t startSize = blob->size();
3327     blob->push_back(0);
3328     blob->push_back(idResultType);
3329     blob->push_back(idResult);
3330     blob->push_back(execution);
3331     blob->push_back(operation);
3332     blob->push_back(x);
3333     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupUMinNonUniformAMD);
3334 }
WriteGroupSMinNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3335 void WriteGroupSMinNonUniformAMD(Blob *blob,
3336                                  IdResultType idResultType,
3337                                  IdResult idResult,
3338                                  IdScope execution,
3339                                  spv::GroupOperation operation,
3340                                  IdRef x)
3341 {
3342     const size_t startSize = blob->size();
3343     blob->push_back(0);
3344     blob->push_back(idResultType);
3345     blob->push_back(idResult);
3346     blob->push_back(execution);
3347     blob->push_back(operation);
3348     blob->push_back(x);
3349     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupSMinNonUniformAMD);
3350 }
WriteGroupFMaxNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3351 void WriteGroupFMaxNonUniformAMD(Blob *blob,
3352                                  IdResultType idResultType,
3353                                  IdResult idResult,
3354                                  IdScope execution,
3355                                  spv::GroupOperation operation,
3356                                  IdRef x)
3357 {
3358     const size_t startSize = blob->size();
3359     blob->push_back(0);
3360     blob->push_back(idResultType);
3361     blob->push_back(idResult);
3362     blob->push_back(execution);
3363     blob->push_back(operation);
3364     blob->push_back(x);
3365     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFMaxNonUniformAMD);
3366 }
WriteGroupUMaxNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3367 void WriteGroupUMaxNonUniformAMD(Blob *blob,
3368                                  IdResultType idResultType,
3369                                  IdResult idResult,
3370                                  IdScope execution,
3371                                  spv::GroupOperation operation,
3372                                  IdRef x)
3373 {
3374     const size_t startSize = blob->size();
3375     blob->push_back(0);
3376     blob->push_back(idResultType);
3377     blob->push_back(idResult);
3378     blob->push_back(execution);
3379     blob->push_back(operation);
3380     blob->push_back(x);
3381     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupUMaxNonUniformAMD);
3382 }
WriteGroupSMaxNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3383 void WriteGroupSMaxNonUniformAMD(Blob *blob,
3384                                  IdResultType idResultType,
3385                                  IdResult idResult,
3386                                  IdScope execution,
3387                                  spv::GroupOperation operation,
3388                                  IdRef x)
3389 {
3390     const size_t startSize = blob->size();
3391     blob->push_back(0);
3392     blob->push_back(idResultType);
3393     blob->push_back(idResult);
3394     blob->push_back(execution);
3395     blob->push_back(operation);
3396     blob->push_back(x);
3397     (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupSMaxNonUniformAMD);
3398 }
3399 
3400 }  // namespace spirv
3401 }  // namespace angle
3402