blob: b042350fb5950cd7a891ac89f3233787e07780b9 [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"
Duncan P. N. Exon Smith03b7a1c2015-05-24 16:33:33 +000014#include "llvm/CodeGen/DwarfStringPoolEntry.h"
David Blaikiedaefdbf2014-04-25 21:34:35 +000015#include "llvm/Support/Allocator.h"
David Blaikiedaefdbf2014-04-25 21:34:35 +000016#include <utility>
17
18namespace llvm {
19
Duncan P. N. Exon Smith9d50e822015-05-24 16:54:59 +000020class AsmPrinter;
David Blaikiedaefdbf2014-04-25 21:34:35 +000021class 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 {
Duncan P. N. Exon Smith03b7a1c2015-05-24 16:33:33 +000029 typedef DwarfStringPoolEntry EntryTy;
Duncan P. N. Exon Smith1a65e4a2015-05-24 16:14:59 +000030 StringMap<EntryTy, BumpPtrAllocator &> Pool;
David Blaikiedaefdbf2014-04-25 21:34:35 +000031 StringRef Prefix;
Duncan P. N. Exon Smith1a65e4a2015-05-24 16:14:59 +000032 unsigned NumBytes = 0;
David Blaikiedaefdbf2014-04-25 21:34:35 +000033
34public:
Duncan P. N. Exon Smith03b7a1c2015-05-24 16:33:33 +000035 typedef DwarfStringPoolEntryRef EntryRef;
36
David Blaikiedaefdbf2014-04-25 21:34:35 +000037 DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix)
David Blaikie6741bb02014-09-11 21:12:48 +000038 : Pool(A), Prefix(Prefix) {}
David Blaikiedaefdbf2014-04-25 21:34:35 +000039
Rafael Espindola0709a7b2015-05-21 19:20:38 +000040 void emit(AsmPrinter &Asm, MCSection *StrSection,
41 MCSection *OffsetSection = nullptr);
David Blaikiedaefdbf2014-04-25 21:34:35 +000042
David Blaikiedaefdbf2014-04-25 21:34:35 +000043 bool empty() const { return Pool.empty(); }
Duncan P. N. Exon Smith8c6499f2015-05-24 16:06:08 +000044
Duncan P. N. Exon Smith03b7a1c2015-05-24 16:33:33 +000045 /// Get a reference to an entry in the string pool.
46 EntryRef getEntry(AsmPrinter &Asm, StringRef Str);
David Blaikiedaefdbf2014-04-25 21:34:35 +000047};
48}
49#endif