Skip to content

[C API] Add Relaxed SIMD operations #5482

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
Feb 7, 2023
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
36 changes: 36 additions & 0 deletions src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,17 @@ BinaryenOp BinaryenOrVec128(void) { return OrVec128; }
BinaryenOp BinaryenXorVec128(void) { return XorVec128; }
BinaryenOp BinaryenAndNotVec128(void) { return AndNotVec128; }
BinaryenOp BinaryenBitselectVec128(void) { return Bitselect; }
BinaryenOp BinaryenRelaxedFmaVecF32x4(void) { return RelaxedFmaVecF32x4; }
BinaryenOp BinaryenRelaxedFmsVecF32x4(void) { return RelaxedFmsVecF32x4; }
BinaryenOp BinaryenRelaxedFmaVecF64x2(void) { return RelaxedFmaVecF64x2; }
BinaryenOp BinaryenRelaxedFmsVecF64x2(void) { return RelaxedFmsVecF64x2; }
BinaryenOp BinaryenLaneselectI8x16(void) { return LaneselectI8x16; }
BinaryenOp BinaryenLaneselectI16x8(void) { return LaneselectI16x8; }
BinaryenOp BinaryenLaneselectI32x4(void) { return LaneselectI32x4; }
BinaryenOp BinaryenLaneselectI64x2(void) { return LaneselectI64x2; }
BinaryenOp BinaryenDotI8x16I7x16AddSToVecI32x4(void) {
return DotI8x16I7x16AddSToVecI32x4;
}
BinaryenOp BinaryenAnyTrueVec128(void) { return AnyTrueVec128; }
BinaryenOp BinaryenAbsVecI8x16(void) { return AbsVecI8x16; }
BinaryenOp BinaryenNegVecI8x16(void) { return NegVecI8x16; }
Expand Down Expand Up @@ -1007,7 +1018,32 @@ BinaryenOp BinaryenDemoteZeroVecF64x2ToVecF32x4(void) {
BinaryenOp BinaryenPromoteLowVecF32x4ToVecF64x2(void) {
return PromoteLowVecF32x4ToVecF64x2;
}
BinaryenOp BinaryenRelaxedTruncSVecF32x4ToVecI32x4(void) {
return RelaxedTruncSVecF32x4ToVecI32x4;
}
BinaryenOp BinaryenRelaxedTruncUVecF32x4ToVecI32x4(void) {
return RelaxedTruncUVecF32x4ToVecI32x4;
}
BinaryenOp BinaryenRelaxedTruncZeroSVecF64x2ToVecI32x4(void) {
return RelaxedTruncZeroSVecF64x2ToVecI32x4;
}
BinaryenOp BinaryenRelaxedTruncZeroUVecF64x2ToVecI32x4(void) {
return RelaxedTruncZeroUVecF64x2ToVecI32x4;
}
BinaryenOp BinaryenSwizzleVecI8x16(void) { return SwizzleVecI8x16; }
BinaryenOp BinaryenRelaxedSwizzleVecI8x16(void) {
return RelaxedSwizzleVecI8x16;
}
BinaryenOp BinaryenRelaxedMinVecF32x4(void) { return RelaxedMinVecF32x4; }
BinaryenOp BinaryenRelaxedMaxVecF32x4(void) { return RelaxedMaxVecF32x4; }
BinaryenOp BinaryenRelaxedMinVecF64x2(void) { return RelaxedMinVecF64x2; }
BinaryenOp BinaryenRelaxedMaxVecF64x2(void) { return RelaxedMaxVecF64x2; }
BinaryenOp BinaryenRelaxedQ15MulrSVecI16x8(void) {
return RelaxedQ15MulrSVecI16x8;
}
BinaryenOp BinaryenDotI8x16I7x16SToVecI16x8(void) {
return DotI8x16I7x16SToVecI16x8;
}
BinaryenOp BinaryenRefAsNonNull(void) { return RefAsNonNull; }
BinaryenOp BinaryenRefAsExternInternalize(void) { return ExternInternalize; }
BinaryenOp BinaryenRefAsExternExternalize(void) { return ExternExternalize; }
Expand Down
20 changes: 20 additions & 0 deletions src/binaryen-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,15 @@ BINARYEN_API BinaryenOp BinaryenOrVec128(void);
BINARYEN_API BinaryenOp BinaryenXorVec128(void);
BINARYEN_API BinaryenOp BinaryenAndNotVec128(void);
BINARYEN_API BinaryenOp BinaryenBitselectVec128(void);
BINARYEN_API BinaryenOp BinaryenRelaxedFmaVecF32x4(void);
BINARYEN_API BinaryenOp BinaryenRelaxedFmsVecF32x4(void);
BINARYEN_API BinaryenOp BinaryenRelaxedFmaVecF64x2(void);
BINARYEN_API BinaryenOp BinaryenRelaxedFmsVecF64x2(void);
BINARYEN_API BinaryenOp BinaryenLaneselectI8x16(void);
BINARYEN_API BinaryenOp BinaryenLaneselectI16x8(void);
BINARYEN_API BinaryenOp BinaryenLaneselectI32x4(void);
BINARYEN_API BinaryenOp BinaryenLaneselectI64x2(void);
BINARYEN_API BinaryenOp BinaryenDotI8x16I7x16AddSToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenAnyTrueVec128(void);
BINARYEN_API BinaryenOp BinaryenPopcntVecI8x16(void);
BINARYEN_API BinaryenOp BinaryenAbsVecI8x16(void);
Expand Down Expand Up @@ -669,7 +678,18 @@ BINARYEN_API BinaryenOp BinaryenTruncSatZeroSVecF64x2ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenTruncSatZeroUVecF64x2ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenDemoteZeroVecF64x2ToVecF32x4(void);
BINARYEN_API BinaryenOp BinaryenPromoteLowVecF32x4ToVecF64x2(void);
BINARYEN_API BinaryenOp BinaryenRelaxedTruncSVecF32x4ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenRelaxedTruncUVecF32x4ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenRelaxedTruncZeroSVecF64x2ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenRelaxedTruncZeroUVecF64x2ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenSwizzleVecI8x16(void);
BINARYEN_API BinaryenOp BinaryenRelaxedSwizzleVecI8x16(void);
BINARYEN_API BinaryenOp BinaryenRelaxedMinVecF32x4(void);
BINARYEN_API BinaryenOp BinaryenRelaxedMaxVecF32x4(void);
BINARYEN_API BinaryenOp BinaryenRelaxedMinVecF64x2(void);
BINARYEN_API BinaryenOp BinaryenRelaxedMaxVecF64x2(void);
BINARYEN_API BinaryenOp BinaryenRelaxedQ15MulrSVecI16x8(void);
BINARYEN_API BinaryenOp BinaryenDotI8x16I7x16SToVecI16x8(void);
BINARYEN_API BinaryenOp BinaryenRefAsNonNull(void);
BINARYEN_API BinaryenOp BinaryenRefAsExternInternalize(void);
BINARYEN_API BinaryenOp BinaryenRefAsExternExternalize(void);
Expand Down
20 changes: 20 additions & 0 deletions src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,15 @@ function initializeConstants() {
'XorVec128',
'AndNotVec128',
'BitselectVec128',
'RelaxedFmaVecF32x4',
'RelaxedFmsVecF32x4',
'RelaxedFmaVecF64x2',
'RelaxedFmsVecF64x2',
'LaneselectI8x16',
'LaneselectI16x8',
'LaneselectI32x4',
'LaneselectI64x2',
'DotI8x16I7x16AddSToVecI32x4',
'AnyTrueVec128',
'PopcntVecI8x16',
'AbsVecI8x16',
Expand Down Expand Up @@ -548,7 +557,18 @@ function initializeConstants() {
'TruncSatZeroUVecF64x2ToVecI32x4',
'DemoteZeroVecF64x2ToVecF32x4',
'PromoteLowVecF32x4ToVecF64x2',
'RelaxedTruncSVecF32x4ToVecI32x4',
'RelaxedTruncUVecF32x4ToVecI32x4',
'RelaxedTruncZeroSVecF64x2ToVecI32x4',
'RelaxedTruncZeroUVecF64x2ToVecI32x4',
'SwizzleVecI8x16',
'RelaxedSwizzleVecI8x16',
'RelaxedMinVecF32x4',
'RelaxedMaxVecF32x4',
'RelaxedMinVecF64x2',
'RelaxedMaxVecF64x2',
'RelaxedQ15MulrSVecI16x8',
'DotI8x16I7x16SToVecI16x8',
'RefAsNonNull',
'RefAsExternInternalize',
'RefAsExternExternalize',
Expand Down
20 changes: 20 additions & 0 deletions test/example/c-api-kitchen-sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,10 @@ void test_core() {
makeUnary(module, BinaryenTruncSatZeroUVecF64x2ToVecI32x4(), v128),
makeUnary(module, BinaryenDemoteZeroVecF64x2ToVecF32x4(), v128),
makeUnary(module, BinaryenPromoteLowVecF32x4ToVecF64x2(), v128),
makeUnary(module, BinaryenRelaxedTruncSVecF32x4ToVecI32x4(), v128),
makeUnary(module, BinaryenRelaxedTruncUVecF32x4ToVecI32x4(), v128),
makeUnary(module, BinaryenRelaxedTruncZeroSVecF64x2ToVecI32x4(), v128),
makeUnary(module, BinaryenRelaxedTruncZeroUVecF64x2ToVecI32x4(), v128),
// Binary
makeBinary(module, BinaryenAddInt32(), i32),
makeBinary(module, BinaryenSubFloat64(), f64),
Expand Down Expand Up @@ -812,6 +816,13 @@ void test_core() {
makeBinary(module, BinaryenNarrowSVecI32x4ToVecI16x8(), v128),
makeBinary(module, BinaryenNarrowUVecI32x4ToVecI16x8(), v128),
makeBinary(module, BinaryenSwizzleVecI8x16(), v128),
makeBinary(module, BinaryenRelaxedSwizzleVecI8x16(), v128),
makeBinary(module, BinaryenRelaxedMinVecF32x4(), v128),
makeBinary(module, BinaryenRelaxedMaxVecF32x4(), v128),
makeBinary(module, BinaryenRelaxedMinVecF64x2(), v128),
makeBinary(module, BinaryenRelaxedMaxVecF64x2(), v128),
makeBinary(module, BinaryenRelaxedQ15MulrSVecI16x8(), v128),
makeBinary(module, BinaryenDotI8x16I7x16SToVecI16x8(), v128),
// SIMD lane manipulation
makeSIMDExtract(module, BinaryenExtractLaneSVecI8x16()),
makeSIMDExtract(module, BinaryenExtractLaneUVecI8x16()),
Expand Down Expand Up @@ -933,6 +944,15 @@ void test_core() {
// Other SIMD
makeSIMDShuffle(module),
makeSIMDTernary(module, BinaryenBitselectVec128()),
makeSIMDTernary(module, BinaryenRelaxedFmaVecF32x4()),
makeSIMDTernary(module, BinaryenRelaxedFmsVecF32x4()),
makeSIMDTernary(module, BinaryenRelaxedFmaVecF64x2()),
makeSIMDTernary(module, BinaryenRelaxedFmsVecF64x2()),
makeSIMDTernary(module, BinaryenLaneselectI8x16()),
makeSIMDTernary(module, BinaryenLaneselectI16x8()),
makeSIMDTernary(module, BinaryenLaneselectI32x4()),
makeSIMDTernary(module, BinaryenLaneselectI64x2()),
makeSIMDTernary(module, BinaryenDotI8x16I7x16AddSToVecI32x4()),
// Bulk memory
makeMemoryInit(module),
makeDataDrop(module),
Expand Down
125 changes: 125 additions & 0 deletions test/example/c-api-kitchen-sink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,26 @@ BinaryenFeatureAll: 126975
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32x4.relaxed_trunc_f32x4_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32x4.relaxed_trunc_f32x4_u
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32x4.relaxed_trunc_f64x2_s_zero
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32x4.relaxed_trunc_f64x2_u_zero
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32.add
(i32.const -10)
Expand Down Expand Up @@ -1563,6 +1583,48 @@ BinaryenFeatureAll: 126975
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i8x16.relaxed_swizzle
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(f32x4.relaxed_min
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(f32x4.relaxed_max
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(f64x2.relaxed_min
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(f64x2.relaxed_max
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i16x8.relaxed_q15mulr_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i16x8.dot_i8x16_i7x16_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i8x16.extract_lane_s 0
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
Expand Down Expand Up @@ -1824,6 +1886,69 @@ BinaryenFeatureAll: 126975
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(f32x4.relaxed_fma
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(f32x4.relaxed_fms
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(f64x2.relaxed_fma
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(f64x2.relaxed_fms
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i8x16.laneselect
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i16x8.laneselect
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32x4.laneselect
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i64x2.laneselect
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(drop
(i32x4.dot_i8x16_i7x16_add_s
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
(v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)
)
)
(memory.init 0
(i32.const 1024)
(i32.const 0)
Expand Down