1 //===-- llvm/CodeGen/DwarfFile.h - Dwarf Debug Framework -------*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CODEGEN_ASMPRINTER_DWARFFILE_H__
11 #define CODEGEN_ASMPRINTER_DWARFFILE_H__
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/FoldingSet.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/ADT/StringMap.h"
17 #include "llvm/Support/Allocator.h"
18 #include "AddressPool.h"
34 // Target of Dwarf emission, used for sizing of abbreviations.
37 // Used to uniquely define abbreviations.
38 FoldingSet<DIEAbbrev> AbbreviationsSet;
40 // A list of all the unique abbreviations in use.
41 std::vector<DIEAbbrev *> Abbreviations;
43 // A pointer to all units in the section.
44 SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs;
46 // Collection of strings for this unit and assorted symbols.
47 // A String->Symbol mapping of strings used by indirect
49 typedef StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &>
52 unsigned NextStringPoolNumber;
53 std::string StringPref;
58 DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA);
62 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; }
64 /// \brief Compute the size and offset of a DIE given an incoming Offset.
65 unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
67 /// \brief Compute the size and offset of all the DIEs.
68 void computeSizeAndOffsets();
70 /// \brief Define a unique number for the abbreviation.
71 void assignAbbrevNumber(DIEAbbrev &Abbrev);
73 /// \brief Add a unit to the list of CUs.
74 void addUnit(std::unique_ptr<DwarfUnit> U);
76 /// \brief Emit all of the units to the section listed with the given
77 /// abbreviation section.
78 void emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym);
80 /// \brief Emit a set of abbreviations to the specific section.
81 void emitAbbrevs(const MCSection *);
83 /// \brief Emit all of the strings to the section given.
84 void emitStrings(const MCSection *StrSection,
85 const MCSection *OffsetSection = nullptr,
86 const MCSymbol *StrSecSym = nullptr);
88 /// \brief Returns the entry into the start of the pool.
89 MCSymbol *getStringPoolSym();
91 /// \brief Returns an entry into the string pool with the given
93 MCSymbol *getStringPoolEntry(StringRef Str);
95 /// \brief Returns the index into the string pool with the given
97 unsigned getStringPoolIndex(StringRef Str);
99 /// \brief Returns the string pool.
100 StrPool *getStringPool() { return &StringPool; }
102 AddressPool &getAddressPool() { return AddrPool; }