]>
git.proxmox.com Git - rustc.git/blob - src/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
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 LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
11 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
13 #include "AddressPool.h"
14 #include "DwarfStringPool.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/FoldingSet.h"
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/ADT/StringMap.h"
19 #include "llvm/Support/Allocator.h"
37 // Target of Dwarf emission, used for sizing of abbreviations.
42 // Used to uniquely define abbreviations.
43 FoldingSet
<DIEAbbrev
> AbbreviationsSet
;
45 // A list of all the unique abbreviations in use.
46 std::vector
<DIEAbbrev
*> Abbreviations
;
48 // A pointer to all units in the section.
49 SmallVector
<std::unique_ptr
<DwarfUnit
>, 1> CUs
;
51 DwarfStringPool StrPool
;
53 // Collection of dbg variables of a scope.
54 DenseMap
<LexicalScope
*, SmallVector
<DbgVariable
*, 8>> ScopeVariables
;
56 // Collection of abstract subprogram DIEs.
57 DenseMap
<const MDNode
*, DIE
*> AbstractSPDies
;
59 /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
60 /// be shared across CUs, that is why we keep the map here instead
61 /// of in DwarfCompileUnit.
62 DenseMap
<const MDNode
*, DIE
*> MDTypeNodeToDieMap
;
65 DwarfFile(AsmPrinter
*AP
, DwarfDebug
&DD
, StringRef Pref
,
66 BumpPtrAllocator
&DA
);
70 const SmallVectorImpl
<std::unique_ptr
<DwarfUnit
>> &getUnits() { return CUs
; }
72 /// \brief Compute the size and offset of a DIE given an incoming Offset.
73 unsigned computeSizeAndOffset(DIE
&Die
, unsigned Offset
);
75 /// \brief Compute the size and offset of all the DIEs.
76 void computeSizeAndOffsets();
78 /// \brief Define a unique number for the abbreviation.
79 void assignAbbrevNumber(DIEAbbrev
&Abbrev
);
81 /// \brief Add a unit to the list of CUs.
82 void addUnit(std::unique_ptr
<DwarfUnit
> U
);
84 /// \brief Emit all of the units to the section listed with the given
85 /// abbreviation section.
86 void emitUnits(const MCSymbol
*ASectionSym
);
88 /// \brief Emit a set of abbreviations to the specific section.
89 void emitAbbrevs(const MCSection
*);
91 /// \brief Emit all of the strings to the section given.
92 void emitStrings(const MCSection
*StrSection
,
93 const MCSection
*OffsetSection
= nullptr);
95 /// \brief Returns the string pool.
96 DwarfStringPool
&getStringPool() { return StrPool
; }
98 void addScopeVariable(LexicalScope
*LS
, DbgVariable
*Var
);
100 DenseMap
<LexicalScope
*, SmallVector
<DbgVariable
*, 8>> &getScopeVariables() {
101 return ScopeVariables
;
104 DenseMap
<const MDNode
*, DIE
*> &getAbstractSPDies() {
105 return AbstractSPDies
;
108 void insertDIE(const MDNode
*TypeMD
, DIE
*Die
) {
109 MDTypeNodeToDieMap
.insert(std::make_pair(TypeMD
, Die
));
111 DIE
*getDIE(const MDNode
*TypeMD
) {
112 return MDTypeNodeToDieMap
.lookup(TypeMD
);