diff --git a/core/iwasm/common/wasm_c_api.c b/core/iwasm/common/wasm_c_api.c index 36bd129b1..9759f33f4 100644 --- a/core/iwasm/common/wasm_c_api.c +++ b/core/iwasm/common/wasm_c_api.c @@ -754,6 +754,7 @@ val_type_rt_2_valkind(uint8 val_type_rt) WAMR_VAL_TYPE_2_WASM_VAL_KIND(I64) WAMR_VAL_TYPE_2_WASM_VAL_KIND(F32) WAMR_VAL_TYPE_2_WASM_VAL_KIND(F64) + WAMR_VAL_TYPE_2_WASM_VAL_KIND(V128) WAMR_VAL_TYPE_2_WASM_VAL_KIND(FUNCREF) #undef WAMR_VAL_TYPE_2_WASM_VAL_KIND @@ -773,7 +774,7 @@ wasm_valtype_new(wasm_valkind_t kind) { wasm_valtype_t *val_type; - if (kind > WASM_F64 && WASM_FUNCREF != kind + if (kind > WASM_V128 && WASM_FUNCREF != kind #if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 && WASM_ANYREF != kind #endif @@ -974,6 +975,7 @@ cmp_val_kind_with_val_type(wasm_valkind_t v_k, uint8 v_t) || (v_k == WASM_I64 && v_t == VALUE_TYPE_I64) || (v_k == WASM_F32 && v_t == VALUE_TYPE_F32) || (v_k == WASM_F64 && v_t == VALUE_TYPE_F64) + || (v_k == WASM_V128 && v_t == VALUE_TYPE_V128) || (v_k == WASM_ANYREF && v_t == VALUE_TYPE_EXTERNREF) || (v_k == WASM_FUNCREF && v_t == VALUE_TYPE_FUNCREF); } @@ -1646,6 +1648,9 @@ rt_val_to_wasm_val(const uint8 *data, uint8 val_type_rt, wasm_val_t *out) out->kind = WASM_F64; out->of.f64 = *((float64 *)data); break; + case VALUE_TYPE_V128: + bh_assert(0); + break; #if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 case VALUE_TYPE_EXTERNREF: out->kind = WASM_ANYREF; @@ -1687,6 +1692,9 @@ wasm_val_to_rt_val(WASMModuleInstanceCommon *inst_comm_rt, uint8 val_type_rt, bh_assert(WASM_F64 == v->kind); *((float64 *)data) = v->of.f64; break; + case VALUE_TYPE_V128: + bh_assert(0); + break; #if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 case VALUE_TYPE_EXTERNREF: bh_assert(WASM_ANYREF == v->kind); @@ -3251,6 +3259,9 @@ params_to_argv(const wasm_val_vec_t *params, *(int64 *)argv = param->of.i64; argv += 2; break; + case WASM_V128: + bh_assert(0); + break; #if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 case WASM_ANYREF: *(uintptr_t *)argv = (uintptr_t)param->of.ref; @@ -3293,6 +3304,9 @@ argv_to_results(const uint32 *argv, const wasm_valtype_vec_t *result_defs, result->of.i64 = *(int64 *)argv; argv += 2; break; + case WASM_V128: + bh_assert(0); + break; #if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 case WASM_ANYREF: result->of.ref = (struct wasm_ref_t *)(*(uintptr_t *)argv); diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index fbab98fee..c04a82a23 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1995,6 +1995,8 @@ val_type_to_val_kind(uint8 value_type) return WASM_F32; case VALUE_TYPE_F64: return WASM_F64; + case VALUE_TYPE_V128: + return WASM_V128; case VALUE_TYPE_FUNCREF: return WASM_FUNCREF; case VALUE_TYPE_EXTERNREF: @@ -2301,6 +2303,11 @@ parse_args_to_uint32_array(WASMFuncType *type, wasm_val_t *args, out_argv[p++] = u.parts[1]; break; } + case WASM_V128: + { + bh_assert(0); + break; + } #if WASM_ENABLE_REF_TYPES != 0 #if WASM_ENABLE_GC == 0 case WASM_FUNCREF: @@ -2382,6 +2389,11 @@ parse_uint32_array_to_results(WASMFuncType *type, uint32 *argv, out_results[i].of.f64 = u.val; break; } + case VALUE_TYPE_V128: + { + bh_assert(0); + break; + } #if WASM_ENABLE_REF_TYPES != 0 #if WASM_ENABLE_GC == 0 case VALUE_TYPE_FUNCREF: @@ -2558,6 +2570,9 @@ wasm_runtime_call_wasm_v(WASMExecEnv *exec_env, args[i].kind = WASM_F64; args[i].of.f64 = va_arg(vargs, float64); break; + case VALUE_TYPE_V128: + bh_assert(0); + break; #if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 case VALUE_TYPE_FUNCREF: { @@ -4019,10 +4034,11 @@ wasm_func_type_get_param_valkind(WASMFuncType *const func_type, return WASM_F32; case VALUE_TYPE_F64: return WASM_F64; + case VALUE_TYPE_V128: + return WASM_V128; case VALUE_TYPE_FUNCREF: return WASM_FUNCREF; - case VALUE_TYPE_V128: case VALUE_TYPE_EXTERNREF: case VALUE_TYPE_VOID: default: @@ -4064,6 +4080,7 @@ wasm_func_type_get_result_valkind(WASMFuncType *const func_type, #if WASM_ENABLE_SIMD != 0 case VALUE_TYPE_V128: + return WASM_V128; #endif #if WASM_ENABLE_REF_TYPES != 0 case VALUE_TYPE_EXTERNREF: diff --git a/core/iwasm/include/gc_export.h b/core/iwasm/include/gc_export.h index a9f65448e..f7426f41d 100644 --- a/core/iwasm/include/gc_export.h +++ b/core/iwasm/include/gc_export.h @@ -71,7 +71,7 @@ typedef struct WASMObject *wasm_obj_t; typedef union V128 { int8_t i8x16[16]; int16_t i16x8[8]; - int32_t i32x8[4]; + int32_t i32x4[4]; int64_t i64x2[2]; float f32x4[4]; double f64x2[2]; diff --git a/core/iwasm/include/wasm_c_api.h b/core/iwasm/include/wasm_c_api.h index 948cef6b5..52598050a 100644 --- a/core/iwasm/include/wasm_c_api.h +++ b/core/iwasm/include/wasm_c_api.h @@ -297,6 +297,7 @@ enum wasm_valkind_enum { WASM_I64, WASM_F32, WASM_F64, + WASM_V128, WASM_ANYREF = 128, WASM_FUNCREF, }; @@ -706,6 +707,9 @@ static inline own wasm_valtype_t* wasm_valtype_new_f32(void) { static inline own wasm_valtype_t* wasm_valtype_new_f64(void) { return wasm_valtype_new(WASM_F64); } +static inline own wasm_valtype_t* wasm_valtype_new_v128(void) { + return wasm_valtype_new(WASM_V128); +} static inline own wasm_valtype_t* wasm_valtype_new_anyref(void) { return wasm_valtype_new(WASM_ANYREF); diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index ca1d1a1b6..11355c9d7 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -249,6 +249,7 @@ enum wasm_valkind_enum { WASM_I64, WASM_F32, WASM_F64, + WASM_V128, WASM_ANYREF = 128, WASM_FUNCREF, }; diff --git a/core/iwasm/interpreter/wasm.h b/core/iwasm/interpreter/wasm.h index 66d73fbeb..b60649e00 100644 --- a/core/iwasm/interpreter/wasm.h +++ b/core/iwasm/interpreter/wasm.h @@ -213,10 +213,11 @@ typedef struct WASMTag WASMTag; #ifndef WASM_VALUE_DEFINED #define WASM_VALUE_DEFINED + typedef union V128 { int8 i8x16[16]; int16 i16x8[8]; - int32 i32x8[4]; + int32 i32x4[4]; int64 i64x2[2]; float32 f32x4[4]; float64 f64x2[2]; diff --git a/samples/wasm-c-api/src/reflect.c b/samples/wasm-c-api/src/reflect.c index a595fd3e0..8181b95a0 100644 --- a/samples/wasm-c-api/src/reflect.c +++ b/samples/wasm-c-api/src/reflect.c @@ -29,6 +29,7 @@ void print_valtype(const wasm_valtype_t* type) { case WASM_I64: printf("i64"); break; case WASM_F32: printf("f32"); break; case WASM_F64: printf("f64"); break; + case WASM_V128: printf("v128"); break; case WASM_ANYREF: printf("anyref"); break; case WASM_FUNCREF: printf("funcref"); break; }