Support: Use Dwarf.def for DW_VIRTUALITY, NFC
[oota-llvm.git] / include / llvm / Support / Dwarf.h
1 //===-- llvm/Support/Dwarf.h ---Dwarf Constants------------------*- 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 // \file
11 // \brief This file contains constants used for implementing Dwarf
12 // debug support.
13 //
14 // For details on the Dwarf specfication see the latest DWARF Debugging
15 // Information Format standard document on http://www.dwarfstd.org. This
16 // file often includes support for non-released standard features.
17 //
18 //===----------------------------------------------------------------------===//
19
20 #ifndef LLVM_SUPPORT_DWARF_H
21 #define LLVM_SUPPORT_DWARF_H
22
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Support/Compiler.h"
25 #include "llvm/Support/DataTypes.h"
26
27 namespace llvm {
28
29 namespace dwarf {
30
31 //===----------------------------------------------------------------------===//
32 // Dwarf constants as gleaned from the DWARF Debugging Information Format V.4
33 // reference manual http://www.dwarfstd.org/.
34 //
35
36 // Do not mix the following two enumerations sets.  DW_TAG_invalid changes the
37 // enumeration base type.
38
39 enum LLVMConstants : uint32_t {
40   // LLVM mock tags (see also llvm/Support/Dwarf.def).
41   DW_TAG_invalid = ~0U,    // Tag for invalid results.
42
43   // Other constants.
44   DWARF_VERSION = 4,       // Default dwarf version we output.
45   DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes.
46   DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames.
47   DW_ARANGES_VERSION = 2   // Section version number for .debug_aranges.
48 };
49
50 // Special ID values that distinguish a CIE from a FDE in DWARF CFI.
51 // Not inside an enum because a 64-bit value is needed.
52 const uint32_t DW_CIE_ID = UINT32_MAX;
53 const uint64_t DW64_CIE_ID = UINT64_MAX;
54
55 enum Tag : uint16_t {
56 #define HANDLE_DW_TAG(ID, NAME) DW_TAG_##NAME = ID,
57 #include "llvm/Support/Dwarf.def"
58   DW_TAG_lo_user = 0x4080,
59   DW_TAG_hi_user = 0xffff,
60   DW_TAG_user_base = 0x1000 // Recommended base for user tags.
61 };
62
63 inline bool isType(Tag T) {
64   switch (T) {
65   case DW_TAG_array_type:
66   case DW_TAG_class_type:
67   case DW_TAG_interface_type:
68   case DW_TAG_enumeration_type:
69   case DW_TAG_pointer_type:
70   case DW_TAG_reference_type:
71   case DW_TAG_rvalue_reference_type:
72   case DW_TAG_string_type:
73   case DW_TAG_structure_type:
74   case DW_TAG_subroutine_type:
75   case DW_TAG_union_type:
76   case DW_TAG_ptr_to_member_type:
77   case DW_TAG_set_type:
78   case DW_TAG_subrange_type:
79   case DW_TAG_base_type:
80   case DW_TAG_const_type:
81   case DW_TAG_file_type:
82   case DW_TAG_packed_type:
83   case DW_TAG_volatile_type:
84   case DW_TAG_typedef:
85     return true;
86   default:
87     return false;
88   }
89 }
90
91 enum Attribute : uint16_t {
92   // Attributes
93   DW_AT_sibling = 0x01,
94   DW_AT_location = 0x02,
95   DW_AT_name = 0x03,
96   DW_AT_ordering = 0x09,
97   DW_AT_byte_size = 0x0b,
98   DW_AT_bit_offset = 0x0c,
99   DW_AT_bit_size = 0x0d,
100   DW_AT_stmt_list = 0x10,
101   DW_AT_low_pc = 0x11,
102   DW_AT_high_pc = 0x12,
103   DW_AT_language = 0x13,
104   DW_AT_discr = 0x15,
105   DW_AT_discr_value = 0x16,
106   DW_AT_visibility = 0x17,
107   DW_AT_import = 0x18,
108   DW_AT_string_length = 0x19,
109   DW_AT_common_reference = 0x1a,
110   DW_AT_comp_dir = 0x1b,
111   DW_AT_const_value = 0x1c,
112   DW_AT_containing_type = 0x1d,
113   DW_AT_default_value = 0x1e,
114   DW_AT_inline = 0x20,
115   DW_AT_is_optional = 0x21,
116   DW_AT_lower_bound = 0x22,
117   DW_AT_producer = 0x25,
118   DW_AT_prototyped = 0x27,
119   DW_AT_return_addr = 0x2a,
120   DW_AT_start_scope = 0x2c,
121   DW_AT_bit_stride = 0x2e,
122   DW_AT_upper_bound = 0x2f,
123   DW_AT_abstract_origin = 0x31,
124   DW_AT_accessibility = 0x32,
125   DW_AT_address_class = 0x33,
126   DW_AT_artificial = 0x34,
127   DW_AT_base_types = 0x35,
128   DW_AT_calling_convention = 0x36,
129   DW_AT_count = 0x37,
130   DW_AT_data_member_location = 0x38,
131   DW_AT_decl_column = 0x39,
132   DW_AT_decl_file = 0x3a,
133   DW_AT_decl_line = 0x3b,
134   DW_AT_declaration = 0x3c,
135   DW_AT_discr_list = 0x3d,
136   DW_AT_encoding = 0x3e,
137   DW_AT_external = 0x3f,
138   DW_AT_frame_base = 0x40,
139   DW_AT_friend = 0x41,
140   DW_AT_identifier_case = 0x42,
141   DW_AT_macro_info = 0x43,
142   DW_AT_namelist_item = 0x44,
143   DW_AT_priority = 0x45,
144   DW_AT_segment = 0x46,
145   DW_AT_specification = 0x47,
146   DW_AT_static_link = 0x48,
147   DW_AT_type = 0x49,
148   DW_AT_use_location = 0x4a,
149   DW_AT_variable_parameter = 0x4b,
150   DW_AT_virtuality = 0x4c,
151   DW_AT_vtable_elem_location = 0x4d,
152   DW_AT_allocated = 0x4e,
153   DW_AT_associated = 0x4f,
154   DW_AT_data_location = 0x50,
155   DW_AT_byte_stride = 0x51,
156   DW_AT_entry_pc = 0x52,
157   DW_AT_use_UTF8 = 0x53,
158   DW_AT_extension = 0x54,
159   DW_AT_ranges = 0x55,
160   DW_AT_trampoline = 0x56,
161   DW_AT_call_column = 0x57,
162   DW_AT_call_file = 0x58,
163   DW_AT_call_line = 0x59,
164   DW_AT_description = 0x5a,
165   DW_AT_binary_scale = 0x5b,
166   DW_AT_decimal_scale = 0x5c,
167   DW_AT_small = 0x5d,
168   DW_AT_decimal_sign = 0x5e,
169   DW_AT_digit_count = 0x5f,
170   DW_AT_picture_string = 0x60,
171   DW_AT_mutable = 0x61,
172   DW_AT_threads_scaled = 0x62,
173   DW_AT_explicit = 0x63,
174   DW_AT_object_pointer = 0x64,
175   DW_AT_endianity = 0x65,
176   DW_AT_elemental = 0x66,
177   DW_AT_pure = 0x67,
178   DW_AT_recursive = 0x68,
179   DW_AT_signature = 0x69,
180   DW_AT_main_subprogram = 0x6a,
181   DW_AT_data_bit_offset = 0x6b,
182   DW_AT_const_expr = 0x6c,
183   DW_AT_enum_class = 0x6d,
184   DW_AT_linkage_name = 0x6e,
185
186   // New in DWARF 5:
187   DW_AT_string_length_bit_size = 0x6f,
188   DW_AT_string_length_byte_size = 0x70,
189   DW_AT_rank = 0x71,
190   DW_AT_str_offsets_base = 0x72,
191   DW_AT_addr_base = 0x73,
192   DW_AT_ranges_base = 0x74,
193   DW_AT_dwo_id = 0x75,
194   DW_AT_dwo_name = 0x76,
195   DW_AT_reference = 0x77,
196   DW_AT_rvalue_reference = 0x78,
197
198   DW_AT_lo_user = 0x2000,
199   DW_AT_hi_user = 0x3fff,
200
201   DW_AT_MIPS_loop_begin = 0x2002,
202   DW_AT_MIPS_tail_loop_begin = 0x2003,
203   DW_AT_MIPS_epilog_begin = 0x2004,
204   DW_AT_MIPS_loop_unroll_factor = 0x2005,
205   DW_AT_MIPS_software_pipeline_depth = 0x2006,
206   DW_AT_MIPS_linkage_name = 0x2007,
207   DW_AT_MIPS_stride = 0x2008,
208   DW_AT_MIPS_abstract_name = 0x2009,
209   DW_AT_MIPS_clone_origin = 0x200a,
210   DW_AT_MIPS_has_inlines = 0x200b,
211   DW_AT_MIPS_stride_byte = 0x200c,
212   DW_AT_MIPS_stride_elem = 0x200d,
213   DW_AT_MIPS_ptr_dopetype = 0x200e,
214   DW_AT_MIPS_allocatable_dopetype = 0x200f,
215   DW_AT_MIPS_assumed_shape_dopetype = 0x2010,
216
217   // This one appears to have only been implemented by Open64 for
218   // fortran and may conflict with other extensions.
219   DW_AT_MIPS_assumed_size = 0x2011,
220
221   // GNU extensions
222   DW_AT_sf_names = 0x2101,
223   DW_AT_src_info = 0x2102,
224   DW_AT_mac_info = 0x2103,
225   DW_AT_src_coords = 0x2104,
226   DW_AT_body_begin = 0x2105,
227   DW_AT_body_end = 0x2106,
228   DW_AT_GNU_vector = 0x2107,
229   DW_AT_GNU_template_name = 0x2110,
230
231   DW_AT_GNU_odr_signature = 0x210f,
232
233   // Extensions for Fission proposal.
234   DW_AT_GNU_dwo_name = 0x2130,
235   DW_AT_GNU_dwo_id = 0x2131,
236   DW_AT_GNU_ranges_base = 0x2132,
237   DW_AT_GNU_addr_base = 0x2133,
238   DW_AT_GNU_pubnames = 0x2134,
239   DW_AT_GNU_pubtypes = 0x2135,
240
241   // Apple extensions.
242   DW_AT_APPLE_optimized = 0x3fe1,
243   DW_AT_APPLE_flags = 0x3fe2,
244   DW_AT_APPLE_isa = 0x3fe3,
245   DW_AT_APPLE_block = 0x3fe4,
246   DW_AT_APPLE_major_runtime_vers = 0x3fe5,
247   DW_AT_APPLE_runtime_class = 0x3fe6,
248   DW_AT_APPLE_omit_frame_ptr = 0x3fe7,
249   DW_AT_APPLE_property_name = 0x3fe8,
250   DW_AT_APPLE_property_getter = 0x3fe9,
251   DW_AT_APPLE_property_setter = 0x3fea,
252   DW_AT_APPLE_property_attribute = 0x3feb,
253   DW_AT_APPLE_objc_complete_type = 0x3fec,
254   DW_AT_APPLE_property = 0x3fed
255 };
256
257 enum Form : uint16_t {
258   // Attribute form encodings
259   DW_FORM_addr = 0x01,
260   DW_FORM_block2 = 0x03,
261   DW_FORM_block4 = 0x04,
262   DW_FORM_data2 = 0x05,
263   DW_FORM_data4 = 0x06,
264   DW_FORM_data8 = 0x07,
265   DW_FORM_string = 0x08,
266   DW_FORM_block = 0x09,
267   DW_FORM_block1 = 0x0a,
268   DW_FORM_data1 = 0x0b,
269   DW_FORM_flag = 0x0c,
270   DW_FORM_sdata = 0x0d,
271   DW_FORM_strp = 0x0e,
272   DW_FORM_udata = 0x0f,
273   DW_FORM_ref_addr = 0x10,
274   DW_FORM_ref1 = 0x11,
275   DW_FORM_ref2 = 0x12,
276   DW_FORM_ref4 = 0x13,
277   DW_FORM_ref8 = 0x14,
278   DW_FORM_ref_udata = 0x15,
279   DW_FORM_indirect = 0x16,
280   DW_FORM_sec_offset = 0x17,
281   DW_FORM_exprloc = 0x18,
282   DW_FORM_flag_present = 0x19,
283   DW_FORM_ref_sig8 = 0x20,
284
285   // Extensions for Fission proposal
286   DW_FORM_GNU_addr_index = 0x1f01,
287   DW_FORM_GNU_str_index = 0x1f02
288 };
289
290 enum LocationAtom {
291   // Operation encodings
292   DW_OP_addr = 0x03,
293   DW_OP_deref = 0x06,
294   DW_OP_const1u = 0x08,
295   DW_OP_const1s = 0x09,
296   DW_OP_const2u = 0x0a,
297   DW_OP_const2s = 0x0b,
298   DW_OP_const4u = 0x0c,
299   DW_OP_const4s = 0x0d,
300   DW_OP_const8u = 0x0e,
301   DW_OP_const8s = 0x0f,
302   DW_OP_constu = 0x10,
303   DW_OP_consts = 0x11,
304   DW_OP_dup = 0x12,
305   DW_OP_drop = 0x13,
306   DW_OP_over = 0x14,
307   DW_OP_pick = 0x15,
308   DW_OP_swap = 0x16,
309   DW_OP_rot = 0x17,
310   DW_OP_xderef = 0x18,
311   DW_OP_abs = 0x19,
312   DW_OP_and = 0x1a,
313   DW_OP_div = 0x1b,
314   DW_OP_minus = 0x1c,
315   DW_OP_mod = 0x1d,
316   DW_OP_mul = 0x1e,
317   DW_OP_neg = 0x1f,
318   DW_OP_not = 0x20,
319   DW_OP_or = 0x21,
320   DW_OP_plus = 0x22,
321   DW_OP_plus_uconst = 0x23,
322   DW_OP_shl = 0x24,
323   DW_OP_shr = 0x25,
324   DW_OP_shra = 0x26,
325   DW_OP_xor = 0x27,
326   DW_OP_skip = 0x2f,
327   DW_OP_bra = 0x28,
328   DW_OP_eq = 0x29,
329   DW_OP_ge = 0x2a,
330   DW_OP_gt = 0x2b,
331   DW_OP_le = 0x2c,
332   DW_OP_lt = 0x2d,
333   DW_OP_ne = 0x2e,
334   DW_OP_lit0 = 0x30,
335   DW_OP_lit1 = 0x31,
336   DW_OP_lit2 = 0x32,
337   DW_OP_lit3 = 0x33,
338   DW_OP_lit4 = 0x34,
339   DW_OP_lit5 = 0x35,
340   DW_OP_lit6 = 0x36,
341   DW_OP_lit7 = 0x37,
342   DW_OP_lit8 = 0x38,
343   DW_OP_lit9 = 0x39,
344   DW_OP_lit10 = 0x3a,
345   DW_OP_lit11 = 0x3b,
346   DW_OP_lit12 = 0x3c,
347   DW_OP_lit13 = 0x3d,
348   DW_OP_lit14 = 0x3e,
349   DW_OP_lit15 = 0x3f,
350   DW_OP_lit16 = 0x40,
351   DW_OP_lit17 = 0x41,
352   DW_OP_lit18 = 0x42,
353   DW_OP_lit19 = 0x43,
354   DW_OP_lit20 = 0x44,
355   DW_OP_lit21 = 0x45,
356   DW_OP_lit22 = 0x46,
357   DW_OP_lit23 = 0x47,
358   DW_OP_lit24 = 0x48,
359   DW_OP_lit25 = 0x49,
360   DW_OP_lit26 = 0x4a,
361   DW_OP_lit27 = 0x4b,
362   DW_OP_lit28 = 0x4c,
363   DW_OP_lit29 = 0x4d,
364   DW_OP_lit30 = 0x4e,
365   DW_OP_lit31 = 0x4f,
366   DW_OP_reg0 = 0x50,
367   DW_OP_reg1 = 0x51,
368   DW_OP_reg2 = 0x52,
369   DW_OP_reg3 = 0x53,
370   DW_OP_reg4 = 0x54,
371   DW_OP_reg5 = 0x55,
372   DW_OP_reg6 = 0x56,
373   DW_OP_reg7 = 0x57,
374   DW_OP_reg8 = 0x58,
375   DW_OP_reg9 = 0x59,
376   DW_OP_reg10 = 0x5a,
377   DW_OP_reg11 = 0x5b,
378   DW_OP_reg12 = 0x5c,
379   DW_OP_reg13 = 0x5d,
380   DW_OP_reg14 = 0x5e,
381   DW_OP_reg15 = 0x5f,
382   DW_OP_reg16 = 0x60,
383   DW_OP_reg17 = 0x61,
384   DW_OP_reg18 = 0x62,
385   DW_OP_reg19 = 0x63,
386   DW_OP_reg20 = 0x64,
387   DW_OP_reg21 = 0x65,
388   DW_OP_reg22 = 0x66,
389   DW_OP_reg23 = 0x67,
390   DW_OP_reg24 = 0x68,
391   DW_OP_reg25 = 0x69,
392   DW_OP_reg26 = 0x6a,
393   DW_OP_reg27 = 0x6b,
394   DW_OP_reg28 = 0x6c,
395   DW_OP_reg29 = 0x6d,
396   DW_OP_reg30 = 0x6e,
397   DW_OP_reg31 = 0x6f,
398   DW_OP_breg0 = 0x70,
399   DW_OP_breg1 = 0x71,
400   DW_OP_breg2 = 0x72,
401   DW_OP_breg3 = 0x73,
402   DW_OP_breg4 = 0x74,
403   DW_OP_breg5 = 0x75,
404   DW_OP_breg6 = 0x76,
405   DW_OP_breg7 = 0x77,
406   DW_OP_breg8 = 0x78,
407   DW_OP_breg9 = 0x79,
408   DW_OP_breg10 = 0x7a,
409   DW_OP_breg11 = 0x7b,
410   DW_OP_breg12 = 0x7c,
411   DW_OP_breg13 = 0x7d,
412   DW_OP_breg14 = 0x7e,
413   DW_OP_breg15 = 0x7f,
414   DW_OP_breg16 = 0x80,
415   DW_OP_breg17 = 0x81,
416   DW_OP_breg18 = 0x82,
417   DW_OP_breg19 = 0x83,
418   DW_OP_breg20 = 0x84,
419   DW_OP_breg21 = 0x85,
420   DW_OP_breg22 = 0x86,
421   DW_OP_breg23 = 0x87,
422   DW_OP_breg24 = 0x88,
423   DW_OP_breg25 = 0x89,
424   DW_OP_breg26 = 0x8a,
425   DW_OP_breg27 = 0x8b,
426   DW_OP_breg28 = 0x8c,
427   DW_OP_breg29 = 0x8d,
428   DW_OP_breg30 = 0x8e,
429   DW_OP_breg31 = 0x8f,
430   DW_OP_regx = 0x90,
431   DW_OP_fbreg = 0x91,
432   DW_OP_bregx = 0x92,
433   DW_OP_piece = 0x93,
434   DW_OP_deref_size = 0x94,
435   DW_OP_xderef_size = 0x95,
436   DW_OP_nop = 0x96,
437   DW_OP_push_object_address = 0x97,
438   DW_OP_call2 = 0x98,
439   DW_OP_call4 = 0x99,
440   DW_OP_call_ref = 0x9a,
441   DW_OP_form_tls_address = 0x9b,
442   DW_OP_call_frame_cfa = 0x9c,
443   DW_OP_bit_piece = 0x9d,
444   DW_OP_implicit_value = 0x9e,
445   DW_OP_stack_value = 0x9f,
446   DW_OP_lo_user = 0xe0,
447   DW_OP_hi_user = 0xff,
448
449   // Extensions for GNU-style thread-local storage.
450   DW_OP_GNU_push_tls_address = 0xe0,
451
452   // Extensions for Fission proposal.
453   DW_OP_GNU_addr_index = 0xfb,
454   DW_OP_GNU_const_index = 0xfc
455 };
456
457 enum TypeKind {
458 #define HANDLE_DW_ATE(ID, NAME) DW_ATE_##NAME = ID,
459 #include "llvm/Support/Dwarf.def"
460   DW_ATE_lo_user = 0x80,
461   DW_ATE_hi_user = 0xff
462 };
463
464 enum DecimalSignEncoding {
465   // Decimal sign attribute values
466   DW_DS_unsigned = 0x01,
467   DW_DS_leading_overpunch = 0x02,
468   DW_DS_trailing_overpunch = 0x03,
469   DW_DS_leading_separate = 0x04,
470   DW_DS_trailing_separate = 0x05
471 };
472
473 enum EndianityEncoding {
474   // Endianity attribute values
475   DW_END_default = 0x00,
476   DW_END_big = 0x01,
477   DW_END_little = 0x02,
478   DW_END_lo_user = 0x40,
479   DW_END_hi_user = 0xff
480 };
481
482 enum AccessAttribute {
483   // Accessibility codes
484   DW_ACCESS_public = 0x01,
485   DW_ACCESS_protected = 0x02,
486   DW_ACCESS_private = 0x03
487 };
488
489 enum VisibilityAttribute {
490   // Visibility codes
491   DW_VIS_local = 0x01,
492   DW_VIS_exported = 0x02,
493   DW_VIS_qualified = 0x03
494 };
495
496 enum VirtualityAttribute {
497 #define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID,
498 #include "llvm/Support/Dwarf.def"
499   DW_VIRTUALITY_max = 0x02
500 };
501
502 enum SourceLanguage {
503 #define HANDLE_DW_LANG(ID, NAME) DW_LANG_##NAME = ID,
504 #include "llvm/Support/Dwarf.def"
505   DW_LANG_lo_user = 0x8000,
506   DW_LANG_hi_user = 0xffff
507 };
508
509 enum CaseSensitivity {
510   // Identifier case codes
511   DW_ID_case_sensitive = 0x00,
512   DW_ID_up_case = 0x01,
513   DW_ID_down_case = 0x02,
514   DW_ID_case_insensitive = 0x03
515 };
516
517 enum CallingConvention {
518   // Calling convention codes
519   DW_CC_normal = 0x01,
520   DW_CC_program = 0x02,
521   DW_CC_nocall = 0x03,
522   DW_CC_lo_user = 0x40,
523   DW_CC_hi_user = 0xff
524 };
525
526 enum InlineAttribute {
527   // Inline codes
528   DW_INL_not_inlined = 0x00,
529   DW_INL_inlined = 0x01,
530   DW_INL_declared_not_inlined = 0x02,
531   DW_INL_declared_inlined = 0x03
532 };
533
534 enum ArrayDimensionOrdering {
535   // Array ordering
536   DW_ORD_row_major = 0x00,
537   DW_ORD_col_major = 0x01
538 };
539
540 enum DiscriminantList {
541   // Discriminant descriptor values
542   DW_DSC_label = 0x00,
543   DW_DSC_range = 0x01
544 };
545
546 enum LineNumberOps {
547   // Line Number Standard Opcode Encodings
548   DW_LNS_extended_op = 0x00,
549   DW_LNS_copy = 0x01,
550   DW_LNS_advance_pc = 0x02,
551   DW_LNS_advance_line = 0x03,
552   DW_LNS_set_file = 0x04,
553   DW_LNS_set_column = 0x05,
554   DW_LNS_negate_stmt = 0x06,
555   DW_LNS_set_basic_block = 0x07,
556   DW_LNS_const_add_pc = 0x08,
557   DW_LNS_fixed_advance_pc = 0x09,
558   DW_LNS_set_prologue_end = 0x0a,
559   DW_LNS_set_epilogue_begin = 0x0b,
560   DW_LNS_set_isa = 0x0c
561 };
562
563 enum LineNumberExtendedOps {
564   // Line Number Extended Opcode Encodings
565   DW_LNE_end_sequence = 0x01,
566   DW_LNE_set_address = 0x02,
567   DW_LNE_define_file = 0x03,
568   DW_LNE_set_discriminator = 0x04,
569   DW_LNE_lo_user = 0x80,
570   DW_LNE_hi_user = 0xff
571 };
572
573 enum MacinfoRecordType {
574   // Macinfo Type Encodings
575   DW_MACINFO_define = 0x01,
576   DW_MACINFO_undef = 0x02,
577   DW_MACINFO_start_file = 0x03,
578   DW_MACINFO_end_file = 0x04,
579   DW_MACINFO_vendor_ext = 0xff
580 };
581
582 enum CallFrameInfo {
583   // Call frame instruction encodings
584   DW_CFA_extended = 0x00,
585   DW_CFA_nop = 0x00,
586   DW_CFA_advance_loc = 0x40,
587   DW_CFA_offset = 0x80,
588   DW_CFA_restore = 0xc0,
589   DW_CFA_set_loc = 0x01,
590   DW_CFA_advance_loc1 = 0x02,
591   DW_CFA_advance_loc2 = 0x03,
592   DW_CFA_advance_loc4 = 0x04,
593   DW_CFA_offset_extended = 0x05,
594   DW_CFA_restore_extended = 0x06,
595   DW_CFA_undefined = 0x07,
596   DW_CFA_same_value = 0x08,
597   DW_CFA_register = 0x09,
598   DW_CFA_remember_state = 0x0a,
599   DW_CFA_restore_state = 0x0b,
600   DW_CFA_def_cfa = 0x0c,
601   DW_CFA_def_cfa_register = 0x0d,
602   DW_CFA_def_cfa_offset = 0x0e,
603   DW_CFA_def_cfa_expression = 0x0f,
604   DW_CFA_expression = 0x10,
605   DW_CFA_offset_extended_sf = 0x11,
606   DW_CFA_def_cfa_sf = 0x12,
607   DW_CFA_def_cfa_offset_sf = 0x13,
608   DW_CFA_val_offset = 0x14,
609   DW_CFA_val_offset_sf = 0x15,
610   DW_CFA_val_expression = 0x16,
611   DW_CFA_MIPS_advance_loc8 = 0x1d,
612   DW_CFA_GNU_window_save = 0x2d,
613   DW_CFA_GNU_args_size = 0x2e,
614   DW_CFA_lo_user = 0x1c,
615   DW_CFA_hi_user = 0x3f
616 };
617
618 enum Constants {
619   // Children flag
620   DW_CHILDREN_no = 0x00,
621   DW_CHILDREN_yes = 0x01,
622
623   DW_EH_PE_absptr = 0x00,
624   DW_EH_PE_omit = 0xff,
625   DW_EH_PE_uleb128 = 0x01,
626   DW_EH_PE_udata2 = 0x02,
627   DW_EH_PE_udata4 = 0x03,
628   DW_EH_PE_udata8 = 0x04,
629   DW_EH_PE_sleb128 = 0x09,
630   DW_EH_PE_sdata2 = 0x0A,
631   DW_EH_PE_sdata4 = 0x0B,
632   DW_EH_PE_sdata8 = 0x0C,
633   DW_EH_PE_signed = 0x08,
634   DW_EH_PE_pcrel = 0x10,
635   DW_EH_PE_textrel = 0x20,
636   DW_EH_PE_datarel = 0x30,
637   DW_EH_PE_funcrel = 0x40,
638   DW_EH_PE_aligned = 0x50,
639   DW_EH_PE_indirect = 0x80
640 };
641
642 // Constants for debug_loc.dwo in the DWARF5 Split Debug Info Proposal
643 enum LocationListEntry : unsigned char {
644   DW_LLE_end_of_list_entry,
645   DW_LLE_base_address_selection_entry,
646   DW_LLE_start_end_entry,
647   DW_LLE_start_length_entry,
648   DW_LLE_offset_pair_entry
649 };
650
651 /// Contstants for the DW_APPLE_PROPERTY_attributes attribute.
652 /// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind.
653 enum ApplePropertyAttributes {
654   // Apple Objective-C Property Attributes
655   DW_APPLE_PROPERTY_readonly = 0x01,
656   DW_APPLE_PROPERTY_getter = 0x02,
657   DW_APPLE_PROPERTY_assign = 0x04,
658   DW_APPLE_PROPERTY_readwrite = 0x08,
659   DW_APPLE_PROPERTY_retain = 0x10,
660   DW_APPLE_PROPERTY_copy = 0x20,
661   DW_APPLE_PROPERTY_nonatomic = 0x40,
662   DW_APPLE_PROPERTY_setter = 0x80,
663   DW_APPLE_PROPERTY_atomic = 0x100,
664   DW_APPLE_PROPERTY_weak =   0x200,
665   DW_APPLE_PROPERTY_strong = 0x400,
666   DW_APPLE_PROPERTY_unsafe_unretained = 0x800
667 };
668
669 // Constants for the DWARF5 Accelerator Table Proposal
670 enum AcceleratorTable {
671   // Data layout descriptors.
672   DW_ATOM_null = 0u,       // Marker as the end of a list of atoms.
673   DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
674   DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
675                           // item in question.
676   DW_ATOM_die_tag = 3u,   // A tag entry.
677   DW_ATOM_type_flags = 4u, // Set of flags for a type.
678
679   // DW_ATOM_type_flags values.
680
681   // Always set for C++, only set for ObjC if this is the @implementation for a
682   // class.
683   DW_FLAG_type_implementation = 2u,
684
685   // Hash functions.
686
687   // Daniel J. Bernstein hash.
688   DW_hash_function_djb = 0u
689 };
690
691 // Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
692 enum GDBIndexEntryKind {
693   GIEK_NONE,
694   GIEK_TYPE,
695   GIEK_VARIABLE,
696   GIEK_FUNCTION,
697   GIEK_OTHER,
698   GIEK_UNUSED5,
699   GIEK_UNUSED6,
700   GIEK_UNUSED7
701 };
702
703 enum GDBIndexEntryLinkage {
704   GIEL_EXTERNAL,
705   GIEL_STATIC
706 };
707
708 /// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
709 ///
710 /// All these functions map their argument's value back to the
711 /// corresponding enumerator name or return nullptr if the value isn't
712 /// known.
713 ///
714 /// @{
715 const char *TagString(unsigned Tag);
716 const char *ChildrenString(unsigned Children);
717 const char *AttributeString(unsigned Attribute);
718 const char *FormEncodingString(unsigned Encoding);
719 const char *OperationEncodingString(unsigned Encoding);
720 const char *AttributeEncodingString(unsigned Encoding);
721 const char *DecimalSignString(unsigned Sign);
722 const char *EndianityString(unsigned Endian);
723 const char *AccessibilityString(unsigned Access);
724 const char *VisibilityString(unsigned Visibility);
725 const char *VirtualityString(unsigned Virtuality);
726 const char *LanguageString(unsigned Language);
727 const char *CaseString(unsigned Case);
728 const char *ConventionString(unsigned Convention);
729 const char *InlineCodeString(unsigned Code);
730 const char *ArrayOrderString(unsigned Order);
731 const char *DiscriminantString(unsigned Discriminant);
732 const char *LNStandardString(unsigned Standard);
733 const char *LNExtendedString(unsigned Encoding);
734 const char *MacinfoString(unsigned Encoding);
735 const char *CallFrameString(unsigned Encoding);
736 const char *ApplePropertyString(unsigned);
737 const char *AtomTypeString(unsigned Atom);
738 const char *GDBIndexEntryKindString(GDBIndexEntryKind Kind);
739 const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
740 /// @}
741
742 /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
743 ///
744 /// These functions map their strings back to the corresponding enumeration
745 /// value or return 0 if there is none.  As an exception, \a getTag() returns
746 /// \a DW_TAG_invalid on invalid input.
747 ///
748 /// @{
749 unsigned getTag(StringRef TagString);
750 unsigned getLanguage(StringRef LanguageString);
751 unsigned getAttributeEncoding(StringRef EncodingString);
752 /// @}
753
754 /// \brief Returns the symbolic string representing Val when used as a value
755 /// for attribute Attr.
756 const char *AttributeValueString(uint16_t Attr, unsigned Val);
757
758 /// \brief Decsribes an entry of the various gnu_pub* debug sections.
759 /// 
760 /// The gnu_pub* kind looks like:
761 ///
762 /// 0-3  reserved
763 /// 4-6  symbol kind
764 /// 7    0 == global, 1 == static
765 ///
766 /// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
767 /// offset of the cu within the debug_info section stored in those 24 bits.
768 struct PubIndexEntryDescriptor {
769   GDBIndexEntryKind Kind;
770   GDBIndexEntryLinkage Linkage;
771   PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
772       : Kind(Kind), Linkage(Linkage) {}
773   /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
774       : Kind(Kind), Linkage(GIEL_EXTERNAL) {}
775   explicit PubIndexEntryDescriptor(uint8_t Value)
776       : Kind(static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >>
777                                             KIND_OFFSET)),
778         Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
779                                                   LINKAGE_OFFSET)) {}
780   uint8_t toBits() { return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET; }
781
782 private:
783   enum {
784     KIND_OFFSET = 4,
785     KIND_MASK = 7 << KIND_OFFSET,
786     LINKAGE_OFFSET = 7,
787     LINKAGE_MASK = 1 << LINKAGE_OFFSET
788   };
789 };
790
791
792 } // End of namespace dwarf
793
794 } // End of namespace llvm
795
796 #endif