14 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
122 const int64_t SignedInt =
Int;
123 if ((
char)Int == SignedInt)
125 if ((
short)Int == SignedInt)
127 if ((
int)Int == SignedInt)
130 if ((
unsigned char)Int == Int)
132 if ((
unsigned short)Int == Int)
134 if ((
unsigned int)Int == Int)
313 #define HANDLE_DIEVALUE(T) is##T,
314 #include "llvm/CodeGen/DIEValue.def"
328 typedef AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
329 DIEDelta *, DIEEntry, DIETypeSignature,
330 DIEBlock *, DIELoc *, DIELocList> ValTy;
331 static_assert(
sizeof(ValTy) <=
sizeof(uint64_t) ||
332 sizeof(ValTy) <=
sizeof(
void *),
333 "Expected all large types to be stored via pointer");
338 template <
class T>
void construct(
T V) {
339 static_assert(std::is_standard_layout<T>::value ||
340 std::is_pointer<T>::value,
341 "Expected standard layout or pointer");
342 new (
reinterpret_cast<void *
>(Val.buffer))
T(V);
345 template <
class T>
T *
get() {
return reinterpret_cast<T *
>(Val.buffer); }
346 template <
class T>
const T *
get()
const {
347 return reinterpret_cast<const T *
>(Val.buffer);
349 template <
class T>
void destruct() { get<T>()->~
T(); }
360 #define HANDLE_DIEVALUE_SMALL(T) \
364 #define HANDLE_DIEVALUE_LARGE(T) \
366 destruct<const DIE##T *>();
368 #include "llvm/CodeGen/DIEValue.def"
381 #define HANDLE_DIEVALUE_SMALL(T) \
383 construct<DIE##T>(*X.get<DIE##T>()); \
385 #define HANDLE_DIEVALUE_LARGE(T) \
387 construct<const DIE##T *>(*X.get<const DIE##T *>()); \
389 #include "llvm/CodeGen/DIEValue.def"
408 #define HANDLE_DIEVALUE_SMALL(T) \
409 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T &V) \
410 : Ty(is##T), Attribute(Attribute), Form(Form) { \
411 construct<DIE##T>(V); \
413 #define HANDLE_DIEVALUE_LARGE(T) \
414 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T *V) \
415 : Ty(is##T), Attribute(Attribute), Form(Form) { \
416 assert(V && "Expected valid value"); \
417 construct<const DIE##T *>(V); \
419 #include "llvm/CodeGen/DIEValue.def"
425 explicit operator bool()
const {
return Ty; }
427 #define HANDLE_DIEVALUE_SMALL(T) \
428 const DIE##T &getDIE##T() const { \
429 assert(getType() == is##T && "Expected " #T); \
430 return *get<DIE##T>(); \
432 #define HANDLE_DIEVALUE_LARGE(T) \
433 const DIE##T &getDIE##T() const { \
434 assert(getType() == is##T && "Expected " #T); \
435 return **get<const DIE##T *>(); \
437 #include "llvm/CodeGen/DIEValue.def"
441 void EmitValue(
const AsmPrinter *AP)
const;
445 unsigned SizeOf(
const AsmPrinter *AP)
const;
448 void print(raw_ostream &O)
const;
458 return Next.getInt() ?
nullptr :
Next.getPointer();
468 assert(N.
Next.getPointer() == &N &&
"Expected unlinked node");
469 assert(N.
Next.getInt() ==
true &&
"Expected unlinked node");
473 Last->
Next.setPointerAndInt(&N,
false);
486 class const_iterator;
501 explicit operator bool()
const {
return N; }
511 const Node *N =
nullptr;
524 explicit operator bool()
const {
return N; }
532 return Last ? iterator(static_cast<T *>(
Last->
Next.getPointer())) :
end();
537 iterator
end() {
return iterator(); }
538 const_iterator
end()
const {
return const_iterator(); }
541 static const_iterator
toIterator(
const T &
N) {
return const_iterator(&N); }
571 class const_iterator;
574 std::forward_iterator_tag, DIEValue> {
577 std::forward_iterator_tag,
590 std::forward_iterator_tag,
593 std::forward_iterator_tag,
609 template <
class... Ts>
658 return new (Alloc)
DIE(
Tag);
727 assert(!Child->
getParent() &&
"Child should be orphaned");
749 mutable unsigned Size;
761 if (DwarfVersion > 3)
764 if ((
unsigned char)Size == Size)
766 if ((
unsigned short)Size == Size)
768 if ((
unsigned int)Size == Size)
785 mutable unsigned Size;
797 if ((
unsigned char)Size == Size)
799 if ((
unsigned short)Size == Size)
801 if ((
unsigned int)Size == Size)
const_iterator begin() const
DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
iterator_range< const_child_iterator > const_child_range
const DIEValue & operator*() const
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 print(raw_ostream &O) const
void print(raw_ostream &O) const
value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
void EmitValue(const AsmPrinter *AP) const
EmitValue - Emit value via the Dwarf writer.
DIEValue(const DIEValue &X)
static const_iterator toIterator(const T &N)
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
DIEAbbrev(dwarf::Tag T, bool C)
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
void print(raw_ostream &O) const
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
AddAttribute - Adds another set of attribute information to the abbreviation.
DIELocList - Represents a pointer to a location list in the debug_loc section.
iterator_range< value_iterator > value_range
void print(raw_ostream &O, unsigned IndentCount=0) const
void Profile(FoldingSetNodeID &ID) const
Profile - Used to gather unique data for the abbreviation folding set.
DIEAbbrevData - Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
size_t getValue() const
getValue - Grab the current index out.
const_child_range children() const
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
void print(raw_ostream &O) const
dwarf::Form getForm() const
A signature reference to a type unit.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
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 Offset
Offset - Offset in debug info section.
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
value_iterator addValue(BumpPtrAllocator &Alloc, DIEValue Value)
addValue - Add a value and attributes to a DIE.
bool operator==(const iterator &X) const
const_iterator & operator++()
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit location data.
const_iterator end() const
const_iterator(typename IntrusiveBackList< T >::iterator X)
bool operator==(const const_iterator &X) const
static unsigned getRefAddrSize(const AsmPrinter *AP)
Returns size of a ref_addr entry.
void setNumber(unsigned N)
const MCSymbol * getValue() const
getValue - Get MCSymbol.
void print(raw_ostream &O) const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
unsigned Size
Size - Size of instance + children.
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 ...
void print(raw_ostream &O) const
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.
PointerIntPair - This class implements a pair of a pointer and small integer.
static iterator toIterator(T &N)
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.
const DIE * getUnitOrNull() const
Similar to getUnit, returns null when DIE is not added to an owner yet.
DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
DIE - A structured debug information entry.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
BestForm - 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.
void print(raw_ostream &O) const
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.
DIEExpr - An expression DIE.
cl::opt< int > DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(0))
DIEValueList Values
Attribute values.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
const_iterator(ListTy::const_iterator X)
const_iterator begin() const
DIEValueList::iterator value_iterator
iterator_range< child_iterator > child_range
DIEString - A container for string values.
void print(raw_ostream &O) const
uint64_t getValue() const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
DIEDelta - A simple label difference DIE.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
dwarf::Attribute getAttribute() const
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
iterator(ListTy::iterator X)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
iterator insert(BumpPtrAllocator &Alloc, DIEValue V)
StringRef getString() const
getString - Grab the string out of the object.
unsigned getOffset() const
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
StringRef getString() const
void print(raw_ostream &O) const
dwarf::Attribute getAttribute() const
dwarf::Form getForm() const
Node - This class is used to maintain the singly linked bucket list in a folding set.
void Profile(FoldingSetNodeID &ID) const
Profile - Used to gather unique data for the abbreviation folding set.
IntrusiveBackList< DIE >::iterator child_iterator
bool operator!=(const const_iterator &X) const
A range adaptor for a pair of iterators.
unsigned SizeOf(const AsmPrinter *AP) const
SizeOf - Return the size of a value in bytes.
iterator emplace(BumpPtrAllocator &Alloc, Ts &&...Args)
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
SizeOf - Determine size of location data in bytes.
DIEValue & operator=(const DIEValue &X)
DIEValue & operator*() const
DIEInteger - An integer value DIE.
const T & operator*() const
DIEAbbrev - Dwarf abbreviation, describes the organization of a debug information object...
IntrusiveBackList< DIE >::const_iterator const_child_iterator
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
const ListTy::iterator & wrapped() const
IntrusiveBackList< DIE > Children
Children DIEs.
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
iterator_range< const_value_iterator > const_value_range
void setOffset(unsigned O)
void print(raw_ostream &O) const
dwarf::Tag Tag
Tag - Dwarf tag code.
void print(raw_ostream &O)
PointerIntPair< IntrusiveBackListNode *, 1 > Next
const MCExpr * getValue() const
getValue - 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 EmitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
const_iterator(DIEValueList::iterator X)
DIEValueList::const_iterator const_value_iterator
IntrusiveBackListNode Node
dwarf::Tag getTag() const
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
LLVM Value Representation.
const_value_range values() const
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
Emit - Print the abbreviation using the specified asm printer.
StringRef - Represent a constant reference to a string, i.e.
DIETypeSignature(const DwarfTypeUnit &Unit)
DIEAbbrevData(dwarf::Attribute A, dwarf::Form F)
const DIE * getUnit() const
Climb up the parent chain to get the compile or type unit DIE this DIE belongs to.
DIEBlock - Represents a block of values.
void print(raw_ostream &O) const
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