Go to the documentation of this file.
13 #ifndef LLVM_CODEGEN_DIE_H
14 #define LLVM_CODEGEN_DIE_H
32 #include <type_traits>
41 class DwarfCompileUnit;
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;
238 static constexpr
unsigned ULEB128PadSize = 4;
242 :
CU(TheCU), Index(Idx) {}
296 template <
typename Allocator>
356 :
Addr(Idx), Offset(Hi, Lo) {}
373 #define HANDLE_DIEVALUE(T) is##T,
374 #include "llvm/CodeGen/DIEValue.def"
388 AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
389 DIEDelta *, DIEEntry, DIEBlock *, DIELoc *,
390 DIELocList, DIEBaseTypeRef *, DIEAddrOffset *>;
392 static_assert(
sizeof(ValTy) <=
sizeof(
uint64_t) ||
393 sizeof(ValTy) <=
sizeof(
void *),
394 "Expected all large types to be stored via pointer");
399 template <
class T>
void construct(T V) {
400 static_assert(std::is_standard_layout<T>::value ||
401 std::is_pointer<T>::value,
402 "Expected standard layout or pointer");
403 new (
reinterpret_cast<void *
>(&Val))
T(V);
406 template <
class T>
T *get() {
return reinterpret_cast<T *
>(&Val); }
407 template <
class T>
const T *get()
const {
408 return reinterpret_cast<const T *
>(&Val);
410 template <
class T>
void destruct() { get<T>()->~T(); }
421 #define HANDLE_DIEVALUE_SMALL(T) \
423 destruct<DIE##T>(); \
425 #define HANDLE_DIEVALUE_LARGE(T) \
427 destruct<const DIE##T *>(); \
429 #include "llvm/CodeGen/DIEValue.def"
442 #define HANDLE_DIEVALUE_SMALL(T) \
444 construct<DIE##T>(*X.get<DIE##T>()); \
446 #define HANDLE_DIEVALUE_LARGE(T) \
448 construct<const DIE##T *>(*X.get<const DIE##T *>()); \
450 #include "llvm/CodeGen/DIEValue.def"
472 #define HANDLE_DIEVALUE_SMALL(T) \
473 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T &V) \
474 : Ty(is##T), Attribute(Attribute), Form(Form) { \
475 construct<DIE##T>(V); \
477 #define HANDLE_DIEVALUE_LARGE(T) \
478 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T *V) \
479 : Ty(is##T), Attribute(Attribute), Form(Form) { \
480 assert(V && "Expected valid value"); \
481 construct<const DIE##T *>(V); \
483 #include "llvm/CodeGen/DIEValue.def"
490 explicit operator bool()
const {
return Ty; }
493 #define HANDLE_DIEVALUE_SMALL(T) \
494 const DIE##T &getDIE##T() const { \
495 assert(getType() == is##T && "Expected " #T); \
496 return *get<DIE##T>(); \
498 #define HANDLE_DIEVALUE_LARGE(T) \
499 const DIE##T &getDIE##T() const { \
500 assert(getType() == is##T && "Expected " #T); \
501 return **get<const DIE##T *>(); \
503 #include "llvm/CodeGen/DIEValue.def"
506 void emitValue(
const AsmPrinter *AP)
const;
509 unsigned sizeOf(
const dwarf::FormParams &FormParams)
const;
511 void print(raw_ostream &
O)
const;
521 return Next.getInt() ? nullptr :
Next.getPointer();
533 assert(
N.Next.getPointer() == &
N &&
"Expected unlinked node");
534 assert(
N.Next.getInt() ==
true &&
"Expected unlinked node");
544 assert(
N.Next.getPointer() == &
N &&
"Expected unlinked node");
545 assert(
N.Next.getInt() ==
true &&
"Expected unlinked node");
548 N.Next.setPointerAndInt(
Last->
Next.getPointer(),
false);
565 return *
static_cast<T *
>(
Last ?
Last->
Next.getPointer() :
nullptr);
568 return *
static_cast<T *
>(
Last ?
Last->
Next.getPointer() :
nullptr);
575 T *FirstNode =
static_cast<T *
>(
Other.Last->Next.getPointer());
576 T *IterNode = FirstNode;
579 T *TmpNode = IterNode;
580 IterNode =
static_cast<T *
>(IterNode->Next.getPointer());
583 TmpNode->Next.setPointerAndInt(TmpNode,
true);
585 }
while (IterNode != FirstNode);
587 Other.Last =
nullptr;
606 explicit operator bool()
const {
return N; }
615 const Node *N =
nullptr;
628 explicit operator bool()
const {
return N; }
640 iterator
end() {
return iterator(); }
677 std::forward_iterator_tag, DIEValue> {
682 std::forward_iterator_tag,
DIEValue>;
688 explicit operator bool()
const {
return bool(
wrapped()); }
693 const_value_iterator, ListTy::const_iterator,
694 std::forward_iterator_tag, const DIEValue> {
697 std::forward_iterator_tag,
const DIEValue>;
706 explicit operator bool()
const {
return bool(
wrapped()); }
714 List.push_back(*
new (Alloc) Node(V));
747 unsigned AbbrevNumber = ~0u;
752 bool ForceChildren =
false;
770 return new (Alloc)
DIE(
Tag);
779 assert(
Offset &&
"Offset being queried before it's been computed.");
784 assert(
Size &&
"Size being queried before it's been ocmputed.");
858 return Children.
back();
865 return Children.
front();
906 this->Section = Section;
931 mutable unsigned Size = 0;
945 if (DwarfVersion > 3)
946 return dwarf::DW_FORM_exprloc;
948 if ((
unsigned char)Size == Size)
949 return dwarf::DW_FORM_block1;
950 if ((
unsigned short)Size == Size)
951 return dwarf::DW_FORM_block2;
952 if ((
unsigned int)Size == Size)
953 return dwarf::DW_FORM_block4;
954 return dwarf::DW_FORM_block;
967 mutable unsigned Size = 0;
981 if ((
unsigned char)Size == Size)
982 return dwarf::DW_FORM_block1;
983 if ((
unsigned short)Size == Size)
984 return dwarf::DW_FORM_block2;
985 if ((
unsigned int)Size == Size)
986 return dwarf::DW_FORM_block4;
987 return dwarf::DW_FORM_block;
998 #endif // LLVM_CODEGEN_DIE_H
const SmallVectorImpl< DIEAbbrevData > & getData() const
dwarf::Form getForm() const
void print(raw_ostream &O) const
void setOffset(unsigned O)
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
void print(raw_ostream &O) const
DIEAbbrevData(dwarf::Attribute A, dwarf::Form F)
const MCSymbol * getValue() const
Get MCSymbol.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const_child_range children() const
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
Represents a compile or type unit.
virtual ~DIEUnit()=default
.debug_info or .debug_types absolute section offset.
void print(raw_ostream &O, unsigned IndentCount=0) const
DIEAbbrev(dwarf::Tag T, bool C)
DIEAbbrev & uniqueAbbreviation(DIE &Die)
Generate the abbreviation declaration for a DIE and return a pointer to the generated abbreviation.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
uint64_t getValue() const
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
const_value_iterator(DIEValueList::value_iterator X)
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of location data in bytes.
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.
dwarf::Attribute getAttribute() const
Accessors.
IntrusiveBackListNode * getNext() const
CRTP base class for adapting an iterator to a different type.
So we should use XX3Form_Rcr to implement intrinsic Convert DP outs ins xscvdpsp No builtin are required Round &Convert QP DP(dword[1] is set to zero) No builtin are required Round to Quad Precision Integer
OutputIt copy(R &&Range, OutputIt Out)
DIEString(DwarfStringPoolEntryRef S)
unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
DIEInlineString(StringRef Str, Allocator &A)
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
Adds another set of attribute information to the abbreviation.
A structured debug information entry.
unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of block data in bytes.
Node(Kind K_, Prec Precedence_=Prec::Primary, Cache RHSComponentCache_=Cache::No, Cache ArrayCache_=Cache::No, Cache FunctionCache_=Cache::No)
const ListTy::iterator & wrapped() const
dwarf::Tag getTag() const
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit debug information entry offset.
uint64_t getDebugSectionOffset() const
void print(raw_ostream &O) const
unsigned computeOffsetsAndAbbrevs(const dwarf::FormParams &FormParams, DIEAbbrevSet &AbbrevSet, unsigned CUOffset)
Compute the offset of this DIE and all its children.
DIEValue & operator*() const
String pool entry reference.
void AddImplicitConstAttribute(dwarf::Attribute Attribute, int64_t Value)
Adds attribute with DW_FORM_implicit_const value.
size_t getValue() const
Grab the current index out.
unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
DIEValue & operator=(const DIEValue &X)
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
DIEBaseTypeRef(const DwarfCompileUnit *TheCU, uint64_t Idx)
const_iterator & operator++()
DIE & addChild(DIE *Child)
Add a child to the DIE.
Dwarf abbreviation, describes the organization of a debug information object.
void print(raw_ostream &O) const
void setValue(uint64_t Val)
const DIEValue & operator*() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void setNumber(unsigned N)
(vector float) vec_cmpeq(*A, *B) C
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
Represents a pointer to a location list in the debug_loc section.
DIE & addChildFront(DIE *Child)
dwarf::Form getForm() const
void Emit(const AsmPrinter *AP) const
Print the abbreviation using the specified asm printer.
void setForceChildren(bool B)
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit base type reference.
A simple label difference DIE.
const_value_range values() const
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const DIE & getUnitDie() const
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
StringRef getString() const
Grab the string out of the object.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of label value in bytes.
void operator=(const DIEUnit &RHS)=delete
static iterator toIterator(T &N)
void Emit(const AsmPrinter *AP, MCSection *Section) const
Print all abbreviations using the specified asm printer.
DIEBlock - Represents a block of values.
DIEValue(const DIEValue &X)
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
void takeValues(DIEValueList &Other)
Take ownership of the nodes in Other, and append them to the back of the list.
void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
void print(raw_ostream &O) const
uint64_t getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
A container for string pool string values.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V)
void setSize(unsigned size)
void print(raw_ostream &O) const
A container for inline string values.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
const_iterator(typename IntrusiveBackList< T >::iterator X)
void setDebugSectionOffset(uint64_t O)
void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit location data.
DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
DIEUnit(dwarf::Tag UnitTag)
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit string value.
void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of delta value in bytes.
~DIEInlineString()=default
void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit block data.
DIE & operator=(const DIE &RHS)=delete
BasicDIEUnit(dwarf::Tag UnitTag)
dwarf::Attribute getAttribute() const
Type getType() const
Accessors.
DIELabel(const MCSymbol *L)
Allocate memory in an ever growing pool, as if by bump-pointer.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
DIELoc - Represents an expression location.
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
void setChildrenFlag(bool hasChild)
const_iterator(const T *N)
const_value_iterator(ListTy::const_iterator X)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const_iterator end() const
value_iterator(ListTy::iterator X)
A pointer to another debug information entry.
void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
void emitValue(const AsmPrinter *AP) const
Emit value via the Dwarf writer.
void print(raw_ostream &O) const
PointerIntPair< IntrusiveBackListNode *, 1 > Next
const T & operator*() const
StringRef getString() const
Grab the string out of the object.
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.
dwarf::Tag getTag() const
Accessors.
DIEAbbrevSet(BumpPtrAllocator &A)
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
sizeOf - Determine size of the base type reference in bytes.
static const_iterator toIterator(const T &N)
StringRef - Represent a constant reference to a string, i.e.
Analysis the ScalarEvolution expression for r is this
Node - This class is used to maintain the singly linked bucket list in a folding set.
void takeNodes(IntrusiveBackList< T > &Other)
const MCExpr * getValue() const
Get MCExpr.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
bool operator==(const iterator &X) const
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
const_iterator begin() const
unsigned sizeOf(const dwarf::FormParams &FormParams) const
Return the size of a value in bytes.
void print(raw_ostream &O) const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
void print(raw_ostream &O) const
DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to.
void print(raw_ostream &O) const
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
Helps unique DIEAbbrev objects and assigns abbreviation numbers.
This class is intended to be used as a driving class for all asm writers.
unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
void setSection(MCSection *Section)
Set the section that this DIEUnit will be emitted into.
uint64_t getIndex() const
unsigned getAbbrevNumber() const
DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
bool operator==(const const_iterator &X) const
PointerIntPair - This class implements a pair of a pointer and small integer.
DIEAddrOffset(uint64_t Idx, const MCSymbol *Hi, const MCSymbol *Lo)
void print(raw_ostream &O) const
A range adaptor for a pair of iterators.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
void setSize(unsigned size)
unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of integer value in bytes.
unsigned getNumber() const
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
const_value_iterator()=default
void print(raw_ostream &O) const
void setAbbrevNumber(unsigned I)
Set the abbreviation number for this DIE.
DIEAbbrevData(dwarf::Attribute A, int64_t V)
LLVM Value Representation.
Base class for the full range of assembler expressions which are needed for parsing.
void print(raw_ostream &O) const
void print(raw_ostream &O) const
Optional< std::vector< StOtherPiece > > Other