Skip to content

Commit 34c74a0

Browse files
committed
update binaryen to 130.0.0-nightly. Add wide int ops api (wip)
1 parent ffed83a commit 34c74a0

6 files changed

Lines changed: 62 additions & 19 deletions

File tree

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"engineStrict": true,
2727
"dependencies": {
28-
"binaryen": "129.0.0-nightly.20260428",
28+
"binaryen": "130.0.0-nightly.20260609",
2929
"long": "^5.2.4"
3030
},
3131
"devDependencies": {

src/glue/binaryen.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ export declare function _BinaryenUnarySetOp(expr: ExpressionRef, op: Op): void;
267267
export declare function _BinaryenUnaryGetValue(expr: ExpressionRef): ExpressionRef;
268268
export declare function _BinaryenUnarySetValue(expr: ExpressionRef, valueExpr: ExpressionRef): void;
269269

270+
export declare function _BinaryenWideIntAddSub(module: ModuleRef, op: Op, leftLowExpr: ExpressionRef, leftHighExpr: ExpressionRef, rightLowExpr: ExpressionRef, rightHighExpr: ExpressionRef): ExpressionRef;
271+
export declare function _BinaryenWideIntMul(module: ModuleRef, op: Op, leftExpr: ExpressionRef, rightExpr: ExpressionRef): ExpressionRef;
272+
270273
export declare function _BinaryenBinary(module: ModuleRef, op: Op, leftExpr: ExpressionRef, rightExpr: ExpressionRef): ExpressionRef;
271274
export declare function _BinaryenBinaryGetOp(expr: ExpressionRef): Op;
272275
export declare function _BinaryenBinarySetOp(expr: ExpressionRef, op: Op): void;

src/glue/binaryen.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ export const {
223223
_BinaryenUnaryGetValue,
224224
_BinaryenUnarySetValue,
225225

226+
_BinaryenWideIntAddSub,
227+
_BinaryenWideIntMul,
228+
226229
_BinaryenBinary,
227230
_BinaryenBinaryGetOp,
228231
_BinaryenBinarySetOp,

src/module.ts

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ export const enum ExpressionId {
331331
ResumeThrow = 102 /* _BinaryenResumeThrowId */,
332332
StackSwitch = 103 /* _BinaryenStackSwitchId */,
333333
StructWait = 104 /* _BinaryenStructWaitId */,
334-
StructNotify = 105 /* _BinaryenStructNotifyId */
334+
StructNotify = 105 /* _BinaryenStructNotifyId */,
335+
WideIntAddSub = 106 /* _BinaryenWideIntAddSubId */,
336+
WideIntMul = 107 /* _BinaryenWideIntMulId */
335337
}
336338

337339
/** Binaryen external kind constants. */
@@ -1057,7 +1059,7 @@ export const enum BinaryOp {
10571059
/** i16x8.relaxed_q15mulr_s */
10581060
RelaxedQ15MulrI16x8 = 215 /* _BinaryenRelaxedQ15MulrSVecI16x8 */,
10591061
/** i16x8.relaxed_dot_i8x16_i7x16_s */
1060-
RelaxedDotI8x16I7x16ToI16x8 = 216 /* _BinaryenDotI8x16I7x16SToVecI16x8 */,
1062+
RelaxedDotI8x16I7x16ToI16x8 = 216 /* _BinaryenRelaxedDotI8x16I7x16SToVecI16x8 */,
10611063

10621064
_last = RelaxedDotI8x16I7x16ToI16x8,
10631065

@@ -1258,15 +1260,15 @@ export const enum SIMDTernaryOp {
12581260
/** f64x2.relaxed_nmadd */
12591261
RelaxedNmaddF64x2 = 4 /* _BinaryenRelaxedNmaddVecF64x2 */,
12601262
/** i8x16.relaxed_laneselect */
1261-
RelaxedLaneselectI8x16 = 5 /* _BinaryenLaneselectI8x16 */,
1263+
RelaxedLaneselectI8x16 = 5 /* _BinaryenRelaxedLaneselectI8x16 */,
12621264
/** i16x8.relaxed_laneselect */
1263-
RelaxedLaneselectI16x8 = 6 /* _BinaryenLaneselectI16x8 */,
1265+
RelaxedLaneselectI16x8 = 6 /* _BinaryenRelaxedLaneselectI16x8 */,
12641266
/** i32x4.relaxed_laneselect */
1265-
RelaxedLaneselectI32x4 = 7 /* _BinaryenLaneselectI32x4 */,
1267+
RelaxedLaneselectI32x4 = 7 /* _BinaryenRelaxedLaneselectI32x4 */,
12661268
/** i64x2.relaxed_laneselect */
1267-
RelaxedLaneselectI64x2 = 8 /* _BinaryenLaneselectI64x2 */,
1269+
RelaxedLaneselectI64x2 = 8 /* _BinaryenRelaxedLaneselectI64x2 */,
12681270
/** i32x4.relaxed_dot_i8x16_i7x16_add_s */
1269-
RelaxedDotI8x16I7x16AddToI32x4 = 9 /* _BinaryenDotI8x16I7x16AddSToVecI32x4 */,
1271+
RelaxedDotI8x16I7x16AddToI32x4 = 9 /* _BinaryenRelaxedDotI8x16I7x16AddSToVecI32x4 */,
12701272
// FIXME: f16x8 madd/nmadd (= 10, 11) are in wasm.h but not yet exported via C API
12711273
}
12721274

@@ -1275,9 +1277,25 @@ export const enum RefAsOp {
12751277
/** ref.as_non_null */
12761278
NonNull = 0 /* _BinaryenRefAsNonNull */,
12771279
/** any.convert_extern */
1278-
ExternInternalize = 1 /* _BinaryenRefAsAnyConvertExtern */,
1280+
AnyConvertExtern = 1 /* _BinaryenRefAsAnyConvertExtern */,
12791281
/** extern.convert_any */
1280-
ExternExternalize = 2 /* _BinaryenRefAsExternConvertAny */
1282+
ExternConvertAny = 2 /* _BinaryenRefAsExternConvertAny */
1283+
}
1284+
1285+
/** Binaryen wide integer add/sub operation constants. */
1286+
export const enum WideIntAddSubOp {
1287+
/** i64.add128 */
1288+
Add = 0 /* _BinaryenAddInt128 */,
1289+
/** i64.sub128 */
1290+
Sub = 1 /* _BinaryenSubInt128 */
1291+
}
1292+
1293+
/** Binaryen wide integer multiply operation constants. */
1294+
export const enum WideIntMulOp {
1295+
/** i64.mul_wide_s */
1296+
SignedI64 = 0 /* _BinaryenMulWideSInt64 */,
1297+
/** i64.mul_wide_u */
1298+
UnsignedI64 = 1 /* _BinaryenMulWideUInt64 */
12811299
}
12821300

12831301
/** Binaryen BrOn operation constants. */
@@ -1511,6 +1529,24 @@ export class Module {
15111529
return binaryen._BinaryenBinary(this.ref, op, left, right);
15121530
}
15131531

1532+
wide_int_add_sub(
1533+
op: WideIntAddSubOp,
1534+
leftLow: ExpressionRef,
1535+
leftHigh: ExpressionRef,
1536+
rightLow: ExpressionRef,
1537+
rightHigh: ExpressionRef
1538+
): ExpressionRef {
1539+
return binaryen._BinaryenWideIntAddSub(this.ref, op, leftLow, leftHigh, rightLow, rightHigh);
1540+
}
1541+
1542+
wide_int_mul(
1543+
op: WideIntMulOp,
1544+
left: ExpressionRef,
1545+
right: ExpressionRef
1546+
): ExpressionRef {
1547+
return binaryen._BinaryenWideIntMul(this.ref, op, left, right);
1548+
}
1549+
15141550
memory_size(name: string = CommonNames.DefaultMemory, is64: bool = false): ExpressionRef {
15151551
let cStr = this.allocStringCached(name);
15161552
return binaryen._BinaryenMemorySize(this.ref, cStr, is64);

tests/compiler/ternary.release.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
select
4949
)
5050
(func $export:ternary/testVoidInclTypeMismatch (param $0 i32) (param $1 i32)
51+
(local $2 i32)
5152
global.get $~lib/memory/__stack_pointer
5253
i32.const 4
5354
i32.sub
@@ -68,11 +69,11 @@
6869
i32.store
6970
local.get $1
7071
i32.load
72+
local.tee $2
7173
call_indirect (type $0)
7274
local.get $0
7375
if
74-
local.get $1
75-
i32.load
76+
local.get $2
7677
call_indirect (type $0)
7778
end
7879
local.get $0

0 commit comments

Comments
 (0)