Skip to content

Commit 635c58b

Browse files
committed
fix(rt): align transparent pointer casts
1 parent 6d61698 commit 635c58b

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

kmir/src/kmir/kdist/mir-semantics/rt/data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ the `Value` sort.
12651265
Conversion is especially possible for the case of _Slices_ (of dynamic length) and _Arrays_ (of static length),
12661266
which have the same representation `Value::Range`.
12671267

1268-
When the cast crosses transparent wrappers (newtypes that just forward field `0` e.g. `struct Wrapper<T>(T)`), the pointer's
1268+
When the cast crosses transparent wrappers (for example newtypes that just forward field `0`), the pointer's
12691269
`Place` must be realigned. `#alignTransparentPlace` rewrites the projection list until the source and target
12701270
expose the same inner value:
12711271
- if the source unwraps more than the target, append an explicit `field(0)` so the target still sees that field;

kmir/src/kmir/kdist/mir-semantics/rt/types.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,14 @@ Pointers to structs with a single zero-offset field are compatible with pointers
7777
syntax Bool ::= #zeroFieldOffset ( MaybeLayoutShape ) [function, total]
7878
7979
rule #zeroFieldOffset(LAYOUT)
80-
=> #layoutOffsets(LAYOUT) ==K .MachineSizes
81-
orBool #layoutOffsets(LAYOUT) ==K machineSize(mirInt(0)) .MachineSizes
82-
orBool #layoutOffsets(LAYOUT) ==K machineSize(0) .MachineSizes
83-
84-
// Extract field offsets from the struct layout when available (Arbitrary only).
85-
syntax MachineSizes ::= #layoutOffsets ( MaybeLayoutShape ) [function, total]
86-
rule #layoutOffsets(someLayoutShape(layoutShape(fieldsShapeArbitrary(mk(OFFSETS)), _, _, _, _))) => OFFSETS
87-
rule #layoutOffsets(noLayoutShape) => .MachineSizes
88-
rule #layoutOffsets(_) => .MachineSizes [owise]
80+
=> #structOffsets(LAYOUT) ==K .MachineSizes
81+
orBool #structOffsets(LAYOUT) ==K machineSize(mirInt(0)) .MachineSizes
82+
orBool #structOffsets(LAYOUT) ==K machineSize(0) .MachineSizes
83+
84+
syntax MachineSizes ::= #structOffsets ( MaybeLayoutShape ) [function, total]
85+
86+
rule #structOffsets(someLayoutShape(layoutShape(fieldsShapeArbitrary(mk(OFFSETS)), _, _, _, _))) => OFFSETS
87+
rule #structOffsets(_) => .MachineSizes [owise]
8988
```
9089

9190
## Determining types of places with projection

0 commit comments

Comments
 (0)