13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H 14 #define LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H 32 #include <type_traits> 60 : Attribute(A), Form(F) {}
62 : Attribute(A), Form(dwarf::DW_FORM_implicit_const), Value(V) {}
141 std::vector<DIEAbbrev *> Abbreviations;
171 const int64_t SignedInt = Int;
172 if ((
char)Int == SignedInt)
173 return dwarf::DW_FORM_data1;
174 if ((
short)Int == SignedInt)
175 return dwarf::DW_FORM_data2;
176 if ((
int)Int == SignedInt)
177 return dwarf::DW_FORM_data4;
179 if ((
unsigned char)Int == Int)
180 return dwarf::DW_FORM_data1;
181 if ((
unsigned short)Int == Int)
182 return dwarf::DW_FORM_data2;
183 if ((
unsigned int)Int == Int)
184 return dwarf::DW_FORM_data4;
186 return dwarf::DW_FORM_data8;
275 template <
typename Allocator>
336 #define HANDLE_DIEVALUE(T) is##T, 337 #include "llvm/CodeGen/DIEValue.def" 350 using ValTy = AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
351 DIEDelta *, DIEEntry, DIEBlock *,
352 DIELoc *, DIELocList>;
354 static_assert(
sizeof(ValTy) <=
sizeof(uint64_t) ||
355 sizeof(ValTy) <=
sizeof(
void *),
356 "Expected all large types to be stored via pointer");
361 template <
class T>
void construct(
T V) {
362 static_assert(std::is_standard_layout<T>::value ||
363 std::is_pointer<T>::value,
364 "Expected standard layout or pointer");
365 new (
reinterpret_cast<void *
>(Val.buffer))
T(V);
368 template <
class T>
T *
get() {
return reinterpret_cast<T *
>(Val.buffer); }
369 template <
class T>
const T *
get()
const {
370 return reinterpret_cast<const T *
>(Val.buffer);
372 template <
class T>
void destruct() { get<T>()->~
T(); }
383 #define HANDLE_DIEVALUE_SMALL(T) \ 385 destruct<DIE##T>(); \ 387 #define HANDLE_DIEVALUE_LARGE(T) \ 389 destruct<const DIE##T *>(); \ 391 #include "llvm/CodeGen/DIEValue.def" 400 void copyVal(
const DIEValue &
X) {
404 #define HANDLE_DIEVALUE_SMALL(T) \ 406 construct<DIE##T>(*X.get<DIE##T>()); \ 408 #define HANDLE_DIEVALUE_LARGE(T) \ 410 construct<const DIE##T *>(*X.get<const DIE##T *>()); \ 412 #include "llvm/CodeGen/DIEValue.def" 417 DIEValue() =
default;
426 Attribute = X.Attribute;
434 #define HANDLE_DIEVALUE_SMALL(T) \ 435 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T &V) \ 436 : Ty(is##T), Attribute(Attribute), Form(Form) { \ 437 construct<DIE##T>(V); \ 439 #define HANDLE_DIEVALUE_LARGE(T) \ 440 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T *V) \ 441 : Ty(is##T), Attribute(Attribute), Form(Form) { \ 442 assert(V && "Expected valid value"); \ 443 construct<const DIE##T *>(V); \ 445 #include "llvm/CodeGen/DIEValue.def" 452 explicit operator bool()
const {
return Ty; }
455 #define HANDLE_DIEVALUE_SMALL(T) \ 456 const DIE##T &getDIE##T() const { \ 457 assert(getType() == is##T && "Expected " #T); \ 458 return *get<DIE##T>(); \ 460 #define HANDLE_DIEVALUE_LARGE(T) \ 461 const DIE##T &getDIE##T() const { \ 462 assert(getType() == is##T && "Expected " #T); \ 463 return **get<const DIE##T *>(); \ 465 #include "llvm/CodeGen/DIEValue.def" 468 void EmitValue(
const AsmPrinter *AP)
const;
471 unsigned SizeOf(
const AsmPrinter *AP)
const;
473 void print(raw_ostream &
O)
const;
492 bool empty()
const {
return !Last; }
495 assert(N.
Next.getPointer() == &N &&
"Expected unlinked node");
496 assert(N.
Next.getInt() ==
true &&
"Expected unlinked node");
500 Last->
Next.setPointerAndInt(&N,
false);
511 T &
back() {
return *
static_cast<T *
>(Last); }
512 const T &
back()
const {
return *
static_cast<T *
>(Last); }
514 class const_iterator;
530 explicit operator bool()
const {
return N; }
540 const Node *
N =
nullptr;
553 explicit operator bool()
const {
return N; }
561 return Last ? iterator(static_cast<T *>(Last->Next.getPointer())) :
end();
566 iterator
end() {
return iterator(); }
567 const_iterator
end()
const {
return const_iterator(); }
570 static const_iterator
toIterator(
const T &
N) {
return const_iterator(&N); }
603 std::forward_iterator_tag, DIEValue> {
608 std::forward_iterator_tag,
DIEValue>;
611 value_iterator() =
default;
614 explicit operator bool()
const {
return bool(wrapped()); }
619 const_value_iterator, ListTy::const_iterator,
620 std::forward_iterator_tag, const DIEValue> {
623 std::forward_iterator_tag,
const DIEValue>;
626 const_value_iterator() =
default;
632 explicit operator bool()
const {
return bool(wrapped()); }
633 const DIEValue &
operator*()
const {
return wrapped()->V; }
646 return addValue(Alloc,
DIEValue(Attribute, Form, std::forward<T>(
Value)));
669 unsigned AbbrevNumber = ~0u;
674 bool ForceChildren =
false;
686 DIE(
const DIE &RHS) =
delete;
688 DIE &operator=(
const DIE &RHS) =
delete;
689 DIE &operator=(
const DIE &&RHS) =
delete;
692 return new (Alloc)
DIE(Tag);
729 unsigned getDebugSectionOffset()
const;
747 unsigned computeOffsetsAndAbbrevs(
const AsmPrinter *AP,
755 const DIE *getUnitDie()
const;
762 const DIEUnit *getUnit()
const;
772 return Children.
back();
800 const uint8_t AddrSize;
808 void operator=(
const DIEUnit &RHS) =
delete;
809 void operator=(
const DIEUnit &&RHS) =
delete;
839 :
DIEUnit(Version, AddrSize, UnitTag) {}
846 mutable unsigned Size = 0;
853 unsigned ComputeSize(
const AsmPrinter *AP)
const;
858 if (DwarfVersion > 3)
859 return dwarf::DW_FORM_exprloc;
861 if ((
unsigned char)Size == Size)
862 return dwarf::DW_FORM_block1;
863 if ((
unsigned short)Size == Size)
864 return dwarf::DW_FORM_block2;
865 if ((
unsigned int)Size == Size)
866 return dwarf::DW_FORM_block4;
867 return dwarf::DW_FORM_block;
880 mutable unsigned Size = 0;
883 DIEBlock() =
default;
887 unsigned ComputeSize(
const AsmPrinter *AP)
const;
892 if ((
unsigned char)Size == Size)
893 return dwarf::DW_FORM_block1;
894 if ((
unsigned short)Size == Size)
895 return dwarf::DW_FORM_block2;
896 if ((
unsigned int)Size == Size)
897 return dwarf::DW_FORM_block4;
898 return dwarf::DW_FORM_block;
909 #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
Node(Kind K_, Cache RHSComponentCache_=Cache::No, Cache ArrayCache_=Cache::No, Cache FunctionCache_=Cache::No)
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...