blob: ab32c1b279b7c015e00db80c89bd4cdfab2c4208 [file] [log] [blame]
David Blaikiedaefdbf2014-04-25 21:34:35 +00001//===-- llvm/CodeGen/DwarfStringPool.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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H
11#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H
David Blaikiedaefdbf2014-04-25 21:34:35 +000012
13#include "llvm/ADT/StringMap.h"
14#include "llvm/CodeGen/AsmPrinter.h"
15#include "llvm/Support/Allocator.h"
16
17#include <utility>
18
19namespace llvm {
20
21class MCSymbol;
22class MCSection;
23class StringRef;
24
25// Collection of strings for this unit and assorted symbols.
26// A String->Symbol mapping of strings used by indirect
27// references.
28class DwarfStringPool {
29 StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> Pool;
30 StringRef Prefix;
David Blaikiedaefdbf2014-04-25 21:34:35 +000031
32public:
33 DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix)
David Blaikie6741bb02014-09-11 21:12:48 +000034 : Pool(A), Prefix(Prefix) {}
David Blaikiedaefdbf2014-04-25 21:34:35 +000035
36 void emit(AsmPrinter &Asm, const MCSection *StrSection,
David Blaikie6741bb02014-09-11 21:12:48 +000037 const MCSection *OffsetSection = nullptr);
David Blaikiedaefdbf2014-04-25 21:34:35 +000038
39 /// \brief Returns an entry into the string pool with the given
40 /// string text.
41 MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str);
42
43 /// \brief Returns the index into the string pool with the given
44 /// string text.
45 unsigned getIndex(AsmPrinter &Asm, StringRef Str);
46
47 bool empty() const { return Pool.empty(); }
48};
49}
50#endif