xref: /freebsd/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===- llvm/CodeGen/DwarfCompileUnit.h - Dwarf Compile Unit -----*- C++ -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric //
9*0b57cec5SDimitry Andric // This file contains support for writing dwarf compile unit.
10*0b57cec5SDimitry Andric //
11*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
12*0b57cec5SDimitry Andric 
13*0b57cec5SDimitry Andric #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
14*0b57cec5SDimitry Andric #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
15*0b57cec5SDimitry Andric 
16*0b57cec5SDimitry Andric #include "DwarfDebug.h"
17*0b57cec5SDimitry Andric #include "DwarfUnit.h"
18*0b57cec5SDimitry Andric #include "llvm/ADT/ArrayRef.h"
19*0b57cec5SDimitry Andric #include "llvm/ADT/DenseMap.h"
20*0b57cec5SDimitry Andric #include "llvm/ADT/SmallVector.h"
21*0b57cec5SDimitry Andric #include "llvm/ADT/StringMap.h"
22*0b57cec5SDimitry Andric #include "llvm/ADT/StringRef.h"
23*0b57cec5SDimitry Andric #include "llvm/BinaryFormat/Dwarf.h"
24*0b57cec5SDimitry Andric #include "llvm/CodeGen/DbgEntityHistoryCalculator.h"
25*0b57cec5SDimitry Andric #include "llvm/CodeGen/DIE.h"
26*0b57cec5SDimitry Andric #include "llvm/CodeGen/LexicalScopes.h"
27*0b57cec5SDimitry Andric #include "llvm/IR/DebugInfoMetadata.h"
28*0b57cec5SDimitry Andric #include "llvm/Support/Casting.h"
29*0b57cec5SDimitry Andric #include <algorithm>
30*0b57cec5SDimitry Andric #include <cassert>
31*0b57cec5SDimitry Andric #include <cstdint>
32*0b57cec5SDimitry Andric #include <memory>
33*0b57cec5SDimitry Andric 
34*0b57cec5SDimitry Andric namespace llvm {
35*0b57cec5SDimitry Andric 
36*0b57cec5SDimitry Andric class AsmPrinter;
37*0b57cec5SDimitry Andric class DwarfFile;
38*0b57cec5SDimitry Andric class GlobalVariable;
39*0b57cec5SDimitry Andric class MCExpr;
40*0b57cec5SDimitry Andric class MCSymbol;
41*0b57cec5SDimitry Andric class MDNode;
42*0b57cec5SDimitry Andric 
43*0b57cec5SDimitry Andric class DwarfCompileUnit final : public DwarfUnit {
44*0b57cec5SDimitry Andric   /// A numeric ID unique among all CUs in the module
45*0b57cec5SDimitry Andric   unsigned UniqueID;
46*0b57cec5SDimitry Andric   bool HasRangeLists = false;
47*0b57cec5SDimitry Andric 
48*0b57cec5SDimitry Andric   /// The attribute index of DW_AT_stmt_list in the compile unit DIE, avoiding
49*0b57cec5SDimitry Andric   /// the need to search for it in applyStmtList.
50*0b57cec5SDimitry Andric   DIE::value_iterator StmtListValue;
51*0b57cec5SDimitry Andric 
52*0b57cec5SDimitry Andric   /// Skeleton unit associated with this unit.
53*0b57cec5SDimitry Andric   DwarfCompileUnit *Skeleton = nullptr;
54*0b57cec5SDimitry Andric 
55*0b57cec5SDimitry Andric   /// The start of the unit within its section.
56*0b57cec5SDimitry Andric   MCSymbol *LabelBegin;
57*0b57cec5SDimitry Andric 
58*0b57cec5SDimitry Andric   /// The start of the unit macro info within macro section.
59*0b57cec5SDimitry Andric   MCSymbol *MacroLabelBegin;
60*0b57cec5SDimitry Andric 
61*0b57cec5SDimitry Andric   using ImportedEntityList = SmallVector<const MDNode *, 8>;
62*0b57cec5SDimitry Andric   using ImportedEntityMap = DenseMap<const MDNode *, ImportedEntityList>;
63*0b57cec5SDimitry Andric 
64*0b57cec5SDimitry Andric   ImportedEntityMap ImportedEntities;
65*0b57cec5SDimitry Andric 
66*0b57cec5SDimitry Andric   /// GlobalNames - A map of globally visible named entities for this unit.
67*0b57cec5SDimitry Andric   StringMap<const DIE *> GlobalNames;
68*0b57cec5SDimitry Andric 
69*0b57cec5SDimitry Andric   /// GlobalTypes - A map of globally visible types for this unit.
70*0b57cec5SDimitry Andric   StringMap<const DIE *> GlobalTypes;
71*0b57cec5SDimitry Andric 
72*0b57cec5SDimitry Andric   // List of ranges for a given compile unit.
73*0b57cec5SDimitry Andric   SmallVector<RangeSpan, 2> CURanges;
74*0b57cec5SDimitry Andric 
75*0b57cec5SDimitry Andric   // The base address of this unit, if any. Used for relative references in
76*0b57cec5SDimitry Andric   // ranges/locs.
77*0b57cec5SDimitry Andric   const MCSymbol *BaseAddress = nullptr;
78*0b57cec5SDimitry Andric 
79*0b57cec5SDimitry Andric   DenseMap<const MDNode *, DIE *> AbstractSPDies;
80*0b57cec5SDimitry Andric   DenseMap<const DINode *, std::unique_ptr<DbgEntity>> AbstractEntities;
81*0b57cec5SDimitry Andric 
82*0b57cec5SDimitry Andric   /// DWO ID for correlating skeleton and split units.
83*0b57cec5SDimitry Andric   uint64_t DWOId = 0;
84*0b57cec5SDimitry Andric 
85*0b57cec5SDimitry Andric   /// Construct a DIE for the given DbgVariable without initializing the
86*0b57cec5SDimitry Andric   /// DbgVariable's DIE reference.
87*0b57cec5SDimitry Andric   DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract);
88*0b57cec5SDimitry Andric 
89*0b57cec5SDimitry Andric   bool isDwoUnit() const override;
90*0b57cec5SDimitry Andric 
91*0b57cec5SDimitry Andric   DenseMap<const MDNode *, DIE *> &getAbstractSPDies() {
92*0b57cec5SDimitry Andric     if (isDwoUnit() && !DD->shareAcrossDWOCUs())
93*0b57cec5SDimitry Andric       return AbstractSPDies;
94*0b57cec5SDimitry Andric     return DU->getAbstractSPDies();
95*0b57cec5SDimitry Andric   }
96*0b57cec5SDimitry Andric 
97*0b57cec5SDimitry Andric   DenseMap<const DINode *, std::unique_ptr<DbgEntity>> &getAbstractEntities() {
98*0b57cec5SDimitry Andric     if (isDwoUnit() && !DD->shareAcrossDWOCUs())
99*0b57cec5SDimitry Andric       return AbstractEntities;
100*0b57cec5SDimitry Andric     return DU->getAbstractEntities();
101*0b57cec5SDimitry Andric   }
102*0b57cec5SDimitry Andric 
103*0b57cec5SDimitry Andric   void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) override;
104*0b57cec5SDimitry Andric 
105*0b57cec5SDimitry Andric public:
106*0b57cec5SDimitry Andric   DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A,
107*0b57cec5SDimitry Andric                    DwarfDebug *DW, DwarfFile *DWU);
108*0b57cec5SDimitry Andric 
109*0b57cec5SDimitry Andric   bool hasRangeLists() const { return HasRangeLists; }
110*0b57cec5SDimitry Andric   unsigned getUniqueID() const { return UniqueID; }
111*0b57cec5SDimitry Andric 
112*0b57cec5SDimitry Andric   DwarfCompileUnit *getSkeleton() const {
113*0b57cec5SDimitry Andric     return Skeleton;
114*0b57cec5SDimitry Andric   }
115*0b57cec5SDimitry Andric 
116*0b57cec5SDimitry Andric   bool includeMinimalInlineScopes() const;
117*0b57cec5SDimitry Andric 
118*0b57cec5SDimitry Andric   void initStmtList();
119*0b57cec5SDimitry Andric 
120*0b57cec5SDimitry Andric   /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
121*0b57cec5SDimitry Andric   void applyStmtList(DIE &D);
122*0b57cec5SDimitry Andric 
123*0b57cec5SDimitry Andric   /// A pair of GlobalVariable and DIExpression.
124*0b57cec5SDimitry Andric   struct GlobalExpr {
125*0b57cec5SDimitry Andric     const GlobalVariable *Var;
126*0b57cec5SDimitry Andric     const DIExpression *Expr;
127*0b57cec5SDimitry Andric   };
128*0b57cec5SDimitry Andric 
129*0b57cec5SDimitry Andric   struct BaseTypeRef {
130*0b57cec5SDimitry Andric     BaseTypeRef(unsigned BitSize, dwarf::TypeKind Encoding) :
131*0b57cec5SDimitry Andric       BitSize(BitSize), Encoding(Encoding) {}
132*0b57cec5SDimitry Andric     unsigned BitSize;
133*0b57cec5SDimitry Andric     dwarf::TypeKind Encoding;
134*0b57cec5SDimitry Andric     DIE *Die = nullptr;
135*0b57cec5SDimitry Andric   };
136*0b57cec5SDimitry Andric 
137*0b57cec5SDimitry Andric   std::vector<BaseTypeRef> ExprRefedBaseTypes;
138*0b57cec5SDimitry Andric 
139*0b57cec5SDimitry Andric   /// Get or create global variable DIE.
140*0b57cec5SDimitry Andric   DIE *
141*0b57cec5SDimitry Andric   getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV,
142*0b57cec5SDimitry Andric                                ArrayRef<GlobalExpr> GlobalExprs);
143*0b57cec5SDimitry Andric 
144*0b57cec5SDimitry Andric   DIE *getOrCreateCommonBlock(const DICommonBlock *CB,
145*0b57cec5SDimitry Andric                               ArrayRef<GlobalExpr> GlobalExprs);
146*0b57cec5SDimitry Andric 
147*0b57cec5SDimitry Andric   void addLocationAttribute(DIE *ToDIE, const DIGlobalVariable *GV,
148*0b57cec5SDimitry Andric                             ArrayRef<GlobalExpr> GlobalExprs);
149*0b57cec5SDimitry Andric 
150*0b57cec5SDimitry Andric   /// addLabelAddress - Add a dwarf label attribute data and value using
151*0b57cec5SDimitry Andric   /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
152*0b57cec5SDimitry Andric   void addLabelAddress(DIE &Die, dwarf::Attribute Attribute,
153*0b57cec5SDimitry Andric                        const MCSymbol *Label);
154*0b57cec5SDimitry Andric 
155*0b57cec5SDimitry Andric   /// addLocalLabelAddress - Add a dwarf label attribute data and value using
156*0b57cec5SDimitry Andric   /// DW_FORM_addr only.
157*0b57cec5SDimitry Andric   void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute,
158*0b57cec5SDimitry Andric                             const MCSymbol *Label);
159*0b57cec5SDimitry Andric 
160*0b57cec5SDimitry Andric   DwarfCompileUnit &getCU() override { return *this; }
161*0b57cec5SDimitry Andric 
162*0b57cec5SDimitry Andric   unsigned getOrCreateSourceID(const DIFile *File) override;
163*0b57cec5SDimitry Andric 
164*0b57cec5SDimitry Andric   void addImportedEntity(const DIImportedEntity* IE) {
165*0b57cec5SDimitry Andric     DIScope *Scope = IE->getScope();
166*0b57cec5SDimitry Andric     assert(Scope && "Invalid Scope encoding!");
167*0b57cec5SDimitry Andric     if (!isa<DILocalScope>(Scope))
168*0b57cec5SDimitry Andric       // No need to add imported enities that are not local declaration.
169*0b57cec5SDimitry Andric       return;
170*0b57cec5SDimitry Andric 
171*0b57cec5SDimitry Andric     auto *LocalScope = cast<DILocalScope>(Scope)->getNonLexicalBlockFileScope();
172*0b57cec5SDimitry Andric     ImportedEntities[LocalScope].push_back(IE);
173*0b57cec5SDimitry Andric   }
174*0b57cec5SDimitry Andric 
175*0b57cec5SDimitry Andric   /// addRange - Add an address range to the list of ranges for this unit.
176*0b57cec5SDimitry Andric   void addRange(RangeSpan Range);
177*0b57cec5SDimitry Andric 
178*0b57cec5SDimitry Andric   void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End);
179*0b57cec5SDimitry Andric 
180*0b57cec5SDimitry Andric   /// Find DIE for the given subprogram and attach appropriate
181*0b57cec5SDimitry Andric   /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
182*0b57cec5SDimitry Andric   /// variables in this scope then create and insert DIEs for these
183*0b57cec5SDimitry Andric   /// variables.
184*0b57cec5SDimitry Andric   DIE &updateSubprogramScopeDIE(const DISubprogram *SP);
185*0b57cec5SDimitry Andric 
186*0b57cec5SDimitry Andric   void constructScopeDIE(LexicalScope *Scope,
187*0b57cec5SDimitry Andric                          SmallVectorImpl<DIE *> &FinalChildren);
188*0b57cec5SDimitry Andric 
189*0b57cec5SDimitry Andric   /// A helper function to construct a RangeSpanList for a given
190*0b57cec5SDimitry Andric   /// lexical scope.
191*0b57cec5SDimitry Andric   void addScopeRangeList(DIE &ScopeDIE, SmallVector<RangeSpan, 2> Range);
192*0b57cec5SDimitry Andric 
193*0b57cec5SDimitry Andric   void attachRangesOrLowHighPC(DIE &D, SmallVector<RangeSpan, 2> Ranges);
194*0b57cec5SDimitry Andric 
195*0b57cec5SDimitry Andric   void attachRangesOrLowHighPC(DIE &D,
196*0b57cec5SDimitry Andric                                const SmallVectorImpl<InsnRange> &Ranges);
197*0b57cec5SDimitry Andric 
198*0b57cec5SDimitry Andric   /// This scope represents inlined body of a function. Construct
199*0b57cec5SDimitry Andric   /// DIE to represent this concrete inlined copy of the function.
200*0b57cec5SDimitry Andric   DIE *constructInlinedScopeDIE(LexicalScope *Scope);
201*0b57cec5SDimitry Andric 
202*0b57cec5SDimitry Andric   /// Construct new DW_TAG_lexical_block for this scope and
203*0b57cec5SDimitry Andric   /// attach DW_AT_low_pc/DW_AT_high_pc labels.
204*0b57cec5SDimitry Andric   DIE *constructLexicalScopeDIE(LexicalScope *Scope);
205*0b57cec5SDimitry Andric 
206*0b57cec5SDimitry Andric   /// constructVariableDIE - Construct a DIE for the given DbgVariable.
207*0b57cec5SDimitry Andric   DIE *constructVariableDIE(DbgVariable &DV, bool Abstract = false);
208*0b57cec5SDimitry Andric 
209*0b57cec5SDimitry Andric   DIE *constructVariableDIE(DbgVariable &DV, const LexicalScope &Scope,
210*0b57cec5SDimitry Andric                             DIE *&ObjectPointer);
211*0b57cec5SDimitry Andric 
212*0b57cec5SDimitry Andric   /// Construct a DIE for the given DbgLabel.
213*0b57cec5SDimitry Andric   DIE *constructLabelDIE(DbgLabel &DL, const LexicalScope &Scope);
214*0b57cec5SDimitry Andric 
215*0b57cec5SDimitry Andric   /// A helper function to create children of a Scope DIE.
216*0b57cec5SDimitry Andric   DIE *createScopeChildrenDIE(LexicalScope *Scope,
217*0b57cec5SDimitry Andric                               SmallVectorImpl<DIE *> &Children,
218*0b57cec5SDimitry Andric                               bool *HasNonScopeChildren = nullptr);
219*0b57cec5SDimitry Andric 
220*0b57cec5SDimitry Andric   void createBaseTypeDIEs();
221*0b57cec5SDimitry Andric 
222*0b57cec5SDimitry Andric   /// Construct a DIE for this subprogram scope.
223*0b57cec5SDimitry Andric   DIE &constructSubprogramScopeDIE(const DISubprogram *Sub,
224*0b57cec5SDimitry Andric                                    LexicalScope *Scope);
225*0b57cec5SDimitry Andric 
226*0b57cec5SDimitry Andric   DIE *createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE);
227*0b57cec5SDimitry Andric 
228*0b57cec5SDimitry Andric   void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
229*0b57cec5SDimitry Andric 
230*0b57cec5SDimitry Andric   /// Construct a call site entry DIE describing a call within \p Scope to a
231*0b57cec5SDimitry Andric   /// callee described by \p CalleeSP. \p IsTail specifies whether the call is
232*0b57cec5SDimitry Andric   /// a tail call. \p PCOffset must be non-zero for non-tail calls or be the
233*0b57cec5SDimitry Andric   /// function-local offset to PC value after the call instruction.
234*0b57cec5SDimitry Andric   DIE &constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram &CalleeSP,
235*0b57cec5SDimitry Andric                                  bool IsTail, const MCExpr *PCOffset);
236*0b57cec5SDimitry Andric 
237*0b57cec5SDimitry Andric   /// Construct import_module DIE.
238*0b57cec5SDimitry Andric   DIE *constructImportedEntityDIE(const DIImportedEntity *Module);
239*0b57cec5SDimitry Andric 
240*0b57cec5SDimitry Andric   void finishSubprogramDefinition(const DISubprogram *SP);
241*0b57cec5SDimitry Andric   void finishEntityDefinition(const DbgEntity *Entity);
242*0b57cec5SDimitry Andric 
243*0b57cec5SDimitry Andric   /// Find abstract variable associated with Var.
244*0b57cec5SDimitry Andric   using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
245*0b57cec5SDimitry Andric   DbgEntity *getExistingAbstractEntity(const DINode *Node);
246*0b57cec5SDimitry Andric   void createAbstractEntity(const DINode *Node, LexicalScope *Scope);
247*0b57cec5SDimitry Andric 
248*0b57cec5SDimitry Andric   /// Set the skeleton unit associated with this unit.
249*0b57cec5SDimitry Andric   void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; }
250*0b57cec5SDimitry Andric 
251*0b57cec5SDimitry Andric   unsigned getHeaderSize() const override {
252*0b57cec5SDimitry Andric     // DWARF v5 added the DWO ID to the header for split/skeleton units.
253*0b57cec5SDimitry Andric     unsigned DWOIdSize =
254*0b57cec5SDimitry Andric         DD->getDwarfVersion() >= 5 && DD->useSplitDwarf() ? sizeof(uint64_t)
255*0b57cec5SDimitry Andric                                                           : 0;
256*0b57cec5SDimitry Andric     return DwarfUnit::getHeaderSize() + DWOIdSize;
257*0b57cec5SDimitry Andric   }
258*0b57cec5SDimitry Andric   unsigned getLength() {
259*0b57cec5SDimitry Andric     return sizeof(uint32_t) + // Length field
260*0b57cec5SDimitry Andric         getHeaderSize() + getUnitDie().getSize();
261*0b57cec5SDimitry Andric   }
262*0b57cec5SDimitry Andric 
263*0b57cec5SDimitry Andric   void emitHeader(bool UseOffsets) override;
264*0b57cec5SDimitry Andric 
265*0b57cec5SDimitry Andric   /// Add the DW_AT_addr_base attribute to the unit DIE.
266*0b57cec5SDimitry Andric   void addAddrTableBase();
267*0b57cec5SDimitry Andric 
268*0b57cec5SDimitry Andric   MCSymbol *getLabelBegin() const {
269*0b57cec5SDimitry Andric     assert(getSection());
270*0b57cec5SDimitry Andric     return LabelBegin;
271*0b57cec5SDimitry Andric   }
272*0b57cec5SDimitry Andric 
273*0b57cec5SDimitry Andric   MCSymbol *getMacroLabelBegin() const {
274*0b57cec5SDimitry Andric     return MacroLabelBegin;
275*0b57cec5SDimitry Andric   }
276*0b57cec5SDimitry Andric 
277*0b57cec5SDimitry Andric   /// Add a new global name to the compile unit.
278*0b57cec5SDimitry Andric   void addGlobalName(StringRef Name, const DIE &Die,
279*0b57cec5SDimitry Andric                      const DIScope *Context) override;
280*0b57cec5SDimitry Andric 
281*0b57cec5SDimitry Andric   /// Add a new global name present in a type unit to this compile unit.
282*0b57cec5SDimitry Andric   void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context);
283*0b57cec5SDimitry Andric 
284*0b57cec5SDimitry Andric   /// Add a new global type to the compile unit.
285*0b57cec5SDimitry Andric   void addGlobalType(const DIType *Ty, const DIE &Die,
286*0b57cec5SDimitry Andric                      const DIScope *Context) override;
287*0b57cec5SDimitry Andric 
288*0b57cec5SDimitry Andric   /// Add a new global type present in a type unit to this compile unit.
289*0b57cec5SDimitry Andric   void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context);
290*0b57cec5SDimitry Andric 
291*0b57cec5SDimitry Andric   const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
292*0b57cec5SDimitry Andric   const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
293*0b57cec5SDimitry Andric 
294*0b57cec5SDimitry Andric   /// Add DW_AT_location attribute for a DbgVariable based on provided
295*0b57cec5SDimitry Andric   /// MachineLocation.
296*0b57cec5SDimitry Andric   void addVariableAddress(const DbgVariable &DV, DIE &Die,
297*0b57cec5SDimitry Andric                           MachineLocation Location);
298*0b57cec5SDimitry Andric   /// Add an address attribute to a die based on the location provided.
299*0b57cec5SDimitry Andric   void addAddress(DIE &Die, dwarf::Attribute Attribute,
300*0b57cec5SDimitry Andric                   const MachineLocation &Location);
301*0b57cec5SDimitry Andric 
302*0b57cec5SDimitry Andric   /// Start with the address based on the location provided, and generate the
303*0b57cec5SDimitry Andric   /// DWARF information necessary to find the actual variable (navigating the
304*0b57cec5SDimitry Andric   /// extra location information encoded in the type) based on the starting
305*0b57cec5SDimitry Andric   /// location.  Add the DWARF information to the die.
306*0b57cec5SDimitry Andric   void addComplexAddress(const DbgVariable &DV, DIE &Die,
307*0b57cec5SDimitry Andric                          dwarf::Attribute Attribute,
308*0b57cec5SDimitry Andric                          const MachineLocation &Location);
309*0b57cec5SDimitry Andric 
310*0b57cec5SDimitry Andric   /// Add a Dwarf loclistptr attribute data and value.
311*0b57cec5SDimitry Andric   void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index);
312*0b57cec5SDimitry Andric   void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie);
313*0b57cec5SDimitry Andric 
314*0b57cec5SDimitry Andric   /// Add a Dwarf expression attribute data and value.
315*0b57cec5SDimitry Andric   void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr);
316*0b57cec5SDimitry Andric 
317*0b57cec5SDimitry Andric   /// Add an attribute containing an address expression to \p Die.
318*0b57cec5SDimitry Andric   void addAddressExpr(DIE &Die, dwarf::Attribute Attribute, const MCExpr *Expr);
319*0b57cec5SDimitry Andric 
320*0b57cec5SDimitry Andric   void applySubprogramAttributesToDefinition(const DISubprogram *SP,
321*0b57cec5SDimitry Andric                                              DIE &SPDie);
322*0b57cec5SDimitry Andric 
323*0b57cec5SDimitry Andric   void applyLabelAttributes(const DbgLabel &Label, DIE &LabelDie);
324*0b57cec5SDimitry Andric 
325*0b57cec5SDimitry Andric   /// getRanges - Get the list of ranges for this unit.
326*0b57cec5SDimitry Andric   const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; }
327*0b57cec5SDimitry Andric   SmallVector<RangeSpan, 2> takeRanges() { return std::move(CURanges); }
328*0b57cec5SDimitry Andric 
329*0b57cec5SDimitry Andric   void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; }
330*0b57cec5SDimitry Andric   const MCSymbol *getBaseAddress() const { return BaseAddress; }
331*0b57cec5SDimitry Andric 
332*0b57cec5SDimitry Andric   uint64_t getDWOId() const { return DWOId; }
333*0b57cec5SDimitry Andric   void setDWOId(uint64_t DwoId) { DWOId = DwoId; }
334*0b57cec5SDimitry Andric 
335*0b57cec5SDimitry Andric   bool hasDwarfPubSections() const;
336*0b57cec5SDimitry Andric 
337*0b57cec5SDimitry Andric   void addBaseTypeRef(DIEValueList &Die, int64_t Idx);
338*0b57cec5SDimitry Andric };
339*0b57cec5SDimitry Andric 
340*0b57cec5SDimitry Andric } // end namespace llvm
341*0b57cec5SDimitry Andric 
342*0b57cec5SDimitry Andric #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
343