Fix variable scoping of do-while
[platform/upstream/glslang.git] / glslang / MachineIndependent / intermOut.cpp
1 //
2 // Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
3 // Copyright (C) 2012-2016 LunarG, Inc.
4 // Copyright (C) 2017 ARM Limited.
5 // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
6 //
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions
11 // are met:
12 //
13 //    Redistributions of source code must retain the above copyright
14 //    notice, this list of conditions and the following disclaimer.
15 //
16 //    Redistributions in binary form must reproduce the above
17 //    copyright notice, this list of conditions and the following
18 //    disclaimer in the documentation and/or other materials provided
19 //    with the distribution.
20 //
21 //    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
22 //    contributors may be used to endorse or promote products derived
23 //    from this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //
38
39 #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
40
41 #include "localintermediate.h"
42 #include "../Include/InfoSink.h"
43
44 #ifdef _MSC_VER
45 #include <cfloat>
46 #else
47 #include <cmath>
48 #endif
49 #include <cstdint>
50
51 namespace {
52
53 bool IsInfinity(double x) {
54 #ifdef _MSC_VER
55     switch (_fpclass(x)) {
56     case _FPCLASS_NINF:
57     case _FPCLASS_PINF:
58         return true;
59     default:
60         return false;
61     }
62 #else
63     return std::isinf(x);
64 #endif
65 }
66
67 bool IsNan(double x) {
68 #ifdef _MSC_VER
69     switch (_fpclass(x)) {
70     case _FPCLASS_SNAN:
71     case _FPCLASS_QNAN:
72         return true;
73     default:
74         return false;
75     }
76 #else
77   return std::isnan(x);
78 #endif
79 }
80
81 }
82
83 namespace glslang {
84
85 //
86 // Two purposes:
87 // 1.  Show an example of how to iterate tree.  Functions can
88 //     also directly call Traverse() on children themselves to
89 //     have finer grained control over the process than shown here.
90 //     See the last function for how to get started.
91 // 2.  Print out a text based description of the tree.
92 //
93
94 //
95 // Use this class to carry along data from node to node in
96 // the traversal
97 //
98 class TOutputTraverser : public TIntermTraverser {
99 public:
100     TOutputTraverser(TInfoSink& i) : infoSink(i), extraOutput(NoExtraOutput) { }
101
102     enum EExtraOutput {
103         NoExtraOutput,
104         BinaryDoubleOutput
105     };
106     void setDoubleOutput(EExtraOutput extra) { extraOutput = extra; }
107
108     virtual bool visitBinary(TVisit, TIntermBinary* node);
109     virtual bool visitUnary(TVisit, TIntermUnary* node);
110     virtual bool visitAggregate(TVisit, TIntermAggregate* node);
111     virtual bool visitSelection(TVisit, TIntermSelection* node);
112     virtual void visitConstantUnion(TIntermConstantUnion* node);
113     virtual void visitSymbol(TIntermSymbol* node);
114     virtual bool visitLoop(TVisit, TIntermLoop* node);
115     virtual bool visitBranch(TVisit, TIntermBranch* node);
116     virtual bool visitSwitch(TVisit, TIntermSwitch* node);
117
118     TInfoSink& infoSink;
119 protected:
120     TOutputTraverser(TOutputTraverser&);
121     TOutputTraverser& operator=(TOutputTraverser&);
122
123     EExtraOutput extraOutput;
124 };
125
126 //
127 // Helper functions for printing, not part of traversing.
128 //
129
130 static void OutputTreeText(TInfoSink& infoSink, const TIntermNode* node, const int depth)
131 {
132     int i;
133
134     infoSink.debug << node->getLoc().string << ":";
135     if (node->getLoc().line)
136         infoSink.debug << node->getLoc().line;
137     else
138         infoSink.debug << "? ";
139
140     for (i = 0; i < depth; ++i)
141         infoSink.debug << "  ";
142 }
143
144 //
145 // The rest of the file are the traversal functions.  The last one
146 // is the one that starts the traversal.
147 //
148 // Return true from interior nodes to have the external traversal
149 // continue on to children.  If you process children yourself,
150 // return false.
151 //
152
153 bool TOutputTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node)
154 {
155     TInfoSink& out = infoSink;
156
157     OutputTreeText(out, node, depth);
158
159     switch (node->getOp()) {
160     case EOpAssign:                   out.debug << "move second child to first child";           break;
161     case EOpAddAssign:                out.debug << "add second child into first child";          break;
162     case EOpSubAssign:                out.debug << "subtract second child into first child";     break;
163     case EOpMulAssign:                out.debug << "multiply second child into first child";     break;
164     case EOpVectorTimesMatrixAssign:  out.debug << "matrix mult second child into first child";  break;
165     case EOpVectorTimesScalarAssign:  out.debug << "vector scale second child into first child"; break;
166     case EOpMatrixTimesScalarAssign:  out.debug << "matrix scale second child into first child"; break;
167     case EOpMatrixTimesMatrixAssign:  out.debug << "matrix mult second child into first child";  break;
168     case EOpDivAssign:                out.debug << "divide second child into first child";       break;
169     case EOpModAssign:                out.debug << "mod second child into first child";          break;
170     case EOpAndAssign:                out.debug << "and second child into first child";          break;
171     case EOpInclusiveOrAssign:        out.debug << "or second child into first child";           break;
172     case EOpExclusiveOrAssign:        out.debug << "exclusive or second child into first child"; break;
173     case EOpLeftShiftAssign:          out.debug << "left shift second child into first child";   break;
174     case EOpRightShiftAssign:         out.debug << "right shift second child into first child";  break;
175
176     case EOpIndexDirect:   out.debug << "direct index";   break;
177     case EOpIndexIndirect: out.debug << "indirect index"; break;
178     case EOpIndexDirectStruct:
179         {
180             bool reference = node->getLeft()->getType().isReference();
181             const TTypeList *members = reference ? node->getLeft()->getType().getReferentType()->getStruct() : node->getLeft()->getType().getStruct();
182             out.debug << (*members)[node->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst()].type->getFieldName();
183             out.debug << ": direct index for structure";      break;
184         }
185     case EOpVectorSwizzle: out.debug << "vector swizzle"; break;
186     case EOpMatrixSwizzle: out.debug << "matrix swizzle"; break;
187
188     case EOpAdd:    out.debug << "add";                     break;
189     case EOpSub:    out.debug << "subtract";                break;
190     case EOpMul:    out.debug << "component-wise multiply"; break;
191     case EOpDiv:    out.debug << "divide";                  break;
192     case EOpMod:    out.debug << "mod";                     break;
193     case EOpRightShift:  out.debug << "right-shift";  break;
194     case EOpLeftShift:   out.debug << "left-shift";   break;
195     case EOpAnd:         out.debug << "bitwise and";  break;
196     case EOpInclusiveOr: out.debug << "inclusive-or"; break;
197     case EOpExclusiveOr: out.debug << "exclusive-or"; break;
198     case EOpEqual:            out.debug << "Compare Equal";                 break;
199     case EOpNotEqual:         out.debug << "Compare Not Equal";             break;
200     case EOpLessThan:         out.debug << "Compare Less Than";             break;
201     case EOpGreaterThan:      out.debug << "Compare Greater Than";          break;
202     case EOpLessThanEqual:    out.debug << "Compare Less Than or Equal";    break;
203     case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
204     case EOpVectorEqual:      out.debug << "Equal";                         break;
205     case EOpVectorNotEqual:   out.debug << "NotEqual";                      break;
206
207     case EOpVectorTimesScalar: out.debug << "vector-scale";          break;
208     case EOpVectorTimesMatrix: out.debug << "vector-times-matrix";   break;
209     case EOpMatrixTimesVector: out.debug << "matrix-times-vector";   break;
210     case EOpMatrixTimesScalar: out.debug << "matrix-scale";          break;
211     case EOpMatrixTimesMatrix: out.debug << "matrix-multiply";       break;
212
213     case EOpLogicalOr:  out.debug << "logical-or";   break;
214     case EOpLogicalXor: out.debug << "logical-xor"; break;
215     case EOpLogicalAnd: out.debug << "logical-and"; break;
216
217     case EOpAbsDifference:          out.debug << "absoluteDifference";    break;
218     case EOpAddSaturate:            out.debug << "addSaturate";           break;
219     case EOpSubSaturate:            out.debug << "subtractSaturate";      break;
220     case EOpAverage:                out.debug << "average";               break;
221     case EOpAverageRounded:         out.debug << "averageRounded";        break;
222     case EOpMul32x16:               out.debug << "multiply32x16";         break;
223
224     default: out.debug << "<unknown op>";
225     }
226
227     out.debug << " (" << node->getCompleteString() << ")";
228
229     out.debug << "\n";
230
231     return true;
232 }
233
234 bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
235 {
236     TInfoSink& out = infoSink;
237
238     OutputTreeText(out, node, depth);
239
240     switch (node->getOp()) {
241     case EOpNegative:       out.debug << "Negate value";         break;
242     case EOpVectorLogicalNot:
243     case EOpLogicalNot:     out.debug << "Negate conditional";   break;
244     case EOpBitwiseNot:     out.debug << "Bitwise not";          break;
245
246     case EOpPostIncrement:  out.debug << "Post-Increment";       break;
247     case EOpPostDecrement:  out.debug << "Post-Decrement";       break;
248     case EOpPreIncrement:   out.debug << "Pre-Increment";        break;
249     case EOpPreDecrement:   out.debug << "Pre-Decrement";        break;
250     case EOpCopyObject:     out.debug << "copy object";          break;
251
252     // * -> bool
253     case EOpConvInt8ToBool:    out.debug << "Convert int8_t to bool";  break;
254     case EOpConvUint8ToBool:   out.debug << "Convert uint8_t to bool"; break;
255     case EOpConvInt16ToBool:   out.debug << "Convert int16_t to bool"; break;
256     case EOpConvUint16ToBool:  out.debug << "Convert uint16_t to bool";break;
257     case EOpConvIntToBool:     out.debug << "Convert int to bool";     break;
258     case EOpConvUintToBool:    out.debug << "Convert uint to bool";    break;
259     case EOpConvInt64ToBool:   out.debug << "Convert int64 to bool";   break;
260     case EOpConvUint64ToBool:  out.debug << "Convert uint64 to bool";  break;
261     case EOpConvFloat16ToBool: out.debug << "Convert float16_t to bool";   break;
262     case EOpConvFloatToBool:   out.debug << "Convert float to bool";   break;
263     case EOpConvDoubleToBool:  out.debug << "Convert double to bool";  break;
264
265     // bool -> *
266     case EOpConvBoolToInt8:    out.debug << "Convert bool to int8_t";  break;
267     case EOpConvBoolToUint8:   out.debug << "Convert bool to uint8_t"; break;
268     case EOpConvBoolToInt16:   out.debug << "Convert bool to in16t_t"; break;
269     case EOpConvBoolToUint16:  out.debug << "Convert bool to uint16_t";break;
270     case EOpConvBoolToInt:     out.debug << "Convert bool to int"  ;   break;
271     case EOpConvBoolToUint:    out.debug << "Convert bool to uint";    break;
272     case EOpConvBoolToInt64:   out.debug << "Convert bool to int64"; break;
273     case EOpConvBoolToUint64:  out.debug << "Convert bool to uint64";break;
274     case EOpConvBoolToFloat16: out.debug << "Convert bool to float16_t";   break;
275     case EOpConvBoolToFloat:   out.debug << "Convert bool to float";   break;
276     case EOpConvBoolToDouble:  out.debug << "Convert bool to double";   break;
277
278     // int8_t -> (u)int*
279     case EOpConvInt8ToInt16:   out.debug << "Convert int8_t to int16_t";break;
280     case EOpConvInt8ToInt:     out.debug << "Convert int8_t to int";    break;
281     case EOpConvInt8ToInt64:   out.debug << "Convert int8_t to int64";   break;
282     case EOpConvInt8ToUint8:   out.debug << "Convert int8_t to uint8_t";break;
283     case EOpConvInt8ToUint16:  out.debug << "Convert int8_t to uint16_t";break;
284     case EOpConvInt8ToUint:    out.debug << "Convert int8_t to uint";    break;
285     case EOpConvInt8ToUint64:  out.debug << "Convert int8_t to uint64";   break;
286
287     // uint8_t -> (u)int*
288     case EOpConvUint8ToInt8:    out.debug << "Convert uint8_t to int8_t";break;
289     case EOpConvUint8ToInt16:   out.debug << "Convert uint8_t to int16_t";break;
290     case EOpConvUint8ToInt:     out.debug << "Convert uint8_t to int";    break;
291     case EOpConvUint8ToInt64:   out.debug << "Convert uint8_t to int64";   break;
292     case EOpConvUint8ToUint16:  out.debug << "Convert uint8_t to uint16_t";break;
293     case EOpConvUint8ToUint:    out.debug << "Convert uint8_t to uint";    break;
294     case EOpConvUint8ToUint64:  out.debug << "Convert uint8_t to uint64";   break;
295
296     // int8_t -> float*
297     case EOpConvInt8ToFloat16:  out.debug << "Convert int8_t to float16_t";break;
298     case EOpConvInt8ToFloat:    out.debug << "Convert int8_t to float";    break;
299     case EOpConvInt8ToDouble:   out.debug << "Convert int8_t to double";   break;
300
301     // uint8_t -> float*
302     case EOpConvUint8ToFloat16: out.debug << "Convert uint8_t to float16_t";break;
303     case EOpConvUint8ToFloat:   out.debug << "Convert uint8_t to float";    break;
304     case EOpConvUint8ToDouble:  out.debug << "Convert uint8_t to double";   break;
305
306     // int16_t -> (u)int*
307     case EOpConvInt16ToInt8:    out.debug << "Convert int16_t to int8_t";break;
308     case EOpConvInt16ToInt:     out.debug << "Convert int16_t to int";    break;
309     case EOpConvInt16ToInt64:   out.debug << "Convert int16_t to int64";   break;
310     case EOpConvInt16ToUint8:   out.debug << "Convert int16_t to uint8_t";break;
311     case EOpConvInt16ToUint16:  out.debug << "Convert int16_t to uint16_t";break;
312     case EOpConvInt16ToUint:    out.debug << "Convert int16_t to uint";    break;
313     case EOpConvInt16ToUint64:  out.debug << "Convert int16_t to uint64";   break;
314
315     // int16_t -> float*
316     case EOpConvInt16ToFloat16:  out.debug << "Convert int16_t to float16_t";break;
317     case EOpConvInt16ToFloat:    out.debug << "Convert int16_t to float";    break;
318     case EOpConvInt16ToDouble:   out.debug << "Convert int16_t to double";   break;
319
320     // uint16_t -> (u)int*
321     case EOpConvUint16ToInt8:    out.debug << "Convert uint16_t to int8_t";break;
322     case EOpConvUint16ToInt16:   out.debug << "Convert uint16_t to int16_t";break;
323     case EOpConvUint16ToInt:     out.debug << "Convert uint16_t to int";    break;
324     case EOpConvUint16ToInt64:   out.debug << "Convert uint16_t to int64";   break;
325     case EOpConvUint16ToUint8:   out.debug << "Convert uint16_t to uint8_t";break;
326     case EOpConvUint16ToUint:    out.debug << "Convert uint16_t to uint";    break;
327     case EOpConvUint16ToUint64:  out.debug << "Convert uint16_t to uint64";   break;
328
329     // uint16_t -> float*
330     case EOpConvUint16ToFloat16: out.debug << "Convert uint16_t to float16_t";break;
331     case EOpConvUint16ToFloat:   out.debug << "Convert uint16_t to float";    break;
332     case EOpConvUint16ToDouble:  out.debug << "Convert uint16_t to double";   break;
333
334     // int32_t -> (u)int*
335     case EOpConvIntToInt8:    out.debug << "Convert int to int8_t";break;
336     case EOpConvIntToInt16:   out.debug << "Convert int to int16_t";break;
337     case EOpConvIntToInt64:   out.debug << "Convert int to int64";   break;
338     case EOpConvIntToUint8:   out.debug << "Convert int to uint8_t";break;
339     case EOpConvIntToUint16:  out.debug << "Convert int to uint16_t";break;
340     case EOpConvIntToUint:    out.debug << "Convert int to uint";    break;
341     case EOpConvIntToUint64:  out.debug << "Convert int to uint64";   break;
342
343     // int32_t -> float*
344     case EOpConvIntToFloat16:  out.debug << "Convert int to float16_t";break;
345     case EOpConvIntToFloat:    out.debug << "Convert int to float";    break;
346     case EOpConvIntToDouble:   out.debug << "Convert int to double";   break;
347
348     // uint32_t -> (u)int*
349     case EOpConvUintToInt8:    out.debug << "Convert uint to int8_t";break;
350     case EOpConvUintToInt16:   out.debug << "Convert uint to int16_t";break;
351     case EOpConvUintToInt:     out.debug << "Convert uint to int";break;
352     case EOpConvUintToInt64:   out.debug << "Convert uint to int64";   break;
353     case EOpConvUintToUint8:   out.debug << "Convert uint to uint8_t";break;
354     case EOpConvUintToUint16:  out.debug << "Convert uint to uint16_t";break;
355     case EOpConvUintToUint64:  out.debug << "Convert uint to uint64";   break;
356
357     // uint32_t -> float*
358     case EOpConvUintToFloat16: out.debug << "Convert uint to float16_t";break;
359     case EOpConvUintToFloat:   out.debug << "Convert uint to float";    break;
360     case EOpConvUintToDouble:  out.debug << "Convert uint to double";   break;
361
362     // int64 -> (u)int*
363     case EOpConvInt64ToInt8:    out.debug << "Convert int64 to int8_t";  break;
364     case EOpConvInt64ToInt16:   out.debug << "Convert int64 to int16_t"; break;
365     case EOpConvInt64ToInt:     out.debug << "Convert int64 to int";   break;
366     case EOpConvInt64ToUint8:   out.debug << "Convert int64 to uint8_t";break;
367     case EOpConvInt64ToUint16:  out.debug << "Convert int64 to uint16_t";break;
368     case EOpConvInt64ToUint:    out.debug << "Convert int64 to uint";    break;
369     case EOpConvInt64ToUint64:  out.debug << "Convert int64 to uint64";   break;
370
371      // int64 -> float*
372     case EOpConvInt64ToFloat16:  out.debug << "Convert int64 to float16_t";break;
373     case EOpConvInt64ToFloat:    out.debug << "Convert int64 to float";    break;
374     case EOpConvInt64ToDouble:   out.debug << "Convert int64 to double";   break;
375
376     // uint64 -> (u)int*
377     case EOpConvUint64ToInt8:    out.debug << "Convert uint64 to int8_t";break;
378     case EOpConvUint64ToInt16:   out.debug << "Convert uint64 to int16_t";break;
379     case EOpConvUint64ToInt:     out.debug << "Convert uint64 to int";    break;
380     case EOpConvUint64ToInt64:   out.debug << "Convert uint64 to int64";   break;
381     case EOpConvUint64ToUint8:   out.debug << "Convert uint64 to uint8_t";break;
382     case EOpConvUint64ToUint16:  out.debug << "Convert uint64 to uint16";    break;
383     case EOpConvUint64ToUint:    out.debug << "Convert uint64 to uint";   break;
384
385     // uint64 -> float*
386     case EOpConvUint64ToFloat16: out.debug << "Convert uint64 to float16_t";break;
387     case EOpConvUint64ToFloat:   out.debug << "Convert uint64 to float";    break;
388     case EOpConvUint64ToDouble:  out.debug << "Convert uint64 to double";   break;
389
390     // float16_t -> int*
391     case EOpConvFloat16ToInt8:  out.debug << "Convert float16_t to int8_t"; break;
392     case EOpConvFloat16ToInt16: out.debug << "Convert float16_t to int16_t"; break;
393     case EOpConvFloat16ToInt:   out.debug << "Convert float16_t to int"; break;
394     case EOpConvFloat16ToInt64: out.debug << "Convert float16_t to int64"; break;
395
396     // float16_t -> uint*
397     case EOpConvFloat16ToUint8:  out.debug << "Convert float16_t to uint8_t"; break;
398     case EOpConvFloat16ToUint16: out.debug << "Convert float16_t to uint16_t"; break;
399     case EOpConvFloat16ToUint:   out.debug << "Convert float16_t to uint"; break;
400     case EOpConvFloat16ToUint64: out.debug << "Convert float16_t to uint64"; break;
401
402     // float16_t -> float*
403     case EOpConvFloat16ToFloat:  out.debug << "Convert float16_t to float"; break;
404     case EOpConvFloat16ToDouble: out.debug << "Convert float16_t to double"; break;
405
406     // float32 -> float*
407     case EOpConvFloatToFloat16: out.debug << "Convert float to float16_t"; break;
408     case EOpConvFloatToDouble:  out.debug << "Convert float to double"; break;
409
410     // float32_t -> int*
411     case EOpConvFloatToInt8:  out.debug << "Convert float to int8_t"; break;
412     case EOpConvFloatToInt16: out.debug << "Convert float to int16_t"; break;
413     case EOpConvFloatToInt:   out.debug << "Convert float to int"; break;
414     case EOpConvFloatToInt64: out.debug << "Convert float to int64"; break;
415
416     // float32_t -> uint*
417     case EOpConvFloatToUint8:  out.debug << "Convert float to uint8_t"; break;
418     case EOpConvFloatToUint16: out.debug << "Convert float to uint16_t"; break;
419     case EOpConvFloatToUint:   out.debug << "Convert float to uint"; break;
420     case EOpConvFloatToUint64: out.debug << "Convert float to uint64"; break;
421
422     // double -> float*
423     case EOpConvDoubleToFloat16: out.debug << "Convert double to float16_t"; break;
424     case EOpConvDoubleToFloat:   out.debug << "Convert double to float"; break;
425
426     // double -> int*
427     case EOpConvDoubleToInt8:  out.debug << "Convert double to int8_t"; break;
428     case EOpConvDoubleToInt16: out.debug << "Convert double to int16_t"; break;
429     case EOpConvDoubleToInt:   out.debug << "Convert double to int"; break;
430     case EOpConvDoubleToInt64: out.debug << "Convert double to int64"; break;
431
432     // float32_t -> uint*
433     case EOpConvDoubleToUint8:  out.debug << "Convert double to uint8_t"; break;
434     case EOpConvDoubleToUint16: out.debug << "Convert double to uint16_t"; break;
435     case EOpConvDoubleToUint:   out.debug << "Convert double to uint"; break;
436     case EOpConvDoubleToUint64: out.debug << "Convert double to uint64"; break;
437
438     case EOpConvUint64ToPtr:  out.debug << "Convert uint64_t to pointer";   break;
439     case EOpConvPtrToUint64:  out.debug << "Convert pointer to uint64_t";   break;
440
441     case EOpConvUint64ToAccStruct: out.debug << "Convert uint64_t to acceleration structure"; break;
442     case EOpConvUvec2ToAccStruct:  out.debug << "Convert uvec2 to acceleration strucuture "; break;
443
444     case EOpRadians:        out.debug << "radians";              break;
445     case EOpDegrees:        out.debug << "degrees";              break;
446     case EOpSin:            out.debug << "sine";                 break;
447     case EOpCos:            out.debug << "cosine";               break;
448     case EOpTan:            out.debug << "tangent";              break;
449     case EOpAsin:           out.debug << "arc sine";             break;
450     case EOpAcos:           out.debug << "arc cosine";           break;
451     case EOpAtan:           out.debug << "arc tangent";          break;
452     case EOpSinh:           out.debug << "hyp. sine";            break;
453     case EOpCosh:           out.debug << "hyp. cosine";          break;
454     case EOpTanh:           out.debug << "hyp. tangent";         break;
455     case EOpAsinh:          out.debug << "arc hyp. sine";        break;
456     case EOpAcosh:          out.debug << "arc hyp. cosine";      break;
457     case EOpAtanh:          out.debug << "arc hyp. tangent";     break;
458
459     case EOpExp:            out.debug << "exp";                  break;
460     case EOpLog:            out.debug << "log";                  break;
461     case EOpExp2:           out.debug << "exp2";                 break;
462     case EOpLog2:           out.debug << "log2";                 break;
463     case EOpSqrt:           out.debug << "sqrt";                 break;
464     case EOpInverseSqrt:    out.debug << "inverse sqrt";         break;
465
466     case EOpAbs:            out.debug << "Absolute value";       break;
467     case EOpSign:           out.debug << "Sign";                 break;
468     case EOpFloor:          out.debug << "Floor";                break;
469     case EOpTrunc:          out.debug << "trunc";                break;
470     case EOpRound:          out.debug << "round";                break;
471     case EOpRoundEven:      out.debug << "roundEven";            break;
472     case EOpCeil:           out.debug << "Ceiling";              break;
473     case EOpFract:          out.debug << "Fraction";             break;
474
475     case EOpIsNan:          out.debug << "isnan";                break;
476     case EOpIsInf:          out.debug << "isinf";                break;
477
478     case EOpFloatBitsToInt: out.debug << "floatBitsToInt";       break;
479     case EOpFloatBitsToUint:out.debug << "floatBitsToUint";      break;
480     case EOpIntBitsToFloat: out.debug << "intBitsToFloat";       break;
481     case EOpUintBitsToFloat:out.debug << "uintBitsToFloat";      break;
482     case EOpDoubleBitsToInt64:  out.debug << "doubleBitsToInt64";  break;
483     case EOpDoubleBitsToUint64: out.debug << "doubleBitsToUint64"; break;
484     case EOpInt64BitsToDouble:  out.debug << "int64BitsToDouble";  break;
485     case EOpUint64BitsToDouble: out.debug << "uint64BitsToDouble"; break;
486     case EOpFloat16BitsToInt16:  out.debug << "float16BitsToInt16";  break;
487     case EOpFloat16BitsToUint16: out.debug << "float16BitsToUint16"; break;
488     case EOpInt16BitsToFloat16:  out.debug << "int16BitsToFloat16";  break;
489     case EOpUint16BitsToFloat16: out.debug << "uint16BitsToFloat16"; break;
490
491     case EOpPackSnorm2x16:  out.debug << "packSnorm2x16";        break;
492     case EOpUnpackSnorm2x16:out.debug << "unpackSnorm2x16";      break;
493     case EOpPackUnorm2x16:  out.debug << "packUnorm2x16";        break;
494     case EOpUnpackUnorm2x16:out.debug << "unpackUnorm2x16";      break;
495     case EOpPackHalf2x16:   out.debug << "packHalf2x16";         break;
496     case EOpUnpackHalf2x16: out.debug << "unpackHalf2x16";       break;
497     case EOpPack16:           out.debug << "pack16";                 break;
498     case EOpPack32:           out.debug << "pack32";                 break;
499     case EOpPack64:           out.debug << "pack64";                 break;
500     case EOpUnpack32:         out.debug << "unpack32";               break;
501     case EOpUnpack16:         out.debug << "unpack16";               break;
502     case EOpUnpack8:          out.debug << "unpack8";               break;
503
504     case EOpPackSnorm4x8:     out.debug << "PackSnorm4x8";       break;
505     case EOpUnpackSnorm4x8:   out.debug << "UnpackSnorm4x8";     break;
506     case EOpPackUnorm4x8:     out.debug << "PackUnorm4x8";       break;
507     case EOpUnpackUnorm4x8:   out.debug << "UnpackUnorm4x8";     break;
508     case EOpPackDouble2x32:   out.debug << "PackDouble2x32";     break;
509     case EOpUnpackDouble2x32: out.debug << "UnpackDouble2x32";   break;
510
511     case EOpPackInt2x32:      out.debug << "packInt2x32";        break;
512     case EOpUnpackInt2x32:    out.debug << "unpackInt2x32";      break;
513     case EOpPackUint2x32:     out.debug << "packUint2x32";       break;
514     case EOpUnpackUint2x32:   out.debug << "unpackUint2x32";     break;
515
516     case EOpPackInt2x16:      out.debug << "packInt2x16";        break;
517     case EOpUnpackInt2x16:    out.debug << "unpackInt2x16";      break;
518     case EOpPackUint2x16:     out.debug << "packUint2x16";       break;
519     case EOpUnpackUint2x16:   out.debug << "unpackUint2x16";     break;
520
521     case EOpPackInt4x16:      out.debug << "packInt4x16";        break;
522     case EOpUnpackInt4x16:    out.debug << "unpackInt4x16";      break;
523     case EOpPackUint4x16:     out.debug << "packUint4x16";       break;
524     case EOpUnpackUint4x16:   out.debug << "unpackUint4x16";     break;
525     case EOpPackFloat2x16:    out.debug << "packFloat2x16";      break;
526     case EOpUnpackFloat2x16:  out.debug << "unpackFloat2x16";    break;
527
528     case EOpLength:         out.debug << "length";               break;
529     case EOpNormalize:      out.debug << "normalize";            break;
530     case EOpDPdx:           out.debug << "dPdx";                 break;
531     case EOpDPdy:           out.debug << "dPdy";                 break;
532     case EOpFwidth:         out.debug << "fwidth";               break;
533     case EOpDPdxFine:       out.debug << "dPdxFine";             break;
534     case EOpDPdyFine:       out.debug << "dPdyFine";             break;
535     case EOpFwidthFine:     out.debug << "fwidthFine";           break;
536     case EOpDPdxCoarse:     out.debug << "dPdxCoarse";           break;
537     case EOpDPdyCoarse:     out.debug << "dPdyCoarse";           break;
538     case EOpFwidthCoarse:   out.debug << "fwidthCoarse";         break;
539
540     case EOpInterpolateAtCentroid: out.debug << "interpolateAtCentroid";  break;
541
542     case EOpDeterminant:    out.debug << "determinant";          break;
543     case EOpMatrixInverse:  out.debug << "inverse";              break;
544     case EOpTranspose:      out.debug << "transpose";            break;
545
546     case EOpAny:            out.debug << "any";                  break;
547     case EOpAll:            out.debug << "all";                  break;
548
549     case EOpArrayLength:    out.debug << "array length";         break;
550
551     case EOpEmitStreamVertex:   out.debug << "EmitStreamVertex";   break;
552     case EOpEndStreamPrimitive: out.debug << "EndStreamPrimitive"; break;
553
554     case EOpAtomicCounterIncrement: out.debug << "AtomicCounterIncrement";break;
555     case EOpAtomicCounterDecrement: out.debug << "AtomicCounterDecrement";break;
556     case EOpAtomicCounter:          out.debug << "AtomicCounter";         break;
557
558     case EOpTextureQuerySize:       out.debug << "textureSize";           break;
559     case EOpTextureQueryLod:        out.debug << "textureQueryLod";       break;
560     case EOpTextureQueryLevels:     out.debug << "textureQueryLevels";    break;
561     case EOpTextureQuerySamples:    out.debug << "textureSamples";        break;
562     case EOpImageQuerySize:         out.debug << "imageQuerySize";        break;
563     case EOpImageQuerySamples:      out.debug << "imageQuerySamples";     break;
564     case EOpImageLoad:              out.debug << "imageLoad";             break;
565
566     case EOpBitFieldReverse:        out.debug << "bitFieldReverse";       break;
567     case EOpBitCount:               out.debug << "bitCount";              break;
568     case EOpFindLSB:                out.debug << "findLSB";               break;
569     case EOpFindMSB:                out.debug << "findMSB";               break;
570
571     case EOpCountLeadingZeros:      out.debug << "countLeadingZeros";     break;
572     case EOpCountTrailingZeros:     out.debug << "countTrailingZeros";    break;
573
574     case EOpNoise:                  out.debug << "noise";                 break;
575
576     case EOpBallot:                 out.debug << "ballot";                break;
577     case EOpReadFirstInvocation:    out.debug << "readFirstInvocation";   break;
578
579     case EOpAnyInvocation:          out.debug << "anyInvocation";         break;
580     case EOpAllInvocations:         out.debug << "allInvocations";        break;
581     case EOpAllInvocationsEqual:    out.debug << "allInvocationsEqual";   break;
582
583     case EOpSubgroupElect:                   out.debug << "subgroupElect";                   break;
584     case EOpSubgroupAll:                     out.debug << "subgroupAll";                     break;
585     case EOpSubgroupAny:                     out.debug << "subgroupAny";                     break;
586     case EOpSubgroupAllEqual:                out.debug << "subgroupAllEqual";                break;
587     case EOpSubgroupBroadcast:               out.debug << "subgroupBroadcast";               break;
588     case EOpSubgroupBroadcastFirst:          out.debug << "subgroupBroadcastFirst";          break;
589     case EOpSubgroupBallot:                  out.debug << "subgroupBallot";                  break;
590     case EOpSubgroupInverseBallot:           out.debug << "subgroupInverseBallot";           break;
591     case EOpSubgroupBallotBitExtract:        out.debug << "subgroupBallotBitExtract";        break;
592     case EOpSubgroupBallotBitCount:          out.debug << "subgroupBallotBitCount";          break;
593     case EOpSubgroupBallotInclusiveBitCount: out.debug << "subgroupBallotInclusiveBitCount"; break;
594     case EOpSubgroupBallotExclusiveBitCount: out.debug << "subgroupBallotExclusiveBitCount"; break;
595     case EOpSubgroupBallotFindLSB:           out.debug << "subgroupBallotFindLSB";           break;
596     case EOpSubgroupBallotFindMSB:           out.debug << "subgroupBallotFindMSB";           break;
597     case EOpSubgroupShuffle:                 out.debug << "subgroupShuffle";                 break;
598     case EOpSubgroupShuffleXor:              out.debug << "subgroupShuffleXor";              break;
599     case EOpSubgroupShuffleUp:               out.debug << "subgroupShuffleUp";               break;
600     case EOpSubgroupShuffleDown:             out.debug << "subgroupShuffleDown";             break;
601     case EOpSubgroupAdd:                     out.debug << "subgroupAdd";                     break;
602     case EOpSubgroupMul:                     out.debug << "subgroupMul";                     break;
603     case EOpSubgroupMin:                     out.debug << "subgroupMin";                     break;
604     case EOpSubgroupMax:                     out.debug << "subgroupMax";                     break;
605     case EOpSubgroupAnd:                     out.debug << "subgroupAnd";                     break;
606     case EOpSubgroupOr:                      out.debug << "subgroupOr";                      break;
607     case EOpSubgroupXor:                     out.debug << "subgroupXor";                     break;
608     case EOpSubgroupInclusiveAdd:            out.debug << "subgroupInclusiveAdd";            break;
609     case EOpSubgroupInclusiveMul:            out.debug << "subgroupInclusiveMul";            break;
610     case EOpSubgroupInclusiveMin:            out.debug << "subgroupInclusiveMin";            break;
611     case EOpSubgroupInclusiveMax:            out.debug << "subgroupInclusiveMax";            break;
612     case EOpSubgroupInclusiveAnd:            out.debug << "subgroupInclusiveAnd";            break;
613     case EOpSubgroupInclusiveOr:             out.debug << "subgroupInclusiveOr";             break;
614     case EOpSubgroupInclusiveXor:            out.debug << "subgroupInclusiveXor";            break;
615     case EOpSubgroupExclusiveAdd:            out.debug << "subgroupExclusiveAdd";            break;
616     case EOpSubgroupExclusiveMul:            out.debug << "subgroupExclusiveMul";            break;
617     case EOpSubgroupExclusiveMin:            out.debug << "subgroupExclusiveMin";            break;
618     case EOpSubgroupExclusiveMax:            out.debug << "subgroupExclusiveMax";            break;
619     case EOpSubgroupExclusiveAnd:            out.debug << "subgroupExclusiveAnd";            break;
620     case EOpSubgroupExclusiveOr:             out.debug << "subgroupExclusiveOr";             break;
621     case EOpSubgroupExclusiveXor:            out.debug << "subgroupExclusiveXor";            break;
622     case EOpSubgroupClusteredAdd:            out.debug << "subgroupClusteredAdd";            break;
623     case EOpSubgroupClusteredMul:            out.debug << "subgroupClusteredMul";            break;
624     case EOpSubgroupClusteredMin:            out.debug << "subgroupClusteredMin";            break;
625     case EOpSubgroupClusteredMax:            out.debug << "subgroupClusteredMax";            break;
626     case EOpSubgroupClusteredAnd:            out.debug << "subgroupClusteredAnd";            break;
627     case EOpSubgroupClusteredOr:             out.debug << "subgroupClusteredOr";             break;
628     case EOpSubgroupClusteredXor:            out.debug << "subgroupClusteredXor";            break;
629     case EOpSubgroupQuadBroadcast:           out.debug << "subgroupQuadBroadcast";           break;
630     case EOpSubgroupQuadSwapHorizontal:      out.debug << "subgroupQuadSwapHorizontal";      break;
631     case EOpSubgroupQuadSwapVertical:        out.debug << "subgroupQuadSwapVertical";        break;
632     case EOpSubgroupQuadSwapDiagonal:        out.debug << "subgroupQuadSwapDiagonal";        break;
633
634     case EOpSubgroupPartition:                          out.debug << "subgroupPartitionNV";                          break;
635     case EOpSubgroupPartitionedAdd:                     out.debug << "subgroupPartitionedAddNV";                     break;
636     case EOpSubgroupPartitionedMul:                     out.debug << "subgroupPartitionedMulNV";                     break;
637     case EOpSubgroupPartitionedMin:                     out.debug << "subgroupPartitionedMinNV";                     break;
638     case EOpSubgroupPartitionedMax:                     out.debug << "subgroupPartitionedMaxNV";                     break;
639     case EOpSubgroupPartitionedAnd:                     out.debug << "subgroupPartitionedAndNV";                     break;
640     case EOpSubgroupPartitionedOr:                      out.debug << "subgroupPartitionedOrNV";                      break;
641     case EOpSubgroupPartitionedXor:                     out.debug << "subgroupPartitionedXorNV";                     break;
642     case EOpSubgroupPartitionedInclusiveAdd:            out.debug << "subgroupPartitionedInclusiveAddNV";            break;
643     case EOpSubgroupPartitionedInclusiveMul:            out.debug << "subgroupPartitionedInclusiveMulNV";            break;
644     case EOpSubgroupPartitionedInclusiveMin:            out.debug << "subgroupPartitionedInclusiveMinNV";            break;
645     case EOpSubgroupPartitionedInclusiveMax:            out.debug << "subgroupPartitionedInclusiveMaxNV";            break;
646     case EOpSubgroupPartitionedInclusiveAnd:            out.debug << "subgroupPartitionedInclusiveAndNV";            break;
647     case EOpSubgroupPartitionedInclusiveOr:             out.debug << "subgroupPartitionedInclusiveOrNV";             break;
648     case EOpSubgroupPartitionedInclusiveXor:            out.debug << "subgroupPartitionedInclusiveXorNV";            break;
649     case EOpSubgroupPartitionedExclusiveAdd:            out.debug << "subgroupPartitionedExclusiveAddNV";            break;
650     case EOpSubgroupPartitionedExclusiveMul:            out.debug << "subgroupPartitionedExclusiveMulNV";            break;
651     case EOpSubgroupPartitionedExclusiveMin:            out.debug << "subgroupPartitionedExclusiveMinNV";            break;
652     case EOpSubgroupPartitionedExclusiveMax:            out.debug << "subgroupPartitionedExclusiveMaxNV";            break;
653     case EOpSubgroupPartitionedExclusiveAnd:            out.debug << "subgroupPartitionedExclusiveAndNV";            break;
654     case EOpSubgroupPartitionedExclusiveOr:             out.debug << "subgroupPartitionedExclusiveOrNV";             break;
655     case EOpSubgroupPartitionedExclusiveXor:            out.debug << "subgroupPartitionedExclusiveXorNV";            break;
656
657     case EOpClip:                   out.debug << "clip";                  break;
658     case EOpIsFinite:               out.debug << "isfinite";              break;
659     case EOpLog10:                  out.debug << "log10";                 break;
660     case EOpRcp:                    out.debug << "rcp";                   break;
661     case EOpSaturate:               out.debug << "saturate";              break;
662
663     case EOpSparseTexelsResident:   out.debug << "sparseTexelsResident";  break;
664
665     case EOpMinInvocations:             out.debug << "minInvocations";              break;
666     case EOpMaxInvocations:             out.debug << "maxInvocations";              break;
667     case EOpAddInvocations:             out.debug << "addInvocations";              break;
668     case EOpMinInvocationsNonUniform:   out.debug << "minInvocationsNonUniform";    break;
669     case EOpMaxInvocationsNonUniform:   out.debug << "maxInvocationsNonUniform";    break;
670     case EOpAddInvocationsNonUniform:   out.debug << "addInvocationsNonUniform";    break;
671
672     case EOpMinInvocationsInclusiveScan:            out.debug << "minInvocationsInclusiveScan";             break;
673     case EOpMaxInvocationsInclusiveScan:            out.debug << "maxInvocationsInclusiveScan";             break;
674     case EOpAddInvocationsInclusiveScan:            out.debug << "addInvocationsInclusiveScan";             break;
675     case EOpMinInvocationsInclusiveScanNonUniform:  out.debug << "minInvocationsInclusiveScanNonUniform";   break;
676     case EOpMaxInvocationsInclusiveScanNonUniform:  out.debug << "maxInvocationsInclusiveScanNonUniform";   break;
677     case EOpAddInvocationsInclusiveScanNonUniform:  out.debug << "addInvocationsInclusiveScanNonUniform";   break;
678
679     case EOpMinInvocationsExclusiveScan:            out.debug << "minInvocationsExclusiveScan";             break;
680     case EOpMaxInvocationsExclusiveScan:            out.debug << "maxInvocationsExclusiveScan";             break;
681     case EOpAddInvocationsExclusiveScan:            out.debug << "addInvocationsExclusiveScan";             break;
682     case EOpMinInvocationsExclusiveScanNonUniform:  out.debug << "minInvocationsExclusiveScanNonUniform";   break;
683     case EOpMaxInvocationsExclusiveScanNonUniform:  out.debug << "maxInvocationsExclusiveScanNonUniform";   break;
684     case EOpAddInvocationsExclusiveScanNonUniform:  out.debug << "addInvocationsExclusiveScanNonUniform";   break;
685
686     case EOpMbcnt:                  out.debug << "mbcnt";                       break;
687
688     case EOpFragmentMaskFetch:      out.debug << "fragmentMaskFetchAMD";        break;
689     case EOpFragmentFetch:          out.debug << "fragmentFetchAMD";            break;
690
691     case EOpCubeFaceIndex:          out.debug << "cubeFaceIndex";               break;
692     case EOpCubeFaceCoord:          out.debug << "cubeFaceCoord";               break;
693
694     case EOpSubpassLoad:   out.debug << "subpassLoad";   break;
695     case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break;
696
697     case EOpConstructReference: out.debug << "Construct reference type"; break;
698
699 #ifndef GLSLANG_WEB
700     case EOpSpirvInst: out.debug << "spirv_instruction"; break;
701 #endif
702
703     default: out.debug.message(EPrefixError, "Bad unary op");
704     }
705
706     out.debug << " (" << node->getCompleteString() << ")";
707
708     out.debug << "\n";
709
710     return true;
711 }
712
713 bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node)
714 {
715     TInfoSink& out = infoSink;
716
717     if (node->getOp() == EOpNull) {
718         out.debug.message(EPrefixError, "node is still EOpNull!");
719         return true;
720     }
721
722     OutputTreeText(out, node, depth);
723
724     switch (node->getOp()) {
725     case EOpSequence:      out.debug << "Sequence\n";       return true;
726     case EOpLinkerObjects: out.debug << "Linker Objects\n"; return true;
727     case EOpComma:         out.debug << "Comma";            break;
728     case EOpFunction:      out.debug << "Function Definition: " << node->getName(); break;
729     case EOpFunctionCall:  out.debug << "Function Call: "       << node->getName(); break;
730     case EOpParameters:    out.debug << "Function Parameters: ";                    break;
731
732     case EOpConstructFloat: out.debug << "Construct float"; break;
733     case EOpConstructDouble:out.debug << "Construct double"; break;
734
735     case EOpConstructVec2:  out.debug << "Construct vec2";  break;
736     case EOpConstructVec3:  out.debug << "Construct vec3";  break;
737     case EOpConstructVec4:  out.debug << "Construct vec4";  break;
738     case EOpConstructDVec2: out.debug << "Construct dvec2";  break;
739     case EOpConstructDVec3: out.debug << "Construct dvec3";  break;
740     case EOpConstructDVec4: out.debug << "Construct dvec4";  break;
741     case EOpConstructBool:  out.debug << "Construct bool";  break;
742     case EOpConstructBVec2: out.debug << "Construct bvec2"; break;
743     case EOpConstructBVec3: out.debug << "Construct bvec3"; break;
744     case EOpConstructBVec4: out.debug << "Construct bvec4"; break;
745     case EOpConstructInt8:   out.debug << "Construct int8_t";   break;
746     case EOpConstructI8Vec2: out.debug << "Construct i8vec2"; break;
747     case EOpConstructI8Vec3: out.debug << "Construct i8vec3"; break;
748     case EOpConstructI8Vec4: out.debug << "Construct i8vec4"; break;
749     case EOpConstructInt:   out.debug << "Construct int";   break;
750     case EOpConstructIVec2: out.debug << "Construct ivec2"; break;
751     case EOpConstructIVec3: out.debug << "Construct ivec3"; break;
752     case EOpConstructIVec4: out.debug << "Construct ivec4"; break;
753     case EOpConstructUint8:    out.debug << "Construct uint8_t";    break;
754     case EOpConstructU8Vec2:   out.debug << "Construct u8vec2";   break;
755     case EOpConstructU8Vec3:   out.debug << "Construct u8vec3";   break;
756     case EOpConstructU8Vec4:   out.debug << "Construct u8vec4";   break;
757     case EOpConstructUint:    out.debug << "Construct uint";    break;
758     case EOpConstructUVec2:   out.debug << "Construct uvec2";   break;
759     case EOpConstructUVec3:   out.debug << "Construct uvec3";   break;
760     case EOpConstructUVec4:   out.debug << "Construct uvec4";   break;
761     case EOpConstructInt64:   out.debug << "Construct int64"; break;
762     case EOpConstructI64Vec2: out.debug << "Construct i64vec2"; break;
763     case EOpConstructI64Vec3: out.debug << "Construct i64vec3"; break;
764     case EOpConstructI64Vec4: out.debug << "Construct i64vec4"; break;
765     case EOpConstructUint64:  out.debug << "Construct uint64"; break;
766     case EOpConstructU64Vec2: out.debug << "Construct u64vec2"; break;
767     case EOpConstructU64Vec3: out.debug << "Construct u64vec3"; break;
768     case EOpConstructU64Vec4: out.debug << "Construct u64vec4"; break;
769     case EOpConstructInt16:   out.debug << "Construct int16_t"; break;
770     case EOpConstructI16Vec2: out.debug << "Construct i16vec2"; break;
771     case EOpConstructI16Vec3: out.debug << "Construct i16vec3"; break;
772     case EOpConstructI16Vec4: out.debug << "Construct i16vec4"; break;
773     case EOpConstructUint16:  out.debug << "Construct uint16_t"; break;
774     case EOpConstructU16Vec2: out.debug << "Construct u16vec2"; break;
775     case EOpConstructU16Vec3: out.debug << "Construct u16vec3"; break;
776     case EOpConstructU16Vec4: out.debug << "Construct u16vec4"; break;
777     case EOpConstructMat2x2:  out.debug << "Construct mat2";    break;
778     case EOpConstructMat2x3:  out.debug << "Construct mat2x3";  break;
779     case EOpConstructMat2x4:  out.debug << "Construct mat2x4";  break;
780     case EOpConstructMat3x2:  out.debug << "Construct mat3x2";  break;
781     case EOpConstructMat3x3:  out.debug << "Construct mat3";    break;
782     case EOpConstructMat3x4:  out.debug << "Construct mat3x4";  break;
783     case EOpConstructMat4x2:  out.debug << "Construct mat4x2";  break;
784     case EOpConstructMat4x3:  out.debug << "Construct mat4x3";  break;
785     case EOpConstructMat4x4:  out.debug << "Construct mat4";    break;
786     case EOpConstructDMat2x2: out.debug << "Construct dmat2";   break;
787     case EOpConstructDMat2x3: out.debug << "Construct dmat2x3"; break;
788     case EOpConstructDMat2x4: out.debug << "Construct dmat2x4"; break;
789     case EOpConstructDMat3x2: out.debug << "Construct dmat3x2"; break;
790     case EOpConstructDMat3x3: out.debug << "Construct dmat3";   break;
791     case EOpConstructDMat3x4: out.debug << "Construct dmat3x4"; break;
792     case EOpConstructDMat4x2: out.debug << "Construct dmat4x2"; break;
793     case EOpConstructDMat4x3: out.debug << "Construct dmat4x3"; break;
794     case EOpConstructDMat4x4: out.debug << "Construct dmat4";   break;
795     case EOpConstructIMat2x2: out.debug << "Construct imat2";   break;
796     case EOpConstructIMat2x3: out.debug << "Construct imat2x3"; break;
797     case EOpConstructIMat2x4: out.debug << "Construct imat2x4"; break;
798     case EOpConstructIMat3x2: out.debug << "Construct imat3x2"; break;
799     case EOpConstructIMat3x3: out.debug << "Construct imat3";   break;
800     case EOpConstructIMat3x4: out.debug << "Construct imat3x4"; break;
801     case EOpConstructIMat4x2: out.debug << "Construct imat4x2"; break;
802     case EOpConstructIMat4x3: out.debug << "Construct imat4x3"; break;
803     case EOpConstructIMat4x4: out.debug << "Construct imat4";   break;
804     case EOpConstructUMat2x2: out.debug << "Construct umat2";   break;
805     case EOpConstructUMat2x3: out.debug << "Construct umat2x3"; break;
806     case EOpConstructUMat2x4: out.debug << "Construct umat2x4"; break;
807     case EOpConstructUMat3x2: out.debug << "Construct umat3x2"; break;
808     case EOpConstructUMat3x3: out.debug << "Construct umat3";   break;
809     case EOpConstructUMat3x4: out.debug << "Construct umat3x4"; break;
810     case EOpConstructUMat4x2: out.debug << "Construct umat4x2"; break;
811     case EOpConstructUMat4x3: out.debug << "Construct umat4x3"; break;
812     case EOpConstructUMat4x4: out.debug << "Construct umat4";   break;
813     case EOpConstructBMat2x2: out.debug << "Construct bmat2";   break;
814     case EOpConstructBMat2x3: out.debug << "Construct bmat2x3"; break;
815     case EOpConstructBMat2x4: out.debug << "Construct bmat2x4"; break;
816     case EOpConstructBMat3x2: out.debug << "Construct bmat3x2"; break;
817     case EOpConstructBMat3x3: out.debug << "Construct bmat3";   break;
818     case EOpConstructBMat3x4: out.debug << "Construct bmat3x4"; break;
819     case EOpConstructBMat4x2: out.debug << "Construct bmat4x2"; break;
820     case EOpConstructBMat4x3: out.debug << "Construct bmat4x3"; break;
821     case EOpConstructBMat4x4: out.debug << "Construct bmat4";   break;
822     case EOpConstructFloat16:   out.debug << "Construct float16_t"; break;
823     case EOpConstructF16Vec2:   out.debug << "Construct f16vec2";   break;
824     case EOpConstructF16Vec3:   out.debug << "Construct f16vec3";   break;
825     case EOpConstructF16Vec4:   out.debug << "Construct f16vec4";   break;
826     case EOpConstructF16Mat2x2: out.debug << "Construct f16mat2";   break;
827     case EOpConstructF16Mat2x3: out.debug << "Construct f16mat2x3"; break;
828     case EOpConstructF16Mat2x4: out.debug << "Construct f16mat2x4"; break;
829     case EOpConstructF16Mat3x2: out.debug << "Construct f16mat3x2"; break;
830     case EOpConstructF16Mat3x3: out.debug << "Construct f16mat3";   break;
831     case EOpConstructF16Mat3x4: out.debug << "Construct f16mat3x4"; break;
832     case EOpConstructF16Mat4x2: out.debug << "Construct f16mat4x2"; break;
833     case EOpConstructF16Mat4x3: out.debug << "Construct f16mat4x3"; break;
834     case EOpConstructF16Mat4x4: out.debug << "Construct f16mat4";   break;
835     case EOpConstructStruct:  out.debug << "Construct structure";  break;
836     case EOpConstructTextureSampler: out.debug << "Construct combined texture-sampler"; break;
837     case EOpConstructReference:  out.debug << "Construct reference";  break;
838     case EOpConstructCooperativeMatrix:  out.debug << "Construct cooperative matrix";  break;
839     case EOpConstructAccStruct: out.debug << "Construct acceleration structure"; break;
840
841     case EOpLessThan:         out.debug << "Compare Less Than";             break;
842     case EOpGreaterThan:      out.debug << "Compare Greater Than";          break;
843     case EOpLessThanEqual:    out.debug << "Compare Less Than or Equal";    break;
844     case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
845     case EOpVectorEqual:      out.debug << "Equal";                         break;
846     case EOpVectorNotEqual:   out.debug << "NotEqual";                      break;
847
848     case EOpMod:           out.debug << "mod";         break;
849     case EOpModf:          out.debug << "modf";        break;
850     case EOpPow:           out.debug << "pow";         break;
851
852     case EOpAtan:          out.debug << "arc tangent"; break;
853
854     case EOpMin:           out.debug << "min";         break;
855     case EOpMax:           out.debug << "max";         break;
856     case EOpClamp:         out.debug << "clamp";       break;
857     case EOpMix:           out.debug << "mix";         break;
858     case EOpStep:          out.debug << "step";        break;
859     case EOpSmoothStep:    out.debug << "smoothstep";  break;
860
861     case EOpDistance:      out.debug << "distance";                break;
862     case EOpDot:           out.debug << "dot-product";             break;
863     case EOpCross:         out.debug << "cross-product";           break;
864     case EOpFaceForward:   out.debug << "face-forward";            break;
865     case EOpReflect:       out.debug << "reflect";                 break;
866     case EOpRefract:       out.debug << "refract";                 break;
867     case EOpMul:           out.debug << "component-wise multiply"; break;
868     case EOpOuterProduct:  out.debug << "outer product";           break;
869
870     case EOpEmitVertex:    out.debug << "EmitVertex";              break;
871     case EOpEndPrimitive:  out.debug << "EndPrimitive";            break;
872
873     case EOpBarrier:                    out.debug << "Barrier";                    break;
874     case EOpMemoryBarrier:              out.debug << "MemoryBarrier";              break;
875     case EOpMemoryBarrierAtomicCounter: out.debug << "MemoryBarrierAtomicCounter"; break;
876     case EOpMemoryBarrierBuffer:        out.debug << "MemoryBarrierBuffer";        break;
877     case EOpMemoryBarrierImage:         out.debug << "MemoryBarrierImage";         break;
878     case EOpMemoryBarrierShared:        out.debug << "MemoryBarrierShared";        break;
879     case EOpGroupMemoryBarrier:         out.debug << "GroupMemoryBarrier";         break;
880
881     case EOpReadInvocation:             out.debug << "readInvocation";        break;
882
883     case EOpSwizzleInvocations:         out.debug << "swizzleInvocations";       break;
884     case EOpSwizzleInvocationsMasked:   out.debug << "swizzleInvocationsMasked"; break;
885     case EOpWriteInvocation:            out.debug << "writeInvocation";          break;
886
887     case EOpMin3:                       out.debug << "min3";                  break;
888     case EOpMax3:                       out.debug << "max3";                  break;
889     case EOpMid3:                       out.debug << "mid3";                  break;
890     case EOpTime:                       out.debug << "time";                  break;
891
892     case EOpAtomicAdd:                  out.debug << "AtomicAdd";             break;
893     case EOpAtomicSubtract:             out.debug << "AtomicSubtract";        break;
894     case EOpAtomicMin:                  out.debug << "AtomicMin";             break;
895     case EOpAtomicMax:                  out.debug << "AtomicMax";             break;
896     case EOpAtomicAnd:                  out.debug << "AtomicAnd";             break;
897     case EOpAtomicOr:                   out.debug << "AtomicOr";              break;
898     case EOpAtomicXor:                  out.debug << "AtomicXor";             break;
899     case EOpAtomicExchange:             out.debug << "AtomicExchange";        break;
900     case EOpAtomicCompSwap:             out.debug << "AtomicCompSwap";        break;
901     case EOpAtomicLoad:                 out.debug << "AtomicLoad";            break;
902     case EOpAtomicStore:                out.debug << "AtomicStore";           break;
903
904     case EOpAtomicCounterAdd:           out.debug << "AtomicCounterAdd";      break;
905     case EOpAtomicCounterSubtract:      out.debug << "AtomicCounterSubtract"; break;
906     case EOpAtomicCounterMin:           out.debug << "AtomicCounterMin";      break;
907     case EOpAtomicCounterMax:           out.debug << "AtomicCounterMax";      break;
908     case EOpAtomicCounterAnd:           out.debug << "AtomicCounterAnd";      break;
909     case EOpAtomicCounterOr:            out.debug << "AtomicCounterOr";       break;
910     case EOpAtomicCounterXor:           out.debug << "AtomicCounterXor";      break;
911     case EOpAtomicCounterExchange:      out.debug << "AtomicCounterExchange"; break;
912     case EOpAtomicCounterCompSwap:      out.debug << "AtomicCounterCompSwap"; break;
913
914     case EOpImageQuerySize:             out.debug << "imageQuerySize";        break;
915     case EOpImageQuerySamples:          out.debug << "imageQuerySamples";     break;
916     case EOpImageLoad:                  out.debug << "imageLoad";             break;
917     case EOpImageStore:                 out.debug << "imageStore";            break;
918     case EOpImageAtomicAdd:             out.debug << "imageAtomicAdd";        break;
919     case EOpImageAtomicMin:             out.debug << "imageAtomicMin";        break;
920     case EOpImageAtomicMax:             out.debug << "imageAtomicMax";        break;
921     case EOpImageAtomicAnd:             out.debug << "imageAtomicAnd";        break;
922     case EOpImageAtomicOr:              out.debug << "imageAtomicOr";         break;
923     case EOpImageAtomicXor:             out.debug << "imageAtomicXor";        break;
924     case EOpImageAtomicExchange:        out.debug << "imageAtomicExchange";   break;
925     case EOpImageAtomicCompSwap:        out.debug << "imageAtomicCompSwap";   break;
926     case EOpImageAtomicLoad:            out.debug << "imageAtomicLoad";       break;
927     case EOpImageAtomicStore:           out.debug << "imageAtomicStore";      break;
928     case EOpImageLoadLod:               out.debug << "imageLoadLod";          break;
929     case EOpImageStoreLod:              out.debug << "imageStoreLod";         break;
930
931     case EOpTextureQuerySize:           out.debug << "textureSize";           break;
932     case EOpTextureQueryLod:            out.debug << "textureQueryLod";       break;
933     case EOpTextureQueryLevels:         out.debug << "textureQueryLevels";    break;
934     case EOpTextureQuerySamples:        out.debug << "textureSamples";        break;
935     case EOpTexture:                    out.debug << "texture";               break;
936     case EOpTextureProj:                out.debug << "textureProj";           break;
937     case EOpTextureLod:                 out.debug << "textureLod";            break;
938     case EOpTextureOffset:              out.debug << "textureOffset";         break;
939     case EOpTextureFetch:               out.debug << "textureFetch";          break;
940     case EOpTextureFetchOffset:         out.debug << "textureFetchOffset";    break;
941     case EOpTextureProjOffset:          out.debug << "textureProjOffset";     break;
942     case EOpTextureLodOffset:           out.debug << "textureLodOffset";      break;
943     case EOpTextureProjLod:             out.debug << "textureProjLod";        break;
944     case EOpTextureProjLodOffset:       out.debug << "textureProjLodOffset";  break;
945     case EOpTextureGrad:                out.debug << "textureGrad";           break;
946     case EOpTextureGradOffset:          out.debug << "textureGradOffset";     break;
947     case EOpTextureProjGrad:            out.debug << "textureProjGrad";       break;
948     case EOpTextureProjGradOffset:      out.debug << "textureProjGradOffset"; break;
949     case EOpTextureGather:              out.debug << "textureGather";         break;
950     case EOpTextureGatherOffset:        out.debug << "textureGatherOffset";   break;
951     case EOpTextureGatherOffsets:       out.debug << "textureGatherOffsets";  break;
952     case EOpTextureClamp:               out.debug << "textureClamp";          break;
953     case EOpTextureOffsetClamp:         out.debug << "textureOffsetClamp";    break;
954     case EOpTextureGradClamp:           out.debug << "textureGradClamp";      break;
955     case EOpTextureGradOffsetClamp:     out.debug << "textureGradOffsetClamp";  break;
956     case EOpTextureGatherLod:           out.debug << "textureGatherLod";        break;
957     case EOpTextureGatherLodOffset:     out.debug << "textureGatherLodOffset";  break;
958     case EOpTextureGatherLodOffsets:    out.debug << "textureGatherLodOffsets"; break;
959
960     case EOpSparseTexture:                  out.debug << "sparseTexture";                   break;
961     case EOpSparseTextureOffset:            out.debug << "sparseTextureOffset";             break;
962     case EOpSparseTextureLod:               out.debug << "sparseTextureLod";                break;
963     case EOpSparseTextureLodOffset:         out.debug << "sparseTextureLodOffset";          break;
964     case EOpSparseTextureFetch:             out.debug << "sparseTexelFetch";                break;
965     case EOpSparseTextureFetchOffset:       out.debug << "sparseTexelFetchOffset";          break;
966     case EOpSparseTextureGrad:              out.debug << "sparseTextureGrad";               break;
967     case EOpSparseTextureGradOffset:        out.debug << "sparseTextureGradOffset";         break;
968     case EOpSparseTextureGather:            out.debug << "sparseTextureGather";             break;
969     case EOpSparseTextureGatherOffset:      out.debug << "sparseTextureGatherOffset";       break;
970     case EOpSparseTextureGatherOffsets:     out.debug << "sparseTextureGatherOffsets";      break;
971     case EOpSparseImageLoad:                out.debug << "sparseImageLoad";                 break;
972     case EOpSparseTextureClamp:             out.debug << "sparseTextureClamp";              break;
973     case EOpSparseTextureOffsetClamp:       out.debug << "sparseTextureOffsetClamp";        break;
974     case EOpSparseTextureGradClamp:         out.debug << "sparseTextureGradClamp";          break;
975     case EOpSparseTextureGradOffsetClamp:   out.debug << "sparseTextureGradOffsetClam";     break;
976     case EOpSparseTextureGatherLod:         out.debug << "sparseTextureGatherLod";          break;
977     case EOpSparseTextureGatherLodOffset:   out.debug << "sparseTextureGatherLodOffset";    break;
978     case EOpSparseTextureGatherLodOffsets:  out.debug << "sparseTextureGatherLodOffsets";   break;
979     case EOpSparseImageLoadLod:             out.debug << "sparseImageLoadLod";              break;
980     case EOpImageSampleFootprintNV:             out.debug << "imageSampleFootprintNV";          break;
981     case EOpImageSampleFootprintClampNV:        out.debug << "imageSampleFootprintClampNV";     break;
982     case EOpImageSampleFootprintLodNV:          out.debug << "imageSampleFootprintLodNV";       break;
983     case EOpImageSampleFootprintGradNV:         out.debug << "imageSampleFootprintGradNV";      break;
984     case EOpImageSampleFootprintGradClampNV:    out.debug << "mageSampleFootprintGradClampNV";  break;
985     case EOpAddCarry:                   out.debug << "addCarry";              break;
986     case EOpSubBorrow:                  out.debug << "subBorrow";             break;
987     case EOpUMulExtended:               out.debug << "uMulExtended";          break;
988     case EOpIMulExtended:               out.debug << "iMulExtended";          break;
989     case EOpBitfieldExtract:            out.debug << "bitfieldExtract";       break;
990     case EOpBitfieldInsert:             out.debug << "bitfieldInsert";        break;
991
992     case EOpFma:                        out.debug << "fma";                   break;
993     case EOpFrexp:                      out.debug << "frexp";                 break;
994     case EOpLdexp:                      out.debug << "ldexp";                 break;
995
996     case EOpInterpolateAtSample:   out.debug << "interpolateAtSample";    break;
997     case EOpInterpolateAtOffset:   out.debug << "interpolateAtOffset";    break;
998     case EOpInterpolateAtVertex:   out.debug << "interpolateAtVertex";    break;
999
1000     case EOpSinCos:                     out.debug << "sincos";                break;
1001     case EOpGenMul:                     out.debug << "mul";                   break;
1002
1003     case EOpAllMemoryBarrierWithGroupSync:    out.debug << "AllMemoryBarrierWithGroupSync";    break;
1004     case EOpDeviceMemoryBarrier:              out.debug << "DeviceMemoryBarrier";              break;
1005     case EOpDeviceMemoryBarrierWithGroupSync: out.debug << "DeviceMemoryBarrierWithGroupSync"; break;
1006     case EOpWorkgroupMemoryBarrier:           out.debug << "WorkgroupMemoryBarrier";           break;
1007     case EOpWorkgroupMemoryBarrierWithGroupSync: out.debug << "WorkgroupMemoryBarrierWithGroupSync"; break;
1008
1009     case EOpSubgroupBarrier:                 out.debug << "subgroupBarrier"; break;
1010     case EOpSubgroupMemoryBarrier:           out.debug << "subgroupMemoryBarrier"; break;
1011     case EOpSubgroupMemoryBarrierBuffer:     out.debug << "subgroupMemoryBarrierBuffer"; break;
1012     case EOpSubgroupMemoryBarrierImage:      out.debug << "subgroupMemoryBarrierImage";   break;
1013     case EOpSubgroupMemoryBarrierShared:     out.debug << "subgroupMemoryBarrierShared"; break;
1014     case EOpSubgroupElect:                   out.debug << "subgroupElect"; break;
1015     case EOpSubgroupAll:                     out.debug << "subgroupAll"; break;
1016     case EOpSubgroupAny:                     out.debug << "subgroupAny"; break;
1017     case EOpSubgroupAllEqual:                out.debug << "subgroupAllEqual"; break;
1018     case EOpSubgroupBroadcast:               out.debug << "subgroupBroadcast"; break;
1019     case EOpSubgroupBroadcastFirst:          out.debug << "subgroupBroadcastFirst"; break;
1020     case EOpSubgroupBallot:                  out.debug << "subgroupBallot"; break;
1021     case EOpSubgroupInverseBallot:           out.debug << "subgroupInverseBallot"; break;
1022     case EOpSubgroupBallotBitExtract:        out.debug << "subgroupBallotBitExtract"; break;
1023     case EOpSubgroupBallotBitCount:          out.debug << "subgroupBallotBitCount"; break;
1024     case EOpSubgroupBallotInclusiveBitCount: out.debug << "subgroupBallotInclusiveBitCount"; break;
1025     case EOpSubgroupBallotExclusiveBitCount: out.debug << "subgroupBallotExclusiveBitCount"; break;
1026     case EOpSubgroupBallotFindLSB:           out.debug << "subgroupBallotFindLSB"; break;
1027     case EOpSubgroupBallotFindMSB:           out.debug << "subgroupBallotFindMSB"; break;
1028     case EOpSubgroupShuffle:                 out.debug << "subgroupShuffle"; break;
1029     case EOpSubgroupShuffleXor:              out.debug << "subgroupShuffleXor"; break;
1030     case EOpSubgroupShuffleUp:               out.debug << "subgroupShuffleUp"; break;
1031     case EOpSubgroupShuffleDown:             out.debug << "subgroupShuffleDown"; break;
1032     case EOpSubgroupAdd:                     out.debug << "subgroupAdd"; break;
1033     case EOpSubgroupMul:                     out.debug << "subgroupMul"; break;
1034     case EOpSubgroupMin:                     out.debug << "subgroupMin"; break;
1035     case EOpSubgroupMax:                     out.debug << "subgroupMax"; break;
1036     case EOpSubgroupAnd:                     out.debug << "subgroupAnd"; break;
1037     case EOpSubgroupOr:                      out.debug << "subgroupOr"; break;
1038     case EOpSubgroupXor:                     out.debug << "subgroupXor"; break;
1039     case EOpSubgroupInclusiveAdd:            out.debug << "subgroupInclusiveAdd"; break;
1040     case EOpSubgroupInclusiveMul:            out.debug << "subgroupInclusiveMul"; break;
1041     case EOpSubgroupInclusiveMin:            out.debug << "subgroupInclusiveMin"; break;
1042     case EOpSubgroupInclusiveMax:            out.debug << "subgroupInclusiveMax"; break;
1043     case EOpSubgroupInclusiveAnd:            out.debug << "subgroupInclusiveAnd"; break;
1044     case EOpSubgroupInclusiveOr:             out.debug << "subgroupInclusiveOr"; break;
1045     case EOpSubgroupInclusiveXor:            out.debug << "subgroupInclusiveXor"; break;
1046     case EOpSubgroupExclusiveAdd:            out.debug << "subgroupExclusiveAdd"; break;
1047     case EOpSubgroupExclusiveMul:            out.debug << "subgroupExclusiveMul"; break;
1048     case EOpSubgroupExclusiveMin:            out.debug << "subgroupExclusiveMin"; break;
1049     case EOpSubgroupExclusiveMax:            out.debug << "subgroupExclusiveMax"; break;
1050     case EOpSubgroupExclusiveAnd:            out.debug << "subgroupExclusiveAnd"; break;
1051     case EOpSubgroupExclusiveOr:             out.debug << "subgroupExclusiveOr"; break;
1052     case EOpSubgroupExclusiveXor:            out.debug << "subgroupExclusiveXor"; break;
1053     case EOpSubgroupClusteredAdd:            out.debug << "subgroupClusteredAdd"; break;
1054     case EOpSubgroupClusteredMul:            out.debug << "subgroupClusteredMul"; break;
1055     case EOpSubgroupClusteredMin:            out.debug << "subgroupClusteredMin"; break;
1056     case EOpSubgroupClusteredMax:            out.debug << "subgroupClusteredMax"; break;
1057     case EOpSubgroupClusteredAnd:            out.debug << "subgroupClusteredAnd"; break;
1058     case EOpSubgroupClusteredOr:             out.debug << "subgroupClusteredOr"; break;
1059     case EOpSubgroupClusteredXor:            out.debug << "subgroupClusteredXor"; break;
1060     case EOpSubgroupQuadBroadcast:           out.debug << "subgroupQuadBroadcast"; break;
1061     case EOpSubgroupQuadSwapHorizontal:      out.debug << "subgroupQuadSwapHorizontal"; break;
1062     case EOpSubgroupQuadSwapVertical:        out.debug << "subgroupQuadSwapVertical"; break;
1063     case EOpSubgroupQuadSwapDiagonal:        out.debug << "subgroupQuadSwapDiagonal"; break;
1064
1065     case EOpSubgroupPartition:                          out.debug << "subgroupPartitionNV";                          break;
1066     case EOpSubgroupPartitionedAdd:                     out.debug << "subgroupPartitionedAddNV";                     break;
1067     case EOpSubgroupPartitionedMul:                     out.debug << "subgroupPartitionedMulNV";                     break;
1068     case EOpSubgroupPartitionedMin:                     out.debug << "subgroupPartitionedMinNV";                     break;
1069     case EOpSubgroupPartitionedMax:                     out.debug << "subgroupPartitionedMaxNV";                     break;
1070     case EOpSubgroupPartitionedAnd:                     out.debug << "subgroupPartitionedAndNV";                     break;
1071     case EOpSubgroupPartitionedOr:                      out.debug << "subgroupPartitionedOrNV";                      break;
1072     case EOpSubgroupPartitionedXor:                     out.debug << "subgroupPartitionedXorNV";                     break;
1073     case EOpSubgroupPartitionedInclusiveAdd:            out.debug << "subgroupPartitionedInclusiveAddNV";            break;
1074     case EOpSubgroupPartitionedInclusiveMul:            out.debug << "subgroupPartitionedInclusiveMulNV";            break;
1075     case EOpSubgroupPartitionedInclusiveMin:            out.debug << "subgroupPartitionedInclusiveMinNV";            break;
1076     case EOpSubgroupPartitionedInclusiveMax:            out.debug << "subgroupPartitionedInclusiveMaxNV";            break;
1077     case EOpSubgroupPartitionedInclusiveAnd:            out.debug << "subgroupPartitionedInclusiveAndNV";            break;
1078     case EOpSubgroupPartitionedInclusiveOr:             out.debug << "subgroupPartitionedInclusiveOrNV";             break;
1079     case EOpSubgroupPartitionedInclusiveXor:            out.debug << "subgroupPartitionedInclusiveXorNV";            break;
1080     case EOpSubgroupPartitionedExclusiveAdd:            out.debug << "subgroupPartitionedExclusiveAddNV";            break;
1081     case EOpSubgroupPartitionedExclusiveMul:            out.debug << "subgroupPartitionedExclusiveMulNV";            break;
1082     case EOpSubgroupPartitionedExclusiveMin:            out.debug << "subgroupPartitionedExclusiveMinNV";            break;
1083     case EOpSubgroupPartitionedExclusiveMax:            out.debug << "subgroupPartitionedExclusiveMaxNV";            break;
1084     case EOpSubgroupPartitionedExclusiveAnd:            out.debug << "subgroupPartitionedExclusiveAndNV";            break;
1085     case EOpSubgroupPartitionedExclusiveOr:             out.debug << "subgroupPartitionedExclusiveOrNV";             break;
1086     case EOpSubgroupPartitionedExclusiveXor:            out.debug << "subgroupPartitionedExclusiveXorNV";            break;
1087
1088     case EOpSubpassLoad:   out.debug << "subpassLoad";   break;
1089     case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break;
1090
1091     case EOpTraceNV:                          out.debug << "traceNV"; break;
1092     case EOpTraceRayMotionNV:                 out.debug << "traceRayMotionNV"; break;
1093     case EOpTraceKHR:                         out.debug << "traceRayKHR"; break;
1094     case EOpReportIntersection:               out.debug << "reportIntersectionNV"; break;
1095     case EOpIgnoreIntersectionNV:             out.debug << "ignoreIntersectionNV"; break;
1096     case EOpIgnoreIntersectionKHR:            out.debug << "ignoreIntersectionKHR"; break;
1097     case EOpTerminateRayNV:                   out.debug << "terminateRayNV"; break;
1098     case EOpTerminateRayKHR:                  out.debug << "terminateRayKHR"; break;
1099     case EOpExecuteCallableNV:                out.debug << "executeCallableNV"; break;
1100     case EOpExecuteCallableKHR:               out.debug << "executeCallableKHR"; break;
1101     case EOpWritePackedPrimitiveIndices4x8NV: out.debug << "writePackedPrimitiveIndices4x8NV"; break;
1102
1103     case EOpRayQueryInitialize:                                            out.debug << "rayQueryInitializeEXT"; break;
1104     case EOpRayQueryTerminate:                                             out.debug << "rayQueryTerminateEXT"; break;
1105     case EOpRayQueryGenerateIntersection:                                  out.debug << "rayQueryGenerateIntersectionEXT"; break;
1106     case EOpRayQueryConfirmIntersection:                                   out.debug << "rayQueryConfirmIntersectionEXT"; break;
1107     case EOpRayQueryProceed:                                               out.debug << "rayQueryProceedEXT"; break;
1108     case EOpRayQueryGetIntersectionType:                                   out.debug << "rayQueryGetIntersectionTypeEXT"; break;
1109     case EOpRayQueryGetRayTMin:                                            out.debug << "rayQueryGetRayTMinEXT"; break;
1110     case EOpRayQueryGetRayFlags:                                           out.debug << "rayQueryGetRayFlagsEXT"; break;
1111     case EOpRayQueryGetIntersectionT:                                      out.debug << "rayQueryGetIntersectionTEXT"; break;
1112     case EOpRayQueryGetIntersectionInstanceCustomIndex:                    out.debug << "rayQueryGetIntersectionInstanceCustomIndexEXT"; break;
1113     case EOpRayQueryGetIntersectionInstanceId:                             out.debug << "rayQueryGetIntersectionInstanceIdEXT"; break;
1114     case EOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffset: out.debug << "rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT"; break;
1115     case EOpRayQueryGetIntersectionGeometryIndex:                          out.debug << "rayQueryGetIntersectionGeometryIndexEXT"; break;
1116     case EOpRayQueryGetIntersectionPrimitiveIndex:                         out.debug << "rayQueryGetIntersectionPrimitiveIndexEXT"; break;
1117     case EOpRayQueryGetIntersectionBarycentrics:                           out.debug << "rayQueryGetIntersectionBarycentricsEXT"; break;
1118     case EOpRayQueryGetIntersectionFrontFace:                              out.debug << "rayQueryGetIntersectionFrontFaceEXT"; break;
1119     case EOpRayQueryGetIntersectionCandidateAABBOpaque:                    out.debug << "rayQueryGetIntersectionCandidateAABBOpaqueEXT"; break;
1120     case EOpRayQueryGetIntersectionObjectRayDirection:                     out.debug << "rayQueryGetIntersectionObjectRayDirectionEXT"; break;
1121     case EOpRayQueryGetIntersectionObjectRayOrigin:                        out.debug << "rayQueryGetIntersectionObjectRayOriginEXT"; break;
1122     case EOpRayQueryGetWorldRayDirection:                                  out.debug << "rayQueryGetWorldRayDirectionEXT"; break;
1123     case EOpRayQueryGetWorldRayOrigin:                                     out.debug << "rayQueryGetWorldRayOriginEXT"; break;
1124     case EOpRayQueryGetIntersectionObjectToWorld:                          out.debug << "rayQueryGetIntersectionObjectToWorldEXT"; break;
1125     case EOpRayQueryGetIntersectionWorldToObject:                          out.debug << "rayQueryGetIntersectionWorldToObjectEXT"; break;
1126
1127     case EOpCooperativeMatrixLoad:  out.debug << "Load cooperative matrix";  break;
1128     case EOpCooperativeMatrixStore:  out.debug << "Store cooperative matrix";  break;
1129     case EOpCooperativeMatrixMulAdd: out.debug << "MulAdd cooperative matrices"; break;
1130
1131     case EOpIsHelperInvocation: out.debug << "IsHelperInvocation"; break;
1132     case EOpDebugPrintf:  out.debug << "Debug printf";  break;
1133
1134 #ifndef GLSLANG_WEB
1135     case EOpSpirvInst: out.debug << "spirv_instruction"; break;
1136 #endif
1137
1138     default: out.debug.message(EPrefixError, "Bad aggregation op");
1139     }
1140
1141     if (node->getOp() != EOpSequence && node->getOp() != EOpParameters)
1142         out.debug << " (" << node->getCompleteString() << ")";
1143
1144     out.debug << "\n";
1145
1146     return true;
1147 }
1148
1149 bool TOutputTraverser::visitSelection(TVisit /* visit */, TIntermSelection* node)
1150 {
1151     TInfoSink& out = infoSink;
1152
1153     OutputTreeText(out, node, depth);
1154
1155     out.debug << "Test condition and select";
1156     out.debug << " (" << node->getCompleteString() << ")";
1157
1158     if (node->getShortCircuit() == false)
1159         out.debug << ": no shortcircuit";
1160     if (node->getFlatten())
1161         out.debug << ": Flatten";
1162     if (node->getDontFlatten())
1163         out.debug << ": DontFlatten";
1164     out.debug << "\n";
1165
1166     ++depth;
1167
1168     OutputTreeText(out, node, depth);
1169     out.debug << "Condition\n";
1170     node->getCondition()->traverse(this);
1171
1172     OutputTreeText(out, node, depth);
1173     if (node->getTrueBlock()) {
1174         out.debug << "true case\n";
1175         node->getTrueBlock()->traverse(this);
1176     } else
1177         out.debug << "true case is null\n";
1178
1179     if (node->getFalseBlock()) {
1180         OutputTreeText(out, node, depth);
1181         out.debug << "false case\n";
1182         node->getFalseBlock()->traverse(this);
1183     }
1184
1185     --depth;
1186
1187     return false;
1188 }
1189
1190 // Print infinities and NaNs, and numbers in a portable way.
1191 // Goals:
1192 //   - portable (across IEEE 754 platforms)
1193 //   - shows all possible IEEE values
1194 //   - shows simple numbers in a simple way, e.g., no leading/trailing 0s
1195 //   - shows all digits, no premature rounding
1196 static void OutputDouble(TInfoSink& out, double value, TOutputTraverser::EExtraOutput extra)
1197 {
1198     if (IsInfinity(value)) {
1199         if (value < 0)
1200             out.debug << "-1.#INF";
1201         else
1202             out.debug << "+1.#INF";
1203     } else if (IsNan(value))
1204         out.debug << "1.#IND";
1205     else {
1206         const int maxSize = 340;
1207         char buf[maxSize];
1208         const char* format = "%f";
1209         if (fabs(value) > 0.0 && (fabs(value) < 1e-5 || fabs(value) > 1e12))
1210             format = "%-.13e";
1211         int len = snprintf(buf, maxSize, format, value);
1212         assert(len < maxSize);
1213
1214         // remove a leading zero in the 100s slot in exponent; it is not portable
1215         // pattern:   XX...XXXe+0XX or XX...XXXe-0XX
1216         if (len > 5) {
1217             if (buf[len-5] == 'e' && (buf[len-4] == '+' || buf[len-4] == '-') && buf[len-3] == '0') {
1218                 buf[len-3] = buf[len-2];
1219                 buf[len-2] = buf[len-1];
1220                 buf[len-1] = '\0';
1221             }
1222         }
1223
1224         out.debug << buf;
1225
1226         switch (extra) {
1227         case TOutputTraverser::BinaryDoubleOutput:
1228         {
1229             uint64_t b;
1230             static_assert(sizeof(b) == sizeof(value), "sizeof(uint64_t) != sizeof(double)");
1231             memcpy(&b, &value, sizeof(b));
1232
1233             out.debug << " : ";
1234             for (size_t i = 0; i < 8 * sizeof(value); ++i, ++b) {
1235                 out.debug << ((b & 0x8000000000000000) != 0 ? "1" : "0");
1236                 b <<= 1;
1237             }
1238             break;
1239         }
1240         default:
1241             break;
1242         }
1243     }
1244 }
1245
1246 static void OutputConstantUnion(TInfoSink& out, const TIntermTyped* node, const TConstUnionArray& constUnion,
1247     TOutputTraverser::EExtraOutput extra, int depth)
1248 {
1249     int size = node->getType().computeNumComponents();
1250
1251     for (int i = 0; i < size; i++) {
1252         OutputTreeText(out, node, depth);
1253         switch (constUnion[i].getType()) {
1254         case EbtBool:
1255             if (constUnion[i].getBConst())
1256                 out.debug << "true";
1257             else
1258                 out.debug << "false";
1259
1260             out.debug << " (" << "const bool" << ")";
1261
1262             out.debug << "\n";
1263             break;
1264         case EbtFloat:
1265         case EbtDouble:
1266         case EbtFloat16:
1267             OutputDouble(out, constUnion[i].getDConst(), extra);
1268             out.debug << "\n";
1269             break;
1270         case EbtInt8:
1271             {
1272                 const int maxSize = 300;
1273                 char buf[maxSize];
1274                 snprintf(buf, maxSize, "%d (%s)", constUnion[i].getI8Const(), "const int8_t");
1275
1276                 out.debug << buf << "\n";
1277             }
1278             break;
1279         case EbtUint8:
1280             {
1281                 const int maxSize = 300;
1282                 char buf[maxSize];
1283                 snprintf(buf, maxSize, "%u (%s)", constUnion[i].getU8Const(), "const uint8_t");
1284
1285                 out.debug << buf << "\n";
1286             }
1287             break;
1288         case EbtInt16:
1289             {
1290                 const int maxSize = 300;
1291                 char buf[maxSize];
1292                 snprintf(buf, maxSize, "%d (%s)", constUnion[i].getI16Const(), "const int16_t");
1293
1294                 out.debug << buf << "\n";
1295             }
1296             break;
1297         case EbtUint16:
1298             {
1299                 const int maxSize = 300;
1300                 char buf[maxSize];
1301                 snprintf(buf, maxSize, "%u (%s)", constUnion[i].getU16Const(), "const uint16_t");
1302
1303                 out.debug << buf << "\n";
1304             }
1305             break;
1306         case EbtInt:
1307             {
1308                 const int maxSize = 300;
1309                 char buf[maxSize];
1310                 snprintf(buf, maxSize, "%d (%s)", constUnion[i].getIConst(), "const int");
1311
1312                 out.debug << buf << "\n";
1313             }
1314             break;
1315         case EbtUint:
1316             {
1317                 const int maxSize = 300;
1318                 char buf[maxSize];
1319                 snprintf(buf, maxSize, "%u (%s)", constUnion[i].getUConst(), "const uint");
1320
1321                 out.debug << buf << "\n";
1322             }
1323             break;
1324         case EbtInt64:
1325             {
1326                 const int maxSize = 300;
1327                 char buf[maxSize];
1328                 snprintf(buf, maxSize, "%lld (%s)", constUnion[i].getI64Const(), "const int64_t");
1329
1330                 out.debug << buf << "\n";
1331             }
1332             break;
1333         case EbtUint64:
1334             {
1335                 const int maxSize = 300;
1336                 char buf[maxSize];
1337                 snprintf(buf, maxSize, "%llu (%s)", constUnion[i].getU64Const(), "const uint64_t");
1338
1339                 out.debug << buf << "\n";
1340             }
1341             break;
1342         case EbtString:
1343             out.debug << "\"" << constUnion[i].getSConst()->c_str() << "\"\n";
1344             break;
1345         default:
1346             out.info.message(EPrefixInternalError, "Unknown constant", node->getLoc());
1347             break;
1348         }
1349     }
1350 }
1351
1352 void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node)
1353 {
1354     OutputTreeText(infoSink, node, depth);
1355     infoSink.debug << "Constant:\n";
1356
1357     OutputConstantUnion(infoSink, node, node->getConstArray(), extraOutput, depth + 1);
1358 }
1359
1360 void TOutputTraverser::visitSymbol(TIntermSymbol* node)
1361 {
1362     OutputTreeText(infoSink, node, depth);
1363
1364     infoSink.debug << "'" << node->getName() << "' (" << node->getCompleteString() << ")\n";
1365
1366     if (! node->getConstArray().empty())
1367         OutputConstantUnion(infoSink, node, node->getConstArray(), extraOutput, depth + 1);
1368     else if (node->getConstSubtree()) {
1369         incrementDepth(node);
1370         node->getConstSubtree()->traverse(this);
1371         decrementDepth();
1372     }
1373 }
1374
1375 bool TOutputTraverser::visitLoop(TVisit /* visit */, TIntermLoop* node)
1376 {
1377     TInfoSink& out = infoSink;
1378
1379     OutputTreeText(out, node, depth);
1380
1381     out.debug << "Loop with condition ";
1382     if (! node->testFirst())
1383         out.debug << "not ";
1384     out.debug << "tested first";
1385
1386     if (node->getUnroll())
1387         out.debug << ": Unroll";
1388     if (node->getDontUnroll())
1389         out.debug << ": DontUnroll";
1390     if (node->getLoopDependency()) {
1391         out.debug << ": Dependency ";
1392         out.debug << node->getLoopDependency();
1393     }
1394     out.debug << "\n";
1395
1396     ++depth;
1397
1398     OutputTreeText(infoSink, node, depth);
1399     if (node->getTest()) {
1400         out.debug << "Loop Condition\n";
1401         node->getTest()->traverse(this);
1402     } else
1403         out.debug << "No loop condition\n";
1404
1405     OutputTreeText(infoSink, node, depth);
1406     if (node->getBody()) {
1407         out.debug << "Loop Body\n";
1408         node->getBody()->traverse(this);
1409     } else
1410         out.debug << "No loop body\n";
1411
1412     if (node->getTerminal()) {
1413         OutputTreeText(infoSink, node, depth);
1414         out.debug << "Loop Terminal Expression\n";
1415         node->getTerminal()->traverse(this);
1416     }
1417
1418     --depth;
1419
1420     return false;
1421 }
1422
1423 bool TOutputTraverser::visitBranch(TVisit /* visit*/, TIntermBranch* node)
1424 {
1425     TInfoSink& out = infoSink;
1426
1427     OutputTreeText(out, node, depth);
1428
1429     switch (node->getFlowOp()) {
1430     case EOpKill:                   out.debug << "Branch: Kill";                  break;
1431     case EOpTerminateInvocation:    out.debug << "Branch: TerminateInvocation";   break;
1432     case EOpIgnoreIntersectionKHR:  out.debug << "Branch: IgnoreIntersectionKHR"; break;
1433     case EOpTerminateRayKHR:        out.debug << "Branch: TerminateRayKHR";       break;
1434     case EOpBreak:                  out.debug << "Branch: Break";                 break;
1435     case EOpContinue:               out.debug << "Branch: Continue";              break;
1436     case EOpReturn:                 out.debug << "Branch: Return";                break;
1437     case EOpCase:                   out.debug << "case: ";                        break;
1438     case EOpDemote:                 out.debug << "Demote";                        break;
1439     case EOpDefault:                out.debug << "default: ";                     break;
1440     default:                        out.debug << "Branch: Unknown Branch";        break;
1441     }
1442
1443     if (node->getExpression()) {
1444         out.debug << " with expression\n";
1445         ++depth;
1446         node->getExpression()->traverse(this);
1447         --depth;
1448     } else
1449         out.debug << "\n";
1450
1451     return false;
1452 }
1453
1454 bool TOutputTraverser::visitSwitch(TVisit /* visit */, TIntermSwitch* node)
1455 {
1456     TInfoSink& out = infoSink;
1457
1458     OutputTreeText(out, node, depth);
1459     out.debug << "switch";
1460
1461     if (node->getFlatten())
1462         out.debug << ": Flatten";
1463     if (node->getDontFlatten())
1464         out.debug << ": DontFlatten";
1465     out.debug << "\n";
1466
1467     OutputTreeText(out, node, depth);
1468     out.debug << "condition\n";
1469     ++depth;
1470     node->getCondition()->traverse(this);
1471
1472     --depth;
1473     OutputTreeText(out, node, depth);
1474     out.debug << "body\n";
1475     ++depth;
1476     node->getBody()->traverse(this);
1477
1478     --depth;
1479
1480     return false;
1481 }
1482
1483 //
1484 // This function is the one to call externally to start the traversal.
1485 // Individual functions can be initialized to 0 to skip processing of that
1486 // type of node.  It's children will still be processed.
1487 //
1488 void TIntermediate::output(TInfoSink& infoSink, bool tree)
1489 {
1490     infoSink.debug << "Shader version: " << version << "\n";
1491     if (requestedExtensions.size() > 0) {
1492         for (auto extIt = requestedExtensions.begin(); extIt != requestedExtensions.end(); ++extIt)
1493             infoSink.debug << "Requested " << *extIt << "\n";
1494     }
1495
1496     if (xfbMode)
1497         infoSink.debug << "in xfb mode\n";
1498
1499     if (getSubgroupUniformControlFlow())
1500         infoSink.debug << "subgroup_uniform_control_flow\n";
1501
1502     switch (language) {
1503     case EShLangVertex:
1504         break;
1505
1506     case EShLangTessControl:
1507         infoSink.debug << "vertices = " << vertices << "\n";
1508
1509         if (inputPrimitive != ElgNone)
1510             infoSink.debug << "input primitive = " << TQualifier::getGeometryString(inputPrimitive) << "\n";
1511         if (vertexSpacing != EvsNone)
1512             infoSink.debug << "vertex spacing = " << TQualifier::getVertexSpacingString(vertexSpacing) << "\n";
1513         if (vertexOrder != EvoNone)
1514             infoSink.debug << "triangle order = " << TQualifier::getVertexOrderString(vertexOrder) << "\n";
1515         break;
1516
1517     case EShLangTessEvaluation:
1518         infoSink.debug << "input primitive = " << TQualifier::getGeometryString(inputPrimitive) << "\n";
1519         infoSink.debug << "vertex spacing = " << TQualifier::getVertexSpacingString(vertexSpacing) << "\n";
1520         infoSink.debug << "triangle order = " << TQualifier::getVertexOrderString(vertexOrder) << "\n";
1521         if (pointMode)
1522             infoSink.debug << "using point mode\n";
1523         break;
1524
1525     case EShLangGeometry:
1526         infoSink.debug << "invocations = " << invocations << "\n";
1527         infoSink.debug << "max_vertices = " << vertices << "\n";
1528         infoSink.debug << "input primitive = " << TQualifier::getGeometryString(inputPrimitive) << "\n";
1529         infoSink.debug << "output primitive = " << TQualifier::getGeometryString(outputPrimitive) << "\n";
1530         break;
1531
1532     case EShLangFragment:
1533         if (pixelCenterInteger)
1534             infoSink.debug << "gl_FragCoord pixel center is integer\n";
1535         if (originUpperLeft)
1536             infoSink.debug << "gl_FragCoord origin is upper left\n";
1537         if (earlyFragmentTests)
1538             infoSink.debug << "using early_fragment_tests\n";
1539         if (postDepthCoverage)
1540             infoSink.debug << "using post_depth_coverage\n";
1541         if (depthLayout != EldNone)
1542             infoSink.debug << "using " << TQualifier::getLayoutDepthString(depthLayout) << "\n";
1543         if (blendEquations != 0) {
1544             infoSink.debug << "using";
1545             // blendEquations is a mask, decode it
1546             for (TBlendEquationShift be = (TBlendEquationShift)0; be < EBlendCount; be = (TBlendEquationShift)(be + 1)) {
1547                 if (blendEquations & (1 << be))
1548                     infoSink.debug << " " << TQualifier::getBlendEquationString(be);
1549             }
1550             infoSink.debug << "\n";
1551         }
1552         if (interlockOrdering != EioNone)
1553             infoSink.debug << "interlock ordering = " << TQualifier::getInterlockOrderingString(interlockOrdering) << "\n";
1554         break;
1555
1556     case EShLangMeshNV:
1557         infoSink.debug << "max_vertices = " << vertices << "\n";
1558         infoSink.debug << "max_primitives = " << primitives << "\n";
1559         infoSink.debug << "output primitive = " << TQualifier::getGeometryString(outputPrimitive) << "\n";
1560         // Fall through
1561     case EShLangTaskNV:
1562         // Fall through
1563     case EShLangCompute:
1564         infoSink.debug << "local_size = (" << localSize[0] << ", " << localSize[1] << ", " << localSize[2] << ")\n";
1565         {
1566             if (localSizeSpecId[0] != TQualifier::layoutNotSet ||
1567                 localSizeSpecId[1] != TQualifier::layoutNotSet ||
1568                 localSizeSpecId[2] != TQualifier::layoutNotSet) {
1569                 infoSink.debug << "local_size ids = (" <<
1570                     localSizeSpecId[0] << ", " <<
1571                     localSizeSpecId[1] << ", " <<
1572                     localSizeSpecId[2] << ")\n";
1573             }
1574         }
1575         break;
1576
1577     default:
1578         break;
1579     }
1580
1581     if (treeRoot == 0 || ! tree)
1582         return;
1583
1584     TOutputTraverser it(infoSink);
1585     if (getBinaryDoubleOutput())
1586         it.setDoubleOutput(TOutputTraverser::BinaryDoubleOutput);
1587     treeRoot->traverse(&it);
1588 }
1589
1590 } // end namespace glslang
1591
1592 #endif // !GLSLANG_WEB && !GLSLANG_ANGLE