LLVM 21.0.0git
Dwarf.h
Go to the documentation of this file.
1//===-- llvm/BinaryFormat/Dwarf.h ---Dwarf Constants-------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// This file contains constants used for implementing Dwarf
11/// debug support.
12///
13/// For details on the Dwarf specfication see the latest DWARF Debugging
14/// Information Format standard document on http://www.dwarfstd.org. This
15/// file often includes support for non-released standard features.
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef LLVM_BINARYFORMAT_DWARF_H
20#define LLVM_BINARYFORMAT_DWARF_H
21
25#include "llvm/Support/Format.h"
28
29#include <limits>
30
31namespace llvm {
32class StringRef;
33
34namespace dwarf {
35
36//===----------------------------------------------------------------------===//
37// DWARF constants as gleaned from the DWARF Debugging Information Format V.5
38// reference manual http://www.dwarfstd.org/.
39//
40
41// Do not mix the following two enumerations sets. DW_TAG_invalid changes the
42// enumeration base type.
43
45 /// LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
46 /// \{
47 DW_TAG_invalid = ~0U, ///< Tag for invalid results.
48 DW_VIRTUALITY_invalid = ~0U, ///< Virtuality for invalid results.
49 DW_MACINFO_invalid = ~0U, ///< Macinfo type for invalid results.
50 DW_APPLE_ENUM_KIND_invalid = ~0U, ///< Enum kind for invalid results.
51 /// \}
52
53 /// Special values for an initial length field.
54 /// \{
55 DW_LENGTH_lo_reserved = 0xfffffff0, ///< Lower bound of the reserved range.
56 DW_LENGTH_DWARF64 = 0xffffffff, ///< Indicator of 64-bit DWARF format.
57 DW_LENGTH_hi_reserved = 0xffffffff, ///< Upper bound of the reserved range.
58 /// \}
59
60 /// Other constants.
61 /// \{
62 DWARF_VERSION = 4, ///< Default dwarf version we output.
63 DW_PUBTYPES_VERSION = 2, ///< Section version number for .debug_pubtypes.
64 DW_PUBNAMES_VERSION = 2, ///< Section version number for .debug_pubnames.
65 DW_ARANGES_VERSION = 2, ///< Section version number for .debug_aranges.
66 /// \}
67
68 /// Identifiers we use to distinguish vendor extensions.
69 /// \{
70 DWARF_VENDOR_DWARF = 0, ///< Defined in v2 or later of the DWARF standard.
88 ///\}
89};
90
91/// Constants that define the DWARF format as 32 or 64 bit.
93
94/// Special ID values that distinguish a CIE from a FDE in DWARF CFI.
95/// Not inside an enum because a 64-bit value is needed.
96/// @{
97const uint32_t DW_CIE_ID = UINT32_MAX;
99/// @}
100
101/// Identifier of an invalid DIE offset in the .debug_info section.
102const uint32_t DW_INVALID_OFFSET = UINT32_MAX;
103
104enum Tag : uint16_t {
105#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) DW_TAG_##NAME = ID,
106#include "llvm/BinaryFormat/Dwarf.def"
109 DW_TAG_user_base = 0x1000 ///< Recommended base for user tags.
111
112inline bool isType(Tag T) {
113 switch (T) {
114 default:
115 return false;
116#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \
117 case DW_TAG_##NAME: \
118 return (KIND == DW_KIND_TYPE);
119#include "llvm/BinaryFormat/Dwarf.def"
120 }
121}
122
123/// Attributes.
125#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) DW_AT_##NAME = ID,
126#include "llvm/BinaryFormat/Dwarf.def"
129};
130
132#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) DW_FORM_##NAME = ID,
133#include "llvm/BinaryFormat/Dwarf.def"
134 DW_FORM_lo_user = 0x1f00, ///< Not specified by DWARF.
135};
136
138#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
139 DW_OP_##NAME = ID,
140#include "llvm/BinaryFormat/Dwarf.def"
143 DW_OP_LLVM_fragment = 0x1000, ///< Only used in LLVM metadata.
144 DW_OP_LLVM_convert = 0x1001, ///< Only used in LLVM metadata.
145 DW_OP_LLVM_tag_offset = 0x1002, ///< Only used in LLVM metadata.
146 DW_OP_LLVM_entry_value = 0x1003, ///< Only used in LLVM metadata.
147 DW_OP_LLVM_implicit_pointer = 0x1004, ///< Only used in LLVM metadata.
148 DW_OP_LLVM_arg = 0x1005, ///< Only used in LLVM metadata.
149 DW_OP_LLVM_extract_bits_sext = 0x1006, ///< Only used in LLVM metadata.
150 DW_OP_LLVM_extract_bits_zext = 0x1007, ///< Only used in LLVM metadata.
151};
152
154#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) DW_OP_LLVM_##NAME = ID,
155#include "llvm/BinaryFormat/Dwarf.def"
156};
157
159#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) DW_ATE_##NAME = ID,
160#include "llvm/BinaryFormat/Dwarf.def"
162 DW_ATE_hi_user = 0xff
164
166 // Decimal sign attribute values
173
175 // Endianity attribute values
176#define HANDLE_DW_END(ID, NAME) DW_END_##NAME = ID,
177#include "llvm/BinaryFormat/Dwarf.def"
179 DW_END_hi_user = 0xff
181
183 // Accessibility codes
186 DW_ACCESS_private = 0x03
188
190 // Visibility codes
193 DW_VIS_qualified = 0x03
195
197#define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID,
198#include "llvm/BinaryFormat/Dwarf.def"
199 DW_VIRTUALITY_max = 0x02
201
203#define HANDLE_DW_APPLE_ENUM_KIND(ID, NAME) DW_APPLE_ENUM_KIND_##NAME = ID,
204#include "llvm/BinaryFormat/Dwarf.def"
207
209#define HANDLE_DW_DEFAULTED(ID, NAME) DW_DEFAULTED_##NAME = ID,
210#include "llvm/BinaryFormat/Dwarf.def"
211 DW_DEFAULTED_max = 0x02
213
215#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
216 DW_LANG_##NAME = ID,
217#include "llvm/BinaryFormat/Dwarf.def"
219 DW_LANG_hi_user = 0xffff
221
223#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) DW_LNAME_##NAME = ID,
224#include "llvm/BinaryFormat/Dwarf.def"
225};
226
227/// Convert a DWARF 6 pair of language name and version to a DWARF 5 DW_LANG.
228/// If the version number doesn't exactly match a known version it is
229/// rounded up to the next-highest known version number.
230inline std::optional<SourceLanguage> toDW_LANG(SourceLanguageName name,
231 uint32_t version) {
232 switch (name) {
233 case DW_LNAME_Ada: // YYYY
234 if (version <= 1983)
235 return DW_LANG_Ada83;
236 if (version <= 1995)
237 return DW_LANG_Ada95;
238 if (version <= 2005)
239 return DW_LANG_Ada2005;
240 if (version <= 2012)
241 return DW_LANG_Ada2012;
242 return {};
243 case DW_LNAME_BLISS:
244 return DW_LANG_BLISS;
245 case DW_LNAME_C: // YYYYMM, K&R 000000
246 if (version == 0)
247 return DW_LANG_C;
248 if (version <= 198912)
249 return DW_LANG_C89;
250 if (version <= 199901)
251 return DW_LANG_C99;
252 if (version <= 201112)
253 return DW_LANG_C11;
254 if (version <= 201710)
255 return DW_LANG_C17;
256 return {};
257 case DW_LNAME_C_plus_plus: // YYYYMM
258 if (version == 0)
259 return DW_LANG_C_plus_plus;
260 if (version <= 199711)
261 return DW_LANG_C_plus_plus;
262 if (version <= 200310)
263 return DW_LANG_C_plus_plus_03;
264 if (version <= 201103)
265 return DW_LANG_C_plus_plus_11;
266 if (version <= 201402)
267 return DW_LANG_C_plus_plus_14;
268 if (version <= 201703)
269 return DW_LANG_C_plus_plus_17;
270 if (version <= 202002)
271 return DW_LANG_C_plus_plus_20;
272 return {};
273 case DW_LNAME_Cobol: // YYYY
274 if (version <= 1974)
275 return DW_LANG_Cobol74;
276 if (version <= 1985)
277 return DW_LANG_Cobol85;
278 return {};
279 case DW_LNAME_Crystal:
280 return DW_LANG_Crystal;
281 case DW_LNAME_D:
282 return DW_LANG_D;
283 case DW_LNAME_Dylan:
284 return DW_LANG_Dylan;
285 case DW_LNAME_Fortran: // YYYY
286 if (version <= 1977)
287 return DW_LANG_Fortran77;
288 if (version <= 1990)
289 return DW_LANG_Fortran90;
290 if (version <= 1995)
291 return DW_LANG_Fortran95;
292 if (version <= 2003)
293 return DW_LANG_Fortran03;
294 if (version <= 2008)
295 return DW_LANG_Fortran08;
296 if (version <= 2018)
297 return DW_LANG_Fortran18;
298 return {};
299 case DW_LNAME_Go:
300 return DW_LANG_Go;
301 case DW_LNAME_Haskell:
302 return DW_LANG_Haskell;
303 // case DW_LNAME_HIP:
304 // return DW_LANG_HIP;
305 case DW_LNAME_Java:
306 return DW_LANG_Java;
307 case DW_LNAME_Julia:
308 return DW_LANG_Julia;
309 case DW_LNAME_Kotlin:
310 return DW_LANG_Kotlin;
311 case DW_LNAME_Modula2:
312 return DW_LANG_Modula2;
313 case DW_LNAME_Modula3:
314 return DW_LANG_Modula3;
315 case DW_LNAME_ObjC:
316 return DW_LANG_ObjC;
317 case DW_LNAME_ObjC_plus_plus:
318 return DW_LANG_ObjC_plus_plus;
319 case DW_LNAME_OCaml:
320 return DW_LANG_OCaml;
321 case DW_LNAME_OpenCL_C:
322 return DW_LANG_OpenCL;
323 case DW_LNAME_Pascal:
324 return DW_LANG_Pascal83;
325 case DW_LNAME_PLI:
326 return DW_LANG_PLI;
327 case DW_LNAME_Python:
328 return DW_LANG_Python;
329 case DW_LNAME_RenderScript:
330 return DW_LANG_RenderScript;
331 case DW_LNAME_Rust:
332 return DW_LANG_Rust;
333 case DW_LNAME_Swift:
334 return DW_LANG_Swift;
335 case DW_LNAME_UPC:
336 return DW_LANG_UPC;
337 case DW_LNAME_Zig:
338 return DW_LANG_Zig;
339 case DW_LNAME_Assembly:
340 return DW_LANG_Assembly;
341 case DW_LNAME_C_sharp:
342 return DW_LANG_C_sharp;
343 case DW_LNAME_Mojo:
344 return DW_LANG_Mojo;
345 case DW_LNAME_GLSL:
346 return DW_LANG_GLSL;
347 case DW_LNAME_GLSL_ES:
348 return DW_LANG_GLSL_ES;
349 case DW_LNAME_HLSL:
350 return DW_LANG_HLSL;
351 case DW_LNAME_OpenCL_CPP:
352 return DW_LANG_OpenCL_CPP;
353 case DW_LNAME_CPP_for_OpenCL:
354 return {};
355 case DW_LNAME_SYCL:
356 return DW_LANG_SYCL;
357 case DW_LNAME_Ruby:
358 return DW_LANG_Ruby;
359 case DW_LNAME_Move:
360 return DW_LANG_Move;
361 case DW_LNAME_Hylo:
362 return DW_LANG_Hylo;
363 case DW_LNAME_Metal:
364 return DW_LANG_Metal;
365 }
366 return {};
367}
368
369/// Convert a DWARF 5 DW_LANG to a DWARF 6 pair of language name and version.
370inline std::optional<std::pair<SourceLanguageName, uint32_t>>
372 switch (language) {
373 case DW_LANG_Ada83:
374 return {{DW_LNAME_Ada, 1983}};
375 case DW_LANG_Ada95:
376 return {{DW_LNAME_Ada, 1995}};
377 case DW_LANG_Ada2005:
378 return {{DW_LNAME_Ada, 2005}};
379 case DW_LANG_Ada2012:
380 return {{DW_LNAME_Ada, 2012}};
381 case DW_LANG_BLISS:
382 return {{DW_LNAME_BLISS, 0}};
383 case DW_LANG_C:
384 return {{DW_LNAME_C, 0}};
385 case DW_LANG_C89:
386 return {{DW_LNAME_C, 198912}};
387 case DW_LANG_C99:
388 return {{DW_LNAME_C, 199901}};
389 case DW_LANG_C11:
390 return {{DW_LNAME_C, 201112}};
391 case DW_LANG_C17:
392 return {{DW_LNAME_C, 201712}};
393 case DW_LANG_C_plus_plus:
394 return {{DW_LNAME_C_plus_plus, 0}};
395 case DW_LANG_C_plus_plus_03:
396 return {{DW_LNAME_C_plus_plus, 200310}};
397 case DW_LANG_C_plus_plus_11:
398 return {{DW_LNAME_C_plus_plus, 201103}};
399 case DW_LANG_C_plus_plus_14:
400 return {{DW_LNAME_C_plus_plus, 201402}};
401 case DW_LANG_C_plus_plus_17:
402 return {{DW_LNAME_C_plus_plus, 201703}};
403 case DW_LANG_C_plus_plus_20:
404 return {{DW_LNAME_C_plus_plus, 202002}};
405 case DW_LANG_Cobol74:
406 return {{DW_LNAME_Cobol, 1974}};
407 case DW_LANG_Cobol85:
408 return {{DW_LNAME_Cobol, 1985}};
409 case DW_LANG_Crystal:
410 return {{DW_LNAME_Crystal, 0}};
411 case DW_LANG_D:
412 return {{DW_LNAME_D, 0}};
413 case DW_LANG_Dylan:
414 return {{DW_LNAME_Dylan, 0}};
415 case DW_LANG_Fortran77:
416 return {{DW_LNAME_Fortran, 1977}};
417 case DW_LANG_Fortran90:
418 return {{DW_LNAME_Fortran, 1990}};
419 case DW_LANG_Fortran95:
420 return {{DW_LNAME_Fortran, 1995}};
421 case DW_LANG_Fortran03:
422 return {{DW_LNAME_Fortran, 2003}};
423 case DW_LANG_Fortran08:
424 return {{DW_LNAME_Fortran, 2008}};
425 case DW_LANG_Fortran18:
426 return {{DW_LNAME_Fortran, 2018}};
427 case DW_LANG_Go:
428 return {{DW_LNAME_Go, 0}};
429 case DW_LANG_Haskell:
430 return {{DW_LNAME_Haskell, 0}};
431 case DW_LANG_HIP:
432 return {}; // return {{DW_LNAME_HIP, 0}};
433 case DW_LANG_Java:
434 return {{DW_LNAME_Java, 0}};
435 case DW_LANG_Julia:
436 return {{DW_LNAME_Julia, 0}};
437 case DW_LANG_Kotlin:
438 return {{DW_LNAME_Kotlin, 0}};
439 case DW_LANG_Modula2:
440 return {{DW_LNAME_Modula2, 0}};
441 case DW_LANG_Modula3:
442 return {{DW_LNAME_Modula3, 0}};
443 case DW_LANG_ObjC:
444 return {{DW_LNAME_ObjC, 0}};
445 case DW_LANG_ObjC_plus_plus:
446 return {{DW_LNAME_ObjC_plus_plus, 0}};
447 case DW_LANG_OCaml:
448 return {{DW_LNAME_OCaml, 0}};
449 case DW_LANG_OpenCL:
450 return {{DW_LNAME_OpenCL_C, 0}};
451 case DW_LANG_Pascal83:
452 return {{DW_LNAME_Pascal, 1983}};
453 case DW_LANG_PLI:
454 return {{DW_LNAME_PLI, 0}};
455 case DW_LANG_Python:
456 return {{DW_LNAME_Python, 0}};
457 case DW_LANG_RenderScript:
458 case DW_LANG_GOOGLE_RenderScript:
459 return {{DW_LNAME_RenderScript, 0}};
460 case DW_LANG_Rust:
461 return {{DW_LNAME_Rust, 0}};
462 case DW_LANG_Swift:
463 return {{DW_LNAME_Swift, 0}};
464 case DW_LANG_UPC:
465 return {{DW_LNAME_UPC, 0}};
466 case DW_LANG_Zig:
467 return {{DW_LNAME_Zig, 0}};
468 case DW_LANG_Assembly:
469 case DW_LANG_Mips_Assembler:
470 return {{DW_LNAME_Assembly, 0}};
471 case DW_LANG_C_sharp:
472 return {{DW_LNAME_C_sharp, 0}};
473 case DW_LANG_Mojo:
474 return {{DW_LNAME_Mojo, 0}};
475 case DW_LANG_GLSL:
476 return {{DW_LNAME_GLSL, 0}};
477 case DW_LANG_GLSL_ES:
478 return {{DW_LNAME_GLSL_ES, 0}};
479 case DW_LANG_HLSL:
480 return {{DW_LNAME_HLSL, 0}};
481 case DW_LANG_OpenCL_CPP:
482 return {{DW_LNAME_OpenCL_CPP, 0}};
483 case DW_LANG_SYCL:
484 return {{DW_LNAME_SYCL, 0}};
485 case DW_LANG_Ruby:
486 return {{DW_LNAME_Ruby, 0}};
487 case DW_LANG_Move:
488 return {{DW_LNAME_Move, 0}};
489 case DW_LANG_Hylo:
490 return {{DW_LNAME_Hylo, 0}};
491 case DW_LANG_Metal:
492 return {{DW_LNAME_Metal, 0}};
493 case DW_LANG_BORLAND_Delphi:
494 case DW_LANG_CPP_for_OpenCL:
495 case DW_LANG_lo_user:
496 case DW_LANG_hi_user:
497 return {};
498 }
499 return {};
500}
501
503
505 bool result = false;
506 // Deliberately enumerate all the language options so we get a warning when
507 // new language options are added (-Wswitch) that'll hopefully help keep this
508 // switch up-to-date when new C++ versions are added.
509 switch (S) {
510 case DW_LANG_C_plus_plus:
511 case DW_LANG_C_plus_plus_03:
512 case DW_LANG_C_plus_plus_11:
513 case DW_LANG_C_plus_plus_14:
514 case DW_LANG_C_plus_plus_17:
515 case DW_LANG_C_plus_plus_20:
516 result = true;
517 break;
518 case DW_LANG_C89:
519 case DW_LANG_C:
520 case DW_LANG_Ada83:
521 case DW_LANG_Cobol74:
522 case DW_LANG_Cobol85:
523 case DW_LANG_Fortran77:
524 case DW_LANG_Fortran90:
525 case DW_LANG_Pascal83:
526 case DW_LANG_Modula2:
527 case DW_LANG_Java:
528 case DW_LANG_C99:
529 case DW_LANG_Ada95:
530 case DW_LANG_Fortran95:
531 case DW_LANG_PLI:
532 case DW_LANG_ObjC:
533 case DW_LANG_ObjC_plus_plus:
534 case DW_LANG_UPC:
535 case DW_LANG_D:
536 case DW_LANG_Python:
537 case DW_LANG_OpenCL:
538 case DW_LANG_Go:
539 case DW_LANG_Modula3:
540 case DW_LANG_Haskell:
541 case DW_LANG_OCaml:
542 case DW_LANG_Rust:
543 case DW_LANG_C11:
544 case DW_LANG_Swift:
545 case DW_LANG_Julia:
546 case DW_LANG_Dylan:
547 case DW_LANG_Fortran03:
548 case DW_LANG_Fortran08:
549 case DW_LANG_RenderScript:
550 case DW_LANG_BLISS:
551 case DW_LANG_Mips_Assembler:
552 case DW_LANG_GOOGLE_RenderScript:
553 case DW_LANG_BORLAND_Delphi:
554 case DW_LANG_lo_user:
555 case DW_LANG_hi_user:
556 case DW_LANG_Kotlin:
557 case DW_LANG_Zig:
558 case DW_LANG_Crystal:
559 case DW_LANG_C17:
560 case DW_LANG_Fortran18:
561 case DW_LANG_Ada2005:
562 case DW_LANG_Ada2012:
563 case DW_LANG_HIP:
564 case DW_LANG_Assembly:
565 case DW_LANG_C_sharp:
566 case DW_LANG_Mojo:
567 case DW_LANG_GLSL:
568 case DW_LANG_GLSL_ES:
569 case DW_LANG_HLSL:
570 case DW_LANG_OpenCL_CPP:
571 case DW_LANG_CPP_for_OpenCL:
572 case DW_LANG_SYCL:
573 case DW_LANG_Ruby:
574 case DW_LANG_Move:
575 case DW_LANG_Hylo:
576 case DW_LANG_Metal:
577 result = false;
578 break;
579 }
580
581 return result;
582}
583
584inline bool isFortran(SourceLanguage S) {
585 bool result = false;
586 // Deliberately enumerate all the language options so we get a warning when
587 // new language options are added (-Wswitch) that'll hopefully help keep this
588 // switch up-to-date when new Fortran versions are added.
589 switch (S) {
590 case DW_LANG_Fortran77:
591 case DW_LANG_Fortran90:
592 case DW_LANG_Fortran95:
593 case DW_LANG_Fortran03:
594 case DW_LANG_Fortran08:
595 case DW_LANG_Fortran18:
596 result = true;
597 break;
598 case DW_LANG_C89:
599 case DW_LANG_C:
600 case DW_LANG_Ada83:
601 case DW_LANG_C_plus_plus:
602 case DW_LANG_Cobol74:
603 case DW_LANG_Cobol85:
604 case DW_LANG_Pascal83:
605 case DW_LANG_Modula2:
606 case DW_LANG_Java:
607 case DW_LANG_C99:
608 case DW_LANG_Ada95:
609 case DW_LANG_PLI:
610 case DW_LANG_ObjC:
611 case DW_LANG_ObjC_plus_plus:
612 case DW_LANG_UPC:
613 case DW_LANG_D:
614 case DW_LANG_Python:
615 case DW_LANG_OpenCL:
616 case DW_LANG_Go:
617 case DW_LANG_Modula3:
618 case DW_LANG_Haskell:
619 case DW_LANG_C_plus_plus_03:
620 case DW_LANG_C_plus_plus_11:
621 case DW_LANG_OCaml:
622 case DW_LANG_Rust:
623 case DW_LANG_C11:
624 case DW_LANG_Swift:
625 case DW_LANG_Julia:
626 case DW_LANG_Dylan:
627 case DW_LANG_C_plus_plus_14:
628 case DW_LANG_RenderScript:
629 case DW_LANG_BLISS:
630 case DW_LANG_Mips_Assembler:
631 case DW_LANG_GOOGLE_RenderScript:
632 case DW_LANG_BORLAND_Delphi:
633 case DW_LANG_lo_user:
634 case DW_LANG_hi_user:
635 case DW_LANG_Kotlin:
636 case DW_LANG_Zig:
637 case DW_LANG_Crystal:
638 case DW_LANG_C_plus_plus_17:
639 case DW_LANG_C_plus_plus_20:
640 case DW_LANG_C17:
641 case DW_LANG_Ada2005:
642 case DW_LANG_Ada2012:
643 case DW_LANG_HIP:
644 case DW_LANG_Assembly:
645 case DW_LANG_C_sharp:
646 case DW_LANG_Mojo:
647 case DW_LANG_GLSL:
648 case DW_LANG_GLSL_ES:
649 case DW_LANG_HLSL:
650 case DW_LANG_OpenCL_CPP:
651 case DW_LANG_CPP_for_OpenCL:
652 case DW_LANG_SYCL:
653 case DW_LANG_Ruby:
654 case DW_LANG_Move:
655 case DW_LANG_Hylo:
656 case DW_LANG_Metal:
657 result = false;
658 break;
659 }
660
661 return result;
662}
663
664inline bool isC(SourceLanguage S) {
665 // Deliberately enumerate all the language options so we get a warning when
666 // new language options are added (-Wswitch) that'll hopefully help keep this
667 // switch up-to-date when new C++ versions are added.
668 switch (S) {
669 case DW_LANG_C11:
670 case DW_LANG_C17:
671 case DW_LANG_C89:
672 case DW_LANG_C99:
673 case DW_LANG_C:
674 case DW_LANG_ObjC:
675 return true;
676 case DW_LANG_C_plus_plus:
677 case DW_LANG_C_plus_plus_03:
678 case DW_LANG_C_plus_plus_11:
679 case DW_LANG_C_plus_plus_14:
680 case DW_LANG_C_plus_plus_17:
681 case DW_LANG_C_plus_plus_20:
682 case DW_LANG_Ada83:
683 case DW_LANG_Cobol74:
684 case DW_LANG_Cobol85:
685 case DW_LANG_Fortran77:
686 case DW_LANG_Fortran90:
687 case DW_LANG_Pascal83:
688 case DW_LANG_Modula2:
689 case DW_LANG_Java:
690 case DW_LANG_Ada95:
691 case DW_LANG_Fortran95:
692 case DW_LANG_PLI:
693 case DW_LANG_ObjC_plus_plus:
694 case DW_LANG_UPC:
695 case DW_LANG_D:
696 case DW_LANG_Python:
697 case DW_LANG_OpenCL:
698 case DW_LANG_Go:
699 case DW_LANG_Modula3:
700 case DW_LANG_Haskell:
701 case DW_LANG_OCaml:
702 case DW_LANG_Rust:
703 case DW_LANG_Swift:
704 case DW_LANG_Julia:
705 case DW_LANG_Dylan:
706 case DW_LANG_Fortran03:
707 case DW_LANG_Fortran08:
708 case DW_LANG_RenderScript:
709 case DW_LANG_BLISS:
710 case DW_LANG_Mips_Assembler:
711 case DW_LANG_GOOGLE_RenderScript:
712 case DW_LANG_BORLAND_Delphi:
713 case DW_LANG_lo_user:
714 case DW_LANG_hi_user:
715 case DW_LANG_Kotlin:
716 case DW_LANG_Zig:
717 case DW_LANG_Crystal:
718 case DW_LANG_Fortran18:
719 case DW_LANG_Ada2005:
720 case DW_LANG_Ada2012:
721 case DW_LANG_HIP:
722 case DW_LANG_Assembly:
723 case DW_LANG_C_sharp:
724 case DW_LANG_Mojo:
725 case DW_LANG_GLSL:
726 case DW_LANG_GLSL_ES:
727 case DW_LANG_HLSL:
728 case DW_LANG_OpenCL_CPP:
729 case DW_LANG_CPP_for_OpenCL:
730 case DW_LANG_SYCL:
731 case DW_LANG_Ruby:
732 case DW_LANG_Move:
733 case DW_LANG_Hylo:
734 case DW_LANG_Metal:
735 return false;
736 }
737 llvm_unreachable("Unknown language kind.");
738}
739
741 return isFortran(S) ? DW_ATE_signed : DW_ATE_unsigned;
742}
743
745 // Identifier case codes
751
753// Calling convention codes
754#define HANDLE_DW_CC(ID, NAME) DW_CC_##NAME = ID,
755#include "llvm/BinaryFormat/Dwarf.def"
757 DW_CC_hi_user = 0xff
759
761 // Inline codes
767
769 // Array ordering
771 DW_ORD_col_major = 0x01
773
775 // Discriminant descriptor values
777 DW_DSC_range = 0x01
779
780/// Line Number Standard Opcode Encodings.
782#define HANDLE_DW_LNS(ID, NAME) DW_LNS_##NAME = ID,
783#include "llvm/BinaryFormat/Dwarf.def"
784};
785
786/// Line Number Extended Opcode Encodings.
788#define HANDLE_DW_LNE(ID, NAME) DW_LNE_##NAME = ID,
789#include "llvm/BinaryFormat/Dwarf.def"
791 DW_LNE_hi_user = 0xff
793
795#define HANDLE_DW_LNCT(ID, NAME) DW_LNCT_##NAME = ID,
796#include "llvm/BinaryFormat/Dwarf.def"
799};
800
802 // Macinfo Type Encodings
809
810/// DWARF v5 macro information entry type encodings.
812#define HANDLE_DW_MACRO(ID, NAME) DW_MACRO_##NAME = ID,
813#include "llvm/BinaryFormat/Dwarf.def"
815 DW_MACRO_hi_user = 0xff
817
818/// GNU .debug_macro macro information entry type encodings.
820#define HANDLE_DW_MACRO_GNU(ID, NAME) DW_MACRO_GNU_##NAME = ID,
821#include "llvm/BinaryFormat/Dwarf.def"
825
826/// DWARF v5 range list entry encoding values.
828#define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID,
829#include "llvm/BinaryFormat/Dwarf.def"
830};
831
832/// DWARF v5 loc list entry encoding values.
834#define HANDLE_DW_LLE(ID, NAME) DW_LLE_##NAME = ID,
835#include "llvm/BinaryFormat/Dwarf.def"
836};
837
838/// Call frame instruction encodings.
840#define HANDLE_DW_CFA(ID, NAME) DW_CFA_##NAME = ID,
841#define HANDLE_DW_CFA_PRED(ID, NAME, ARCH) DW_CFA_##NAME = ID,
842#include "llvm/BinaryFormat/Dwarf.def"
844
846 DW_CFA_hi_user = 0x3f
848
850 // Children flag
853
870 DW_EH_PE_indirect = 0x80
872
873/// Constants for the DW_APPLE_PROPERTY_attributes attribute.
874/// Keep this list in sync with clang's DeclObjCCommon.h
875/// ObjCPropertyAttribute::Kind!
877#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
878#include "llvm/BinaryFormat/Dwarf.def"
879};
880
881/// Constants for unit types in DWARF v5.
882enum UnitType : unsigned char {
883#define HANDLE_DW_UT(ID, NAME) DW_UT_##NAME = ID,
884#include "llvm/BinaryFormat/Dwarf.def"
886 DW_UT_hi_user = 0xff
888
889enum Index {
890#define HANDLE_DW_IDX(ID, NAME) DW_IDX_##NAME = ID,
891#include "llvm/BinaryFormat/Dwarf.def"
893 DW_IDX_hi_user = 0x3fff
895
897 switch (UnitType) {
898 case DW_UT_compile:
899 case DW_UT_type:
900 case DW_UT_partial:
901 case DW_UT_skeleton:
902 case DW_UT_split_compile:
903 case DW_UT_split_type:
904 return true;
905 default:
906 return false;
907 }
908}
909
910inline bool isUnitType(dwarf::Tag T) {
911 switch (T) {
912 case DW_TAG_compile_unit:
913 case DW_TAG_type_unit:
914 case DW_TAG_partial_unit:
915 case DW_TAG_skeleton_unit:
916 return true;
917 default:
918 return false;
919 }
920}
921
922// Constants for the DWARF v5 Accelerator Table Proposal
924 // Data layout descriptors.
925 DW_ATOM_null = 0u, /// Marker as the end of a list of atoms.
926 DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
927 DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
928 // item in question.
929 DW_ATOM_die_tag = 3u, // A tag entry.
930 DW_ATOM_type_flags = 4u, // Set of flags for a type.
931
932 DW_ATOM_type_type_flags = 5u, // Dsymutil type extension.
933 DW_ATOM_qual_name_hash = 6u, // Dsymutil qualified hash extension.
934
935 // DW_ATOM_type_flags values.
936
937 // Always set for C++, only set for ObjC if this is the @implementation for a
938 // class.
940
941 // Hash functions.
942
943 // Daniel J. Bernstein hash.
946
947// Return a suggested bucket count for the DWARF v5 Accelerator Table.
949 if (UniqueHashCount > 1024)
950 return UniqueHashCount / 4;
951 if (UniqueHashCount > 16)
952 return UniqueHashCount / 2;
953 return std::max<uint32_t>(UniqueHashCount, 1);
954}
955
956// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
967
969
970/// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
971///
972/// All these functions map their argument's value back to the
973/// corresponding enumerator name or return an empty StringRef if the value
974/// isn't known.
975///
976/// @{
977StringRef TagString(unsigned Tag);
978StringRef ChildrenString(unsigned Children);
980StringRef FormEncodingString(unsigned Encoding);
981StringRef OperationEncodingString(unsigned Encoding);
982StringRef SubOperationEncodingString(unsigned OpEncoding,
983 unsigned SubOpEncoding);
984StringRef AttributeEncodingString(unsigned Encoding);
985StringRef DecimalSignString(unsigned Sign);
988StringRef DefaultedMemberString(unsigned DefaultedEncodings);
989StringRef VisibilityString(unsigned Visibility);
990StringRef VirtualityString(unsigned Virtuality);
991StringRef EnumKindString(unsigned EnumKind);
992StringRef LanguageString(unsigned Language);
993StringRef CaseString(unsigned Case);
994StringRef ConventionString(unsigned Convention);
995StringRef InlineCodeString(unsigned Code);
996StringRef ArrayOrderString(unsigned Order);
997StringRef LNStandardString(unsigned Standard);
998StringRef LNExtendedString(unsigned Encoding);
999StringRef MacinfoString(unsigned Encoding);
1000StringRef MacroString(unsigned Encoding);
1001StringRef GnuMacroString(unsigned Encoding);
1002StringRef RangeListEncodingString(unsigned Encoding);
1003StringRef LocListEncodingString(unsigned Encoding);
1004StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch);
1006StringRef UnitTypeString(unsigned);
1007StringRef AtomTypeString(unsigned Atom);
1010StringRef IndexString(unsigned Idx);
1012StringRef FormatString(bool IsDWARF64);
1013StringRef RLEString(unsigned RLE);
1014/// @}
1015
1016/// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
1017///
1018/// These functions map their strings back to the corresponding enumeration
1019/// value or return 0 if there is none, except for these exceptions:
1020///
1021/// \li \a getTag() returns \a DW_TAG_invalid on invalid input.
1022/// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input.
1023/// \li \a getMacinfo() returns \a DW_MACINFO_invalid on invalid input.
1024///
1025/// @{
1026unsigned getTag(StringRef TagString);
1028unsigned getSubOperationEncoding(unsigned OpEncoding,
1034unsigned getAttributeEncoding(StringRef EncodingString);
1037/// @}
1038
1039/// \defgroup DwarfConstantsVersioning Dwarf version for constants
1040///
1041/// For constants defined by DWARF, returns the DWARF version when the constant
1042/// was first defined. For vendor extensions, if there is a version-related
1043/// policy for when to emit it, returns a version number for that policy.
1044/// Otherwise returns 0.
1045///
1046/// @{
1047unsigned TagVersion(Tag T);
1048unsigned AttributeVersion(Attribute A);
1049unsigned FormVersion(Form F);
1050unsigned OperationVersion(LocationAtom O);
1053/// @}
1054
1055/// \defgroup DwarfConstantsVendor Dwarf "vendor" for constants
1056///
1057/// These functions return an identifier describing "who" defined the constant,
1058/// either the DWARF standard itself or the vendor who defined the extension.
1059///
1060/// @{
1061unsigned TagVendor(Tag T);
1062unsigned AttributeVendor(Attribute A);
1063unsigned FormVendor(Form F);
1064unsigned OperationVendor(LocationAtom O);
1066unsigned LanguageVendor(SourceLanguage L);
1067/// @}
1068
1069/// The number of operands for the given LocationAtom.
1070std::optional<unsigned> OperationOperands(LocationAtom O);
1071
1072/// The arity of the given LocationAtom. This is the number of elements on the
1073/// stack this operation operates on. Returns -1 if the arity is variable (e.g.
1074/// depending on the argument) or unknown.
1075std::optional<unsigned> OperationArity(LocationAtom O);
1076
1077std::optional<unsigned> LanguageLowerBound(SourceLanguage L);
1078
1079/// The size of a reference determined by the DWARF 32/64-bit format.
1081 switch (Format) {
1083 return 4;
1085 return 8;
1086 }
1087 llvm_unreachable("Invalid Format value");
1088}
1089
1090/// A helper struct providing information about the byte size of DW_FORM
1091/// values that vary in size depending on the DWARF version, address byte
1092/// size, or DWARF32/DWARF64.
1097 /// True if DWARF v2 output generally uses relocations for references
1098 /// to other .debug_* sections.
1100
1101 /// The definition of the size of form DW_FORM_ref_addr depends on the
1102 /// version. In DWARF v2 it's the size of an address; after that, it's the
1103 /// size of a reference.
1105 if (Version == 2)
1106 return AddrSize;
1107 return getDwarfOffsetByteSize();
1108 }
1109
1110 /// The size of a reference is determined by the DWARF 32/64-bit format.
1113 }
1114
1115 explicit operator bool() const { return Version && AddrSize; }
1116};
1117
1118/// Get the byte size of the unit length field depending on the DWARF format.
1120 switch (Format) {
1122 return 4;
1124 return 12;
1125 }
1126 llvm_unreachable("Invalid Format value");
1127}
1128
1129/// Get the fixed byte size for a given form.
1130///
1131/// If the form has a fixed byte size, then an Optional with a value will be
1132/// returned. If the form is always encoded using a variable length storage
1133/// format (ULEB or SLEB numbers or blocks) then std::nullopt will be returned.
1134///
1135/// \param Form DWARF form to get the fixed byte size for.
1136/// \param Params DWARF parameters to help interpret forms.
1137/// \returns std::optional<uint8_t> value with the fixed byte size or
1138/// std::nullopt if \p Form doesn't have a fixed byte size.
1139std::optional<uint8_t> getFixedFormByteSize(dwarf::Form Form,
1140 FormParams Params);
1141
1142/// Tells whether the specified form is defined in the specified version,
1143/// or is an extension if extensions are allowed.
1144bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk = true);
1145
1146/// Returns the symbolic string representing Val when used as a value
1147/// for attribute Attr.
1148StringRef AttributeValueString(uint16_t Attr, unsigned Val);
1149
1150/// Returns the symbolic string representing Val when used as a value
1151/// for atom Atom.
1152StringRef AtomValueString(uint16_t Atom, unsigned Val);
1153
1154/// Describes an entry of the various gnu_pub* debug sections.
1155///
1156/// The gnu_pub* kind looks like:
1157///
1158/// 0-3 reserved
1159/// 4-6 symbol kind
1160/// 7 0 == global, 1 == static
1161///
1162/// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
1163/// offset of the cu within the debug_info section stored in those 24 bits.
1168 : Kind(Kind), Linkage(Linkage) {}
1172 : Kind(
1173 static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >> KIND_OFFSET)),
1174 Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
1175 LINKAGE_OFFSET)) {}
1176 uint8_t toBits() const {
1177 return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET;
1178 }
1179
1180private:
1181 enum {
1182 KIND_OFFSET = 4,
1183 KIND_MASK = 7 << KIND_OFFSET,
1184 LINKAGE_OFFSET = 7,
1185 LINKAGE_MASK = 1 << LINKAGE_OFFSET
1186 };
1187};
1188
1189template <typename Enum> struct EnumTraits : public std::false_type {};
1190
1191template <> struct EnumTraits<Attribute> : public std::true_type {
1192 static constexpr char Type[3] = "AT";
1193 static constexpr StringRef (*StringFn)(unsigned) = &AttributeString;
1194};
1195
1196template <> struct EnumTraits<Form> : public std::true_type {
1197 static constexpr char Type[5] = "FORM";
1198 static constexpr StringRef (*StringFn)(unsigned) = &FormEncodingString;
1199};
1200
1201template <> struct EnumTraits<Index> : public std::true_type {
1202 static constexpr char Type[4] = "IDX";
1203 static constexpr StringRef (*StringFn)(unsigned) = &IndexString;
1204};
1205
1206template <> struct EnumTraits<Tag> : public std::true_type {
1207 static constexpr char Type[4] = "TAG";
1208 static constexpr StringRef (*StringFn)(unsigned) = &TagString;
1209};
1210
1211template <> struct EnumTraits<LineNumberOps> : public std::true_type {
1212 static constexpr char Type[4] = "LNS";
1213 static constexpr StringRef (*StringFn)(unsigned) = &LNStandardString;
1214};
1215
1216template <> struct EnumTraits<LocationAtom> : public std::true_type {
1217 static constexpr char Type[3] = "OP";
1218 static constexpr StringRef (*StringFn)(unsigned) = &OperationEncodingString;
1219};
1220
1222 return std::numeric_limits<uint64_t>::max() >> (8 - AddressByteSize) * 8;
1223}
1224
1225} // End of namespace dwarf
1226
1227/// Dwarf constants format_provider
1228///
1229/// Specialization of the format_provider template for dwarf enums. Unlike the
1230/// dumping functions above, these format unknown enumerator values as
1231/// DW_TYPE_unknown_1234 (e.g. DW_TAG_unknown_ffff).
1232template <typename Enum>
1233struct format_provider<Enum, std::enable_if_t<dwarf::EnumTraits<Enum>::value>> {
1234 static void format(const Enum &E, raw_ostream &OS, StringRef Style) {
1236 if (Str.empty()) {
1237 OS << "DW_" << dwarf::EnumTraits<Enum>::Type << "_unknown_"
1238 << llvm::format("%x", E);
1239 } else
1240 OS << Str;
1241 }
1242};
1243} // End of namespace llvm
1244
1245#endif
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DXIL Finalize Linkage
DXIL Resource Access
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
#define F(x, y, z)
Definition: MD5.cpp:55
static const char * name
Definition: SMEABIPass.cpp:46
endianness Endian
raw_pwrite_stream & OS
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
StringRef LNExtendedString(unsigned Encoding)
Definition: Dwarf.cpp:542
StringRef RangeListEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:610
StringRef CaseString(unsigned Case)
Definition: Dwarf.cpp:475
StringRef VisibilityString(unsigned Visibility)
Definition: Dwarf.cpp:362
StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
Definition: Dwarf.cpp:725
StringRef AttributeString(unsigned Attribute)
Definition: Dwarf.cpp:72
StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch)
Definition: Dwarf.cpp:632
StringRef FormEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:105
StringRef ArrayOrderString(unsigned Order)
Definition: Dwarf.cpp:521
StringRef MacroString(unsigned Encoding)
Definition: Dwarf.cpp:582
StringRef EnumKindString(unsigned EnumKind)
Definition: Dwarf.cpp:393
StringRef LocListEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:621
StringRef IndexString(unsigned Idx)
Definition: Dwarf.cpp:781
StringRef RLEString(unsigned RLE)
Definition: Dwarf.cpp:903
StringRef SubOperationEncodingString(unsigned OpEncoding, unsigned SubOpEncoding)
Definition: Dwarf.cpp:202
StringRef LanguageString(unsigned Language)
Definition: Dwarf.cpp:412
StringRef DecimalSignString(unsigned Sign)
Definition: Dwarf.cpp:304
StringRef VirtualityString(unsigned Virtuality)
Definition: Dwarf.cpp:374
StringRef AttributeEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:263
StringRef ChildrenString(unsigned Children)
Definition: Dwarf.cpp:62
StringRef ApplePropertyString(unsigned)
Definition: Dwarf.cpp:661
StringRef AtomTypeString(unsigned Atom)
Definition: Dwarf.cpp:683
StringRef FormatString(DwarfFormat Format)
Definition: Dwarf.cpp:889
StringRef GnuMacroString(unsigned Encoding)
Definition: Dwarf.cpp:593
StringRef EndianityString(unsigned Endian)
Definition: Dwarf.cpp:320
StringRef ConventionString(unsigned Convention)
Definition: Dwarf.cpp:489
StringRef MacinfoString(unsigned Encoding)
Definition: Dwarf.cpp:553
StringRef OperationEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:138
StringRef UnitTypeString(unsigned)
Definition: Dwarf.cpp:672
StringRef InlineCodeString(unsigned Code)
Definition: Dwarf.cpp:507
StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
Definition: Dwarf.cpp:702
StringRef TagString(unsigned Tag)
Definition: Dwarf.cpp:21
StringRef LNStandardString(unsigned Standard)
Definition: Dwarf.cpp:531
StringRef AccessibilityString(unsigned Access)
Definition: Dwarf.cpp:336
StringRef DefaultedMemberString(unsigned DefaultedEncodings)
Definition: Dwarf.cpp:349
unsigned getSubOperationEncoding(unsigned OpEncoding, StringRef SubOperationEncodingString)
Definition: Dwarf.cpp:209
unsigned getOperationEncoding(StringRef OperationEncodingString)
Definition: Dwarf.cpp:165
unsigned getAttributeEncoding(StringRef EncodingString)
Definition: Dwarf.cpp:274
unsigned getTag(StringRef TagString)
Definition: Dwarf.cpp:32
unsigned getCallingConvention(StringRef LanguageString)
Definition: Dwarf.cpp:500
unsigned getLanguage(StringRef LanguageString)
Definition: Dwarf.cpp:423
unsigned getVirtuality(StringRef VirtualityString)
Definition: Dwarf.cpp:385
unsigned getEnumKind(StringRef EnumKindString)
Definition: Dwarf.cpp:404
unsigned getMacro(StringRef MacroString)
Definition: Dwarf.cpp:604
unsigned getMacinfo(StringRef MacinfoString)
Definition: Dwarf.cpp:572
unsigned AttributeEncodingVendor(TypeKind E)
Definition: Dwarf.cpp:293
unsigned FormVendor(Form F)
Definition: Dwarf.cpp:127
unsigned AttributeVendor(Attribute A)
Definition: Dwarf.cpp:94
unsigned OperationVendor(LocationAtom O)
Definition: Dwarf.cpp:252
unsigned TagVendor(Tag T)
Definition: Dwarf.cpp:51
unsigned LanguageVendor(SourceLanguage L)
Definition: Dwarf.cpp:442
unsigned OperationVersion(LocationAtom O)
Definition: Dwarf.cpp:215
unsigned AttributeVersion(Attribute A)
Definition: Dwarf.cpp:83
unsigned LanguageVersion(SourceLanguage L)
Definition: Dwarf.cpp:431
unsigned AttributeEncodingVersion(TypeKind E)
Definition: Dwarf.cpp:282
unsigned TagVersion(Tag T)
Definition: Dwarf.cpp:40
unsigned FormVersion(Form F)
Definition: Dwarf.cpp:116
#define UINT64_MAX
Definition: DataTypes.h:77
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
InlineAttribute
Definition: Dwarf.h:760
@ DW_INL_not_inlined
Definition: Dwarf.h:762
@ DW_INL_declared_not_inlined
Definition: Dwarf.h:764
@ DW_INL_inlined
Definition: Dwarf.h:763
@ DW_INL_declared_inlined
Definition: Dwarf.h:765
const uint32_t DW_CIE_ID
Special ID values that distinguish a CIE from a FDE in DWARF CFI.
Definition: Dwarf.h:97
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
Definition: Dwarf.h:1119
AccessAttribute
Definition: Dwarf.h:182
@ DW_ACCESS_private
Definition: Dwarf.h:186
@ DW_ACCESS_protected
Definition: Dwarf.h:185
@ DW_ACCESS_public
Definition: Dwarf.h:184
MacroEntryType
DWARF v5 macro information entry type encodings.
Definition: Dwarf.h:811
@ DW_MACRO_lo_user
Definition: Dwarf.h:814
@ DW_MACRO_hi_user
Definition: Dwarf.h:815
Attribute
Attributes.
Definition: Dwarf.h:124
@ DW_AT_hi_user
Definition: Dwarf.h:128
@ DW_AT_lo_user
Definition: Dwarf.h:127
std::optional< unsigned > LanguageLowerBound(SourceLanguage L)
Definition: Dwarf.cpp:454
LineNumberEntryFormat
Definition: Dwarf.h:794
@ DW_LNCT_lo_user
Definition: Dwarf.h:797
@ DW_LNCT_hi_user
Definition: Dwarf.h:798
StringRef AtomValueString(uint16_t Atom, unsigned Val)
Returns the symbolic string representing Val when used as a value for atom Atom.
Definition: Dwarf.cpp:770
DefaultedMemberAttribute
Definition: Dwarf.h:208
@ DW_DEFAULTED_max
Definition: Dwarf.h:211
SourceLanguageName
Definition: Dwarf.h:222
const uint64_t DW64_CIE_ID
Definition: Dwarf.h:98
std::optional< unsigned > OperationArity(LocationAtom O)
The arity of the given LocationAtom.
Definition: Dwarf.cpp:239
VisibilityAttribute
Definition: Dwarf.h:189
@ DW_VIS_local
Definition: Dwarf.h:191
@ DW_VIS_exported
Definition: Dwarf.h:192
@ DW_VIS_qualified
Definition: Dwarf.h:193
LlvmUserLocationAtom
Definition: Dwarf.h:153
ArrayDimensionOrdering
Definition: Dwarf.h:768
@ DW_ORD_row_major
Definition: Dwarf.h:770
@ DW_ORD_col_major
Definition: Dwarf.h:771
CallingConvention
Definition: Dwarf.h:752
@ DW_CC_lo_user
Definition: Dwarf.h:756
@ DW_CC_hi_user
Definition: Dwarf.h:757
LineNumberOps
Line Number Standard Opcode Encodings.
Definition: Dwarf.h:781
@ DW_ATE_hi_user
Definition: Dwarf.h:162
@ DW_ATE_lo_user
Definition: Dwarf.h:161
ApplePropertyAttributes
Constants for the DW_APPLE_PROPERTY_attributes attribute.
Definition: Dwarf.h:876
LoclistEntries
DWARF v5 loc list entry encoding values.
Definition: Dwarf.h:833
bool isFortran(SourceLanguage S)
Definition: Dwarf.h:584
bool isUnitType(uint8_t UnitType)
Definition: Dwarf.h:896
@ DW_IDX_lo_user
Definition: Dwarf.h:892
@ DW_IDX_hi_user
Definition: Dwarf.h:893
EnumKindAttribute
Definition: Dwarf.h:202
@ DW_APPLE_ENUM_KIND_max
Definition: Dwarf.h:205
GnuMacroEntryType
GNU .debug_macro macro information entry type encodings.
Definition: Dwarf.h:819
@ DW_MACRO_GNU_lo_user
Definition: Dwarf.h:822
@ DW_MACRO_GNU_hi_user
Definition: Dwarf.h:823
UnitType
Constants for unit types in DWARF v5.
Definition: Dwarf.h:882
@ DW_UT_lo_user
Definition: Dwarf.h:885
@ DW_UT_hi_user
Definition: Dwarf.h:886
@ DW_FORM_lo_user
Not specified by DWARF.
Definition: Dwarf.h:134
EndianityEncoding
Definition: Dwarf.h:174
@ DW_END_lo_user
Definition: Dwarf.h:178
@ DW_END_hi_user
Definition: Dwarf.h:179
bool isType(Tag T)
Definition: Dwarf.h:112
LocationAtom
Definition: Dwarf.h:137
@ DW_OP_LLVM_entry_value
Only used in LLVM metadata.
Definition: Dwarf.h:146
@ DW_OP_LLVM_implicit_pointer
Only used in LLVM metadata.
Definition: Dwarf.h:147
@ DW_OP_LLVM_extract_bits_zext
Only used in LLVM metadata.
Definition: Dwarf.h:150
@ DW_OP_lo_user
Definition: Dwarf.h:141
@ DW_OP_hi_user
Definition: Dwarf.h:142
@ DW_OP_LLVM_tag_offset
Only used in LLVM metadata.
Definition: Dwarf.h:145
@ DW_OP_LLVM_fragment
Only used in LLVM metadata.
Definition: Dwarf.h:143
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
Definition: Dwarf.h:148
@ DW_OP_LLVM_convert
Only used in LLVM metadata.
Definition: Dwarf.h:144
@ DW_OP_LLVM_extract_bits_sext
Only used in LLVM metadata.
Definition: Dwarf.h:149
SourceLanguage
Definition: Dwarf.h:214
@ DW_LANG_lo_user
Definition: Dwarf.h:218
@ DW_LANG_hi_user
Definition: Dwarf.h:219
CaseSensitivity
Definition: Dwarf.h:744
@ DW_ID_down_case
Definition: Dwarf.h:748
@ DW_ID_case_insensitive
Definition: Dwarf.h:749
@ DW_ID_case_sensitive
Definition: Dwarf.h:746
@ DW_ID_up_case
Definition: Dwarf.h:747
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:92
@ DWARF64
Definition: Dwarf.h:92
@ DWARF32
Definition: Dwarf.h:92
bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk=true)
Tells whether the specified form is defined in the specified version, or is an extension if extension...
Definition: Dwarf.cpp:880
std::optional< SourceLanguage > toDW_LANG(SourceLanguageName name, uint32_t version)
Convert a DWARF 6 pair of language name and version to a DWARF 5 DW_LANG.
Definition: Dwarf.h:230
MacinfoRecordType
Definition: Dwarf.h:801
@ DW_MACINFO_undef
Definition: Dwarf.h:804
@ DW_MACINFO_start_file
Definition: Dwarf.h:805
@ DW_MACINFO_end_file
Definition: Dwarf.h:806
@ DW_MACINFO_define
Definition: Dwarf.h:803
@ DW_MACINFO_vendor_ext
Definition: Dwarf.h:807
const uint32_t DW_INVALID_OFFSET
Identifier of an invalid DIE offset in the .debug_info section.
Definition: Dwarf.h:102
RnglistEntries
DWARF v5 range list entry encoding values.
Definition: Dwarf.h:827
std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
Definition: Dwarf.cpp:792
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:1080
VirtualityAttribute
Definition: Dwarf.h:196
@ DW_VIRTUALITY_max
Definition: Dwarf.h:199
GDBIndexEntryKind
Definition: Dwarf.h:957
@ GIEK_NONE
Definition: Dwarf.h:958
@ GIEK_UNUSED7
Definition: Dwarf.h:965
@ GIEK_TYPE
Definition: Dwarf.h:959
@ GIEK_UNUSED6
Definition: Dwarf.h:964
@ GIEK_OTHER
Definition: Dwarf.h:962
@ GIEK_FUNCTION
Definition: Dwarf.h:961
@ GIEK_UNUSED5
Definition: Dwarf.h:963
@ GIEK_VARIABLE
Definition: Dwarf.h:960
LineNumberExtendedOps
Line Number Extended Opcode Encodings.
Definition: Dwarf.h:787
@ DW_LNE_hi_user
Definition: Dwarf.h:791
@ DW_LNE_lo_user
Definition: Dwarf.h:790
bool isCPlusPlus(SourceLanguage S)
Definition: Dwarf.h:504
@ DW_EH_PE_textrel
Definition: Dwarf.h:866
@ DW_CHILDREN_no
Definition: Dwarf.h:851
@ DW_EH_PE_datarel
Definition: Dwarf.h:867
@ DW_EH_PE_pcrel
Definition: Dwarf.h:865
@ DW_EH_PE_signed
Definition: Dwarf.h:864
@ DW_CHILDREN_yes
Definition: Dwarf.h:852
@ DW_EH_PE_sdata4
Definition: Dwarf.h:862
@ DW_EH_PE_funcrel
Definition: Dwarf.h:868
@ DW_EH_PE_aligned
Definition: Dwarf.h:869
@ DW_EH_PE_udata2
Definition: Dwarf.h:857
@ DW_EH_PE_sdata8
Definition: Dwarf.h:863
@ DW_EH_PE_absptr
Definition: Dwarf.h:854
@ DW_EH_PE_sdata2
Definition: Dwarf.h:861
@ DW_EH_PE_udata4
Definition: Dwarf.h:858
@ DW_EH_PE_udata8
Definition: Dwarf.h:859
@ DW_EH_PE_uleb128
Definition: Dwarf.h:856
@ DW_EH_PE_indirect
Definition: Dwarf.h:870
@ DW_EH_PE_sleb128
Definition: Dwarf.h:860
@ DW_EH_PE_omit
Definition: Dwarf.h:855
TypeKind getArrayIndexTypeEncoding(SourceLanguage S)
Definition: Dwarf.h:740
StringRef AttributeValueString(uint16_t Attr, unsigned Val)
Returns the symbolic string representing Val when used as a value for attribute Attr.
Definition: Dwarf.cpp:735
DiscriminantList
Definition: Dwarf.h:774
@ DW_DSC_range
Definition: Dwarf.h:777
@ DW_DSC_label
Definition: Dwarf.h:776
std::optional< unsigned > OperationOperands(LocationAtom O)
The number of operands for the given LocationAtom.
Definition: Dwarf.cpp:226
@ DW_TAG_user_base
Recommended base for user tags.
Definition: Dwarf.h:109
@ DW_TAG_hi_user
Definition: Dwarf.h:108
@ DW_TAG_lo_user
Definition: Dwarf.h:107
CallFrameInfo
Call frame instruction encodings.
Definition: Dwarf.h:839
@ DW_CFA_hi_user
Definition: Dwarf.h:846
@ DW_CFA_extended
Definition: Dwarf.h:843
@ DW_CFA_lo_user
Definition: Dwarf.h:845
DecimalSignEncoding
Definition: Dwarf.h:165
@ DW_DS_leading_separate
Definition: Dwarf.h:170
@ DW_DS_trailing_separate
Definition: Dwarf.h:171
@ DW_DS_trailing_overpunch
Definition: Dwarf.h:169
@ DW_DS_leading_overpunch
Definition: Dwarf.h:168
@ DW_DS_unsigned
Definition: Dwarf.h:167
uint32_t getDebugNamesBucketCount(uint32_t UniqueHashCount)
Definition: Dwarf.h:948
uint64_t computeTombstoneAddress(uint8_t AddressByteSize)
Definition: Dwarf.h:1221
llvm::StringRef LanguageDescription(SourceLanguageName name)
Definition: Dwarf.cpp:465
AcceleratorTable
Definition: Dwarf.h:923
@ DW_ATOM_type_flags
Definition: Dwarf.h:930
@ DW_ATOM_null
Definition: Dwarf.h:925
@ DW_ATOM_die_tag
Definition: Dwarf.h:929
@ DW_FLAG_type_implementation
Definition: Dwarf.h:939
@ DW_ATOM_qual_name_hash
Definition: Dwarf.h:933
@ DW_ATOM_die_offset
Marker as the end of a list of atoms.
Definition: Dwarf.h:926
@ DW_ATOM_type_type_flags
Definition: Dwarf.h:932
@ DW_ATOM_cu_offset
Definition: Dwarf.h:927
@ DW_hash_function_djb
Definition: Dwarf.h:944
bool isC(SourceLanguage S)
Definition: Dwarf.h:664
LLVMConstants
Definition: Dwarf.h:44
@ DWARF_VENDOR_COMPAQ
Definition: Dwarf.h:79
@ DWARF_VENDOR_LLVM
Definition: Dwarf.h:75
@ DWARF_VENDOR_WASM
Definition: Dwarf.h:77
@ DW_ARANGES_VERSION
Section version number for .debug_aranges.
Definition: Dwarf.h:65
@ DW_PUBNAMES_VERSION
Section version number for .debug_pubnames.
Definition: Dwarf.h:64
@ DWARF_VENDOR_APPLE
Definition: Dwarf.h:71
@ DWARF_VERSION
Other constants.
Definition: Dwarf.h:62
@ DWARF_VENDOR_ALTIUM
Definition: Dwarf.h:78
@ DWARF_VENDOR_IBM
Definition: Dwarf.h:83
@ DWARF_VENDOR_GO
Definition: Dwarf.h:81
@ DWARF_VENDOR_SUN
Definition: Dwarf.h:86
@ DW_TAG_invalid
LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
Definition: Dwarf.h:47
@ DWARF_VENDOR_PGI
Definition: Dwarf.h:85
@ DWARF_VENDOR_HP
Definition: Dwarf.h:82
@ DWARF_VENDOR_INTEL
Definition: Dwarf.h:84
@ DW_LENGTH_lo_reserved
Special values for an initial length field.
Definition: Dwarf.h:55
@ DW_MACINFO_invalid
Macinfo type for invalid results.
Definition: Dwarf.h:49
@ DWARF_VENDOR_UPC
Definition: Dwarf.h:87
@ DW_APPLE_ENUM_KIND_invalid
Enum kind for invalid results.
Definition: Dwarf.h:50
@ DWARF_VENDOR_GNU
Definition: Dwarf.h:73
@ DW_VIRTUALITY_invalid
Virtuality for invalid results.
Definition: Dwarf.h:48
@ DW_LENGTH_hi_reserved
Upper bound of the reserved range.
Definition: Dwarf.h:57
@ DWARF_VENDOR_GOOGLE
Definition: Dwarf.h:74
@ DWARF_VENDOR_BORLAND
Definition: Dwarf.h:72
@ DWARF_VENDOR_GHS
Definition: Dwarf.h:80
@ DWARF_VENDOR_MIPS
Definition: Dwarf.h:76
@ DW_PUBTYPES_VERSION
Section version number for .debug_pubtypes.
Definition: Dwarf.h:63
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
Definition: Dwarf.h:56
@ DWARF_VENDOR_DWARF
Identifiers we use to distinguish vendor extensions.
Definition: Dwarf.h:70
GDBIndexEntryLinkage
Definition: Dwarf.h:968
@ GIEL_EXTERNAL
Definition: Dwarf.h:968
@ GIEL_STATIC
Definition: Dwarf.h:968
std::optional< std::pair< SourceLanguageName, uint32_t > > toDW_LNAME(SourceLanguage language)
Convert a DWARF 5 DW_LANG to a DWARF 6 pair of language name and version.
Definition: Dwarf.h:371
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:125
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition: Dwarf.h:1093
bool DwarfUsesRelocationsAcrossSections
True if DWARF v2 output generally uses relocations for references to other .debug_* sections.
Definition: Dwarf.h:1099
DwarfFormat Format
Definition: Dwarf.h:1096
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:1111
uint8_t getRefAddrByteSize() const
The definition of the size of form DW_FORM_ref_addr depends on the version.
Definition: Dwarf.h:1104
Describes an entry of the various gnu_pub* debug sections.
Definition: Dwarf.h:1164
PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
Definition: Dwarf.h:1167
PubIndexEntryDescriptor(uint8_t Value)
Definition: Dwarf.h:1171
PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
Definition: Dwarf.h:1169
GDBIndexEntryLinkage Linkage
Definition: Dwarf.h:1166
static void format(const Enum &E, raw_ostream &OS, StringRef Style)
Definition: Dwarf.h:1234