Skip to content

Add v128.load32/64_zero SIMD instructions to C/JS API #3783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ BinaryenOp BinaryenLoadExtSVec32x2ToVecI64x2(void) {
BinaryenOp BinaryenLoadExtUVec32x2ToVecI64x2(void) {
return LoadExtUVec32x2ToVecI64x2;
}
BinaryenOp BinaryenLoad32Zero(void) { return Load32Zero; }
BinaryenOp BinaryenLoad64Zero(void) { return Load64Zero; }
BinaryenOp BinaryenNarrowSVecI16x8ToVecI8x16(void) {
return NarrowSVecI16x8ToVecI8x16;
}
Expand Down
3 changes: 2 additions & 1 deletion src/binaryen-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ BINARYEN_API BinaryenOp BinaryenLoadExtSVec16x4ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenLoadExtUVec16x4ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenLoadExtSVec32x2ToVecI64x2(void);
BINARYEN_API BinaryenOp BinaryenLoadExtUVec32x2ToVecI64x2(void);
// TODO: Add Load{32,64}Zero to C and JS APIs once merged to proposal
BINARYEN_API BinaryenOp BinaryenLoad32Zero(void);
BINARYEN_API BinaryenOp BinaryenLoad64Zero(void);
BINARYEN_API BinaryenOp BinaryenNarrowSVecI16x8ToVecI8x16(void);
BINARYEN_API BinaryenOp BinaryenNarrowUVecI16x8ToVecI8x16(void);
BINARYEN_API BinaryenOp BinaryenNarrowSVecI32x4ToVecI16x8(void);
Expand Down
8 changes: 8 additions & 0 deletions src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ function initializeConstants() {
'LoadExtUVec16x4ToVecI32x4',
'LoadExtSVec32x2ToVecI64x2',
'LoadExtUVec32x2ToVecI64x2',
'Load32Zero',
'Load64Zero',
'NarrowSVecI16x8ToVecI8x16',
'NarrowUVecI16x8ToVecI8x16',
'NarrowSVecI32x4ToVecI16x8',
Expand Down Expand Up @@ -1471,6 +1473,12 @@ function wrapModule(module, self = {}) {
'load32x2_u'(offset, align, ptr) {
return Module['_BinaryenSIMDLoad'](module, Module['LoadExtUVec32x2ToVecI64x2'], offset, align, ptr);
},
'load32_zero'(offset, align, ptr) {
return Module['_BinaryenSIMDLoad'](module, Module['Load32Zero'], offset, align, ptr);
},
'load64_zero'(offset, align, ptr) {
return Module['_BinaryenSIMDLoad'](module, Module['Load64Zero'], offset, align, ptr);
},
'store'(offset, align, ptr, value) {
return Module['_BinaryenStore'](module, 16, offset, align, ptr, value, Module['v128']);
},
Expand Down
2 changes: 2 additions & 0 deletions test/binaryen.js/kitchen-sink.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ function test_core() {
module.v128.load16x4_u(0, 8, module.i32.const(128)),
module.v128.load32x2_s(0, 8, module.i32.const(128)),
module.v128.load32x2_u(0, 8, module.i32.const(128)),
module.v128.load32_zero(0, 4, module.i32.const(128)),
module.v128.load64_zero(0, 8, module.i32.const(128)),
// Other SIMD
module.i8x16.shuffle(module.v128.const(v128_bytes), module.v128.const(v128_bytes), v128_bytes),
module.v128.bitselect(module.v128.const(v128_bytes), module.v128.const(v128_bytes), module.v128.const(v128_bytes)),
Expand Down
20 changes: 20 additions & 0 deletions test/binaryen.js/kitchen-sink.js.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,16 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7}
(i32.const 128)
)
)
(drop
(v128.load32_zero
(i32.const 128)
)
)
(drop
(v128.load64_zero
(i32.const 128)
)
)
(drop
(i8x16.shuffle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
Expand Down Expand Up @@ -3587,6 +3597,16 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7}
(i32.const 128)
)
)
(drop
(v128.load32_zero
(i32.const 128)
)
)
(drop
(v128.load64_zero
(i32.const 128)
)
)
(drop
(i8x16.shuffle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
Expand Down
10 changes: 10 additions & 0 deletions test/example/c-api-kitchen-sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,16 @@ void test_core() {
0,
8,
makeInt32(module, 128)),
BinaryenSIMDLoad(module,
BinaryenLoad32Zero(),
0,
4,
makeInt32(module, 128)),
BinaryenSIMDLoad(module,
BinaryenLoad64Zero(),
0,
8,
makeInt32(module, 128)),
// Other SIMD
makeSIMDShuffle(module),
makeSIMDTernary(module, BinaryenBitselectVec128()),
Expand Down
10 changes: 10 additions & 0 deletions test/example/c-api-kitchen-sink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,16 @@ BinaryenFeatureAll: 8191
(i32.const 128)
)
)
(drop
(v128.load32_zero
(i32.const 128)
)
)
(drop
(v128.load64_zero
(i32.const 128)
)
)
(drop
(i8x16.shuffle 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
Expand Down