14 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
33 #include <type_traits>
142 std::vector<DIEAbbrev *> Abbreviations;
172 const int64_t SignedInt = Int;
173 if ((
char)Int == SignedInt)
174 return dwarf::DW_FORM_data1;
175 if ((
short)Int == SignedInt)
176 return dwarf::DW_FORM_data2;
177 if ((
int)Int == SignedInt)
178 return dwarf::DW_FORM_data4;
180 if ((
unsigned char)Int == Int)
181 return dwarf::DW_FORM_data1;
182 if ((
unsigned short)Int == Int)
183 return dwarf::DW_FORM_data2;
184 if ((
unsigned int)Int == Int)
185 return dwarf::DW_FORM_data4;
187 return dwarf::DW_FORM_data8;
276 template <
typename Allocator>
337 #define HANDLE_DIEVALUE(T) is##T,
338 #include "llvm/CodeGen/DIEValue.def"
351 using ValTy = AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
352 DIEDelta *, DIEEntry, DIEBlock *,
353 DIELoc *, DIELocList>;
355 static_assert(
sizeof(ValTy) <=
sizeof(uint64_t) ||
356 sizeof(ValTy) <=
sizeof(
void *),
357 "Expected all large types to be stored via pointer");
362 template <
class T>
void construct(
T V) {
363 static_assert(std::is_standard_layout<T>::value ||
364 std::is_pointer<T>::value,
365 "Expected standard layout or pointer");
366 new (
reinterpret_cast<void *
>(Val.
buffer))
T(V);
369 template <
class T>
T *
get() {
return reinterpret_cast<T *
>(Val.
buffer); }
370 template <
class T>
const T *
get()
const {
371 return reinterpret_cast<const T *
>(Val.
buffer);
373 template <
class T>
void destruct() { get<T>()->~
T(); }
384 #define HANDLE_DIEVALUE_SMALL(T) \
386 destruct<DIE##T>(); \
388 #define HANDLE_DIEVALUE_LARGE(T) \
390 destruct<const DIE##T *>(); \
392 #include "llvm/CodeGen/DIEValue.def"
405 #define HANDLE_DIEVALUE_SMALL(T) \
407 construct<DIE##T>(*X.get<DIE##T>()); \
409 #define HANDLE_DIEVALUE_LARGE(T) \
411 construct<const DIE##T *>(*X.get<const DIE##T *>()); \
413 #include "llvm/CodeGen/DIEValue.def"
435 #define HANDLE_DIEVALUE_SMALL(T) \
436 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T &V) \
437 : Ty(is##T), Attribute(Attribute), Form(Form) { \
438 construct<DIE##T>(V); \
440 #define HANDLE_DIEVALUE_LARGE(T) \
441 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T *V) \
442 : Ty(is##T), Attribute(Attribute), Form(Form) { \
443 assert(V && "Expected valid value"); \
444 construct<const DIE##T *>(V); \
446 #include "llvm/CodeGen/DIEValue.def"
453 explicit operator bool()
const {
return Ty; }
456 #define HANDLE_DIEVALUE_SMALL(T) \
457 const DIE##T &getDIE##T() const { \
458 assert(getType() == is##T && "Expected " #T); \
459 return *get<DIE##T>(); \
461 #define HANDLE_DIEVALUE_LARGE(T) \
462 const DIE##T &getDIE##T() const { \
463 assert(getType() == is##T && "Expected " #T); \
464 return **get<const DIE##T *>(); \
466 #include "llvm/CodeGen/DIEValue.def"
469 void EmitValue(
const AsmPrinter *AP)
const;
472 unsigned SizeOf(
const AsmPrinter *AP)
const;
474 void print(raw_ostream &O)
const;
484 return Next.getInt() ?
nullptr :
Next.getPointer();
496 assert(N.
Next.getPointer() == &N &&
"Expected unlinked node");
497 assert(N.
Next.getInt() ==
true &&
"Expected unlinked node");
501 Last->
Next.setPointerAndInt(&N,
false);
515 class const_iterator;
531 explicit operator bool()
const {
return N; }
541 const Node *N =
nullptr;
554 explicit operator bool()
const {
return N; }
562 return Last ? iterator(static_cast<T *>(
Last->
Next.getPointer())) :
end();
567 iterator
end() {
return iterator(); }
568 const_iterator
end()
const {
return const_iterator(); }
571 static const_iterator
toIterator(
const T &
N) {
return const_iterator(&N); }
604 std::forward_iterator_tag, DIEValue> {
609 std::forward_iterator_tag,
DIEValue>;
620 const_value_iterator, ListTy::const_iterator,
621 std::forward_iterator_tag, const DIEValue> {
624 std::forward_iterator_tag,
const DIEValue>;
670 unsigned AbbrevNumber = ~0u;
675 bool ForceChildren =
false;
687 DIE(
const DIE &RHS) =
delete;
702 bool hasChildren()
const {
return ForceChildren || !Children.empty(); }
711 return make_range(Children.begin(), Children.end());
714 return make_range(Children.begin(), Children.end());
772 Children.push_back(*Child);
773 return Children.back();
800 const uint16_t Version;
801 const uint8_t AddrSize;
817 this->Section = Section;
840 :
DIEUnit(Version, AddrSize, UnitTag) {}
847 mutable unsigned Size = 0;
859 if (DwarfVersion > 3)
860 return dwarf::DW_FORM_exprloc;
862 if ((
unsigned char)Size == Size)
863 return dwarf::DW_FORM_block1;
864 if ((
unsigned short)Size == Size)
865 return dwarf::DW_FORM_block2;
866 if ((
unsigned int)Size == Size)
867 return dwarf::DW_FORM_block4;
868 return dwarf::DW_FORM_block;
881 mutable unsigned Size = 0;
893 if ((
unsigned char)Size == Size)
894 return dwarf::DW_FORM_block1;
895 if ((
unsigned short)Size == Size)
896 return dwarf::DW_FORM_block2;
897 if ((
unsigned int)Size == Size)
898 return dwarf::DW_FORM_block4;
899 return dwarf::DW_FORM_block;
910 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
const_iterator begin() const
DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit block data.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit debug information entry offset.
DIEString(DwarfStringPoolEntryRef S)
DIELoc - Represents an expression location.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit string value.
DIELabel(const MCSymbol *L)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
IntrusiveBackListNode * getNext() const
void EmitValue(const AsmPrinter *AP) const
Emit value via the Dwarf writer.
DIEValue(const DIEValue &X)
void print(raw_ostream &O) const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
static const_iterator toIterator(const T &N)
DIEAbbrev(dwarf::Tag T, bool C)
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
const_value_iterator(DIEValueList::value_iterator X)
~DIEUnit()=default
The size in bytes of an address for this unit.
void print(raw_ostream &O) const
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
Adds another set of attribute information to the abbreviation.
Represents a pointer to a location list in the debug_loc section.
value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
DIE & operator=(const DIE &RHS)=delete
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to...
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
void print(raw_ostream &O, unsigned IndentCount=0) const
size_t getValue() const
Grab the current index out.
const_child_range children() const
const DIE & getUnitDie() const
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
void setForceChildren(bool B)
DIEInlineString(StringRef Str, Allocator &A)
dwarf::Form getForm() const
void AddImplicitConstAttribute(dwarf::Attribute Attribute, int64_t Value)
Adds attribute with DW_FORM_implicit_const value.
String pool entry reference.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
bool operator==(const iterator &X) const
const_iterator & operator++()
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit location data.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
const_iterator(typename IntrusiveBackList< T >::iterator X)
bool operator==(const const_iterator &X) const
void setNumber(unsigned N)
const MCSymbol * getValue() const
Get MCSymbol.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
DIE & addChild(DIE *Child)
Add a child to the DIE.
dwarf::Tag getTag() const
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
uint16_t getDwarfVersion() const
void print(raw_ostream &O) const
Helps unique DIEAbbrev objects and assigns abbreviation numbers.
~DIEInlineString()=default
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of label value in bytes.
A pointer to another debug information entry.
unsigned getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
void print(raw_ostream &O) const
PointerIntPair - This class implements a pair of a pointer and small integer.
static iterator toIterator(T &N)
StringRef getString() const
Grab the string out of the object.
Allocate memory in an ever growing pool, as if by bump-pointer.
unsigned getAbbrevNumber() const
CRTP base class for adapting an iterator to a different type.
DIEAbbrevSet(BumpPtrAllocator &A)
DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
A container for inline string values.
A structured debug information entry.
void print(raw_ostream &O) const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
void Emit(const AsmPrinter *AP, MCSection *Section) const
Print all abbreviations using the specified asm printer.
const_value_range values() const
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
bool operator!=(const iterator &X) const
This class is intended to be used as a driving class for all asm writers.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of integer value in bytes.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of block data in bytes.
void print(raw_ostream &O) const
cl::opt< int > DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(0))
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
void print(raw_ostream &O) const
A container for string pool string values.
void operator=(const DIEUnit &RHS)=delete
void setDebugSectionOffset(unsigned O)
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
unsigned computeOffsetsAndAbbrevs(const AsmPrinter *AP, DIEAbbrevSet &AbbrevSet, unsigned CUOffset)
Compute the offset of this DIE and all its children.
uint64_t getValue() const
void print(raw_ostream &O) const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
A simple label difference DIE.
const DIEValue & operator*() const
DIEAbbrevData(dwarf::Attribute A, int64_t V)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
dwarf::Attribute getAttribute() const
Accessors.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
uint16_t getAddressSize() const
const DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to...
unsigned getDebugSectionOffset() const
DIEUnit(uint16_t Version, uint8_t AddrSize, dwarf::Tag UnitTag)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
StringRef getString() const
Grab the string out of the object.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
Represents a compile or type unit.
StringRef getString() const
dwarf::Attribute getAttribute() const
dwarf::Form getForm() const
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
uint64_t getLength() const
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
bool operator!=(const const_iterator &X) const
A range adaptor for a pair of iterators.
DIEValue & operator*() const
unsigned SizeOf(const AsmPrinter *AP) const
Return the size of a value in bytes.
const_value_iterator()=default
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of location data in bytes.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
DIEValue & operator=(const DIEValue &X)
DIEAbbrev & uniqueAbbreviation(DIE &Die)
Generate the abbreviation declaration for a DIE and return a pointer to the generated abbreviation...
const T & operator*() const
Dwarf abbreviation, describes the organization of a debug information object.
void setSection(MCSection *Section)
Set the section that this DIEUnit will be emitted into.
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
const ListTy::iterator & wrapped() const
Node - This class is used to maintain the singly linked bucket list in a folding set.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
void setOffset(unsigned O)
value_iterator(ListTy::iterator X)
void setLength(uint64_t L)
PointerIntPair< IntrusiveBackListNode *, 1 > Next
const_value_iterator(ListTy::const_iterator X)
BasicDIEUnit(uint16_t Version, uint8_t AddrSize, dwarf::Tag UnitTag)
const MCExpr * getValue() const
Get MCExpr.
const SmallVectorImpl< DIEAbbrevData > & getData() const
void setChildrenFlag(bool hasChild)
const_iterator(const T *N)
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
void print(raw_ostream &O) const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
void print(raw_ostream &O) const
Type getType() const
Accessors.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
dwarf::Tag getTag() const
Accessors.
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
LLVM Value Representation.
IntrusiveBackListNode Node
void setAbbrevNumber(unsigned I)
Set the abbreviation number for this DIE.
This class implements an extremely fast bulk output stream that can only output to a stream...
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
const_iterator end() const
void Emit(const AsmPrinter *AP) const
Print the abbreviation using the specified asm printer.
StringRef - Represent a constant reference to a string, i.e.
DIEAbbrevData(dwarf::Attribute A, dwarf::Form F)
DIEBlock - Represents a block of values.
void print(raw_ostream &O) const
void print(raw_ostream &O) const
value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V)
void setValue(uint64_t Val)
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
unsigned getNumber() const
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...