13#ifndef LLVM_CODEGEN_DIE_H
14#define LLVM_CODEGEN_DIE_H
41class DwarfCompileUnit;
120 Data.push_back(AbbrevData);
147 std::vector<DIEAbbrev *> Abbreviations;
177 const int64_t SignedInt =
Int;
178 if ((
char)
Int == SignedInt)
179 return dwarf::DW_FORM_data1;
180 if ((
short)
Int == SignedInt)
181 return dwarf::DW_FORM_data2;
182 if ((
int)
Int == SignedInt)
183 return dwarf::DW_FORM_data4;
185 if ((
unsigned char)
Int ==
Int)
186 return dwarf::DW_FORM_data1;
187 if ((
unsigned short)
Int ==
Int)
188 return dwarf::DW_FORM_data2;
189 if ((
unsigned int)
Int ==
Int)
190 return dwarf::DW_FORM_data4;
192 return dwarf::DW_FORM_data8;
243 static constexpr unsigned ULEB128PadSize = 4;
301 template <
typename Allocator>
378#define HANDLE_DIEVALUE(T) is##T,
379#include "llvm/CodeGen/DIEValue.def"
393 AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
394 DIEDelta *, DIEEntry, DIEBlock *, DIELoc *,
395 DIELocList, DIEBaseTypeRef *, DIEAddrOffset *>;
397 static_assert(
sizeof(ValTy) <=
sizeof(
uint64_t) ||
398 sizeof(ValTy) <=
sizeof(
void *),
399 "Expected all large types to be stored via pointer");
404 template <
class T>
void construct(
T V) {
405 static_assert(std::is_standard_layout<T>::value ||
406 std::is_pointer<T>::value,
407 "Expected standard layout or pointer");
408 new (
reinterpret_cast<void *
>(&Val))
T(
V);
411 template <
class T>
T *get() {
return reinterpret_cast<T *
>(&Val); }
412 template <
class T>
const T *get()
const {
413 return reinterpret_cast<const T *
>(&Val);
415 template <
class T>
void destruct() { get<T>()->~T(); }
426#define HANDLE_DIEVALUE_SMALL(T) \
428 destruct<DIE##T>(); \
430#define HANDLE_DIEVALUE_LARGE(T) \
432 destruct<const DIE##T *>(); \
434#include "llvm/CodeGen/DIEValue.def"
447#define HANDLE_DIEVALUE_SMALL(T) \
449 construct<DIE##T>(*X.get<DIE##T>()); \
451#define HANDLE_DIEVALUE_LARGE(T) \
453 construct<const DIE##T *>(*X.get<const DIE##T *>()); \
455#include "llvm/CodeGen/DIEValue.def"
479#define HANDLE_DIEVALUE_SMALL(T) \
480 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T &V) \
481 : Ty(is##T), Attribute(Attribute), Form(Form) { \
482 construct<DIE##T>(V); \
484#define HANDLE_DIEVALUE_LARGE(T) \
485 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T *V) \
486 : Ty(is##T), Attribute(Attribute), Form(Form) { \
487 assert(V && "Expected valid value"); \
488 construct<const DIE##T *>(V); \
490#include "llvm/CodeGen/DIEValue.def"
497 explicit operator bool()
const {
return Ty; }
500#define HANDLE_DIEVALUE_SMALL(T) \
501 const DIE##T &getDIE##T() const { \
502 assert(getType() == is##T && "Expected " #T); \
503 return *get<DIE##T>(); \
505#define HANDLE_DIEVALUE_LARGE(T) \
506 const DIE##T &getDIE##T() const { \
507 assert(getType() == is##T && "Expected " #T); \
508 return **get<const DIE##T *>(); \
510#include "llvm/CodeGen/DIEValue.def"
513 void emitValue(
const AsmPrinter *AP)
const;
516 unsigned sizeOf(
const dwarf::FormParams &FormParams)
const;
518 void print(raw_ostream &O)
const;
528 return Next.getInt() ? nullptr :
Next.getPointer();
540 assert(
N.Next.getPointer() == &
N &&
"Expected unlinked node");
541 assert(
N.Next.getInt() ==
true &&
"Expected unlinked node");
551 assert(
N.Next.getPointer() == &
N &&
"Expected unlinked node");
552 assert(
N.Next.getInt() ==
true &&
"Expected unlinked node");
555 N.Next.setPointerAndInt(
Last->
Next.getPointer(),
false);
573 return *
static_cast<T *
>(
Last ?
Last->
Next.getPointer() :
nullptr);
576 return *
static_cast<T *
>(
Last ?
Last->
Next.getPointer() :
nullptr);
583 T *FirstNode =
static_cast<T *
>(
Other.Last->Next.getPointer());
584 T *IterNode = FirstNode;
587 T *TmpNode = IterNode;
588 IterNode =
static_cast<T *
>(IterNode->Next.getPointer());
591 TmpNode->Next.setPointerAndInt(TmpNode,
true);
593 }
while (IterNode != FirstNode);
595 Other.Last =
nullptr;
606 while (cur && cur->
Next.getPointer()) {
607 if (cur->
Next.getPointer() == &
N) {
608 cur->
Next.setPointer(cur->
Next.getPointer()->Next.getPointer());
611 cur = cur->
Next.getPointer();
633 explicit operator bool()
const {
return N; }
642 const Node *N =
nullptr;
655 explicit operator bool()
const {
return N; }
704 std::forward_iterator_tag, DIEValue> {
709 std::forward_iterator_tag,
DIEValue>;
720 const_value_iterator, ListTy::const_iterator,
721 std::forward_iterator_tag, const DIEValue> {
724 std::forward_iterator_tag,
const DIEValue>;
758 DIEValue(NewAttribute,
Form, std::forward<T>(NewValue));
793 for (
auto &node :
List) {
794 if (node.V.getAttribute() ==
Attribute) {
795 return List.deleteNode(node);
827 unsigned AbbrevNumber = ~0u;
832 bool ForceChildren =
false;
859 assert(
Offset &&
"Offset being queried before it's been computed.");
864 assert(
Size &&
"Size being queried before it's been ocmputed.");
867 bool hasChildren()
const {
return ForceChildren || !Children.empty(); }
876 return make_range(Children.begin(), Children.end());
879 return make_range(Children.begin(), Children.end());
937 Children.push_back(*Child);
938 return Children.back();
944 Children.push_front(*Child);
945 return Children.front();
986 this->Section = Section;
1011 mutable unsigned Size = 0;
1025 if (DwarfVersion > 3)
1026 return dwarf::DW_FORM_exprloc;
1028 if ((
unsigned char)Size == Size)
1029 return dwarf::DW_FORM_block1;
1030 if ((
unsigned short)Size == Size)
1031 return dwarf::DW_FORM_block2;
1032 if ((
unsigned int)Size == Size)
1033 return dwarf::DW_FORM_block4;
1034 return dwarf::DW_FORM_block;
1047 mutable unsigned Size = 0;
1061 if ((
unsigned char)Size == Size)
1062 return dwarf::DW_FORM_block1;
1063 if ((
unsigned short)Size == Size)
1064 return dwarf::DW_FORM_block2;
1065 if ((
unsigned int)Size == Size)
1066 return dwarf::DW_FORM_block4;
1067 return dwarf::DW_FORM_block;
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file contains constants used for implementing Dwarf debug support.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file defines a hash set that can be used to remove duplication of nodes in a graph.
This file defines the PointerIntPair class.
This file defines the PointerUnion class, which is a discriminated union of pointer types.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This class is intended to be used as a driving class for all asm writers.
Allocate memory in an ever growing pool, as if by bump-pointer.
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
dwarf::Form getForm() const
dwarf::Attribute getAttribute() const
Accessors.
DIEAbbrevData(dwarf::Attribute A, int64_t V)
DIEAbbrevData(dwarf::Attribute A, dwarf::Form F)
Helps unique DIEAbbrev objects and assigns abbreviation numbers.
DIEAbbrevSet(BumpPtrAllocator &A)
DIEAbbrev & uniqueAbbreviation(DIE &Die)
Generate the abbreviation declaration for a DIE and return a pointer to the generated abbreviation.
Dwarf abbreviation, describes the organization of a debug information object.
void print(raw_ostream &O) const
void AddImplicitConstAttribute(dwarf::Attribute Attribute, int64_t Value)
Adds attribute with DW_FORM_implicit_const value.
unsigned getNumber() const
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
Adds another set of attribute information to the abbreviation.
void AddAttribute(const DIEAbbrevData &AbbrevData)
Adds another set of attribute information to the abbreviation.
const SmallVectorImpl< DIEAbbrevData > & getData() const
DIEAbbrev(dwarf::Tag T, bool C)
void setChildrenFlag(bool hasChild)
dwarf::Tag getTag() const
Accessors.
void setNumber(unsigned N)
void print(raw_ostream &O) const
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
DIEAddrOffset(uint64_t Idx, const MCSymbol *Hi, const MCSymbol *Lo)
uint64_t getIndex() const
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit base type reference.
void print(raw_ostream &O) const
DIEBaseTypeRef(const DwarfCompileUnit *TheCU, uint64_t Idx)
unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
sizeOf - Determine size of the base type reference in bytes.
DIEBlock - Represents a block of values.
unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of block data in bytes.
void setSize(unsigned size)
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
void print(raw_ostream &O) const
void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit block data.
unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
A simple label difference DIE.
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
void print(raw_ostream &O) const
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
A pointer to another debug information entry.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit debug information entry offset.
void print(raw_ostream &O) const
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
void print(raw_ostream &O) const
const MCExpr * getValue() const
Get MCExpr.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
A container for inline string values.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
~DIEInlineString()=default
void print(raw_ostream &O) const
unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
StringRef getString() const
Grab the string out of the object.
DIEInlineString(StringRef Str, Allocator &A)
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of integer value in bytes.
uint64_t getValue() const
void setValue(uint64_t Val)
void print(raw_ostream &O) const
void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
const MCSymbol * getValue() const
Get MCSymbol.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
void print(raw_ostream &O) const
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of label value in bytes.
DIELabel(const MCSymbol *L)
Represents a pointer to a location list in the debug_loc section.
void print(raw_ostream &O) const
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
size_t getValue() const
Grab the current index out.
DIELoc - Represents an expression location.
void setSize(unsigned size)
void print(raw_ostream &O) const
unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of location data in bytes.
void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit location data.
unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
A container for string pool string values.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit string value.
DIEString(DwarfStringPoolEntryRef S)
void print(raw_ostream &O) const
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of delta value in bytes.
StringRef getString() const
Grab the string out of the object.
Represents a compile or type unit.
void setSection(MCSection *Section)
Set the section that this DIEUnit will be emitted into.
void operator=(const DIEUnit &&RHS)=delete
DIEUnit(DIEUnit &&RHS)=delete
void operator=(const DIEUnit &RHS)=delete
const DIE & getUnitDie() const
DIEUnit(const DIEUnit &RHS)=delete
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
void setDebugSectionOffset(uint64_t O)
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
virtual ~DIEUnit()=default
.debug_info or .debug_types absolute section offset.
uint64_t getDebugSectionOffset() const
const_value_iterator()=default
const DIEValue & operator*() const
const_value_iterator(DIEValueList::value_iterator X)
const_value_iterator(ListTy::const_iterator X)
value_iterator(ListTy::iterator X)
DIEValue & operator*() const
bool deleteValue(dwarf::Attribute Attribute)
void takeValues(DIEValueList &Other)
Take ownership of the nodes in Other, and append them to the back of the list.
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Attribute NewAttribute, dwarf::Form Form, T &&NewValue)
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&NewValue)
value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V)
const_value_range values() const
value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, DIEValue &NewValue)
void print(raw_ostream &O) const
void emitValue(const AsmPrinter *AP) const
Emit value via the Dwarf writer.
unsigned sizeOf(const dwarf::FormParams &FormParams) const
Return the size of a value in bytes.
dwarf::Form getForm() const
Type getType() const
Accessors.
DIEValue(const DIEValue &X)
DIEValue & operator=(const DIEValue &X)
dwarf::Attribute getAttribute() const
A structured debug information entry.
DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
void print(raw_ostream &O, unsigned IndentCount=0) const
unsigned getAbbrevNumber() const
const_child_range children() const
DIE & addChild(DIE *Child)
Add a child to the DIE.
DIE(const DIE &RHS)=delete
DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
unsigned computeOffsetsAndAbbrevs(const dwarf::FormParams &FormParams, DIEAbbrevSet &AbbrevSet, unsigned CUOffset)
Compute the offset of this DIE and all its children.
DIE & addChildFront(DIE *Child)
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to.
DIE & operator=(const DIE &RHS)=delete
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.
void setAbbrevNumber(unsigned I)
Set the abbreviation number for this DIE.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
void setOffset(unsigned O)
void setForceChildren(bool B)
uint64_t getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
dwarf::Tag getTag() const
DIE & operator=(const DIE &&RHS)=delete
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
StringRef getString() const
Node - This class is used to maintain the singly linked bucket list in a folding set.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
const T & operator*() const
bool operator==(const const_iterator &X) const
const_iterator(typename IntrusiveBackList< T >::iterator X)
const_iterator & operator++()
const_iterator(const T *N)
bool operator==(const iterator &X) const
void takeNodes(IntrusiveBackList< T > &Other)
static const_iterator toIterator(const T &N)
const_iterator begin() const
const_iterator end() const
static iterator toIterator(T &N)
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
PointerIntPair - This class implements a pair of a pointer and small integer.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
CRTP base class for adapting an iterator to a different type.
const ListTy::iterator & wrapped() const
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
OutputIt copy(R &&Range, OutputIt Out)
BasicDIEUnit(dwarf::Tag UnitTag)
PointerIntPair< IntrusiveBackListNode *, 1 > Next
IntrusiveBackListNode * getNext() const