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