Commit 3858d65
committed
Visitor: Add convenient way of using member functions
Using member functions of the payload type seems likely to be a very
common pattern, especially for converting code that uses the
llvm::InstVisitor.
This complicates the VisitorHandler setup a bit. At some point, one
has to wonder if it wouldn't be better to just use std::function. The
current system still has some performance advantages:
* It is able to handle generic projections while still handling the
common case of projections to fields cheaply, with a single, perfectly
predictable branch.
* VisitorHandler is 32 bytes; so is std::function, so wrapping
std::function would be more expensive in terms of cache pressure.
And we specifically do not want the full power of std::function. Users
of this facility should be strongly encouraged to use the pattern where
a visitor is constructed once as a static variable, so that the cost of
building hash maps is amortized.1 parent d1e1959 commit 3858d65
File tree
3 files changed
+70
-18
lines changed- example
- include/llvm-dialects/Dialect
- lib/Dialect
3 files changed
+70
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
| |||
179 | 183 | | |
180 | 184 | | |
181 | 185 | | |
182 | | - | |
183 | | - | |
184 | | - | |
| 186 | + | |
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
127 | 142 | | |
128 | 143 | | |
129 | 144 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | 145 | | |
134 | 146 | | |
135 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
136 | 151 | | |
137 | 152 | | |
138 | 153 | | |
| |||
157 | 172 | | |
158 | 173 | | |
159 | 174 | | |
160 | | - | |
| 175 | + | |
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
| |||
200 | 215 | | |
201 | 216 | | |
202 | 217 | | |
203 | | - | |
| 218 | + | |
204 | 219 | | |
205 | 220 | | |
206 | 221 | | |
| |||
316 | 331 | | |
317 | 332 | | |
318 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
319 | 339 | | |
320 | 340 | | |
321 | 341 | | |
322 | 342 | | |
323 | 343 | | |
324 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
325 | 351 | | |
326 | 352 | | |
327 | 353 | | |
| |||
354 | 380 | | |
355 | 381 | | |
356 | 382 | | |
357 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
358 | 387 | | |
359 | 388 | | |
360 | 389 | | |
361 | | - | |
362 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
363 | 402 | | |
364 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
365 | 413 | | |
366 | 414 | | |
367 | 415 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
47 | | - | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
144 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
145 | 147 | | |
146 | 148 | | |
147 | 149 | | |
| |||
220 | 222 | | |
221 | 223 | | |
222 | 224 | | |
223 | | - | |
| 225 | + | |
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
| |||
0 commit comments