]> git.proxmox.com Git - rustc.git/blob - src/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / lib / CodeGen / AsmPrinter / DwarfFile.h
1 //===-- llvm/CodeGen/DwarfFile.h - Dwarf Debug Framework -------*- C++ -*--===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
11 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
12
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"
20 #include <memory>
21 #include <string>
22 #include <vector>
23
24 namespace llvm {
25 class AsmPrinter;
26 class DbgVariable;
27 class DwarfUnit;
28 class DIEAbbrev;
29 class MCSymbol;
30 class DIE;
31 class DISubprogram;
32 class LexicalScope;
33 class StringRef;
34 class DwarfDebug;
35 class MCSection;
36 class DwarfFile {
37 // Target of Dwarf emission, used for sizing of abbreviations.
38 AsmPrinter *Asm;
39
40 DwarfDebug &DD;
41
42 // Used to uniquely define abbreviations.
43 FoldingSet<DIEAbbrev> AbbreviationsSet;
44
45 // A list of all the unique abbreviations in use.
46 std::vector<DIEAbbrev *> Abbreviations;
47
48 // A pointer to all units in the section.
49 SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs;
50
51 DwarfStringPool StrPool;
52
53 // Collection of dbg variables of a scope.
54 DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8>> ScopeVariables;
55
56 // Collection of abstract subprogram DIEs.
57 DenseMap<const MDNode *, DIE *> AbstractSPDies;
58
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;
63
64 public:
65 DwarfFile(AsmPrinter *AP, DwarfDebug &DD, StringRef Pref,
66 BumpPtrAllocator &DA);
67
68 ~DwarfFile();
69
70 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; }
71
72 /// \brief Compute the size and offset of a DIE given an incoming Offset.
73 unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
74
75 /// \brief Compute the size and offset of all the DIEs.
76 void computeSizeAndOffsets();
77
78 /// \brief Define a unique number for the abbreviation.
79 void assignAbbrevNumber(DIEAbbrev &Abbrev);
80
81 /// \brief Add a unit to the list of CUs.
82 void addUnit(std::unique_ptr<DwarfUnit> U);
83
84 /// \brief Emit all of the units to the section listed with the given
85 /// abbreviation section.
86 void emitUnits(const MCSymbol *ASectionSym);
87
88 /// \brief Emit a set of abbreviations to the specific section.
89 void emitAbbrevs(const MCSection *);
90
91 /// \brief Emit all of the strings to the section given.
92 void emitStrings(const MCSection *StrSection,
93 const MCSection *OffsetSection = nullptr);
94
95 /// \brief Returns the string pool.
96 DwarfStringPool &getStringPool() { return StrPool; }
97
98 void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
99
100 DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8>> &getScopeVariables() {
101 return ScopeVariables;
102 }
103
104 DenseMap<const MDNode *, DIE *> &getAbstractSPDies() {
105 return AbstractSPDies;
106 }
107
108 void insertDIE(const MDNode *TypeMD, DIE *Die) {
109 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
110 }
111 DIE *getDIE(const MDNode *TypeMD) {
112 return MDTypeNodeToDieMap.lookup(TypeMD);
113 }
114 };
115 }
116 #endif