13#ifndef LLVM_CODEGEN_DIE_H 
   14#define LLVM_CODEGEN_DIE_H 
   62      : Attribute(
A), Form(
F) {}
 
 
   64      : Attribute(
A), Form(
dwarf::DW_FORM_implicit_const), Value(V) {}
 
 
 
  121    Data.push_back(AbbrevData);
 
 
 
  148  std::vector<DIEAbbrev *> Abbreviations;
 
 
  178      const int64_t SignedInt = 
Int;
 
  179      if ((int8_t)
Int == SignedInt)
 
  180        return dwarf::DW_FORM_data1;
 
  181      if ((int16_t)
Int == SignedInt)
 
  182        return dwarf::DW_FORM_data2;
 
  183      if ((int32_t)
Int == SignedInt)
 
  184        return dwarf::DW_FORM_data4;
 
  187        return dwarf::DW_FORM_data1;
 
  189        return dwarf::DW_FORM_data2;
 
  191        return dwarf::DW_FORM_data4;
 
  193    return dwarf::DW_FORM_data8;
 
 
 
  247  static constexpr unsigned ULEB128PadSize = 4;
 
  251    : 
CU(TheCU), Index(Idx) {}
 
 
 
  307  template <
typename Allocator>
 
 
  369      : Addr(Idx), Offset(
Hi, 
Lo) {}
 
 
 
  387#define HANDLE_DIEVALUE(T) is##T, 
  388#include "llvm/CodeGen/DIEValue.def" 
 
  402      AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
 
  403                            DIEDelta *, DIEEntry, DIEBlock *, DIELoc *,
 
  404                            DIELocList, DIEBaseTypeRef *, DIEAddrOffset *>;
 
  406  static_assert(
sizeof(ValTy) <= 
sizeof(uint64_t) ||
 
  407                    sizeof(ValTy) <= 
sizeof(
void *),
 
  408                "Expected all large types to be stored via pointer");
 
  413  template <
class T> 
void construct(
T V) {
 
  414    static_assert(std::is_standard_layout<T>::value ||
 
  415                      std::is_pointer<T>::value,
 
  416                  "Expected standard layout or pointer");
 
  417    new (
reinterpret_cast<void *
>(&Val)) 
T(
V);
 
  420  template <
class T> 
T *get() { 
return reinterpret_cast<T *
>(&Val); }
 
  421  template <
class T> 
const T *get()
 const {
 
  422    return reinterpret_cast<const T *
>(&Val);
 
  424  template <
class T> 
void destruct() { get<T>()->~T(); }
 
  435#define HANDLE_DIEVALUE_SMALL(T)                                               \ 
  437    destruct<DIE##T>();                                                        \ 
  439#define HANDLE_DIEVALUE_LARGE(T)                                               \ 
  441    destruct<const DIE##T *>();                                                \ 
  443#include "llvm/CodeGen/DIEValue.def" 
  456#define HANDLE_DIEVALUE_SMALL(T)                                               \ 
  458    construct<DIE##T>(*X.get<DIE##T>());                                       \ 
  460#define HANDLE_DIEVALUE_LARGE(T)                                               \ 
  462    construct<const DIE##T *>(*X.get<const DIE##T *>());                       \ 
  464#include "llvm/CodeGen/DIEValue.def" 
  480    Attribute = 
X.Attribute;
 
 
  488#define HANDLE_DIEVALUE_SMALL(T)                                               \ 
  489  DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T &V)      \ 
  490      : Ty(is##T), Attribute(Attribute), Form(Form) {                          \ 
  491    construct<DIE##T>(V);                                                      \ 
 
  493#define HANDLE_DIEVALUE_LARGE(T)                                               \ 
  494  DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T *V)      \ 
  495      : Ty(is##T), Attribute(Attribute), Form(Form) {                          \ 
  496    assert(V && "Expected valid value");                                       \ 
  497    construct<const DIE##T *>(V);                                              \ 
 
  499#include "llvm/CodeGen/DIEValue.def" 
  506  explicit operator bool()
 const { 
return Ty; }
 
  509#define HANDLE_DIEVALUE_SMALL(T)                                               \ 
  510  const DIE##T &getDIE##T() const {                                            \ 
  511    assert(getType() == is##T && "Expected " #T);                              \ 
  512    return *get<DIE##T>();                                                     \ 
  514#define HANDLE_DIEVALUE_LARGE(T)                                               \ 
  515  const DIE##T &getDIE##T() const {                                            \ 
  516    assert(getType() == is##T && "Expected " #T);                              \ 
  517    return **get<const DIE##T *>();                                            \ 
  519#include "llvm/CodeGen/DIEValue.def" 
 
  537    return Next.getInt() ? nullptr : 
Next.getPointer();
 
 
 
  549    assert(
N.Next.getPointer() == &
N && 
"Expected unlinked node");
 
  550    assert(
N.Next.getInt() == 
true && 
"Expected unlinked node");
 
  554      Last->Next.setPointerAndInt(&
N, 
false);
 
 
  560    assert(
N.Next.getPointer() == &
N && 
"Expected unlinked node");
 
  561    assert(
N.Next.getInt() == 
true && 
"Expected unlinked node");
 
  564      N.Next.setPointerAndInt(
Last->Next.getPointer(), 
false);
 
  565      Last->Next.setPointerAndInt(&
N, 
true);
 
 
 
  582    return *
static_cast<T *
>(
Last ? 
Last->Next.getPointer() : 
nullptr);
 
 
  585    return *
static_cast<T *
>(
Last ? 
Last->Next.getPointer() : 
nullptr);
 
 
  592    T *FirstNode = 
static_cast<T *
>(
Other.Last->Next.getPointer());
 
  593    T *IterNode = FirstNode;
 
  596      T *TmpNode = IterNode;
 
  597      IterNode = 
static_cast<T *
>(IterNode->Next.getPointer());
 
  600      TmpNode->Next.setPointerAndInt(TmpNode, 
true);
 
  602    } 
while (IterNode != FirstNode);
 
  604    Other.Last = 
nullptr;
 
 
  610      Last->Next.setInt(
true);
 
  615    while (cur && cur->
Next.getPointer()) {
 
  616      if (cur->
Next.getPointer() == &
N) {
 
  617        cur->
Next.setPointer(cur->
Next.getPointer()->Next.getPointer());
 
  620      cur = cur->
Next.getPointer();
 
 
  642    explicit operator bool()
 const { 
return N; }
 
 
  651    const Node *N = 
nullptr;
 
  664    explicit operator bool()
 const { 
return N; }
 
 
  671    return Last ? iterator(
static_cast<T *
>(
Last->Next.getPointer())) : 
end();
 
 
  676  iterator 
end() { 
return iterator(); }
 
  677  const_iterator 
end()
 const { 
return const_iterator(); }
 
 
  713                                     std::forward_iterator_tag, DIEValue> {
 
  716    using iterator_adaptor =
 
  718                              std::forward_iterator_tag, 
DIEValue>;
 
 
  729                                   const_value_iterator, ListTy::const_iterator,
 
  730                                   std::forward_iterator_tag, const DIEValue> {
 
  731    using iterator_adaptor =
 
  733                              std::forward_iterator_tag, 
const DIEValue>;
 
  740        : iterator_adaptor(
X) {}
 
 
 
  750    List.push_back(*
new (
Alloc) Node(V));
 
 
  767                  DIEValue(NewAttribute, Form, std::forward<T>(NewValue));
 
 
  802    for (
auto &node : List) {
 
  803      if (node.V.getAttribute() == 
Attribute) {
 
  804        return List.deleteNode(node);
 
 
 
  836  unsigned AbbrevNumber = ~0u;
 
  841  bool ForceChildren = 
false;
 
  868    assert(Offset && 
"Offset being queried before it's been computed.");
 
 
  873    assert(Size && 
"Size being queried before it's been ocmputed.");
 
 
  876  bool hasChildren()
 const { 
return ForceChildren || !Children.empty(); }
 
  885    return make_range(Children.begin(), Children.end());
 
 
  888    return make_range(Children.begin(), Children.end());
 
 
  947    Children.push_back(*Child);
 
  948    return Children.back();
 
 
  954    Children.push_front(*Child);
 
  955    return Children.front();
 
 
 
  996    this->Section = Section;
 
 
 
 1021  mutable unsigned Size = 0; 
 
 1035    if (DwarfVersion > 3)
 
 1036      return dwarf::DW_FORM_exprloc;
 
 1039      return dwarf::DW_FORM_block1;
 
 1041      return dwarf::DW_FORM_block2;
 
 1043      return dwarf::DW_FORM_block4;
 
 1044    return dwarf::DW_FORM_block;
 
 
 
 1057  mutable unsigned Size = 0; 
 
 1072      return dwarf::DW_FORM_block1;
 
 1074      return dwarf::DW_FORM_block2;
 
 1076      return dwarf::DW_FORM_block4;
 
 1077    return dwarf::DW_FORM_block;
 
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains constants used for implementing Dwarf debug support.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
This file defines the PointerIntPair class.
This file defines the PointerUnion class, which is a discriminated union of pointer types.
This file defines the SmallVector class.
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
This class is intended to be used as a driving class for all asm writers.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
dwarf::Form getForm() const
dwarf::Attribute getAttribute() const
Accessors.
DIEAbbrevData(dwarf::Attribute A, int64_t V)
DIEAbbrevData(dwarf::Attribute A, dwarf::Form F)
Helps unique DIEAbbrev objects and assigns abbreviation numbers.
LLVM_ABI void Emit(const AsmPrinter *AP, MCSection *Section) const
Print all abbreviations using the specified asm printer.
DIEAbbrevSet(BumpPtrAllocator &A)
LLVM_ABI DIEAbbrev & uniqueAbbreviation(DIE &Die)
Generate the abbreviation declaration for a DIE and return a pointer to the generated abbreviation.
Dwarf abbreviation, describes the organization of a debug information object.
LLVM_ABI void print(raw_ostream &O) const
void AddImplicitConstAttribute(dwarf::Attribute Attribute, int64_t Value)
Adds attribute with DW_FORM_implicit_const value.
unsigned getNumber() const
LLVM_ABI void Emit(const AsmPrinter *AP) const
Print the abbreviation using the specified asm printer.
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
Adds another set of attribute information to the abbreviation.
void AddAttribute(const DIEAbbrevData &AbbrevData)
Adds another set of attribute information to the abbreviation.
const SmallVectorImpl< DIEAbbrevData > & getData() const
DIEAbbrev(dwarf::Tag T, bool C)
void setChildrenFlag(bool hasChild)
dwarf::Tag getTag() const
Accessors.
void setNumber(unsigned N)
LLVM_ABI void dump() const
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
DIEAddrOffset(uint64_t Idx, const MCSymbol *Hi, const MCSymbol *Lo)
uint64_t getIndex() const
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit base type reference.
LLVM_ABI void print(raw_ostream &O) const
DIEBaseTypeRef(const DwarfCompileUnit *TheCU, uint64_t Idx)
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
sizeOf - Determine size of the base type reference in bytes.
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of block data in bytes.
void setSize(unsigned size)
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit block data.
LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
A simple label difference DIE.
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit debug information entry offset.
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
LLVM_ABI void print(raw_ostream &O) const
const MCExpr * getValue() const
Get MCExpr.
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
~DIEInlineString()=default
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
StringRef getString() const
Grab the string out of the object.
DIEInlineString(StringRef Str, Allocator &A)
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of integer value in bytes.
uint64_t getValue() const
void setValue(uint64_t Val)
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
const MCSymbol * getValue() const
Get MCSymbol.
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of label value in bytes.
DIELabel(const MCSymbol *L)
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
size_t getValue() const
Grab the current index out.
void setSize(unsigned size)
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of location data in bytes.
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit location data.
LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit string value.
DIEString(DwarfStringPoolEntryRef S)
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of delta value in bytes.
StringRef getString() const
Grab the string out of the object.
Represents a compile or type unit.
void setSection(MCSection *Section)
Set the section that this DIEUnit will be emitted into.
void operator=(const DIEUnit &&RHS)=delete
DIEUnit(DIEUnit &&RHS)=delete
void operator=(const DIEUnit &RHS)=delete
const DIE & getUnitDie() const
DIEUnit(const DIEUnit &RHS)=delete
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
LLVM_ABI DIEUnit(dwarf::Tag UnitTag)
void setDebugSectionOffset(uint64_t O)
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
virtual ~DIEUnit()=default
.debug_info or .debug_types absolute section offset.
uint64_t getDebugSectionOffset() const
const_value_iterator()=default
const DIEValue & operator*() const
const_value_iterator(DIEValueList::value_iterator X)
const_value_iterator(ListTy::const_iterator X)
friend class const_value_iterator
value_iterator(ListTy::iterator X)
DIEValue & operator*() const
bool deleteValue(dwarf::Attribute Attribute)
void takeValues(DIEValueList &Other)
Take ownership of the nodes in Other, and append them to the back of the list.
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Attribute NewAttribute, dwarf::Form Form, T &&NewValue)
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&NewValue)
iterator_range< value_iterator > value_range
value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V)
const_value_range values() const
iterator_range< const_value_iterator > const_value_range
value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, DIEValue &NewValue)
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI void emitValue(const AsmPrinter *AP) const
Emit value via the Dwarf writer.
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams) const
Return the size of a value in bytes.
dwarf::Form getForm() const
Type getType() const
Accessors.
DIEValue(const DIEValue &X)
DIEValue & operator=(const DIEValue &X)
dwarf::Attribute getAttribute() const
LLVM_ABI void dump() const
A structured debug information entry.
LLVM_ABI DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
LLVM_ABI void print(raw_ostream &O, unsigned IndentCount=0) const
IntrusiveBackList< DIE >::const_iterator const_child_iterator
unsigned getAbbrevNumber() const
const_child_range children() const
IntrusiveBackList< DIE >::iterator child_iterator
DIE & addChild(DIE *Child)
Add a child to the DIE.
DIE(const DIE &RHS)=delete
LLVM_ABI DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
LLVM_ABI unsigned computeOffsetsAndAbbrevs(const dwarf::FormParams &FormParams, DIEAbbrevSet &AbbrevSet, unsigned CUOffset)
Compute the offset of this DIE and all its children.
DIE & addChildFront(DIE *Child)
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
LLVM_ABI DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to.
DIE & operator=(const DIE &RHS)=delete
LLVM_ABI const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.
void setAbbrevNumber(unsigned I)
Set the abbreviation number for this DIE.
iterator_range< child_iterator > child_range
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
void setOffset(unsigned O)
void setForceChildren(bool B)
LLVM_ABI uint64_t getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
iterator_range< const_child_iterator > const_child_range
dwarf::Tag getTag() const
LLVM_ABI void dump() const
DIE & operator=(const DIE &&RHS)=delete
LLVM_ABI DIE * getParent() const
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
const T & operator*() const
bool operator==(const const_iterator &X) const
const_iterator(typename IntrusiveBackList< T >::iterator X)
const_iterator & operator++()
const_iterator(const T *N)
bool operator==(const iterator &X) const
friend class const_iterator
void takeNodes(IntrusiveBackList< T > &Other)
static const_iterator toIterator(const T &N)
const_iterator begin() const
const_iterator end() const
static iterator toIterator(T &N)
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
PointerIntPair - This class implements a pair of a pointer and small integer.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
const ListTy::iterator & wrapped() const
iterator_adaptor_base()=default
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
Calculates the starting offsets for various sections within the .debug_names section.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
FoldingSetBase::Node FoldingSetNode
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
OutputIt copy(R &&Range, OutputIt Out)
BasicDIEUnit(dwarf::Tag UnitTag)
IntrusiveBackListNode Node
PointerIntPair< IntrusiveBackListNode *, 1 > Next
IntrusiveBackListNode * getNext() const