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