1 | #ifdef GET_ASITagsList_DECL |
2 | const ASITag *lookupASITagByEncoding(uint8_t Encoding); |
3 | const ASITag *lookupASITagByAltName(StringRef AltName); |
4 | const ASITag *lookupASITagByName(StringRef Name); |
5 | #endif |
6 | |
7 | #ifdef GET_ASITagsList_IMPL |
8 | constexpr ASITag ASITagsList[] = { |
9 | { "ASI_N" , "ASI_NUCLEUS" , 0x4 }, // 0 |
10 | { "ASI_N_L" , "ASI_NUCLEUS_LITTLE" , 0xC }, // 1 |
11 | { "ASI_AIUP" , "ASI_AS_IF_USER_PRIMARY" , 0x10 }, // 2 |
12 | { "ASI_AIUS" , "ASI_AS_IF_USER_SECONDARY" , 0x11 }, // 3 |
13 | { "ASI_AIUP_L" , "ASI_AS_IF_USER_PRIMARY_LITTLE" , 0x18 }, // 4 |
14 | { "ASI_AIUS_L" , "ASI_AS_IF_USER_SECONDARY_LITTLE" , 0x19 }, // 5 |
15 | { "ASI_P" , "ASI_PRIMARY" , 0x80 }, // 6 |
16 | { "ASI_S" , "ASI_SECONDARY" , 0x81 }, // 7 |
17 | { "ASI_PNF" , "ASI_PRIMARY_NOFAULT" , 0x82 }, // 8 |
18 | { "ASI_SNF" , "ASI_SECONDARY_NOFAULT" , 0x83 }, // 9 |
19 | { "ASI_P_L" , "ASI_PRIMARY_LITTLE" , 0x88 }, // 10 |
20 | { "ASI_S_L" , "ASI_SECONDARY_LITTLE" , 0x89 }, // 11 |
21 | { "ASI_PNF_L" , "ASI_PRIMARY_NOFAULT_LITTLE" , 0x8A }, // 12 |
22 | { "ASI_SNF_L" , "ASI_SECONDARY_NOFAULT_LITTLE" , 0x8B }, // 13 |
23 | }; |
24 | |
25 | const ASITag *lookupASITagByEncoding(uint8_t Encoding) { |
26 | struct KeyType { |
27 | uint8_t Encoding; |
28 | }; |
29 | KeyType Key = {Encoding}; |
30 | struct Comp { |
31 | bool operator()(const ASITag &LHS, const KeyType &RHS) const { |
32 | if (LHS.Encoding < RHS.Encoding) |
33 | return true; |
34 | if (LHS.Encoding > RHS.Encoding) |
35 | return false; |
36 | return false; |
37 | } |
38 | }; |
39 | auto Table = ArrayRef(ASITagsList); |
40 | auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp()); |
41 | if (Idx == Table.end() || |
42 | Key.Encoding != Idx->Encoding) |
43 | return nullptr; |
44 | |
45 | return &*Idx; |
46 | } |
47 | |
48 | const ASITag *lookupASITagByAltName(StringRef AltName) { |
49 | struct IndexType { |
50 | const char * AltName; |
51 | unsigned _index; |
52 | }; |
53 | static const struct IndexType Index[] = { |
54 | { "ASI_AS_IF_USER_PRIMARY" , 2 }, |
55 | { "ASI_AS_IF_USER_PRIMARY_LITTLE" , 4 }, |
56 | { "ASI_AS_IF_USER_SECONDARY" , 3 }, |
57 | { "ASI_AS_IF_USER_SECONDARY_LITTLE" , 5 }, |
58 | { "ASI_NUCLEUS" , 0 }, |
59 | { "ASI_NUCLEUS_LITTLE" , 1 }, |
60 | { "ASI_PRIMARY" , 6 }, |
61 | { "ASI_PRIMARY_LITTLE" , 10 }, |
62 | { "ASI_PRIMARY_NOFAULT" , 8 }, |
63 | { "ASI_PRIMARY_NOFAULT_LITTLE" , 12 }, |
64 | { "ASI_SECONDARY" , 7 }, |
65 | { "ASI_SECONDARY_LITTLE" , 11 }, |
66 | { "ASI_SECONDARY_NOFAULT" , 9 }, |
67 | { "ASI_SECONDARY_NOFAULT_LITTLE" , 13 }, |
68 | }; |
69 | |
70 | struct KeyType { |
71 | std::string AltName; |
72 | }; |
73 | KeyType Key = {AltName.upper()}; |
74 | struct Comp { |
75 | bool operator()(const IndexType &LHS, const KeyType &RHS) const { |
76 | int CmpAltName = StringRef(LHS.AltName).compare(RHS.AltName); |
77 | if (CmpAltName < 0) return true; |
78 | if (CmpAltName > 0) return false; |
79 | return false; |
80 | } |
81 | }; |
82 | auto Table = ArrayRef(Index); |
83 | auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp()); |
84 | if (Idx == Table.end() || |
85 | Key.AltName != Idx->AltName) |
86 | return nullptr; |
87 | |
88 | return &ASITagsList[Idx->_index]; |
89 | } |
90 | |
91 | const ASITag *lookupASITagByName(StringRef Name) { |
92 | struct IndexType { |
93 | const char * Name; |
94 | unsigned _index; |
95 | }; |
96 | static const struct IndexType Index[] = { |
97 | { "ASI_AIUP" , 2 }, |
98 | { "ASI_AIUP_L" , 4 }, |
99 | { "ASI_AIUS" , 3 }, |
100 | { "ASI_AIUS_L" , 5 }, |
101 | { "ASI_N" , 0 }, |
102 | { "ASI_N_L" , 1 }, |
103 | { "ASI_P" , 6 }, |
104 | { "ASI_PNF" , 8 }, |
105 | { "ASI_PNF_L" , 12 }, |
106 | { "ASI_P_L" , 10 }, |
107 | { "ASI_S" , 7 }, |
108 | { "ASI_SNF" , 9 }, |
109 | { "ASI_SNF_L" , 13 }, |
110 | { "ASI_S_L" , 11 }, |
111 | }; |
112 | |
113 | struct KeyType { |
114 | std::string Name; |
115 | }; |
116 | KeyType Key = {Name.upper()}; |
117 | struct Comp { |
118 | bool operator()(const IndexType &LHS, const KeyType &RHS) const { |
119 | int CmpName = StringRef(LHS.Name).compare(RHS.Name); |
120 | if (CmpName < 0) return true; |
121 | if (CmpName > 0) return false; |
122 | return false; |
123 | } |
124 | }; |
125 | auto Table = ArrayRef(Index); |
126 | auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp()); |
127 | if (Idx == Table.end() || |
128 | Key.Name != Idx->Name) |
129 | return nullptr; |
130 | |
131 | return &ASITagsList[Idx->_index]; |
132 | } |
133 | #endif |
134 | |
135 | #ifdef GET_PrefetchTagsList_DECL |
136 | const PrefetchTag *lookupPrefetchTagByEncoding(uint8_t Encoding); |
137 | const PrefetchTag *lookupPrefetchTagByName(StringRef Name); |
138 | #endif |
139 | |
140 | #ifdef GET_PrefetchTagsList_IMPL |
141 | constexpr PrefetchTag PrefetchTagsList[] = { |
142 | { "n_reads" , 0x0 }, // 0 |
143 | { "one_read" , 0x1 }, // 1 |
144 | { "n_writes" , 0x2 }, // 2 |
145 | { "one_write" , 0x3 }, // 3 |
146 | { "page" , 0x4 }, // 4 |
147 | { "unified" , 0x11 }, // 5 |
148 | { "n_reads_strong" , 0x14 }, // 6 |
149 | { "one_read_strong" , 0x15 }, // 7 |
150 | { "n_writes_strong" , 0x16 }, // 8 |
151 | { "one_write_strong" , 0x17 }, // 9 |
152 | }; |
153 | |
154 | const PrefetchTag *lookupPrefetchTagByEncoding(uint8_t Encoding) { |
155 | struct KeyType { |
156 | uint8_t Encoding; |
157 | }; |
158 | KeyType Key = {Encoding}; |
159 | struct Comp { |
160 | bool operator()(const PrefetchTag &LHS, const KeyType &RHS) const { |
161 | if (LHS.Encoding < RHS.Encoding) |
162 | return true; |
163 | if (LHS.Encoding > RHS.Encoding) |
164 | return false; |
165 | return false; |
166 | } |
167 | }; |
168 | auto Table = ArrayRef(PrefetchTagsList); |
169 | auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp()); |
170 | if (Idx == Table.end() || |
171 | Key.Encoding != Idx->Encoding) |
172 | return nullptr; |
173 | |
174 | return &*Idx; |
175 | } |
176 | |
177 | const PrefetchTag *lookupPrefetchTagByName(StringRef Name) { |
178 | struct IndexType { |
179 | const char * Name; |
180 | unsigned _index; |
181 | }; |
182 | static const struct IndexType Index[] = { |
183 | { "N_READS" , 0 }, |
184 | { "N_READS_STRONG" , 6 }, |
185 | { "N_WRITES" , 2 }, |
186 | { "N_WRITES_STRONG" , 8 }, |
187 | { "ONE_READ" , 1 }, |
188 | { "ONE_READ_STRONG" , 7 }, |
189 | { "ONE_WRITE" , 3 }, |
190 | { "ONE_WRITE_STRONG" , 9 }, |
191 | { "PAGE" , 4 }, |
192 | { "UNIFIED" , 5 }, |
193 | }; |
194 | |
195 | struct KeyType { |
196 | std::string Name; |
197 | }; |
198 | KeyType Key = {Name.upper()}; |
199 | struct Comp { |
200 | bool operator()(const IndexType &LHS, const KeyType &RHS) const { |
201 | int CmpName = StringRef(LHS.Name).compare(RHS.Name); |
202 | if (CmpName < 0) return true; |
203 | if (CmpName > 0) return false; |
204 | return false; |
205 | } |
206 | }; |
207 | auto Table = ArrayRef(Index); |
208 | auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp()); |
209 | if (Idx == Table.end() || |
210 | Key.Name != Idx->Name) |
211 | return nullptr; |
212 | |
213 | return &PrefetchTagsList[Idx->_index]; |
214 | } |
215 | #endif |
216 | |
217 | #undef GET_ASITagsList_DECL |
218 | #undef GET_ASITagsList_IMPL |
219 | #undef GET_PrefetchTagsList_DECL |
220 | #undef GET_PrefetchTagsList_IMPL |
221 | |