Commit 4fb9a32
Initial Ptr Offset semantics
Support for `binOpOffset`
- `binOpOffset` is applied to a `PtrLocal` but must come from a `Range`
of some kind (e.g. `[u8; 2]`, `&[u8]`) in which case the offset is
applied to a pointer to the element e.g. `*const u8`;
- Both `Reference` and `PtrLocal` has the same `Metadata` that tracks
and offset;
- In order to ensure that pointers are not out of range when the offset
is applied, `Metadata` has an `OriginSize` field for `PtrLocal` and
`Reference` for the necessary bounds checking in the external `Range`;
- After an offset is applied to a `PtrLocal` it can be turned back into
a `Reference`, which essentially is an index into the `Range` but it
does not return the element type but the `Range` type (with smaller
bounds);
- The bulk of the change is in `#traverseProjection` that now needs to
account for an offset when a `projectionDeref` occurs;
- When a non-zero offset is encountered a
`ProjectionElem::PointerOffset` is appended to the place projections,
later this will be turned into a `CtxPointerOffset` when the contexts
are being processed;
- `CtxPointerOffset` is essentially the same as a subslice as we must
have a `Range` to be offsetting through
Test cases for read and write are added
---------
Co-authored-by: Jost Berthold <jost.berthold@gmail.com>binOpOffset (#746)1 parent 206880e commit 4fb9a32
33 files changed
Lines changed: 460 additions & 209 deletions
File tree
- kmir/src
- kmir
- kdist/mir-semantics/rt
- tests/integration/data
- exec-smir
- allocs
- arrays
- intrinsic
- niche-enum
- pointers
- references
- prove-rs
- run-smir-random/simple-types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
315 | 323 | | |
316 | 324 | | |
317 | 325 | | |
| |||
359 | 367 | | |
360 | 368 | | |
361 | 369 | | |
362 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
363 | 378 | | |
364 | 379 | | |
365 | 380 | | |
| |||
372 | 387 | | |
373 | 388 | | |
374 | 389 | | |
375 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
376 | 398 | | |
377 | 399 | | |
378 | 400 | | |
| |||
397 | 419 | | |
398 | 420 | | |
399 | 421 | | |
400 | | - | |
| 422 | + | |
401 | 423 | | |
402 | 424 | | |
403 | | - | |
| 425 | + | |
404 | 426 | | |
405 | 427 | | |
406 | 428 | | |
| |||
418 | 440 | | |
419 | 441 | | |
420 | 442 | | |
421 | | - | |
| 443 | + | |
422 | 444 | | |
423 | 445 | | |
424 | 446 | | |
| |||
479 | 501 | | |
480 | 502 | | |
481 | 503 | | |
482 | | - | |
| 504 | + | |
483 | 505 | | |
484 | 506 | | |
485 | 507 | | |
| |||
0 commit comments