LLVM: include/llvm/ADT/TrieHashIndexGenerator.h Source File (original) (raw)
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9#ifndef LLVM_ADT_TRIEHASHINDEXGENERATOR_H
10#define LLVM_ADT_TRIEHASHINDEXGENERATOR_H
11
13#include
14
15namespace llvm {
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
35 std::optional<size_t> StartBit = std::nullopt;
36
37
40 size_t TotalNumBits = Bytes.size() * 8;
44 }
45
46
49
52 }
54
58 }
59
60 return end();
61 }
62
63
64
65
66
67
68 size_t hint(unsigned Index, unsigned Bit) {
72 return Index;
73 }
74
75
76
77
82
83 size_t end() const { return SIZE_MAX; }
84
85
86
88 size_t NumBits) {
90
93 size_t Index = 0;
94
95
97 size_t ByteStart = 0, ByteEnd = 8;
100 Byte &= (1u << (8 - StartBit)) - 1u;
102 }
103 size_t CurrentNumBits = ByteEnd - ByteStart;
104 if (CurrentNumBits > NumBits) {
105 Byte >>= CurrentNumBits - NumBits;
106 CurrentNumBits = NumBits;
107 }
108 Index <<= CurrentNumBits;
109 Index |= Byte & ((1u << CurrentNumBits) - 1u);
110
111 assert(NumBits >= CurrentNumBits);
112 NumBits -= CurrentNumBits;
113 if (!NumBits)
114 break;
115 }
116 return Index;
117 }
118};
119
120}
121
122#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an optimization pass for GlobalISel generic memory operations.
The utility class that helps computing the index of the object inside trie from its hash.
Definition TrieHashIndexGenerator.h:31
std::optional< size_t > StartBit
Definition TrieHashIndexGenerator.h:35
size_t NumRootBits
Definition TrieHashIndexGenerator.h:32
ArrayRef< uint8_t > Bytes
Definition TrieHashIndexGenerator.h:34
size_t getNumBits() const
Definition TrieHashIndexGenerator.h:38
size_t NumSubtrieBits
Definition TrieHashIndexGenerator.h:33
size_t getCollidingBits(ArrayRef< uint8_t > CollidingBits) const
Definition TrieHashIndexGenerator.h:78
size_t end() const
Definition TrieHashIndexGenerator.h:83
size_t next()
Definition TrieHashIndexGenerator.h:47
static size_t getIndex(ArrayRef< uint8_t > Bytes, size_t StartBit, size_t NumBits)
Definition TrieHashIndexGenerator.h:87
size_t hint(unsigned Index, unsigned Bit)
Definition TrieHashIndexGenerator.h:68