14 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H 15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H 33 #include <type_traits> 61 : Attribute(A), Form(F) {}
63 : Attribute(A), Form(dwarf::DW_FORM_implicit_const), Value(V) {}
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" 401 void copyVal(
const DIEValue &
X) {
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" 418 DIEValue() =
default;
427 Attribute = X.Attribute;
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;
493 bool empty()
const {
return !Last; }
496 assert(N.
Next.getPointer() == &N &&
"Expected unlinked node");
497 assert(N.
Next.getInt() ==
true &&
"Expected unlinked node");
501 Last->
Next.setPointerAndInt(&N,
false);
512 T &
back() {
return *
static_cast<T *
>(Last); }
513 const T &
back()
const {
return *
static_cast<T *
>(Last); }
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>;
612 value_iterator() =
default;
615 explicit operator bool()
const {
return bool(wrapped()); }
620 const_value_iterator, ListTy::const_iterator,
621 std::forward_iterator_tag, const DIEValue> {
624 std::forward_iterator_tag,
const DIEValue>;
627 const_value_iterator() =
default;
633 explicit operator bool()
const {
return bool(wrapped()); }
634 const DIEValue &
operator*()
const {
return wrapped()->V; }
647 return addValue(Alloc,
DIEValue(Attribute, Form, std::forward<T>(
Value)));
670 unsigned AbbrevNumber = ~0u;
675 bool ForceChildren =
false;
687 DIE(
const DIE &RHS) =
delete;
689 DIE &operator=(
const DIE &RHS) =
delete;
690 DIE &operator=(
const DIE &&RHS) =
delete;
693 return new (Alloc)
DIE(Tag);
730 unsigned getDebugSectionOffset()
const;
748 unsigned computeOffsetsAndAbbrevs(
const AsmPrinter *AP,
756 const DIE *getUnitDie()
const;
763 const DIEUnit *getUnit()
const;
773 return Children.
back();
801 const uint8_t AddrSize;
809 void operator=(
const DIEUnit &RHS) =
delete;
810 void operator=(
const DIEUnit &&RHS) =
delete;
840 :
DIEUnit(Version, AddrSize, UnitTag) {}
847 mutable unsigned Size = 0;
854 unsigned ComputeSize(
const AsmPrinter *AP)
const;
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;
884 DIEBlock() =
default;
888 unsigned ComputeSize(
const AsmPrinter *AP)
const;
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 StringRef getString() const
uint16_t getAddressSize() const
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const_iterator end(StringRef path)
Get end iterator over path.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
DIEString(DwarfStringPoolEntryRef S)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
DIELoc - Represents an expression location.
This class represents lattice values for constants.
PointerTy getPointer() const
DIELabel(const MCSymbol *L)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const_child_range children() const
DIEValue(const DIEValue &X)
void push_back(const T &Elt)
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
bool operator!=(const const_iterator &X) const
static const_iterator toIterator(const T &N)
DIEAbbrev(dwarf::Tag T, bool C)
unsigned getDebugSectionOffset() const
const_value_iterator(DIEValueList::value_iterator X)
block Block Frequency true
const DIE & getUnitDie() 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)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
StringRef getString() const
Grab the string out of the object.
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
size_t getValue() const
Grab the current index out.
void setForceChildren(bool B)
DIEInlineString(StringRef Str, Allocator &A)
const MCExpr * getValue() const
Get MCExpr.
void AddImplicitConstAttribute(dwarf::Attribute Attribute, int64_t Value)
Adds attribute with DW_FORM_implicit_const value.
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.
dwarf::Form getForm() const
const_iterator & operator++()
const_iterator(typename IntrusiveBackList< T >::iterator X)
void setNumber(unsigned N)
bool operator!=(const iterator &X) const
DIE & addChild(DIE *Child)
Add a child to the DIE.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Helps unique DIEAbbrev objects and assigns abbreviation numbers.
uint16_t getDwarfVersion() const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
A pointer to another debug information entry.
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
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.
CRTP base class for adapting an iterator to a different type.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DIEAbbrevSet(BumpPtrAllocator &A)
const DIEValue & operator*() const
A container for inline string values.
A structured debug information entry.
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
This class is intended to be used as a driving class for all asm writers.
dwarf::Attribute getAttribute() const
Accessors.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
const MCSymbol * getValue() const
Get MCSymbol.
bool operator==(const const_iterator &X) const
A container for string pool string values.
void setDebugSectionOffset(unsigned O)
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
A simple label difference DIE.
DIEAbbrevData(dwarf::Attribute A, int64_t V)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const_iterator begin() const
dwarf::Tag getTag() const
Accessors.
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Represents a compile or type unit.
const_iterator end() const
A range adaptor for a pair of iterators.
This file contains constants used for implementing Dwarf debug support.
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
const T & operator*() const
dwarf::Tag getTag() const
String pool entry reference.
uint64_t getValue() const
DIEValue & operator=(const DIEValue &X)
const_value_range values() 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.
DIEValue & operator*() const
Node - This class is used to maintain the singly linked bucket list in a folding set.
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
void setOffset(unsigned O)
value_iterator(ListTy::iterator X)
uint64_t getLength() const
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)
void setChildrenFlag(bool hasChild)
const_iterator(const T *N)
bool operator==(const iterator &X) const
dwarf::Attribute getAttribute() const
unsigned getAbbrevNumber() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Type getType() const
Accessors.
const SmallVectorImpl< DIEAbbrevData > & getData() const
LLVM Value Representation.
unsigned getNumber() const
static const Function * getParent(const Value *V)
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 getOffset() const
Get the compile/type unit relative offset of this DIE.
StringRef - Represent a constant reference to a string, i.e.
DIEAbbrevData(dwarf::Attribute A, dwarf::Form F)
DIEBlock - Represents a block of values.
dwarf::Form getForm() const
OutputIt copy(R &&Range, OutputIt Out)
IntrusiveBackListNode * getNext() const
value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V)
void setValue(uint64_t Val)
StringRef getString() const
Grab the string out of the object.
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...