@@ -323,6 +323,7 @@ export namespace BuiltinSymbols {
323323 export const v128_all_true = "~lib/builtins/v128.all_true" ;
324324 export const v128_min = "~lib/builtins/v128.min" ;
325325 export const v128_max = "~lib/builtins/v128.max" ;
326+ export const v128_dot = "~lib/builtins/v128.dot" ;
326327 export const v128_abs = "~lib/builtins/v128.abs" ;
327328 export const v128_sqrt = "~lib/builtins/v128.sqrt" ;
328329 export const v128_eq = "~lib/builtins/v128.eq" ;
@@ -353,6 +354,10 @@ export namespace BuiltinSymbols {
353354 export const i8x16_add = "~lib/builtins/i8x16.add" ;
354355 export const i8x16_sub = "~lib/builtins/i8x16.sub" ;
355356 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" ;
356361 export const i8x16_neg = "~lib/builtins/i8x16.neg" ;
357362 export const i8x16_add_saturate_s = "~lib/builtins/i8x16.add_saturate_s" ;
358363 export const i8x16_add_saturate_u = "~lib/builtins/i8x16.add_saturate_u" ;
@@ -383,6 +388,10 @@ export namespace BuiltinSymbols {
383388 export const i16x8_add = "~lib/builtins/i16x8.add" ;
384389 export const i16x8_sub = "~lib/builtins/i16x8.sub" ;
385390 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" ;
386395 export const i16x8_neg = "~lib/builtins/i16x8.neg" ;
387396 export const i16x8_add_saturate_s = "~lib/builtins/i16x8.add_saturate_s" ;
388397 export const i16x8_add_saturate_u = "~lib/builtins/i16x8.add_saturate_u" ;
@@ -418,6 +427,11 @@ export namespace BuiltinSymbols {
418427 export const i32x4_add = "~lib/builtins/i32x4.add" ;
419428 export const i32x4_sub = "~lib/builtins/i32x4.sub" ;
420429 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" ;
421435 export const i32x4_neg = "~lib/builtins/i32x4.neg" ;
422436 export const i32x4_shl = "~lib/builtins/i32x4.shl" ;
423437 export const i32x4_shr_s = "~lib/builtins/i32x4.shr_s" ;
@@ -3332,6 +3346,20 @@ export function compileCall(
33323346 let arg1 = compiler . compileExpression ( operands [ 1 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
33333347 if ( ! type . is ( TypeFlags . REFERENCE ) ) {
33343348 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 ) ;
33353363 case TypeKind . F32 : return module . binary ( BinaryOp . MinF32x4 , arg0 , arg1 ) ;
33363364 case TypeKind . F64 : return module . binary ( BinaryOp . MinF64x2 , arg0 , arg1 ) ;
33373365 }
@@ -3356,6 +3384,20 @@ export function compileCall(
33563384 let arg1 = compiler . compileExpression ( operands [ 1 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
33573385 if ( ! type . is ( TypeFlags . REFERENCE ) ) {
33583386 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 ) ;
33593401 case TypeKind . F32 : return module . binary ( BinaryOp . MaxF32x4 , arg0 , arg1 ) ;
33603402 case TypeKind . F64 : return module . binary ( BinaryOp . MaxF64x2 , arg0 , arg1 ) ;
33613403 }
@@ -3366,6 +3408,29 @@ export function compileCall(
33663408 ) ;
33673409 return module . unreachable ( ) ;
33683410 }
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+ }
33693434 case BuiltinSymbols . v128_eq : { // eq<T!>(a: v128, b: v128) -> v128
33703435 if (
33713436 checkFeatureEnabled ( Feature . SIMD , reportNode , compiler ) |
@@ -4501,6 +4566,10 @@ function tryDeferASM(
45014566 case BuiltinSymbols . i8x16_add : return deferASM ( BuiltinSymbols . v128_add , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
45024567 case BuiltinSymbols . i8x16_sub : return deferASM ( BuiltinSymbols . v128_sub , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
45034568 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 ) ;
45044573 case BuiltinSymbols . i8x16_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
45054574 case BuiltinSymbols . i8x16_add_saturate_s : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
45064575 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(
45314600 case BuiltinSymbols . i16x8_add : return deferASM ( BuiltinSymbols . v128_add , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
45324601 case BuiltinSymbols . i16x8_sub : return deferASM ( BuiltinSymbols . v128_sub , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
45334602 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 ) ;
45344607 case BuiltinSymbols . i16x8_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
45354608 case BuiltinSymbols . i16x8_add_saturate_s : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
45364609 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(
45664639 case BuiltinSymbols . i32x4_add : return deferASM ( BuiltinSymbols . v128_add , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
45674640 case BuiltinSymbols . i32x4_sub : return deferASM ( BuiltinSymbols . v128_sub , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
45684641 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 ) ;
45694647 case BuiltinSymbols . i32x4_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
45704648 case BuiltinSymbols . i32x4_shl : return deferASM ( BuiltinSymbols . v128_shl , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
45714649 case BuiltinSymbols . i32x4_shr_s : return deferASM ( BuiltinSymbols . v128_shr , compiler , Type . i32 , operands , Type . v128 , reportNode ) ;
0 commit comments