[cleanup] Re-sort all the includes with utils/sort_includes.py.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfUnit.h
1 //===-- llvm/CodeGen/DwarfUnit.h - Dwarf Compile Unit ---*- 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 // This file contains support for writing dwarf compile unit.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
15 #define CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
16
17 #include "DIE.h"
18 #include "DwarfDebug.h"
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/Optional.h"
21 #include "llvm/ADT/OwningPtr.h"
22 #include "llvm/ADT/StringMap.h"
23 #include "llvm/DIBuilder.h"
24 #include "llvm/DebugInfo.h"
25 #include "llvm/MC/MCExpr.h"
26 #include "llvm/MC/MCSection.h"
27
28 namespace llvm {
29
30 class MachineLocation;
31 class MachineOperand;
32 class ConstantInt;
33 class ConstantFP;
34 class DbgVariable;
35 class DwarfCompileUnit;
36
37 // Data structure to hold a range for range lists.
38 class RangeSpan {
39 public:
40   RangeSpan(MCSymbol *S, MCSymbol *E) : Start(S), End(E) {}
41   const MCSymbol *getStart() const { return Start; }
42   const MCSymbol *getEnd() const { return End; }
43
44 private:
45   const MCSymbol *Start, *End;
46 };
47
48 class RangeSpanList {
49 private:
50   // Index for locating within the debug_range section this particular span.
51   MCSymbol *RangeSym;
52   // List of ranges.
53   SmallVector<RangeSpan, 2> Ranges;
54
55 public:
56   RangeSpanList(MCSymbol *Sym) : RangeSym(Sym) {}
57   MCSymbol *getSym() const { return RangeSym; }
58   const SmallVectorImpl<RangeSpan> &getRanges() const { return Ranges; }
59   void addRange(RangeSpan Range) { Ranges.push_back(Range); }
60 };
61
62 //===----------------------------------------------------------------------===//
63 /// Unit - This dwarf writer support class manages information associated
64 /// with a source file.
65 class DwarfUnit {
66 protected:
67   /// UniqueID - a numeric ID unique among all CUs in the module
68   unsigned UniqueID;
69
70   /// Node - MDNode for the compile unit.
71   DICompileUnit CUNode;
72
73   /// Unit debug information entry.
74   const OwningPtr<DIE> UnitDie;
75
76   /// Offset of the UnitDie from beginning of debug info section.
77   unsigned DebugInfoOffset;
78
79   /// Asm - Target of Dwarf emission.
80   AsmPrinter *Asm;
81
82   // Holders for some common dwarf information.
83   DwarfDebug *DD;
84   DwarfFile *DU;
85
86   /// IndexTyDie - An anonymous type for index type.  Owned by UnitDie.
87   DIE *IndexTyDie;
88
89   /// MDNodeToDieMap - Tracks the mapping of unit level debug information
90   /// variables to debug information entries.
91   DenseMap<const MDNode *, DIE *> MDNodeToDieMap;
92
93   /// MDNodeToDIEEntryMap - Tracks the mapping of unit level debug information
94   /// descriptors to debug information entries using a DIEEntry proxy.
95   DenseMap<const MDNode *, DIEEntry *> MDNodeToDIEEntryMap;
96
97   /// GlobalNames - A map of globally visible named entities for this unit.
98   StringMap<const DIE *> GlobalNames;
99
100   /// GlobalTypes - A map of globally visible types for this unit.
101   StringMap<const DIE *> GlobalTypes;
102
103   /// AccelNames - A map of names for the name accelerator table.
104   StringMap<std::vector<const DIE *> > AccelNames;
105
106   /// AccelObjC - A map of objc spec for the objc accelerator table.
107   StringMap<std::vector<const DIE *> > AccelObjC;
108
109   /// AccelNamespace - A map of names for the namespace accelerator table.
110   StringMap<std::vector<const DIE *> > AccelNamespace;
111
112   /// AccelTypes - A map of names for the type accelerator table.
113   StringMap<std::vector<std::pair<const DIE *, unsigned> > > AccelTypes;
114
115   /// DIEBlocks - A list of all the DIEBlocks in use.
116   std::vector<DIEBlock *> DIEBlocks;
117   
118   /// DIELocs - A list of all the DIELocs in use.
119   std::vector<DIELoc *> DIELocs;
120
121   /// ContainingTypeMap - This map is used to keep track of subprogram DIEs that
122   /// need DW_AT_containing_type attribute. This attribute points to a DIE that
123   /// corresponds to the MDNode mapped with the subprogram DIE.
124   DenseMap<DIE *, const MDNode *> ContainingTypeMap;
125
126   // List of ranges for a given compile unit.
127   SmallVector<RangeSpan, 1> CURanges;
128
129   // List of range lists for a given compile unit, separate from the ranges for
130   // the CU itself.
131   SmallVector<RangeSpanList, 1> CURangeLists;
132
133   // DIEValueAllocator - All DIEValues are allocated through this allocator.
134   BumpPtrAllocator DIEValueAllocator;
135
136   // DIEIntegerOne - A preallocated DIEValue because 1 is used frequently.
137   DIEInteger *DIEIntegerOne;
138
139   /// The section this unit will be emitted in.
140   const MCSection *Section;
141
142   /// A label at the start of the non-dwo section related to this unit.
143   MCSymbol *SectionSym;
144
145   /// The start of the unit within its section.
146   MCSymbol *LabelBegin;
147
148   /// The end of the unit within its section.
149   MCSymbol *LabelEnd;
150
151   /// The label for the start of the range sets for the elements of this unit.
152   MCSymbol *LabelRange;
153
154   /// Skeleton unit associated with this unit.
155   DwarfUnit *Skeleton;
156
157   DwarfUnit(unsigned UID, DIE *D, DICompileUnit CU, AsmPrinter *A,
158             DwarfDebug *DW, DwarfFile *DWU);
159
160 public:
161   virtual ~DwarfUnit();
162
163   /// Set the skeleton unit associated with this unit.
164   void setSkeleton(DwarfUnit *Skel) { Skeleton = Skel; }
165
166   /// Get the skeleton unit associated with this unit.
167   DwarfUnit *getSkeleton() const { return Skeleton; }
168
169   /// Pass in the SectionSym even though we could recreate it in every compile
170   /// unit (type units will have actually distinct symbols once they're in
171   /// comdat sections).
172   void initSection(const MCSection *Section, MCSymbol *SectionSym) {
173     assert(!this->Section);
174     this->Section = Section;
175     this->SectionSym = SectionSym;
176     this->LabelBegin =
177         Asm->GetTempSymbol(Section->getLabelBeginName(), getUniqueID());
178     this->LabelEnd =
179         Asm->GetTempSymbol(Section->getLabelEndName(), getUniqueID());
180     this->LabelRange = Asm->GetTempSymbol("gnu_ranges", getUniqueID());
181   }
182
183   const MCSection *getSection() const {
184     assert(Section);
185     return Section;
186   }
187
188   /// If there's a skeleton then return the section symbol for the skeleton
189   /// unit, otherwise return the section symbol for this unit.
190   MCSymbol *getLocalSectionSym() const {
191     if (Skeleton)
192       return Skeleton->getSectionSym();
193     return getSectionSym();
194   }
195
196   MCSymbol *getSectionSym() const {
197     assert(Section);
198     return SectionSym;
199   }
200
201   /// If there's a skeleton then return the begin label for the skeleton unit,
202   /// otherwise return the local label for this unit.
203   MCSymbol *getLocalLabelBegin() const {
204     if (Skeleton)
205       return Skeleton->getLabelBegin();
206     return getLabelBegin();
207   }
208
209   MCSymbol *getLabelBegin() const {
210     assert(Section);
211     return LabelBegin;
212   }
213
214   MCSymbol *getLabelEnd() const {
215     assert(Section);
216     return LabelEnd;
217   }
218
219   MCSymbol *getLabelRange() const {
220     assert(Section);
221     return LabelRange;
222   }
223
224   // Accessors.
225   unsigned getUniqueID() const { return UniqueID; }
226   uint16_t getLanguage() const { return CUNode.getLanguage(); }
227   DICompileUnit getCUNode() const { return CUNode; }
228   DIE *getUnitDie() const { return UnitDie.get(); }
229   const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
230   const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
231
232   const StringMap<std::vector<const DIE *> > &getAccelNames() const {
233     return AccelNames;
234   }
235   const StringMap<std::vector<const DIE *> > &getAccelObjC() const {
236     return AccelObjC;
237   }
238   const StringMap<std::vector<const DIE *> > &getAccelNamespace() const {
239     return AccelNamespace;
240   }
241   const StringMap<std::vector<std::pair<const DIE *, unsigned> > > &
242   getAccelTypes() const {
243     return AccelTypes;
244   }
245
246   unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
247   void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; }
248
249   /// hasContent - Return true if this compile unit has something to write out.
250   bool hasContent() const { return !UnitDie->getChildren().empty(); }
251
252   /// addRange - Add an address range to the list of ranges for this unit.
253   void addRange(RangeSpan Range) {
254     // Only add a range for this unit if we're emitting full debug.
255     if (getCUNode().getEmissionKind() == DIBuilder::FullDebug)
256       CURanges.push_back(Range);
257   }
258
259   /// getRanges - Get the list of ranges for this unit.
260   const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; }
261   SmallVectorImpl<RangeSpan> &getRanges() { return CURanges; }
262
263   /// addRangeList - Add an address range list to the list of range lists.
264   void addRangeList(RangeSpanList Ranges) { CURangeLists.push_back(Ranges); }
265
266   /// getRangeLists - Get the vector of range lists.
267   const SmallVectorImpl<RangeSpanList> &getRangeLists() const {
268     return CURangeLists;
269   }
270   SmallVectorImpl<RangeSpanList> &getRangeLists() { return CURangeLists; }
271
272   /// getParentContextString - Get a string containing the language specific
273   /// context for a global name.
274   std::string getParentContextString(DIScope Context) const;
275
276   /// addGlobalName - Add a new global entity to the compile unit.
277   ///
278   void addGlobalName(StringRef Name, DIE *Die, DIScope Context);
279
280   /// addAccelName - Add a new name to the name accelerator table.
281   void addAccelName(StringRef Name, const DIE *Die);
282
283   /// addAccelObjC - Add a new name to the ObjC accelerator table.
284   void addAccelObjC(StringRef Name, const DIE *Die);
285
286   /// addAccelNamespace - Add a new name to the namespace accelerator table.
287   void addAccelNamespace(StringRef Name, const DIE *Die);
288
289   /// addAccelType - Add a new type to the type accelerator table.
290   void addAccelType(StringRef Name, std::pair<const DIE *, unsigned> Die);
291
292   /// getDIE - Returns the debug information entry map slot for the
293   /// specified debug variable. We delegate the request to DwarfDebug
294   /// when the MDNode can be part of the type system, since DIEs for
295   /// the type system can be shared across CUs and the mappings are
296   /// kept in DwarfDebug.
297   DIE *getDIE(DIDescriptor D) const;
298
299   /// getDIELoc - Returns a fresh newly allocated DIELoc.
300   DIELoc *getDIELoc() { return new (DIEValueAllocator) DIELoc(); }
301
302   /// insertDIE - Insert DIE into the map. We delegate the request to DwarfDebug
303   /// when the MDNode can be part of the type system, since DIEs for
304   /// the type system can be shared across CUs and the mappings are
305   /// kept in DwarfDebug.
306   void insertDIE(DIDescriptor Desc, DIE *D);
307
308   /// addDie - Adds or interns the DIE to the compile unit.
309   ///
310   void addDie(DIE *Buffer) { UnitDie->addChild(Buffer); }
311
312   /// addFlag - Add a flag that is true to the DIE.
313   void addFlag(DIE *Die, dwarf::Attribute Attribute);
314
315   /// addUInt - Add an unsigned integer attribute data and value.
316   void addUInt(DIE *Die, dwarf::Attribute Attribute, Optional<dwarf::Form> Form,
317                uint64_t Integer);
318
319   void addUInt(DIE *Block, dwarf::Form Form, uint64_t Integer);
320
321   /// addSInt - Add an signed integer attribute data and value.
322   void addSInt(DIE *Die, dwarf::Attribute Attribute, Optional<dwarf::Form> Form,
323                int64_t Integer);
324
325   void addSInt(DIELoc *Die, Optional<dwarf::Form> Form, int64_t Integer);
326
327   /// addString - Add a string attribute data and value.
328   void addString(DIE *Die, dwarf::Attribute Attribute, const StringRef Str);
329
330   /// addLocalString - Add a string attribute data and value.
331   void addLocalString(DIE *Die, dwarf::Attribute Attribute,
332                       const StringRef Str);
333
334   /// addExpr - Add a Dwarf expression attribute data and value.
335   void addExpr(DIELoc *Die, dwarf::Form Form, const MCExpr *Expr);
336
337   /// addLabel - Add a Dwarf label attribute data and value.
338   void addLabel(DIE *Die, dwarf::Attribute Attribute, dwarf::Form Form,
339                 const MCSymbol *Label);
340
341   void addLabel(DIELoc *Die, dwarf::Form Form, const MCSymbol *Label);
342
343   /// addSectionLabel - Add a Dwarf section label attribute data and value.
344   ///
345   void addSectionLabel(DIE *Die, dwarf::Attribute Attribute,
346                        const MCSymbol *Label);
347
348   /// addSectionOffset - Add an offset into a section attribute data and value.
349   ///
350   void addSectionOffset(DIE *Die, dwarf::Attribute Attribute, uint64_t Integer);
351
352   /// addOpAddress - Add a dwarf op address data and value using the
353   /// form given and an op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
354   void addOpAddress(DIELoc *Die, const MCSymbol *Label);
355
356   /// addSectionDelta - Add a label delta attribute data and value.
357   void addSectionDelta(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
358                        const MCSymbol *Lo);
359
360   /// addDIEEntry - Add a DIE attribute data and value.
361   void addDIEEntry(DIE *Die, dwarf::Attribute Attribute, DIE *Entry);
362
363   /// addDIEEntry - Add a DIE attribute data and value.
364   void addDIEEntry(DIE *Die, dwarf::Attribute Attribute, DIEEntry *Entry);
365
366   void addDIETypeSignature(DIE *Die, const DwarfTypeUnit &Type);
367
368   /// addBlock - Add block data.
369   void addBlock(DIE *Die, dwarf::Attribute Attribute, DIELoc *Block);
370
371   /// addBlock - Add block data.
372   void addBlock(DIE *Die, dwarf::Attribute Attribute, DIEBlock *Block);
373
374   /// addSourceLine - Add location information to specified debug information
375   /// entry.
376   void addSourceLine(DIE *Die, unsigned Line, StringRef File,
377                      StringRef Directory);
378   void addSourceLine(DIE *Die, DIVariable V);
379   void addSourceLine(DIE *Die, DIGlobalVariable G);
380   void addSourceLine(DIE *Die, DISubprogram SP);
381   void addSourceLine(DIE *Die, DIType Ty);
382   void addSourceLine(DIE *Die, DINameSpace NS);
383   void addSourceLine(DIE *Die, DIObjCProperty Ty);
384
385   /// addAddress - Add an address attribute to a die based on the location
386   /// provided.
387   void addAddress(DIE *Die, dwarf::Attribute Attribute,
388                   const MachineLocation &Location, bool Indirect = false);
389
390   /// addConstantValue - Add constant value entry in variable DIE.
391   void addConstantValue(DIE *Die, const MachineOperand &MO, DIType Ty);
392   void addConstantValue(DIE *Die, const ConstantInt *CI, bool Unsigned);
393   void addConstantValue(DIE *Die, const APInt &Val, bool Unsigned);
394
395   /// addConstantFPValue - Add constant value entry in variable DIE.
396   void addConstantFPValue(DIE *Die, const MachineOperand &MO);
397   void addConstantFPValue(DIE *Die, const ConstantFP *CFP);
398
399   /// addTemplateParams - Add template parameters in buffer.
400   void addTemplateParams(DIE &Buffer, DIArray TParams);
401
402   /// addRegisterOp - Add register operand.
403   void addRegisterOp(DIELoc *TheDie, unsigned Reg);
404
405   /// addRegisterOffset - Add register offset.
406   void addRegisterOffset(DIELoc *TheDie, unsigned Reg, int64_t Offset);
407
408   /// addComplexAddress - Start with the address based on the location provided,
409   /// and generate the DWARF information necessary to find the actual variable
410   /// (navigating the extra location information encoded in the type) based on
411   /// the starting location.  Add the DWARF information to the die.
412   void addComplexAddress(const DbgVariable &DV, DIE *Die,
413                          dwarf::Attribute Attribute,
414                          const MachineLocation &Location);
415
416   // FIXME: Should be reformulated in terms of addComplexAddress.
417   /// addBlockByrefAddress - Start with the address based on the location
418   /// provided, and generate the DWARF information necessary to find the
419   /// actual Block variable (navigating the Block struct) based on the
420   /// starting location.  Add the DWARF information to the die.  Obsolete,
421   /// please use addComplexAddress instead.
422   void addBlockByrefAddress(const DbgVariable &DV, DIE *Die,
423                             dwarf::Attribute Attribute,
424                             const MachineLocation &Location);
425
426   /// addVariableAddress - Add DW_AT_location attribute for a
427   /// DbgVariable based on provided MachineLocation.
428   void addVariableAddress(const DbgVariable &DV, DIE *Die,
429                           MachineLocation Location);
430
431   /// addType - Add a new type attribute to the specified entity. This takes
432   /// and attribute parameter because DW_AT_friend attributes are also
433   /// type references.
434   void addType(DIE *Entity, DIType Ty,
435                dwarf::Attribute Attribute = dwarf::DW_AT_type);
436
437   /// getOrCreateNameSpace - Create a DIE for DINameSpace.
438   DIE *getOrCreateNameSpace(DINameSpace NS);
439
440   /// getOrCreateSubprogramDIE - Create new DIE using SP.
441   DIE *getOrCreateSubprogramDIE(DISubprogram SP);
442
443   /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
444   /// given DIType.
445   DIE *getOrCreateTypeDIE(const MDNode *N);
446
447   /// getOrCreateContextDIE - Get context owner's DIE.
448   DIE *createTypeDIE(DICompositeType Ty);
449
450   /// getOrCreateContextDIE - Get context owner's DIE.
451   DIE *getOrCreateContextDIE(DIScope Context);
452
453   /// constructContainingTypeDIEs - Construct DIEs for types that contain
454   /// vtables.
455   void constructContainingTypeDIEs();
456
457   /// constructVariableDIE - Construct a DIE for the given DbgVariable.
458   DIE *constructVariableDIE(DbgVariable &DV, bool isScopeAbstract);
459
460   /// constructSubprogramArguments - Construct function argument DIEs.
461   void constructSubprogramArguments(DIE &Buffer, DIArray Args);
462
463   /// Create a DIE with the given Tag, add the DIE to its parent, and
464   /// call insertDIE if MD is not null.
465   DIE *createAndAddDIE(unsigned Tag, DIE &Parent,
466                        DIDescriptor N = DIDescriptor());
467
468   /// Compute the size of a header for this unit, not including the initial
469   /// length field.
470   virtual unsigned getHeaderSize() const {
471     return sizeof(int16_t) + // DWARF version number
472            sizeof(int32_t) + // Offset Into Abbrev. Section
473            sizeof(int8_t);   // Pointer Size (in bytes)
474   }
475
476   /// Emit the header for this unit, not including the initial length field.
477   virtual void emitHeader(const MCSection *ASection,
478                           const MCSymbol *ASectionSym) const;
479
480   virtual DwarfCompileUnit &getCU() = 0;
481
482 protected:
483   /// getOrCreateStaticMemberDIE - Create new static data member DIE.
484   DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
485
486 private:
487   /// constructTypeDIE - Construct basic type die from DIBasicType.
488   void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
489
490   /// constructTypeDIE - Construct derived type die from DIDerivedType.
491   void constructTypeDIE(DIE &Buffer, DIDerivedType DTy);
492
493   /// constructTypeDIE - Construct type DIE from DICompositeType.
494   void constructTypeDIE(DIE &Buffer, DICompositeType CTy);
495
496   /// constructSubrangeDIE - Construct subrange DIE from DISubrange.
497   void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
498
499   /// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
500   void constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy);
501
502   /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
503   void constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy);
504
505   /// constructMemberDIE - Construct member DIE from DIDerivedType.
506   void constructMemberDIE(DIE &Buffer, DIDerivedType DT);
507
508   /// constructTemplateTypeParameterDIE - Construct new DIE for the given
509   /// DITemplateTypeParameter.
510   void constructTemplateTypeParameterDIE(DIE &Buffer,
511                                          DITemplateTypeParameter TP);
512
513   /// constructTemplateValueParameterDIE - Construct new DIE for the given
514   /// DITemplateValueParameter.
515   void constructTemplateValueParameterDIE(DIE &Buffer,
516                                           DITemplateValueParameter TVP);
517
518   /// getLowerBoundDefault - Return the default lower bound for an array. If the
519   /// DWARF version doesn't handle the language, return -1.
520   int64_t getDefaultLowerBound() const;
521
522   /// getDIEEntry - Returns the debug information entry for the specified
523   /// debug variable.
524   DIEEntry *getDIEEntry(const MDNode *N) const {
525     return MDNodeToDIEEntryMap.lookup(N);
526   }
527
528   /// insertDIEEntry - Insert debug information entry into the map.
529   void insertDIEEntry(const MDNode *N, DIEEntry *E) {
530     MDNodeToDIEEntryMap.insert(std::make_pair(N, E));
531   }
532
533   // getIndexTyDie - Get an anonymous type for index type.
534   DIE *getIndexTyDie() { return IndexTyDie; }
535
536   // setIndexTyDie - Set D as anonymous type for index which can be reused
537   // later.
538   void setIndexTyDie(DIE *D) { IndexTyDie = D; }
539
540   /// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug
541   /// information entry.
542   DIEEntry *createDIEEntry(DIE *Entry);
543
544   /// resolve - Look in the DwarfDebug map for the MDNode that
545   /// corresponds to the reference.
546   template <typename T> T resolve(DIRef<T> Ref) const {
547     return DD->resolve(Ref);
548   }
549
550   /// If this is a named finished type then include it in the list of types for
551   /// the accelerator tables.
552   void updateAcceleratorTables(DIScope Context, DIType Ty, const DIE *TyDIE);
553 };
554
555 class DwarfCompileUnit : public DwarfUnit {
556   /// The attribute index of DW_AT_stmt_list in the compile unit DIE, avoiding
557   /// the need to search for it in applyStmtList.
558   unsigned stmtListIndex;
559
560 public:
561   DwarfCompileUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A,
562                    DwarfDebug *DW, DwarfFile *DWU);
563
564   void initStmtList(MCSymbol *DwarfLineSectionSym);
565
566   /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
567   void applyStmtList(DIE &D);
568
569   /// createGlobalVariableDIE - create global variable DIE.
570   void createGlobalVariableDIE(DIGlobalVariable GV);
571
572   /// addLabelAddress - Add a dwarf label attribute data and value using
573   /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
574   void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label);
575
576   DwarfCompileUnit &getCU() override { return *this; }
577 };
578
579 class DwarfTypeUnit : public DwarfUnit {
580 private:
581   uint64_t TypeSignature;
582   const DIE *Ty;
583   DwarfCompileUnit &CU;
584
585 public:
586   DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU, AsmPrinter *A,
587                 DwarfDebug *DW, DwarfFile *DWU);
588
589   void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
590   uint64_t getTypeSignature() const { return TypeSignature; }
591   void setType(const DIE *Ty) { this->Ty = Ty; }
592
593   /// Emit the header for this unit, not including the initial length field.
594   void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym) const
595       override;
596   unsigned getHeaderSize() const override {
597     return DwarfUnit::getHeaderSize() + sizeof(uint64_t) + // Type Signature
598            sizeof(uint32_t);                               // Type DIE Offset
599   }
600   void initSection(const MCSection *Section);
601   DwarfCompileUnit &getCU() override { return CU; }
602 };
603 } // end llvm namespace
604 #endif