blob: 1cac3b7c8432a1edfdea61ad7a15a4feb81d21c7 [file] [log] [blame]
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +00001//===- llvm/CodeGen/DwarfStringPool.h - Dwarf Debug Framework ---*- C++ -*-===//
David Blaikiedaefdbf2014-04-25 21:34:35 +00002//
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"
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000014#include "llvm/ADT/StringRef.h"
Duncan P. N. Exon Smith03b7a1c2015-05-24 16:33:33 +000015#include "llvm/CodeGen/DwarfStringPoolEntry.h"
David Blaikiedaefdbf2014-04-25 21:34:35 +000016#include "llvm/Support/Allocator.h"
David Blaikiedaefdbf2014-04-25 21:34:35 +000017
18namespace llvm {
19
Duncan P. N. Exon Smith9d50e822015-05-24 16:54:59 +000020class AsmPrinter;
David Blaikiedaefdbf2014-04-25 21:34:35 +000021class MCSection;
David Blaikiedaefdbf2014-04-25 21:34:35 +000022
23// Collection of strings for this unit and assorted symbols.
24// A String->Symbol mapping of strings used by indirect
25// references.
26class DwarfStringPool {
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000027 using EntryTy = DwarfStringPoolEntry;
28
Duncan P. N. Exon Smith1a65e4a2015-05-24 16:14:59 +000029 StringMap<EntryTy, BumpPtrAllocator &> Pool;
David Blaikiedaefdbf2014-04-25 21:34:35 +000030 StringRef Prefix;
Duncan P. N. Exon Smith1a65e4a2015-05-24 16:14:59 +000031 unsigned NumBytes = 0;
Duncan P. N. Exon Smith882a2b52015-05-24 16:58:59 +000032 bool ShouldCreateSymbols;
David Blaikiedaefdbf2014-04-25 21:34:35 +000033
34public:
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000035 using EntryRef = DwarfStringPoolEntryRef;
Duncan P. N. Exon Smith03b7a1c2015-05-24 16:33:33 +000036
Duncan P. N. Exon Smith882a2b52015-05-24 16:58:59 +000037 DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix);
David Blaikiedaefdbf2014-04-25 21:34:35 +000038
Rafael Espindola0709a7b2015-05-21 19:20:38 +000039 void emit(AsmPrinter &Asm, MCSection *StrSection,
40 MCSection *OffsetSection = nullptr);
David Blaikiedaefdbf2014-04-25 21:34:35 +000041
David Blaikiedaefdbf2014-04-25 21:34:35 +000042 bool empty() const { return Pool.empty(); }
Duncan P. N. Exon Smith8c6499f2015-05-24 16:06:08 +000043
Duncan P. N. Exon Smith03b7a1c2015-05-24 16:33:33 +000044 /// Get a reference to an entry in the string pool.
45 EntryRef getEntry(AsmPrinter &Asm, StringRef Str);
David Blaikiedaefdbf2014-04-25 21:34:35 +000046};
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000047
48} // end namespace llvm
49
50#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H