blob: a98ab26cc0f7bf3759b722b4faa677f17744dcd0 [file] [log] [blame]
David Blaikie37c52312014-10-04 15:49:50 +00001//===-- llvm/CodeGen/DwarfCompileUnit.h - Dwarf Compile Unit ---*- 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// This file contains support for writing dwarf compile unit.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
15#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
16
17#include "DwarfUnit.h"
18#include "llvm/Support/Dwarf.h"
19#include "llvm/ADT/StringRef.h"
20#include "llvm/IR/DebugInfo.h"
21
22namespace llvm {
23
24class AsmPrinter;
25class DIE;
26class DwarfDebug;
27class DwarfFile;
28class MCSymbol;
29
30class DwarfCompileUnit : public DwarfUnit {
31 /// The attribute index of DW_AT_stmt_list in the compile unit DIE, avoiding
32 /// the need to search for it in applyStmtList.
33 unsigned stmtListIndex;
34
35public:
36 DwarfCompileUnit(unsigned UID, DICompileUnit Node, AsmPrinter *A,
37 DwarfDebug *DW, DwarfFile *DWU);
38
39 void initStmtList(MCSymbol *DwarfLineSectionSym);
40
41 /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
42 void applyStmtList(DIE &D);
43
44 /// getOrCreateGlobalVariableDIE - get or create global variable DIE.
45 DIE *getOrCreateGlobalVariableDIE(DIGlobalVariable GV);
46
47 /// addLabelAddress - Add a dwarf label attribute data and value using
48 /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
49 void addLabelAddress(DIE &Die, dwarf::Attribute Attribute,
50 const MCSymbol *Label);
51
52 /// addLocalLabelAddress - Add a dwarf label attribute data and value using
53 /// DW_FORM_addr only.
54 void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute,
55 const MCSymbol *Label);
56
57 DwarfCompileUnit &getCU() override { return *this; }
58
59 unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
60
61 /// addRange - Add an address range to the list of ranges for this unit.
62 void addRange(RangeSpan Range);
David Blaikie14499a72014-10-04 15:58:47 +000063
64 void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End);
David Blaikiecda2aa82014-10-04 16:24:00 +000065
66 /// \brief Find DIE for the given subprogram and attach appropriate
67 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
68 /// variables in this scope then create and insert DIEs for these
69 /// variables.
70 DIE &updateSubprogramScopeDIE(DISubprogram SP);
David Blaikie37c52312014-10-04 15:49:50 +000071};
72
73} // end llvm namespace
74
75#endif