LLVM 17.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>
17#include <string_view>
18
19namespace llvm {
20namespace dwarflinker_parallel {
21
22/// StringEntry keeps data of the string: the length, external offset
23/// and a string body which is placed right after StringEntry.
25
27public:
28 /// \returns Hash value for the specified \p Key.
29 static inline uint64_t getHashValue(const StringRef &Key) {
30 return xxHash64(Key);
31 }
32
33 /// \returns true if both \p LHS and \p RHS are equal.
34 static inline bool isEqual(const StringRef &LHS, const StringRef &RHS) {
35 return LHS == RHS;
36 }
37
38 /// \returns key for the specified \p KeyData.
39 static inline StringRef getKey(const StringEntry &KeyData) {
40 return KeyData.getKey();
41 }
42
43 /// \returns newly created object of KeyDataTy type.
44 static inline StringEntry *
46 return StringEntry::create(Key, Allocator);
47 }
48};
49
51 : public ConcurrentHashTableByPtr<StringRef, StringEntry,
52 parallel::PerThreadBumpPtrAllocator,
53 StringPoolEntryInfo> {
54public:
57 parallel::PerThreadBumpPtrAllocator,
58 StringPoolEntryInfo>(Allocator) {}
59
60 StringPool(size_t InitialSize)
62 parallel::PerThreadBumpPtrAllocator,
63 StringPoolEntryInfo>(Allocator, InitialSize) {}
64
66
67private:
69};
70
71} // end of namespace dwarflinker_parallel
72} // end namespace llvm
73
74#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:39
static StringEntry * create(const StringRef &Key, parallel::PerThreadBumpPtrAllocator &Allocator)
Definition: StringPool.h:45
static bool isEqual(const StringRef &LHS, const StringRef &RHS)
Definition: StringPool.h:34
static uint64_t getHashValue(const StringRef &Key)
Definition: StringPool.h:29
parallel::PerThreadBumpPtrAllocator & getAllocatorRef()
Definition: StringPool.h:65
PerThreadAllocator< BumpPtrAllocator > PerThreadBumpPtrAllocator
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
uint64_t xxHash64(llvm::StringRef Data)
Definition: xxhash.cpp:70