LLVM: lib/CodeGen/AsmPrinter/DwarfUnit.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFUNIT_H
14#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFUNIT_H
15
22#include
23#include
24
25namespace llvm {
26
32
33
34
35
37protected:
38
40
42
43
45
46
48
49
51
52
54
55
58
59
61
62
63
65
66
68
69
71
72
73
74
76
79
81
83
84 template
87
88
89
90
91
92 if (Attribute != 0 && Asm->TM.Options.DebugStrictDwarf &&
94 return;
95
98 }
99
100public:
101
103
105
114
115
117
118
119
120
121
122
123
124
126
127
129 const DIScope *Context) = 0;
130
131
133 const DIScope *Context) = 0;
134
136
137
138
139
140
141
143
144
146
147
148
149
150
151
153
155
156
158
159
162
164
165
167 std::optionaldwarf::Form Form, int64_t Integer);
168
171
172
175
176
177
178
179
180
181
183
184
187
189
190
192
193
194
197
198
201
202
204
205
207
208
210
211
213
214
218
219
221
222
231
232
238
239
241
242
244
245
247
248
250
251
253
254
255
256
257
260
265 bool Minimal = false);
266
268 bool SkipSPAttributes = false);
269
270
272
273
275
276
278
279
281
282
283
284
285
288
289
290
292
294 return DD->useSegmentedStringOffsetsTable();
295 }
296
297
298
300 return sizeof(int16_t) +
301 Asm->getDwarfOffsetByteSize() +
302 sizeof(int8_t) +
303 (DD->getDwarfVersion() >= 5 ? sizeof(int8_t)
304 : 0);
305 }
306
307
309
310
312
313
315
317
319
320
323
324
327
328
330
331
333
334
335
337 const DIE &TyDIE);
338
339protected:
341
342
344
345
346
348
349
351
353
354 return Minimal || SP->getDeclaration();
355 }
356
358 bool IgnoreScope) {
359 if (IgnoreScope)
362 }
363
364private:
367 }
368
369
370
371 void addIntAsBlock(DIE &Die, dwarf::Attribute Attribute, const APInt &Val);
372
373
374 void addDiscriminant(DIE &Variant, Constant *Discriminant, bool IsUnsigned);
375
377 void constructTypeDIE(DIE &Buffer, const DIFixedPointType *BTy);
379 void constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy);
380 void constructTypeDIE(DIE &Buffer, const DISubroutineType *CTy);
381 void constructSubrangeDIE(DIE &Buffer, const DISubrangeType *SR,
382 bool ForArray = false);
383 void constructSubrangeDIE(DIE &Buffer, const DISubrange *SR);
384 void constructGenericSubrangeDIE(DIE &Buffer, const DIGenericSubrange *SR);
385 void constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy);
386 void constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy);
387 DIE &constructMemberDIE(DIE &Buffer, const DIDerivedType *DT);
388 void constructTemplateTypeParameterDIE(DIE &Buffer,
389 const DITemplateTypeParameter *TP);
390 void constructTemplateValueParameterDIE(DIE &Buffer,
391 const DITemplateValueParameter *TVP);
392
393
394
395
396 int64_t getDefaultLowerBound() const;
397
398
399 DIE *getIndexTyDie();
400
401
402 void setIndexTyDie(DIE *D) { IndexTyDie = D; }
403
404 virtual void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) = 0;
405
406 virtual bool isDwoUnit() const = 0;
408
409
410
411 bool isCompatibleWithVersion(uint16_t Version) const;
412};
413
416 const DIE *Ty;
419 bool UsedLineTable = false;
420
421 unsigned getOrCreateSourceID(const DIFile *File) override;
423 bool isDwoUnit() const override;
424
425public:
429
431
434
435
436 void emitHeader(bool UseOffsets) override;
439 Asm->getDwarfOffsetByteSize();
440 }
442 const DIScope *Context) override;
444 const DIScope *Context) override;
446};
447}
448#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file defines the DenseMap class.
Class for arbitrary precision integers.
Annotations lets you mark points and ranges inside source code, for tests:
This class is intended to be used as a driving class for all asm writers.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
ConstantFP - Floating Point Values [float, double].
This is the shared class of boolean and integer constants.
DISourceLanguageName getSourceLanguage() const
DIEBlock - Represents a block of values.
A pointer to another debug information entry.
DIELoc - Represents an expression location.
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
LLVM_ABI DIEUnit(dwarf::Tag UnitTag)
A structured debug information entry.
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Tagged DWARF-like metadata node.
Base class for scope-like contexts.
Wrapper structure that holds a language name and its version.
Subprogram description. Uses SubclassData1.
Collects and handles dwarf debug information.
DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID, MCDwarfDwoLineTable *SplitLineTable=nullptr)
void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context) override
Add a new global type to the compile unit.
unsigned getHeaderSize() const override
Compute the size of a header for this unit, not including the initial length field.
Definition DwarfUnit.h:437
DwarfCompileUnit & getCU() override
Definition DwarfUnit.h:445
uint64_t getTypeSignature() const
Returns Type Signature.
Definition DwarfUnit.h:432
void emitHeader(bool UseOffsets) override
Emit the header for this unit, not including the initial length field.
void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context) override
Add a new global name to the compile unit.
void setTypeSignature(uint64_t Signature)
Definition DwarfUnit.h:430
void setType(const DIE *Ty)
Definition DwarfUnit.h:433
virtual DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
void addInt(DIE &Die, dwarf::Attribute Attribute, const APInt &Integer, bool Unsigned)
Add an integer attribute data and value; value may be any width.
DwarfDebug & getDwarfDebug() const
Definition DwarfUnit.h:113
void addThrownTypes(DIE &Die, DINodeArray ThrownTypes)
Add thrown types.
void addStringOffsetsStart()
Add the DW_AT_str_offsets_base attribute to the unit DIE.
void addAnnotation(DIE &Buffer, DINodeArray Annotations)
Add DW_TAG_LLVM_annotation.
std::vector< DIEBlock * > DIEBlocks
A list of all the DIEBlocks in use.
Definition DwarfUnit.h:67
std::vector< DIELoc * > DIELocs
A list of all the DIELocs in use.
Definition DwarfUnit.h:70
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)
Add block data.
void addTemplateParams(DIE &Buffer, DINodeArray TParams)
Add template parameters in buffer.
virtual DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
bool useSegmentedStringOffsetsTable() const
Definition DwarfUnit.h:293
bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal)
DIELoc * getDIELoc()
Returns a fresh newly allocated DIELoc.
Definition DwarfUnit.h:145
void updateAcceleratorTables(const DIScope *Context, const DIType *Ty, const DIE &TyDIE)
If this is a named finished type then include it in the list of types for the accelerator tables.
virtual void emitHeader(bool UseOffsets)=0
Emit the header for this unit, not including the initial length field.
void addAttribute(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
Definition DwarfUnit.h:85
void addOpAddress(DIELoc &Die, const MCSymbol *Sym)
Add a dwarf op address data and value using the form given and an op of either DW_FORM_addr or DW_FOR...
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty)
Add constant value entry in variable DIE.
DIE * getOrCreateNameSpace(const DINamespace *NS)
void insertDIE(const DINode *Desc, DIE *D)
Insert DIE into the map.
void addAccess(DIE &Die, DINode::DIFlags Flags)
Add the accessibility attribute.
void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
addSectionDelta - Add a label delta attribute data and value.
void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context)
DIE * createTypeDIE(const DIScope *Context, DIE &ContextDIE, const DIType *Ty)
Creates type DIE with specific context.
bool shouldPlaceInUnitDIE(const DISubprogram *SP, bool Minimal)
Definition DwarfUnit.h:352
DwarfDebug * DD
Definition DwarfUnit.h:56
DenseMap< DIE *, const DINode * > ContainingTypeMap
This map is used to keep track of subprogram DIEs that need DW_AT_containing_type attribute.
Definition DwarfUnit.h:75
const DICompileUnit * CUNode
MDNode for the compile unit.
Definition DwarfUnit.h:41
virtual unsigned getOrCreateSourceID(const DIFile *File)=0
Look up the source ID for the given file.
virtual DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, const Function *FnHint, bool Minimal=false)
DIE * getOrCreateSubprogramContextDIE(const DISubprogram *SP, bool IgnoreScope)
Definition DwarfUnit.h:357
virtual void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context)=0
Add a new global type to the compile unit.
void addDIETypeSignature(DIE &Die, uint64_t Signature)
Add a type's DW_AT_signature and set the declaration flag.
std::optional< unsigned > constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args)
Construct function argument DIEs.
virtual DwarfCompileUnit & getCU()=0
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
AsmPrinter * getAsmPrinter() const
Definition DwarfUnit.h:104
virtual unsigned getHeaderSize() const
Compute the size of a header for this unit, not including the initial length field.
Definition DwarfUnit.h:299
bool hasContent() const
Return true if this compile unit has something to write out.
Definition DwarfUnit.h:116
MCSymbol * LabelBegin
The start of the unit within its section.
Definition DwarfUnit.h:50
void addSInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, int64_t Integer)
Add an signed integer attribute data and value.
DwarfUnit(dwarf::Tag, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID=0)
void addLabelDelta(DIEValueList &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
Add a label delta attribute data and value.
void addLinkageName(DIE &Die, StringRef LinkageName)
Add a linkage name, if it isn't empty.
MCSymbol * getEndLabel() const
Definition DwarfUnit.h:110
std::string getParentContextString(const DIScope *Context) const
Get string containing language specific context for a global name.
void addSourceLine(DIE &Die, unsigned Line, unsigned Column, const DIFile *File)
Add location information to specified debug information entry.
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT)
Emit the common part of the header for this unit.
BumpPtrAllocator DIEValueAllocator
Definition DwarfUnit.h:44
DIE * IndexTyDie
An anonymous type for index type. Owned by DIEUnit.
Definition DwarfUnit.h:60
void addRnglistsBase()
Add the DW_AT_rnglists_base attribute to the unit DIE.
DIE * getOrCreateModule(const DIModule *M)
const DICompileUnit * getCUNode() const
Definition DwarfUnit.h:112
DIE & createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N=nullptr)
Create a DIE with the given Tag, add the DIE to its parent, and call insertDIE if MD is not null.
DwarfFile * DU
Definition DwarfUnit.h:57
void addSectionOffset(DIE &Die, dwarf::Attribute Attribute, uint64_t Integer)
Add an offset into a section attribute data and value.
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
void addConstantFPValue(DIE &Die, const ConstantFP *CFP)
Add constant value entry in variable DIE.
void constructContainingTypeDIEs()
Construct DIEs for types that contain vtables.
unsigned UniqueID
A numeric ID unique among all CUs in the module.
Definition DwarfUnit.h:39
void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
bool isShareableAcrossCUs(const DINode *D) const
Check whether the DIE for this MDNode can be shared across CUs.
llvm::dwarf::SourceLanguage getSourceLanguage() const
void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)
MCSymbol * getLabelBegin() const
Get the the symbol for start of the section for this unit.
Definition DwarfUnit.h:106
DenseMap< const MDNode *, DIE * > MDNodeToDieMap
Tracks the mapping of unit level debug information variables to debug information entries.
Definition DwarfUnit.h:64
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)
virtual void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context)=0
Add a new global name to the compile unit.
MCSymbol * EndLabel
Emitted at the end of the CU and used to compute the CU Length field.
Definition DwarfUnit.h:53
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
AsmPrinter * Asm
Target of Dwarf emission.
Definition DwarfUnit.h:47
unsigned getUniqueID() const
Gets Unique ID for this unit.
Definition DwarfUnit.h:102
void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
Add a new type attribute to the specified entity.
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
LLVM_ABI unsigned AttributeVersion(Attribute A)
UnitType
Constants for unit types in DWARF v5.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.