Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/lib/SPIRV/libSPIRV/SPIRV.debug.h

raw
1 #ifndef SPIRV_DEBUG_H
2 #define SPIRV_DEBUG_H
3 #include "SPIRVEnum.h"
4 #include "SPIRVUtil.h"
5 #include "spirv/unified1/spirv.hpp"
6 #include "spirv_internal.hpp"
7 #include "llvm/BinaryFormat/Dwarf.h"
8 #include "llvm/IR/DebugInfoMetadata.h"
9
10 namespace SPIRVDebug {
11
12 const unsigned int DebugInfoVersion = 0x00010000;
13 static const std::string ProducerPrefix = {"Debug info producer: "};
14 static const std::string ChecksumKindPrefx = {"//__CSK_"};
15
16 // clang-format off
17
18 // Need to update hasDbgInstParentScopeIdx each time we add new instruction
19 // with ParentScopeIdx
20 enum Instruction {
21 DebugInfoNone = 0,
22 CompilationUnit = 1,
23 TypeBasic = 2,
24 TypePointer = 3,
25 TypeQualifier = 4,
26 TypeArray = 5,
27 TypeVector = 6,
28 Typedef = 7,
29 TypeFunction = 8,
30 TypeEnum = 9,
31 TypeComposite = 10,
32 TypeMember = 11,
33 TypeInheritance = 12,
34 TypePtrToMember = 13,
35 TypeTemplate = 14,
36 TypeTemplateParameter = 15,
37 TypeTemplateParameterPack = 16,
38 TypeTemplateTemplateParameter = 17,
39 GlobalVariable = 18,
40 FunctionDeclaration = 19,
41 Function = 20,
42 LexicalBlock = 21,
43 LexicalBlockDiscriminator = 22,
44 Scope = 23,
45 NoScope = 24,
46 InlinedAt = 25,
47 LocalVariable = 26,
48 InlinedVariable = 27,
49 Declare = 28,
50 Value = 29,
51 Operation = 30,
52 Expression = 31,
53 MacroDef = 32,
54 MacroUndef = 33,
55 ImportedEntity = 34,
56 Source = 35,
57 ModuleINTEL = 36,
58 InstCount = 37,
59 FunctionDefinition = 101,
60 SourceContinued = 102,
61 DebugLine = 103,
62 DebugNoLine = 104,
63 BuildIdentifier = 105,
64 StoragePath = 106,
65 EntryPoint = 107,
66 Module = 200,
67 TypeSubrange = 201,
68 TypeArrayDynamic = 202,
69 TypeString = 203
70 };
71
72 enum Flag {
73 FlagIsProtected = 1 << 0,
74 FlagIsPrivate = 1 << 1,
75 FlagIsPublic = FlagIsPrivate | FlagIsProtected,
76 FlagAccess = FlagIsPublic,
77 FlagIsLocal = 1 << 2,
78 FlagIsDefinition = 1 << 3,
79 FlagIsFwdDecl = 1 << 4,
80 FlagIsArtificial = 1 << 5,
81 FlagIsExplicit = 1 << 6,
82 FlagIsPrototyped = 1 << 7,
83 FlagIsObjectPointer = 1 << 8,
84 FlagIsStaticMember = 1 << 9,
85 FlagIsIndirectVariable = 1 << 10,
86 FlagIsLValueReference = 1 << 11,
87 FlagIsRValueReference = 1 << 12,
88 FlagIsOptimized = 1 << 13,
89 FlagIsEnumClass = 1 << 14,
90 FlagTypePassByValue = 1 << 15,
91 FlagTypePassByReference = 1 << 16,
92 FlagUnknownPhysicalLayout = 1 << 17,
93 FlagBitField = 1 << 18
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 Complex = 8
106 };
107
108 enum CompositeTypeTag {
109 Class = 0,
110 Structure = 1,
111 Union = 2
112 };
113
114 enum TypeQualifierTag {
115 ConstType = 0,
116 VolatileType = 1,
117 RestrictType = 2,
118 AtomicType = 3
119 };
120
121 enum ExpressionOpCode {
122 Deref = 0,
123 Plus = 1,
124 Minus = 2,
125 PlusUconst = 3,
126 BitPiece = 4,
127 Swap = 5,
128 Xderef = 6,
129 StackValue = 7,
130 Constu = 8,
131 Fragment = 9,
132 Convert = 10,
133 Addr = 11,
134 Const1u = 12,
135 Const1s = 13,
136 Const2u = 14,
137 Const2s = 15,
138 Const4u = 16,
139 Const4s = 17,
140 Const8u = 18,
141 Const8s = 19,
142 Consts = 20,
143 Dup = 21,
144 Drop = 22,
145 Over = 23,
146 Pick = 24,
147 Rot = 25,
148 Abs = 26,
149 And = 27,
150 Div = 28,
151 Mod = 29,
152 Mul = 30,
153 Neg = 31,
154 Not = 32,
155 Or = 33,
156 Shl = 34,
157 Shr = 35,
158 Shra = 36,
159 Xor = 37,
160 Bra = 38,
161 Eq = 39,
162 Ge = 40,
163 Gt = 41,
164 Le = 42,
165 Lt = 43,
166 Ne = 44,
167 Skip = 45,
168 Lit0 = 46,
169 Lit1 = 47,
170 Lit2 = 48,
171 Lit3 = 49,
172 Lit4 = 50,
173 Lit5 = 51,
174 Lit6 = 52,
175 Lit7 = 53,
176 Lit8 = 54,
177 Lit9 = 55,
178 Lit10 = 56,
179 Lit11 = 57,
180 Lit12 = 58,
181 Lit13 = 59,
182 Lit14 = 60,
183 Lit15 = 61,
184 Lit16 = 62,
185 Lit17 = 63,
186 Lit18 = 64,
187 Lit19 = 65,
188 Lit20 = 66,
189 Lit21 = 67,
190 Lit22 = 68,
191 Lit23 = 69,
192 Lit24 = 70,
193 Lit25 = 71,
194 Lit26 = 72,
195 Lit27 = 73,
196 Lit28 = 74,
197 Lit29 = 75,
198 Lit30 = 76,
199 Lit31 = 77,
200 Reg0 = 78,
201 Reg1 = 79,
202 Reg2 = 80,
203 Reg3 = 81,
204 Reg4 = 82,
205 Reg5 = 83,
206 Reg6 = 84,
207 Reg7 = 85,
208 Reg8 = 86,
209 Reg9 = 87,
210 Reg10 = 88,
211 Reg11 = 89,
212 Reg12 = 90,
213 Reg13 = 91,
214 Reg14 = 92,
215 Reg15 = 93,
216 Reg16 = 94,
217 Reg17 = 95,
218 Reg18 = 96,
219 Reg19 = 97,
220 Reg20 = 98,
221 Reg21 = 99,
222 Reg22 = 100,
223 Reg23 = 101,
224 Reg24 = 102,
225 Reg25 = 103,
226 Reg26 = 104,
227 Reg27 = 105,
228 Reg28 = 106,
229 Reg29 = 107,
230 Reg30 = 108,
231 Reg31 = 109,
232 Breg0 = 110,
233 Breg1 = 111,
234 Breg2 = 112,
235 Breg3 = 113,
236 Breg4 = 114,
237 Breg5 = 115,
238 Breg6 = 116,
239 Breg7 = 117,
240 Breg8 = 118,
241 Breg9 = 119,
242 Breg10 = 120,
243 Breg11 = 121,
244 Breg12 = 122,
245 Breg13 = 123,
246 Breg14 = 124,
247 Breg15 = 125,
248 Breg16 = 126,
249 Breg17 = 127,
250 Breg18 = 128,
251 Breg19 = 129,
252 Breg20 = 130,
253 Breg21 = 131,
254 Breg22 = 132,
255 Breg23 = 133,
256 Breg24 = 134,
257 Breg25 = 135,
258 Breg26 = 136,
259 Breg27 = 137,
260 Breg28 = 138,
261 Breg29 = 139,
262 Breg30 = 140,
263 Breg31 = 141,
264 Regx = 142,
265 Fbreg = 143,
266 Bregx = 144,
267 Piece = 145,
268 DerefSize = 146,
269 XderefSize = 147,
270 Nop = 148,
271 PushObjectAddress = 149,
272 Call2 = 150,
273 Call4 = 151,
274 CallRef = 152,
275 FormTlsAddress = 153,
276 CallFrameCfa = 154,
277 ImplicitValue = 155,
278 ImplicitPointer = 156,
279 Addrx = 157,
280 Constx = 158,
281 EntryValue = 159,
282 ConstTypeOp = 160,
283 RegvalType = 161,
284 DerefType = 162,
285 XderefType = 163,
286 Reinterpret = 164,
287 LLVMArg = 165,
288 ImplicitPointerTag = 166,
289 TagOffset = 167,
290 };
291
292 enum ImportedEntityTag {
293 ImportedModule = 0,
294 ImportedDeclaration = 1,
295 };
296
297 enum FileChecksumKind {
298 MD5 = 0,
299 SHA1 = 1,
300 SHA256 = 2,
301 };
302
303 namespace Operand {
304
305 namespace CompilationUnit {
306 enum {
307 SPIRVDebugInfoVersionIdx = 0,
308 DWARFVersionIdx = 1,
309 SourceIdx = 2,
310 LanguageIdx = 3,
311 // For NonSemantic.Shader.DebugInfo.200
312 ProducerIdx = 4,
313 MinOperandCount = 4
314 };
315 }
316
317 namespace Source {
318 enum {
319 FileIdx = 0,
320 TextIdx = 1,
321 // For NonSemantic.Shader.DebugInfo.200
322 ChecksumKind = 1,
323 ChecksumValue = 2,
324 TextNonSemIdx = 3,
325 MinOperandCount = 1,
326 MaxOperandCount = 4
327 };
328 }
329
330 namespace BuildIdentifier {
331 enum {
332 IdentifierIdx = 0,
333 FlagsIdx = 1,
334 OperandCount = 2
335 };
336 }
337
338 namespace StoragePath {
339 enum {
340 PathIdx = 0,
341 OperandCount = 1
342 };
343 }
344
345 namespace TypeBasic {
346 enum {
347 NameIdx = 0,
348 SizeIdx = 1,
349 EncodingIdx = 2,
350 // For NonSemantic Specs
351 FlagsIdx = 3,
352 OperandCountOCL = 3,
353 OperandCountNonSemantic = 4
354 };
355 }
356
357 namespace TypePointer {
358 enum {
359 BaseTypeIdx = 0,
360 StorageClassIdx = 1,
361 FlagsIdx = 2,
362 OperandCount = 3
363 };
364 }
365
366 namespace TypeQualifier {
367 enum {
368 BaseTypeIdx = 0,
369 QualifierIdx = 1,
370 OperandCount = 2
371 };
372 }
373
374 namespace TypeArray {
375 enum {
376 BaseTypeIdx = 0,
377 ComponentCountIdx = 1,
378 SubrangesIdx = 1,
379 MinOperandCount = 2
380 };
381 }
382
383 namespace TypeArrayDynamic {
384 enum {
385 BaseTypeIdx = 0,
386 DataLocationIdx = 1,
387 AssociatedIdx = 2,
388 AllocatedIdx = 3,
389 RankIdx = 4,
390 SubrangesIdx = 5,
391 MinOperandCount = 6
392 };
393 }
394
395 namespace TypeVector = TypeArray;
396
397 namespace TypeSubrange {
398 enum {
399 LowerBoundIdx = 0,
400 UpperBoundIdx = 1,
401 CountIdx = 2,
402 StrideIdx = 3,
403 MinOperandCount = 3,
404 MaxOperandCount = 4
405 };
406 }
407
408 namespace TypeString {
409 enum {
410 NameIdx = 0,
411 BaseTypeIdx = 1,
412 DataLocationIdx = 2,
413 SizeIdx = 3,
414 LengthAddrIdx = 4,
415 LengthSizeIdx = 5,
416 MinOperandCount = 5
417 };
418 }
419
420 namespace Typedef {
421 enum {
422 NameIdx = 0,
423 BaseTypeIdx = 1,
424 SourceIdx = 2,
425 LineIdx = 3,
426 ColumnIdx = 4,
427 ParentIdx = 5,
428 OperandCount = 6
429 };
430 }
431
432 namespace TypeFunction {
433 enum {
434 FlagsIdx = 0,
435 ReturnTypeIdx = 1,
436 FirstParameterIdx = 2,
437 MinOperandCount = 2
438 };
439 }
440
441 namespace TypeEnum {
442 enum {
443 NameIdx = 0,
444 UnderlyingTypeIdx = 1,
445 SourceIdx = 2,
446 LineIdx = 3,
447 ColumnIdx = 4,
448 ParentIdx = 5,
449 SizeIdx = 6,
450 FlagsIdx = 7,
451 FirstEnumeratorIdx = 8,
452 MinOperandCount = 8
453 };
454 }
455
456 namespace TypeComposite {
457 enum {
458 NameIdx = 0,
459 TagIdx = 1,
460 SourceIdx = 2,
461 LineIdx = 3,
462 ColumnIdx = 4,
463 ParentIdx = 5,
464 LinkageNameIdx = 6,
465 SizeIdx = 7,
466 FlagsIdx = 8,
467 FirstMemberIdx = 9,
468 MinOperandCount = 9
469 };
470 }
471
472 namespace TypeMember {
473 namespace OpenCL {
474 enum {
475 NameIdx = 0,
476 TypeIdx = 1,
477 SourceIdx = 2,
478 LineIdx = 3,
479 ColumnIdx = 4,
480 ParentIdx = 5,
481 OffsetIdx = 6,
482 SizeIdx = 7,
483 FlagsIdx = 8,
484 ValueIdx = 9,
485 MinOperandCount = 9
486 };
487 }
488
489 namespace NonSemantic {
490 enum {
491 NameIdx = 0,
492 TypeIdx = 1,
493 SourceIdx = 2,
494 LineIdx = 3,
495 ColumnIdx = 4,
496 OffsetIdx = 5,
497 SizeIdx = 6,
498 FlagsIdx = 7,
499 ValueIdx = 8,
500 MinOperandCount = 8
501 };
502 }
503 } // namespace TypeMember
504
505 namespace TypeInheritance {
506 namespace NonSemantic {
507 enum {
508 ParentIdx = 0,
509 OffsetIdx = 1,
510 SizeIdx = 2,
511 FlagsIdx = 3,
512 OperandCount = 4
513 };
514 }
515
516 namespace OpenCL {
517 enum {
518 ChildIdx = 0,
519 ParentIdx = 1,
520 OffsetIdx = 2,
521 SizeIdx = 3,
522 FlagsIdx = 4,
523 OperandCount = 5
524 };
525 }
526 } // namespace TypeInheritance
527
528 namespace TypePtrToMember {
529 enum {
530 MemberTypeIdx = 0,
531 ParentIdx = 1,
532 OperandCount = 2
533 };
534 }
535
536 namespace TypeTemplate {
537 enum {
538 TargetIdx = 0,
539 FirstParameterIdx = 1,
540 MinOperandCount = 1
541 };
542 }
543
544 namespace TypeTemplateParameter {
545 enum {
546 NameIdx = 0,
547 TypeIdx = 1,
548 ValueIdx = 2,
549 SourceIdx = 3,
550 LineIdx = 4,
551 ColumnIdx = 5,
552 OperandCount = 6
553 };
554 }
555
556 namespace TypeTemplateTemplateParameter {
557 enum {
558 NameIdx = 0,
559 TemplateNameIdx = 1,
560 SourceIdx = 2,
561 LineIdx = 3,
562 ColumnIdx = 4,
563 OperandCount = 5
564 };
565 }
566
567 namespace TypeTemplateParameterPack {
568 enum {
569 NameIdx = 0,
570 SourceIdx = 1,
571 LineIdx = 2,
572 ColumnIdx = 3,
573 FirstParameterIdx = 4,
574 MinOperandCount = 4
575 };
576 }
577
578 namespace GlobalVariable {
579 enum {
580 NameIdx = 0,
581 TypeIdx = 1,
582 SourceIdx = 2,
583 LineIdx = 3,
584 ColumnIdx = 4,
585 ParentIdx = 5,
586 LinkageNameIdx = 6,
587 VariableIdx = 7,
588 FlagsIdx = 8,
589 StaticMemberDeclarationIdx = 9,
590 MinOperandCount = 9
591 };
592 }
593
594 namespace FunctionDeclaration {
595 enum {
596 NameIdx = 0,
597 TypeIdx = 1,
598 SourceIdx = 2,
599 LineIdx = 3,
600 ColumnIdx = 4,
601 ParentIdx = 5,
602 LinkageNameIdx = 6,
603 FlagsIdx = 7,
604 OperandCount = 8
605 };
606 }
607
608 namespace Function {
609 enum {
610 NameIdx = 0,
611 TypeIdx = 1,
612 SourceIdx = 2,
613 LineIdx = 3,
614 ColumnIdx = 4,
615 ParentIdx = 5,
616 LinkageNameIdx = 6,
617 FlagsIdx = 7,
618 ScopeLineIdx = 8,
619 FunctionIdIdx = 9,
620 DeclarationIdx = 10,
621 MinOperandCount = 10,
622
623 // Only for NonSemantic.Shader.DebugInfo.*
624 // No operand FunctionId
625 DeclarationNonSemIdx = 9,
626 MinOperandCountNonSem = 9,
627 // Only for NonSemantic.Shader.DebugInfo.200
628 TargetFunctionNameIdx = 10,
629 };
630 }
631
632 namespace FunctionDefinition {
633 enum {
634 FunctionIdx = 0,
635 DefinitionIdx = 1,
636 OperandCount = 2
637 };
638 }
639
640 namespace SourceContinued {
641 enum {
642 TextIdx = 0,
643 OperandCount = 1
644 };
645 }
646
647 namespace DebugLine {
648 enum {
649 SourceIdx = 0,
650 StartIdx = 1,
651 EndIdx = 2,
652 ColumnStartIdx = 3,
653 ColumnEndIdx = 4,
654 OperandCount = 5
655 };
656 }
657
658 namespace DebugNoLine {
659 enum {
660 OperandCount = 0
661 };
662 }
663
664 namespace EntryPoint {
665 enum {
666 EntryPointIdx = 0,
667 CompilationUnitIdx = 1,
668 CompilerSignatureIdx = 2,
669 CommandLineArgsIdx = 3,
670 OperandCount = 4
671 };
672 }
673
674 namespace LexicalBlock {
675 enum {
676 SourceIdx = 0,
677 LineIdx = 1,
678 ColumnIdx = 2,
679 ParentIdx = 3,
680 MinOperandCount = 4,
681 NameIdx = 4,
682 InlineNamespaceIdx = 5,
683 };
684 }
685
686 namespace LexicalBlockDiscriminator {
687 enum {
688 SourceIdx = 0,
689 DiscriminatorIdx = 1,
690 ParentIdx = 2,
691 OperandCount = 3
692 };
693 }
694
695 namespace Scope {
696 enum {
697 ScopeIdx = 0,
698 InlinedAtIdx = 1,
699 MinOperandCount = 1
700 };
701 }
702
703 namespace NoScope {
704 // No operands
705 }
706
707 namespace InlinedAt {
708 namespace OpenCL {
709 enum {
710 LineIdx = 0,
711 ScopeIdx = 1,
712 InlinedIdx = 2,
713 MinOperandCount = 2
714 };
715 } // namespace OpenCL
716
717 namespace NonSemantic {
718 enum {
719 LineIdx = 0,
720 ColumnIdx = 1,
721 ScopeIdx = 2,
722 InlinedIdx = 3,
723 MinOperandCount = 3
724 };
725 } // namespace NonSemantic
726 } // namespace ImportedEntity
727
728 namespace LocalVariable {
729 enum {
730 NameIdx = 0,
731 TypeIdx = 1,
732 SourceIdx = 2,
733 LineIdx = 3,
734 ColumnIdx = 4,
735 ParentIdx = 5,
736 FlagsIdx = 6,
737 ArgNumberIdx = 7,
738 MinOperandCount = 7
739 };
740 }
741
742 namespace InlinedVariable {
743 enum {
744 VariableIdx = 0,
745 InlinedIdx = 1,
746 OperandCount = 2
747 };
748 }
749
750 namespace DebugDeclare {
751 enum {
752 DebugLocalVarIdx = 0,
753 VariableIdx = 1,
754 ExpressionIdx = 2,
755 OperandCount = 3
756 };
757 }
758
759 namespace DebugValue {
760 enum {
761 DebugLocalVarIdx = 0,
762 ValueIdx = 1,
763 ExpressionIdx = 2,
764 FirstIndexOperandIdx = 3,
765 MinOperandCount = 3
766 };
767 }
768
769 namespace Operation {
770 enum {
771 OpCodeIdx = 0
772 };
773 static std::map<ExpressionOpCode, unsigned> OpCountMap {
774 { Deref, 1 },
775 { Plus, 1 },
776 { Minus, 1 },
777 { PlusUconst, 2 },
778 { BitPiece, 3 },
779 { Swap, 1 },
780 { Xderef, 1 },
781 { StackValue, 1 },
782 { Constu, 2 },
783 { Fragment, 3 },
784 { Convert, 3 },
785 { Addr, 2 },
786 { Const1u, 2 },
787 { Const1s, 2 },
788 { Const2u, 2 },
789 { Const2s, 2 },
790 { Const4u, 2 },
791 { Const4s, 2 },
792 { Const8u, 2 },
793 { Const8s, 2 },
794 { Consts, 2 },
795 { Dup, 1 },
796 { Drop, 1 },
797 { Over, 1 },
798 { Pick, 1 },
799 { Rot, 1 },
800 { Abs, 1 },
801 { And, 1 },
802 { Div, 1 },
803 { Mod, 1 },
804 { Mul, 1 },
805 { Neg, 1 },
806 { Not, 1 },
807 { Or, 1 },
808 { Shl, 1 },
809 { Shr, 1 },
810 { Shra, 1 },
811 { Xor, 1 },
812 { Bra, 2 },
813 { Eq, 1 },
814 { Ge, 1 },
815 { Gt, 1 },
816 { Le, 1 },
817 { Lt, 1 },
818 { Ne, 1 },
819 { Skip, 2 },
820 { Lit0, 1 },
821 { Lit1, 1 },
822 { Lit2, 1 },
823 { Lit3, 1 },
824 { Lit4, 1 },
825 { Lit5, 1 },
826 { Lit6, 1 },
827 { Lit7, 1 },
828 { Lit8, 1 },
829 { Lit9, 1 },
830 { Lit10, 1 },
831 { Lit11, 1 },
832 { Lit12, 1 },
833 { Lit13, 1 },
834 { Lit14, 1 },
835 { Lit15, 1 },
836 { Lit16, 1 },
837 { Lit17, 1 },
838 { Lit18, 1 },
839 { Lit19, 1 },
840 { Lit20, 1 },
841 { Lit21, 1 },
842 { Lit22, 1 },
843 { Lit23, 1 },
844 { Lit24, 1 },
845 { Lit25, 1 },
846 { Lit26, 1 },
847 { Lit27, 1 },
848 { Lit28, 1 },
849 { Lit29, 1 },
850 { Lit30, 1 },
851 { Lit31, 1 },
852 { Reg0, 1 },
853 { Reg1, 1 },
854 { Reg2, 1 },
855 { Reg3, 1 },
856 { Reg4, 1 },
857 { Reg5, 1 },
858 { Reg6, 1 },
859 { Reg7, 1 },
860 { Reg8, 1 },
861 { Reg9, 1 },
862 { Reg10, 1 },
863 { Reg11, 1 },
864 { Reg12, 1 },
865 { Reg13, 1 },
866 { Reg14, 1 },
867 { Reg15, 1 },
868 { Reg16, 1 },
869 { Reg17, 1 },
870 { Reg18, 1 },
871 { Reg19, 1 },
872 { Reg20, 1 },
873 { Reg21, 1 },
874 { Reg22, 1 },
875 { Reg23, 1 },
876 { Reg24, 1 },
877 { Reg25, 1 },
878 { Reg26, 1 },
879 { Reg27, 1 },
880 { Reg28, 1 },
881 { Reg29, 1 },
882 { Reg30, 1 },
883 { Reg31, 1 },
884 { Breg0, 2 },
885 { Breg1, 2 },
886 { Breg2, 2 },
887 { Breg3, 2 },
888 { Breg4, 2 },
889 { Breg5, 2 },
890 { Breg6, 2 },
891 { Breg7, 2 },
892 { Breg8, 2 },
893 { Breg9, 2 },
894 { Breg10, 2 },
895 { Breg11, 2 },
896 { Breg12, 2 },
897 { Breg13, 2 },
898 { Breg14, 2 },
899 { Breg15, 2 },
900 { Breg16, 2 },
901 { Breg17, 2 },
902 { Breg18, 2 },
903 { Breg19, 2 },
904 { Breg20, 2 },
905 { Breg21, 2 },
906 { Breg22, 2 },
907 { Breg23, 2 },
908 { Breg24, 2 },
909 { Breg25, 2 },
910 { Breg26, 2 },
911 { Breg27, 2 },
912 { Breg28, 2 },
913 { Breg29, 2 },
914 { Breg30, 2 },
915 { Breg31, 2 },
916 { Regx, 2 },
917 { Fbreg, 1 },
918 { Bregx, 3 },
919 { Piece, 2 },
920 { DerefSize, 2 },
921 { XderefSize, 2 },
922 { Nop, 1 },
923 { PushObjectAddress, 1 },
924 { Call2, 2 },
925 { Call4, 2 },
926 { CallRef, 2 },
927 { FormTlsAddress, 1 },
928 { CallFrameCfa, 1 },
929 { ImplicitValue, 3 },
930 { ImplicitPointer, 3 },
931 { Addrx, 2 },
932 { Constx, 2 },
933 { EntryValue, 3 },
934 { ConstTypeOp, 4 },
935 { RegvalType, 3 },
936 { DerefType, 3 },
937 { XderefType, 3 },
938 { Reinterpret, 2 },
939 { LLVMArg, 2 },
940 { ImplicitPointerTag, 2 },
941 { TagOffset, 2 },
942 };
943 }
944
945 namespace ImportedEntity {
946 namespace OpenCL {
947 // it's bugged version, note 2nd index is missing
948 // FIXME: need to remove it after some graceful period
949 enum {
950 NameIdx = 0,
951 TagIdx = 1,
952 SourceIdx = 3,
953 EntityIdx = 4,
954 LineIdx = 5,
955 ColumnIdx = 6,
956 ParentIdx = 7,
957 OperandCount = 8
958 };
959 } // namespace OpenCL
960 namespace NonSemantic {
961 enum {
962 NameIdx = 0,
963 TagIdx = 1,
964 SourceIdx = 2,
965 EntityIdx = 3,
966 LineIdx = 4,
967 ColumnIdx = 5,
968 ParentIdx = 6,
969 OperandCount = 7
970 };
971 } // namespace NonSemantic
972 } // namespace ImportedEntity
973
974 namespace ModuleINTEL {
975 enum {
976 NameIdx = 0,
977 SourceIdx = 1,
978 LineIdx = 2,
979 ParentIdx = 3,
980 ConfigMacrosIdx = 4,
981 IncludePathIdx = 5,
982 ApiNotesIdx = 6,
983 IsDeclIdx = 7,
984 OperandCount = 8
985 };
986 }
987
988 // helper function to get parent scope of debug instruction, to be used
989 // to determine with which compile unit the particular instruction relates
990 inline bool hasDbgInstParentScopeIdx(
991 const uint32_t Kind, uint32_t &ParentScopeIdx,
992 const SPIRV::SPIRVExtInstSetKind ExtKind = SPIRV::SPIRVEIS_OpenCL) {
993 switch (Kind) {
994 case SPIRVDebug::Typedef:
995 ParentScopeIdx = Typedef::ParentIdx;
996 return true;
997 case SPIRVDebug::TypeEnum:
998 ParentScopeIdx = TypeEnum::ParentIdx;
999 return true;
1000 case SPIRVDebug::TypeComposite:
1001 ParentScopeIdx = TypeMember::OpenCL::ParentIdx;
1002 return true;
1003 case SPIRVDebug::TypeInheritance:
1004 if (ExtKind == SPIRV::SPIRVEIS_OpenCL_DebugInfo_100)
1005 ParentScopeIdx = TypeInheritance::OpenCL::ParentIdx;
1006 else
1007 ParentScopeIdx = TypeInheritance::NonSemantic::ParentIdx;
1008 return true;
1009 case SPIRVDebug::TypePtrToMember:
1010 ParentScopeIdx = TypePtrToMember::ParentIdx;
1011 return true;
1012 case SPIRVDebug::Function:
1013 ParentScopeIdx = Function::ParentIdx;
1014 return true;
1015 case SPIRVDebug::EntryPoint:
1016 ParentScopeIdx = EntryPoint::CompilationUnitIdx;
1017 return true;
1018 case SPIRVDebug::LexicalBlock:
1019 ParentScopeIdx = LexicalBlock::ParentIdx;
1020 return true;
1021 case SPIRVDebug::LexicalBlockDiscriminator:
1022 ParentScopeIdx = LexicalBlockDiscriminator::ParentIdx;
1023 return true;
1024 case SPIRVDebug::Scope:
1025 ParentScopeIdx = Scope::ScopeIdx;
1026 return true;
1027 case SPIRVDebug::InlinedAt:
1028 if (ExtKind == SPIRV::SPIRVEIS_NonSemantic_Shader_DebugInfo_200)
1029 ParentScopeIdx = InlinedAt::NonSemantic::ScopeIdx;
1030 else
1031 ParentScopeIdx = InlinedAt::OpenCL::ScopeIdx;
1032 return true;
1033 case SPIRVDebug::LocalVariable:
1034 ParentScopeIdx = LocalVariable::ParentIdx;
1035 return true;
1036 case SPIRVDebug::ImportedEntity:
1037 if (ExtKind == SPIRV::SPIRVEIS_OpenCL_DebugInfo_100)
1038 ParentScopeIdx = ImportedEntity::OpenCL::ParentIdx;
1039 else
1040 ParentScopeIdx = ImportedEntity::NonSemantic::ParentIdx;
1041 return true;
1042 case SPIRVDebug::ModuleINTEL:
1043 ParentScopeIdx = ModuleINTEL::ParentIdx;
1044 return true;
1045 case SPIRVDebug::Module:
1046 ParentScopeIdx = ModuleINTEL::ParentIdx;
1047 return true;
1048 default:
1049 return false;
1050 }
1051 }
1052
1053 } // namespace Operand
1054 } // namespace SPIRVDebug
1055
1056 using namespace llvm;
1057
1058 inline spv::SourceLanguage convertDWARFSourceLangToSPIRV(dwarf::SourceLanguage DwarfLang) {
1059 switch (DwarfLang) {
1060 // When updating this function, make sure to also
1061 // update convertSPIRVSourceLangToDWARF()
1062 case dwarf::SourceLanguage::DW_LANG_C_plus_plus_14:
1063 case dwarf::SourceLanguage::DW_LANG_C_plus_plus:
1064 return spv::SourceLanguage::SourceLanguageCPP_for_OpenCL;
1065 case dwarf::SourceLanguage::DW_LANG_C99:
1066 case dwarf::SourceLanguage::DW_LANG_OpenCL:
1067 return spv::SourceLanguage::SourceLanguageOpenCL_C;
1068 default:
1069 return spv::SourceLanguage::SourceLanguageUnknown;
1070 }
1071 }
1072
1073 inline bool isSPIRVSourceLangValid(unsigned SourceLang) {
1074 switch (SourceLang) {
1075 // When updating this function, make sure to also
1076 // update convertSPIRVSourceLangToDWARF()
1077 case spv::SourceLanguage::SourceLanguageOpenCL_CPP:
1078 case spv::SourceLanguage::SourceLanguageCPP_for_OpenCL:
1079 case spv::SourceLanguage::SourceLanguageOpenCL_C:
1080 case spv::SourceLanguage::SourceLanguageESSL:
1081 case spv::SourceLanguage::SourceLanguageGLSL:
1082 case spv::SourceLanguage::SourceLanguageHLSL:
1083 case spv::SourceLanguage::SourceLanguageUnknown:
1084 return true;
1085 default:
1086 return false;
1087 }
1088 }
1089
1090 inline dwarf::SourceLanguage convertSPIRVSourceLangToDWARF(unsigned SourceLang) {
1091 switch (SourceLang) {
1092 // When updating this function, make sure to also
1093 // update convertDWARFSourceLangToSPIRV()
1094 case spv::SourceLanguage::SourceLanguageOpenCL_CPP:
1095 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_14;
1096 case spv::SourceLanguage::SourceLanguageCPP_for_OpenCL:
1097 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_14;
1098 case spv::SourceLanguage::SourceLanguageOpenCL_C:
1099 case spv::SourceLanguage::SourceLanguageESSL:
1100 case spv::SourceLanguage::SourceLanguageGLSL:
1101 case spv::SourceLanguage::SourceLanguageHLSL:
1102 case spv::SourceLanguage::SourceLanguageUnknown:
1103 default:
1104 return dwarf::DW_LANG_OpenCL;
1105 }
1106 }
1107
1108 inline spv::SourceLanguage convertDWARFSourceLangToSPIRVNonSemanticDbgInfo(
1109 dwarf::SourceLanguage DwarfLang) {
1110 switch (DwarfLang) {
1111 // When updating this function, make sure to also
1112 // update convertSPIRVSourceLangToDWARFNonSemanticDbgInfo()
1113 case dwarf::SourceLanguage::DW_LANG_OpenCL:
1114 return spv::SourceLanguage::SourceLanguageOpenCL_C;
1115
1116 case dwarf::SourceLanguage::DW_LANG_C_plus_plus_14:
1117 return spv::internal::SourceLanguageCPP14;
1118 case dwarf::SourceLanguage::DW_LANG_C_plus_plus_11:
1119 return spv::internal::SourceLanguageCPP11;
1120 case dwarf::SourceLanguage::DW_LANG_C_plus_plus_03:
1121 return spv::internal::SourceLanguageCPP03;
1122 case dwarf::SourceLanguage::DW_LANG_C_plus_plus:
1123 return spv::internal::SourceLanguageCPP;
1124
1125 case dwarf::SourceLanguage::DW_LANG_C:
1126 return spv::internal::SourceLanguageC;
1127 case dwarf::SourceLanguage::DW_LANG_C99:
1128 return spv::internal::SourceLanguageC99;
1129 case dwarf::SourceLanguage::DW_LANG_C11:
1130 return spv::internal::SourceLanguageC11;
1131
1132 case dwarf::SourceLanguage::DW_LANG_Python:
1133 return spv::internal::SourceLanguagePython;
1134 case dwarf::SourceLanguage::DW_LANG_Julia:
1135 return spv::internal::SourceLanguageJulia;
1136 case dwarf::SourceLanguage::DW_LANG_Rust:
1137 return spv::internal::SourceLanguageRust;
1138 case dwarf::SourceLanguage::DW_LANG_D:
1139 return spv::internal::SourceLanguageD;
1140
1141 case dwarf::SourceLanguage::DW_LANG_Fortran77:
1142 return spv::internal::SourceLanguageFortran77;
1143 case dwarf::SourceLanguage::DW_LANG_Fortran90:
1144 return spv::internal::SourceLanguageFortran90;
1145 case dwarf::SourceLanguage::DW_LANG_Fortran95:
1146 return spv::internal::SourceLanguageFortran95;
1147 case dwarf::SourceLanguage::DW_LANG_Fortran03:
1148 return spv::internal::SourceLanguageFortran2003;
1149 case dwarf::SourceLanguage::DW_LANG_Fortran08:
1150 return spv::internal::SourceLanguageFortran2008;
1151 default:
1152 return spv::SourceLanguage::SourceLanguageUnknown;
1153 }
1154 }
1155
1156 inline dwarf::SourceLanguage
1157 convertSPIRVSourceLangToDWARFNonSemanticDbgInfo(unsigned SourceLang) {
1158 switch (SourceLang) {
1159 // When updating this function, make sure to also
1160 // update convertDWARFSourceLangToSPIRVNonSemanticDbgInfo()
1161 case spv::SourceLanguage::SourceLanguageOpenCL_CPP:
1162 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_14;
1163 case spv::SourceLanguage::SourceLanguageCPP_for_OpenCL:
1164 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_14;
1165
1166 case spv::internal::SourceLanguageCPP14:
1167 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_14;
1168 case spv::internal::SourceLanguageCPP11:
1169 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_11;
1170 case spv::internal::SourceLanguageCPP03:
1171 return dwarf::SourceLanguage::DW_LANG_C_plus_plus_03;
1172 case spv::internal::SourceLanguageCPP:
1173 return dwarf::SourceLanguage::DW_LANG_C_plus_plus;
1174
1175 case spv::internal::SourceLanguageC:
1176 return dwarf::SourceLanguage::DW_LANG_C;
1177 case spv::internal::SourceLanguageC99:
1178 return dwarf::SourceLanguage::DW_LANG_C99;
1179 case spv::internal::SourceLanguageC11:
1180 return dwarf::SourceLanguage::DW_LANG_C11;
1181
1182 case spv::internal::SourceLanguagePython:
1183 return dwarf::SourceLanguage::DW_LANG_Python;
1184 case spv::internal::SourceLanguageJulia:
1185 return dwarf::SourceLanguage::DW_LANG_Julia;
1186 case spv::internal::SourceLanguageRust:
1187 return dwarf::SourceLanguage::DW_LANG_Rust;
1188 case spv::internal::SourceLanguageD:
1189 return dwarf::SourceLanguage::DW_LANG_D;
1190
1191 case spv::internal::SourceLanguageFortran77:
1192 return dwarf::SourceLanguage::DW_LANG_Fortran77;
1193 case spv::internal::SourceLanguageFortran90:
1194 return dwarf::SourceLanguage::DW_LANG_Fortran90;
1195 case spv::internal::SourceLanguageFortran95:
1196 return dwarf::SourceLanguage::DW_LANG_Fortran95;
1197 case spv::internal::SourceLanguageFortran2003:
1198 return dwarf::SourceLanguage::DW_LANG_Fortran03;
1199 case spv::internal::SourceLanguageFortran2008:
1200 return dwarf::SourceLanguage::DW_LANG_Fortran08;
1201
1202 case spv::SourceLanguage::SourceLanguageOpenCL_C:
1203 case spv::SourceLanguage::SourceLanguageESSL:
1204 case spv::SourceLanguage::SourceLanguageGLSL:
1205 case spv::SourceLanguage::SourceLanguageHLSL:
1206 case spv::SourceLanguage::SourceLanguageUnknown:
1207 default:
1208 return dwarf::DW_LANG_OpenCL;
1209 }
1210 }
1211
1212 namespace SPIRV {
1213 typedef SPIRVMap<dwarf::TypeKind, SPIRVDebug::EncodingTag> DbgEncodingMap;
1214 template <>
1215 inline void DbgEncodingMap::init() {
1216 add(static_cast<dwarf::TypeKind>(0), SPIRVDebug::Unspecified);
1217 add(dwarf::DW_ATE_address, SPIRVDebug::Address);
1218 add(dwarf::DW_ATE_boolean, SPIRVDebug::Boolean);
1219 add(dwarf::DW_ATE_float, SPIRVDebug::Float);
1220 add(dwarf::DW_ATE_signed, SPIRVDebug::Signed);
1221 add(dwarf::DW_ATE_signed_char, SPIRVDebug::SignedChar);
1222 add(dwarf::DW_ATE_unsigned, SPIRVDebug::Unsigned);
1223 add(dwarf::DW_ATE_unsigned_char, SPIRVDebug::UnsignedChar);
1224 add(dwarf::DW_ATE_complex_float, SPIRVDebug::Complex);
1225 }
1226
1227 typedef SPIRVMap<dwarf::Tag, SPIRVDebug::TypeQualifierTag> DbgTypeQulifierMap;
1228 template <>
1229 inline void DbgTypeQulifierMap::init() {
1230 add(dwarf::DW_TAG_const_type, SPIRVDebug::ConstType);
1231 add(dwarf::DW_TAG_volatile_type, SPIRVDebug::VolatileType);
1232 add(dwarf::DW_TAG_restrict_type, SPIRVDebug::RestrictType);
1233 add(dwarf::DW_TAG_atomic_type, SPIRVDebug::AtomicType);
1234 }
1235
1236 typedef SPIRVMap<dwarf::Tag, SPIRVDebug::CompositeTypeTag> DbgCompositeTypeMap;
1237 template <>
1238 inline void DbgCompositeTypeMap::init() {
1239 add(dwarf::DW_TAG_class_type, SPIRVDebug::Class);
1240 add(dwarf::DW_TAG_structure_type, SPIRVDebug::Structure);
1241 add(dwarf::DW_TAG_union_type, SPIRVDebug::Union);
1242 }
1243
1244 typedef SPIRVMap<dwarf::LocationAtom, SPIRVDebug::ExpressionOpCode>
1245 DbgExpressionOpCodeMap;
1246 template <>
1247 inline void DbgExpressionOpCodeMap::init() {
1248 add(dwarf::DW_OP_deref, SPIRVDebug::Deref);
1249 add(dwarf::DW_OP_plus, SPIRVDebug::Plus);
1250 add(dwarf::DW_OP_minus, SPIRVDebug::Minus);
1251 add(dwarf::DW_OP_plus_uconst, SPIRVDebug::PlusUconst);
1252 add(dwarf::DW_OP_bit_piece, SPIRVDebug::BitPiece);
1253 add(dwarf::DW_OP_swap, SPIRVDebug::Swap);
1254 add(dwarf::DW_OP_xderef, SPIRVDebug::Xderef);
1255 add(dwarf::DW_OP_stack_value, SPIRVDebug::StackValue);
1256 add(dwarf::DW_OP_constu, SPIRVDebug::Constu);
1257 add(dwarf::DW_OP_LLVM_fragment, SPIRVDebug::Fragment);
1258 add(dwarf::DW_OP_LLVM_convert, SPIRVDebug::Convert);
1259 add(dwarf::DW_OP_addr, SPIRVDebug::Addr);
1260 add(dwarf::DW_OP_const1u, SPIRVDebug::Const1u);
1261 add(dwarf::DW_OP_const1s, SPIRVDebug::Const1s);
1262 add(dwarf::DW_OP_const2u, SPIRVDebug::Const2u);
1263 add(dwarf::DW_OP_const2s, SPIRVDebug::Const2s);
1264 add(dwarf::DW_OP_const4u, SPIRVDebug::Const4u);
1265 add(dwarf::DW_OP_const4s, SPIRVDebug::Const4s);
1266 add(dwarf::DW_OP_const8u, SPIRVDebug::Const8u);
1267 add(dwarf::DW_OP_const8s, SPIRVDebug::Const8s);
1268 add(dwarf::DW_OP_consts, SPIRVDebug::Consts);
1269 add(dwarf::DW_OP_dup, SPIRVDebug::Dup);
1270 add(dwarf::DW_OP_drop, SPIRVDebug::Drop);
1271 add(dwarf::DW_OP_over, SPIRVDebug::Over);
1272 add(dwarf::DW_OP_pick, SPIRVDebug::Pick);
1273 add(dwarf::DW_OP_rot, SPIRVDebug::Rot);
1274 add(dwarf::DW_OP_abs, SPIRVDebug::Abs);
1275 add(dwarf::DW_OP_and, SPIRVDebug::And);
1276 add(dwarf::DW_OP_div, SPIRVDebug::Div);
1277 add(dwarf::DW_OP_mod, SPIRVDebug::Mod);
1278 add(dwarf::DW_OP_mul, SPIRVDebug::Mul);
1279 add(dwarf::DW_OP_neg, SPIRVDebug::Neg);
1280 add(dwarf::DW_OP_not, SPIRVDebug::Not);
1281 add(dwarf::DW_OP_or, SPIRVDebug::Or);
1282 add(dwarf::DW_OP_shl, SPIRVDebug::Shl);
1283 add(dwarf::DW_OP_shr, SPIRVDebug::Shr);
1284 add(dwarf::DW_OP_shra, SPIRVDebug::Shra);
1285 add(dwarf::DW_OP_xor, SPIRVDebug::Xor);
1286 add(dwarf::DW_OP_bra, SPIRVDebug::Bra);
1287 add(dwarf::DW_OP_eq, SPIRVDebug::Eq);
1288 add(dwarf::DW_OP_ge, SPIRVDebug::Ge);
1289 add(dwarf::DW_OP_gt, SPIRVDebug::Gt);
1290 add(dwarf::DW_OP_le, SPIRVDebug::Le);
1291 add(dwarf::DW_OP_lt, SPIRVDebug::Lt);
1292 add(dwarf::DW_OP_ne, SPIRVDebug::Ne);
1293 add(dwarf::DW_OP_skip, SPIRVDebug::Skip);
1294 add(dwarf::DW_OP_lit0, SPIRVDebug::Lit0);
1295 add(dwarf::DW_OP_lit1, SPIRVDebug::Lit1);
1296 add(dwarf::DW_OP_lit2, SPIRVDebug::Lit2);
1297 add(dwarf::DW_OP_lit3, SPIRVDebug::Lit3);
1298 add(dwarf::DW_OP_lit4, SPIRVDebug::Lit4);
1299 add(dwarf::DW_OP_lit5, SPIRVDebug::Lit5);
1300 add(dwarf::DW_OP_lit6, SPIRVDebug::Lit6);
1301 add(dwarf::DW_OP_lit7, SPIRVDebug::Lit7);
1302 add(dwarf::DW_OP_lit8, SPIRVDebug::Lit8);
1303 add(dwarf::DW_OP_lit9, SPIRVDebug::Lit9);
1304 add(dwarf::DW_OP_lit10, SPIRVDebug::Lit10);
1305 add(dwarf::DW_OP_lit11, SPIRVDebug::Lit11);
1306 add(dwarf::DW_OP_lit12, SPIRVDebug::Lit12);
1307 add(dwarf::DW_OP_lit13, SPIRVDebug::Lit13);
1308 add(dwarf::DW_OP_lit14, SPIRVDebug::Lit14);
1309 add(dwarf::DW_OP_lit15, SPIRVDebug::Lit15);
1310 add(dwarf::DW_OP_lit16, SPIRVDebug::Lit16);
1311 add(dwarf::DW_OP_lit17, SPIRVDebug::Lit17);
1312 add(dwarf::DW_OP_lit18, SPIRVDebug::Lit18);
1313 add(dwarf::DW_OP_lit19, SPIRVDebug::Lit19);
1314 add(dwarf::DW_OP_lit20, SPIRVDebug::Lit20);
1315 add(dwarf::DW_OP_lit21, SPIRVDebug::Lit21);
1316 add(dwarf::DW_OP_lit22, SPIRVDebug::Lit22);
1317 add(dwarf::DW_OP_lit23, SPIRVDebug::Lit23);
1318 add(dwarf::DW_OP_lit24, SPIRVDebug::Lit24);
1319 add(dwarf::DW_OP_lit25, SPIRVDebug::Lit25);
1320 add(dwarf::DW_OP_lit26, SPIRVDebug::Lit26);
1321 add(dwarf::DW_OP_lit27, SPIRVDebug::Lit27);
1322 add(dwarf::DW_OP_lit28, SPIRVDebug::Lit28);
1323 add(dwarf::DW_OP_lit29, SPIRVDebug::Lit29);
1324 add(dwarf::DW_OP_lit30, SPIRVDebug::Lit30);
1325 add(dwarf::DW_OP_lit31, SPIRVDebug::Lit31);
1326 add(dwarf::DW_OP_reg0, SPIRVDebug::Reg0);
1327 add(dwarf::DW_OP_reg1, SPIRVDebug::Reg1);
1328 add(dwarf::DW_OP_reg2, SPIRVDebug::Reg2);
1329 add(dwarf::DW_OP_reg3, SPIRVDebug::Reg3);
1330 add(dwarf::DW_OP_reg4, SPIRVDebug::Reg4);
1331 add(dwarf::DW_OP_reg5, SPIRVDebug::Reg5);
1332 add(dwarf::DW_OP_reg6, SPIRVDebug::Reg6);
1333 add(dwarf::DW_OP_reg7, SPIRVDebug::Reg7);
1334 add(dwarf::DW_OP_reg8, SPIRVDebug::Reg8);
1335 add(dwarf::DW_OP_reg9, SPIRVDebug::Reg9);
1336 add(dwarf::DW_OP_reg10, SPIRVDebug::Reg10);
1337 add(dwarf::DW_OP_reg11, SPIRVDebug::Reg11);
1338 add(dwarf::DW_OP_reg12, SPIRVDebug::Reg12);
1339 add(dwarf::DW_OP_reg13, SPIRVDebug::Reg13);
1340 add(dwarf::DW_OP_reg14, SPIRVDebug::Reg14);
1341 add(dwarf::DW_OP_reg15, SPIRVDebug::Reg15);
1342 add(dwarf::DW_OP_reg16, SPIRVDebug::Reg16);
1343 add(dwarf::DW_OP_reg17, SPIRVDebug::Reg17);
1344 add(dwarf::DW_OP_reg18, SPIRVDebug::Reg18);
1345 add(dwarf::DW_OP_reg19, SPIRVDebug::Reg19);
1346 add(dwarf::DW_OP_reg20, SPIRVDebug::Reg20);
1347 add(dwarf::DW_OP_reg21, SPIRVDebug::Reg21);
1348 add(dwarf::DW_OP_reg22, SPIRVDebug::Reg22);
1349 add(dwarf::DW_OP_reg23, SPIRVDebug::Reg23);
1350 add(dwarf::DW_OP_reg24, SPIRVDebug::Reg24);
1351 add(dwarf::DW_OP_reg25, SPIRVDebug::Reg25);
1352 add(dwarf::DW_OP_reg26, SPIRVDebug::Reg26);
1353 add(dwarf::DW_OP_reg27, SPIRVDebug::Reg27);
1354 add(dwarf::DW_OP_reg28, SPIRVDebug::Reg28);
1355 add(dwarf::DW_OP_reg29, SPIRVDebug::Reg29);
1356 add(dwarf::DW_OP_reg30, SPIRVDebug::Reg30);
1357 add(dwarf::DW_OP_reg31, SPIRVDebug::Reg31);
1358 add(dwarf::DW_OP_breg0, SPIRVDebug::Breg0);
1359 add(dwarf::DW_OP_breg1, SPIRVDebug::Breg1);
1360 add(dwarf::DW_OP_breg2, SPIRVDebug::Breg2);
1361 add(dwarf::DW_OP_breg3, SPIRVDebug::Breg3);
1362 add(dwarf::DW_OP_breg4, SPIRVDebug::Breg4);
1363 add(dwarf::DW_OP_breg5, SPIRVDebug::Breg5);
1364 add(dwarf::DW_OP_breg6, SPIRVDebug::Breg6);
1365 add(dwarf::DW_OP_breg7, SPIRVDebug::Breg7);
1366 add(dwarf::DW_OP_breg8, SPIRVDebug::Breg8);
1367 add(dwarf::DW_OP_breg9, SPIRVDebug::Breg9);
1368 add(dwarf::DW_OP_breg10, SPIRVDebug::Breg10);
1369 add(dwarf::DW_OP_breg11, SPIRVDebug::Breg11);
1370 add(dwarf::DW_OP_breg12, SPIRVDebug::Breg12);
1371 add(dwarf::DW_OP_breg13, SPIRVDebug::Breg13);
1372 add(dwarf::DW_OP_breg14, SPIRVDebug::Breg14);
1373 add(dwarf::DW_OP_breg15, SPIRVDebug::Breg15);
1374 add(dwarf::DW_OP_breg16, SPIRVDebug::Breg16);
1375 add(dwarf::DW_OP_breg17, SPIRVDebug::Breg17);
1376 add(dwarf::DW_OP_breg18, SPIRVDebug::Breg18);
1377 add(dwarf::DW_OP_breg19, SPIRVDebug::Breg19);
1378 add(dwarf::DW_OP_breg20, SPIRVDebug::Breg20);
1379 add(dwarf::DW_OP_breg21, SPIRVDebug::Breg21);
1380 add(dwarf::DW_OP_breg22, SPIRVDebug::Breg22);
1381 add(dwarf::DW_OP_breg23, SPIRVDebug::Breg23);
1382 add(dwarf::DW_OP_breg24, SPIRVDebug::Breg24);
1383 add(dwarf::DW_OP_breg25, SPIRVDebug::Breg25);
1384 add(dwarf::DW_OP_breg26, SPIRVDebug::Breg26);
1385 add(dwarf::DW_OP_breg27, SPIRVDebug::Breg27);
1386 add(dwarf::DW_OP_breg28, SPIRVDebug::Breg28);
1387 add(dwarf::DW_OP_breg29, SPIRVDebug::Breg29);
1388 add(dwarf::DW_OP_breg30, SPIRVDebug::Breg30);
1389 add(dwarf::DW_OP_breg31, SPIRVDebug::Breg31);
1390 add(dwarf::DW_OP_regx, SPIRVDebug::Regx);
1391 add(dwarf::DW_OP_bregx, SPIRVDebug::Bregx);
1392 add(dwarf::DW_OP_piece, SPIRVDebug::Piece);
1393 add(dwarf::DW_OP_deref_size, SPIRVDebug::DerefSize );
1394 add(dwarf::DW_OP_xderef_size, SPIRVDebug::XderefSize );
1395 add(dwarf::DW_OP_nop, SPIRVDebug::Nop);
1396 add(dwarf::DW_OP_push_object_address, SPIRVDebug::PushObjectAddress );
1397
1398
1399 add(dwarf::DW_OP_call2, SPIRVDebug::Call2);
1400 add(dwarf::DW_OP_call4, SPIRVDebug::Call4);
1401 add(dwarf::DW_OP_call_ref, SPIRVDebug::CallRef);
1402 add(dwarf::DW_OP_form_tls_address, SPIRVDebug::FormTlsAddress);
1403 add(dwarf::DW_OP_call_frame_cfa, SPIRVDebug::CallFrameCfa);
1404 add(dwarf::DW_OP_implicit_value, SPIRVDebug::ImplicitValue);
1405 add(dwarf::DW_OP_implicit_pointer, SPIRVDebug::ImplicitPointer);
1406 add(dwarf::DW_OP_addrx, SPIRVDebug::Addrx);
1407 add(dwarf::DW_OP_constx, SPIRVDebug::Constx);
1408 add(dwarf::DW_OP_entry_value, SPIRVDebug::EntryValue);
1409 add(dwarf::DW_OP_const_type, SPIRVDebug::ConstTypeOp);
1410 add(dwarf::DW_OP_regval_type, SPIRVDebug::RegvalType);
1411 add(dwarf::DW_OP_deref_type, SPIRVDebug::DerefType);
1412 add(dwarf::DW_OP_xderef_type, SPIRVDebug::XderefType);
1413 add(dwarf::DW_OP_reinterpret, SPIRVDebug::Reinterpret);
1414 add(dwarf::DW_OP_LLVM_arg, SPIRVDebug::LLVMArg);
1415 add(dwarf::DW_OP_LLVM_implicit_pointer, SPIRVDebug::ImplicitPointerTag);
1416 add(dwarf::DW_OP_LLVM_tag_offset, SPIRVDebug::TagOffset);
1417 }
1418
1419 typedef SPIRVMap<dwarf::Tag, SPIRVDebug::ImportedEntityTag>
1420 DbgImportedEntityMap;
1421 template <>
1422 inline void DbgImportedEntityMap::init() {
1423 add(dwarf::DW_TAG_imported_module, SPIRVDebug::ImportedModule);
1424 add(dwarf::DW_TAG_imported_declaration, SPIRVDebug::ImportedDeclaration);
1425 }
1426
1427 typedef SPIRVMap<llvm::DIFile::ChecksumKind, SPIRVDebug::FileChecksumKind>
1428 DbgChecksumKindMap;
1429 template <>
1430 inline void DbgChecksumKindMap::init() {
1431 add(llvm::DIFile::CSK_MD5, SPIRVDebug::MD5);
1432 add(llvm::DIFile::CSK_SHA1, SPIRVDebug::SHA1);
1433 add(llvm::DIFile::CSK_SHA256, SPIRVDebug::SHA256);
1434 }
1435
1436 } // namespace SPIRV
1437
1438 #endif // SPIRV_DEBUG_H