1//===- StringPool.h ---------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DWARFLINKER_STRINGPOOL_H
10#define LLVM_DWARFLINKER_STRINGPOOL_H
11
12#include "llvm/ADT/ConcurrentHashtable.h"
13#include "llvm/CodeGen/DwarfStringPoolEntry.h"
14#include "llvm/Support/Allocator.h"
15#include "llvm/Support/PerThreadBumpPtrAllocator.h"
16#include <string_view>
17
18namespace llvm {
19namespace dwarf_linker {
20
21/// StringEntry keeps data of the string: the length, external offset
22/// and a string body which is placed right after StringEntry.
23using StringEntry = StringMapEntry<EmptyStringSetTag>;
24
25class StringPool
26 : public ConcurrentHashTableByPtr<
27 StringRef, StringEntry, llvm::parallel::PerThreadBumpPtrAllocator> {
28public:
29 StringPool()
30 : ConcurrentHashTableByPtr<StringRef, StringEntry,
31 llvm::parallel::PerThreadBumpPtrAllocator>(
32 Allocator) {}
33
34 StringPool(size_t InitialSize)
35 : ConcurrentHashTableByPtr<StringRef, StringEntry,
36 llvm::parallel::PerThreadBumpPtrAllocator>(
37 Allocator, InitialSize) {}
38
39 llvm::parallel::PerThreadBumpPtrAllocator &getAllocatorRef() {
40 return Allocator;
41 }
42
43 void clear() { Allocator.Reset(); }
44
45private:
46 llvm::parallel::PerThreadBumpPtrAllocator Allocator;
47};
48
49} // namespace dwarf_linker
50} // end namespace llvm
51
52#endif // LLVM_DWARFLINKER_STRINGPOOL_H
53