1 /*========================== begin_copyright_notice ============================
2
3 Copyright (C) 2017-2021 Intel Corporation
4
5 SPDX-License-Identifier: MIT
6
7 ============================= end_copyright_notice ===========================*/
8
9 //===----------------------------------------------------------------------===//
10 /// \file
11 ///
12 /// This file defines Debug Info ext instruction class for SPIR-V.
13 ///
14 //===----------------------------------------------------------------------===//
15
16 #ifndef SPIRVDEBUGINFOEXT_HPP_
17 #define SPIRVDEBUGINFOEXT_HPP_
18
19 #include <llvm/BinaryFormat/Dwarf.h>
20
21 #include "SPIRVEntry.h"
22 #include "SPIRVInstruction.h"
23 #include "SPIRVExtInst.h"
24 #include "spirv.hpp"
25
26 namespace igc_spv {
27
28 // SPIRVDebug is shared with common clang's SPIRV emitter
29 namespace SPIRVDebug {
30
31 const unsigned int DebugInfoVersion = 10001;
32
33 enum Instruction {
34 DebugInfoNone = 0,
35 CompilationUnit = 1,
36 TypeBasic = 2,
37 TypePointer = 3,
38 TypeQualifier = 4,
39 TypeArray = 5,
40 TypeVector = 6,
41 Typedef = 7,
42 TypeFunction = 8,
43 TypeEnum = 9,
44 TypeComposite = 10,
45 TypeMember = 11,
46 Inheritance = 12,
47 TypePtrToMember = 13,
48 TypeTemplate = 14,
49 TypeTemplateParameter = 15,
50 TypeTemplateTemplateParameter = 16,
51 TypeTemplateParameterPack = 17,
52 GlobalVariable = 18,
53 FunctionDecl = 19,
54 Function = 20,
55 LexicalBlock = 21,
56 LexicalBlockDiscriminator = 22,
57 Scope = 23,
58 NoScope = 24,
59 InlinedAt = 25,
60 LocalVariable = 26,
61 InlinedVariable = 27,
62 Declare = 28,
63 Value = 29,
64 Operation = 30,
65 Expression = 31,
66 MacroDef = 32,
67 MacroUndef = 33,
68 ImportedEntity = 34,
69 Source = 35,
70 ModuleINTEL = 36,
71 InstCount = 37
72 };
73
74 enum Flag {
75 FlagIsProtected = 1 << 0,
76 FlagIsPrivate = 1 << 1,
77 FlagIsPublic = FlagIsPrivate | FlagIsProtected,
78 FlagAccess = FlagIsPublic,
79 FlagIsLocal = 1 << 2,
80 FlagIsDefinition = 1 << 3,
81 FlagIsFwdDecl = 1 << 4,
82 FlagIsArtificial = 1 << 5,
83 FlagIsExplicit = 1 << 6,
84 FlagIsPrototyped = 1 << 7,
85 FlagIsObjectPointer = 1 << 8,
86 FlagIsStaticMember = 1 << 9,
87 FlagIsIndirectVariable = 1 << 10,
88 FlagIsLValueReference = 1 << 11,
89 FlagIsRValueReference = 1 << 12,
90 FlagIsOptimized = 1 << 13,
91 FlagIsEnumClass = 1 << 14,
92 FlagTypePassByValue = 1 << 15,
93 FlagTypePassByReference = 1 << 16,
94 };
95
96 enum EncodingTag {
97 Unspecified = 0,
98 Address = 1,
99 Boolean = 2,
100 Float = 3,
101 Signed = 4,
102 SignedChar = 5,
103 Unsigned = 6,
104 UnsignedChar = 7
105 };
106
107 enum CompositeTypeTag {
108 Class = 0,
109 Structure = 1,
110 Union = 2
111 };
112
113 enum TypeQualifierTag {
114 ConstType = 0,
115 VolatileType = 1,
116 RestrictType = 2,
117 AtomicType = 3
118 };
119
120 enum ExpressionOpCode {
121 Deref = 0,
122 Plus = 1,
123 Minus = 2,
124 PlusUconst = 3,
125 BitPiece = 4,
126 Swap = 5,
127 Xderef = 6,
128 StackValue = 7,
129 Constu = 8,
130 Fragment = 9,
131 Convert = 10,
132 Addr = 11,
133 Const1u = 12,
134 Const1s = 13,
135 Const2u = 14,
136 Const2s = 15,
137 Const4u = 16,
138 Const4s = 17,
139 Const8u = 18,
140 Const8s = 19,
141 Consts = 20,
142 Dup = 21,
143 Drop = 22,
144 Over = 23,
145 Pick = 24,
146 Rot = 25,
147 Abs = 26,
148 And = 27,
149 Div = 28,
150 Mod = 29,
151 Mul = 30,
152 Neg = 31,
153 Not = 32,
154 Or = 33,
155 Shl = 34,
156 Shr = 35,
157 Shra = 36,
158 Xor = 37,
159 Bra = 38,
160 Eq = 39,
161 Ge = 40,
162 Gt = 41,
163 Le = 42,
164 Lt = 43,
165 Ne = 44,
166 Skip = 45,
167 Lit0 = 46,
168 Lit1 = 47,
169 Lit2 = 48,
170 Lit3 = 49,
171 Lit4 = 50,
172 Lit5 = 51,
173 Lit6 = 52,
174 Lit7 = 53,
175 Lit8 = 54,
176 Lit9 = 55,
177 Lit10 = 56,
178 Lit11 = 57,
179 Lit12 = 58,
180 Lit13 = 59,
181 Lit14 = 60,
182 Lit15 = 61,
183 Lit16 = 62,
184 Lit17 = 63,
185 Lit18 = 64,
186 Lit19 = 65,
187 Lit20 = 66,
188 Lit21 = 67,
189 Lit22 = 68,
190 Lit23 = 69,
191 Lit24 = 70,
192 Lit25 = 71,
193 Lit26 = 72,
194 Lit27 = 73,
195 Lit28 = 74,
196 Lit29 = 75,
197 Lit30 = 76,
198 Lit31 = 77,
199 Reg0 = 78,
200 Reg1 = 79,
201 Reg2 = 80,
202 Reg3 = 81,
203 Reg4 = 82,
204 Reg5 = 83,
205 Reg6 = 84,
206 Reg7 = 85,
207 Reg8 = 86,
208 Reg9 = 87,
209 Reg10 = 88,
210 Reg11 = 89,
211 Reg12 = 90,
212 Reg13 = 91,
213 Reg14 = 92,
214 Reg15 = 93,
215 Reg16 = 94,
216 Reg17 = 95,
217 Reg18 = 96,
218 Reg19 = 97,
219 Reg20 = 98,
220 Reg21 = 99,
221 Reg22 = 100,
222 Reg23 = 101,
223 Reg24 = 102,
224 Reg25 = 103,
225 Reg26 = 104,
226 Reg27 = 105,
227 Reg28 = 106,
228 Reg29 = 107,
229 Reg30 = 108,
230 Reg31 = 109,
231 Breg0 = 110,
232 Breg1 = 111,
233 Breg2 = 112,
234 Breg3 = 113,
235 Breg4 = 114,
236 Breg5 = 115,
237 Breg6 = 116,
238 Breg7 = 117,
239 Breg8 = 118,
240 Breg9 = 119,
241 Breg10 = 120,
242 Breg11 = 121,
243 Breg12 = 122,
244 Breg13 = 123,
245 Breg14 = 124,
246 Breg15 = 125,
247 Breg16 = 126,
248 Breg17 = 127,
249 Breg18 = 128,
250 Breg19 = 129,
251 Breg20 = 130,
252 Breg21 = 131,
253 Breg22 = 132,
254 Breg23 = 133,
255 Breg24 = 134,
256 Breg25 = 135,
257 Breg26 = 136,
258 Breg27 = 137,
259 Breg28 = 138,
260 Breg29 = 139,
261 Breg30 = 140,
262 Breg31 = 141,
263 Regx = 142,
264 Fbreg = 143,
265 Bregx = 144,
266 Piece = 145,
267 DerefSize = 146,
268 XderefSize = 147,
269 Nop = 148,
270 PushObjectAddress = 149,
271 Call2 = 150,
272 Call4 = 151,
273 CallRef = 152,
274 FormTlsAddress = 153,
275 CallFrameCfa = 154,
276 ImplicitValue = 155,
277 ImplicitPointer = 156,
278 Addrx = 157,
279 Constx = 158,
280 EntryValue = 159,
281 ConstTypeOp = 160,
282 RegvalType = 161,
283 DerefType = 162,
284 XderefType = 163,
285 Reinterpret = 164
286 };
287
288 static std::unordered_map<ExpressionOpCode, unsigned> OpCountMap{
289 { Deref, 1 },
290 { Plus, 1 },
291 { Minus, 1 },
292 { PlusUconst, 2 },
293 { BitPiece, 3 },
294 { Swap, 1 },
295 { Xderef, 1 },
296 { StackValue, 1 },
297 { Constu, 2 },
298 { Fragment, 3 },
299 { Convert, 3 },
300 { Addr, 2 },
301 { Const1u, 2 },
302 { Const1s, 2 },
303 { Const2u, 2 },
304 { Const2s, 2 },
305 { Const4u, 2 },
306 { Const4s, 2 },
307 { Const8u, 2 },
308 { Const8s, 2 },
309 { Consts, 2 },
310 { Dup, 1 },
311 { Drop, 1 },
312 { Over, 1 },
313 { Pick, 1 },
314 { Rot, 1 },
315 { Abs, 1 },
316 { And, 1 },
317 { Div, 1 },
318 { Mod, 1 },
319 { Mul, 1 },
320 { Neg, 1 },
321 { Not, 1 },
322 { Or, 1 },
323 { Shl, 1 },
324 { Shr, 1 },
325 { Shra, 1 },
326 { Xor, 1 },
327 { Bra, 2 },
328 { Eq, 1 },
329 { Ge, 1 },
330 { Gt, 1 },
331 { Le, 1 },
332 { Lt, 1 },
333 { Ne, 1 },
334 { Skip, 2 },
335 { Lit0, 1 },
336 { Lit1, 1 },
337 { Lit2, 1 },
338 { Lit3, 1 },
339 { Lit4, 1 },
340 { Lit5, 1 },
341 { Lit6, 1 },
342 { Lit7, 1 },
343 { Lit8, 1 },
344 { Lit9, 1 },
345 { Lit10, 1 },
346 { Lit11, 1 },
347 { Lit12, 1 },
348 { Lit13, 1 },
349 { Lit14, 1 },
350 { Lit15, 1 },
351 { Lit16, 1 },
352 { Lit17, 1 },
353 { Lit18, 1 },
354 { Lit19, 1 },
355 { Lit20, 1 },
356 { Lit21, 1 },
357 { Lit22, 1 },
358 { Lit23, 1 },
359 { Lit24, 1 },
360 { Lit25, 1 },
361 { Lit26, 1 },
362 { Lit27, 1 },
363 { Lit28, 1 },
364 { Lit29, 1 },
365 { Lit30, 1 },
366 { Lit31, 1 },
367 { Reg0, 1 },
368 { Reg1, 1 },
369 { Reg2, 1 },
370 { Reg3, 1 },
371 { Reg4, 1 },
372 { Reg5, 1 },
373 { Reg6, 1 },
374 { Reg7, 1 },
375 { Reg8, 1 },
376 { Reg9, 1 },
377 { Reg10, 1 },
378 { Reg11, 1 },
379 { Reg12, 1 },
380 { Reg13, 1 },
381 { Reg14, 1 },
382 { Reg15, 1 },
383 { Reg16, 1 },
384 { Reg17, 1 },
385 { Reg18, 1 },
386 { Reg19, 1 },
387 { Reg20, 1 },
388 { Reg21, 1 },
389 { Reg22, 1 },
390 { Reg23, 1 },
391 { Reg24, 1 },
392 { Reg25, 1 },
393 { Reg26, 1 },
394 { Reg27, 1 },
395 { Reg28, 1 },
396 { Reg29, 1 },
397 { Reg30, 1 },
398 { Reg31, 1 },
399 { Breg0, 2 },
400 { Breg1, 2 },
401 { Breg2, 2 },
402 { Breg3, 2 },
403 { Breg4, 2 },
404 { Breg5, 2 },
405 { Breg6, 2 },
406 { Breg7, 2 },
407 { Breg8, 2 },
408 { Breg9, 2 },
409 { Breg10, 2 },
410 { Breg11, 2 },
411 { Breg12, 2 },
412 { Breg13, 2 },
413 { Breg14, 2 },
414 { Breg15, 2 },
415 { Breg16, 2 },
416 { Breg17, 2 },
417 { Breg18, 2 },
418 { Breg19, 2 },
419 { Breg20, 2 },
420 { Breg21, 2 },
421 { Breg22, 2 },
422 { Breg23, 2 },
423 { Breg24, 2 },
424 { Breg25, 2 },
425 { Breg26, 2 },
426 { Breg27, 2 },
427 { Breg28, 2 },
428 { Breg29, 2 },
429 { Breg30, 2 },
430 { Breg31, 2 },
431 { Regx, 2 },
432 { Fbreg, 1 },
433 { Bregx, 3 },
434 { Piece, 2 },
435 { DerefSize, 2 },
436 { XderefSize, 2 },
437 { Nop, 1 },
438 { PushObjectAddress, 1 },
439 { Call2, 2 },
440 { Call4, 2 },
441 { CallRef, 2 },
442 { FormTlsAddress, 1 },
443 { CallFrameCfa, 1 },
444 { ImplicitValue, 3 },
445 { ImplicitPointer, 3 },
446 { Addrx, 2 },
447 { Constx, 2 },
448 { EntryValue, 3 },
449 { ConstTypeOp, 4 },
450 { RegvalType, 3 },
451 { DerefType, 3 },
452 { XderefType, 3 },
453 { Reinterpret, 2 },
454 };
455
456 enum ImportedEntityTag {
457 ImportedModule = 0,
458 ImportedDeclaration = 1,
459 };
460
461 namespace Operand {
462
463 namespace CompilationUnit {
464 enum {
465 SPIRVDebugInfoVersionIdx = 0,
466 DWARFVersionIdx = 1,
467 SourceIdx = 2,
468 LanguageIdx = 3,
469 OperandCount = 4
470 };
471 }
472
473 namespace Source {
474 enum {
475 FileIdx = 0,
476 TextIdx = 1,
477 OperandCount = 2
478 };
479 }
480
481 namespace TypeBasic {
482 enum {
483 NameIdx = 0,
484 SizeIdx = 1,
485 EncodingIdx = 2,
486 OperandCount = 3
487 };
488 }
489
490 namespace TypePointer {
491 enum {
492 BaseTypeIdx = 0,
493 StorageClassIdx = 1,
494 FlagsIdx = 2,
495 OperandCount = 3
496 };
497 }
498
499 namespace TypeQualifier {
500 enum {
501 BaseTypeIdx = 0,
502 QualifierIdx = 1,
503 OperandCount = 2
504 };
505 }
506
507 namespace TypeArray {
508 enum {
509 BaseTypeIdx = 0,
510 ComponentCountIdx = 1,
511 MinOperandCount = 2
512 };
513 }
514
515 namespace TypeVector = TypeArray;
516
517 namespace Typedef {
518 enum {
519 NameIdx = 0,
520 BaseTypeIdx = 1,
521 SourceIdx = 2,
522 LineIdx = 3,
523 ColumnIdx = 4,
524 ParentIdx = 5,
525 OperandCount = 6
526 };
527 }
528
529 namespace TypeFunction {
530 enum {
531 FlagsIdx = 0,
532 ReturnTypeIdx = 1,
533 FirstParameterIdx = 2,
534 MinOperandCount = 2
535 };
536 }
537
538 namespace TypeEnum {
539 enum {
540 NameIdx = 0,
541 UnderlyingTypeIdx = 1,
542 SourceIdx = 2,
543 LineIdx = 3,
544 ColumnIdx = 4,
545 ParentIdx = 5,
546 SizeIdx = 6,
547 FlagsIdx = 7,
548 FirstEnumeratorIdx = 8,
549 MinOperandCount = 8
550 };
551 }
552
553 namespace TypeComposite {
554 enum {
555 NameIdx = 0,
556 TagIdx = 1,
557 SourceIdx = 2,
558 LineIdx = 3,
559 ColumnIdx = 4,
560 ParentIdx = 5,
561 LinkageNameIdx = 6,
562 SizeIdx = 7,
563 FlagsIdx = 8,
564 FirstMemberIdx = 9,
565 MinOperandCount = 9
566 };
567 }
568
569 namespace TypeMember {
570 enum {
571 NameIdx = 0,
572 TypeIdx = 1,
573 SourceIdx = 2,
574 LineIdx = 3,
575 ColumnIdx = 4,
576 ParentIdx = 5,
577 OffsetIdx = 6,
578 SizeIdx = 7,
579 FlagsIdx = 8,
580 ValueIdx = 9,
581 MinOperandCount = 9
582 };
583 }
584
585 namespace TypeInheritance {
586 enum {
587 ChildIdx = 0,
588 ParentIdx = 1,
589 OffsetIdx = 2,
590 SizeIdx = 3,
591 FlagsIdx = 4,
592 OperandCount = 5
593 };
594 }
595
596 namespace PtrToMember {
597 enum {
598 MemberTypeIdx = 0,
599 ParentIdx = 1,
600 OperandCount = 2
601 };
602 }
603
604 namespace Template {
605 enum {
606 TargetIdx = 0,
607 FirstParameterIdx = 1,
608 MinOperandCount = 1
609 };
610 }
611
612 namespace TemplateParameter {
613 enum {
614 NameIdx = 0,
615 TypeIdx = 1,
616 ValueIdx = 2,
617 SourceIdx = 3,
618 LineIdx = 4,
619 ColumnIdx = 5,
620 OperandCount = 6
621 };
622 }
623
624 namespace TemplateTemplateParameter {
625 enum {
626 NameIdx = 0,
627 TemplateNameIdx = 1,
628 SourceIdx = 2,
629 LineIdx = 3,
630 ColumnIdx = 4,
631 OperandCount = 4
632 };
633 }
634
635 namespace TemplateParameterPack {
636 enum {
637 NameIdx = 0,
638 SourceIdx = 1,
639 LineIdx = 2,
640 ColumnIdx = 3,
641 FirstParameterIdx = 4,
642 MinOperandCount = 4
643 };
644 }
645
646 namespace GlobalVariable {
647 enum {
648 NameIdx = 0,
649 TypeIdx = 1,
650 SourceIdx = 2,
651 LineIdx = 3,
652 ColumnIdx = 4,
653 ParentIdx = 5,
654 LinkageNameIdx = 6,
655 VariableIdx = 7,
656 FlagsIdx = 8,
657 StaticMemberDeclarationIdx = 9,
658 MinOperandCount = 9
659 };
660 }
661
662 namespace FunctionDeclaration {
663 enum {
664 NameIdx = 0,
665 TypeIdx = 1,
666 SourceIdx = 2,
667 LineIdx = 3,
668 ColumnIdx = 4,
669 ParentIdx = 5,
670 LinkageNameIdx = 6,
671 FlagsIdx = 7,
672 OperandCount = 8
673 };
674 }
675
676 namespace Function {
677 enum {
678 NameIdx = 0,
679 TypeIdx = 1,
680 SourceIdx = 2,
681 LineIdx = 3,
682 ColumnIdx = 4,
683 ParentIdx = 5,
684 LinkageNameIdx = 6,
685 FlagsIdx = 7,
686 ScopeLineIdx = 8,
687 FunctionIdIdx = 9,
688 DeclarationIdx = 10,
689 MinOperandCount = 10
690 };
691 }
692
693 namespace LexicalBlock {
694 enum {
695 SourceIdx = 0,
696 LineIdx = 1,
697 ColumnIdx = 2,
698 ParentIdx = 3,
699 NameIdx = 4,
700 MinOperandCount = 4
701 };
702 }
703
704 namespace LexicalBlockDiscriminator {
705 enum {
706 SourceIdx = 0,
707 DiscriminatorIdx = 1,
708 ParentIdx = 2,
709 OperandCount = 3
710 };
711 }
712
713 namespace Scope {
714 enum {
715 ScopeIdx = 0,
716 InlinedAtIdx = 1,
717 MinOperandCount = 1
718 };
719 }
720
721 namespace NoScope {
722 // No operands
723 }
724
725 namespace InlinedAt {
726 enum {
727 LineIdx = 0,
728 ScopeIdx = 1,
729 InlinedIdx = 2,
730 MinOperandCount = 2
731 };
732 }
733
734 namespace LocalVariable {
735 enum {
736 NameIdx = 0,
737 TypeIdx = 1,
738 SourceIdx = 2,
739 LineIdx = 3,
740 ColumnIdx = 4,
741 ParentIdx = 5,
742 FlagsIdx = 6,
743 ArgNumberIdx = 7,
744 MinOperandCount = 7
745 };
746 }
747
748 namespace InlinedVariable {
749 enum {
750 VariableIdx = 0,
751 InlinedIdx = 1,
752 OperandCount = 2
753 };
754 }
755
756 namespace DebugDeclare {
757 enum {
758 DebugLocalVarIdx = 0,
759 VariableIdx = 1,
760 ExpressionIdx = 2,
761 OperandCount = 3
762 };
763 }
764
765 namespace DebugValue {
766 enum {
767 DebugLocalVarIdx = 0,
768 ValueIdx = 1,
769 ExpressionIdx = 2,
770 FirstIndexOperandIdx = 3,
771 MinOperandCount = 3
772 };
773 }
774
775 namespace Operation {
776 enum {
777 OpCodeIdx = 0
778 };
779 static std::map<ExpressionOpCode, unsigned> OpCountMap{
780 { Deref, 1 },
781 { Plus, 2 },
782 { Minus, 2 },
783 { PlusUconst, 2 },
784 { BitPiece, 3 },
785 { Swap, 1 },
786 { Xderef, 1 },
787 { StackValue, 1 },
788 { Constu, 2 },
789 { Fragment, 3 }
790 };
791 }
792
793 namespace ImportedEntity {
794 enum {
795 NameIdx = 0,
796 TagIdx = 1,
797 SourceIdx = 3,
798 EntityIdx = 4,
799 LineIdx = 5,
800 ColumnIdx = 6,
801 ParentIdx = 7,
802 OperandCount = 8
803 };
804 }
805
806 namespace ModuleINTEL {
807 enum {
808 NameIdx = 0,
809 SourceIdx = 1,
810 LineIdx = 2,
811 ParentIdx = 3,
812 ConfigurationMacrosIdx = 4,
813 IncludePathIdx = 5,
814 APINotesFileIdx = 6,
815 IsDeclIdx = 7,
816 OperandCount = 8
817 };
818 }
819 } // namespace Operand
820 } // namespace SPIRVDebug
821
822 // SPIRV Debug info class containers. These classes are light-weight as they
823 // only help interpret a given SPIRVExtInst during SPIRV->LLVM IR translation.
824 class OpDebugInfoBase
825 {
826 public:
OpDebugInfoBase(SPIRVExtInst * i)827 OpDebugInfoBase(SPIRVExtInst* i)
828 {
829 extInst = i;
830 }
isOpDebugInfo()831 bool isOpDebugInfo() { return true; }
832
833 protected:
834 SPIRVExtInst* extInst = nullptr;
835 template <typename T>
arg(unsigned int id)836 T arg(unsigned int id)
837 {
838 return static_cast<T>(extInst->getArguments()[id]);
839 }
str(SPIRVId id)840 SPIRVString* str(SPIRVId id)
841 {
842 auto item = extInst->getModule()->getEntry(arg<SPIRVId>(id));
843 if (item->isString())
844 return static_cast<SPIRVString*>(item);
845 else
846 return nullptr;
847 }
const_val(SPIRVId id)848 uint64_t const_val(SPIRVId id)
849 {
850 auto item = extInst->getModule()->getEntry(arg<SPIRVId>(id));
851 if (item->isConstant())
852 return static_cast<SPIRVConstant*>(item)->getZExtIntValue();
853 else
854 return (uint64_t)-1;
855 }
getNumArgs()856 unsigned int getNumArgs() { return extInst->getArguments().size(); }
857 };
858
859 class OpCompilationUnit : OpDebugInfoBase
860 {
861 public:
OpCompilationUnit(SPIRVExtInst * extInst)862 OpCompilationUnit(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getSPIRVDIVersion()863 SPIRVWord getSPIRVDIVersion() { return arg<SPIRVWord>(SPIRVDebug::Operand::CompilationUnit::SPIRVDebugInfoVersionIdx); }
getDWARFVersion()864 SPIRVWord getDWARFVersion() { return arg<SPIRVWord>(SPIRVDebug::Operand::CompilationUnit::DWARFVersionIdx); }
getSource()865 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::CompilationUnit::SourceIdx); }
getLang()866 SPIRVWord getLang() { return arg<SPIRVWord>(SPIRVDebug::Operand::CompilationUnit::LanguageIdx); }
867 };
868
869 class OpDebugLexicalBlock : OpDebugInfoBase
870 {
871 public:
OpDebugLexicalBlock(SPIRVExtInst * extInst)872 OpDebugLexicalBlock(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getResultId()873 SPIRVId getResultId() { return extInst->getId(); }
getSource()874 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::LexicalBlock::SourceIdx); }
getLine()875 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::LexicalBlock::LineIdx); }
getColumn()876 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::LexicalBlock::ColumnIdx); }
getParent()877 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::LexicalBlock::ParentIdx); }
hasNameSpace()878 const bool hasNameSpace() { return getNumArgs() > SPIRVDebug::Operand::LexicalBlock::MinOperandCount; }
getNameSpace()879 SPIRVString* getNameSpace() { return str(SPIRVDebug::Operand::LexicalBlock::NameIdx); }
880 };
881
882 class OpDebugSubprogram : OpDebugInfoBase
883 {
884 public:
OpDebugSubprogram(SPIRVExtInst * extInst)885 OpDebugSubprogram(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()886 SPIRVString* getName() { return str(SPIRVDebug::Operand::Function::NameIdx); }
getType()887 SPIRVId getType() { return arg<SPIRVId>(SPIRVDebug::Operand::Function::TypeIdx); }
getSource()888 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::Function::SourceIdx); }
getLine()889 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::Function::LineIdx); }
getColumn()890 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::Function::ColumnIdx); }
getParent()891 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::Function::ParentIdx); }
getLinkage()892 SPIRVString* getLinkage() { return str(SPIRVDebug::Operand::Function::LinkageNameIdx); }
getFlags()893 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::Function::FlagsIdx); }
getScopeLine()894 SPIRVWord getScopeLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::Function::ScopeLineIdx); }
getSPIRVFunction()895 SPIRVId getSPIRVFunction() { return arg<SPIRVId>(SPIRVDebug::Operand::Function::FunctionIdIdx); }
hasDeclaration()896 bool hasDeclaration() { return getNumArgs() > SPIRVDebug::Operand::Function::DeclarationIdx; }
getDecl()897 SPIRVId getDecl() { return arg<SPIRVId>(SPIRVDebug::Operand::Function::DeclarationIdx); }
898 };
899
900 class OpDebugSubroutineType : OpDebugInfoBase
901 {
902 public:
OpDebugSubroutineType(SPIRVExtInst * extInst)903 OpDebugSubroutineType(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getFlags()904 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeFunction::FlagsIdx); }
getReturnType()905 SPIRVId getReturnType() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeFunction::ReturnTypeIdx); }
getNumParms()906 unsigned int getNumParms() { return getNumArgs() - SPIRVDebug::Operand::TypeFunction::FirstParameterIdx; }
getParmType(unsigned int i)907 SPIRVId getParmType(unsigned int i) { return arg<SPIRVId>(i + SPIRVDebug::Operand::TypeFunction::FirstParameterIdx); }
908 };
909
910 class OpDebugDeclare : OpDebugInfoBase
911 {
912 public:
OpDebugDeclare(SPIRVExtInst * extInst)913 OpDebugDeclare(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getResultId()914 SPIRVId getResultId() { return extInst->getId(); }
getVar()915 SPIRVId getVar() { return arg<SPIRVId>(SPIRVDebug::Operand::DebugDeclare::DebugLocalVarIdx); }
getLocalVar()916 SPIRVId getLocalVar() { return arg<SPIRVId>(SPIRVDebug::Operand::DebugDeclare::VariableIdx); }
getExpression()917 SPIRVId getExpression() { return arg<SPIRVId>(SPIRVDebug::Operand::DebugDeclare::ExpressionIdx); }
918 };
919
920 class OpDebugValue : OpDebugInfoBase
921 {
922 public:
OpDebugValue(SPIRVExtInst * extInst)923 OpDebugValue(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getResultId()924 SPIRVId getResultId() { return extInst->getId(); }
getVar()925 SPIRVId getVar() { return arg<SPIRVId>(SPIRVDebug::Operand::DebugValue::DebugLocalVarIdx); }
getValueVar()926 SPIRVId getValueVar() { return arg<SPIRVId>(SPIRVDebug::Operand::DebugValue::ValueIdx); }
getExpression()927 SPIRVId getExpression() { return arg<SPIRVId>(SPIRVDebug::Operand::DebugValue::ExpressionIdx); }
getIndex(unsigned int i)928 SPIRVId getIndex(unsigned int i) { return arg<SPIRVId>(SPIRVDebug::Operand::DebugValue::FirstIndexOperandIdx + i); }
929 };
930
931 class OpDebugLocalVar : OpDebugInfoBase
932 {
933 public:
isParamVar()934 bool isParamVar() { return getNumArgs() > SPIRVDebug::Operand::LocalVariable::ArgNumberIdx; }
OpDebugLocalVar(SPIRVExtInst * extInst)935 OpDebugLocalVar(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getResultId()936 SPIRVId getResultId() { return extInst->getId(); }
getName()937 SPIRVId getName() { return arg<SPIRVId>(SPIRVDebug::Operand::LocalVariable::NameIdx); }
getType()938 SPIRVId getType() { return arg<SPIRVId>(SPIRVDebug::Operand::LocalVariable::TypeIdx); }
getSource()939 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::LocalVariable::SourceIdx); }
getLine()940 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::LocalVariable::LineIdx); }
getCol()941 SPIRVWord getCol() { return arg<SPIRVWord>(SPIRVDebug::Operand::LocalVariable::ColumnIdx); }
getParent()942 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::LocalVariable::ParentIdx); }
getFlags()943 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::LocalVariable::FlagsIdx); }
getArgNo()944 SPIRVWord getArgNo() { return arg<SPIRVWord>(SPIRVDebug::Operand::LocalVariable::ArgNumberIdx); }
945 };
946
947 class OpDebugInlinedLocalVar : OpDebugInfoBase
948 {
949 public:
OpDebugInlinedLocalVar(SPIRVExtInst * extInst)950 OpDebugInlinedLocalVar(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getVar()951 SPIRVId getVar() { return arg<SPIRVId>(SPIRVDebug::Operand::InlinedVariable::VariableIdx); }
getInlinedAt()952 SPIRVId getInlinedAt() { return arg<SPIRVId>(SPIRVDebug::Operand::InlinedVariable::InlinedIdx); }
953 };
954
955 class OpDebugTypeBasic : OpDebugInfoBase
956 {
957 public:
OpDebugTypeBasic(SPIRVExtInst * extInst)958 OpDebugTypeBasic(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()959 SPIRVString* getName() { return str(SPIRVDebug::Operand::TypeBasic::NameIdx); }
getSize()960 uint64_t getSize() { return const_val(SPIRVDebug::Operand::TypeBasic::SizeIdx); }
getEncoding()961 SPIRVDebug::EncodingTag getEncoding() { return arg<SPIRVDebug::EncodingTag>(SPIRVDebug::Operand::TypeBasic::EncodingIdx); }
962 };
963
964 class OpDebugPtrType : OpDebugInfoBase
965 {
966 public:
OpDebugPtrType(SPIRVExtInst * extInst)967 OpDebugPtrType(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getBaseType()968 SPIRVId getBaseType() { return arg<SPIRVId>(SPIRVDebug::Operand::TypePointer::BaseTypeIdx); }
getStorageClass()969 SPIRVWord getStorageClass() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypePointer::StorageClassIdx); }
getFlags()970 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypePointer::FlagsIdx); }
971 };
972
973 class OpDebugTypeQualifier : OpDebugInfoBase
974 {
975 public:
OpDebugTypeQualifier(SPIRVExtInst * extInst)976 OpDebugTypeQualifier(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getBaseType()977 SPIRVId getBaseType() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeQualifier::BaseTypeIdx); }
978 enum TypeQualifier
979 {
980 qual_const = 0,
981 qual_volatile = 1,
982 qual_restrict = 2
983 };
getQualifier()984 TypeQualifier getQualifier() { return arg<TypeQualifier>(SPIRVDebug::Operand::TypeQualifier::QualifierIdx); }
985 };
986
987 class OpDebugTypeArray : OpDebugInfoBase
988 {
989 public:
OpDebugTypeArray(SPIRVExtInst * extInst)990 OpDebugTypeArray(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getBaseType()991 SPIRVId getBaseType() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeArray::BaseTypeIdx); }
getNumDims()992 SPIRVWord getNumDims() { return (getNumArgs() - SPIRVDebug::Operand::TypeArray::ComponentCountIdx); }
getComponentCount(unsigned int i)993 SPIRVId getComponentCount(unsigned int i) { return arg<SPIRVId>(i + SPIRVDebug::Operand::TypeArray::ComponentCountIdx); }
994 };
995
996 class OpDebugTypeVector : OpDebugInfoBase
997 {
998 public:
OpDebugTypeVector(SPIRVExtInst * extInst)999 OpDebugTypeVector(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getBaseType()1000 SPIRVId getBaseType() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeVector::BaseTypeIdx); }
getNumComponents()1001 SPIRVWord getNumComponents() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeVector::ComponentCountIdx); }
1002 };
1003
1004 class OpDebugTypeDef : OpDebugInfoBase
1005 {
1006 public:
OpDebugTypeDef(SPIRVExtInst * extInst)1007 OpDebugTypeDef(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1008 SPIRVString* getName() { return str(SPIRVDebug::Operand::Typedef::NameIdx); }
getBaseType()1009 SPIRVId getBaseType() { return arg<SPIRVId>(SPIRVDebug::Operand::Typedef::BaseTypeIdx); }
getSource()1010 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::Typedef::SourceIdx); }
getLine()1011 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::Typedef::LineIdx); }
getColumn()1012 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::Typedef::ColumnIdx); }
getParent()1013 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::Typedef::ParentIdx); }
1014 };
1015
1016 class OpDebugTypeEnum : OpDebugInfoBase
1017 {
1018 public:
OpDebugTypeEnum(SPIRVExtInst * extInst)1019 OpDebugTypeEnum(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1020 SPIRVString* getName() { return str(SPIRVDebug::Operand::TypeEnum::NameIdx); }
getType()1021 SPIRVId getType() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeEnum::UnderlyingTypeIdx); }
getSource()1022 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeEnum::SourceIdx); }
getLine()1023 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeEnum::LineIdx); }
getColumn()1024 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeEnum::ColumnIdx); }
getParent()1025 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeEnum::ParentIdx); }
getSize()1026 uint64_t getSize() { return const_val(SPIRVDebug::Operand::TypeEnum::SizeIdx); }
getFlags()1027 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeEnum::FlagsIdx); }
getItem(unsigned int idx)1028 std::pair<SPIRVString*, uint64_t> getItem(unsigned int idx)
1029 {
1030 return std::make_pair(str((idx * 2) + SPIRVDebug::Operand::TypeEnum::FirstEnumeratorIdx+1),
1031 const_val((idx * 2) + SPIRVDebug::Operand::TypeEnum::FirstEnumeratorIdx));
1032 }
getNumItems()1033 unsigned int getNumItems() { return (getNumArgs() - SPIRVDebug::Operand::TypeEnum::FirstEnumeratorIdx)/2; }
1034 };
1035
1036 class OpDebugTypeComposite : OpDebugInfoBase
1037 {
1038 public:
OpDebugTypeComposite(SPIRVExtInst * extInst)1039 OpDebugTypeComposite(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1040 SPIRVString* getName() { return str(SPIRVDebug::Operand::TypeComposite::NameIdx); }
getTag()1041 SPIRVWord getTag() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeComposite::TagIdx); }
getSource()1042 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeComposite::SourceIdx); }
getLine()1043 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeComposite::LineIdx); }
getColumn()1044 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeComposite::ColumnIdx); }
getParent()1045 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeComposite::ParentIdx); }
getLinkageName()1046 SPIRVString* getLinkageName() { return str(SPIRVDebug::Operand::TypeComposite::LinkageNameIdx); }
getSize()1047 uint64_t getSize() { return const_val(SPIRVDebug::Operand::TypeComposite::SizeIdx); }
getFlags()1048 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeComposite::FlagsIdx); }
getNumItems()1049 unsigned int getNumItems() { return (getNumArgs() - SPIRVDebug::Operand::TypeComposite::FirstMemberIdx); }
getItem(unsigned int i)1050 SPIRVId getItem(unsigned int i) { return arg<SPIRVId>(i + SPIRVDebug::Operand::TypeComposite::FirstMemberIdx); }
1051 };
1052
1053 class OpDebugTypeMember : OpDebugInfoBase
1054 {
1055 public:
OpDebugTypeMember(SPIRVExtInst * extInst)1056 OpDebugTypeMember(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1057 SPIRVString* getName() { return str(SPIRVDebug::Operand::TypeMember::NameIdx); }
getType()1058 SPIRVId getType() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeMember::TypeIdx); }
getSource()1059 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeMember::SourceIdx); }
getLine()1060 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeMember::LineIdx); }
getColumn()1061 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeMember::ColumnIdx); }
getParent()1062 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeMember::ParentIdx); }
getOffset()1063 uint64_t getOffset() { return const_val(SPIRVDebug::Operand::TypeMember::OffsetIdx); }
getSize()1064 uint64_t getSize() { return const_val(SPIRVDebug::Operand::TypeMember::SizeIdx); }
getFlags()1065 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeMember::FlagsIdx); }
getInitConst()1066 uint64_t getInitConst() { return const_val(SPIRVDebug::Operand::TypeMember::ValueIdx); }
getInitConstId()1067 SPIRVId getInitConstId() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeMember::ValueIdx); }
hasInitConst()1068 bool hasInitConst() { return getNumArgs() > SPIRVDebug::Operand::TypeMember::MinOperandCount; }
1069 };
1070
1071 class OpDebugTypeInheritance : OpDebugInfoBase
1072 {
1073 public:
OpDebugTypeInheritance(SPIRVExtInst * extInst)1074 OpDebugTypeInheritance(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getChild()1075 SPIRVId getChild() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeInheritance::ChildIdx); }
getParent()1076 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::TypeInheritance::ParentIdx); }
getOffset()1077 uint64_t getOffset() { return const_val(SPIRVDebug::Operand::TypeInheritance::OffsetIdx); }
getSize()1078 uint64_t getSize() { return const_val(SPIRVDebug::Operand::TypeInheritance::SizeIdx); }
getFlags()1079 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::TypeInheritance::FlagsIdx); }
1080 };
1081
1082 class OpDebugPtrToMember : OpDebugInfoBase
1083 {
1084 public:
OpDebugPtrToMember(SPIRVExtInst * extInst)1085 OpDebugPtrToMember(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getType()1086 SPIRVId getType() { return arg<SPIRVId>(SPIRVDebug::Operand::PtrToMember::MemberTypeIdx); }
getParent()1087 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::PtrToMember::ParentIdx); }
1088 };
1089
1090 class OpDebugGlobalVar : OpDebugInfoBase
1091 {
1092 public:
OpDebugGlobalVar(SPIRVExtInst * extInst)1093 OpDebugGlobalVar(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1094 SPIRVString* getName() { return str(SPIRVDebug::Operand::GlobalVariable::NameIdx); }
getType()1095 SPIRVId getType() { return arg<SPIRVId>(SPIRVDebug::Operand::GlobalVariable::TypeIdx); }
getSource()1096 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::GlobalVariable::SourceIdx); }
getLine()1097 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::GlobalVariable::LineIdx); }
getColumn()1098 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::GlobalVariable::ColumnIdx); }
getParent()1099 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::GlobalVariable::ParentIdx); }
getLinkageName()1100 SPIRVString* getLinkageName() { return str(SPIRVDebug::Operand::GlobalVariable::LinkageNameIdx); }
getVariable()1101 SPIRVId getVariable() { return arg<SPIRVId>(SPIRVDebug::Operand::GlobalVariable::VariableIdx); }
getFlags()1102 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::GlobalVariable::FlagsIdx); }
hasStaticDecl()1103 bool hasStaticDecl() { return getNumArgs() > SPIRVDebug::Operand::GlobalVariable::MinOperandCount; }
getStaticMemberDecl()1104 SPIRVId getStaticMemberDecl() { return arg<SPIRVId>(SPIRVDebug::Operand::GlobalVariable::StaticMemberDeclarationIdx); }
1105 };
1106
1107 class OpDebugFuncDecl : OpDebugInfoBase
1108 {
1109 public:
OpDebugFuncDecl(SPIRVExtInst * extInst)1110 OpDebugFuncDecl(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1111 SPIRVString* getName() { return str(SPIRVDebug::Operand::FunctionDeclaration::NameIdx); }
getType()1112 SPIRVId getType() { return arg<SPIRVId>(SPIRVDebug::Operand::FunctionDeclaration::TypeIdx); }
getSource()1113 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::FunctionDeclaration::SourceIdx); }
getLine()1114 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::FunctionDeclaration::LineIdx); }
getColumn()1115 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::FunctionDeclaration::ColumnIdx); }
getParent()1116 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::FunctionDeclaration::ParentIdx); }
getLinkageName()1117 SPIRVString* getLinkageName() { return str(SPIRVDebug::Operand::FunctionDeclaration::LinkageNameIdx); }
getFlags()1118 SPIRVWord getFlags() { return arg<SPIRVWord>(SPIRVDebug::Operand::FunctionDeclaration::FlagsIdx); }
1119 };
1120
1121 class OpDebugLexicalBlkDiscriminator : OpDebugInfoBase
1122 {
1123 public:
OpDebugLexicalBlkDiscriminator(SPIRVExtInst * extInst)1124 OpDebugLexicalBlkDiscriminator(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getSource()1125 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::LexicalBlockDiscriminator::SourceIdx); }
getDiscriminator()1126 SPIRVWord getDiscriminator() { return arg<SPIRVWord>(SPIRVDebug::Operand::LexicalBlockDiscriminator::DiscriminatorIdx); }
getParent()1127 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::LexicalBlockDiscriminator::ParentIdx); }
1128 };
1129
1130 class OpDebugScope : OpDebugInfoBase
1131 {
1132 public:
OpDebugScope(SPIRVExtInst * extInst)1133 OpDebugScope(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getScope()1134 SPIRVId getScope() { return arg<SPIRVId>(SPIRVDebug::Operand::Scope::ScopeIdx); }
hasInlinedAt()1135 bool hasInlinedAt() { return getNumArgs() > SPIRVDebug::Operand::Scope::MinOperandCount; }
getInlinedAt()1136 SPIRVId getInlinedAt() { return arg<SPIRVId>(SPIRVDebug::Operand::Scope::InlinedAtIdx); }
1137 };
1138
1139 class OpDebugSource : OpDebugInfoBase
1140 {
1141 public:
OpDebugSource(SPIRVExtInst * extInst)1142 OpDebugSource(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getFileStr()1143 SPIRVString* getFileStr() { return str(SPIRVDebug::Operand::Source::FileIdx); }
1144 };
1145
1146 class OpDebugInlinedAt : OpDebugInfoBase
1147 {
1148 public:
OpDebugInlinedAt(SPIRVExtInst * extInst)1149 OpDebugInlinedAt(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getLine()1150 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::InlinedAt::LineIdx); }
getScope()1151 SPIRVId getScope() { return arg<SPIRVId>(SPIRVDebug::Operand::InlinedAt::ScopeIdx); }
inlinedAtPresent()1152 bool inlinedAtPresent() { return getNumArgs() > SPIRVDebug::Operand::InlinedAt::MinOperandCount; }
getInlinedAt()1153 SPIRVId getInlinedAt() { return arg<SPIRVId>(SPIRVDebug::Operand::InlinedAt::InlinedIdx); }
1154 };
1155
1156 class OpDebugTypeTemplate : OpDebugInfoBase
1157 {
1158 public:
OpDebugTypeTemplate(SPIRVExtInst * extInst)1159 OpDebugTypeTemplate(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getTarget()1160 SPIRVId getTarget() { return arg<SPIRVId>(SPIRVDebug::Operand::Template::TargetIdx); }
getParm(unsigned int i)1161 SPIRVId getParm(unsigned int i) { return arg<SPIRVId>(i+SPIRVDebug::Operand::Template::FirstParameterIdx); }
getNumParms()1162 unsigned int getNumParms() { return (getNumArgs() - SPIRVDebug::Operand::Template::FirstParameterIdx); }
1163 };
1164
1165 class OpDebugTypeTemplateParm : OpDebugInfoBase
1166 {
1167 public:
OpDebugTypeTemplateParm(SPIRVExtInst * extInst)1168 OpDebugTypeTemplateParm(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1169 SPIRVString* getName() { return str(SPIRVDebug::Operand::TemplateParameter::NameIdx); }
getActualType()1170 SPIRVId getActualType() { return arg<SPIRVId>(SPIRVDebug::Operand::TemplateParameter::TypeIdx); }
hasValue()1171 bool hasValue() { return const_val(SPIRVDebug::Operand::TemplateParameter::ValueIdx) != (uint64_t)-1; }
getValue()1172 uint64_t getValue() { return const_val(SPIRVDebug::Operand::TemplateParameter::ValueIdx); }
getSource()1173 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::TemplateParameter::SourceIdx); }
getLine()1174 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::TemplateParameter::LineIdx); }
getColumn()1175 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::TemplateParameter::ColumnIdx); }
1176 };
1177
1178 class OpDebugTypeTemplateParmPack : OpDebugInfoBase
1179 {
1180 public:
OpDebugTypeTemplateParmPack(SPIRVExtInst * extInst)1181 OpDebugTypeTemplateParmPack(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1182 SPIRVString* getName() { return str(SPIRVDebug::Operand::TemplateParameterPack::NameIdx); }
getSource()1183 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::TemplateParameterPack::SourceIdx); }
getLine()1184 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::TemplateParameterPack::LineIdx); }
getColumn()1185 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::TemplateParameterPack::ColumnIdx); }
getParm(unsigned int i)1186 SPIRVId getParm(unsigned int i) { return arg<SPIRVId>(i + SPIRVDebug::Operand::TemplateParameterPack::FirstParameterIdx); }
getNumParms()1187 unsigned int getNumParms() { return (getNumArgs() - SPIRVDebug::Operand::TemplateParameterPack::FirstParameterIdx); }
1188
1189 };
1190
1191 class OpDebugTypeTemplateTemplateParm : OpDebugInfoBase
1192 {
1193 public:
OpDebugTypeTemplateTemplateParm(SPIRVExtInst * extInst)1194 OpDebugTypeTemplateTemplateParm(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1195 SPIRVString* getName() { return str(SPIRVDebug::Operand::TemplateTemplateParameter::NameIdx); }
getTemplateName()1196 SPIRVString* getTemplateName() { return str(SPIRVDebug::Operand::TemplateTemplateParameter::TemplateNameIdx); }
getSource()1197 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::TemplateTemplateParameter::SourceIdx); }
getLine()1198 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::TemplateTemplateParameter::LineIdx); }
getColumn()1199 SPIRVWord getColumn() { return arg<SPIRVWord>(SPIRVDebug::Operand::TemplateTemplateParameter::ColumnIdx); }
1200 };
1201
1202 class OpDebugExpression : OpDebugInfoBase
1203 {
1204 public:
OpDebugExpression(SPIRVExtInst * extInst)1205 OpDebugExpression(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getOperation(unsigned int idx)1206 SPIRVId getOperation(unsigned int idx) { return arg<SPIRVId>(idx); }
getNumOperations()1207 unsigned int getNumOperations() { return getNumArgs(); }
1208 };
1209
1210 class OpDebugOperation : OpDebugInfoBase
1211 {
1212 public:
OpDebugOperation(SPIRVExtInst * extInst)1213 OpDebugOperation(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getNumLiterals()1214 unsigned int getNumLiterals() { return getNumArgs() - SPIRVDebug::Operand::Operation::OpCodeIdx - 1; }
getLiteral(unsigned int idx)1215 unsigned int getLiteral(unsigned int idx) { return arg<SPIRVWord>(idx + SPIRVDebug::Operand::Operation::OpCodeIdx); }
getOperation()1216 SPIRVWord getOperation() { return arg<SPIRVWord>(SPIRVDebug::Operand::Operation::OpCodeIdx); }
1217 };
1218
1219 class OpDebugModuleINTEL : OpDebugInfoBase
1220 {
1221 public:
OpDebugModuleINTEL(SPIRVExtInst * extInst)1222 OpDebugModuleINTEL(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1223 SPIRVId getName() { return arg<SPIRVId>(SPIRVDebug::Operand::ModuleINTEL::NameIdx); }
getSource()1224 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::ModuleINTEL::SourceIdx); }
getLine()1225 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::ModuleINTEL::LineIdx); }
getParent()1226 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::ModuleINTEL::ParentIdx); }
getConfigurationMacros()1227 SPIRVId getConfigurationMacros() { return arg<SPIRVId>(SPIRVDebug::Operand::ModuleINTEL::ConfigurationMacrosIdx); }
getIncludePath()1228 SPIRVId getIncludePath() { return arg<SPIRVId>(SPIRVDebug::Operand::ModuleINTEL::IncludePathIdx); }
getAPINotesFile()1229 SPIRVId getAPINotesFile() { return arg<SPIRVId>(SPIRVDebug::Operand::ModuleINTEL::APINotesFileIdx); }
getIsDecl()1230 SPIRVWord getIsDecl() { return arg<SPIRVWord>(SPIRVDebug::Operand::ModuleINTEL::IsDeclIdx); }
1231 };
1232
1233 class OpDebugImportedEntity : OpDebugInfoBase
1234 {
1235 public:
OpDebugImportedEntity(SPIRVExtInst * extInst)1236 OpDebugImportedEntity(SPIRVExtInst* extInst) : OpDebugInfoBase(extInst) {}
getName()1237 SPIRVId getName() { return arg<SPIRVId>(SPIRVDebug::Operand::ImportedEntity::NameIdx); }
getTag()1238 SPIRVWord getTag() { return arg<SPIRVId>(SPIRVDebug::Operand::ImportedEntity::TagIdx); }
getSource()1239 SPIRVId getSource() { return arg<SPIRVId>(SPIRVDebug::Operand::ImportedEntity::SourceIdx); }
getEntity()1240 SPIRVWord getEntity() { return arg<SPIRVWord>(SPIRVDebug::Operand::ImportedEntity::EntityIdx); }
getLine()1241 SPIRVWord getLine() { return arg<SPIRVWord>(SPIRVDebug::Operand::ImportedEntity::LineIdx); }
getColumn()1242 SPIRVWord getColumn() { return arg<SPIRVId>(SPIRVDebug::Operand::ImportedEntity::ColumnIdx); }
getParent()1243 SPIRVId getParent() { return arg<SPIRVId>(SPIRVDebug::Operand::ImportedEntity::ParentIdx); }
1244 };
1245 }
1246
1247 using namespace llvm;
1248
convertDWARFSourceLangToSPIRV(dwarf::SourceLanguage DwarfLang)1249 inline igc_spv::SpvSourceLanguage convertDWARFSourceLangToSPIRV(dwarf::SourceLanguage DwarfLang) {
1250 switch (DwarfLang) {
1251 // When updating this function, make sure to also
1252 // update convertSPIRVSourceLangToDWARF()
1253
1254 // LLVM does not yet define DW_LANG_C_plus_plus_17
1255 // case dwarf::SourceLanguage::DW_LANG_C_plus_plus_17:
1256 case dwarf::SourceLanguage::DW_LANG_C_plus_plus_14:
1257 case dwarf::SourceLanguage::DW_LANG_C_plus_plus:
1258 return igc_spv::SpvSourceLanguage::SpvSourceLanguageCPP_for_OpenCL;
1259 case dwarf::SourceLanguage::DW_LANG_C99:
1260 case dwarf::SourceLanguage::DW_LANG_OpenCL:
1261 return igc_spv::SpvSourceLanguage::SpvSourceLanguageOpenCL_C;
1262 default:
1263 return igc_spv::SpvSourceLanguage::SpvSourceLanguageUnknown;
1264 }
1265 }
1266
convertSPIRVSourceLangToDWARF(unsigned SourceLang)1267 inline dwarf::SourceLanguage convertSPIRVSourceLangToDWARF(unsigned SourceLang) {
1268 switch (SourceLang) {
1269 // When updating this function, make sure to also
1270 // update convertDWARFSourceLangToSPIRV()
1271 case igc_spv::SpvSourceLanguage::SpvSourceLanguageOpenCL_CPP:
1272 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_14;
1273 case igc_spv::SpvSourceLanguage::SpvSourceLanguageCPP_for_OpenCL:
1274 // LLVM does not yet define DW_LANG_C_plus_plus_17
1275 // SourceLang = dwarf::SourceLanguage::DW_LANG_C_plus_plus_17;
1276 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_14;
1277 case igc_spv::SpvSourceLanguage::SpvSourceLanguageOpenCL_C:
1278 case igc_spv::SpvSourceLanguage::SpvSourceLanguageESSL:
1279 case igc_spv::SpvSourceLanguage::SpvSourceLanguageGLSL:
1280 case igc_spv::SpvSourceLanguage::SpvSourceLanguageHLSL:
1281 case igc_spv::SpvSourceLanguage::SpvSourceLanguageUnknown:
1282 return dwarf::DW_LANG_OpenCL;
1283 default:
1284 // Workaround on frontends generating SPIR-V out of SpvSourceLanguage scope.
1285 return (dwarf::SourceLanguage)SourceLang;
1286 }
1287 }
1288
1289 #endif
1290