@@ -323,6 +323,7 @@ export namespace BuiltinSymbols {
323
323
export const v128_all_true = "~lib/builtins/v128.all_true" ;
324
324
export const v128_min = "~lib/builtins/v128.min" ;
325
325
export const v128_max = "~lib/builtins/v128.max" ;
326
+ export const v128_dot = "~lib/builtins/v128.dot" ;
326
327
export const v128_abs = "~lib/builtins/v128.abs" ;
327
328
export const v128_sqrt = "~lib/builtins/v128.sqrt" ;
328
329
export const v128_eq = "~lib/builtins/v128.eq" ;
@@ -353,6 +354,10 @@ export namespace BuiltinSymbols {
353
354
export const i8x16_add = "~lib/builtins/i8x16.add" ;
354
355
export const i8x16_sub = "~lib/builtins/i8x16.sub" ;
355
356
export const i8x16_mul = "~lib/builtins/i8x16.mul" ;
357
+ export const i8x16_min_s = "~lib/builtins/i8x16.min_s" ;
358
+ export const i8x16_min_u = "~lib/builtins/i8x16.min_u" ;
359
+ export const i8x16_max_s = "~lib/builtins/i8x16.max_s" ;
360
+ export const i8x16_max_u = "~lib/builtins/i8x16.max_u" ;
356
361
export const i8x16_neg = "~lib/builtins/i8x16.neg" ;
357
362
export const i8x16_add_saturate_s = "~lib/builtins/i8x16.add_saturate_s" ;
358
363
export const i8x16_add_saturate_u = "~lib/builtins/i8x16.add_saturate_u" ;
@@ -383,6 +388,10 @@ export namespace BuiltinSymbols {
383
388
export const i16x8_add = "~lib/builtins/i16x8.add" ;
384
389
export const i16x8_sub = "~lib/builtins/i16x8.sub" ;
385
390
export const i16x8_mul = "~lib/builtins/i16x8.mul" ;
391
+ export const i16x8_min_s = "~lib/builtins/i16x8.min_s" ;
392
+ export const i16x8_min_u = "~lib/builtins/i16x8.min_u" ;
393
+ export const i16x8_max_s = "~lib/builtins/i16x8.max_s" ;
394
+ export const i16x8_max_u = "~lib/builtins/i16x8.max_u" ;
386
395
export const i16x8_neg = "~lib/builtins/i16x8.neg" ;
387
396
export const i16x8_add_saturate_s = "~lib/builtins/i16x8.add_saturate_s" ;
388
397
export const i16x8_add_saturate_u = "~lib/builtins/i16x8.add_saturate_u" ;
@@ -418,6 +427,11 @@ export namespace BuiltinSymbols {
418
427
export const i32x4_add = "~lib/builtins/i32x4.add" ;
419
428
export const i32x4_sub = "~lib/builtins/i32x4.sub" ;
420
429
export const i32x4_mul = "~lib/builtins/i32x4.mul" ;
430
+ export const i32x4_min_s = "~lib/builtins/i32x4.min_s" ;
431
+ export const i32x4_min_u = "~lib/builtins/i32x4.min_u" ;
432
+ export const i32x4_max_s = "~lib/builtins/i32x4.max_s" ;
433
+ export const i32x4_max_u = "~lib/builtins/i32x4.max_u" ;
434
+ export const i32x4_dot_i16x8_s = "~lib/builtins/i32x4.dot_i16x8_s" ;
421
435
export const i32x4_neg = "~lib/builtins/i32x4.neg" ;
422
436
export const i32x4_shl = "~lib/builtins/i32x4.shl" ;
423
437
export const i32x4_shr_s = "~lib/builtins/i32x4.shr_s" ;
@@ -3332,6 +3346,20 @@ export function compileCall(
3332
3346
let arg1 = compiler . compileExpression ( operands [ 1 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
3333
3347
if ( ! type . is ( TypeFlags . REFERENCE ) ) {
3334
3348
switch ( type . kind ) {
3349
+ case TypeKind . I8 : return module . binary ( BinaryOp . MinI8x16 , arg0 , arg1 ) ;
3350
+ case TypeKind . U8 : return module . binary ( BinaryOp . MinU8x16 , arg0 , arg1 ) ;
3351
+ case TypeKind . I16 : return module . binary ( BinaryOp . MinI16x8 , arg0 , arg1 ) ;
3352
+ case TypeKind . U16 : return module . binary ( BinaryOp . MinU16x8 , arg0 , arg1 ) ;
3353
+ case TypeKind . ISIZE : {
3354
+ if ( compiler . options . isWasm64 ) break ;
3355
+ // fall-through
3356
+ }
3357
+ case TypeKind . I32 : return module . binary ( BinaryOp . MinI32x4 , arg0 , arg1 ) ;
3358
+ case TypeKind . USIZE : {
3359
+ if ( compiler . options . isWasm64 ) break ;
3360
+ // fall-through
3361
+ }
3362
+ case TypeKind . U32 : return module . binary ( BinaryOp . MinU32x4 , arg0 , arg1 ) ;
3335
3363
case TypeKind . F32 : return module . binary ( BinaryOp . MinF32x4 , arg0 , arg1 ) ;
3336
3364
case TypeKind . F64 : return module . binary ( BinaryOp . MinF64x2 , arg0 , arg1 ) ;
3337
3365
}
@@ -3356,6 +3384,20 @@ export function compileCall(
3356
3384
let arg1 = compiler . compileExpression ( operands [ 1 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
3357
3385
if ( ! type . is ( TypeFlags . REFERENCE ) ) {
3358
3386
switch ( type . kind ) {
3387
+ case TypeKind . I8 : return module . binary ( BinaryOp . MaxI8x16 , arg0 , arg1 ) ;
3388
+ case TypeKind . U8 : return module . binary ( BinaryOp . MaxU8x16 , arg0 , arg1 ) ;
3389
+ case TypeKind . I16 : return module . binary ( BinaryOp . MaxI16x8 , arg0 , arg1 ) ;
3390
+ case TypeKind . U16 : return module . binary ( BinaryOp . MaxU16x8 , arg0 , arg1 ) ;
3391
+ case TypeKind . ISIZE : {
3392
+ if ( compiler . options . isWasm64 ) break ;
3393
+ // fall-through
3394
+ }
3395
+ case TypeKind . I32 : return module . binary ( BinaryOp . MaxI32x4 , arg0 , arg1 ) ;
3396
+ case TypeKind . USIZE : {
3397
+ if ( compiler . options . isWasm64 ) break ;
3398
+ // fall-through
3399
+ }
3400
+ case TypeKind . U32 : return module . binary ( BinaryOp . MaxU32x4 , arg0 , arg1 ) ;
3359
3401
case TypeKind . F32 : return module . binary ( BinaryOp . MaxF32x4 , arg0 , arg1 ) ;
3360
3402
case TypeKind . F64 : return module . binary ( BinaryOp . MaxF64x2 , arg0 , arg1 ) ;
3361
3403
}
@@ -3366,6 +3408,29 @@ export function compileCall(
3366
3408
) ;
3367
3409
return module . unreachable ( ) ;
3368
3410
}
3411
+ case BuiltinSymbols . v128_dot : { // dot<T!>(a: v128, b: v128) -> v128
3412
+ if (
3413
+ checkFeatureEnabled ( Feature . SIMD , reportNode , compiler ) |
3414
+ checkTypeRequired ( typeArguments , reportNode , compiler ) |
3415
+ checkArgsRequired ( operands , 2 , reportNode , compiler )
3416
+ ) {
3417
+ compiler . currentType = Type . v128 ;
3418
+ return module . unreachable ( ) ;
3419
+ }
3420
+ let type = typeArguments ! [ 0 ] ;
3421
+ let arg0 = compiler . compileExpression ( operands [ 0 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
3422
+ let arg1 = compiler . compileExpression ( operands [ 1 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
3423
+ if ( ! type . is ( TypeFlags . REFERENCE ) ) {
3424
+ switch ( type . kind ) {
3425
+ case TypeKind . I16 : return module . binary ( BinaryOp . DotI16x8 , arg0 , arg1 ) ;
3426
+ }
3427
+ }
3428
+ compiler . error (
3429
+ DiagnosticCode . Operation_0_cannot_be_applied_to_type_1 ,
3430
+ reportNode . typeArgumentsRange , "v128.dot" , type . toString ( )
3431
+ ) ;
3432
+ return module . unreachable ( ) ;
3433
+ }
3369
3434
case BuiltinSymbols . v128_eq : { // eq<T!>(a: v128, b: v128) -> v128
3370
3435
if (
3371
3436
checkFeatureEnabled ( Feature . SIMD , reportNode , compiler ) |
@@ -4501,6 +4566,10 @@ function tryDeferASM(
4501
4566
case BuiltinSymbols . i8x16_add : return deferASM ( BuiltinSymbols . v128_add , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4502
4567
case BuiltinSymbols . i8x16_sub : return deferASM ( BuiltinSymbols . v128_sub , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4503
4568
case BuiltinSymbols . i8x16_mul : return deferASM ( BuiltinSymbols . v128_mul , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4569
+ case BuiltinSymbols . i8x16_min_s : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4570
+ case BuiltinSymbols . i8x16_min_u : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . u8 , operands , Type . v128 , reportNode ) ;
4571
+ case BuiltinSymbols . i8x16_max_s : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4572
+ case BuiltinSymbols . i8x16_max_u : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . u8 , operands , Type . v128 , reportNode ) ;
4504
4573
case BuiltinSymbols . i8x16_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4505
4574
case BuiltinSymbols . i8x16_add_saturate_s : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4506
4575
case BuiltinSymbols . i8x16_add_saturate_u : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . u8 , operands , Type . v128 , reportNode ) ;
@@ -4531,6 +4600,10 @@ function tryDeferASM(
4531
4600
case BuiltinSymbols . i16x8_add : return deferASM ( BuiltinSymbols . v128_add , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4532
4601
case BuiltinSymbols . i16x8_sub : return deferASM ( BuiltinSymbols . v128_sub , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4533
4602
case BuiltinSymbols . i16x8_mul : return deferASM ( BuiltinSymbols . v128_mul , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4603
+ case BuiltinSymbols . i16x8_min_s : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4604
+ case BuiltinSymbols . i16x8_min_u : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
4605
+ case BuiltinSymbols . i16x8_max_s : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4606
+ case BuiltinSymbols . i16x8_max_u : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
4534
4607
case BuiltinSymbols . i16x8_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4535
4608
case BuiltinSymbols . i16x8_add_saturate_s : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4536
4609
case BuiltinSymbols . i16x8_add_saturate_u : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
@@ -4566,6 +4639,11 @@ function tryDeferASM(
4566
4639
case BuiltinSymbols . i32x4_add : return deferASM ( BuiltinSymbols . v128_add , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
4567
4640
case BuiltinSymbols . i32x4_sub : return deferASM ( BuiltinSymbols . v128_sub , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
4568
4641
case BuiltinSymbols . i32x4_mul : return deferASM ( BuiltinSymbols . v128_mul , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
4642
+ case BuiltinSymbols . i32x4_min_s : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
4643
+ case BuiltinSymbols . i32x4_min_u : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . u32 , operands , Type . v128 , reportNode ) ;
4644
+ case BuiltinSymbols . i32x4_max_s : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
4645
+ case BuiltinSymbols . i32x4_max_u : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . u32 , operands , Type . v128 , reportNode ) ;
4646
+ case BuiltinSymbols . i32x4_dot_i16x8_s : return deferASM ( BuiltinSymbols . v128_dot , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4569
4647
case BuiltinSymbols . i32x4_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
4570
4648
case BuiltinSymbols . i32x4_shl : return deferASM ( BuiltinSymbols . v128_shl , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
4571
4649
case BuiltinSymbols . i32x4_shr_s : return deferASM ( BuiltinSymbols . v128_shr , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
0 commit comments