DwarfCompileUnit.h revision 6948897e478cbd66626159776a8017b3c18579b9
137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//===-- llvm/CodeGen/DwarfCompileUnit.h - Dwarf Compile Unit ---*- C++ -*--===//
237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//
337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//                     The LLVM Compiler Infrastructure
437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//
537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines// This file is distributed under the University of Illinois Open Source
637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines// License. See LICENSE.TXT for details.
737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//
837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//===----------------------------------------------------------------------===//
937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//
1037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines// This file contains support for writing dwarf compile unit.
1137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//
1237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines//===----------------------------------------------------------------------===//
1337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
1437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
1537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
1637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
1737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#include "DwarfUnit.h"
1837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#include "llvm/ADT/StringRef.h"
1937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#include "llvm/IR/DebugInfo.h"
20ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines#include "llvm/Support/Dwarf.h"
2137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
2237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinesnamespace llvm {
2337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
2437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinesclass AsmPrinter;
2537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinesclass DIE;
2637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinesclass DwarfDebug;
2737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinesclass DwarfFile;
2837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinesclass MCSymbol;
2937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinesclass LexicalScope;
3037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
3137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinesclass DwarfCompileUnit : public DwarfUnit {
3237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// The attribute index of DW_AT_stmt_list in the compile unit DIE, avoiding
3337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// the need to search for it in applyStmtList.
3437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  unsigned stmtListIndex;
3537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
3637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Skeleton unit associated with this unit.
3737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  DwarfCompileUnit *Skeleton;
3837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
3937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// The start of the unit within its section.
4037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  MCSymbol *LabelBegin;
4137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
4237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// GlobalNames - A map of globally visible named entities for this unit.
4337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  StringMap<const DIE *> GlobalNames;
4437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
4537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// GlobalTypes - A map of globally visible types for this unit.
4637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  StringMap<const DIE *> GlobalTypes;
4737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
4837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  // List of range lists for a given compile unit, separate from the ranges for
4937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  // the CU itself.
5037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  SmallVector<RangeSpanList, 1> CURangeLists;
5137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
5237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  // List of ranges for a given compile unit.
5337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  SmallVector<RangeSpan, 2> CURanges;
5437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
5537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  // The base address of this unit, if any. Used for relative references in
5637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  // ranges/locs.
5737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  const MCSymbol *BaseAddress;
5837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
5937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// \brief Construct a DIE for the given DbgVariable without initializing the
6037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// DbgVariable's DIE reference.
6137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
6237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                                                bool Abstract);
6337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
6437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  bool isDwoUnit() const override;
6537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
6637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  bool includeMinimalInlineScopes() const;
6737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
6837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinespublic:
696948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A,
7037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                   DwarfDebug *DW, DwarfFile *DWU);
7137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
7237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  DwarfCompileUnit *getSkeleton() const {
7337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    return Skeleton;
7437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
7537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
764c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  void initStmtList();
7737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
7837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
7937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void applyStmtList(DIE &D);
8037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
8137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// getOrCreateGlobalVariableDIE - get or create global variable DIE.
826948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  DIE *getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV);
8337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
8437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// addLabelAddress - Add a dwarf label attribute data and value using
8537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
8637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addLabelAddress(DIE &Die, dwarf::Attribute Attribute,
8737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                       const MCSymbol *Label);
8837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
8937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// addLocalLabelAddress - Add a dwarf label attribute data and value using
9037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// DW_FORM_addr only.
9137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute,
9237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                            const MCSymbol *Label);
9337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
9437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// addSectionDelta - Add a label delta attribute data and value.
9537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
9637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                       const MCSymbol *Lo);
9737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
9837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  DwarfCompileUnit &getCU() override { return *this; }
9937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
10037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
10137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
10237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// addRange - Add an address range to the list of ranges for this unit.
10337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addRange(RangeSpan Range);
10437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
10537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End);
10637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
10737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// addSectionLabel - Add a Dwarf section label attribute data and value.
10837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  ///
10937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
11037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                       const MCSymbol *Label, const MCSymbol *Sec);
11137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
11237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// \brief Find DIE for the given subprogram and attach appropriate
11337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
11437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// variables in this scope then create and insert DIEs for these
11537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// variables.
1166948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  DIE &updateSubprogramScopeDIE(const DISubprogram *SP);
11737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
11837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void constructScopeDIE(LexicalScope *Scope,
11937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                         SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren);
12037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
12137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// \brief A helper function to construct a RangeSpanList for a given
12237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// lexical scope.
12337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addScopeRangeList(DIE &ScopeDIE, SmallVector<RangeSpan, 2> Range);
12437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
12537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void attachRangesOrLowHighPC(DIE &D, SmallVector<RangeSpan, 2> Ranges);
12637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
12737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void attachRangesOrLowHighPC(DIE &D,
12837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                               const SmallVectorImpl<InsnRange> &Ranges);
12937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// \brief This scope represents inlined body of a function. Construct
13037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// DIE to represent this concrete inlined copy of the function.
13137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  std::unique_ptr<DIE> constructInlinedScopeDIE(LexicalScope *Scope);
13237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
13337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// \brief Construct new DW_TAG_lexical_block for this scope and
13437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// attach DW_AT_low_pc/DW_AT_high_pc labels.
13537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  std::unique_ptr<DIE> constructLexicalScopeDIE(LexicalScope *Scope);
13637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
13737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// constructVariableDIE - Construct a DIE for the given DbgVariable.
13837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
13937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                                            bool Abstract = false);
14037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
14137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
14237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                                            const LexicalScope &Scope,
14337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                                            DIE *&ObjectPointer);
14437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
14537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// A helper function to create children of a Scope DIE.
14637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  DIE *createScopeChildrenDIE(LexicalScope *Scope,
14737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                              SmallVectorImpl<std::unique_ptr<DIE>> &Children,
14837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                              unsigned *ChildScopeCount = nullptr);
14937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
15037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// \brief Construct a DIE for this subprogram scope.
15137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void constructSubprogramScopeDIE(LexicalScope *Scope);
15237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
15337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  DIE *createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE);
15437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
15537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
15637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
15737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// \brief Construct import_module DIE.
15837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  std::unique_ptr<DIE>
1596948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  constructImportedEntityDIE(const DIImportedEntity *Module);
16037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
1616948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  void finishSubprogramDefinition(const DISubprogram *SP);
16237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
1636948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  void collectDeadVariables(const DISubprogram *SP);
16437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
16537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Set the skeleton unit associated with this unit.
16637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; }
16737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
1684c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  const MCSymbol *getSectionSym() const {
16937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    assert(Section);
1704c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar    return Section->getBeginSymbol();
17137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
17237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
17337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  unsigned getLength() {
17437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    return sizeof(uint32_t) + // Length field
17537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines        getHeaderSize() + UnitDie.getSize();
17637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
17737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
1784c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  void emitHeader(bool UseOffsets) override;
17937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
18037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  MCSymbol *getLabelBegin() const {
18137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    assert(Section);
18237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    return LabelBegin;
18337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
18437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
18537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Add a new global name to the compile unit.
1866948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) override;
18737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
18837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Add a new global type to the compile unit.
1896948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  void addGlobalType(const DIType *Ty, const DIE &Die,
1906948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar                     const DIScope *Context) override;
19137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
19237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
19337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
19437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
19537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Add DW_AT_location attribute for a DbgVariable based on provided
19637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// MachineLocation.
19737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addVariableAddress(const DbgVariable &DV, DIE &Die,
19837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                          MachineLocation Location);
19937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Add an address attribute to a die based on the location provided.
20037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addAddress(DIE &Die, dwarf::Attribute Attribute,
201ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines                  const MachineLocation &Location);
20237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
20337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Start with the address based on the location provided, and generate the
20437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// DWARF information necessary to find the actual variable (navigating the
20537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// extra location information encoded in the type) based on the starting
20637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// location.  Add the DWARF information to the die.
20737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addComplexAddress(const DbgVariable &DV, DIE &Die,
20837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                         dwarf::Attribute Attribute,
20937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                         const MachineLocation &Location);
21037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
21137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Add a Dwarf loclistptr attribute data and value.
21237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index);
21337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie);
21437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
21537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Add a Dwarf expression attribute data and value.
21637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr);
21737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
2186948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  void applySubprogramAttributesToDefinition(const DISubprogram *SP,
2196948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar                                             DIE &SPDie);
22037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
22137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// getRangeLists - Get the vector of range lists.
22237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  const SmallVectorImpl<RangeSpanList> &getRangeLists() const {
22337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    return (Skeleton ? Skeleton : this)->CURangeLists;
22437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
22537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
22637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// getRanges - Get the list of ranges for this unit.
22737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; }
22837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  SmallVector<RangeSpan, 2> takeRanges() { return std::move(CURanges); }
22937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
23037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; }
23137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  const MCSymbol *getBaseAddress() const { return BaseAddress; }
23237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines};
23337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
23437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines} // end llvm namespace
23537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
23637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#endif
237