14 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
33 #include <type_traits>
141 std::vector<DIEAbbrev *> Abbreviations;
170 const int64_t SignedInt = Int;
171 if ((
char)Int == SignedInt)
172 return dwarf::DW_FORM_data1;
173 if ((
short)Int == SignedInt)
174 return dwarf::DW_FORM_data2;
175 if ((
int)Int == SignedInt)
176 return dwarf::DW_FORM_data4;
178 if ((
unsigned char)Int == Int)
179 return dwarf::DW_FORM_data1;
180 if ((
unsigned short)Int == Int)
181 return dwarf::DW_FORM_data2;
182 if ((
unsigned int)Int == Int)
183 return dwarf::DW_FORM_data4;
185 return dwarf::DW_FORM_data8;
274 template <
typename Allocator>
337 #define HANDLE_DIEVALUE(T) is##T,
338 #include "llvm/CodeGen/DIEValue.def"
351 typedef AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
352 DIEDelta *, DIEEntry, DIEBlock *, DIELoc *,
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) \
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();
494 assert(N.
Next.getPointer() == &N &&
"Expected unlinked node");
495 assert(N.
Next.getInt() ==
true &&
"Expected unlinked node");
499 Last->
Next.setPointerAndInt(&N,
false);
512 class const_iterator;
527 explicit operator bool()
const {
return N; }
537 const Node *N =
nullptr;
550 explicit operator bool()
const {
return N; }
558 return Last ? iterator(static_cast<T *>(
Last->
Next.getPointer())) :
end();
563 iterator
end() {
return iterator(); }
564 const_iterator
end()
const {
return const_iterator(); }
567 static const_iterator
toIterator(
const T &
N) {
return const_iterator(&N); }
598 std::forward_iterator_tag, DIEValue> {
601 std::forward_iterator_tag,
613 const_value_iterator, ListTy::const_iterator,
614 std::forward_iterator_tag, const DIEValue> {
616 std::forward_iterator_tag,
663 unsigned AbbrevNumber = ~0u;
678 ForceChildren(
false) {}
682 return new (Alloc)
DIE(
Tag);
685 DIE(
const DIE &RHS) =
delete;
696 bool hasChildren()
const {
return ForceChildren || !Children.empty(); }
705 return make_range(Children.begin(), Children.end());
708 return make_range(Children.begin(), Children.end());
766 Children.push_back(*Child);
767 return Children.back();
794 const uint16_t Version;
795 const uint8_t AddrSize;
808 this->Section = Section;
830 mutable unsigned Size;
842 if (DwarfVersion > 3)
843 return dwarf::DW_FORM_exprloc;
845 if ((
unsigned char)Size == Size)
846 return dwarf::DW_FORM_block1;
847 if ((
unsigned short)Size == Size)
848 return dwarf::DW_FORM_block2;
849 if ((
unsigned int)Size == Size)
850 return dwarf::DW_FORM_block4;
851 return dwarf::DW_FORM_block;
864 mutable unsigned Size;
876 if ((
unsigned char)Size == Size)
877 return dwarf::DW_FORM_block1;
878 if ((
unsigned short)Size == Size)
879 return dwarf::DW_FORM_block2;
880 if ((
unsigned int)Size == Size)
881 return dwarf::DW_FORM_block4;
882 return dwarf::DW_FORM_block;
893 #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...
iterator_range< const_child_iterator > const_child_range
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)
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)
iterator_range< value_iterator > value_range
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.
Function Alias Analysis false
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
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
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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.
unsigned getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
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.
Greedy Register Allocator
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
iterator_range< child_iterator > child_range
void print(raw_ostream &O)
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)
The size in bytes of an address for this unit.
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
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Node - This class is used to maintain the singly linked bucket list in a folding set.
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
uint64_t getLength() const
IntrusiveBackList< DIE >::iterator child_iterator
void operator=(const DIE &RHS)=delete
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.
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.
IntrusiveBackList< DIE >::const_iterator const_child_iterator
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
const ListTy::iterator & wrapped() const
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)
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())
IntrusiveBackListNode Node
dwarf::Tag getTag() const
Accessors.
unsigned ComputeSize(const AsmPrinter *AP) const
ComputeSize - Calculate the size of the location expression.
LLVM Value Representation.
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
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
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...
iterator_range< const_value_iterator > const_value_range