-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathTagging.v3
39 lines (36 loc) · 1.17 KB
/
Tagging.v3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2022 Ben L. Titzer. All rights reserved.
// See LICENSE for details of Apache 2.0 license.
// Configures the representation of values on a (native) value stack.
class Tagging(tagged: bool, simd: bool) {
def raw: int = if(simd, 16, 8); // XXX: make unsigned
def tag_size: int = if(tagged, raw, 0); // XXX: make unsigned
def slot_size: int = if(tagged, u31.!(raw * 2), raw); // XXX: make unsigned
def slot_size_log: u6 = if(tagged, if(simd, 5, 4), if(simd, 4, 3));
def value_size: int = slot_size - tag_size;
def maybeRefTag(tag: byte) -> bool {
match (i7.view(tag)) {
BpTypeCode.I32.val,
BpTypeCode.I64.val,
BpTypeCode.F32.val,
BpTypeCode.F64.val,
BpTypeCode.V128.val,
BpTypeCode.I8.val,
BpTypeCode.I16.val => return false;
BpTypeCode.NOCONT.val,
BpTypeCode.CONTREF.val,
BpTypeCode.FUNCREF.val,
BpTypeCode.EXTERNREF.val,
BpTypeCode.ANYREF.val,
BpTypeCode.EQREF.val,
BpTypeCode.REF_NULL.val,
BpTypeCode.REF.val,
BpTypeCode.I31REF.val,
BpTypeCode.STRUCTREF.val,
BpTypeCode.ARRAYREF.val,
BpTypeCode.NULLREF.val,
BpTypeCode.NULLEXTERNREF.val,
BpTypeCode.NULLFUNCREF.val => return true;
}
return false;
}
}