diff options
33 files changed, 923 insertions, 450 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a950f6ae..370576ce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,9 +20,11 @@ Current Trunk - `i32.wait` / `i64.wait` -> `i32.atomic.wait` / `i64.atomic.wait` - Binaryen.js: `flags` argument in `setMemory` function is removed. - `atomic.fence` instruction support is added. -- wasm-emscripten-finalize: Don't realy on name section being present in the +- wasm-emscripten-finalize: Don't rely on name section being present in the input. Use the exported names for things instead. - Added `mutable` parameter to BinaryenAddGlobalImport. +- Replace BinaryenSIMDBitselect* with BinaryenSIMDTernary* in the C API and add + qfma/qfms instructions. v88 --- diff --git a/build-js.sh b/build-js.sh index 895be69f0..14dfff08f 100755 --- a/build-js.sh +++ b/build-js.sh @@ -223,7 +223,7 @@ export_function "_BinaryenAtomicFenceId" export_function "_BinaryenSIMDExtractId" export_function "_BinaryenSIMDReplaceId" export_function "_BinaryenSIMDShuffleId" -export_function "_BinaryenSIMDBitselectId" +export_function "_BinaryenSIMDTernaryId" export_function "_BinaryenSIMDShiftId" export_function "_BinaryenMemoryInitId" export_function "_BinaryenDataDropId" @@ -522,6 +522,10 @@ export_function "_BinaryenSubVecI64x2" export_function "_BinaryenAbsVecF32x4" export_function "_BinaryenNegVecF32x4" export_function "_BinaryenSqrtVecF32x4" +export_function "_BinaryenQFMAVecF32x4" +export_function "_BinaryenQFMSVecF32x4" +export_function "_BinaryenQFMAVecF32x4" +export_function "_BinaryenQFMSVecF32x4" export_function "_BinaryenAddVecF32x4" export_function "_BinaryenSubVecF32x4" export_function "_BinaryenMulVecF32x4" @@ -531,6 +535,8 @@ export_function "_BinaryenMaxVecF32x4" export_function "_BinaryenAbsVecF64x2" export_function "_BinaryenNegVecF64x2" export_function "_BinaryenSqrtVecF64x2" +export_function "_BinaryenQFMAVecF64x2" +export_function "_BinaryenQFMSVecF64x2" export_function "_BinaryenAddVecF64x2" export_function "_BinaryenSubVecF64x2" export_function "_BinaryenMulVecF64x2" @@ -582,7 +588,7 @@ export_function "_BinaryenAtomicFence" export_function "_BinaryenSIMDExtract" export_function "_BinaryenSIMDReplace" export_function "_BinaryenSIMDShuffle" -export_function "_BinaryenSIMDBitselect" +export_function "_BinaryenSIMDTernary" export_function "_BinaryenSIMDShift" export_function "_BinaryenMemoryInit" export_function "_BinaryenDataDrop" @@ -744,10 +750,11 @@ export_function "_BinaryenSIMDShuffleGetLeft" export_function "_BinaryenSIMDShuffleGetRight" export_function "_BinaryenSIMDShuffleGetMask" -# 'SIMDBitselect' expression operations -export_function "_BinaryenSIMDBitselectGetLeft" -export_function "_BinaryenSIMDBitselectGetRight" -export_function "_BinaryenSIMDBitselectGetCond" +# 'SIMDTernary' expression operations +export_function "_BinaryenSIMDTernaryGetOp" +export_function "_BinaryenSIMDTernaryGetA" +export_function "_BinaryenSIMDTernaryGetB" +export_function "_BinaryenSIMDTernaryGetC" # 'SIMDShift' expression operations export_function "_BinaryenSIMDShiftGetOp" diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index 29f822f50..989634d9d 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -355,7 +355,7 @@ instructions = [ ("v128.and", "makeBinary(s, BinaryOp::AndVec128)"), ("v128.or", "makeBinary(s, BinaryOp::OrVec128)"), ("v128.xor", "makeBinary(s, BinaryOp::XorVec128)"), - ("v128.bitselect", "makeSIMDBitselect(s)"), + ("v128.bitselect", "makeSIMDTernary(s, SIMDTernaryOp::Bitselect)"), ("i8x16.neg", "makeUnary(s, UnaryOp::NegVecI8x16)"), ("i8x16.any_true", "makeUnary(s, UnaryOp::AnyTrueVecI8x16)"), ("i8x16.all_true", "makeUnary(s, UnaryOp::AllTrueVecI8x16)"), @@ -402,6 +402,8 @@ instructions = [ ("f32x4.abs", "makeUnary(s, UnaryOp::AbsVecF32x4)"), ("f32x4.neg", "makeUnary(s, UnaryOp::NegVecF32x4)"), ("f32x4.sqrt", "makeUnary(s, UnaryOp::SqrtVecF32x4)"), + ("f32x4.qfma", "makeSIMDTernary(s, SIMDTernaryOp::QFMAF32x4)"), + ("f32x4.qfms", "makeSIMDTernary(s, SIMDTernaryOp::QFMSF32x4)"), ("f32x4.add", "makeBinary(s, BinaryOp::AddVecF32x4)"), ("f32x4.sub", "makeBinary(s, BinaryOp::SubVecF32x4)"), ("f32x4.mul", "makeBinary(s, BinaryOp::MulVecF32x4)"), @@ -411,6 +413,8 @@ instructions = [ ("f64x2.abs", "makeUnary(s, UnaryOp::AbsVecF64x2)"), ("f64x2.neg", "makeUnary(s, UnaryOp::NegVecF64x2)"), ("f64x2.sqrt", "makeUnary(s, UnaryOp::SqrtVecF64x2)"), + ("f64x2.qfma", "makeSIMDTernary(s, SIMDTernaryOp::QFMAF64x2)"), + ("f64x2.qfms", "makeSIMDTernary(s, SIMDTernaryOp::QFMSF64x2)"), ("f64x2.add", "makeBinary(s, BinaryOp::AddVecF64x2)"), ("f64x2.sub", "makeBinary(s, BinaryOp::SubVecF64x2)"), ("f64x2.mul", "makeBinary(s, BinaryOp::MulVecF64x2)"), diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index cbaa513ac..b991f39fa 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -343,8 +343,8 @@ BinaryenExpressionId BinaryenSIMDReplaceId(void) { BinaryenExpressionId BinaryenSIMDShuffleId(void) { return Expression::Id::SIMDShuffleId; } -BinaryenExpressionId BinaryenSIMDBitselectId(void) { - return Expression::Id::SIMDBitselectId; +BinaryenExpressionId BinaryenSIMDTernaryId(void) { + return Expression::Id::SIMDTernaryId; } BinaryenExpressionId BinaryenSIMDShiftId(void) { return Expression::Id::SIMDShiftId; @@ -790,6 +790,7 @@ BinaryenOp BinaryenNotVec128(void) { return NotVec128; } BinaryenOp BinaryenAndVec128(void) { return AndVec128; } BinaryenOp BinaryenOrVec128(void) { return OrVec128; } BinaryenOp BinaryenXorVec128(void) { return XorVec128; } +BinaryenOp BinaryenBitselectVec128(void) { return Bitselect; } BinaryenOp BinaryenNegVecI8x16(void) { return NegVecI8x16; } BinaryenOp BinaryenAnyTrueVecI8x16(void) { return AnyTrueVecI8x16; } BinaryenOp BinaryenAllTrueVecI8x16(void) { return AllTrueVecI8x16; } @@ -836,6 +837,8 @@ BinaryenOp BinaryenSubVecI64x2(void) { return SubVecI64x2; } BinaryenOp BinaryenAbsVecF32x4(void) { return AbsVecF32x4; } BinaryenOp BinaryenNegVecF32x4(void) { return NegVecF32x4; } BinaryenOp BinaryenSqrtVecF32x4(void) { return SqrtVecF32x4; } +BinaryenOp BinaryenQFMAVecF32x4(void) { return QFMAF32x4; } +BinaryenOp BinaryenQFMSVecF32x4(void) { return QFMSF32x4; } BinaryenOp BinaryenAddVecF32x4(void) { return AddVecF32x4; } BinaryenOp BinaryenSubVecF32x4(void) { return SubVecF32x4; } BinaryenOp BinaryenMulVecF32x4(void) { return MulVecF32x4; } @@ -845,6 +848,8 @@ BinaryenOp BinaryenMaxVecF32x4(void) { return MaxVecF32x4; } BinaryenOp BinaryenAbsVecF64x2(void) { return AbsVecF64x2; } BinaryenOp BinaryenNegVecF64x2(void) { return NegVecF64x2; } BinaryenOp BinaryenSqrtVecF64x2(void) { return SqrtVecF64x2; } +BinaryenOp BinaryenQFMAVecF64x2(void) { return QFMAF64x2; } +BinaryenOp BinaryenQFMSVecF64x2(void) { return QFMSF64x2; } BinaryenOp BinaryenAddVecF64x2(void) { return AddVecF64x2; } BinaryenOp BinaryenSubVecF64x2(void) { return SubVecF64x2; } BinaryenOp BinaryenMulVecF64x2(void) { return MulVecF64x2; } @@ -1532,15 +1537,17 @@ BinaryenExpressionRef BinaryenSIMDShuffle(BinaryenModuleRef module, } return static_cast<Expression*>(ret); } -BinaryenExpressionRef BinaryenSIMDBitselect(BinaryenModuleRef module, - BinaryenExpressionRef left, - BinaryenExpressionRef right, - BinaryenExpressionRef cond) { - auto* ret = Builder(*(Module*)module) - .makeSIMDBitselect( - (Expression*)left, (Expression*)right, (Expression*)cond); +BinaryenExpressionRef BinaryenSIMDTernary(BinaryenModuleRef module, + BinaryenOp op, + BinaryenExpressionRef a, + BinaryenExpressionRef b, + BinaryenExpressionRef c) { + auto* ret = + Builder(*(Module*)module) + .makeSIMDTernary( + SIMDTernaryOp(op), (Expression*)a, (Expression*)b, (Expression*)c); if (tracing) { - traceExpression(ret, "BinaryenSIMDBitselect", left, right, cond); + traceExpression(ret, "BinaryenSIMDTernary", op, a, b, c); } return static_cast<Expression*>(ret); } @@ -2652,37 +2659,46 @@ void BinaryenSIMDShuffleGetMask(BinaryenExpressionRef expr, uint8_t* mask) { assert(expression->is<SIMDShuffle>()); memcpy(mask, static_cast<SIMDShuffle*>(expression)->mask.data(), 16); } -// SIMDBitselect -BinaryenExpressionRef BinaryenSIMDBitselectGetLeft(BinaryenExpressionRef expr) { +// SIMDTernary +BinaryenOp BinaryenSIMDTernaryGetOp(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenSIMDBitselectGetLeft(expressions[" - << expressions[expr] << "]);\n"; + std::cout << " BinaryenSIMDTernaryOp(expressions[" << expressions[expr] + << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<SIMDBitselect>()); - return static_cast<SIMDBitselect*>(expression)->left; + assert(expression->is<SIMDTernary>()); + return static_cast<SIMDTernary*>(expression)->op; } -BinaryenExpressionRef -BinaryenSIMDBitselectGetRight(BinaryenExpressionRef expr) { +BinaryenExpressionRef BinaryenSIMDTernaryGetA(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenSIMDBitselectGetRight(expressions[" - << expressions[expr] << "]);\n"; + std::cout << " BinaryenSIMDTernaryGetA(expressions[" << expressions[expr] + << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<SIMDBitselect>()); - return static_cast<SIMDBitselect*>(expression)->right; + assert(expression->is<SIMDTernary>()); + return static_cast<SIMDTernary*>(expression)->a; } -BinaryenExpressionRef BinaryenSIMDBitselectGetCond(BinaryenExpressionRef expr) { +BinaryenExpressionRef BinaryenSIMDTernaryGetB(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenSIMDBitselectGetCond(expressions[" - << expressions[expr] << "]);\n"; + std::cout << " BinaryenSIMDTernaryGetB(expressions[" << expressions[expr] + << "]);\n"; + } + + auto* expression = (Expression*)expr; + assert(expression->is<SIMDTernary>()); + return static_cast<SIMDTernary*>(expression)->b; +} +BinaryenExpressionRef BinaryenSIMDTernaryGetC(BinaryenExpressionRef expr) { + if (tracing) { + std::cout << " BinaryenSIMDTernaryGetC(expressions[" << expressions[expr] + << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<SIMDBitselect>()); - return static_cast<SIMDBitselect*>(expression)->cond; + assert(expression->is<SIMDTernary>()); + return static_cast<SIMDTernary*>(expression)->c; } // SIMDShift BinaryenOp BinaryenSIMDShiftGetOp(BinaryenExpressionRef expr) { diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 451dcf23f..396ee2e8d 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -123,7 +123,7 @@ BinaryenExpressionId BinaryenAtomicFenceId(void); BinaryenExpressionId BinaryenSIMDExtractId(void); BinaryenExpressionId BinaryenSIMDReplaceId(void); BinaryenExpressionId BinaryenSIMDShuffleId(void); -BinaryenExpressionId BinaryenSIMDBitselectId(void); +BinaryenExpressionId BinaryenSIMDTernaryId(void); BinaryenExpressionId BinaryenSIMDShiftId(void); BinaryenExpressionId BinaryenMemoryInitId(void); BinaryenExpressionId BinaryenDataDropId(void); @@ -486,6 +486,8 @@ BinaryenOp BinaryenSubVecI64x2(void); BinaryenOp BinaryenAbsVecF32x4(void); BinaryenOp BinaryenNegVecF32x4(void); BinaryenOp BinaryenSqrtVecF32x4(void); +BinaryenOp BinaryenQFMAVecF32x4(void); +BinaryenOp BinaryenQFMSVecF32x4(void); BinaryenOp BinaryenAddVecF32x4(void); BinaryenOp BinaryenSubVecF32x4(void); BinaryenOp BinaryenMulVecF32x4(void); @@ -495,6 +497,8 @@ BinaryenOp BinaryenMaxVecF32x4(void); BinaryenOp BinaryenAbsVecF64x2(void); BinaryenOp BinaryenNegVecF64x2(void); BinaryenOp BinaryenSqrtVecF64x2(void); +BinaryenOp BinaryenQFMAVecF64x2(void); +BinaryenOp BinaryenQFMSVecF64x2(void); BinaryenOp BinaryenAddVecF64x2(void); BinaryenOp BinaryenSubVecF64x2(void); BinaryenOp BinaryenMulVecF64x2(void); @@ -687,10 +691,11 @@ BinaryenExpressionRef BinaryenSIMDShuffle(BinaryenModuleRef module, BinaryenExpressionRef left, BinaryenExpressionRef right, const uint8_t mask[16]); -BinaryenExpressionRef BinaryenSIMDBitselect(BinaryenModuleRef module, - BinaryenExpressionRef left, - BinaryenExpressionRef right, - BinaryenExpressionRef cond); +BinaryenExpressionRef BinaryenSIMDTernary(BinaryenModuleRef module, + BinaryenOp op, + BinaryenExpressionRef a, + BinaryenExpressionRef b, + BinaryenExpressionRef c); BinaryenExpressionRef BinaryenSIMDShift(BinaryenModuleRef module, BinaryenOp op, BinaryenExpressionRef vec, @@ -856,9 +861,10 @@ BinaryenExpressionRef BinaryenSIMDShuffleGetLeft(BinaryenExpressionRef expr); BinaryenExpressionRef BinaryenSIMDShuffleGetRight(BinaryenExpressionRef expr); void BinaryenSIMDShuffleGetMask(BinaryenExpressionRef expr, uint8_t* mask); -BinaryenExpressionRef BinaryenSIMDBitselectGetLeft(BinaryenExpressionRef expr); -BinaryenExpressionRef BinaryenSIMDBitselectGetRight(BinaryenExpressionRef expr); -BinaryenExpressionRef BinaryenSIMDBitselectGetCond(BinaryenExpressionRef expr); +BinaryenOp BinaryenSIMDTernaryGetOp(BinaryenExpressionRef expr); +BinaryenExpressionRef BinaryenSIMDTernaryGetA(BinaryenExpressionRef expr); +BinaryenExpressionRef BinaryenSIMDTernaryGetB(BinaryenExpressionRef expr); +BinaryenExpressionRef BinaryenSIMDTernaryGetC(BinaryenExpressionRef expr); BinaryenOp BinaryenSIMDShiftGetOp(BinaryenExpressionRef expr); BinaryenExpressionRef BinaryenSIMDShiftGetVec(BinaryenExpressionRef expr); diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 68a8140a6..08d911aef 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -338,6 +338,17 @@ switch (op[0]) { default: goto parse_error; } } + case 'q': { + switch (op[9]) { + case 'a': + if (strcmp(op, "f32x4.qfma") == 0) { return makeSIMDTernary(s, SIMDTernaryOp::QFMAF32x4); } + goto parse_error; + case 's': + if (strcmp(op, "f32x4.qfms") == 0) { return makeSIMDTernary(s, SIMDTernaryOp::QFMSF32x4); } + goto parse_error; + default: goto parse_error; + } + } case 'r': if (strcmp(op, "f32x4.replace_lane") == 0) { return makeSIMDReplace(s, SIMDReplaceOp::ReplaceLaneVecF32x4, 4); } goto parse_error; @@ -608,6 +619,17 @@ switch (op[0]) { default: goto parse_error; } } + case 'q': { + switch (op[9]) { + case 'a': + if (strcmp(op, "f64x2.qfma") == 0) { return makeSIMDTernary(s, SIMDTernaryOp::QFMAF64x2); } + goto parse_error; + case 's': + if (strcmp(op, "f64x2.qfms") == 0) { return makeSIMDTernary(s, SIMDTernaryOp::QFMSF64x2); } + goto parse_error; + default: goto parse_error; + } + } case 'r': if (strcmp(op, "f64x2.replace_lane") == 0) { return makeSIMDReplace(s, SIMDReplaceOp::ReplaceLaneVecF64x2, 2); } goto parse_error; @@ -2315,7 +2337,7 @@ switch (op[0]) { if (strcmp(op, "v128.and") == 0) { return makeBinary(s, BinaryOp::AndVec128); } goto parse_error; case 'b': - if (strcmp(op, "v128.bitselect") == 0) { return makeSIMDBitselect(s); } + if (strcmp(op, "v128.bitselect") == 0) { return makeSIMDTernary(s, SIMDTernaryOp::Bitselect); } goto parse_error; case 'c': if (strcmp(op, "v128.const") == 0) { return makeConst(s, v128); } diff --git a/src/ir/ExpressionAnalyzer.cpp b/src/ir/ExpressionAnalyzer.cpp index a52d7af90..ee3cb0123 100644 --- a/src/ir/ExpressionAnalyzer.cpp +++ b/src/ir/ExpressionAnalyzer.cpp @@ -194,7 +194,7 @@ template<typename T> void visitImmediates(Expression* curr, T& visitor) { visitor.visitInt(x); } } - void visitSIMDBitselect(SIMDBitselect* curr) {} + void visitSIMDTernary(SIMDTernary* curr) { visitor.visitInt(curr->op); } void visitSIMDShift(SIMDShift* curr) { visitor.visitInt(curr->op); } void visitMemoryInit(MemoryInit* curr) { visitor.visitIndex(curr->segment); diff --git a/src/ir/ExpressionManipulator.cpp b/src/ir/ExpressionManipulator.cpp index 7b0ee29d7..7c4de4ceb 100644 --- a/src/ir/ExpressionManipulator.cpp +++ b/src/ir/ExpressionManipulator.cpp @@ -171,9 +171,9 @@ flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) { return builder.makeSIMDShuffle( copy(curr->left), copy(curr->right), curr->mask); } - Expression* visitSIMDBitselect(SIMDBitselect* curr) { - return builder.makeSIMDBitselect( - copy(curr->left), copy(curr->right), copy(curr->cond)); + Expression* visitSIMDTernary(SIMDTernary* curr) { + return builder.makeSIMDTernary( + curr->op, copy(curr->a), copy(curr->b), copy(curr->c)); } Expression* visitSIMDShift(SIMDShift* curr) { return builder.makeSIMDShift( diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp index 49b70684b..6c4e7a447 100644 --- a/src/ir/ReFinalize.cpp +++ b/src/ir/ReFinalize.cpp @@ -145,7 +145,7 @@ void ReFinalize::visitAtomicFence(AtomicFence* curr) { curr->finalize(); } void ReFinalize::visitSIMDExtract(SIMDExtract* curr) { curr->finalize(); } void ReFinalize::visitSIMDReplace(SIMDReplace* curr) { curr->finalize(); } void ReFinalize::visitSIMDShuffle(SIMDShuffle* curr) { curr->finalize(); } -void ReFinalize::visitSIMDBitselect(SIMDBitselect* curr) { curr->finalize(); } +void ReFinalize::visitSIMDTernary(SIMDTernary* curr) { curr->finalize(); } void ReFinalize::visitSIMDShift(SIMDShift* curr) { curr->finalize(); } void ReFinalize::visitMemoryInit(MemoryInit* curr) { curr->finalize(); } void ReFinalize::visitDataDrop(DataDrop* curr) { curr->finalize(); } diff --git a/src/ir/effects.h b/src/ir/effects.h index c175bed85..dcee4404b 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -305,7 +305,7 @@ struct EffectAnalyzer void visitSIMDExtract(SIMDExtract* curr) {} void visitSIMDReplace(SIMDReplace* curr) {} void visitSIMDShuffle(SIMDShuffle* curr) {} - void visitSIMDBitselect(SIMDBitselect* curr) {} + void visitSIMDTernary(SIMDTernary* curr) {} void visitSIMDShift(SIMDShift* curr) {} void visitMemoryInit(MemoryInit* curr) { writesMemory = true; diff --git a/src/ir/utils.h b/src/ir/utils.h index 43ba2fdde..4ca80caa3 100644 --- a/src/ir/utils.h +++ b/src/ir/utils.h @@ -132,7 +132,7 @@ struct ReFinalize void visitSIMDExtract(SIMDExtract* curr); void visitSIMDReplace(SIMDReplace* curr); void visitSIMDShuffle(SIMDShuffle* curr); - void visitSIMDBitselect(SIMDBitselect* curr); + void visitSIMDTernary(SIMDTernary* curr); void visitSIMDShift(SIMDShift* curr); void visitMemoryInit(MemoryInit* curr); void visitDataDrop(DataDrop* curr); @@ -196,7 +196,7 @@ struct ReFinalizeNode : public OverriddenVisitor<ReFinalizeNode> { void visitSIMDExtract(SIMDExtract* curr) { curr->finalize(); } void visitSIMDReplace(SIMDReplace* curr) { curr->finalize(); } void visitSIMDShuffle(SIMDShuffle* curr) { curr->finalize(); } - void visitSIMDBitselect(SIMDBitselect* curr) { curr->finalize(); } + void visitSIMDTernary(SIMDTernary* curr) { curr->finalize(); } void visitSIMDShift(SIMDShift* curr) { curr->finalize(); } void visitMemoryInit(MemoryInit* curr) { curr->finalize(); } void visitDataDrop(DataDrop* curr) { curr->finalize(); } diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 30a023b2c..bb5e4b21e 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -74,7 +74,7 @@ Module['AtomicFenceId'] = Module['_BinaryenAtomicFenceId'](); Module['SIMDExtractId'] = Module['_BinaryenSIMDExtractId'](); Module['SIMDReplaceId'] = Module['_BinaryenSIMDReplaceId'](); Module['SIMDShuffleId'] = Module['_BinaryenSIMDShuffleId'](); -Module['SIMDBitselectId'] = Module['_BinaryenSIMDBitselectId'](); +Module['SIMDTernaryId'] = Module['_BinaryenSIMDTernaryId'](); Module['SIMDShiftId'] = Module['_BinaryenSIMDShiftId'](); Module['MemoryInitId'] = Module['_BinaryenMemoryInitId'](); Module['DataDropId'] = Module['_BinaryenDataDropId'](); @@ -366,6 +366,8 @@ Module['SubVecI64x2'] = Module['_BinaryenSubVecI64x2'](); Module['AbsVecF32x4'] = Module['_BinaryenAbsVecF32x4'](); Module['NegVecF32x4'] = Module['_BinaryenNegVecF32x4'](); Module['SqrtVecF32x4'] = Module['_BinaryenSqrtVecF32x4'](); +Module['QFMAVecF32x4'] = Module['_BinaryenQFMAVecF32x4'](); +Module['QFMSVecF32x4'] = Module['_BinaryenQFMSVecF32x4'](); Module['AddVecF32x4'] = Module['_BinaryenAddVecF32x4'](); Module['SubVecF32x4'] = Module['_BinaryenSubVecF32x4'](); Module['MulVecF32x4'] = Module['_BinaryenMulVecF32x4'](); @@ -375,6 +377,8 @@ Module['MaxVecF32x4'] = Module['_BinaryenMaxVecF32x4'](); Module['AbsVecF64x2'] = Module['_BinaryenAbsVecF64x2'](); Module['NegVecF64x2'] = Module['_BinaryenNegVecF64x2'](); Module['SqrtVecF64x2'] = Module['_BinaryenSqrtVecF64x2'](); +Module['QFMAVecF64x2'] = Module['_BinaryenQFMAVecF64x2'](); +Module['QFMSVecF64x2'] = Module['_BinaryenQFMSVecF64x2'](); Module['AddVecF64x2'] = Module['_BinaryenAddVecF64x2'](); Module['SubVecF64x2'] = Module['_BinaryenSubVecF64x2'](); Module['MulVecF64x2'] = Module['_BinaryenMulVecF64x2'](); @@ -1323,7 +1327,7 @@ function wrapModule(module, self) { return Module['_BinaryenUnary'](module, Module['XorVec128'], value); }, 'bitselect': function(left, right, cond) { - return Module['_BinaryenSIMDBitselect'](module, left, right, cond); + return Module['_BinaryenSIMDTernary'](module, Module['Bitselect'], left, right, cond); }, 'pop': function() { return Module['_BinaryenPop'](module, Module['v128']); @@ -1660,6 +1664,12 @@ function wrapModule(module, self) { 'sqrt': function(value) { return Module['_BinaryenUnary'](module, Module['SqrtVecF32x4'], value); }, + 'qfma': function(a, b, c) { + return Module['_BinaryenSIMDTernary'](module, Module['QFMAVecF32x4'], a, b, c); + }, + 'qfms': function(a, b, c) { + return Module['_BinaryenSIMDTernary'](module, Module['QFMSVecF32x4'], a, b, c); + }, 'add': function(left, right) { return Module['_BinaryenBinary'](module, Module['AddVecF32x4'], left, right); }, @@ -1723,6 +1733,12 @@ function wrapModule(module, self) { 'sqrt': function(value) { return Module['_BinaryenUnary'](module, Module['SqrtVecF64x2'], value); }, + 'qfma': function(a, b, c) { + return Module['_BinaryenSIMDTernary'](module, Module['QFMAVecF64x2'], a, b, c); + }, + 'qfms': function(a, b, c) { + return Module['_BinaryenSIMDTernary'](module, Module['QFMSVecF64x2'], a, b, c); + }, 'add': function(left, right) { return Module['_BinaryenBinary'](module, Module['AddVecF64x2'], left, right); }, @@ -2370,13 +2386,14 @@ Module['getExpressionInfo'] = function(expr) { 'mask': mask }; }); - case Module['SIMDBitselectId']: + case Module['SIMDTernaryId']: return { 'id': id, 'type': type, - 'left': Module['_BinaryenSIMDBitselectGetLeft'](expr), - 'right': Module['_BinaryenSIMDBitselectGetRight'](expr), - 'cond': Module['_BinaryenSIMDBitselectGetCond'](expr) + 'op': Module['_BinaryenSIMDTernaryGetOp'](expr), + 'a': Module['_BinaryenSIMDTernaryGetA'](expr), + 'b': Module['_BinaryenSIMDTernaryGetB'](expr), + 'c': Module['_BinaryenSIMDTernaryGetC'](expr) }; case Module['SIMDShiftId']: return { diff --git a/src/passes/DeadCodeElimination.cpp b/src/passes/DeadCodeElimination.cpp index 464451763..1d13ed67c 100644 --- a/src/passes/DeadCodeElimination.cpp +++ b/src/passes/DeadCodeElimination.cpp @@ -306,8 +306,8 @@ struct DeadCodeElimination DELEGATE(SIMDReplace); case Expression::Id::SIMDShuffleId: DELEGATE(SIMDShuffle); - case Expression::Id::SIMDBitselectId: - DELEGATE(SIMDBitselect); + case Expression::Id::SIMDTernaryId: + DELEGATE(SIMDTernary); case Expression::Id::SIMDShiftId: DELEGATE(SIMDShift); case Expression::Id::MemoryInitId: diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index b1e1240ae..ad4d20bae 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -330,9 +330,25 @@ struct PrintExpressionContents o << " " << std::to_string(mask_index); } } - void visitSIMDBitselect(SIMDBitselect* curr) { + void visitSIMDTernary(SIMDTernary* curr) { prepareColor(o); - o << "v128.bitselect"; + switch (curr->op) { + case Bitselect: + o << "v128.bitselect"; + break; + case QFMAF32x4: + o << "f32x4.qfma"; + break; + case QFMSF32x4: + o << "f32x4.qfms"; + break; + case QFMAF64x2: + o << "f64x2.qfma"; + break; + case QFMSF64x2: + o << "f64x2.qfms"; + break; + } } void visitSIMDShift(SIMDShift* curr) { prepareColor(o); @@ -1534,13 +1550,13 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { printFullLine(curr->right); decIndent(); } - void visitSIMDBitselect(SIMDBitselect* curr) { + void visitSIMDTernary(SIMDTernary* curr) { o << '('; PrintExpressionContents(currFunction, o).visit(curr); incIndent(); - printFullLine(curr->left); - printFullLine(curr->right); - printFullLine(curr->cond); + printFullLine(curr->a); + printFullLine(curr->b); + printFullLine(curr->c); decIndent(); } void visitSIMDShift(SIMDShift* curr) { diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index dde8a0de7..82a269740 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -2336,7 +2336,7 @@ private: case 3: return makeSIMDShuffle(); case 4: - return makeSIMDBitselect(); + return makeSIMDTernary(); case 5: return makeSIMDShift(); } @@ -2444,11 +2444,18 @@ private: return builder.makeSIMDShuffle(left, right, mask); } - Expression* makeSIMDBitselect() { - Expression* left = make(v128); - Expression* right = make(v128); - Expression* cond = make(v128); - return builder.makeSIMDBitselect(left, right, cond); + Expression* makeSIMDTernary() { + // TODO: Enable qfma/qfms once it is implemented in V8 and the interpreter + // SIMDTernaryOp op = pick(Bitselect, + // QFMAF32x4, + // QFMSF32x4, + // QFMAF64x2, + // QFMSF64x2); + SIMDTernaryOp op = Bitselect; + Expression* a = make(v128); + Expression* b = make(v128); + Expression* c = make(v128); + return builder.makeSIMDTernary(op, a, b, c); } Expression* makeSIMDShift() { diff --git a/src/wasm-binary.h b/src/wasm-binary.h index b3ac336ee..1c5fa774a 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -829,6 +829,8 @@ enum ASTNodes { F32x4Abs = 0x95, F32x4Neg = 0x96, F32x4Sqrt = 0x97, + F32x4QFMA = 0x98, + F32x4QFMS = 0x99, F32x4Add = 0x9a, F32x4Sub = 0x9b, F32x4Mul = 0x9c, @@ -838,6 +840,8 @@ enum ASTNodes { F64x2Abs = 0xa0, F64x2Neg = 0xa1, F64x2Sqrt = 0xa2, + F64x2QFMA = 0xa3, + F64x2QFMS = 0xa4, F64x2Add = 0xa5, F64x2Sub = 0xa6, F64x2Mul = 0xa7, @@ -1246,7 +1250,7 @@ public: bool maybeVisitSIMDExtract(Expression*& out, uint32_t code); bool maybeVisitSIMDReplace(Expression*& out, uint32_t code); bool maybeVisitSIMDShuffle(Expression*& out, uint32_t code); - bool maybeVisitSIMDBitselect(Expression*& out, uint32_t code); + bool maybeVisitSIMDTernary(Expression*& out, uint32_t code); bool maybeVisitSIMDShift(Expression*& out, uint32_t code); bool maybeVisitMemoryInit(Expression*& out, uint32_t code); bool maybeVisitDataDrop(Expression*& out, uint32_t code); diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 3e61b1a36..c2f1e41b6 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -400,12 +400,15 @@ public: ret->finalize(); return ret; } - SIMDBitselect* - makeSIMDBitselect(Expression* left, Expression* right, Expression* cond) { - auto* ret = allocator.alloc<SIMDBitselect>(); - ret->left = left; - ret->right = right; - ret->cond = cond; + SIMDTernary* makeSIMDTernary(SIMDTernaryOp op, + Expression* a, + Expression* b, + Expression* c) { + auto* ret = allocator.alloc<SIMDTernary>(); + ret->op = op; + ret->a = a; + ret->b = b; + ret->c = c; ret->finalize(); return ret; } diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index d854b20d3..2c4496f3f 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -863,24 +863,30 @@ public: Literal right = flow.value; return left.shuffleV8x16(right, curr->mask); } - Flow visitSIMDBitselect(SIMDBitselect* curr) { + Flow visitSIMDTernary(SIMDTernary* curr) { NOTE_ENTER("SIMDBitselect"); - Flow flow = this->visit(curr->left); + Flow flow = this->visit(curr->a); if (flow.breaking()) { return flow; } - Literal left = flow.value; - flow = this->visit(curr->right); + Literal a = flow.value; + flow = this->visit(curr->b); if (flow.breaking()) { return flow; } - Literal right = flow.value; - flow = this->visit(curr->cond); + Literal b = flow.value; + flow = this->visit(curr->c); if (flow.breaking()) { return flow; } - Literal cond = flow.value; - return cond.bitselectV128(left, right); + Literal c = flow.value; + switch (curr->op) { + case Bitselect: + return c.bitselectV128(a, b); + default: + // TODO: implement qfma/qfms + WASM_UNREACHABLE(); + } } Flow visitSIMDShift(SIMDShift* curr) { NOTE_ENTER("SIMDShift"); diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index b6ef320d5..67035f0ff 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -198,7 +198,7 @@ private: Expression* makeSIMDExtract(Element& s, SIMDExtractOp op, size_t lanes); Expression* makeSIMDReplace(Element& s, SIMDReplaceOp op, size_t lanes); Expression* makeSIMDShuffle(Element& s); - Expression* makeSIMDBitselect(Element& s); + Expression* makeSIMDTernary(Element& s, SIMDTernaryOp op); Expression* makeSIMDShift(Element& s, SIMDShiftOp op); Expression* makeMemoryInit(Element& s); Expression* makeDataDrop(Element& s); diff --git a/src/wasm-stack.h b/src/wasm-stack.h index 3a7d7c38e..4b0ffde40 100644 --- a/src/wasm-stack.h +++ b/src/wasm-stack.h @@ -107,7 +107,7 @@ public: void visitSIMDExtract(SIMDExtract* curr); void visitSIMDReplace(SIMDReplace* curr); void visitSIMDShuffle(SIMDShuffle* curr); - void visitSIMDBitselect(SIMDBitselect* curr); + void visitSIMDTernary(SIMDTernary* curr); void visitSIMDShift(SIMDShift* curr); void visitMemoryInit(MemoryInit* curr); void visitDataDrop(DataDrop* curr); @@ -183,7 +183,7 @@ public: void visitSIMDExtract(SIMDExtract* curr); void visitSIMDReplace(SIMDReplace* curr); void visitSIMDShuffle(SIMDShuffle* curr); - void visitSIMDBitselect(SIMDBitselect* curr); + void visitSIMDTernary(SIMDTernary* curr); void visitSIMDShift(SIMDShift* curr); void visitMemoryInit(MemoryInit* curr); void visitDataDrop(DataDrop* curr); @@ -565,10 +565,10 @@ void BinaryenIRWriter<SubType>::visitSIMDShuffle(SIMDShuffle* curr) { } template<typename SubType> -void BinaryenIRWriter<SubType>::visitSIMDBitselect(SIMDBitselect* curr) { - visit(curr->left); - visit(curr->right); - visit(curr->cond); +void BinaryenIRWriter<SubType>::visitSIMDTernary(SIMDTernary* curr) { + visit(curr->a); + visit(curr->b); + visit(curr->c); if (curr->type == unreachable) { emitUnreachable(); return; diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h index 202d136c8..06ab69615 100644 --- a/src/wasm-traversal.h +++ b/src/wasm-traversal.h @@ -58,7 +58,7 @@ template<typename SubType, typename ReturnType = void> struct Visitor { ReturnType visitSIMDExtract(SIMDExtract* curr) { return ReturnType(); } ReturnType visitSIMDReplace(SIMDReplace* curr) { return ReturnType(); } ReturnType visitSIMDShuffle(SIMDShuffle* curr) { return ReturnType(); } - ReturnType visitSIMDBitselect(SIMDBitselect* curr) { return ReturnType(); } + ReturnType visitSIMDTernary(SIMDTernary* curr) { return ReturnType(); } ReturnType visitSIMDShift(SIMDShift* curr) { return ReturnType(); } ReturnType visitMemoryInit(MemoryInit* curr) { return ReturnType(); } ReturnType visitDataDrop(DataDrop* curr) { return ReturnType(); } @@ -139,8 +139,8 @@ template<typename SubType, typename ReturnType = void> struct Visitor { DELEGATE(SIMDReplace); case Expression::Id::SIMDShuffleId: DELEGATE(SIMDShuffle); - case Expression::Id::SIMDBitselectId: - DELEGATE(SIMDBitselect); + case Expression::Id::SIMDTernaryId: + DELEGATE(SIMDTernary); case Expression::Id::SIMDShiftId: DELEGATE(SIMDShift); case Expression::Id::MemoryInitId: @@ -225,7 +225,7 @@ struct OverriddenVisitor { UNIMPLEMENTED(SIMDExtract); UNIMPLEMENTED(SIMDReplace); UNIMPLEMENTED(SIMDShuffle); - UNIMPLEMENTED(SIMDBitselect); + UNIMPLEMENTED(SIMDTernary); UNIMPLEMENTED(SIMDShift); UNIMPLEMENTED(MemoryInit); UNIMPLEMENTED(DataDrop); @@ -307,8 +307,8 @@ struct OverriddenVisitor { DELEGATE(SIMDReplace); case Expression::Id::SIMDShuffleId: DELEGATE(SIMDShuffle); - case Expression::Id::SIMDBitselectId: - DELEGATE(SIMDBitselect); + case Expression::Id::SIMDTernaryId: + DELEGATE(SIMDTernary); case Expression::Id::SIMDShiftId: DELEGATE(SIMDShift); case Expression::Id::MemoryInitId: @@ -430,7 +430,7 @@ struct UnifiedExpressionVisitor : public Visitor<SubType, ReturnType> { ReturnType visitSIMDShuffle(SIMDShuffle* curr) { return static_cast<SubType*>(this)->visitExpression(curr); } - ReturnType visitSIMDBitselect(SIMDBitselect* curr) { + ReturnType visitSIMDTernary(SIMDTernary* curr) { return static_cast<SubType*>(this)->visitExpression(curr); } ReturnType visitSIMDShift(SIMDShift* curr) { @@ -732,8 +732,8 @@ struct Walker : public VisitorType { static void doVisitSIMDShuffle(SubType* self, Expression** currp) { self->visitSIMDShuffle((*currp)->cast<SIMDShuffle>()); } - static void doVisitSIMDBitselect(SubType* self, Expression** currp) { - self->visitSIMDBitselect((*currp)->cast<SIMDBitselect>()); + static void doVisitSIMDTernary(SubType* self, Expression** currp) { + self->visitSIMDTernary((*currp)->cast<SIMDTernary>()); } static void doVisitSIMDShift(SubType* self, Expression** currp) { self->visitSIMDShift((*currp)->cast<SIMDShift>()); @@ -946,11 +946,11 @@ struct PostWalker : public Walker<SubType, VisitorType> { self->pushTask(SubType::scan, &curr->cast<SIMDShuffle>()->left); break; } - case Expression::Id::SIMDBitselectId: { - self->pushTask(SubType::doVisitSIMDBitselect, currp); - self->pushTask(SubType::scan, &curr->cast<SIMDBitselect>()->cond); - self->pushTask(SubType::scan, &curr->cast<SIMDBitselect>()->right); - self->pushTask(SubType::scan, &curr->cast<SIMDBitselect>()->left); + case Expression::Id::SIMDTernaryId: { + self->pushTask(SubType::doVisitSIMDTernary, currp); + self->pushTask(SubType::scan, &curr->cast<SIMDTernary>()->c); + self->pushTask(SubType::scan, &curr->cast<SIMDTernary>()->b); + self->pushTask(SubType::scan, &curr->cast<SIMDTernary>()->a); break; } case Expression::Id::SIMDShiftId: { diff --git a/src/wasm.h b/src/wasm.h index e7d83ace3..9c0f5dec8 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -417,6 +417,8 @@ enum SIMDShiftOp { ShrUVecI64x2 }; +enum SIMDTernaryOp { Bitselect, QFMAF32x4, QFMSF32x4, QFMAF64x2, QFMSF64x2 }; + // // Expressions // @@ -472,7 +474,7 @@ public: SIMDExtractId, SIMDReplaceId, SIMDShuffleId, - SIMDBitselectId, + SIMDTernaryId, SIMDShiftId, MemoryInitId, DataDropId, @@ -834,14 +836,15 @@ public: void finalize(); }; -class SIMDBitselect : public SpecificExpression<Expression::SIMDBitselectId> { +class SIMDTernary : public SpecificExpression<Expression::SIMDTernaryId> { public: - SIMDBitselect() = default; - SIMDBitselect(MixedArena& allocator) : SIMDBitselect() {} + SIMDTernary() = default; + SIMDTernary(MixedArena& allocator) : SIMDTernary() {} - Expression* left; - Expression* right; - Expression* cond; + SIMDTernaryOp op; + Expression* a; + Expression* b; + Expression* c; void finalize(); }; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index b7daeda5a..529a3ff52 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2355,7 +2355,7 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { if (maybeVisitSIMDShuffle(curr, opcode)) { break; } - if (maybeVisitSIMDBitselect(curr, opcode)) { + if (maybeVisitSIMDTernary(curr, opcode)) { break; } if (maybeVisitSIMDShift(curr, opcode)) { @@ -4251,15 +4251,35 @@ bool WasmBinaryBuilder::maybeVisitSIMDShuffle(Expression*& out, uint32_t code) { return true; } -bool WasmBinaryBuilder::maybeVisitSIMDBitselect(Expression*& out, - uint32_t code) { - if (code != BinaryConsts::V128Bitselect) { - return false; +bool WasmBinaryBuilder::maybeVisitSIMDTernary(Expression*& out, uint32_t code) { + SIMDTernary* curr; + switch (code) { + case BinaryConsts::V128Bitselect: + curr = allocator.alloc<SIMDTernary>(); + curr->op = Bitselect; + break; + case BinaryConsts::F32x4QFMA: + curr = allocator.alloc<SIMDTernary>(); + curr->op = QFMAF32x4; + break; + case BinaryConsts::F32x4QFMS: + curr = allocator.alloc<SIMDTernary>(); + curr->op = QFMSF32x4; + break; + case BinaryConsts::F64x2QFMA: + curr = allocator.alloc<SIMDTernary>(); + curr->op = QFMAF64x2; + break; + case BinaryConsts::F64x2QFMS: + curr = allocator.alloc<SIMDTernary>(); + curr->op = QFMSF64x2; + break; + default: + return false; } - auto* curr = allocator.alloc<SIMDBitselect>(); - curr->cond = popNonVoidExpression(); - curr->right = popNonVoidExpression(); - curr->left = popNonVoidExpression(); + curr->c = popNonVoidExpression(); + curr->b = popNonVoidExpression(); + curr->a = popNonVoidExpression(); curr->finalize(); out = curr; return true; diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 3a1e0db09..322c36c45 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1473,11 +1473,13 @@ Expression* SExpressionWasmBuilder::makeSIMDShuffle(Element& s) { return ret; } -Expression* SExpressionWasmBuilder::makeSIMDBitselect(Element& s) { - auto ret = allocator.alloc<SIMDBitselect>(); - ret->left = parseExpression(s[1]); - ret->right = parseExpression(s[2]); - ret->cond = parseExpression(s[3]); +Expression* SExpressionWasmBuilder::makeSIMDTernary(Element& s, + SIMDTernaryOp op) { + auto ret = allocator.alloc<SIMDTernary>(); + ret->op = op; + ret->a = parseExpression(s[1]); + ret->b = parseExpression(s[2]); + ret->c = parseExpression(s[3]); ret->finalize(); return ret; } diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index faa06330b..498a53cb2 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -491,8 +491,25 @@ void BinaryInstWriter::visitSIMDShuffle(SIMDShuffle* curr) { } } -void BinaryInstWriter::visitSIMDBitselect(SIMDBitselect* curr) { - o << int8_t(BinaryConsts::SIMDPrefix) << U32LEB(BinaryConsts::V128Bitselect); +void BinaryInstWriter::visitSIMDTernary(SIMDTernary* curr) { + o << int8_t(BinaryConsts::SIMDPrefix); + switch (curr->op) { + case Bitselect: + o << U32LEB(BinaryConsts::V128Bitselect); + break; + case QFMAF32x4: + o << U32LEB(BinaryConsts::F32x4QFMA); + break; + case QFMSF32x4: + o << U32LEB(BinaryConsts::F32x4QFMS); + break; + case QFMAF64x2: + o << U32LEB(BinaryConsts::F64x2QFMA); + break; + case QFMSF64x2: + o << U32LEB(BinaryConsts::F64x2QFMS); + break; + } } void BinaryInstWriter::visitSIMDShift(SIMDShift* curr) { diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 9b1220371..f2d6c259b 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -274,7 +274,7 @@ public: void visitSIMDExtract(SIMDExtract* curr); void visitSIMDReplace(SIMDReplace* curr); void visitSIMDShuffle(SIMDShuffle* curr); - void visitSIMDBitselect(SIMDBitselect* curr); + void visitSIMDTernary(SIMDTernary* curr); void visitSIMDShift(SIMDShift* curr); void visitMemoryInit(MemoryInit* curr); void visitDataDrop(DataDrop* curr); @@ -1030,17 +1030,17 @@ void FunctionValidator::visitSIMDShuffle(SIMDShuffle* curr) { } } -void FunctionValidator::visitSIMDBitselect(SIMDBitselect* curr) { +void FunctionValidator::visitSIMDTernary(SIMDTernary* curr) { shouldBeTrue( getModule()->features.hasSIMD(), curr, "SIMD operation (SIMD is disabled)"); shouldBeEqualOrFirstIsUnreachable( - curr->type, v128, curr, "v128.bitselect must have type v128"); + curr->type, v128, curr, "SIMD ternary must have type v128"); shouldBeEqualOrFirstIsUnreachable( - curr->left->type, v128, curr, "expected operand of type v128"); + curr->a->type, v128, curr, "expected operand of type v128"); shouldBeEqualOrFirstIsUnreachable( - curr->right->type, v128, curr, "expected operand of type v128"); + curr->b->type, v128, curr, "expected operand of type v128"); shouldBeEqualOrFirstIsUnreachable( - curr->cond->type, v128, curr, "expected operand of type v128"); + curr->c->type, v128, curr, "expected operand of type v128"); } void FunctionValidator::visitSIMDShift(SIMDShift* curr) { diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 1a47327c1..a0b845446 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -157,8 +157,8 @@ const char* getExpressionName(Expression* curr) { return "simd_replace"; case Expression::Id::SIMDShuffleId: return "simd_shuffle"; - case Expression::Id::SIMDBitselectId: - return "simd_bitselect"; + case Expression::Id::SIMDTernaryId: + return "simd_ternary"; case Expression::Id::SIMDShiftId: return "simd_shift"; case Expression::Id::MemoryInitId: @@ -582,11 +582,11 @@ void SIMDShuffle::finalize() { } } -void SIMDBitselect::finalize() { - assert(left && right && cond); +void SIMDTernary::finalize() { + assert(a && b && c); type = v128; - if (left->type == unreachable || right->type == unreachable || - cond->type == unreachable) { + if (a->type == unreachable || b->type == unreachable || + c->type == unreachable) { type = unreachable; } } diff --git a/src/wasm2js.h b/src/wasm2js.h index 1526dbb89..95ba2e154 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -1832,7 +1832,7 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, unimplemented(curr); WASM_UNREACHABLE(); } - Ref visitSIMDBitselect(SIMDBitselect* curr) { + Ref visitSIMDTernary(SIMDTernary* curr) { unimplemented(curr); WASM_UNREACHABLE(); } diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index dd8b87354..463aa33ed 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -108,7 +108,7 @@ function test_ids() { console.log("BinaryenSIMDExtractId: " + Binaryen.SIMDExtractId); console.log("BinaryenSIMDReplaceId: " + Binaryen.SIMDReplaceId); console.log("BinaryenSIMDShuffleId: " + Binaryen.SIMDShuffleId); - console.log("BinaryenSIMDBitselectId: " + Binaryen.SIMDBitselectId); + console.log("BinaryenSIMDTernaryId: " + Binaryen.SIMDTernaryId); console.log("BinaryenSIMDShiftId: " + Binaryen.SIMDShiftId); console.log("MemoryInitId: " + Binaryen.MemoryInitId); console.log("DataDropId: " + Binaryen.DataDropId); @@ -370,6 +370,10 @@ function test_core() { // Other SIMD module.v8x16.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)), + module.f32x4.qfma(module.v128.const(v128_bytes), module.v128.const(v128_bytes), module.v128.const(v128_bytes)), + module.f32x4.qfms(module.v128.const(v128_bytes), module.v128.const(v128_bytes), module.v128.const(v128_bytes)), + module.f64x2.qfma(module.v128.const(v128_bytes), module.v128.const(v128_bytes), module.v128.const(v128_bytes)), + module.f64x2.qfms(module.v128.const(v128_bytes), module.v128.const(v128_bytes), module.v128.const(v128_bytes)), // Bulk memory module.memory.init(0, makeInt32(1024), makeInt32(0), makeInt32(12)), module.data.drop(0), diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 72b7d57be..b60a2d759 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -49,7 +49,7 @@ BinaryenAtomicNotifyId: 26 BinaryenSIMDExtractId: 28 BinaryenSIMDReplaceId: 29 BinaryenSIMDShuffleId: 30 -BinaryenSIMDBitselectId: 31 +BinaryenSIMDTernaryId: 31 BinaryenSIMDShiftId: 32 MemoryInitId: 33 DataDropId: 34 @@ -1284,6 +1284,34 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) ) ) + (drop + (f32x4.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f32x4.qfms + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfms + (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) @@ -2724,6 +2752,34 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) ) ) + (drop + (f32x4.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f32x4.qfms + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfms + (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) @@ -4696,157 +4752,209 @@ int main() { uint8_t t209[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; expressions[576] = BinaryenConst(the_module, BinaryenLiteralVec128(t209)); } - expressions[577] = BinaryenSIMDBitselect(the_module, expressions[574], expressions[575], expressions[576]); - expressions[578] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); - expressions[579] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[580] = BinaryenConst(the_module, BinaryenLiteralInt32(12)); - expressions[581] = BinaryenMemoryInit(the_module, 0, expressions[578], expressions[579], expressions[580]); - expressions[582] = BinaryenDataDrop(the_module, 0); - expressions[583] = BinaryenConst(the_module, BinaryenLiteralInt32(2048)); - expressions[584] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); - expressions[585] = BinaryenConst(the_module, BinaryenLiteralInt32(12)); - expressions[586] = BinaryenMemoryCopy(the_module, expressions[583], expressions[584], expressions[585]); - expressions[587] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[588] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); - expressions[589] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); - expressions[590] = BinaryenMemoryFill(the_module, expressions[587], expressions[588], expressions[589]); + expressions[577] = BinaryenSIMDTernary(the_module, 0, expressions[574], expressions[575], expressions[576]); + { + uint8_t t210[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[578] = BinaryenConst(the_module, BinaryenLiteralVec128(t210)); + } + { + uint8_t t211[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[579] = BinaryenConst(the_module, BinaryenLiteralVec128(t211)); + } + { + uint8_t t212[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[580] = BinaryenConst(the_module, BinaryenLiteralVec128(t212)); + } + expressions[581] = BinaryenSIMDTernary(the_module, 1, expressions[578], expressions[579], expressions[580]); + { + uint8_t t213[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[582] = BinaryenConst(the_module, BinaryenLiteralVec128(t213)); + } + { + uint8_t t214[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[583] = BinaryenConst(the_module, BinaryenLiteralVec128(t214)); + } + { + uint8_t t215[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[584] = BinaryenConst(the_module, BinaryenLiteralVec128(t215)); + } + expressions[585] = BinaryenSIMDTernary(the_module, 2, expressions[582], expressions[583], expressions[584]); + { + uint8_t t216[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[586] = BinaryenConst(the_module, BinaryenLiteralVec128(t216)); + } + { + uint8_t t217[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[587] = BinaryenConst(the_module, BinaryenLiteralVec128(t217)); + } + { + uint8_t t218[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[588] = BinaryenConst(the_module, BinaryenLiteralVec128(t218)); + } + expressions[589] = BinaryenSIMDTernary(the_module, 3, expressions[586], expressions[587], expressions[588]); + { + uint8_t t219[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[590] = BinaryenConst(the_module, BinaryenLiteralVec128(t219)); + } + { + uint8_t t220[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[591] = BinaryenConst(the_module, BinaryenLiteralVec128(t220)); + } + { + uint8_t t221[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[592] = BinaryenConst(the_module, BinaryenLiteralVec128(t221)); + } + expressions[593] = BinaryenSIMDTernary(the_module, 4, expressions[590], expressions[591], expressions[592]); + expressions[594] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); + expressions[595] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[596] = BinaryenConst(the_module, BinaryenLiteralInt32(12)); + expressions[597] = BinaryenMemoryInit(the_module, 0, expressions[594], expressions[595], expressions[596]); + expressions[598] = BinaryenDataDrop(the_module, 0); + expressions[599] = BinaryenConst(the_module, BinaryenLiteralInt32(2048)); + expressions[600] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); + expressions[601] = BinaryenConst(the_module, BinaryenLiteralInt32(12)); + expressions[602] = BinaryenMemoryCopy(the_module, expressions[599], expressions[600], expressions[601]); + expressions[603] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[604] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); + expressions[605] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); + expressions[606] = BinaryenMemoryFill(the_module, expressions[603], expressions[604], expressions[605]); { BinaryenExpressionRef children[] = { 0 }; - expressions[591] = BinaryenBlock(the_module, NULL, children, 0, 0); - } - expressions[592] = BinaryenIf(the_module, expressions[7], expressions[8], expressions[9]); - expressions[593] = BinaryenIf(the_module, expressions[10], expressions[11], expressions[0]); - expressions[594] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[595] = BinaryenLoop(the_module, "in", expressions[594]); - expressions[596] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[597] = BinaryenLoop(the_module, NULL, expressions[596]); - expressions[598] = BinaryenBreak(the_module, "the-value", expressions[12], expressions[13]); - expressions[599] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - expressions[600] = BinaryenBreak(the_module, "the-nothing", expressions[599], expressions[0]); - expressions[601] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); - expressions[602] = BinaryenBreak(the_module, "the-value", expressions[0], expressions[601]); - expressions[603] = BinaryenBreak(the_module, "the-nothing", expressions[0], expressions[0]); + expressions[607] = BinaryenBlock(the_module, NULL, children, 0, 0); + } + expressions[608] = BinaryenIf(the_module, expressions[7], expressions[8], expressions[9]); + expressions[609] = BinaryenIf(the_module, expressions[10], expressions[11], expressions[0]); + expressions[610] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[611] = BinaryenLoop(the_module, "in", expressions[610]); + expressions[612] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[613] = BinaryenLoop(the_module, NULL, expressions[612]); + expressions[614] = BinaryenBreak(the_module, "the-value", expressions[12], expressions[13]); + expressions[615] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[616] = BinaryenBreak(the_module, "the-nothing", expressions[615], expressions[0]); + expressions[617] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); + expressions[618] = BinaryenBreak(the_module, "the-value", expressions[0], expressions[617]); + expressions[619] = BinaryenBreak(the_module, "the-nothing", expressions[0], expressions[0]); { const char* names[] = { "the-value" }; - expressions[604] = BinaryenSwitch(the_module, names, 1, "the-value", expressions[14], expressions[15]); + expressions[620] = BinaryenSwitch(the_module, names, 1, "the-value", expressions[14], expressions[15]); } - expressions[605] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[621] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); { const char* names[] = { "the-nothing" }; - expressions[606] = BinaryenSwitch(the_module, names, 1, "the-nothing", expressions[605], expressions[0]); - } - expressions[607] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); - expressions[608] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); - expressions[609] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); - expressions[610] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); - { - BinaryenExpressionRef operands[] = { expressions[607], expressions[608], expressions[609], expressions[610] }; - expressions[611] = BinaryenCall(the_module, "kitchen()sinker", operands, 4, 1); - } - expressions[612] = BinaryenUnary(the_module, 20, expressions[611]); - expressions[613] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); - expressions[614] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); - { - BinaryenExpressionRef operands[] = { expressions[613], expressions[614] }; - expressions[615] = BinaryenCall(the_module, "an-imported", operands, 2, 3); - } - expressions[616] = BinaryenUnary(the_module, 25, expressions[615]); - expressions[617] = BinaryenUnary(the_module, 20, expressions[616]); - expressions[618] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); - expressions[619] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); - expressions[620] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); - expressions[621] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); - expressions[622] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); - { - BinaryenExpressionRef operands[] = { expressions[619], expressions[620], expressions[621], expressions[622] }; - expressions[623] = BinaryenCallIndirect(the_module, expressions[618], operands, 4, "iiIfF"); - } - expressions[624] = BinaryenUnary(the_module, 20, expressions[623]); - expressions[625] = BinaryenLocalGet(the_module, 0, 1); - expressions[626] = BinaryenDrop(the_module, expressions[625]); - expressions[627] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); - expressions[628] = BinaryenLocalSet(the_module, 0, expressions[627]); - expressions[629] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); - expressions[630] = BinaryenLocalTee(the_module, 0, expressions[629]); - expressions[631] = BinaryenDrop(the_module, expressions[630]); - expressions[632] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - expressions[633] = BinaryenLoad(the_module, 4, 1, 0, 0, 1, expressions[632]); - expressions[634] = BinaryenConst(the_module, BinaryenLiteralInt32(8)); - expressions[635] = BinaryenLoad(the_module, 2, 1, 2, 1, 2, expressions[634]); - expressions[636] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - expressions[637] = BinaryenLoad(the_module, 4, 1, 0, 0, 3, expressions[636]); - expressions[638] = BinaryenConst(the_module, BinaryenLiteralInt32(9)); - expressions[639] = BinaryenLoad(the_module, 8, 1, 2, 8, 4, expressions[638]); - expressions[640] = BinaryenStore(the_module, 4, 0, 0, expressions[19], expressions[20], 1); - expressions[641] = BinaryenStore(the_module, 8, 2, 4, expressions[21], expressions[22], 2); - expressions[642] = BinaryenSelect(the_module, expressions[16], expressions[17], expressions[18]); - expressions[643] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); - expressions[644] = BinaryenReturn(the_module, expressions[643]); - expressions[645] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); - expressions[646] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); - expressions[647] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); - expressions[648] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); - { - BinaryenExpressionRef operands[] = { expressions[645], expressions[646], expressions[647], expressions[648] }; - expressions[649] = BinaryenReturnCall(the_module, "kitchen()sinker", operands, 4, 1); - } - expressions[650] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); - expressions[651] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); - expressions[652] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); - expressions[653] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); - expressions[654] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); - { - BinaryenExpressionRef operands[] = { expressions[651], expressions[652], expressions[653], expressions[654] }; - expressions[655] = BinaryenReturnCallIndirect(the_module, expressions[650], operands, 4, "iiIfF"); - } - expressions[656] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - { - BinaryenExpressionRef operands[] = { expressions[656] }; - expressions[657] = BinaryenThrow(the_module, "a-event", operands, 1); - } - expressions[658] = BinaryenPop(the_module, 7); - expressions[659] = BinaryenLocalSet(the_module, 5, expressions[658]); - expressions[660] = BinaryenLocalGet(the_module, 5, 7); - expressions[661] = BinaryenBrOnExn(the_module, "try-block", "a-event", expressions[660]); - expressions[662] = BinaryenRethrow(the_module, expressions[661]); - { - BinaryenExpressionRef children[] = { expressions[662] }; - expressions[663] = BinaryenBlock(the_module, "try-block", children, 1, 1); - } - expressions[664] = BinaryenDrop(the_module, expressions[663]); - { - BinaryenExpressionRef children[] = { expressions[659], expressions[664] }; - expressions[665] = BinaryenBlock(the_module, NULL, children, 2, 0); - } - expressions[666] = BinaryenTry(the_module, expressions[657], expressions[665]); - expressions[667] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[668] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[669] = BinaryenAtomicLoad(the_module, 4, 0, 1, expressions[668]); - expressions[670] = BinaryenAtomicStore(the_module, 4, 0, expressions[667], expressions[669], 1); - expressions[671] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[622] = BinaryenSwitch(the_module, names, 1, "the-nothing", expressions[621], expressions[0]); + } + expressions[623] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); + expressions[624] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); + expressions[625] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); + expressions[626] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); + { + BinaryenExpressionRef operands[] = { expressions[623], expressions[624], expressions[625], expressions[626] }; + expressions[627] = BinaryenCall(the_module, "kitchen()sinker", operands, 4, 1); + } + expressions[628] = BinaryenUnary(the_module, 20, expressions[627]); + expressions[629] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); + expressions[630] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); + { + BinaryenExpressionRef operands[] = { expressions[629], expressions[630] }; + expressions[631] = BinaryenCall(the_module, "an-imported", operands, 2, 3); + } + expressions[632] = BinaryenUnary(the_module, 25, expressions[631]); + expressions[633] = BinaryenUnary(the_module, 20, expressions[632]); + expressions[634] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); + expressions[635] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); + expressions[636] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); + expressions[637] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); + expressions[638] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); + { + BinaryenExpressionRef operands[] = { expressions[635], expressions[636], expressions[637], expressions[638] }; + expressions[639] = BinaryenCallIndirect(the_module, expressions[634], operands, 4, "iiIfF"); + } + expressions[640] = BinaryenUnary(the_module, 20, expressions[639]); + expressions[641] = BinaryenLocalGet(the_module, 0, 1); + expressions[642] = BinaryenDrop(the_module, expressions[641]); + expressions[643] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); + expressions[644] = BinaryenLocalSet(the_module, 0, expressions[643]); + expressions[645] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); + expressions[646] = BinaryenLocalTee(the_module, 0, expressions[645]); + expressions[647] = BinaryenDrop(the_module, expressions[646]); + expressions[648] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + expressions[649] = BinaryenLoad(the_module, 4, 1, 0, 0, 1, expressions[648]); + expressions[650] = BinaryenConst(the_module, BinaryenLiteralInt32(8)); + expressions[651] = BinaryenLoad(the_module, 2, 1, 2, 1, 2, expressions[650]); + expressions[652] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[653] = BinaryenLoad(the_module, 4, 1, 0, 0, 3, expressions[652]); + expressions[654] = BinaryenConst(the_module, BinaryenLiteralInt32(9)); + expressions[655] = BinaryenLoad(the_module, 8, 1, 2, 8, 4, expressions[654]); + expressions[656] = BinaryenStore(the_module, 4, 0, 0, expressions[19], expressions[20], 1); + expressions[657] = BinaryenStore(the_module, 8, 2, 4, expressions[21], expressions[22], 2); + expressions[658] = BinaryenSelect(the_module, expressions[16], expressions[17], expressions[18]); + expressions[659] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); + expressions[660] = BinaryenReturn(the_module, expressions[659]); + expressions[661] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); + expressions[662] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); + expressions[663] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); + expressions[664] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); + { + BinaryenExpressionRef operands[] = { expressions[661], expressions[662], expressions[663], expressions[664] }; + expressions[665] = BinaryenReturnCall(the_module, "kitchen()sinker", operands, 4, 1); + } + expressions[666] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); + expressions[667] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); + expressions[668] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); + expressions[669] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); + expressions[670] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); + { + BinaryenExpressionRef operands[] = { expressions[667], expressions[668], expressions[669], expressions[670] }; + expressions[671] = BinaryenReturnCallIndirect(the_module, expressions[666], operands, 4, "iiIfF"); + } expressions[672] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[673] = BinaryenConst(the_module, BinaryenLiteralInt64(0)); - expressions[674] = BinaryenAtomicWait(the_module, expressions[671], expressions[672], expressions[673], 1); - expressions[675] = BinaryenDrop(the_module, expressions[674]); - expressions[676] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[677] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[678] = BinaryenAtomicNotify(the_module, expressions[676], expressions[677]); - expressions[679] = BinaryenDrop(the_module, expressions[678]); - expressions[680] = BinaryenAtomicFence(the_module); - expressions[681] = BinaryenPop(the_module, 1); - expressions[682] = BinaryenPush(the_module, expressions[681]); - expressions[683] = BinaryenPop(the_module, 2); - expressions[684] = BinaryenPush(the_module, expressions[683]); - expressions[685] = BinaryenPop(the_module, 3); - expressions[686] = BinaryenPush(the_module, expressions[685]); - expressions[687] = BinaryenPop(the_module, 4); - expressions[688] = BinaryenPush(the_module, expressions[687]); - expressions[689] = BinaryenPop(the_module, 5); - expressions[690] = BinaryenPush(the_module, expressions[689]); - expressions[691] = BinaryenPop(the_module, 7); - expressions[692] = BinaryenPush(the_module, expressions[691]); - expressions[693] = BinaryenNop(the_module); - expressions[694] = BinaryenUnreachable(the_module); + { + BinaryenExpressionRef operands[] = { expressions[672] }; + expressions[673] = BinaryenThrow(the_module, "a-event", operands, 1); + } + expressions[674] = BinaryenPop(the_module, 7); + expressions[675] = BinaryenLocalSet(the_module, 5, expressions[674]); + expressions[676] = BinaryenLocalGet(the_module, 5, 7); + expressions[677] = BinaryenBrOnExn(the_module, "try-block", "a-event", expressions[676]); + expressions[678] = BinaryenRethrow(the_module, expressions[677]); + { + BinaryenExpressionRef children[] = { expressions[678] }; + expressions[679] = BinaryenBlock(the_module, "try-block", children, 1, 1); + } + expressions[680] = BinaryenDrop(the_module, expressions[679]); + { + BinaryenExpressionRef children[] = { expressions[675], expressions[680] }; + expressions[681] = BinaryenBlock(the_module, NULL, children, 2, 0); + } + expressions[682] = BinaryenTry(the_module, expressions[673], expressions[681]); + expressions[683] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[684] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[685] = BinaryenAtomicLoad(the_module, 4, 0, 1, expressions[684]); + expressions[686] = BinaryenAtomicStore(the_module, 4, 0, expressions[683], expressions[685], 1); + expressions[687] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[688] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[689] = BinaryenConst(the_module, BinaryenLiteralInt64(0)); + expressions[690] = BinaryenAtomicWait(the_module, expressions[687], expressions[688], expressions[689], 1); + expressions[691] = BinaryenDrop(the_module, expressions[690]); + expressions[692] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[693] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[694] = BinaryenAtomicNotify(the_module, expressions[692], expressions[693]); + expressions[695] = BinaryenDrop(the_module, expressions[694]); + expressions[696] = BinaryenAtomicFence(the_module); + expressions[697] = BinaryenPop(the_module, 1); + expressions[698] = BinaryenPush(the_module, expressions[697]); + expressions[699] = BinaryenPop(the_module, 2); + expressions[700] = BinaryenPush(the_module, expressions[699]); + expressions[701] = BinaryenPop(the_module, 3); + expressions[702] = BinaryenPush(the_module, expressions[701]); + expressions[703] = BinaryenPop(the_module, 4); + expressions[704] = BinaryenPush(the_module, expressions[703]); + expressions[705] = BinaryenPop(the_module, 5); + expressions[706] = BinaryenPush(the_module, expressions[705]); + expressions[707] = BinaryenPop(the_module, 7); + expressions[708] = BinaryenPush(the_module, expressions[707]); + expressions[709] = BinaryenNop(the_module); + expressions[710] = BinaryenUnreachable(the_module); BinaryenExpressionGetId(expressions[30]); BinaryenExpressionGetType(expressions[30]); BinaryenUnaryGetOp(expressions[30]); @@ -4857,26 +4965,26 @@ getExpressionInfo={"id":15,"type":3,"op":6} (f32.const -33.61199951171875) ) - expressions[695] = BinaryenConst(the_module, BinaryenLiteralInt32(5)); - BinaryenExpressionGetId(expressions[695]); - BinaryenExpressionGetType(expressions[695]); - BinaryenConstGetValueI32(expressions[695]); + expressions[711] = BinaryenConst(the_module, BinaryenLiteralInt32(5)); + BinaryenExpressionGetId(expressions[711]); + BinaryenExpressionGetType(expressions[711]); + BinaryenConstGetValueI32(expressions[711]); getExpressionInfo(i32.const)={"id":14,"type":1,"value":5} - expressions[696] = BinaryenConst(the_module, BinaryenLiteralInt64(30064771078)); - BinaryenExpressionGetId(expressions[696]); - BinaryenExpressionGetType(expressions[696]); - BinaryenConstGetValueI64Low(expressions[696]); - BinaryenConstGetValueI64High(expressions[696]); + expressions[712] = BinaryenConst(the_module, BinaryenLiteralInt64(30064771078)); + BinaryenExpressionGetId(expressions[712]); + BinaryenExpressionGetType(expressions[712]); + BinaryenConstGetValueI64Low(expressions[712]); + BinaryenConstGetValueI64High(expressions[712]); getExpressionInfo(i64.const)={"id":14,"type":2,"value":{"low":6,"high":7}} - expressions[697] = BinaryenConst(the_module, BinaryenLiteralFloat32(8.5)); - BinaryenExpressionGetId(expressions[697]); - BinaryenExpressionGetType(expressions[697]); - BinaryenConstGetValueF32(expressions[697]); + expressions[713] = BinaryenConst(the_module, BinaryenLiteralFloat32(8.5)); + BinaryenExpressionGetId(expressions[713]); + BinaryenExpressionGetType(expressions[713]); + BinaryenConstGetValueF32(expressions[713]); getExpressionInfo(f32.const)={"id":14,"type":3,"value":8.5} - expressions[698] = BinaryenConst(the_module, BinaryenLiteralFloat64(9.5)); - BinaryenExpressionGetId(expressions[698]); - BinaryenExpressionGetType(expressions[698]); - BinaryenConstGetValueF64(expressions[698]); + expressions[714] = BinaryenConst(the_module, BinaryenLiteralFloat64(9.5)); + BinaryenExpressionGetId(expressions[714]); + BinaryenExpressionGetType(expressions[714]); + BinaryenConstGetValueF64(expressions[714]); getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} { BinaryenExpressionRef children[] = { expressions[24], expressions[26], expressions[28], expressions[30], expressions[32], @@ -4914,32 +5022,33 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} expressions[514], expressions[516], expressions[519], expressions[522], expressions[525], expressions[528], expressions[531], expressions[534], expressions[537], expressions[540], expressions[543], expressions[546], expressions[549], expressions[552], expressions[555], expressions[558], expressions[561], expressions[564], - expressions[567], expressions[570], expressions[573], expressions[577], expressions[581], expressions[582], - expressions[586], expressions[590], expressions[591], expressions[592], expressions[593], expressions[595], - expressions[597], expressions[598], expressions[600], expressions[602], expressions[603], expressions[604], - expressions[606], expressions[612], expressions[617], expressions[624], expressions[626], expressions[628], - expressions[631], expressions[633], expressions[635], expressions[637], expressions[639], expressions[640], - expressions[641], expressions[642], expressions[644], expressions[649], expressions[655], expressions[666], - expressions[670], expressions[675], expressions[679], expressions[680], expressions[682], expressions[684], - expressions[686], expressions[688], expressions[690], expressions[692], expressions[693], expressions[694] }; - expressions[699] = BinaryenBlock(the_module, "the-value", children, 257, 0); + expressions[567], expressions[570], expressions[573], expressions[577], expressions[581], expressions[585], + expressions[589], expressions[593], expressions[597], expressions[598], expressions[602], expressions[606], + expressions[607], expressions[608], expressions[609], expressions[611], expressions[613], expressions[614], + expressions[616], expressions[618], expressions[619], expressions[620], expressions[622], expressions[628], + expressions[633], expressions[640], expressions[642], expressions[644], expressions[647], expressions[649], + expressions[651], expressions[653], expressions[655], expressions[656], expressions[657], expressions[658], + expressions[660], expressions[665], expressions[671], expressions[682], expressions[686], expressions[691], + expressions[695], expressions[696], expressions[698], expressions[700], expressions[702], expressions[704], + expressions[706], expressions[708], expressions[709], expressions[710] }; + expressions[715] = BinaryenBlock(the_module, "the-value", children, 261, 0); } - expressions[700] = BinaryenDrop(the_module, expressions[699]); + expressions[716] = BinaryenDrop(the_module, expressions[715]); { - BinaryenExpressionRef children[] = { expressions[700] }; - expressions[701] = BinaryenBlock(the_module, "the-nothing", children, 1, 0); + BinaryenExpressionRef children[] = { expressions[716] }; + expressions[717] = BinaryenBlock(the_module, "the-nothing", children, 1, 0); } - expressions[702] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); + expressions[718] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); { - BinaryenExpressionRef children[] = { expressions[701], expressions[702] }; - expressions[703] = BinaryenBlock(the_module, "the-body", children, 2, 0); + BinaryenExpressionRef children[] = { expressions[717], expressions[718] }; + expressions[719] = BinaryenBlock(the_module, "the-body", children, 2, 0); } { BinaryenType varTypes[] = { 1, 7 }; - functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[1], varTypes, 2, expressions[703]); + functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[1], varTypes, 2, expressions[719]); } - expressions[704] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[704]); + expressions[720] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[720]); { BinaryenType paramTypes[] = { 1, 4 }; functionTypes[2] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2); @@ -4969,13 +5078,13 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} const char* funcNames[] = { "kitchen()sinker" }; BinaryenSetFunctionTable(the_module, 1, 4294967295, funcNames, 1); } - expressions[705] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); + expressions[721] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); { const char segment0[] = { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 }; const char segment1[] = { 73, 32, 97, 109, 32, 112, 97, 115, 115, 105, 118, 101 }; const char* segments[] = { segment0, segment1 }; int8_t segmentPassive[] = { 0, 1 }; - BinaryenExpressionRef segmentOffsets[] = { expressions[705], expressions[0] }; + BinaryenExpressionRef segmentOffsets[] = { expressions[721], expressions[0] }; BinaryenIndex segmentSizes[] = { 12, 12 }; BinaryenSetMemory(the_module, 1, 256, "mem", segments, segmentPassive, segmentOffsets, segmentSizes, 2, 1); } @@ -4983,10 +5092,10 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} BinaryenType paramTypes[] = { 0 }; functionTypes[3] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } - expressions[706] = BinaryenNop(the_module); + expressions[722] = BinaryenNop(the_module); { BinaryenType varTypes[] = { 0 }; - functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[706]); + functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[722]); } BinaryenSetStart(the_module, functions[1]); { @@ -6211,6 +6320,34 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) ) ) + (drop + (f32x4.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f32x4.qfms + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfms + (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) @@ -7653,6 +7790,34 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) ) ) + (drop + (f32x4.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f32x4.qfms + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfms + (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) diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 95bc398b5..ad61ca528 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -109,11 +109,11 @@ BinaryenExpressionRef makeSIMDShuffle(BinaryenModuleRef module) { return BinaryenSIMDShuffle(module, left, right, (uint8_t[16]) {}); } -BinaryenExpressionRef makeSIMDBitselect(BinaryenModuleRef module) { - BinaryenExpressionRef left = makeVec128(module, v128_bytes); - BinaryenExpressionRef right = makeVec128(module, v128_bytes); - BinaryenExpressionRef cond = makeVec128(module, v128_bytes); - return BinaryenSIMDBitselect(module, left, right, cond); +BinaryenExpressionRef makeSIMDTernary(BinaryenModuleRef module, BinaryenOp op) { + BinaryenExpressionRef a = makeVec128(module, v128_bytes); + BinaryenExpressionRef b = makeVec128(module, v128_bytes); + BinaryenExpressionRef c = makeVec128(module, v128_bytes); + return BinaryenSIMDTernary(module, op, a, b, c); } BinaryenExpressionRef makeSIMDShift(BinaryenModuleRef module, BinaryenOp op) { @@ -472,7 +472,11 @@ void test_core() { makeSIMDShift(module, BinaryenShrUVecI64x2()), // Other SIMD makeSIMDShuffle(module), - makeSIMDBitselect(module), + makeSIMDTernary(module, BinaryenBitselectVec128()), + makeSIMDTernary(module, BinaryenQFMAVecF32x4()), + makeSIMDTernary(module, BinaryenQFMSVecF32x4()), + makeSIMDTernary(module, BinaryenQFMAVecF64x2()), + makeSIMDTernary(module, BinaryenQFMSVecF64x2()), // Bulk memory makeMemoryInit(module), makeDataDrop(module), @@ -489,19 +493,27 @@ void test_core() { BinaryenBreak(module, "the-value", NULL, makeInt32(module, 3)), BinaryenBreak(module, "the-nothing", NULL, NULL), BinaryenSwitch(module, switchValueNames, 1, "the-value", temp8, temp9), - BinaryenSwitch(module, switchBodyNames, 1, "the-nothing", makeInt32(module, 2), NULL), - BinaryenUnary(module, BinaryenEqZInt32(), // check the output type of the call node - BinaryenCall(module, "kitchen()sinker", callOperands4, 4, BinaryenTypeInt32()) - ), - BinaryenUnary(module, BinaryenEqZInt32(), // check the output type of the call node - BinaryenUnary(module, - BinaryenTruncSFloat32ToInt32(), - BinaryenCall(module, "an-imported", callOperands2, 2, BinaryenTypeFloat32()) - ) - ), - BinaryenUnary(module, BinaryenEqZInt32(), // check the output type of the call node - BinaryenCallIndirect(module, makeInt32(module, 2449), callOperands4b, 4, "iiIfF") - ), + BinaryenSwitch( + module, switchBodyNames, 1, "the-nothing", makeInt32(module, 2), NULL), + BinaryenUnary( + module, + BinaryenEqZInt32(), // check the output type of the call node + BinaryenCall( + module, "kitchen()sinker", callOperands4, 4, BinaryenTypeInt32())), + BinaryenUnary(module, + BinaryenEqZInt32(), // check the output type of the call node + BinaryenUnary(module, + BinaryenTruncSFloat32ToInt32(), + BinaryenCall(module, + "an-imported", + callOperands2, + 2, + BinaryenTypeFloat32()))), + BinaryenUnary( + module, + BinaryenEqZInt32(), // check the output type of the call node + BinaryenCallIndirect( + module, makeInt32(module, 2449), callOperands4b, 4, "iiIfF")), BinaryenDrop(module, BinaryenLocalGet(module, 0, BinaryenTypeInt32())), BinaryenLocalSet(module, 0, makeInt32(module, 101)), BinaryenDrop(module, BinaryenLocalTee(module, 0, makeInt32(module, 102))), @@ -523,13 +535,16 @@ void test_core() { // Exception handling BinaryenTry(module, tryBody, catchBody), // Atomics - BinaryenAtomicStore(module, 4, 0, temp6, + BinaryenAtomicStore( + module, + 4, + 0, + temp6, BinaryenAtomicLoad(module, 4, 0, BinaryenTypeInt32(), temp6), - BinaryenTypeInt32() - ), - BinaryenDrop(module, - BinaryenAtomicWait(module, temp6, temp6, temp16, BinaryenTypeInt32()) - ), + BinaryenTypeInt32()), + BinaryenDrop( + module, + BinaryenAtomicWait(module, temp6, temp6, temp16, BinaryenTypeInt32())), BinaryenDrop(module, BinaryenAtomicNotify(module, temp6, temp6)), BinaryenAtomicFence(module), diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 7f9266207..68c75fee5 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -1241,6 +1241,34 @@ BinaryenFeatureAll: 511 (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) ) ) + (drop + (f32x4.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f32x4.qfms + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfms + (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) @@ -3246,101 +3274,153 @@ int main() { uint8_t t210[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; expressions[597] = BinaryenConst(the_module, BinaryenLiteralVec128(t210)); } - expressions[598] = BinaryenSIMDBitselect(the_module, expressions[595], expressions[596], expressions[597]); - expressions[599] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); - expressions[600] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[601] = BinaryenConst(the_module, BinaryenLiteralInt32(12)); - expressions[602] = BinaryenMemoryInit(the_module, 0, expressions[599], expressions[600], expressions[601]); - expressions[603] = BinaryenDataDrop(the_module, 0); - expressions[604] = BinaryenConst(the_module, BinaryenLiteralInt32(2048)); - expressions[605] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); - expressions[606] = BinaryenConst(the_module, BinaryenLiteralInt32(12)); - expressions[607] = BinaryenMemoryCopy(the_module, expressions[604], expressions[605], expressions[606]); - expressions[608] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[609] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); - expressions[610] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); - expressions[611] = BinaryenMemoryFill(the_module, expressions[608], expressions[609], expressions[610]); + expressions[598] = BinaryenSIMDTernary(the_module, 0, expressions[595], expressions[596], expressions[597]); + { + uint8_t t211[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[599] = BinaryenConst(the_module, BinaryenLiteralVec128(t211)); + } + { + uint8_t t212[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[600] = BinaryenConst(the_module, BinaryenLiteralVec128(t212)); + } + { + uint8_t t213[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[601] = BinaryenConst(the_module, BinaryenLiteralVec128(t213)); + } + expressions[602] = BinaryenSIMDTernary(the_module, 1, expressions[599], expressions[600], expressions[601]); + { + uint8_t t214[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[603] = BinaryenConst(the_module, BinaryenLiteralVec128(t214)); + } + { + uint8_t t215[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[604] = BinaryenConst(the_module, BinaryenLiteralVec128(t215)); + } + { + uint8_t t216[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[605] = BinaryenConst(the_module, BinaryenLiteralVec128(t216)); + } + expressions[606] = BinaryenSIMDTernary(the_module, 2, expressions[603], expressions[604], expressions[605]); + { + uint8_t t217[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[607] = BinaryenConst(the_module, BinaryenLiteralVec128(t217)); + } + { + uint8_t t218[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[608] = BinaryenConst(the_module, BinaryenLiteralVec128(t218)); + } + { + uint8_t t219[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[609] = BinaryenConst(the_module, BinaryenLiteralVec128(t219)); + } + expressions[610] = BinaryenSIMDTernary(the_module, 3, expressions[607], expressions[608], expressions[609]); + { + uint8_t t220[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[611] = BinaryenConst(the_module, BinaryenLiteralVec128(t220)); + } + { + uint8_t t221[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[612] = BinaryenConst(the_module, BinaryenLiteralVec128(t221)); + } + { + uint8_t t222[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + expressions[613] = BinaryenConst(the_module, BinaryenLiteralVec128(t222)); + } + expressions[614] = BinaryenSIMDTernary(the_module, 4, expressions[611], expressions[612], expressions[613]); + expressions[615] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); + expressions[616] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[617] = BinaryenConst(the_module, BinaryenLiteralInt32(12)); + expressions[618] = BinaryenMemoryInit(the_module, 0, expressions[615], expressions[616], expressions[617]); + expressions[619] = BinaryenDataDrop(the_module, 0); + expressions[620] = BinaryenConst(the_module, BinaryenLiteralInt32(2048)); + expressions[621] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); + expressions[622] = BinaryenConst(the_module, BinaryenLiteralInt32(12)); + expressions[623] = BinaryenMemoryCopy(the_module, expressions[620], expressions[621], expressions[622]); + expressions[624] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[625] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); + expressions[626] = BinaryenConst(the_module, BinaryenLiteralInt32(1024)); + expressions[627] = BinaryenMemoryFill(the_module, expressions[624], expressions[625], expressions[626]); { BinaryenExpressionRef children[] = { 0 }; - expressions[612] = BinaryenBlock(the_module, NULL, children, 0, BinaryenTypeAuto()); - } - expressions[613] = BinaryenIf(the_module, expressions[18], expressions[19], expressions[20]); - expressions[614] = BinaryenIf(the_module, expressions[21], expressions[22], expressions[0]); - expressions[615] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[616] = BinaryenLoop(the_module, "in", expressions[615]); - expressions[617] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[618] = BinaryenLoop(the_module, NULL, expressions[617]); - expressions[619] = BinaryenBreak(the_module, "the-value", expressions[23], expressions[24]); - expressions[620] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - expressions[621] = BinaryenBreak(the_module, "the-nothing", expressions[620], expressions[0]); - expressions[622] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); - expressions[623] = BinaryenBreak(the_module, "the-value", expressions[0], expressions[622]); - expressions[624] = BinaryenBreak(the_module, "the-nothing", expressions[0], expressions[0]); + expressions[628] = BinaryenBlock(the_module, NULL, children, 0, BinaryenTypeAuto()); + } + expressions[629] = BinaryenIf(the_module, expressions[18], expressions[19], expressions[20]); + expressions[630] = BinaryenIf(the_module, expressions[21], expressions[22], expressions[0]); + expressions[631] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[632] = BinaryenLoop(the_module, "in", expressions[631]); + expressions[633] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[634] = BinaryenLoop(the_module, NULL, expressions[633]); + expressions[635] = BinaryenBreak(the_module, "the-value", expressions[23], expressions[24]); + expressions[636] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[637] = BinaryenBreak(the_module, "the-nothing", expressions[636], expressions[0]); + expressions[638] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); + expressions[639] = BinaryenBreak(the_module, "the-value", expressions[0], expressions[638]); + expressions[640] = BinaryenBreak(the_module, "the-nothing", expressions[0], expressions[0]); { const char* names[] = { "the-value" }; - expressions[625] = BinaryenSwitch(the_module, names, 1, "the-value", expressions[25], expressions[26]); + expressions[641] = BinaryenSwitch(the_module, names, 1, "the-value", expressions[25], expressions[26]); } - expressions[626] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[642] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); { const char* names[] = { "the-nothing" }; - expressions[627] = BinaryenSwitch(the_module, names, 1, "the-nothing", expressions[626], expressions[0]); + expressions[643] = BinaryenSwitch(the_module, names, 1, "the-nothing", expressions[642], expressions[0]); } { BinaryenExpressionRef operands[] = { expressions[10], expressions[11], expressions[12], expressions[13] }; - expressions[628] = BinaryenCall(the_module, "kitchen()sinker", operands, 4, 1); + expressions[644] = BinaryenCall(the_module, "kitchen()sinker", operands, 4, 1); } - expressions[629] = BinaryenUnary(the_module, 20, expressions[628]); + expressions[645] = BinaryenUnary(the_module, 20, expressions[644]); { BinaryenExpressionRef operands[] = { expressions[8], expressions[9] }; - expressions[630] = BinaryenCall(the_module, "an-imported", operands, 2, 3); + expressions[646] = BinaryenCall(the_module, "an-imported", operands, 2, 3); } - expressions[631] = BinaryenUnary(the_module, 25, expressions[630]); - expressions[632] = BinaryenUnary(the_module, 20, expressions[631]); - expressions[633] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); + expressions[647] = BinaryenUnary(the_module, 25, expressions[646]); + expressions[648] = BinaryenUnary(the_module, 20, expressions[647]); + expressions[649] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); { BinaryenExpressionRef operands[] = { expressions[14], expressions[15], expressions[16], expressions[17] }; - expressions[634] = BinaryenCallIndirect(the_module, expressions[633], operands, 4, "iiIfF"); - } - expressions[635] = BinaryenUnary(the_module, 20, expressions[634]); - expressions[636] = BinaryenLocalGet(the_module, 0, 1); - expressions[637] = BinaryenDrop(the_module, expressions[636]); - expressions[638] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); - expressions[639] = BinaryenLocalSet(the_module, 0, expressions[638]); - expressions[640] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); - expressions[641] = BinaryenLocalTee(the_module, 0, expressions[640]); - expressions[642] = BinaryenDrop(the_module, expressions[641]); - expressions[643] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - expressions[644] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[643]); - expressions[645] = BinaryenConst(the_module, BinaryenLiteralInt32(8)); - expressions[646] = BinaryenLoad(the_module, 2, 1, 2, 1, 2, expressions[645]); - expressions[647] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - expressions[648] = BinaryenLoad(the_module, 4, 0, 0, 0, 3, expressions[647]); - expressions[649] = BinaryenConst(the_module, BinaryenLiteralInt32(9)); - expressions[650] = BinaryenLoad(the_module, 8, 0, 2, 8, 4, expressions[649]); - expressions[651] = BinaryenStore(the_module, 4, 0, 0, expressions[30], expressions[31], 1); - expressions[652] = BinaryenStore(the_module, 8, 2, 4, expressions[32], expressions[33], 2); - expressions[653] = BinaryenSelect(the_module, expressions[27], expressions[28], expressions[29]); - expressions[654] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); - expressions[655] = BinaryenReturn(the_module, expressions[654]); + expressions[650] = BinaryenCallIndirect(the_module, expressions[649], operands, 4, "iiIfF"); + } + expressions[651] = BinaryenUnary(the_module, 20, expressions[650]); + expressions[652] = BinaryenLocalGet(the_module, 0, 1); + expressions[653] = BinaryenDrop(the_module, expressions[652]); + expressions[654] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); + expressions[655] = BinaryenLocalSet(the_module, 0, expressions[654]); + expressions[656] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); + expressions[657] = BinaryenLocalTee(the_module, 0, expressions[656]); + expressions[658] = BinaryenDrop(the_module, expressions[657]); + expressions[659] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + expressions[660] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[659]); + expressions[661] = BinaryenConst(the_module, BinaryenLiteralInt32(8)); + expressions[662] = BinaryenLoad(the_module, 2, 1, 2, 1, 2, expressions[661]); + expressions[663] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[664] = BinaryenLoad(the_module, 4, 0, 0, 0, 3, expressions[663]); + expressions[665] = BinaryenConst(the_module, BinaryenLiteralInt32(9)); + expressions[666] = BinaryenLoad(the_module, 8, 0, 2, 8, 4, expressions[665]); + expressions[667] = BinaryenStore(the_module, 4, 0, 0, expressions[30], expressions[31], 1); + expressions[668] = BinaryenStore(the_module, 8, 2, 4, expressions[32], expressions[33], 2); + expressions[669] = BinaryenSelect(the_module, expressions[27], expressions[28], expressions[29]); + expressions[670] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); + expressions[671] = BinaryenReturn(the_module, expressions[670]); { BinaryenExpressionRef operands[] = { expressions[10], expressions[11], expressions[12], expressions[13] }; - expressions[656] = BinaryenReturnCall(the_module, "kitchen()sinker", operands, 4, 1); + expressions[672] = BinaryenReturnCall(the_module, "kitchen()sinker", operands, 4, 1); } - expressions[657] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); + expressions[673] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); { BinaryenExpressionRef operands[] = { expressions[14], expressions[15], expressions[16], expressions[17] }; - expressions[658] = BinaryenReturnCallIndirect(the_module, expressions[657], operands, 4, "iiIfF"); - } - expressions[659] = BinaryenTry(the_module, expressions[35], expressions[43]); - expressions[660] = BinaryenAtomicLoad(the_module, 4, 0, 1, expressions[23]); - expressions[661] = BinaryenAtomicStore(the_module, 4, 0, expressions[23], expressions[660], 1); - expressions[662] = BinaryenAtomicWait(the_module, expressions[23], expressions[23], expressions[33], 1); - expressions[663] = BinaryenDrop(the_module, expressions[662]); - expressions[664] = BinaryenAtomicNotify(the_module, expressions[23], expressions[23]); - expressions[665] = BinaryenDrop(the_module, expressions[664]); - expressions[666] = BinaryenAtomicFence(the_module); - expressions[667] = BinaryenNop(the_module); - expressions[668] = BinaryenUnreachable(the_module); + expressions[674] = BinaryenReturnCallIndirect(the_module, expressions[673], operands, 4, "iiIfF"); + } + expressions[675] = BinaryenTry(the_module, expressions[35], expressions[43]); + expressions[676] = BinaryenAtomicLoad(the_module, 4, 0, 1, expressions[23]); + expressions[677] = BinaryenAtomicStore(the_module, 4, 0, expressions[23], expressions[676], 1); + expressions[678] = BinaryenAtomicWait(the_module, expressions[23], expressions[23], expressions[33], 1); + expressions[679] = BinaryenDrop(the_module, expressions[678]); + expressions[680] = BinaryenAtomicNotify(the_module, expressions[23], expressions[23]); + expressions[681] = BinaryenDrop(the_module, expressions[680]); + expressions[682] = BinaryenAtomicFence(the_module); + expressions[683] = BinaryenNop(the_module); + expressions[684] = BinaryenUnreachable(the_module); BinaryenExpressionPrint(expressions[51]); (f32.neg (f32.const -33.61199951171875) @@ -3381,33 +3461,34 @@ int main() { expressions[535], expressions[537], expressions[540], expressions[543], expressions[546], expressions[549], expressions[552], expressions[555], expressions[558], expressions[561], expressions[564], expressions[567], expressions[570], expressions[573], expressions[576], expressions[579], expressions[582], expressions[585], - expressions[588], expressions[591], expressions[594], expressions[598], expressions[602], expressions[603], - expressions[607], expressions[611], expressions[612], expressions[613], expressions[614], expressions[616], - expressions[618], expressions[619], expressions[621], expressions[623], expressions[624], expressions[625], - expressions[627], expressions[629], expressions[632], expressions[635], expressions[637], expressions[639], - expressions[642], expressions[644], expressions[646], expressions[648], expressions[650], expressions[651], - expressions[652], expressions[653], expressions[655], expressions[656], expressions[658], expressions[659], - expressions[661], expressions[663], expressions[665], expressions[666], expressions[667], expressions[668] }; - expressions[669] = BinaryenBlock(the_module, "the-value", children, 251, BinaryenTypeAuto()); + expressions[588], expressions[591], expressions[594], expressions[598], expressions[602], expressions[606], + expressions[610], expressions[614], expressions[618], expressions[619], expressions[623], expressions[627], + expressions[628], expressions[629], expressions[630], expressions[632], expressions[634], expressions[635], + expressions[637], expressions[639], expressions[640], expressions[641], expressions[643], expressions[645], + expressions[648], expressions[651], expressions[653], expressions[655], expressions[658], expressions[660], + expressions[662], expressions[664], expressions[666], expressions[667], expressions[668], expressions[669], + expressions[671], expressions[672], expressions[674], expressions[675], expressions[677], expressions[679], + expressions[681], expressions[682], expressions[683], expressions[684] }; + expressions[685] = BinaryenBlock(the_module, "the-value", children, 255, BinaryenTypeAuto()); } - expressions[670] = BinaryenDrop(the_module, expressions[669]); + expressions[686] = BinaryenDrop(the_module, expressions[685]); { - BinaryenExpressionRef children[] = { expressions[670] }; - expressions[671] = BinaryenBlock(the_module, "the-nothing", children, 1, BinaryenTypeAuto()); + BinaryenExpressionRef children[] = { expressions[686] }; + expressions[687] = BinaryenBlock(the_module, "the-nothing", children, 1, BinaryenTypeAuto()); } - expressions[672] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); + expressions[688] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); { - BinaryenExpressionRef children[] = { expressions[671], expressions[672] }; - expressions[673] = BinaryenBlock(the_module, "the-body", children, 2, BinaryenTypeAuto()); + BinaryenExpressionRef children[] = { expressions[687], expressions[688] }; + expressions[689] = BinaryenBlock(the_module, "the-body", children, 2, BinaryenTypeAuto()); } { BinaryenType varTypes[] = { 1, 7 }; - functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 2, expressions[673]); + functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 2, expressions[689]); } - expressions[674] = BinaryenConst(the_module, BinaryenLiteralInt32(7)); - globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[674]); - expressions[675] = BinaryenConst(the_module, BinaryenLiteralFloat32(7.5)); - globals[1] = BinaryenAddGlobal(the_module, "a-mutable-global", 3, 1, expressions[675]); + expressions[690] = BinaryenConst(the_module, BinaryenLiteralInt32(7)); + globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[690]); + expressions[691] = BinaryenConst(the_module, BinaryenLiteralFloat32(7.5)); + globals[1] = BinaryenAddGlobal(the_module, "a-mutable-global", 3, 1, expressions[691]); { BinaryenType paramTypes[] = { 1, 4 }; functionTypes[2] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2); @@ -3419,13 +3500,13 @@ int main() { const char* funcNames[] = { "kitchen()sinker" }; BinaryenSetFunctionTable(the_module, 1, 1, funcNames, 1); } - expressions[676] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); + expressions[692] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); { const char segment0[] = { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 }; const char segment1[] = { 73, 32, 97, 109, 32, 112, 97, 115, 115, 105, 118, 101 }; const char* segments[] = { segment0, segment1 }; int8_t segmentPassive[] = { 0, 1 }; - BinaryenExpressionRef segmentOffsets[] = { expressions[676], expressions[0] }; + BinaryenExpressionRef segmentOffsets[] = { expressions[692], expressions[0] }; BinaryenIndex segmentSizes[] = { 12, 12 }; BinaryenSetMemory(the_module, 1, 256, "mem", segments, segmentPassive, segmentOffsets, segmentSizes, 2, 1); } @@ -3433,10 +3514,10 @@ int main() { BinaryenType paramTypes[] = { 0 }; functionTypes[3] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } - expressions[677] = BinaryenNop(the_module); + expressions[693] = BinaryenNop(the_module); { BinaryenType varTypes[] = { 0 }; - functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[677]); + functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[693]); } BinaryenSetStart(the_module, functions[1]); { @@ -4667,6 +4748,34 @@ int main() { (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) ) ) + (drop + (f32x4.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f32x4.qfms + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfms + (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) diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt index 792656d96..4a9660ea1 100644 --- a/test/example/c-api-kitchen-sink.txt.txt +++ b/test/example/c-api-kitchen-sink.txt.txt @@ -1220,6 +1220,34 @@ (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) ) ) + (drop + (f32x4.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f32x4.qfms + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfma + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d) + ) + ) + (drop + (f64x2.qfms + (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) |