Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions kmir/src/kmir/kdist/mir-semantics/rt/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,20 @@ The situation typically arises when the stored value is a pointer (`NonNull`) bu
)
=> #traverseProjection(DEST, Aggregate(variantIdx(0), ListItem(VALUE)), PROJS, CtxWrapStruct CTXTS) ... </k>
[preserves-definedness, priority(100)]

rule <k> #traverseProjection(
DEST,
Aggregate(variantIdx(0), ListItem(Range(ELEMS))),
projectionElemConstantIndex(I, MIN_LENGTH, FROM_END) PROJS,
CTXTS
)
=> #traverseProjection(
DEST,
Range(ELEMS),
projectionElemConstantIndex(I, MIN_LENGTH, FROM_END) PROJS,
CTXTS
) ... </k>
[preserves-definedness, priority(100)]
```

A somewhat dual case to this rule can occur when a pointer into an array of data elements has been offset and is then dereferenced.
Expand Down
25 changes: 18 additions & 7 deletions kmir/src/kmir/kdist/mir-semantics/rt/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,11 @@ the source should be wrapped rather than unwrapped (e.g., `*const [u8;2] → *co
)
requires #zeroFieldOffset(LAYOUT)

rule #pointeeProjection(SRC:TypeInfo, typeInfoStructType(_NAME, _ADTDEF, FIELD .Tys, LAYOUT))
=> maybeConcatProj(
projectionElemWrapStruct,
#pointeeProjection(SRC, lookupTy(FIELD))
)
rule #pointeeProjection(SRC:TypeInfo, TGT)
=> #pointeeProjectionTarget(SRC, TGT)
requires #isArrayType(SRC)
andBool #zeroFieldOffset(LAYOUT)
andBool lookupTy(FIELD) ==K SRC
andBool #wholeArrayTargetCompatible(SRC, TGT)
andBool SRC =/=K TGT
[priority(42)]

rule #pointeeProjection(typeInfoArrayType(TY1, _), TY2)
Expand Down Expand Up @@ -189,6 +186,20 @@ the source-first strategy.
rule #layoutOffsets(someLayoutShape(layoutShape(fieldsShapeArbitrary(mk(OFFSETS)), _, _, _, _))) => OFFSETS
rule #layoutOffsets(noLayoutShape) => .MachineSizes
rule #layoutOffsets(_) => .MachineSizes [owise]

syntax Bool ::= #wholeArrayTargetCompatible ( TypeInfo , TypeInfo ) [function, total]
// ----------------------------------------------------------------------------
rule #wholeArrayTargetCompatible(SRC, SRC) => true

rule #wholeArrayTargetCompatible(SRC, typeInfoStructType(_, _, FIELD .Tys, LAYOUT))
=> #wholeArrayTargetCompatible(SRC, lookupTy(FIELD))
requires #zeroFieldOffset(LAYOUT)

rule #wholeArrayTargetCompatible(SRC, typeInfoArrayType(ELEM_TY, someTyConst(tyConst(KIND, _))))
=> #wholeArrayTargetCompatible(SRC, lookupTy(ELEM_TY))
requires readTyConstInt(KIND) ==Int 1

rule #wholeArrayTargetCompatible(_, _) => false [owise]
```

--------------------------------------------------
Expand Down
Loading