]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
MFV r315791: ntp 4.2.8p10.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / CodeView / CodeView.h
1 //===- CodeView.h -----------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H
11 #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H
12
13 #include <cinttypes>
14 #include <type_traits>
15
16 namespace llvm {
17 namespace codeview {
18
19 /// Distinguishes individual records in .debug$T section or PDB type stream. The
20 /// documentation and headers talk about this as the "leaf" type.
21 enum class TypeRecordKind : uint16_t {
22 #define TYPE_RECORD(lf_ename, value, name) name = value,
23 #include "TypeRecords.def"
24 };
25
26 /// Duplicate copy of the above enum, but using the official CV names. Useful
27 /// for reference purposes and when dealing with unknown record types.
28 enum TypeLeafKind : uint16_t {
29 #define CV_TYPE(name, val) name = val,
30 #include "TypeRecords.def"
31 };
32
33 /// Distinguishes individual records in the Symbols subsection of a .debug$S
34 /// section. Equivalent to SYM_ENUM_e in cvinfo.h.
35 enum class SymbolRecordKind : uint16_t {
36 #define SYMBOL_RECORD(lf_ename, value, name) name = value,
37 #include "CVSymbolTypes.def"
38 };
39
40 /// Duplicate copy of the above enum, but using the official CV names. Useful
41 /// for reference purposes and when dealing with unknown record types.
42 enum SymbolKind : uint16_t {
43 #define CV_SYMBOL(name, val) name = val,
44 #include "CVSymbolTypes.def"
45 };
46
47 #define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class)                            \
48   inline Class operator|(Class a, Class b) {                                   \
49     return static_cast<Class>(                                                 \
50         static_cast<std::underlying_type<Class>::type>(a) |                    \
51         static_cast<std::underlying_type<Class>::type>(b));                    \
52   }                                                                            \
53   inline Class operator&(Class a, Class b) {                                   \
54     return static_cast<Class>(                                                 \
55         static_cast<std::underlying_type<Class>::type>(a) &                    \
56         static_cast<std::underlying_type<Class>::type>(b));                    \
57   }                                                                            \
58   inline Class operator~(Class a) {                                            \
59     return static_cast<Class>(                                                 \
60         ~static_cast<std::underlying_type<Class>::type>(a));                   \
61   }                                                                            \
62   inline Class &operator|=(Class &a, Class b) {                                \
63     a = a | b;                                                                 \
64     return a;                                                                  \
65   }                                                                            \
66   inline Class &operator&=(Class &a, Class b) {                                \
67     a = a & b;                                                                 \
68     return a;                                                                  \
69   }
70
71 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
72 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
73 enum class CPUType : uint16_t {
74   Intel8080 = 0x0,
75   Intel8086 = 0x1,
76   Intel80286 = 0x2,
77   Intel80386 = 0x3,
78   Intel80486 = 0x4,
79   Pentium = 0x5,
80   PentiumPro = 0x6,
81   Pentium3 = 0x7,
82   MIPS = 0x10,
83   MIPS16 = 0x11,
84   MIPS32 = 0x12,
85   MIPS64 = 0x13,
86   MIPSI = 0x14,
87   MIPSII = 0x15,
88   MIPSIII = 0x16,
89   MIPSIV = 0x17,
90   MIPSV = 0x18,
91   M68000 = 0x20,
92   M68010 = 0x21,
93   M68020 = 0x22,
94   M68030 = 0x23,
95   M68040 = 0x24,
96   Alpha = 0x30,
97   Alpha21164 = 0x31,
98   Alpha21164A = 0x32,
99   Alpha21264 = 0x33,
100   Alpha21364 = 0x34,
101   PPC601 = 0x40,
102   PPC603 = 0x41,
103   PPC604 = 0x42,
104   PPC620 = 0x43,
105   PPCFP = 0x44,
106   PPCBE = 0x45,
107   SH3 = 0x50,
108   SH3E = 0x51,
109   SH3DSP = 0x52,
110   SH4 = 0x53,
111   SHMedia = 0x54,
112   ARM3 = 0x60,
113   ARM4 = 0x61,
114   ARM4T = 0x62,
115   ARM5 = 0x63,
116   ARM5T = 0x64,
117   ARM6 = 0x65,
118   ARM_XMAC = 0x66,
119   ARM_WMMX = 0x67,
120   ARM7 = 0x68,
121   Omni = 0x70,
122   Ia64 = 0x80,
123   Ia64_2 = 0x81,
124   CEE = 0x90,
125   AM33 = 0xa0,
126   M32R = 0xb0,
127   TriCore = 0xc0,
128   X64 = 0xd0,
129   EBC = 0xe0,
130   Thumb = 0xf0,
131   ARMNT = 0xf4,
132   D3D11_Shader = 0x100,
133 };
134
135 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
136 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
137 enum SourceLanguage : uint8_t {
138   C = 0x00,
139   Cpp = 0x01,
140   Fortran = 0x02,
141   Masm = 0x03,
142   Pascal = 0x04,
143   Basic = 0x05,
144   Cobol = 0x06,
145   Link = 0x07,
146   Cvtres = 0x08,
147   Cvtpgd = 0x09,
148   CSharp = 0x0a,
149   VB = 0x0b,
150   ILAsm = 0x0c,
151   Java = 0x0d,
152   JScript = 0x0e,
153   MSIL = 0x0f,
154   HLSL = 0x10
155 };
156
157 /// These values correspond to the CV_call_e enumeration, and are documented
158 /// at the following locations:
159 ///   https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
160 ///   https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
161 ///
162 enum class CallingConvention : uint8_t {
163   NearC = 0x00,       // near right to left push, caller pops stack
164   FarC = 0x01,        // far right to left push, caller pops stack
165   NearPascal = 0x02,  // near left to right push, callee pops stack
166   FarPascal = 0x03,   // far left to right push, callee pops stack
167   NearFast = 0x04,    // near left to right push with regs, callee pops stack
168   FarFast = 0x05,     // far left to right push with regs, callee pops stack
169   NearStdCall = 0x07, // near standard call
170   FarStdCall = 0x08,  // far standard call
171   NearSysCall = 0x09, // near sys call
172   FarSysCall = 0x0a,  // far sys call
173   ThisCall = 0x0b,    // this call (this passed in register)
174   MipsCall = 0x0c,    // Mips call
175   Generic = 0x0d,     // Generic call sequence
176   AlphaCall = 0x0e,   // Alpha call
177   PpcCall = 0x0f,     // PPC call
178   SHCall = 0x10,      // Hitachi SuperH call
179   ArmCall = 0x11,     // ARM call
180   AM33Call = 0x12,    // AM33 call
181   TriCall = 0x13,     // TriCore Call
182   SH5Call = 0x14,     // Hitachi SuperH-5 call
183   M32RCall = 0x15,    // M32R Call
184   ClrCall = 0x16,     // clr call
185   Inline =
186       0x17, // Marker for routines always inlined and thus lacking a convention
187   NearVector = 0x18 // near left to right push with regs, callee pops stack
188 };
189
190 enum class ClassOptions : uint16_t {
191   None = 0x0000,
192   Packed = 0x0001,
193   HasConstructorOrDestructor = 0x0002,
194   HasOverloadedOperator = 0x0004,
195   Nested = 0x0008,
196   ContainsNestedClass = 0x0010,
197   HasOverloadedAssignmentOperator = 0x0020,
198   HasConversionOperator = 0x0040,
199   ForwardReference = 0x0080,
200   Scoped = 0x0100,
201   HasUniqueName = 0x0200,
202   Sealed = 0x0400,
203   Intrinsic = 0x2000
204 };
205 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ClassOptions)
206
207 enum class FrameProcedureOptions : uint32_t {
208   None = 0x00000000,
209   HasAlloca = 0x00000001,
210   HasSetJmp = 0x00000002,
211   HasLongJmp = 0x00000004,
212   HasInlineAssembly = 0x00000008,
213   HasExceptionHandling = 0x00000010,
214   MarkedInline = 0x00000020,
215   HasStructuredExceptionHandling = 0x00000040,
216   Naked = 0x00000080,
217   SecurityChecks = 0x00000100,
218   AsynchronousExceptionHandling = 0x00000200,
219   NoStackOrderingForSecurityChecks = 0x00000400,
220   Inlined = 0x00000800,
221   StrictSecurityChecks = 0x00001000,
222   SafeBuffers = 0x00002000,
223   ProfileGuidedOptimization = 0x00040000,
224   ValidProfileCounts = 0x00080000,
225   OptimizedForSpeed = 0x00100000,
226   GuardCfg = 0x00200000,
227   GuardCfw = 0x00400000
228 };
229 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions)
230
231 enum class FunctionOptions : uint8_t {
232   None = 0x00,
233   CxxReturnUdt = 0x01,
234   Constructor = 0x02,
235   ConstructorWithVirtualBases = 0x04
236 };
237 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FunctionOptions)
238
239 enum class HfaKind : uint8_t {
240   None = 0x00,
241   Float = 0x01,
242   Double = 0x02,
243   Other = 0x03
244 };
245
246 /// Source-level access specifier. (CV_access_e)
247 enum class MemberAccess : uint8_t {
248   None = 0,
249   Private = 1,
250   Protected = 2,
251   Public = 3
252 };
253
254 /// Part of member attribute flags. (CV_methodprop_e)
255 enum class MethodKind : uint8_t {
256   Vanilla = 0x00,
257   Virtual = 0x01,
258   Static = 0x02,
259   Friend = 0x03,
260   IntroducingVirtual = 0x04,
261   PureVirtual = 0x05,
262   PureIntroducingVirtual = 0x06
263 };
264
265 /// Equivalent to CV_fldattr_t bitfield.
266 enum class MethodOptions : uint16_t {
267   None = 0x0000,
268   AccessMask = 0x0003,
269   MethodKindMask = 0x001c,
270   Pseudo = 0x0020,
271   NoInherit = 0x0040,
272   NoConstruct = 0x0080,
273   CompilerGenerated = 0x0100,
274   Sealed = 0x0200
275 };
276 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(MethodOptions)
277
278 /// Equivalent to CV_modifier_t.
279 /// TODO: Add flag for _Atomic modifier
280 enum class ModifierOptions : uint16_t {
281   None = 0x0000,
282   Const = 0x0001,
283   Volatile = 0x0002,
284   Unaligned = 0x0004
285 };
286 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions)
287
288 enum class ModuleSubstreamKind : uint32_t {
289   None = 0,
290   Symbols = 0xf1,
291   Lines = 0xf2,
292   StringTable = 0xf3,
293   FileChecksums = 0xf4,
294   FrameData = 0xf5,
295   InlineeLines = 0xf6,
296   CrossScopeImports = 0xf7,
297   CrossScopeExports = 0xf8,
298
299   // These appear to relate to .Net assembly info.
300   ILLines = 0xf9,
301   FuncMDTokenMap = 0xfa,
302   TypeMDTokenMap = 0xfb,
303   MergedAssemblyInput = 0xfc,
304
305   CoffSymbolRVA = 0xfd,
306 };
307
308 /// Equivalent to CV_ptrtype_e.
309 enum class PointerKind : uint8_t {
310   Near16 = 0x00,                // 16 bit pointer
311   Far16 = 0x01,                 // 16:16 far pointer
312   Huge16 = 0x02,                // 16:16 huge pointer
313   BasedOnSegment = 0x03,        // based on segment
314   BasedOnValue = 0x04,          // based on value of base
315   BasedOnSegmentValue = 0x05,   // based on segment value of base
316   BasedOnAddress = 0x06,        // based on address of base
317   BasedOnSegmentAddress = 0x07, // based on segment address of base
318   BasedOnType = 0x08,           // based on type
319   BasedOnSelf = 0x09,           // based on self
320   Near32 = 0x0a,                // 32 bit pointer
321   Far32 = 0x0b,                 // 16:32 pointer
322   Near64 = 0x0c                 // 64 bit pointer
323 };
324
325 /// Equivalent to CV_ptrmode_e.
326 enum class PointerMode : uint8_t {
327   Pointer = 0x00,                 // "normal" pointer
328   LValueReference = 0x01,         // "old" reference
329   PointerToDataMember = 0x02,     // pointer to data member
330   PointerToMemberFunction = 0x03, // pointer to member function
331   RValueReference = 0x04          // r-value reference
332 };
333
334 /// Equivalent to misc lfPointerAttr bitfields.
335 enum class PointerOptions : uint32_t {
336   None = 0x00000000,
337   Flat32 = 0x00000100,
338   Volatile = 0x00000200,
339   Const = 0x00000400,
340   Unaligned = 0x00000800,
341   Restrict = 0x00001000,
342   WinRTSmartPointer = 0x00080000
343 };
344 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PointerOptions)
345
346 /// Equivalent to CV_pmtype_e.
347 enum class PointerToMemberRepresentation : uint16_t {
348   Unknown = 0x00,                     // not specified (pre VC8)
349   SingleInheritanceData = 0x01,       // member data, single inheritance
350   MultipleInheritanceData = 0x02,     // member data, multiple inheritance
351   VirtualInheritanceData = 0x03,      // member data, virtual inheritance
352   GeneralData = 0x04,                 // member data, most general
353   SingleInheritanceFunction = 0x05,   // member function, single inheritance
354   MultipleInheritanceFunction = 0x06, // member function, multiple inheritance
355   VirtualInheritanceFunction = 0x07,  // member function, virtual inheritance
356   GeneralFunction = 0x08              // member function, most general
357 };
358
359 enum class VFTableSlotKind : uint8_t {
360   Near16 = 0x00,
361   Far16 = 0x01,
362   This = 0x02,
363   Outer = 0x03,
364   Meta = 0x04,
365   Near = 0x05,
366   Far = 0x06
367 };
368
369 enum class WindowsRTClassKind : uint8_t {
370   None = 0x00,
371   RefClass = 0x01,
372   ValueClass = 0x02,
373   Interface = 0x03
374 };
375
376 /// Corresponds to CV_LVARFLAGS bitfield.
377 enum class LocalSymFlags : uint16_t {
378   None = 0,
379   IsParameter = 1 << 0,
380   IsAddressTaken = 1 << 1,
381   IsCompilerGenerated = 1 << 2,
382   IsAggregate = 1 << 3,
383   IsAggregated = 1 << 4,
384   IsAliased = 1 << 5,
385   IsAlias = 1 << 6,
386   IsReturnValue = 1 << 7,
387   IsOptimizedOut = 1 << 8,
388   IsEnregisteredGlobal = 1 << 9,
389   IsEnregisteredStatic = 1 << 10,
390 };
391 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags)
392
393 /// Corresponds to the CV_PROCFLAGS bitfield.
394 enum class ProcSymFlags : uint8_t {
395   None = 0,
396   HasFP = 1 << 0,
397   HasIRET = 1 << 1,
398   HasFRET = 1 << 2,
399   IsNoReturn = 1 << 3,
400   IsUnreachable = 1 << 4,
401   HasCustomCallingConv = 1 << 5,
402   IsNoInline = 1 << 6,
403   HasOptimizedDebugInfo = 1 << 7,
404 };
405 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ProcSymFlags)
406
407 /// Corresponds to COMPILESYM2::Flags bitfield.
408 enum class CompileSym2Flags : uint32_t {
409   EC = 1 << 8,
410   NoDbgInfo = 1 << 9,
411   LTCG = 1 << 10,
412   NoDataAlign = 1 << 11,
413   ManagedPresent = 1 << 12,
414   SecurityChecks = 1 << 13,
415   HotPatch = 1 << 14,
416   CVTCIL = 1 << 15,
417   MSILModule = 1 << 16,
418 };
419 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym2Flags)
420
421 /// Corresponds to COMPILESYM3::Flags bitfield.
422 enum class CompileSym3Flags : uint32_t {
423   EC = 1 << 8,
424   NoDbgInfo = 1 << 9,
425   LTCG = 1 << 10,
426   NoDataAlign = 1 << 11,
427   ManagedPresent = 1 << 12,
428   SecurityChecks = 1 << 13,
429   HotPatch = 1 << 14,
430   CVTCIL = 1 << 15,
431   MSILModule = 1 << 16,
432   Sdl = 1 << 17,
433   PGO = 1 << 18,
434   Exp = 1 << 19,
435 };
436 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym3Flags)
437
438 enum class ExportFlags : uint16_t {
439   IsConstant = 1 << 0,
440   IsData = 1 << 1,
441   IsPrivate = 1 << 2,
442   HasNoName = 1 << 3,
443   HasExplicitOrdinal = 1 << 4,
444   IsForwarder = 1 << 5
445 };
446 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ExportFlags)
447
448 // Corresponds to BinaryAnnotationOpcode enum.
449 enum class BinaryAnnotationsOpCode : uint32_t {
450   Invalid,
451   CodeOffset,
452   ChangeCodeOffsetBase,
453   ChangeCodeOffset,
454   ChangeCodeLength,
455   ChangeFile,
456   ChangeLineOffset,
457   ChangeLineEndDelta,
458   ChangeRangeKind,
459   ChangeColumnStart,
460   ChangeColumnEndDelta,
461   ChangeCodeOffsetAndLineOffset,
462   ChangeCodeLengthAndCodeOffset,
463   ChangeColumnEnd,
464 };
465
466 // Corresponds to CV_cookietype_e enum.
467 enum class FrameCookieKind : uint8_t {
468   Copy,
469   XorStackPointer,
470   XorFramePointer,
471   XorR13,
472 };
473
474 // Corresponds to CV_HREG_e enum.
475 enum class RegisterId : uint16_t {
476   Unknown = 0,
477   VFrame = 30006,
478   AL = 1,
479   CL = 2,
480   DL = 3,
481   BL = 4,
482   AH = 5,
483   CH = 6,
484   DH = 7,
485   BH = 8,
486   AX = 9,
487   CX = 10,
488   DX = 11,
489   BX = 12,
490   SP = 13,
491   BP = 14,
492   SI = 15,
493   DI = 16,
494   EAX = 17,
495   ECX = 18,
496   EDX = 19,
497   EBX = 20,
498   ESP = 21,
499   EBP = 22,
500   ESI = 23,
501   EDI = 24,
502   ES = 25,
503   CS = 26,
504   SS = 27,
505   DS = 28,
506   FS = 29,
507   GS = 30,
508   IP = 31,
509   RAX = 328,
510   RBX = 329,
511   RCX = 330,
512   RDX = 331,
513   RSI = 332,
514   RDI = 333,
515   RBP = 334,
516   RSP = 335,
517   R8 = 336,
518   R9 = 337,
519   R10 = 338,
520   R11 = 339,
521   R12 = 340,
522   R13 = 341,
523   R14 = 342,
524   R15 = 343,
525 };
526
527 /// These values correspond to the THUNK_ORDINAL enumeration.
528 enum class ThunkOrdinal : uint8_t {
529   Standard,
530   ThisAdjustor,
531   Vcall,
532   Pcode,
533   UnknownLoad,
534   TrampIncremental,
535   BranchIsland
536 };
537
538 enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland };
539
540 // These values correspond to the CV_SourceChksum_t enumeration.
541 enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 };
542
543 enum LineFlags : uint32_t {
544   HaveColumns = 1, // CV_LINES_HAVE_COLUMNS
545 };
546 }
547 }
548
549 #endif