Skip to content

Add i64x2.extend_low/high_* SIMD instructions to C/JS API #3778

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 2 commits into from
Apr 7, 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
12 changes: 12 additions & 0 deletions src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,18 @@ BinaryenOp BinaryenExtendLowUVecI16x8ToVecI32x4(void) {
BinaryenOp BinaryenExtendHighUVecI16x8ToVecI32x4(void) {
return ExtendHighUVecI16x8ToVecI32x4;
}
BinaryenOp BinaryenExtendLowSVecI32x4ToVecI64x2(void) {
return ExtendLowSVecI32x4ToVecI64x2;
}
BinaryenOp BinaryenExtendHighSVecI32x4ToVecI64x2(void) {
return ExtendHighSVecI32x4ToVecI64x2;
}
BinaryenOp BinaryenExtendLowUVecI32x4ToVecI64x2(void) {
return ExtendLowUVecI32x4ToVecI64x2;
}
BinaryenOp BinaryenExtendHighUVecI32x4ToVecI64x2(void) {
return ExtendHighUVecI32x4ToVecI64x2;
}
BinaryenOp BinaryenSwizzleVec8x16(void) { return SwizzleVec8x16; }
BinaryenOp BinaryenRefIsNull(void) { return RefIsNull; }
BinaryenOp BinaryenRefIsFunc(void) { return RefIsFunc; }
Expand Down
4 changes: 4 additions & 0 deletions src/binaryen-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ BINARYEN_API BinaryenOp BinaryenExtendLowSVecI16x8ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenExtendHighSVecI16x8ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenExtendLowUVecI16x8ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenExtendHighUVecI16x8ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenExtendLowSVecI32x4ToVecI64x2(void);
BINARYEN_API BinaryenOp BinaryenExtendHighSVecI32x4ToVecI64x2(void);
BINARYEN_API BinaryenOp BinaryenExtendLowUVecI32x4ToVecI64x2(void);
BINARYEN_API BinaryenOp BinaryenExtendHighUVecI32x4ToVecI64x2(void);
BINARYEN_API BinaryenOp BinaryenSwizzleVec8x16(void);
BINARYEN_API BinaryenOp BinaryenRefIsNull(void);
BINARYEN_API BinaryenOp BinaryenRefIsFunc(void);
Expand Down
16 changes: 16 additions & 0 deletions src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ function initializeConstants() {
'ExtendHighSVecI16x8ToVecI32x4',
'ExtendLowUVecI16x8ToVecI32x4',
'ExtendHighUVecI16x8ToVecI32x4',
'ExtendLowSVecI32x4ToVecI64x2',
'ExtendHighSVecI32x4ToVecI64x2',
'ExtendLowUVecI32x4ToVecI64x2',
'ExtendHighUVecI32x4ToVecI64x2',
'SwizzleVec8x16',
'RefIsNull',
'RefIsFunc',
Expand Down Expand Up @@ -1856,6 +1860,18 @@ function wrapModule(module, self = {}) {
'mul'(left, right) {
return Module['_BinaryenBinary'](module, Module['MulVecI64x2'], left, right);
},
'extend_low_i32x4_s'(value) {
return Module['_BinaryenUnary'](module, Module['ExtendLowSVecI32x4ToVecI64x2'], value);
},
'extend_high_i32x4_s'(value) {
return Module['_BinaryenUnary'](module, Module['ExtendHighSVecI32x4ToVecI64x2'], value);
},
'extend_low_i32x4_u'(value) {
return Module['_BinaryenUnary'](module, Module['ExtendLowUVecI32x4ToVecI64x2'], value);
},
'extend_high_i32x4_u'(value) {
return Module['_BinaryenUnary'](module, Module['ExtendHighUVecI32x4ToVecI64x2'], value);
},
};

self['f32x4'] = {
Expand Down
4 changes: 4 additions & 0 deletions test/binaryen.js/kitchen-sink.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ function test_core() {
module.i32x4.extend_high_i16x8_s(module.v128.const(v128_bytes)),
module.i32x4.extend_low_i16x8_u(module.v128.const(v128_bytes)),
module.i32x4.extend_high_i16x8_u(module.v128.const(v128_bytes)),
module.i64x2.extend_low_i32x4_s(module.v128.const(v128_bytes)),
module.i64x2.extend_high_i32x4_s(module.v128.const(v128_bytes)),
module.i64x2.extend_low_i32x4_u(module.v128.const(v128_bytes)),
module.i64x2.extend_high_i32x4_u(module.v128.const(v128_bytes)),
// Binary
module.i32.add(module.i32.const(-10), module.i32.const(-11)),
module.f64.sub(module.f64.const(-9005.841), module.f64.const(-9007.333)),
Expand Down
40 changes: 40 additions & 0 deletions test/binaryen.js/kitchen-sink.js.txt
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,26 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7}
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_low_i32x4_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_high_i32x4_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_low_i32x4_u
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_high_i32x4_u
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32.add
(i32.const -10)
Expand Down Expand Up @@ -2359,6 +2379,26 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7}
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_low_i32x4_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_high_i32x4_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_low_i32x4_u
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_high_i32x4_u
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32.add
(i32.const -10)
Expand Down
4 changes: 4 additions & 0 deletions test/example/c-api-kitchen-sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ void test_core() {
makeUnary(module, BinaryenExtendHighSVecI16x8ToVecI32x4(), v128),
makeUnary(module, BinaryenExtendLowUVecI16x8ToVecI32x4(), v128),
makeUnary(module, BinaryenExtendHighUVecI16x8ToVecI32x4(), v128),
makeUnary(module, BinaryenExtendLowSVecI32x4ToVecI64x2(), v128),
makeUnary(module, BinaryenExtendHighSVecI32x4ToVecI64x2(), v128),
makeUnary(module, BinaryenExtendLowUVecI32x4ToVecI64x2(), v128),
makeUnary(module, BinaryenExtendHighUVecI32x4ToVecI64x2(), v128),
// Binary
makeBinary(module, BinaryenAddInt32(), i32),
makeBinary(module, BinaryenSubFloat64(), f64),
Expand Down
20 changes: 20 additions & 0 deletions test/example/c-api-kitchen-sink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,26 @@ BinaryenFeatureAll: 8191
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_low_i32x4_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_high_i32x4_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_low_i32x4_u
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.extend_high_i32x4_u
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32.add
(i32.const -10)
Expand Down