From 13720e9dd20653910422ac0eed36a94f130d64a7 Mon Sep 17 00:00:00 2001 From: Oscar Spencer Date: Fri, 9 May 2025 19:56:50 -0500 Subject: [PATCH 1/2] feat: Implement SIMD operations --- src/dune | 1 + src/expression.c | 98 ++++++++++++ src/expression.js | 105 +++++++++++++ src/expression.ml | 48 ++++++ src/expression.mli | 28 ++++ src/helpers.js | 10 ++ src/literal.c | 11 ++ src/literal.js | 7 + src/literal.ml | 8 + src/literal.mli | 1 + src/op.c | 372 +++++++++++++++++++++++++++++++++++++++++++++ src/op.js | 318 ++++++++++++++++++++++++++++++++++++++ src/op.ml | 263 ++++++++++++++++++++++++++++++++ src/op.mli | 53 +++++++ test/test.expected | 104 +++++++++++++ test/test.ml | 56 ++++++- 16 files changed, 1482 insertions(+), 1 deletion(-) create mode 100644 src/helpers.js diff --git a/src/dune b/src/dune index a5bcd431..e456450d 100644 --- a/src/dune +++ b/src/dune @@ -27,6 +27,7 @@ (flags :standard -O2 -Wall -Wextra)) (js_of_ocaml (javascript_files + helpers.js array_type.js type.js op.js diff --git a/src/expression.c b/src/expression.c index d6926d39..79dc0729 100644 --- a/src/expression.c +++ b/src/expression.c @@ -351,6 +351,104 @@ caml_binaryen_unreachable(value _module) { CAMLreturn(alloc_BinaryenExpressionRef(exp)); } +CAMLprim value +caml_binaryen_simd_extract(value _module, value _op, value _vec, value _index) { + CAMLparam4(_module, _op, _vec, _index); + BinaryenModuleRef module = BinaryenModuleRef_val(_module); + BinaryenOp op = BinaryenOp_val(_op); + BinaryenExpressionRef vec = BinaryenExpressionRef_val(_vec); + int index = Int_val(_index); + BinaryenExpressionRef exp = BinaryenSIMDExtract(module, op, vec, index); + CAMLreturn(alloc_BinaryenExpressionRef(exp)); +} + +CAMLprim value +caml_binaryen_simd_replace(value _module, value _op, value _vec, value _index, value _val) { + CAMLparam5(_module, _op, _vec, _index, _val); + BinaryenModuleRef module = BinaryenModuleRef_val(_module); + BinaryenOp op = BinaryenOp_val(_op); + BinaryenExpressionRef vec = BinaryenExpressionRef_val(_vec); + int index = Int_val(_index); + BinaryenExpressionRef val = BinaryenExpressionRef_val(_val); + BinaryenExpressionRef exp = BinaryenSIMDReplace(module, op, vec, index, val); + CAMLreturn(alloc_BinaryenExpressionRef(exp)); +} + +CAMLprim value +caml_binaryen_simd_shuffle(value _module, value _left, value _right, value _mask) { + CAMLparam4(_module, _left, _right, _mask); + BinaryenModuleRef module = BinaryenModuleRef_val(_module); + BinaryenExpressionRef left = BinaryenExpressionRef_val(_left); + BinaryenExpressionRef right = BinaryenExpressionRef_val(_right); + uint8_t mask[16]; + for (int i = 0; i < 16; i++) { + mask[i] = Int_val(Field(_mask, i)); + } + BinaryenExpressionRef exp = BinaryenSIMDShuffle(module, left, right, mask); + CAMLreturn(alloc_BinaryenExpressionRef(exp)); +} + +CAMLprim value +caml_binaryen_simd_ternary(value _module, value _op, value _a, value _b, value _c) { + CAMLparam5(_module, _op, _a, _b, _c); + BinaryenModuleRef module = BinaryenModuleRef_val(_module); + BinaryenOp op = BinaryenOp_val(_op); + BinaryenExpressionRef a = BinaryenExpressionRef_val(_a); + BinaryenExpressionRef b = BinaryenExpressionRef_val(_b); + BinaryenExpressionRef c = BinaryenExpressionRef_val(_c); + BinaryenExpressionRef exp = BinaryenSIMDTernary(module, op, a, b, c); + CAMLreturn(alloc_BinaryenExpressionRef(exp)); +} + +CAMLprim value +caml_binaryen_simd_shift(value _module, value _op, value _vec, value _shift) { + CAMLparam4(_module, _op, _vec, _shift); + BinaryenModuleRef module = BinaryenModuleRef_val(_module); + BinaryenOp op = BinaryenOp_val(_op); + BinaryenExpressionRef vec = BinaryenExpressionRef_val(_vec); + BinaryenExpressionRef shift = BinaryenExpressionRef_val(_shift); + BinaryenExpressionRef exp = BinaryenSIMDShift(module, op, vec, shift); + CAMLreturn(alloc_BinaryenExpressionRef(exp)); +} + +CAMLprim value +caml_binaryen_simd_load(value _module, value _op, value _offset, value _align, value _ptr, value _memoryName) { + CAMLparam5(_module, _op, _offset, _align, _ptr); + CAMLxparam1(_memoryName); + BinaryenModuleRef module = BinaryenModuleRef_val(_module); + BinaryenOp op = BinaryenOp_val(_op); + int offset = Int_val(_offset); + int align = Int_val(_align); + BinaryenExpressionRef ptr = BinaryenExpressionRef_val(_ptr); + char* memoryName = Safe_String_val(_memoryName); + BinaryenExpressionRef exp = BinaryenSIMDLoad(module, op, offset, align, ptr, memoryName); + CAMLreturn(alloc_BinaryenExpressionRef(exp)); +} +CAMLprim value +caml_binaryen_simd_load__bytecode(value * argv) { + return caml_binaryen_simd_load(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); +} + +CAMLprim value +caml_binaryen_simd_load_store_lane(value _module, value _op, value _offset, value _align, value _index, value _ptr, value _vec, value _memoryName) { + CAMLparam5(_module, _op, _offset, _align, _index); + CAMLxparam3(_ptr, _vec, _memoryName); + BinaryenModuleRef module = BinaryenModuleRef_val(_module); + BinaryenOp op = BinaryenOp_val(_op); + int offset = Int_val(_offset); + int align = Int_val(_align); + int index = Int_val(_index); + BinaryenExpressionRef ptr = BinaryenExpressionRef_val(_ptr); + BinaryenExpressionRef vec = BinaryenExpressionRef_val(_vec); + char* memoryName = Safe_String_val(_memoryName); + BinaryenExpressionRef exp = BinaryenSIMDLoadStoreLane(module, op, offset, align, index, ptr, vec, memoryName); + CAMLreturn(alloc_BinaryenExpressionRef(exp)); +} +CAMLprim value +caml_binaryen_simd_load_store_lane__bytecode(value * argv) { + return caml_binaryen_simd_load_store_lane(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]); +} + CAMLprim value caml_binaryen_memory_init(value _module, value _segment, value _dest, value _offset, value _size, value _memoryName) { CAMLparam5(_module, _segment, _dest, _offset, _size); diff --git a/src/expression.js b/src/expression.js index fa8c8332..13966cae 100644 --- a/src/expression.js +++ b/src/expression.js @@ -387,6 +387,10 @@ function caml_binaryen_const(wasm_mod, lit) { ); } + if (lit.type === "vec128") { + return wasm_mod.v128.const(lit.value); + } + caml_failwith("invalid Literal for Binaryen.Const.make"); } @@ -446,6 +450,107 @@ function caml_binaryen_unreachable(wasm_mod) { return wasm_mod.unreachable(); } +//Provides: caml_binaryen_simd_extract +//Requires: Binaryen +function caml_binaryen_simd_extract(wasm_mod, op, vec, index) { + return Binaryen._BinaryenSIMDExtract(wasm_mod, op, vec, index); +} + +//Provides: caml_binaryen_simd_replace +//Requires: Binaryen +function caml_binaryen_simd_replace(wasm_mod, op, vec, index, value) { + return Binaryen._BinaryenSIMDReplace(wasm_mod, op, vec, index, value); +} + +//Provides: caml_binaryen_simd_shuffle +//Requires: caml_js_from_array +function caml_binaryen_simd_shuffle(wasm_mod, left, right, mask) { + return wasm_mod.i8x16.shuffle(left, right, caml_js_from_array(mask)); +} + +//Provides: caml_binaryen_simd_ternary +//Requires: Binaryen +function caml_binaryen_simd_ternary(wasm_mod, op, a, b, c) { + return Binaryen._BinaryenSIMDTernary(wasm_mod, op, a, b, c); +} + +//Provides: caml_binaryen_simd_shift +//Requires: Binaryen +function caml_binaryen_simd_shift(wasm_mod, op, vec, shift) { + return Binaryen._BinaryenSIMDShift(wasm_mod, op, vec, shift); +} + +//Provides: caml_binaryen_simd_load +//Requires: Binaryen +//Requires: caml_jsstring_of_string, caml_alloc_string_on_heap +function caml_binaryen_simd_load(wasm_mod, op, offset, align, ptr, memoryName) { + var memory = caml_alloc_string_on_heap(caml_jsstring_of_string(memoryName)); + var exp = Binaryen._BinaryenSIMDLoad( + wasm_mod, + op, + offset, + align, + ptr, + memory + ); + Binaryen._free(memory); + return exp; +} +//Provides: caml_binaryen_simd_load__bytecode +//Requires: caml_binaryen_simd_load +function caml_binaryen_simd_load__bytecode() { + return caml_binaryen_simd_load( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); +} + +//Provides: caml_binaryen_simd_load_store_lane +//Requires: Binaryen +//Requires: caml_jsstring_of_string, caml_alloc_string_on_heap +function caml_binaryen_simd_load_store_lane( + wasm_mod, + op, + offset, + align, + index, + ptr, + vec, + memoryName +) { + var memory = caml_alloc_string_on_heap(caml_jsstring_of_string(memoryName)); + var exp = Binaryen._BinaryenSIMDLoadStoreLane( + wasm_mod, + op, + offset, + align, + index, + ptr, + vec, + memory + ); + Binaryen._free(memory); + return exp; +} +//Provides: caml_binaryen_simd_load_store_lane__bytecode +//Requires: caml_binaryen_simd_load_store_lane +function caml_binaryen_simd_load_store_lane__bytecode() { + return caml_binaryen_simd_load_store_lane( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6], + arguments[7] + ); +} + //Provides: caml_binaryen_memory_init //Requires: caml_jsstring_of_string function caml_binaryen_memory_init( diff --git a/src/expression.ml b/src/expression.ml index d8bcb3a6..2e823a03 100644 --- a/src/expression.ml +++ b/src/expression.ml @@ -819,6 +819,54 @@ module Pop = struct (** Module, type *) end +module SIMD_extract = struct + external make : Module.t -> Op.t -> t -> int -> t + = "caml_binaryen_simd_extract" + (** Module, op, vec, index *) +end + +module SIMD_replace = struct + external make : Module.t -> Op.t -> t -> int -> t -> t + = "caml_binaryen_simd_replace" + (** Module, op, vec, index, value *) +end + +module SIMD_shuffle = struct + external make : Module.t -> t -> t -> int array -> t + = "caml_binaryen_simd_shuffle" + + (** Module, left, right, mask *) + let make wasm_mod left right mask = + if Array.length mask <> 16 then + raise + (Invalid_argument + "Binaryen.SIMD_shuffle.make: mask must be of length 16"); + make wasm_mod left right mask +end + +module SIMD_ternary = struct + external make : Module.t -> Op.t -> t -> t -> t -> t + = "caml_binaryen_simd_ternary" + (** Module, op, first, second, third *) +end + +module SIMD_shift = struct + external make : Module.t -> Op.t -> t -> t -> t = "caml_binaryen_simd_shift" + (** Module, op, left, right *) +end + +module SIMD_load = struct + external make : Module.t -> Op.t -> int -> int -> t -> string -> t + = "caml_binaryen_simd_load__bytecode" "caml_binaryen_simd_load" + (** Module, op, offset, align, ptr, memory *) +end + +module SIMD_load_store_lane = struct + external make : Module.t -> Op.t -> int -> int -> int -> t -> t -> string -> t + = "caml_binaryen_simd_load_store_lane__bytecode" "caml_binaryen_simd_load_store_lane" + (** Module, op, offset, align, index, ptr, vec, memory *) +end + module I31 = struct external make : Module.t -> t -> t = "caml_binaryen_ref_i31" (** Module, value *) diff --git a/src/expression.mli b/src/expression.mli index c22e1810..6c510445 100644 --- a/src/expression.mli +++ b/src/expression.mli @@ -321,6 +321,34 @@ module Pop : sig val make : Module.t -> Type.t -> t end +module SIMD_extract : sig + val make : Module.t -> Op.t -> t -> int -> t +end + +module SIMD_replace : sig + val make : Module.t -> Op.t -> t -> int -> t -> t +end + +module SIMD_shuffle : sig + val make : Module.t -> t -> t -> int array -> t +end + +module SIMD_ternary : sig + val make : Module.t -> Op.t -> t -> t -> t -> t +end + +module SIMD_shift : sig + val make : Module.t -> Op.t -> t -> t -> t +end + +module SIMD_load : sig + val make : Module.t -> Op.t -> int -> int -> t -> string -> t +end + +module SIMD_load_store_lane : sig + val make : Module.t -> Op.t -> int -> int -> int -> t -> t -> string -> t +end + module I31 : sig val make : Module.t -> t -> t (** Module, value *) diff --git a/src/helpers.js b/src/helpers.js new file mode 100644 index 00000000..f9cb923e --- /dev/null +++ b/src/helpers.js @@ -0,0 +1,10 @@ +//Requires: Binaryen +//Provides: caml_alloc_string_on_heap +function caml_alloc_string_on_heap(str) { + var len = str.length; + var ptr = Binaryen._malloc(len + 1); + var encoder = new TextEncoder(); + encoder.encodeInto(str, Binaryen.HEAPU8.subarray(ptr, ptr + len)); + Binaryen.HEAPU8[ptr + len] = 0; + return ptr; +} diff --git a/src/literal.c b/src/literal.c index 2d3a9e8b..450ac9b6 100644 --- a/src/literal.c +++ b/src/literal.c @@ -45,3 +45,14 @@ caml_binaryen_literal_float64_bits(value _i64) { struct BinaryenLiteral lit = BinaryenLiteralFloat64Bits(i64); CAMLreturn(alloc_BinaryenLiteral(lit)); } + +CAMLprim value +caml_binaryen_literal_vec128(value _v128) { + CAMLparam1(_v128); + uint8_t v128[16]; + for (int i = 0; i < 16; i++) { + v128[i] = Int_val(Field(_v128, i)); + } + struct BinaryenLiteral lit = BinaryenLiteralVec128(v128); + CAMLreturn(alloc_BinaryenLiteral(lit)); +} diff --git a/src/literal.js b/src/literal.js index fe11e970..c9552f9a 100644 --- a/src/literal.js +++ b/src/literal.js @@ -27,3 +27,10 @@ function caml_binaryen_literal_float64_bits(i64) { // Hack around Binaryen.js return { type: 'float64_bits', value: i64 }; } + +//Provides: caml_binaryen_literal_vec128 +//Requires: caml_js_from_array +function caml_binaryen_literal_vec128(v128) { + // Hack around Binaryen.js + return { type: "vec128", value: caml_js_from_array(v128) }; +} diff --git a/src/literal.ml b/src/literal.ml index 477d6d65..bf0b9ebc 100644 --- a/src/literal.ml +++ b/src/literal.ml @@ -8,3 +8,11 @@ external float64_bits : int64 -> t = "caml_binaryen_literal_float64_bits" let float32 n = float32_bits @@ Int32.bits_of_float n external float64 : float -> t = "caml_binaryen_literal_float64" +external vec128 : int array -> t = "caml_binaryen_literal_vec128" + +let vec128 (low, high) = + let bytes = Bytes.create 16 in + Bytes.set_int64_le bytes 0 low; + Bytes.set_int64_le bytes 8 high; + let arr = Array.init 16 (Bytes.get_uint8 bytes) in + vec128 arr diff --git a/src/literal.mli b/src/literal.mli index 9efe03a9..67ef6c32 100644 --- a/src/literal.mli +++ b/src/literal.mli @@ -6,3 +6,4 @@ val float32_bits : int32 -> t val float64_bits : int64 -> t val float32 : float -> t val float64 : float -> t +val vec128 : int64 * int64 -> t diff --git a/src/op.c b/src/op.c index 1b22510f..07f20251 100644 --- a/src/op.c +++ b/src/op.c @@ -2176,6 +2176,34 @@ caml_binaryen_nearest_vec_f64x2(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_ext_add_pairwise_s_vec_i8x16_to_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtAddPairwiseSVecI8x16ToI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_add_pairwise_u_vec_i8x16_to_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtAddPairwiseUVecI8x16ToI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_add_pairwise_s_vec_i16x8_to_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtAddPairwiseSVecI16x8ToI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_add_pairwise_u_vec_i16x8_to_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtAddPairwiseUVecI16x8ToI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + CAMLprim value caml_binaryen_trunc_sat_s_vec_f32x4_to_vec_i32x4(value unit) { CAMLparam1(unit); @@ -2204,6 +2232,146 @@ caml_binaryen_convert_u_vec_i32x4_to_vec_f32x4(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_load8_splat_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad8SplatVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load16_splat_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad16SplatVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load32_splat_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad32SplatVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load64_splat_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad64SplatVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load8x8_s_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad8x8SVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load8x8_u_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad8x8UVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load16x4_s_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad16x4SVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load16x4_u_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad16x4UVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load32x2_s_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad32x2SVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load32x2_u_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad32x2UVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load32_zero_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad32ZeroVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load64_zero_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad64ZeroVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load8_lane_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad8LaneVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load16_lane_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad16LaneVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load32_lane_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad32LaneVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_load64_lane_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLoad64LaneVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_store8_lane_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenStore8LaneVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_store16_lane_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenStore16LaneVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_store32_lane_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenStore32LaneVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_store64_lane_vec128(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenStore64LaneVec128(); + CAMLreturn(alloc_BinaryenOp(op)); +} + CAMLprim value caml_binaryen_narrow_s_vec_i16x8_to_vec_i8x16(value unit) { CAMLparam1(unit); @@ -2232,6 +2400,161 @@ caml_binaryen_narrow_u_vec_i32x4_to_vec_i16x8(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_extend_low_s_vec_i8x16_to_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendLowSVecI8x16ToVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_high_s_vec_i8x16_to_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendHighSVecI8x16ToVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_low_u_vec_i8x16_to_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendLowUVecI8x16ToVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_high_u_vec_i8x16_to_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendHighUVecI8x16ToVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_low_s_vec_i16x8_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendLowSVecI16x8ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_high_s_vec_i16x8_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendHighSVecI16x8ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_low_u_vec_i16x8_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendLowUVecI16x8ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_high_u_vec_i16x8_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendHighUVecI16x8ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_low_s_vec_i32x4_to_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendLowSVecI32x4ToVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_high_s_vec_i32x4_to_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendHighSVecI32x4ToVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_low_u_vec_i32x4_to_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendLowUVecI32x4ToVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_extend_high_u_vec_i32x4_to_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtendHighUVecI32x4ToVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_convert_low_s_vec_i32x4_to_vec_f64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenConvertLowSVecI32x4ToVecF64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_convert_low_u_vec_i32x4_to_vec_f64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenConvertLowUVecI32x4ToVecF64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_trunc_sat_zero_s_vec_f64x2_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenTruncSatZeroSVecF64x2ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_trunc_sat_zero_u_vec_f64x2_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenTruncSatZeroUVecF64x2ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_demote_zero_vec_f64x2_to_vec_f32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenDemoteZeroVecF64x2ToVecF32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_promote_low_vec_f32x4_to_vec_f64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenPromoteLowVecF32x4ToVecF64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_trunc_s_vec_f32x4_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedTruncSVecF32x4ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_trunc_u_vec_f32x4_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedTruncUVecF32x4ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_trunc_zero_s_vec_f64x2_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedTruncZeroSVecF64x2ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_trunc_zero_u_vec_f64x2_to_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedTruncZeroUVecF64x2ToVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + + CAMLprim value caml_binaryen_swizzle_vec8x16(value unit) { CAMLparam1(unit); @@ -2239,6 +2562,55 @@ caml_binaryen_swizzle_vec8x16(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_relaxed_swizzle_vec_i8x16(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedSwizzleVecI8x16(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_min_vec_f32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedMinVecF32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_max_vec_f32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedMaxVecF32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_min_vec_f64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedMinVecF64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_max_vec_f64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedMaxVecF64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_relaxed_q15_mulr_s_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenRelaxedQ15MulrSVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_dot_i8x16_i7x16_s_to_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenDotI8x16I7x16SToVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + CAMLprim value caml_binaryen_ref_as_non_null(value unit) { CAMLparam1(unit); diff --git a/src/op.js b/src/op.js index 1a0f0dce..edbba99c 100644 --- a/src/op.js +++ b/src/op.js @@ -1858,6 +1858,30 @@ function caml_binaryen_nearest_vec_f64x2() { return Binaryen.Operations.NearestVecF64x2; } +//Provides: caml_binaryen_ext_add_pairwise_s_vec_i8x16_to_i16x8 +//Requires: Binaryen +function caml_binaryen_ext_add_pairwise_s_vec_i8x16_to_i16x8() { + return Binaryen.Operations.ExtAddPairwiseSVecI8x16ToI16x8; +} + +//Provides: caml_binaryen_ext_add_pairwise_u_vec_i8x16_to_i16x8 +//Requires: Binaryen +function caml_binaryen_ext_add_pairwise_u_vec_i8x16_to_i16x8() { + return Binaryen.Operations.ExtAddPairwiseUVecI8x16ToI16x8; +} + +//Provides: caml_binaryen_ext_add_pairwise_s_vec_i16x8_to_i32x4 +//Requires: Binaryen +function caml_binaryen_ext_add_pairwise_s_vec_i16x8_to_i32x4() { + return Binaryen.Operations.ExtAddPairwiseSVecI16x8ToI32x4; +} + +//Provides: caml_binaryen_ext_add_pairwise_u_vec_i16x8_to_i32x4 +//Requires: Binaryen +function caml_binaryen_ext_add_pairwise_u_vec_i16x8_to_i32x4() { + return Binaryen.Operations.ExtAddPairwiseUVecI16x8ToI32x4; +} + //Provides: caml_binaryen_trunc_sat_s_vec_f32x4_to_vec_i32x4 //Requires: Binaryen function caml_binaryen_trunc_sat_s_vec_f32x4_to_vec_i32x4() { @@ -1882,6 +1906,126 @@ function caml_binaryen_convert_u_vec_i32x4_to_vec_f32x4() { return Binaryen.Operations.ConvertUVecI32x4ToVecF32x4; } +//Provides: caml_binaryen_load8_splat_vec128 +//Requires: Binaryen +function caml_binaryen_load8_splat_vec128() { + return Binaryen.Operations.Load8SplatVec128; +} + +//Provides: caml_binaryen_load16_splat_vec128 +//Requires: Binaryen +function caml_binaryen_load16_splat_vec128() { + return Binaryen.Operations.Load16SplatVec128; +} + +//Provides: caml_binaryen_load32_splat_vec128 +//Requires: Binaryen +function caml_binaryen_load32_splat_vec128() { + return Binaryen.Operations.Load32SplatVec128; +} + +//Provides: caml_binaryen_load64_splat_vec128 +//Requires: Binaryen +function caml_binaryen_load64_splat_vec128() { + return Binaryen.Operations.Load64SplatVec128; +} + +//Provides: caml_binaryen_load8x8_s_vec128 +//Requires: Binaryen +function caml_binaryen_load8x8_s_vec128() { + return Binaryen.Operations.Load8x8SVec128; +} + +//Provides: caml_binaryen_load8x8_u_vec128 +//Requires: Binaryen +function caml_binaryen_load8x8_u_vec128() { + return Binaryen.Operations.Load8x8UVec128; +} + +//Provides: caml_binaryen_load16x4_s_vec128 +//Requires: Binaryen +function caml_binaryen_load16x4_s_vec128() { + return Binaryen.Operations.Load16x4SVec128; +} + +//Provides: caml_binaryen_load16x4_u_vec128 +//Requires: Binaryen +function caml_binaryen_load16x4_u_vec128() { + return Binaryen.Operations.Load16x4UVec128; +} + +//Provides: caml_binaryen_load32x2_s_vec128 +//Requires: Binaryen +function caml_binaryen_load32x2_s_vec128() { + return Binaryen.Operations.Load32x2SVec128; +} + +//Provides: caml_binaryen_load32x2_u_vec128 +//Requires: Binaryen +function caml_binaryen_load32x2_u_vec128() { + return Binaryen.Operations.Load32x2UVec128; +} + +//Provides: caml_binaryen_load32_zero_vec128 +//Requires: Binaryen +function caml_binaryen_load32_zero_vec128() { + return Binaryen.Operations.Load32ZeroVec128; +} + +//Provides: caml_binaryen_load64_zero_vec128 +//Requires: Binaryen +function caml_binaryen_load64_zero_vec128() { + return Binaryen.Operations.Load64ZeroVec128; +} + +//Provides: caml_binaryen_load8_lane_vec128 +//Requires: Binaryen +function caml_binaryen_load8_lane_vec128() { + return Binaryen.Operations.Load8LaneVec128; +} + +//Provides: caml_binaryen_load16_lane_vec128 +//Requires: Binaryen +function caml_binaryen_load16_lane_vec128() { + return Binaryen.Operations.Load16LaneVec128; +} + +//Provides: caml_binaryen_load32_lane_vec128 +//Requires: Binaryen +function caml_binaryen_load32_lane_vec128() { + return Binaryen.Operations.Load32LaneVec128; +} + +//Provides: caml_binaryen_load64_lane_vec128 +//Requires: Binaryen +function caml_binaryen_load64_lane_vec128() { + return Binaryen.Operations.Load64LaneVec128; +} + +//Provides: caml_binaryen_store8_lane_vec128 +//Requires: Binaryen +function caml_binaryen_store8_lane_vec128() { + return Binaryen.Operations.Store8LaneVec128; +} + +//Provides: caml_binaryen_store16_lane_vec128 +//Requires: Binaryen +function caml_binaryen_store16_lane_vec128() { + return Binaryen.Operations.Store16LaneVec128; +} + +//Provides: caml_binaryen_store32_lane_vec128 +//Requires: Binaryen +function caml_binaryen_store32_lane_vec128() { + return Binaryen.Operations.Store32LaneVec128; +} + +//Provides: caml_binaryen_store64_lane_vec128 +//Requires: Binaryen +function caml_binaryen_store64_lane_vec128() { + return Binaryen.Operations.Store64LaneVec128; +} + //Provides: caml_binaryen_narrow_s_vec_i16x8_to_vec_i8x16 //Requires: Binaryen function caml_binaryen_narrow_s_vec_i16x8_to_vec_i8x16() { @@ -1906,12 +2050,186 @@ function caml_binaryen_narrow_u_vec_i32x4_to_vec_i16x8() { return Binaryen.Operations.NarrowUVecI32x4ToVecI16x8; } +//Provides: caml_binaryen_extend_low_s_vec_i8x16_to_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_extend_low_s_vec_i8x16_to_vec_i16x8() { + return Binaryen.Operations.ExtendLowSVecI8x16ToVecI16x8; +} + +//Provides: caml_binaryen_extend_high_s_vec_i8x16_to_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_extend_high_s_vec_i8x16_to_vec_i16x8() { + return Binaryen.Operations.ExtendHighSVecI8x16ToVecI16x8; +} + +//Provides: caml_binaryen_extend_low_u_vec_i8x16_to_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_extend_low_u_vec_i8x16_to_vec_i16x8() { + return Binaryen.Operations.ExtendLowUVecI8x16ToVecI16x8; +} + +//Provides: caml_binaryen_extend_high_u_vec_i8x16_to_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_extend_high_u_vec_i8x16_to_vec_i16x8() { + return Binaryen.Operations.ExtendHighUVecI8x16ToVecI16x8; +} + +//Provides: caml_binaryen_extend_low_s_vec_i16x8_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_extend_low_s_vec_i16x8_to_vec_i32x4() { + return Binaryen.Operations.ExtendLowSVecI16x8ToVecI32x4; +} + +//Provides: caml_binaryen_extend_high_s_vec_i16x8_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_extend_high_s_vec_i16x8_to_vec_i32x4() { + return Binaryen.Operations.ExtendHighSVecI16x8ToVecI32x4; +} + +//Provides: caml_binaryen_extend_low_u_vec_i16x8_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_extend_low_u_vec_i16x8_to_vec_i32x4() { + return Binaryen.Operations.ExtendLowUVecI16x8ToVecI32x4; +} + +//Provides: caml_binaryen_extend_high_u_vec_i16x8_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_extend_high_u_vec_i16x8_to_vec_i32x4() { + return Binaryen.Operations.ExtendHighUVecI16x8ToVecI32x4; +} + +//Provides: caml_binaryen_extend_low_s_vec_i32x4_to_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_extend_low_s_vec_i32x4_to_vec_i64x2() { + return Binaryen.Operations.ExtendLowSVecI32x4ToVecI64x2; +} + +//Provides: caml_binaryen_extend_high_s_vec_i32x4_to_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_extend_high_s_vec_i32x4_to_vec_i64x2() { + return Binaryen.Operations.ExtendHighSVecI32x4ToVecI64x2; +} + +//Provides: caml_binaryen_extend_low_u_vec_i32x4_to_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_extend_low_u_vec_i32x4_to_vec_i64x2() { + return Binaryen.Operations.ExtendLowUVecI32x4ToVecI64x2; +} + +//Provides: caml_binaryen_extend_high_u_vec_i32x4_to_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_extend_high_u_vec_i32x4_to_vec_i64x2() { + return Binaryen.Operations.ExtendHighUVecI32x4ToVecI64x2; +} + +//Provides: caml_binaryen_convert_low_s_vec_i32x4_to_vec_f64x2 +//Requires: Binaryen +function caml_binaryen_convert_low_s_vec_i32x4_to_vec_f64x2() { + return Binaryen.Operations.ConvertLowSVecI32x4ToVecF64x2; +} + +//Provides: caml_binaryen_convert_low_u_vec_i32x4_to_vec_f64x2 +//Requires: Binaryen +function caml_binaryen_convert_low_u_vec_i32x4_to_vec_f64x2() { + return Binaryen.Operations.ConvertLowUVecI32x4ToVecF64x2; +} + +//Provides: caml_binaryen_trunc_sat_zero_s_vec_f64x2_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_trunc_sat_zero_s_vec_f64x2_to_vec_i32x4() { + return Binaryen.Operations.TruncSatZeroSVecF64x2ToVecI32x4; +} + +//Provides: caml_binaryen_trunc_sat_zero_u_vec_f64x2_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_trunc_sat_zero_u_vec_f64x2_to_vec_i32x4() { + return Binaryen.Operations.TruncSatZeroUVecF64x2ToVecI32x4; +} + +//Provides: caml_binaryen_demote_zero_vec_f64x2_to_vec_f32x4 +//Requires: Binaryen +function caml_binaryen_demote_zero_vec_f64x2_to_vec_f32x4() { + return Binaryen.Operations.DemoteZeroVecF64x2ToVecF32x4; +} + +//Provides: caml_binaryen_promote_low_vec_f32x4_to_vec_f64x2 +//Requires: Binaryen +function caml_binaryen_promote_low_vec_f32x4_to_vec_f64x2() { + return Binaryen.Operations.PromoteLowVecF32x4ToVecF64x2; +} + +//Provides: caml_binaryen_relaxed_trunc_s_vec_f32x4_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_relaxed_trunc_s_vec_f32x4_to_vec_i32x4() { + return Binaryen.Operations.RelaxedTruncSVecF32x4ToVecI32x4; +} + +//Provides: caml_binaryen_relaxed_trunc_u_vec_f32x4_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_relaxed_trunc_u_vec_f32x4_to_vec_i32x4() { + return Binaryen.Operations.RelaxedTruncUVecF32x4ToVecI32x4; +} + +//Provides: caml_binaryen_relaxed_trunc_zero_s_vec_f64x2_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_relaxed_trunc_zero_s_vec_f64x2_to_vec_i32x4() { + return Binaryen.Operations.RelaxedTruncZeroSVecF64x2ToVecI32x4; +} + +//Provides: caml_binaryen_relaxed_trunc_zero_u_vec_f64x2_to_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_relaxed_trunc_zero_u_vec_f64x2_to_vec_i32x4() { + return Binaryen.Operations.RelaxedTruncZeroUVecF64x2ToVecI32x4; +} + //Provides: caml_binaryen_swizzle_vec8x16 //Requires: Binaryen function caml_binaryen_swizzle_vec8x16() { return Binaryen.Operations.SwizzleVecI8x16; } +//Provides: caml_binaryen_relaxed_swizzle_vec_i8x16 +//Requires: Binaryen +function caml_binaryen_relaxed_swizzle_vec_i8x16() { + return Binaryen.Operations.RelaxedSwizzleVecI8x16; +} + +//Provides: caml_binaryen_relaxed_min_vec_f32x4 +//Requires: Binaryen +function caml_binaryen_relaxed_min_vec_f32x4() { + return Binaryen.Operations.RelaxedMinVecF32x4; +} + +//Provides: caml_binaryen_relaxed_max_vec_f32x4 +//Requires: Binaryen +function caml_binaryen_relaxed_max_vec_f32x4() { + return Binaryen.Operations.RelaxedMaxVecF32x4; +} + +//Provides: caml_binaryen_relaxed_min_vec_f64x2 +//Requires: Binaryen +function caml_binaryen_relaxed_min_vec_f64x2() { + return Binaryen.Operations.RelaxedMinVecF64x2; +} + +//Provides: caml_binaryen_relaxed_max_vec_f64x2 +//Requires: Binaryen +function caml_binaryen_relaxed_max_vec_f64x2() { + return Binaryen.Operations.RelaxedMaxVecF64x2; +} + +//Provides: caml_binaryen_relaxed_q15_mulr_s_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_relaxed_q15_mulr_s_vec_i16x8() { + return Binaryen.Operations.RelaxedQ15MulrSVecI16x8; +} + +//Provides: caml_binaryen_dot_i8x16_i7x16_s_to_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_dot_i8x16_i7x16_s_to_vec_i16x8() { + return Binaryen.Operations.DotI8x16I7x16SToVecI16x8; +} + //Provides: caml_binaryen_ref_as_non_null //Requires: Binaryen function caml_binaryen_ref_as_non_null() { diff --git a/src/op.ml b/src/op.ml index b181265a..3ebf29ef 100644 --- a/src/op.ml +++ b/src/op.ml @@ -1284,6 +1284,30 @@ external nearest_vec_f64x2 : unit -> t = "caml_binaryen_nearest_vec_f64x2" let nearest_vec_f64x2 = nearest_vec_f64x2 () +external ext_add_pairwise_s_vec_i8x16_to_i16x8 : unit -> t + = "caml_binaryen_ext_add_pairwise_s_vec_i8x16_to_i16x8" + +let ext_add_pairwise_s_vec_i8x16_to_i16x8 = + ext_add_pairwise_s_vec_i8x16_to_i16x8 () + +external ext_add_pairwise_u_vec_i8x16_to_i16x8 : unit -> t + = "caml_binaryen_ext_add_pairwise_u_vec_i8x16_to_i16x8" + +let ext_add_pairwise_u_vec_i8x16_to_i16x8 = + ext_add_pairwise_u_vec_i8x16_to_i16x8 () + +external ext_add_pairwise_s_vec_i16x8_to_i32x4 : unit -> t + = "caml_binaryen_ext_add_pairwise_s_vec_i16x8_to_i32x4" + +let ext_add_pairwise_s_vec_i16x8_to_i32x4 = + ext_add_pairwise_s_vec_i16x8_to_i32x4 () + +external ext_add_pairwise_u_vec_i16x8_to_i32x4 : unit -> t + = "caml_binaryen_ext_add_pairwise_u_vec_i16x8_to_i32x4" + +let ext_add_pairwise_u_vec_i16x8_to_i32x4 = + ext_add_pairwise_u_vec_i16x8_to_i32x4 () + external trunc_sat_s_vec_f32x4_to_vec_i32x4 : unit -> t = "caml_binaryen_trunc_sat_s_vec_f32x4_to_vec_i32x4" @@ -1304,6 +1328,86 @@ external convert_u_vec_i32x4_to_vec_f32x4 : unit -> t let convert_u_vec_i32x4_to_vec_f32x4 = convert_u_vec_i32x4_to_vec_f32x4 () +external load8_splat_vec128 : unit -> t = "caml_binaryen_load8_splat_vec128" + +let load8_splat_vec128 = load8_splat_vec128 () + +external load16_splat_vec128 : unit -> t = "caml_binaryen_load16_splat_vec128" + +let load16_splat_vec128 = load16_splat_vec128 () + +external load32_splat_vec128 : unit -> t = "caml_binaryen_load32_splat_vec128" + +let load32_splat_vec128 = load32_splat_vec128 () + +external load64_splat_vec128 : unit -> t = "caml_binaryen_load64_splat_vec128" + +let load64_splat_vec128 = load64_splat_vec128 () + +external load8x8_s_vec128 : unit -> t = "caml_binaryen_load8x8_s_vec128" + +let load8x8_s_vec128 = load8x8_s_vec128 () + +external load8x8_u_vec128 : unit -> t = "caml_binaryen_load8x8_u_vec128" + +let load8x8_u_vec128 = load8x8_u_vec128 () + +external load16x4_s_vec128 : unit -> t = "caml_binaryen_load16x4_s_vec128" + +let load16x4_s_vec128 = load16x4_s_vec128 () + +external load16x4_u_vec128 : unit -> t = "caml_binaryen_load16x4_u_vec128" + +let load16x4_u_vec128 = load16x4_u_vec128 () + +external load32x2_s_vec128 : unit -> t = "caml_binaryen_load32x2_s_vec128" + +let load32x2_s_vec128 = load32x2_s_vec128 () + +external load32x2_u_vec128 : unit -> t = "caml_binaryen_load32x2_u_vec128" + +let load32x2_u_vec128 = load32x2_u_vec128 () + +external load32_zero_vec128 : unit -> t = "caml_binaryen_load32_zero_vec128" + +let load32_zero_vec128 = load32_zero_vec128 () + +external load64_zero_vec128 : unit -> t = "caml_binaryen_load64_zero_vec128" + +let load64_zero_vec128 = load64_zero_vec128 () + +external load8_lane_vec128 : unit -> t = "caml_binaryen_load8_lane_vec128" + +let load8_lane_vec128 = load8_lane_vec128 () + +external load16_lane_vec128 : unit -> t = "caml_binaryen_load16_lane_vec128" + +let load16_lane_vec128 = load16_lane_vec128 () + +external load32_lane_vec128 : unit -> t = "caml_binaryen_load32_lane_vec128" + +let load32_lane_vec128 = load32_lane_vec128 () + +external load64_lane_vec128 : unit -> t = "caml_binaryen_load64_lane_vec128" + +let load64_lane_vec128 = load64_lane_vec128 () + +external store8_lane_vec128 : unit -> t = "caml_binaryen_store8_lane_vec128" + +let store8_lane_vec128 = store8_lane_vec128 () + +external store16_lane_vec128 : unit -> t = "caml_binaryen_store16_lane_vec128" + +let store16_lane_vec128 = store16_lane_vec128 () + +external store32_lane_vec128 : unit -> t = "caml_binaryen_store32_lane_vec128" + +let store32_lane_vec128 = store32_lane_vec128 () + +external store64_lane_vec128 : unit -> t = "caml_binaryen_store64_lane_vec128" + +let store64_lane_vec128 = store64_lane_vec128 () + external narrow_s_vec_i16x8_to_vec_i8x16 : unit -> t = "caml_binaryen_narrow_s_vec_i16x8_to_vec_i8x16" @@ -1324,10 +1428,169 @@ external narrow_u_vec_i32x4_to_vec_i16x8 : unit -> t let narrow_u_vec_i32x4_to_vec_i16x8 = narrow_u_vec_i32x4_to_vec_i16x8 () +external extend_low_s_vec_i8x16_to_vec_i16x8 : unit -> t + = "caml_binaryen_extend_low_s_vec_i8x16_to_vec_i16x8" + +let extend_low_s_vec_i8x16_to_vec_i16x8 = extend_low_s_vec_i8x16_to_vec_i16x8 () + +external extend_high_s_vec_i8x16_to_vec_i16x8 : unit -> t + = "caml_binaryen_extend_high_s_vec_i8x16_to_vec_i16x8" + +let extend_high_s_vec_i8x16_to_vec_i16x8 = + extend_high_s_vec_i8x16_to_vec_i16x8 () + +external extend_low_u_vec_i8x16_to_vec_i16x8 : unit -> t + = "caml_binaryen_extend_low_u_vec_i8x16_to_vec_i16x8" + +let extend_low_u_vec_i8x16_to_vec_i16x8 = extend_low_u_vec_i8x16_to_vec_i16x8 () + +external extend_high_u_vec_i8x16_to_vec_i16x8 : unit -> t + = "caml_binaryen_extend_high_u_vec_i8x16_to_vec_i16x8" + +let extend_high_u_vec_i8x16_to_vec_i16x8 = + extend_high_u_vec_i8x16_to_vec_i16x8 () + +external extend_low_s_vec_i16x8_to_vec_i32x4 : unit -> t + = "caml_binaryen_extend_low_s_vec_i16x8_to_vec_i32x4" + +let extend_low_s_vec_i16x8_to_vec_i32x4 = extend_low_s_vec_i16x8_to_vec_i32x4 () + +external extend_high_s_vec_i16x8_to_vec_i32x4 : unit -> t + = "caml_binaryen_extend_high_s_vec_i16x8_to_vec_i32x4" + +let extend_high_s_vec_i16x8_to_vec_i32x4 = + extend_high_s_vec_i16x8_to_vec_i32x4 () + +external extend_low_u_vec_i16x8_to_vec_i32x4 : unit -> t + = "caml_binaryen_extend_low_u_vec_i16x8_to_vec_i32x4" + +let extend_low_u_vec_i16x8_to_vec_i32x4 = extend_low_u_vec_i16x8_to_vec_i32x4 () + +external extend_high_u_vec_i16x8_to_vec_i32x4 : unit -> t + = "caml_binaryen_extend_high_u_vec_i16x8_to_vec_i32x4" + +let extend_high_u_vec_i16x8_to_vec_i32x4 = + extend_high_u_vec_i16x8_to_vec_i32x4 () + +external extend_low_s_vec_i32x4_to_vec_i64x2 : unit -> t + = "caml_binaryen_extend_low_s_vec_i32x4_to_vec_i64x2" + +let extend_low_s_vec_i32x4_to_vec_i64x2 = extend_low_s_vec_i32x4_to_vec_i64x2 () + +external extend_high_s_vec_i32x4_to_vec_i64x2 : unit -> t + = "caml_binaryen_extend_high_s_vec_i32x4_to_vec_i64x2" + +let extend_high_s_vec_i32x4_to_vec_i64x2 = + extend_high_s_vec_i32x4_to_vec_i64x2 () + +external extend_low_u_vec_i32x4_to_vec_i64x2 : unit -> t + = "caml_binaryen_extend_low_u_vec_i32x4_to_vec_i64x2" + +let extend_low_u_vec_i32x4_to_vec_i64x2 = extend_low_u_vec_i32x4_to_vec_i64x2 () + +external extend_high_u_vec_i32x4_to_vec_i64x2 : unit -> t + = "caml_binaryen_extend_high_u_vec_i32x4_to_vec_i64x2" + +let extend_high_u_vec_i32x4_to_vec_i64x2 = + extend_high_u_vec_i32x4_to_vec_i64x2 () + +external convert_low_s_vec_i32x4_to_vec_f64x2 : unit -> t + = "caml_binaryen_convert_low_s_vec_i32x4_to_vec_f64x2" + +let convert_low_s_vec_i32x4_to_vec_f64x2 = + convert_low_s_vec_i32x4_to_vec_f64x2 () + +external convert_low_u_vec_i32x4_to_vec_f64x2 : unit -> t + = "caml_binaryen_convert_low_u_vec_i32x4_to_vec_f64x2" + +let convert_low_u_vec_i32x4_to_vec_f64x2 = + convert_low_u_vec_i32x4_to_vec_f64x2 () + +external trunc_sat_zero_s_vec_f64x2_to_vec_i32x4 : unit -> t + = "caml_binaryen_trunc_sat_zero_s_vec_f64x2_to_vec_i32x4" + +let trunc_sat_zero_s_vec_f64x2_to_vec_i32x4 = + trunc_sat_zero_s_vec_f64x2_to_vec_i32x4 () + +external trunc_sat_zero_u_vec_f64x2_to_vec_i32x4 : unit -> t + = "caml_binaryen_trunc_sat_zero_u_vec_f64x2_to_vec_i32x4" + +let trunc_sat_zero_u_vec_f64x2_to_vec_i32x4 = + trunc_sat_zero_u_vec_f64x2_to_vec_i32x4 () + +external demote_zero_vec_f64x2_to_vec_f32x4 : unit -> t + = "caml_binaryen_demote_zero_vec_f64x2_to_vec_f32x4" + +let demote_zero_vec_f64x2_to_vec_f32x4 = demote_zero_vec_f64x2_to_vec_f32x4 () + +external promote_low_vec_f32x4_to_vec_f64x2 : unit -> t + = "caml_binaryen_promote_low_vec_f32x4_to_vec_f64x2" + +let promote_low_vec_f32x4_to_vec_f64x2 = promote_low_vec_f32x4_to_vec_f64x2 () + +external relaxed_trunc_s_vec_f32x4_to_vec_i32x4 : unit -> t + = "caml_binaryen_relaxed_trunc_s_vec_f32x4_to_vec_i32x4" + +let relaxed_trunc_s_vec_f32x4_to_vec_i32x4 = + relaxed_trunc_s_vec_f32x4_to_vec_i32x4 () + +external relaxed_trunc_u_vec_f32x4_to_vec_i32x4 : unit -> t + = "caml_binaryen_relaxed_trunc_u_vec_f32x4_to_vec_i32x4" + +let relaxed_trunc_u_vec_f32x4_to_vec_i32x4 = + relaxed_trunc_u_vec_f32x4_to_vec_i32x4 () + +external relaxed_trunc_zero_s_vec_f64x2_to_vec_i32x4 : unit -> t + = "caml_binaryen_relaxed_trunc_zero_s_vec_f64x2_to_vec_i32x4" + +let relaxed_trunc_zero_s_vec_f64x2_to_vec_i32x4 = + relaxed_trunc_zero_s_vec_f64x2_to_vec_i32x4 () + +external relaxed_trunc_zero_u_vec_f64x2_to_vec_i32x4 : unit -> t + = "caml_binaryen_relaxed_trunc_zero_u_vec_f64x2_to_vec_i32x4" + +let relaxed_trunc_zero_u_vec_f64x2_to_vec_i32x4 = + relaxed_trunc_zero_u_vec_f64x2_to_vec_i32x4 () + external swizzle_vec8x16 : unit -> t = "caml_binaryen_swizzle_vec8x16" let swizzle_vec8x16 = swizzle_vec8x16 () +external relaxed_swizzle_vec_i8x16 : unit -> t + = "caml_binaryen_relaxed_swizzle_vec_i8x16" + +let relaxed_swizzle_vec_i8x16 = relaxed_swizzle_vec_i8x16 () + +external relaxed_min_vec_f32x4 : unit -> t + = "caml_binaryen_relaxed_min_vec_f32x4" + +let relaxed_min_vec_f32x4 = relaxed_min_vec_f32x4 () + +external relaxed_max_vec_f32x4 : unit -> t + = "caml_binaryen_relaxed_max_vec_f32x4" + +let relaxed_max_vec_f32x4 = relaxed_max_vec_f32x4 () + +external relaxed_min_vec_f64x2 : unit -> t + = "caml_binaryen_relaxed_min_vec_f64x2" + +let relaxed_min_vec_f64x2 = relaxed_min_vec_f64x2 () + +external relaxed_max_vec_f64x2 : unit -> t + = "caml_binaryen_relaxed_max_vec_f64x2" + +let relaxed_max_vec_f64x2 = relaxed_max_vec_f64x2 () + +external relaxed_q15_mulr_s_vec_i16x8 : unit -> t + = "caml_binaryen_relaxed_q15_mulr_s_vec_i16x8" + +let relaxed_q15_mulr_s_vec_i16x8 = relaxed_q15_mulr_s_vec_i16x8 () + +external dot_i8x16_i7x16_s_to_vec_i16x8 : unit -> t + = "caml_binaryen_dot_i8x16_i7x16_s_to_vec_i16x8" + +let dot_i8x16_i7x16_s_to_vec_i16x8 = dot_i8x16_i7x16_s_to_vec_i16x8 () + external ref_as_non_null : unit -> t = "caml_binaryen_ref_as_non_null" let ref_as_non_null = ref_as_non_null () diff --git a/src/op.mli b/src/op.mli index 18eea0e9..7947a443 100644 --- a/src/op.mli +++ b/src/op.mli @@ -310,15 +310,68 @@ val ceil_vec_f64x2 : t val floor_vec_f64x2 : t val trunc_vec_f64x2 : t val nearest_vec_f64x2 : t +val ext_add_pairwise_s_vec_i8x16_to_i16x8 : t +val ext_add_pairwise_u_vec_i8x16_to_i16x8 : t +val ext_add_pairwise_s_vec_i16x8_to_i32x4 : t +val ext_add_pairwise_u_vec_i16x8_to_i32x4 : t val trunc_sat_s_vec_f32x4_to_vec_i32x4 : t val trunc_sat_u_vec_f32x4_to_vec_i32x4 : t val convert_s_vec_i32x4_to_vec_f32x4 : t val convert_u_vec_i32x4_to_vec_f32x4 : t +val load8_splat_vec128 : t +val load16_splat_vec128 : t +val load32_splat_vec128 : t +val load64_splat_vec128 : t +val load8x8_s_vec128 : t +val load8x8_u_vec128 : t +val load16x4_s_vec128 : t +val load16x4_u_vec128 : t +val load32x2_s_vec128 : t +val load32x2_u_vec128 : t +val load32_zero_vec128 : t +val load64_zero_vec128 : t +val load8_lane_vec128 : t +val load16_lane_vec128 : t +val load32_lane_vec128 : t +val load64_lane_vec128 : t +val store8_lane_vec128 : t +val store16_lane_vec128 : t +val store32_lane_vec128 : t +val store64_lane_vec128 : t val narrow_s_vec_i16x8_to_vec_i8x16 : t val narrow_u_vec_i16x8_to_vec_i8x16 : t val narrow_s_vec_i32x4_to_vec_i16x8 : t val narrow_u_vec_i32x4_to_vec_i16x8 : t +val extend_low_s_vec_i8x16_to_vec_i16x8 : t +val extend_high_s_vec_i8x16_to_vec_i16x8 : t +val extend_low_u_vec_i8x16_to_vec_i16x8 : t +val extend_high_u_vec_i8x16_to_vec_i16x8 : t +val extend_low_s_vec_i16x8_to_vec_i32x4 : t +val extend_high_s_vec_i16x8_to_vec_i32x4 : t +val extend_low_u_vec_i16x8_to_vec_i32x4 : t +val extend_high_u_vec_i16x8_to_vec_i32x4 : t +val extend_low_s_vec_i32x4_to_vec_i64x2 : t +val extend_high_s_vec_i32x4_to_vec_i64x2 : t +val extend_low_u_vec_i32x4_to_vec_i64x2 : t +val extend_high_u_vec_i32x4_to_vec_i64x2 : t +val convert_low_s_vec_i32x4_to_vec_f64x2 : t +val convert_low_u_vec_i32x4_to_vec_f64x2 : t +val trunc_sat_zero_s_vec_f64x2_to_vec_i32x4 : t +val trunc_sat_zero_u_vec_f64x2_to_vec_i32x4 : t +val demote_zero_vec_f64x2_to_vec_f32x4 : t +val promote_low_vec_f32x4_to_vec_f64x2 : t +val relaxed_trunc_s_vec_f32x4_to_vec_i32x4 : t +val relaxed_trunc_u_vec_f32x4_to_vec_i32x4 : t +val relaxed_trunc_zero_s_vec_f64x2_to_vec_i32x4 : t +val relaxed_trunc_zero_u_vec_f64x2_to_vec_i32x4 : t val swizzle_vec8x16 : t +val relaxed_swizzle_vec_i8x16 : t +val relaxed_min_vec_f32x4 : t +val relaxed_max_vec_f32x4 : t +val relaxed_min_vec_f64x2 : t +val relaxed_max_vec_f64x2 : t +val relaxed_q15_mulr_s_vec_i16x8 : t +val dot_i8x16_i7x16_s_to_vec_i16x8 : t val ref_as_non_null : t val ref_as_extern_internalize : t val ref_as_extern_externalize : t diff --git a/test/test.expected b/test/test.expected index 65253319..9857622a 100644 --- a/test/test.expected +++ b/test/test.expected @@ -26,6 +26,70 @@ (start $start) (func $adder (type $0) (param $0 i32) (param $1 i32) (result i32) (block $add (result i32) + (block $simd + (drop + (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + ) + (drop + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + (drop + (i64x2.extract_lane 0 + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + ) + (drop + (i8x16.replace_lane 7 + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (local.get $0) + ) + ) + (drop + (i8x16.shuffle 0 16 1 17 2 18 3 19 4 20 5 21 6 22 7 23 + (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + ) + (drop + (v128.any_true + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + ) + (drop + (v128.and + (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + ) + (drop + (v128.bitselect + (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x00000001 0x00000000 0x00000001 0x00000000) + ) + ) + (drop + (i16x8.shl + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (local.get $0) + ) + ) + (drop + (v128.load64_splat offset=4 + (local.get $0) + ) + ) + (drop + (v128.load32_lane offset=4 3 + (local.get $0) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + ) + (v128.store64_lane offset=4 1 + (local.get $0) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + ) (if (i32.const 0) (unreachable) @@ -82,6 +146,21 @@ (export "hello" (func $hello)) (start $start) (func $adder (type $0) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) + (drop + (v128.load64_splat offset=4 + (local.get $0) + ) + ) + (drop + (v128.load32_lane offset=4 3 + (local.get $0) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + ) + (v128.store64_lane offset=4 1 + (local.get $0) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) (i32.add (select (local.get $0) @@ -130,6 +209,21 @@ (export "hello" (func $2)) (start $1) (func $0 (type $type$1) (param $0 i32) (param $1 i32) (result i32) + (drop + (v128.load64_splat offset=4 + (local.get $0) + ) + ) + (drop + (v128.load32_lane offset=4 3 + (local.get $0) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) + ) + (v128.store64_lane offset=4 1 + (local.get $0) + (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + ) (i32.add (select (local.get $0) @@ -178,6 +272,16 @@ (export "hello" (func $2)) (start $1) (func $0 (type $type$1) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + v128.load64_splat offset=4 + drop + local.get $0 + v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef + v128.load32_lane offset=4 3 + drop + local.get $0 + v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef + v128.store64_lane offset=4 1 local.get $0 local.get $1 i32.load diff --git a/test/test.ml b/test/test.ml index e0339e08..c35638d9 100644 --- a/test/test.ml +++ b/test/test.ml @@ -76,8 +76,62 @@ let if_ = let _ = assert (Expression.If.get_if_false if_ = None) +(* SIMD *) + +let v128 v = Expression.Const.make wasm_mod (Literal.vec128 v) + +let simd = + Expression.Block.make wasm_mod "simd" + [ + Expression.Drop.make wasm_mod (v128 (0L, 0L)); + Expression.Drop.make wasm_mod + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)); + Expression.Drop.make wasm_mod + (Expression.SIMD_extract.make wasm_mod Op.extract_lane_vec_i64x2 + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + 0); + Expression.Drop.make wasm_mod + (Expression.SIMD_replace.make wasm_mod Op.replace_lane_vec_i8x16 + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + 7 (x ())); + Expression.Drop.make wasm_mod + (Expression.SIMD_shuffle.make wasm_mod + (v128 (0L, 0L)) + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + [| 0; 16; 1; 17; 2; 18; 3; 19; 4; 20; 5; 21; 6; 22; 7; 23 |]); + Expression.Drop.make wasm_mod + (Expression.Unary.make wasm_mod Op.any_true_vec128 + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL))); + Expression.Drop.make wasm_mod + (Expression.Binary.make wasm_mod Op.and_vec128 + (v128 (0L, 0L)) + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL))); + Expression.Drop.make wasm_mod + (Expression.SIMD_ternary.make wasm_mod Op.bitselect_vec128 + (v128 (0L, 0L)) + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + (v128 (1L, 1L))); + Expression.Drop.make wasm_mod + (Expression.SIMD_shift.make wasm_mod Op.shl_vec_i16x8 + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + (x ())); + Expression.Drop.make wasm_mod + (Expression.SIMD_load.make wasm_mod Op.load64_splat_vec128 4 8 (x ()) + "0"); + Expression.Drop.make wasm_mod + (Expression.SIMD_load_store_lane.make wasm_mod Op.load32_lane_vec128 4 4 + 3 (x ()) + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + "0"); + Expression.SIMD_load_store_lane.make wasm_mod Op.store64_lane_vec128 4 8 1 + (x ()) + (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + "0"; + ] + let add = - Expression.Block.make wasm_mod ~return_type:Type.int32 "add" [ if_; bin ] + Expression.Block.make wasm_mod ~return_type:Type.int32 "add" + [ simd; if_; bin ] let _ = assert (Expression.Block.get_name add = Some "add") From 332f09ff7f876cfb52488b95cc547de6a05ff1f1 Mon Sep 17 00:00:00 2001 From: Oscar Spencer Date: Wed, 14 May 2025 21:24:09 -0700 Subject: [PATCH 2/2] rework --- src/literal.ml | 8 ++- src/literal.mli | 2 +- src/op.c | 154 +++++++++++++++++++++++++++++++++++++++++++++ src/op.js | 132 ++++++++++++++++++++++++++++++++++++++ src/op.ml | 101 +++++++++++++++++++++++++++++ src/op.mli | 22 +++++++ test/test.expected | 34 +++++----- test/test.ml | 32 +++++----- 8 files changed, 448 insertions(+), 37 deletions(-) diff --git a/src/literal.ml b/src/literal.ml index bf0b9ebc..282a0f9a 100644 --- a/src/literal.ml +++ b/src/literal.ml @@ -10,9 +10,11 @@ let float32 n = float32_bits @@ Int32.bits_of_float n external float64 : float -> t = "caml_binaryen_literal_float64" external vec128 : int array -> t = "caml_binaryen_literal_vec128" -let vec128 (low, high) = +let vec128 (low, low_mid, high_mid, high) = let bytes = Bytes.create 16 in - Bytes.set_int64_le bytes 0 low; - Bytes.set_int64_le bytes 8 high; + Bytes.set_int32_le bytes 0 low; + Bytes.set_int32_le bytes 4 low_mid; + Bytes.set_int32_le bytes 8 high_mid; + Bytes.set_int32_le bytes 12 high; let arr = Array.init 16 (Bytes.get_uint8 bytes) in vec128 arr diff --git a/src/literal.mli b/src/literal.mli index 67ef6c32..e54f7445 100644 --- a/src/literal.mli +++ b/src/literal.mli @@ -6,4 +6,4 @@ val float32_bits : int32 -> t val float64_bits : int64 -> t val float32 : float -> t val float64 : float -> t -val vec128 : int64 * int64 -> t +val vec128 : int32 * int32 * int32 * int32 -> t diff --git a/src/op.c b/src/op.c index 07f20251..2adff35c 100644 --- a/src/op.c +++ b/src/op.c @@ -1350,6 +1350,48 @@ caml_binaryen_ge_u_vec_i32x4(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_eq_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenEqVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ne_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenNeVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_lt_s_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLtSVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_gt_s_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenGtSVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_le_s_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenLeSVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ge_s_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenGeSVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + CAMLprim value caml_binaryen_eq_vec_f32x4(value unit) { CAMLparam1(unit); @@ -1812,6 +1854,41 @@ caml_binaryen_avgr_u_vec_i16x8(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_q15_mulr_sat_s_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenQ15MulrSatSVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_low_s_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulLowSVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_high_s_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulHighSVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_low_u_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulLowUVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_high_u_vec_i16x8(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulHighUVecI16x8(); + CAMLreturn(alloc_BinaryenOp(op)); +} + CAMLprim value caml_binaryen_abs_vec_i32x4(value unit) { CAMLparam1(unit); @@ -1917,6 +1994,41 @@ caml_binaryen_dot_s_vec_i16x8_to_vec_i32x4(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_ext_mul_low_s_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulLowSVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_high_s_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulHighSVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_low_u_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulLowUVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_high_u_vec_i32x4(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulHighUVecI32x4(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_abs_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenAbsVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + CAMLprim value caml_binaryen_neg_vec_i64x2(value unit) { CAMLparam1(unit); @@ -1924,6 +2036,20 @@ caml_binaryen_neg_vec_i64x2(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_all_true_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenAllTrueVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_bitmask_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenBitmaskVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + CAMLprim value caml_binaryen_shl_vec_i64x2(value unit) { CAMLparam1(unit); @@ -1966,6 +2092,34 @@ caml_binaryen_mul_vec_i64x2(value unit) { CAMLreturn(alloc_BinaryenOp(op)); } +CAMLprim value +caml_binaryen_ext_mul_low_s_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulLowSVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_high_s_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulHighSVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_low_u_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulLowUVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + +CAMLprim value +caml_binaryen_ext_mul_high_u_vec_i64x2(value unit) { + CAMLparam1(unit); + BinaryenOp op = BinaryenExtMulHighUVecI64x2(); + CAMLreturn(alloc_BinaryenOp(op)); +} + CAMLprim value caml_binaryen_abs_vec_f32x4(value unit) { CAMLparam1(unit); diff --git a/src/op.js b/src/op.js index edbba99c..40a32350 100644 --- a/src/op.js +++ b/src/op.js @@ -1150,6 +1150,42 @@ function caml_binaryen_ge_u_vec_i32x4() { return Binaryen.Operations.GeUVecI32x4; } +//Provides: caml_binaryen_eq_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_eq_vec_i64x2() { + return Binaryen.Operations.EqVecI64x2; +} + +//Provides: caml_binaryen_ne_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_ne_vec_i64x2() { + return Binaryen.Operations.NeVecI64x2; +} + +//Provides: caml_binaryen_lt_s_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_lt_s_vec_i64x2() { + return Binaryen.Operations.LtSVecI64x2; +} + +//Provides: caml_binaryen_gt_s_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_gt_s_vec_i64x2() { + return Binaryen.Operations.GtSVecI64x2; +} + +//Provides: caml_binaryen_le_s_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_le_s_vec_i64x2() { + return Binaryen.Operations.LeSVecI64x2; +} + +//Provides: caml_binaryen_ge_s_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_ge_s_vec_i64x2() { + return Binaryen.Operations.GeSVecI64x2; +} + //Provides: caml_binaryen_eq_vec_f32x4 //Requires: Binaryen function caml_binaryen_eq_vec_f32x4() { @@ -1546,6 +1582,36 @@ function caml_binaryen_avgr_u_vec_i16x8() { return Binaryen.Operations.AvgrUVecI16x8; } +//Provides: caml_binaryen_q15_mulr_sat_s_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_q15_mulr_sat_s_vec_i16x8() { + return Binaryen.Operations.Q15MulrSatSVecI16x8; +} + +//Provides: caml_binaryen_ext_mul_low_s_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_ext_mul_low_s_vec_i16x8() { + return Binaryen.Operations.ExtMulLowSVecI16x8; +} + +//Provides: caml_binaryen_ext_mul_high_s_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_ext_mul_high_s_vec_i16x8() { + return Binaryen.Operations.ExtMulHighSVecI16x8; +} + +//Provides: caml_binaryen_ext_mul_low_u_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_ext_mul_low_u_vec_i16x8() { + return Binaryen.Operations.ExtMulLowUVecI16x8; +} + +//Provides: caml_binaryen_ext_mul_high_u_vec_i16x8 +//Requires: Binaryen +function caml_binaryen_ext_mul_high_u_vec_i16x8() { + return Binaryen.Operations.ExtMulHighUVecI16x8; +} + //Provides: caml_binaryen_abs_vec_i32x4 //Requires: Binaryen function caml_binaryen_abs_vec_i32x4() { @@ -1636,12 +1702,54 @@ function caml_binaryen_dot_s_vec_i16x8_to_vec_i32x4() { return Binaryen.Operations.DotSVecI16x8ToVecI32x4; } +//Provides: caml_binaryen_ext_mul_low_s_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_ext_mul_low_s_vec_i32x4() { + return Binaryen.Operations.ExtMulLowSVecI32x4; +} + +//Provides: caml_binaryen_ext_mul_high_s_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_ext_mul_high_s_vec_i32x4() { + return Binaryen.Operations.ExtMulHighSVecI32x4; +} + +//Provides: caml_binaryen_ext_mul_low_u_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_ext_mul_low_u_vec_i32x4() { + return Binaryen.Operations.ExtMulLowUVecI32x4; +} + +//Provides: caml_binaryen_ext_mul_high_u_vec_i32x4 +//Requires: Binaryen +function caml_binaryen_ext_mul_high_u_vec_i32x4() { + return Binaryen.Operations.ExtMulHighUVecI32x4; +} + +//Provides: caml_binaryen_abs_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_abs_vec_i64x2() { + return Binaryen.Operations.AbsVecI64x2; +} + //Provides: caml_binaryen_neg_vec_i64x2 //Requires: Binaryen function caml_binaryen_neg_vec_i64x2() { return Binaryen.Operations.NegVecI64x2; } +//Provides: caml_binaryen_all_true_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_all_true_vec_i64x2() { + return Binaryen.Operations.AllTrueVecI64x2; +} + +//Provides: caml_binaryen_bitmask_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_bitmask_vec_i64x2() { + return Binaryen.Operations.BitmaskVecI64x2; +} + //Provides: caml_binaryen_shl_vec_i64x2 //Requires: Binaryen function caml_binaryen_shl_vec_i64x2() { @@ -1678,6 +1786,30 @@ function caml_binaryen_mul_vec_i64x2() { return Binaryen.Operations.MulVecI64x2; } +//Provides: caml_binaryen_ext_mul_low_s_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_ext_mul_low_s_vec_i64x2() { + return Binaryen.Operations.ExtMulLowSVecI64x2; +} + +//Provides: caml_binaryen_ext_mul_high_s_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_ext_mul_high_s_vec_i64x2() { + return Binaryen.Operations.ExtMulHighSVecI64x2; +} + +//Provides: caml_binaryen_ext_mul_low_u_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_ext_mul_low_u_vec_i64x2() { + return Binaryen.Operations.ExtMulLowUVecI64x2; +} + +//Provides: caml_binaryen_ext_mul_high_u_vec_i64x2 +//Requires: Binaryen +function caml_binaryen_ext_mul_high_u_vec_i64x2() { + return Binaryen.Operations.ExtMulHighUVecI64x2; +} + //Provides: caml_binaryen_abs_vec_f32x4 //Requires: Binaryen function caml_binaryen_abs_vec_f32x4() { diff --git a/src/op.ml b/src/op.ml index 3ebf29ef..7c33d556 100644 --- a/src/op.ml +++ b/src/op.ml @@ -806,6 +806,30 @@ external ge_u_vec_i32x4 : unit -> t = "caml_binaryen_ge_u_vec_i32x4" let ge_u_vec_i32x4 = ge_u_vec_i32x4 () +external eq_vec_i64x2 : unit -> t = "caml_binaryen_eq_vec_i64x2" + +let eq_vec_i64x2 = eq_vec_i64x2 () + +external ne_vec_i64x2 : unit -> t = "caml_binaryen_ne_vec_i64x2" + +let ne_vec_i64x2 = ne_vec_i64x2 () + +external lt_s_vec_i64x2 : unit -> t = "caml_binaryen_lt_s_vec_i64x2" + +let lt_s_vec_i64x2 = lt_s_vec_i64x2 () + +external gt_s_vec_i64x2 : unit -> t = "caml_binaryen_gt_s_vec_i64x2" + +let gt_s_vec_i64x2 = gt_s_vec_i64x2 () + +external le_s_vec_i64x2 : unit -> t = "caml_binaryen_le_s_vec_i64x2" + +let le_s_vec_i64x2 = le_s_vec_i64x2 () + +external ge_s_vec_i64x2 : unit -> t = "caml_binaryen_ge_s_vec_i64x2" + +let ge_s_vec_i64x2 = ge_s_vec_i64x2 () + external eq_vec_f32x4 : unit -> t = "caml_binaryen_eq_vec_f32x4" let eq_vec_f32x4 = eq_vec_f32x4 () @@ -1075,6 +1099,31 @@ external avgr_u_vec_i16x8 : unit -> t = "caml_binaryen_avgr_u_vec_i16x8" let avgr_u_vec_i16x8 = avgr_u_vec_i16x8 () +external q15_mulr_sat_s_vec_i16x8 : unit -> t + = "caml_binaryen_q15_mulr_sat_s_vec_i16x8" + +let q15_mulr_sat_s_vec_i16x8 = q15_mulr_sat_s_vec_i16x8 () + +external ext_mul_low_s_vec_i16x8 : unit -> t + = "caml_binaryen_ext_mul_low_s_vec_i16x8" + +let ext_mul_low_s_vec_i16x8 = ext_mul_low_s_vec_i16x8 () + +external ext_mul_high_s_vec_i16x8 : unit -> t + = "caml_binaryen_ext_mul_high_s_vec_i16x8" + +let ext_mul_high_s_vec_i16x8 = ext_mul_high_s_vec_i16x8 () + +external ext_mul_low_u_vec_i16x8 : unit -> t + = "caml_binaryen_ext_mul_low_u_vec_i16x8" + +let ext_mul_low_u_vec_i16x8 = ext_mul_low_u_vec_i16x8 () + +external ext_mul_high_u_vec_i16x8 : unit -> t + = "caml_binaryen_ext_mul_high_u_vec_i16x8" + +let ext_mul_high_u_vec_i16x8 = ext_mul_high_u_vec_i16x8 () + external abs_vec_i32x4 : unit -> t = "caml_binaryen_abs_vec_i32x4" let abs_vec_i32x4 = abs_vec_i32x4 () @@ -1136,10 +1185,42 @@ external dot_s_vec_i16x8_to_vec_i32x4 : unit -> t let dot_s_vec_i16x8_to_vec_i32x4 = dot_s_vec_i16x8_to_vec_i32x4 () +external ext_mul_low_s_vec_i32x4 : unit -> t + = "caml_binaryen_ext_mul_low_s_vec_i32x4" + +let ext_mul_low_s_vec_i32x4 = ext_mul_low_s_vec_i32x4 () + +external ext_mul_high_s_vec_i32x4 : unit -> t + = "caml_binaryen_ext_mul_high_s_vec_i32x4" + +let ext_mul_high_s_vec_i32x4 = ext_mul_high_s_vec_i32x4 () + +external ext_mul_low_u_vec_i32x4 : unit -> t + = "caml_binaryen_ext_mul_low_u_vec_i32x4" + +let ext_mul_low_u_vec_i32x4 = ext_mul_low_u_vec_i32x4 () + +external ext_mul_high_u_vec_i32x4 : unit -> t + = "caml_binaryen_ext_mul_high_u_vec_i32x4" + +let ext_mul_high_u_vec_i32x4 = ext_mul_high_u_vec_i32x4 () + +external abs_vec_i64x2 : unit -> t = "caml_binaryen_abs_vec_i64x2" + +let abs_vec_i64x2 = abs_vec_i64x2 () + external neg_vec_i64x2 : unit -> t = "caml_binaryen_neg_vec_i64x2" let neg_vec_i64x2 = neg_vec_i64x2 () +external all_true_vec_i64x2 : unit -> t = "caml_binaryen_all_true_vec_i64x2" + +let all_true_vec_i64x2 = all_true_vec_i64x2 () + +external bitmask_vec_i64x2 : unit -> t = "caml_binaryen_bitmask_vec_i64x2" + +let bitmask_vec_i64x2 = bitmask_vec_i64x2 () + external shl_vec_i64x2 : unit -> t = "caml_binaryen_shl_vec_i64x2" let shl_vec_i64x2 = shl_vec_i64x2 () @@ -1164,6 +1245,26 @@ external mul_vec_i64x2 : unit -> t = "caml_binaryen_mul_vec_i64x2" let mul_vec_i64x2 = mul_vec_i64x2 () +external ext_mul_low_s_vec_i64x2 : unit -> t + = "caml_binaryen_ext_mul_low_s_vec_i64x2" + +let ext_mul_low_s_vec_i64x2 = ext_mul_low_s_vec_i64x2 () + +external ext_mul_high_s_vec_i64x2 : unit -> t + = "caml_binaryen_ext_mul_high_s_vec_i64x2" + +let ext_mul_high_s_vec_i64x2 = ext_mul_high_s_vec_i64x2 () + +external ext_mul_low_u_vec_i64x2 : unit -> t + = "caml_binaryen_ext_mul_low_u_vec_i64x2" + +let ext_mul_low_u_vec_i64x2 = ext_mul_low_u_vec_i64x2 () + +external ext_mul_high_u_vec_i64x2 : unit -> t + = "caml_binaryen_ext_mul_high_u_vec_i64x2" + +let ext_mul_high_u_vec_i64x2 = ext_mul_high_u_vec_i64x2 () + external abs_vec_f32x4 : unit -> t = "caml_binaryen_abs_vec_f32x4" let abs_vec_f32x4 = abs_vec_f32x4 () diff --git a/src/op.mli b/src/op.mli index 7947a443..177636fb 100644 --- a/src/op.mli +++ b/src/op.mli @@ -192,6 +192,12 @@ val le_s_vec_i32x4 : t val le_u_vec_i32x4 : t val ge_s_vec_i32x4 : t val ge_u_vec_i32x4 : t +val eq_vec_i64x2 : t +val ne_vec_i64x2 : t +val lt_s_vec_i64x2 : t +val gt_s_vec_i64x2 : t +val le_s_vec_i64x2 : t +val ge_s_vec_i64x2 : t val eq_vec_f32x4 : t val ne_vec_f32x4 : t val lt_vec_f32x4 : t @@ -258,6 +264,11 @@ val min_u_vec_i16x8 : t val max_s_vec_i16x8 : t val max_u_vec_i16x8 : t val avgr_u_vec_i16x8 : t +val q15_mulr_sat_s_vec_i16x8 : t +val ext_mul_low_s_vec_i16x8 : t +val ext_mul_high_s_vec_i16x8 : t +val ext_mul_low_u_vec_i16x8 : t +val ext_mul_high_u_vec_i16x8 : t val abs_vec_i32x4 : t val neg_vec_i32x4 : t val all_true_vec_i32x4 : t @@ -273,13 +284,24 @@ val min_u_vec_i32x4 : t val max_s_vec_i32x4 : t val max_u_vec_i32x4 : t val dot_s_vec_i16x8_to_vec_i32x4 : t +val ext_mul_low_s_vec_i32x4 : t +val ext_mul_high_s_vec_i32x4 : t +val ext_mul_low_u_vec_i32x4 : t +val ext_mul_high_u_vec_i32x4 : t +val abs_vec_i64x2 : t val neg_vec_i64x2 : t +val all_true_vec_i64x2 : t +val bitmask_vec_i64x2 : t val shl_vec_i64x2 : t val shr_s_vec_i64x2 : t val shr_u_vec_i64x2 : t val add_vec_i64x2 : t val sub_vec_i64x2 : t val mul_vec_i64x2 : t +val ext_mul_low_s_vec_i64x2 : t +val ext_mul_high_s_vec_i64x2 : t +val ext_mul_low_u_vec_i64x2 : t +val ext_mul_high_u_vec_i64x2 : t val abs_vec_f32x4 : t val neg_vec_f32x4 : t val sqrt_vec_f32x4 : t diff --git a/test/test.expected b/test/test.expected index 9857622a..c25cf281 100644 --- a/test/test.expected +++ b/test/test.expected @@ -31,46 +31,46 @@ (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) ) (drop - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) (drop (i64x2.extract_lane 0 - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) ) (drop (i8x16.replace_lane 7 - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) (local.get $0) ) ) (drop (i8x16.shuffle 0 16 1 17 2 18 3 19 4 20 5 21 6 22 7 23 (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) ) (drop (v128.any_true - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) ) (drop (v128.and (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) ) (drop (v128.bitselect (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) - (v128.const i32x4 0x00000001 0x00000000 0x00000001 0x00000000) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x00000001 0x00000001 0x00000001 0x00000001) ) ) (drop (i16x8.shl - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) (local.get $0) ) ) @@ -82,12 +82,12 @@ (drop (v128.load32_lane offset=4 3 (local.get $0) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) ) (v128.store64_lane offset=4 1 (local.get $0) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) ) (if @@ -154,12 +154,12 @@ (drop (v128.load32_lane offset=4 3 (local.get $0) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) ) (v128.store64_lane offset=4 1 (local.get $0) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) (i32.add (select @@ -217,12 +217,12 @@ (drop (v128.load32_lane offset=4 3 (local.get $0) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) ) (v128.store64_lane offset=4 1 (local.get $0) - (v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef) + (v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef) ) (i32.add (select @@ -276,11 +276,11 @@ v128.load64_splat offset=4 drop local.get $0 - v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef + v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef v128.load32_lane offset=4 3 drop local.get $0 - v128.const i32x4 0x87654321 0x12345678 0xdeadbeef 0xdeadbeef + v128.const i32x4 0x12345678 0x87654321 0xdeadbeef 0xdeadbeef v128.store64_lane offset=4 1 local.get $0 local.get $1 diff --git a/test/test.ml b/test/test.ml index c35638d9..da5db2c3 100644 --- a/test/test.ml +++ b/test/test.ml @@ -83,37 +83,37 @@ let v128 v = Expression.Const.make wasm_mod (Literal.vec128 v) let simd = Expression.Block.make wasm_mod "simd" [ - Expression.Drop.make wasm_mod (v128 (0L, 0L)); + Expression.Drop.make wasm_mod (v128 (0l, 0l, 0l, 0l)); Expression.Drop.make wasm_mod - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)); + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl)); Expression.Drop.make wasm_mod (Expression.SIMD_extract.make wasm_mod Op.extract_lane_vec_i64x2 - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl)) 0); Expression.Drop.make wasm_mod (Expression.SIMD_replace.make wasm_mod Op.replace_lane_vec_i8x16 - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl)) 7 (x ())); Expression.Drop.make wasm_mod (Expression.SIMD_shuffle.make wasm_mod - (v128 (0L, 0L)) - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + (v128 (0l, 0l, 0l, 0l)) + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl)) [| 0; 16; 1; 17; 2; 18; 3; 19; 4; 20; 5; 21; 6; 22; 7; 23 |]); Expression.Drop.make wasm_mod (Expression.Unary.make wasm_mod Op.any_true_vec128 - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL))); + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl))); Expression.Drop.make wasm_mod (Expression.Binary.make wasm_mod Op.and_vec128 - (v128 (0L, 0L)) - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL))); + (v128 (0l, 0l, 0l, 0l)) + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl))); Expression.Drop.make wasm_mod (Expression.SIMD_ternary.make wasm_mod Op.bitselect_vec128 - (v128 (0L, 0L)) - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) - (v128 (1L, 1L))); + (v128 (0l, 0l, 0l, 0l)) + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl)) + (v128 (1l, 1l, 1l, 1l))); Expression.Drop.make wasm_mod (Expression.SIMD_shift.make wasm_mod Op.shl_vec_i16x8 - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl)) (x ())); Expression.Drop.make wasm_mod (Expression.SIMD_load.make wasm_mod Op.load64_splat_vec128 4 8 (x ()) @@ -121,12 +121,12 @@ let simd = Expression.Drop.make wasm_mod (Expression.SIMD_load_store_lane.make wasm_mod Op.load32_lane_vec128 4 4 3 (x ()) - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl)) "0"); Expression.SIMD_load_store_lane.make wasm_mod Op.store64_lane_vec128 4 8 1 (x ()) - (v128 (0x1234567887654321L, 0xdeadbeefdeadbeefL)) - "0"; + (v128 (0x12345678l, 0x87654321l, 0xdeadbeefl, 0xdeadbeefl)) + "0"; ] let add =