blob: 93a168485a54a92336f8a78598378054cee36721 [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;
Duncan P. N. Exon Smith882a2b52015-05-24 16:58:59 +000033 bool ShouldCreateSymbols;
David Blaikiedaefdbf2014-04-25 21:34:35 +000034
35public:
Duncan P. N. Exon Smith03b7a1c2015-05-24 16:33:33 +000036 typedef DwarfStringPoolEntryRef EntryRef;
37
Duncan P. N. Exon Smith882a2b52015-05-24 16:58:59 +000038 DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef 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};
Alexander Kornienkof00654e2015-06-23 09:49:53 +000048}
David Blaikiedaefdbf2014-04-25 21:34:35 +000049#endif