Implements v128.const and adds support for vector value type. (#556)
This commit implements the v128.const, i32x4.add and i64x2.add in interpreter mode and this adds support for the vector value types in the locals and globals. Notably, the vector type values can be passed and returned by exported functions as well as host functions via two-uint64 encodings as described in #484 (comment). Note: implementation of these instructions on JIT will be done in subsequent PR. part of #484 Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
12
api/wasm.go
12
api/wasm.go
@@ -59,6 +59,7 @@ func ExternTypeName(et ExternType) string {
|
||||
// * ValueTypeI64 - uint64(int64)
|
||||
// * ValueTypeF32 - EncodeF32 DecodeF32 from float32
|
||||
// * ValueTypeF64 - EncodeF64 DecodeF64 from float64
|
||||
// * ValueTypeV128 TODO:
|
||||
// * ValueTypeExternref - unintptr(unsafe.Pointer(p)) where p is any pointer type in Go (e.g. *string)
|
||||
//
|
||||
// Ex. Given a Text Format type use (param i64) (result i64), no conversion is necessary.
|
||||
@@ -84,6 +85,15 @@ const (
|
||||
ValueTypeF32 ValueType = 0x7d
|
||||
// ValueTypeF64 is a 64-bit floating point number.
|
||||
ValueTypeF64 ValueType = 0x7c
|
||||
// ValueTypeV128 is a 128-bit vector value.
|
||||
//
|
||||
// The type corresponds to a 128 bit vector of packed integer or floating-point data.
|
||||
// The packed data can be interpreted as signed or unsigned integers, single or double
|
||||
// precision floating-point values, or a single 128 bit type. The interpretation is
|
||||
// determined by individual operations.
|
||||
//
|
||||
// See https://www.w3.org/TR/2022/WD-wasm-core-2-20220419/syntax/types.html#syntax-vectype
|
||||
ValueTypeV128 ValueType = 0x7b
|
||||
// ValueTypeExternref is a externref type.
|
||||
//
|
||||
// Note: in wazero, externref type value are opaque raw 64-bit pointers, and the ValueTypeExternref type
|
||||
@@ -112,6 +122,8 @@ func ValueTypeName(t ValueType) string {
|
||||
return "f32"
|
||||
case ValueTypeF64:
|
||||
return "f64"
|
||||
case ValueTypeV128:
|
||||
return "v128"
|
||||
case ValueTypeExternref:
|
||||
return "externref"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user