Skip to content

Commit 0bc45b2

Browse files
committed
Added NullaryOp AlignOf evaluation
1 parent 3093afc commit 0bc45b2

File tree

1 file changed

+34
-0
lines changed
  • kmir/src/kmir/kdist/mir-semantics/rt

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,40 @@ One important use case of `UbChecks` is to determine overflows in unchecked arit
13571357
`nullOpAlignOf`
13581358
`nullOpOffsetOf(VariantAndFieldIndices)`
13591359

1360+
```k
1361+
1362+
// FIXME: Alignment is platform specific
1363+
syntax Int ::= #alignOf( TypeInfo ) [function]
1364+
1365+
rule #alignOf( typeInfoPrimitiveType(primTypeBool) ) => 1
1366+
rule #alignOf( typeInfoPrimitiveType(primTypeChar) ) => 4
1367+
1368+
rule #alignOf( typeInfoPrimitiveType(primTypeInt(intTyIsize)) ) => 8 // FIXME: Hard coded since usize not implemented
1369+
rule #alignOf( typeInfoPrimitiveType(primTypeInt(intTyI8)) ) => 1
1370+
rule #alignOf( typeInfoPrimitiveType(primTypeInt(intTyI16)) ) => 2
1371+
rule #alignOf( typeInfoPrimitiveType(primTypeInt(intTyI32)) ) => 4
1372+
rule #alignOf( typeInfoPrimitiveType(primTypeInt(intTyI64)) ) => 8
1373+
rule #alignOf( typeInfoPrimitiveType(primTypeInt(intTyI128)) ) => 16
1374+
1375+
rule #alignOf( typeInfoPrimitiveType(primTypeUint(uintTyUsize)) ) => 8 // FIXME: Hard coded since usize not implemented
1376+
rule #alignOf( typeInfoPrimitiveType(primTypeUint(uintTyU8)) ) => 1
1377+
rule #alignOf( typeInfoPrimitiveType(primTypeUint(uintTyU16)) ) => 2
1378+
rule #alignOf( typeInfoPrimitiveType(primTypeUint(uintTyU32)) ) => 4
1379+
rule #alignOf( typeInfoPrimitiveType(primTypeUint(uintTyU64)) ) => 8
1380+
rule #alignOf( typeInfoPrimitiveType(primTypeUint(uintTyU128)) ) => 16
1381+
1382+
rule #alignOf( typeInfoPrimitiveType(primTypeFloat(floatTyF16)) ) => 2
1383+
rule #alignOf( typeInfoPrimitiveType(primTypeFloat(floatTyF32)) ) => 4
1384+
rule #alignOf( typeInfoPrimitiveType(primTypeFloat(floatTyF64)) ) => 8
1385+
rule #alignOf( typeInfoPrimitiveType(primTypeFloat(floatTyF128)) ) => 16
1386+
1387+
rule <k> rvalueNullaryOp(nullOpAlignOf, TY) => typedValue( Integer(#alignOf({TYPEMAP[TY]}:>TypeInfo), 64, false), TyUnknown, mutabilityNot ) ... </k> // FIXME: 64 is hardcoded since usize not supported
1388+
<types> TYPEMAP </types>
1389+
requires TY in_keys(TYPEMAP)
1390+
andBool isTypeInfo(TYPEMAP[TY])
1391+
1392+
```
1393+
13601394
#### Other operations
13611395

13621396
`binOpOffset`

0 commit comments

Comments
 (0)