Skip to content

Commit 4348cb1

Browse files
committed
Reference now RefStack and RefAlloc
1 parent a80d051 commit 4348cb1

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ In the simplest case, the reference refers to a local in the same stack frame (h
232232

233233
```k
234234
rule <k> #readProjection(
235-
typedValue(Reference(0, place(local(I:Int), PLACEPROJS:ProjectionElems), _), _, _),
235+
typedValue(RefStack(0, place(local(I:Int), PLACEPROJS:ProjectionElems), _), _, _),
236236
projectionElemDeref PROJS:ProjectionElems
237237
)
238238
=>
@@ -259,7 +259,7 @@ An important prerequisite of this rule is that when passing references to a call
259259

260260
```k
261261
rule <k> #readProjection(
262-
typedValue(Reference(FRAME, place(LOCAL:Local, PLACEPROJS), _), _, _),
262+
typedValue(RefStack(FRAME, place(LOCAL:Local, PLACEPROJS), _), _, _),
263263
projectionElemDeref PROJS
264264
)
265265
=>
@@ -290,8 +290,8 @@ An important prerequisite of this rule is that when passing references to a call
290290
| #decrementRef ( TypedLocal ) [function, total]
291291
| #adjustRef (TypedLocal, Int ) [function, total]
292292
293-
rule #adjustRef(typedValue(Reference(HEIGHT, PLACE, REFMUT), TY, MUT), OFFSET)
294-
=> typedValue(Reference(HEIGHT +Int OFFSET, PLACE, REFMUT), TY, MUT)
293+
rule #adjustRef(typedValue(RefStack(HEIGHT, PLACE, REFMUT), TY, MUT), OFFSET)
294+
=> typedValue(RefStack(HEIGHT +Int OFFSET, PLACE, REFMUT), TY, MUT)
295295
rule #adjustRef(TL, _) => TL [owise]
296296
297297
rule #incrementRef(TL) => #adjustRef(TL, 1)
@@ -523,7 +523,7 @@ The solution is to use rewrite operations in a downward pass through the project
523523
524524
rule <k> #projectedUpdate(
525525
_DEST,
526-
typedValue(Reference(OFFSET, place(LOCAL, PLACEPROJ), _MUT), _, _),
526+
typedValue(RefStack(OFFSET, place(LOCAL, PLACEPROJ), _MUT), _, _),
527527
projectionElemDeref PROJS,
528528
UPDATE,
529529
_CTXTS,
@@ -548,7 +548,7 @@ The solution is to use rewrite operations in a downward pass through the project
548548
549549
rule <k> #projectedUpdate(
550550
_DEST,
551-
typedValue(Reference(OFFSET, place(local(I), PLACEPROJ), _MUT), _, _),
551+
typedValue(RefStack(OFFSET, place(local(I), PLACEPROJ), _MUT), _, _),
552552
projectionElemDeref PROJS,
553553
UPDATE,
554554
_CTXTS,
@@ -799,7 +799,7 @@ The `BorrowKind` indicates mutability of the value through the reference, but al
799799
```k
800800
rule <k> rvalueRef(_REGION, KIND, PLACE)
801801
=>
802-
typedValue(Reference(0, PLACE, #mutabilityOf(KIND)), TyUnknown, #mutabilityOf(KIND))
802+
typedValue(RefStack(0, PLACE, #mutabilityOf(KIND)), TyUnknown, #mutabilityOf(KIND))
803803
...
804804
</k>
805805

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ High-level values can be
3030
// heterogenous value list for tuples and structs (standard, tuple, or anonymous)
3131
| Float( Float, Int )
3232
// value, bit-width for f16-f128
33-
| Reference( Int , Place , Mutability )
33+
| Reference
3434
// stack depth (initially 0), place, borrow kind
3535
| Range( List )
3636
// homogenous values for array/slice
3737
// | Ptr( Address, MaybeValue )
3838
// address, metadata for ref/ptr
3939
| "Any"
4040
// arbitrary value for transmute/invalid ptr lookup
41+
42+
syntax Reference ::= RefStack( Int , Place , Mutability )
43+
| RefAlloc( Int )
4144
```
4245

4346
## Local variables

0 commit comments

Comments
 (0)