bced5335e288356406d456a51c29db476d65471f
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfCompileUnit.h
1 //===-- 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
22 namespace llvm {
23
24 class AsmPrinter;
25 class DIE;
26 class DwarfDebug;
27 class DwarfFile;
28 class MCSymbol;
29
30 class 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
35 public:
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);
63 };
64
65 } // end llvm namespace
66
67 #endif