llvm.org GIT mirror llvm / 7089f45
1. Revise vector debug support. 2. Update docs for vector debug support and new version control. 3. Simplify serialization of DebugDescInfo subclasses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28816 91177308-0d34-0410-b5e6-96231b3b80d8 Jim Laskey 13 years ago
5 changed file(s) with 133 addition(s) and 125 deletion(s). Raw diff Collapse all Expand all
294294 }
295295
296296
297

The first field of a descriptor is always an uint containing a tag

298 value identifying the content of the descriptor. The remaining fields are
299 specific to the descriptor. The values of tags are loosely bound to the tag
300 values of Dwarf information entries. However, that does not restrict the use of
301 the information supplied to Dwarf targets.

302
303

The details of the various descriptors follow.

297

The first field of a descriptor is always an

298 uint containing a tag value identifying the content of the descriptor.
299 The remaining fields are specific to the descriptor. The values of tags are
300 loosely bound to the tag values of Dwarf information entries. However, that
301 does not restrict the use of the information supplied to Dwarf targets. To
302 facilitate versioning of debug information, the tag is augmented with the
303 current debug version (LLVMDebugVersion = 4 << 16 or 0x40000.)

304
305

The details of the various descriptors follow.

304306
305307
306308
313315
314316

                  
                
315317 %llvm.dbg.anchor.type = type {
316 uint, ;; Tag = 0
318 uint, ;; Tag = 0 + LLVMDebugVersion
317319 uint ;; Tag of descriptors grouped by the anchor
318320 }
319321
351353
352354

                  
                
353355 %llvm.dbg.compile_unit.type = type {
354 uint, ;; Tag = 17 (DW_TAG_compile_unit)
356 uint, ;; Tag = 17 + LLVMDebugVersion (DW_TAG_compile_unit)
355357 { }*, ;; Compile unit anchor = cast = (%llvm.dbg.anchor.type* %llvm.dbg.compile_units to { }*)
356 uint, ;; LLVM debug version number = 3
357358 uint, ;; Dwarf language identifier (ex. DW_LANG_C89)
358359 sbyte*, ;; Source file name
359360 sbyte*, ;; Source file directory (includes trailing slash)
361362 }
362363
363364
364

These descriptors contain the version number for the debug info (currently

365 3), a source language ID for the file (we use the Dwarf 3.0 ID numbers, such as
366 DW_LANG_C89, DW_LANG_C_plus_plus, DW_LANG_Cobol74,
367 etc), three strings describing the filename, working directory of the compiler,
368 and an identifier string for the compiler that produced it.

365

These descriptors contain a source language ID for the file (we use the Dwarf

366 3.0 ID numbers, such as DW_LANG_C89, DW_LANG_C_plus_plus,
367 DW_LANG_Cobol74, etc), three strings describing the filename, working
368 directory of the compiler, and an identifier string for the compiler that
369 produced it.

369370
370371

Compile unit descriptors provide the root context for objects declared in a

371372 specific source file. Global variables and top level functions would be defined
383384
384385

                  
                
385386 %llvm.dbg.global_variable.type = type {
386 uint, ;; Tag = 52 (DW_TAG_variable)
387 uint, ;; Tag = 52 + LLVMDebugVersion (DW_TAG_variable)
387388 { }*, ;; Global variable anchor = cast (%llvm.dbg.anchor.type* %llvm.dbg.global_variables to { }*),
388389 { }*, ;; Reference to context descriptor
389390 sbyte*, ;; Name
410411
411412

                  
                
412413 %llvm.dbg.subprogram.type = type {
413 uint, ;; Tag = 46 (DW_TAG_subprogram)
414 uint, ;; Tag = 46 + LLVMDebugVersion (DW_TAG_subprogram)
414415 { }*, ;; Subprogram anchor = cast (%llvm.dbg.anchor.type* %llvm.dbg.subprograms to { }*),
415416 { }*, ;; Reference to context descriptor
416417 sbyte*, ;; Name
436437
437438

                  
                
438439 %llvm.dbg.block = type {
439 uint, ;; Tag = 13 (DW_TAG_lexical_block)
440 uint, ;; Tag = 13 + LLVMDebugVersion (DW_TAG_lexical_block)
440441 { }* ;; Reference to context descriptor
441442 }
442443
456457
457458

                  
                
458459 %llvm.dbg.basictype.type = type {
459 uint, ;; Tag = 36 (DW_TAG_base_type)
460 uint, ;; Tag = 36 + LLVMDebugVersion (DW_TAG_base_type)
460461 { }*, ;; Reference to context (typically a compile unit)
461462 sbyte*, ;; Name (may be "" for anonymous types)
462463 { }*, ;; Reference to compile unit where defined (may be NULL)
574575 uint, ;; Size in bits
575576 uint, ;; Alignment in bits
576577 uint, ;; Offset in bits
577 bool, ;; Is vector flag
578578 { }* ;; Reference to array of member descriptors
579579 }
580580
588588 DW_TAG_enumeration_type = 4
589589 DW_TAG_structure_type = 19
590590 DW_TAG_union_type = 23
591 DW_TAG_vector_type = 259
591592
592593
593594

The vector flag indicates that an array type is a native packed vector.

594595
595

The members of array types (tag = DW_TAG_array_type) are

596 href="#format_subrange">subrange descriptors, each representing the range of
597 subscripts at that level of indexing.

596

The members of array types (tag = DW_TAG_array_type) or vector types

597 (tag = DW_TAG_vector_type) are subrange
598 descriptors, each representing the range of subscripts at that level of
599 indexing.

598600
599601

The members of enumeration types (tag = DW_TAG_enumeration_type) are

600602 enumerator descriptors, each representing the
626628
627629

                  
                
628630 %llvm.dbg.subrange.type = type {
629 uint, ;; Tag = 33 (DW_TAG_subrange_type)
631 uint, ;; Tag = 33 + LLVMDebugVersion (DW_TAG_subrange_type)
630632 uint, ;; Low value
631633 uint ;; High value
632634 }
649651
650652

                  
                
651653 %llvm.dbg.enumerator.type = type {
652 uint, ;; Tag = 40 (DW_TAG_enumerator)
654 uint, ;; Tag = 40 + LLVMDebugVersion (DW_TAG_enumerator)
653655 sbyte*, ;; Name
654656 uint ;; Value
655657 }
10411043 ;; Define the compile unit for the source file "/Users/mine/sources/MySource.cpp".
10421044 ;;
10431045 %llvm.dbg.compile_unit1 = internal constant %llvm.dbg.compile_unit.type {
1044 uint 17,
1046 uint add(uint 17, uint 262144),
10451047 { }* cast (%llvm.dbg.anchor.type* %llvm.dbg.compile_units to { }*),
10461048 uint 1,
10471049 uint 1,
10531055 ;; Define the compile unit for the header file "/Users/mine/sources/MyHeader.h".
10541056 ;;
10551057 %llvm.dbg.compile_unit2 = internal constant %llvm.dbg.compile_unit.type {
1056 uint 17,
1058 uint add(uint 17, uint 262144),
10571059 { }* cast (%llvm.dbg.anchor.type* %llvm.dbg.compile_units to { }*),
10581060 uint 1,
10591061 uint 1,
11161118 ;; variable anchor and the global variable itself.
11171119 ;;
11181120 %llvm.dbg.global_variable = internal constant %llvm.dbg.global_variable.type {
1119 uint 52,
1121 uint add(uint 52, uint 262144),
11201122 { }* cast (%llvm.dbg.anchor.type* %llvm.dbg.global_variables to { }*),
11211123 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
11221124 sbyte* getelementptr ([9 x sbyte]* %str1, int 0, int 0),
11321134 ;; intrinsic type the source file is NULL and line 0.
11331135 ;;
11341136 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1135 uint 36,
1137 uint add(uint 36, uint 262144),
11361138 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
11371139 sbyte* getelementptr ([4 x sbyte]* %str2, int 0, int 0),
11381140 { }* null,
11891191 ;; Define the descriptor for the subprogram. TODO - more details.
11901192 ;;
11911193 %llvm.dbg.subprogram = internal constant %llvm.dbg.subprogram.type {
1192 uint 46,
1194 uint add(uint 46, uint 262144),
11931195 { }* cast (%llvm.dbg.anchor.type* %llvm.dbg.subprograms to { }*),
11941196 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
11951197 sbyte* getelementptr ([5 x sbyte]* %str1, int 0, int 0),
12341236
12351237

                  
                
12361238 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1237 uint 36,
1239 uint add(uint 36, uint 262144),
12381240 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
12391241 sbyte* getelementptr ([5 x sbyte]* %str1, int 0, int 0),
12401242 { }* null,
12571259
12581260

                  
                
12591261 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1260 uint 36,
1262 uint add(uint 36, uint 262144),
12611263 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
12621264 sbyte* getelementptr ([5 x sbyte]* %str1, int 0, int 0),
12631265 { }* null,
12801282
12811283

                  
                
12821284 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1283 uint 36,
1285 uint add(uint 36, uint 262144),
12841286 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
12851287 sbyte* getelementptr ([14 x sbyte]* %str1, int 0, int 0),
12861288 { }* null,
13031305
13041306

                  
                
13051307 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1306 uint 36,
1308 uint add(uint 36, uint 262144),
13071309 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
13081310 sbyte* getelementptr ([10 x sbyte]* %str1, int 0, int 0),
13091311 { }* null,
13261328
13271329

                  
                
13281330 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1329 uint 36,
1331 uint add(uint 36, uint 262144),
13301332 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
13311333 sbyte* getelementptr ([19 x sbyte]* %str1, int 0, int 0),
13321334 { }* null,
13491351
13501352

                  
                
13511353 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1352 uint 36,
1354 uint add(uint 36, uint 262144),
13531355 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
13541356 sbyte* getelementptr ([4 x sbyte]* %str1, int 0, int 0),
13551357 { }* null,
13721374
13731375

                  
                
13741376 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1375 uint 36,
1377 uint add(uint 36, uint 262144),
13761378 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
13771379 sbyte* getelementptr ([13 x sbyte]* %str1, int 0, int 0),
13781380 { }* null,
13951397
13961398

                  
                
13971399 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1398 uint 36,
1400 uint add(uint 36, uint 262144),
13991401 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
14001402 sbyte* getelementptr ([14 x sbyte]* %str1, int 0, int 0),
14011403 { }* null,
14181420
14191421

                  
                
14201422 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1421 uint 36,
1423 uint add(uint 36, uint 262144),
14221424 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
14231425 sbyte* getelementptr ([23 x sbyte]* %str1, int 0, int 0),
14241426 { }* null,
14411443
14421444

                  
                
14431445 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1444 uint 36,
1446 uint add(uint 36, uint 262144),
14451447 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
14461448 sbyte* getelementptr ([6 x sbyte]* %str1, int 0, int 0),
14471449 { }* null,
14641466
14651467

                  
                
14661468 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1467 uint 36,
1469 uint add(uint 36, uint 262144),
14681470 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
14691471 sbyte* getelementptr ([7 x sbyte]* %str1, int 0, int 0),
14701472 { }* null,
14981500 ;; Define the typedef "IntPtr".
14991501 ;;
15001502 %llvm.dbg.derivedtype1 = internal constant %llvm.dbg.derivedtype.type {
1501 uint 22,
1503 uint add(uint 22, uint 262144),
15021504 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
15031505 sbyte* getelementptr ([7 x sbyte]* %str1, int 0, int 0),
15041506 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
15131515 ;; Define the pointer type.
15141516 ;;
15151517 %llvm.dbg.derivedtype2 = internal constant %llvm.dbg.derivedtype.type {
1516 uint 15,
1518 uint add(uint 15, uint 262144),
15171519 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
15181520 sbyte* null,
15191521 { }* null,
15271529 ;; Define the const type.
15281530 ;;
15291531 %llvm.dbg.derivedtype3 = internal constant %llvm.dbg.derivedtype.type {
1530 uint 38,
1532 uint add(uint 38, uint 262144),
15311533 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
15321534 sbyte* null,
15331535 { }* null,
15411543 ;; Define the int type.
15421544 ;;
15431545 %llvm.dbg.basictype1 = internal constant %llvm.dbg.basictype.type {
1544 uint 36,
1546 uint add(uint 36, uint 262144),
15451547 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
15461548 sbyte* getelementptr ([4 x sbyte]* %str2, int 0, int 0),
15471549 { }* null,
15791581 ;; Define basic type for unsigned int.
15801582 ;;
15811583 %llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type {
1582 uint 36,
1584 uint add(uint 36, uint 262144),
15831585 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
15841586 sbyte* getelementptr ([13 x sbyte]* %str1, int 0, int 0),
15851587 { }* null,
15941596 ;; Define composite type for struct Color.
15951597 ;;
15961598 %llvm.dbg.compositetype = internal constant %llvm.dbg.compositetype.type {
1597 uint 19,
1599 uint add(uint 19, uint 262144),
15981600 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
15991601 sbyte* getelementptr ([6 x sbyte]* %str2, int 0, int 0),
16001602 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
16031605 uint 32,
16041606 uint 0,
16051607 { }* null,
1606 bool false,
16071608 { }* cast ([3 x { }*]* %llvm.dbg.array to { }*) }, section "llvm.metadata"
16081609 %str2 = internal constant [6 x sbyte] c"Color\00", section "llvm.metadata"
16091610
16111612 ;; Define the Red field.
16121613 ;;
16131614 %llvm.dbg.derivedtype1 = internal constant %llvm.dbg.derivedtype.type {
1614 uint 13,
1615 uint add(uint 13, uint 262144),
16151616 { }* null,
16161617 sbyte* getelementptr ([4 x sbyte]* %str3, int 0, int 0),
16171618 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
16261627 ;; Define the Green field.
16271628 ;;
16281629 %llvm.dbg.derivedtype2 = internal constant %llvm.dbg.derivedtype.type {
1629 uint 13,
1630 uint add(uint 13, uint 262144),
16301631 { }* null,
16311632 sbyte* getelementptr ([6 x sbyte]* %str4, int 0, int 0),
16321633 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
16411642 ;; Define the Blue field.
16421643 ;;
16431644 %llvm.dbg.derivedtype3 = internal constant %llvm.dbg.derivedtype.type {
1644 uint 13,
1645 uint add(uint 13, uint 262144),
16451646 { }* null,
16461647 sbyte* getelementptr ([5 x sbyte]* %str5, int 0, int 0),
16471648 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
16871688 ;; Define composite type for enum Trees
16881689 ;;
16891690 %llvm.dbg.compositetype = internal constant %llvm.dbg.compositetype.type {
1690 uint 4,
1691 uint add(uint 4, uint 262144),
16911692 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
16921693 sbyte* getelementptr ([6 x sbyte]* %str1, int 0, int 0),
16931694 { }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit to { }*),
16961697 uint 32,
16971698 uint 0,
16981699 { }* null,
1699 bool false,
17001700 { }* cast ([3 x { }*]* %llvm.dbg.array to { }*) }, section "llvm.metadata"
17011701 %str1 = internal constant [6 x sbyte] c"Trees\00", section "llvm.metadata"
17021702
17041704 ;; Define Spruce enumerator.
17051705 ;;
17061706 %llvm.dbg.enumerator1 = internal constant %llvm.dbg.enumerator.type {
1707 uint 40,
1707 uint add(uint 40, uint 262144),
17081708 sbyte* getelementptr ([7 x sbyte]* %str2, int 0, int 0),
17091709 int 100 }, section "llvm.metadata"
17101710 %str2 = internal constant [7 x sbyte] c"Spruce\00", section "llvm.metadata"
17131713 ;; Define Oak enumerator.
17141714 ;;
17151715 %llvm.dbg.enumerator2 = internal constant %llvm.dbg.enumerator.type {
1716 uint 40,
1716 uint add(uint 40, uint 262144),
17171717 sbyte* getelementptr ([4 x sbyte]* %str3, int 0, int 0),
17181718 int 200 }, section "llvm.metadata"
17191719 %str3 = internal constant [4 x sbyte] c"Oak\00", section "llvm.metadata"
17221722 ;; Define Maple enumerator.
17231723 ;;
17241724 %llvm.dbg.enumerator3 = internal constant %llvm.dbg.enumerator.type {
1725 uint 40,
1725 uint add(uint 40, uint 262144),
17261726 sbyte* getelementptr ([6 x sbyte]* %str4, int 0, int 0),
17271727 int 300 }, section "llvm.metadata"
17281728 %str4 = internal constant [6 x sbyte] c"Maple\00", section "llvm.metadata"
5656 // Debug info constants.
5757
5858 enum {
59 LLVMDebugVersion = 4 // Current version of debug information.
59 LLVMDebugVersion = (4 << 16), // Current version of debug information.
60 LLVMDebugVersionMask = 0xffff0000 // Mask for version number.
6061 };
6162
6263 //===----------------------------------------------------------------------===//
8990 ///
9091 class DebugInfoDesc {
9192 private:
92 enum {
93 tag_mask = 0x0000ffff,
94 version_shift = 16
95 };
96
97
9893 unsigned Tag; // Content indicator. Dwarf values are
9994 // used but that does not limit use to
10095 // Dwarf writers.
10196
10297 protected:
103 DebugInfoDesc(unsigned T) : Tag(T | (LLVMDebugVersion << version_shift)) {}
98 DebugInfoDesc(unsigned T) : Tag(T | LLVMDebugVersion) {}
10499
105100 public:
106101 virtual ~DebugInfoDesc() {}
107102
108103 // Accessors
109 unsigned getTag() const { return Tag & tag_mask; }
110 unsigned getVersion() const { return Tag >> version_shift; }
104 unsigned getTag() const { return Tag & ~LLVMDebugVersionMask; }
105 unsigned getVersion() const { return Tag & LLVMDebugVersionMask; }
106 void setTag(unsigned T) { Tag = T | LLVMDebugVersion; }
111107
112108 /// TagFromGlobal - Returns the tag number from a debug info descriptor
113109 /// GlobalVariable. Return DIIValid if operand is not an unsigned int.
198194 /// descriptors.
199195 class AnchoredDesc : public DebugInfoDesc {
200196 private:
201 AnchorDesc *Anchor; // Anchor for all descriptors of the
197 DebugInfoDesc *Anchor; // Anchor for all descriptors of the
202198 // same type.
203199
204200 protected:
207203
208204 public:
209205 // Accessors.
210 AnchorDesc *getAnchor() const { return Anchor; }
211 void setAnchor(AnchorDesc *A) { Anchor = A; }
206 AnchorDesc *getAnchor() const { return static_cast(Anchor); }
207 void setAnchor(AnchorDesc *A) { Anchor = static_cast(A); }
212208
213209 //===--------------------------------------------------------------------===//
214210 // Subclasses should supply the following virtual methods.
281277 private:
282278 DebugInfoDesc *Context; // Context debug descriptor.
283279 std::string Name; // Type name (may be empty.)
284 CompileUnitDesc *File; // Defined compile unit (may be NULL.)
280 DebugInfoDesc *File; // Defined compile unit (may be NULL.)
285281 unsigned Line; // Defined line# (may be zero.)
286282 uint64_t Size; // Type bit size (may be zero.)
287283 uint64_t Align; // Type bit alignment (may be zero.)
293289 // Accessors
294290 DebugInfoDesc *getContext() const { return Context; }
295291 const std::string &getName() const { return Name; }
296 CompileUnitDesc *getFile() const { return File; }
292 CompileUnitDesc *getFile() const {
293 return static_cast(File);
294 }
297295 unsigned getLine() const { return Line; }
298296 uint64_t getSize() const { return Size; }
299297 uint64_t getAlign() const { return Align; }
300298 uint64_t getOffset() const { return Offset; }
301299 void setContext(DebugInfoDesc *C) { Context = C; }
302300 void setName(const std::string &N) { Name = N; }
303 void setFile(CompileUnitDesc *U) { File = U; }
301 void setFile(CompileUnitDesc *U) {
302 File = static_cast(U);
303 }
304304 void setLine(unsigned L) { Line = L; }
305305 void setSize(uint64_t S) { Size = S; }
306306 void setAlign(uint64_t A) { Align = A; }
364364 /// derived types (eg., typedef, pointer, reference.)
365365 class DerivedTypeDesc : public TypeDesc {
366366 private:
367 TypeDesc *FromType; // Type derived from.
367 DebugInfoDesc *FromType; // Type derived from.
368368
369369 public:
370370 DerivedTypeDesc(unsigned T);
371371
372372 // Accessors
373 TypeDesc *getFromType() const { return FromType; }
374 void setFromType(TypeDesc *F) { FromType = F; }
373 TypeDesc *getFromType() const {
374 return static_cast(FromType);
375 }
376 void setFromType(TypeDesc *F) {
377 FromType = static_cast(F);
378 }
375379
376380 // Implement isa/cast/dyncast.
377381 static bool classof(const DerivedTypeDesc *) { return true; }
399403 /// array/struct types (eg., arrays, struct, union, enums.)
400404 class CompositeTypeDesc : public DerivedTypeDesc {
401405 private:
402 bool IsVector; // packed/vector array
403406 std::vector Elements;// Information used to compose type.
404407
405408 public:
406409 CompositeTypeDesc(unsigned T);
407410
408411 // Accessors
409 bool isVector() const { return IsVector; }
410412 std::vector &getElements() { return Elements; }
411 void setIsVector() { IsVector = true; }
412413
413414 // Implement isa/cast/dyncast.
414415 static bool classof(const CompositeTypeDesc *) { return true; }
515516 private:
516517 DebugInfoDesc *Context; // Context debug descriptor.
517518 std::string Name; // Type name (may be empty.)
518 CompileUnitDesc *File; // Defined compile unit (may be NULL.)
519 DebugInfoDesc *File; // Defined compile unit (may be NULL.)
519520 unsigned Line; // Defined line# (may be zero.)
520 TypeDesc *TyDesc; // Type of variable.
521 DebugInfoDesc *TyDesc; // Type of variable.
521522
522523 public:
523524 VariableDesc(unsigned T);
525526 // Accessors
526527 DebugInfoDesc *getContext() const { return Context; }
527528 const std::string &getName() const { return Name; }
528 CompileUnitDesc *getFile() const { return File; }
529 CompileUnitDesc *getFile() const {
530 return static_cast(File);
531 }
529532 unsigned getLine() const { return Line; }
530 TypeDesc *getType() const { return TyDesc; }
533 TypeDesc *getType() const {
534 return static_cast(TyDesc);
535 }
531536 void setContext(DebugInfoDesc *C) { Context = C; }
532537 void setName(const std::string &N) { Name = N; }
533 void setFile(CompileUnitDesc *U) { File = U; }
538 void setFile(CompileUnitDesc *U) {
539 File = static_cast(U);
540 }
534541 void setLine(unsigned L) { Line = L; }
535 void setType(TypeDesc *T) { TyDesc = T; }
542 void setType(TypeDesc *T) {
543 TyDesc = static_cast(T);
544 }
536545
537546 // Implement isa/cast/dyncast.
538547 static bool classof(const VariableDesc *) { return true; }
562571 private:
563572 DebugInfoDesc *Context; // Context debug descriptor.
564573 std::string Name; // Global name.
565 CompileUnitDesc *File; // Defined compile unit (may be NULL.)
574 DebugInfoDesc *File; // Defined compile unit (may be NULL.)
566575 unsigned Line; // Defined line# (may be zero.)
567 TypeDesc *TyDesc; // Type debug descriptor.
576 DebugInfoDesc *TyDesc; // Type debug descriptor.
568577 bool IsStatic; // Is the global a static.
569578 bool IsDefinition; // Is the global defined in context.
570579
575584 // Accessors
576585 DebugInfoDesc *getContext() const { return Context; }
577586 const std::string &getName() const { return Name; }
578 CompileUnitDesc *getFile() const { return File; }
587 CompileUnitDesc *getFile() const {
588 return static_cast(File);
589 }
579590 unsigned getLine() const { return Line; }
580 TypeDesc *getType() const { return TyDesc; }
591 TypeDesc *getType() const {
592 return static_cast(TyDesc);
593 }
581594 bool isStatic() const { return IsStatic; }
582595 bool isDefinition() const { return IsDefinition; }
583596 void setContext(DebugInfoDesc *C) { Context = C; }
584597 void setName(const std::string &N) { Name = N; }
585 void setFile(CompileUnitDesc *U) { File = U; }
598 void setFile(CompileUnitDesc *U) {
599 File = static_cast(U);
600 }
586601 void setLine(unsigned L) { Line = L; }
587 void setType(TypeDesc *T) { TyDesc = T; }
602 void setType(TypeDesc *T) {
603 TyDesc = static_cast(T);
604 }
588605 void setIsStatic(bool IS) { IsStatic = IS; }
589606 void setIsDefinition(bool ID) { IsDefinition = ID; }
590607
3535 DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables.
3636 DW_TAG_arg_variable = 0x101, // Tag for argument variables.
3737 DW_TAG_return_variable = 0x102, // Tag for return variables.
38
39 DW_TAG_vector_type = 0x103, // Tag for vector types.
3840
3941 DW_TAG_user_base = 0x1000, // Recommended base for user tags.
4042
12751275 NewType(Context, FromTy, Unit));
12761276 }
12771277 } else if (CompositeTypeDesc *CompTy = dyn_cast(TyDesc)) {
1278 // Fetch tag
1279 unsigned Tag = CompTy->getTag();
1280
12781281 // Create specific DIE.
1279 Slot = Ty = new DIE(CompTy->getTag());
1282 Slot = Ty = Tag == DW_TAG_vector_type ? new DIE(DW_TAG_array_type) :
1283 new DIE(Tag);
1284
12801285 std::vector &Elements = CompTy->getElements();
12811286
1282 switch (CompTy->getTag()) {
1287 switch (Tag) {
1288 case DW_TAG_vector_type: Ty->AddUInt(DW_AT_GNU_vector, DW_FORM_flag, 1);
1289 // Fall thru
12831290 case DW_TAG_array_type: {
12841291 // Add element type.
12851292 if (TypeDesc *FromTy = CompTy->getFromType()) {
12861293 Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4,
12871294 NewType(Context, FromTy, Unit));
1288 }
1289
1290 // check for vector type
1291 if (CompTy->isVector()) {
1292 Ty->AddUInt(DW_AT_GNU_vector, DW_FORM_flag, 1);
12931295 }
12941296
12951297 // Don't emit size attribute.
458458 /// GlobalVariable. Return DIIValid if operand is not an unsigned int.
459459 unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
460460 ConstantUInt *C = getUIntOperand(GV, 0);
461 return C ? ((unsigned)C->getValue() & tag_mask) : (unsigned)DW_TAG_invalid;
461 return C ? ((unsigned)C->getValue() & ~LLVMDebugVersionMask) :
462 (unsigned)DW_TAG_invalid;
462463 }
463464
464465 /// VersionFromGlobal - Returns the version number from a debug info
466467 /// int.
467468 unsigned DebugInfoDesc::VersionFromGlobal(GlobalVariable *GV) {
468469 ConstantUInt *C = getUIntOperand(GV, 0);
469 return C ? ((unsigned)C->getValue() >> version_shift) :
470 return C ? ((unsigned)C->getValue() & LLVMDebugVersionMask) :
470471 (unsigned)DW_TAG_invalid;
471472 }
472473
490491 case DW_TAG_array_type:
491492 case DW_TAG_structure_type:
492493 case DW_TAG_union_type:
493 case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag);
494 case DW_TAG_enumeration_type:
495 case DW_TAG_vector_type: return new CompositeTypeDesc(Tag);
494496 case DW_TAG_subrange_type: return new SubrangeDesc();
495497 case DW_TAG_enumerator: return new EnumeratorDesc();
496498 case DW_TAG_return_variable:
589591 void AnchoredDesc::ApplyToFields(DIVisitor *Visitor) {
590592 DebugInfoDesc::ApplyToFields(Visitor);
591593
592 DebugInfoDesc *Tmp = Anchor;
593 Visitor->Apply(Tmp);
594 Anchor = (AnchorDesc*)Tmp;
594 Visitor->Apply(Anchor);
595595 }
596596
597597 //===----------------------------------------------------------------------===//
672672
673673 Visitor->Apply(Context);
674674 Visitor->Apply(Name);
675 DebugInfoDesc* Tmp = File;
676 Visitor->Apply(Tmp);
677 File = (CompileUnitDesc*)Tmp;
675 Visitor->Apply(File);
678676 Visitor->Apply(Line);
679677 Visitor->Apply(Size);
680678 Visitor->Apply(Align);
781779 void DerivedTypeDesc::ApplyToFields(DIVisitor *Visitor) {
782780 TypeDesc::ApplyToFields(Visitor);
783781
784 DebugInfoDesc* Tmp = FromType;
785 Visitor->Apply(Tmp);
786 FromType = (TypeDesc*)Tmp;
782 Visitor->Apply(FromType);
787783 }
788784
789785 /// getDescString - Return a string used to compose global names and labels.
816812
817813 CompositeTypeDesc::CompositeTypeDesc(unsigned T)
818814 : DerivedTypeDesc(T)
819 , IsVector(false)
820815 , Elements()
821816 {}
822817
828823 case DW_TAG_structure_type:
829824 case DW_TAG_union_type:
830825 case DW_TAG_enumeration_type:
826 case DW_TAG_vector_type:
831827 return true;
832828 default: break;
833829 }
837833 /// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc.
838834 ///
839835 void CompositeTypeDesc::ApplyToFields(DIVisitor *Visitor) {
840 DerivedTypeDesc::ApplyToFields(Visitor);
841
842 Visitor->Apply(IsVector);
836 DerivedTypeDesc::ApplyToFields(Visitor);
837
843838 Visitor->Apply(Elements);
844839 }
845840
989984
990985 Visitor->Apply(Context);
991986 Visitor->Apply(Name);
992 DebugInfoDesc* Tmp1 = File;
993 Visitor->Apply(Tmp1);
994 File = (CompileUnitDesc*)Tmp1;
987 Visitor->Apply(File);
995988 Visitor->Apply(Line);
996 DebugInfoDesc* Tmp2 = TyDesc;
997 Visitor->Apply(Tmp2);
998 TyDesc = (TypeDesc*)Tmp2;
989 Visitor->Apply(TyDesc);
999990 }
1000991
1001992 /// getDescString - Return a string used to compose global names and labels.
10431034
10441035 Visitor->Apply(Context);
10451036 Visitor->Apply(Name);
1046 DebugInfoDesc* Tmp1 = File;
1047 Visitor->Apply(Tmp1);
1048 File = (CompileUnitDesc*)Tmp1;
1037 Visitor->Apply(File);
10491038 Visitor->Apply(Line);
1050 DebugInfoDesc* Tmp2 = TyDesc;
1051 Visitor->Apply(Tmp2);
1052 TyDesc = (TypeDesc*)Tmp2;
1039 Visitor->Apply(TyDesc);
10531040 Visitor->Apply(IsStatic);
10541041 Visitor->Apply(IsDefinition);
10551042 }