File indexing completed on 2026-05-10 08:43:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DWARFLINKER_STRINGPOOL_H
0010 #define LLVM_DWARFLINKER_STRINGPOOL_H
0011
0012 #include "llvm/ADT/ConcurrentHashtable.h"
0013 #include "llvm/CodeGen/DwarfStringPoolEntry.h"
0014 #include "llvm/Support/Allocator.h"
0015 #include "llvm/Support/PerThreadBumpPtrAllocator.h"
0016 #include <string_view>
0017
0018 namespace llvm {
0019 namespace dwarf_linker {
0020
0021
0022
0023 using StringEntry = StringMapEntry<std::nullopt_t>;
0024
0025 class StringPoolEntryInfo {
0026 public:
0027
0028 static inline uint64_t getHashValue(const StringRef &Key) {
0029 return xxh3_64bits(Key);
0030 }
0031
0032
0033 static inline bool isEqual(const StringRef &LHS, const StringRef &RHS) {
0034 return LHS == RHS;
0035 }
0036
0037
0038 static inline StringRef getKey(const StringEntry &KeyData) {
0039 return KeyData.getKey();
0040 }
0041
0042
0043 static inline StringEntry *
0044 create(const StringRef &Key,
0045 llvm::parallel::PerThreadBumpPtrAllocator &Allocator) {
0046 return StringEntry::create(Key, Allocator);
0047 }
0048 };
0049
0050 class StringPool
0051 : public ConcurrentHashTableByPtr<StringRef, StringEntry,
0052 llvm::parallel::PerThreadBumpPtrAllocator,
0053 StringPoolEntryInfo> {
0054 public:
0055 StringPool()
0056 : ConcurrentHashTableByPtr<StringRef, StringEntry,
0057 llvm::parallel::PerThreadBumpPtrAllocator,
0058 StringPoolEntryInfo>(Allocator) {}
0059
0060 StringPool(size_t InitialSize)
0061 : ConcurrentHashTableByPtr<StringRef, StringEntry,
0062 llvm::parallel::PerThreadBumpPtrAllocator,
0063 StringPoolEntryInfo>(Allocator, InitialSize) {}
0064
0065 llvm::parallel::PerThreadBumpPtrAllocator &getAllocatorRef() {
0066 return Allocator;
0067 }
0068
0069 void clear() { Allocator.Reset(); }
0070
0071 private:
0072 llvm::parallel::PerThreadBumpPtrAllocator Allocator;
0073 };
0074
0075 }
0076 }
0077
0078 #endif