#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
#include "DwarfStringPool.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Support/Allocator.h"
#include <map>
#include <memory>
#include <utility>
namespace llvm {
class AsmPrinter;
class DbgVariable;
class DwarfCompileUnit;
class DwarfUnit;
class LexicalScope;
class MCSection;
class DwarfFile {
AsmPrinter *Asm;
BumpPtrAllocator AbbrevAllocator;
DIEAbbrevSet Abbrevs;
SmallVector<std::unique_ptr<DwarfCompileUnit>, 1> CUs;
DwarfStringPool StrPool;
MCSymbol *StringOffsetsStartSym = nullptr;
MCSymbol *RnglistsTableBaseSym = nullptr;
struct ScopeVars {
std::map<unsigned, DbgVariable *> Args;
SmallVector<DbgVariable *, 8> Locals;
};
DenseMap<LexicalScope *, ScopeVars> ScopeVariables;
DenseMap<const MDNode *, DIE *> AbstractSPDies;
DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
DenseMap<const MDNode *, DIE *> DITypeNodeToDieMap;
public:
DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA);
const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() {
return CUs;
}
unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
void computeSizeAndOffsets();
unsigned computeSizeAndOffsetsForUnit(DwarfUnit *TheU);
void addUnit(std::unique_ptr<DwarfCompileUnit> U);
void emitUnits(bool UseOffsets);
void emitUnit(DwarfUnit *U, bool UseOffsets);
void emitAbbrevs(MCSection *);
void emitStrings(MCSection *StrSection, MCSection *OffsetSection = nullptr,
bool UseRelativeOffsets = false);
DwarfStringPool &getStringPool() { return StrPool; }
MCSymbol *getStringOffsetsStartSym() const { return StringOffsetsStartSym; }
void setStringOffsetsStartSym(MCSymbol *Sym) { StringOffsetsStartSym = Sym; }
MCSymbol *getRnglistsTableBaseSym() const { return RnglistsTableBaseSym; }
void setRnglistsTableBaseSym(MCSymbol *Sym) { RnglistsTableBaseSym = Sym; }
bool addScopeVariable(LexicalScope *LS, DbgVariable *Var);
DenseMap<LexicalScope *, ScopeVars> &getScopeVariables() {
return ScopeVariables;
}
DenseMap<const MDNode *, DIE *> &getAbstractSPDies() {
return AbstractSPDies;
}
DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> &getAbstractVariables() {
return AbstractVariables;
}
void insertDIE(const MDNode *TypeMD, DIE *Die) {
DITypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
}
DIE *getDIE(const MDNode *TypeMD) {
return DITypeNodeToDieMap.lookup(TypeMD);
}
};
}
#endif