LLVM 18.0.0git
StringPool.h
Go to the documentation of this file.
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_DWARFLINKERPARALLEL_STRINGPOOL_H
10#define LLVM_DWARFLINKERPARALLEL_STRINGPOOL_H
11
16#include <string_view>
17
18namespace llvm {
19namespace dwarflinker_parallel {
20
21/// StringEntry keeps data of the string: the length, external offset
22/// and a string body which is placed right after StringEntry.
24
26public:
27 /// \returns Hash value for the specified \p Key.
28 static inline uint64_t getHashValue(const StringRef &Key) {
29 return xxh3_64bits(Key);
30 }
31
32 /// \returns true if both \p LHS and \p RHS are equal.
33 static inline bool isEqual(const StringRef &LHS, const StringRef &RHS) {
34 return LHS == RHS;
35 }
36
37 /// \returns key for the specified \p KeyData.
38 static inline StringRef getKey(const StringEntry &KeyData) {
39 return KeyData.getKey();
40 }
41
42 /// \returns newly created object of KeyDataTy type.
43 static inline StringEntry *
45 return StringEntry::create(Key, Allocator);
46 }
47};
48
50 : public ConcurrentHashTableByPtr<StringRef, StringEntry,
51 parallel::PerThreadBumpPtrAllocator,
52 StringPoolEntryInfo> {
53public:
56 parallel::PerThreadBumpPtrAllocator,
57 StringPoolEntryInfo>(Allocator) {}
58
59 StringPool(size_t InitialSize)
61 parallel::PerThreadBumpPtrAllocator,
62 StringPoolEntryInfo>(Allocator, InitialSize) {}
63
65
66 void clear() { Allocator.Reset(); }
67
68private:
70};
71
72} // end of namespace dwarflinker_parallel
73} // end namespace llvm
74
75#endif // LLVM_DWARFLINKERPARALLEL_STRINGPOOL_H
This file defines the BumpPtrAllocator interface.
Basic Register Allocator
Value * RHS
Value * LHS
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
static StringMapEntry * create(StringRef key, AllocatorTy &allocator, InitTy &&...initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
StringRef getKey() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
static StringRef getKey(const StringEntry &KeyData)
Definition: StringPool.h:38
static StringEntry * create(const StringRef &Key, parallel::PerThreadBumpPtrAllocator &Allocator)
Definition: StringPool.h:44
static bool isEqual(const StringRef &LHS, const StringRef &RHS)
Definition: StringPool.h:33
static uint64_t getHashValue(const StringRef &Key)
Definition: StringPool.h:28
parallel::PerThreadBumpPtrAllocator & getAllocatorRef()
Definition: StringPool.h:64
PerThreadAllocator< BumpPtrAllocator > PerThreadBumpPtrAllocator
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
uint64_t xxh3_64bits(ArrayRef< uint8_t > data)
Definition: xxhash.cpp:397