@@ -323,6 +323,7 @@ export namespace BuiltinSymbols {
323
323
export const v128_min = "~lib/builtins/v128.min" ;
324
324
export const v128_max = "~lib/builtins/v128.max" ;
325
325
export const v128_dot = "~lib/builtins/v128.dot" ;
326
+ export const v128_avgr = "~lib/builtins/v128.avgr" ;
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" ;
@@ -357,6 +358,7 @@ export namespace BuiltinSymbols {
357
358
export const i8x16_min_u = "~lib/builtins/i8x16.min_u" ;
358
359
export const i8x16_max_s = "~lib/builtins/i8x16.max_s" ;
359
360
export const i8x16_max_u = "~lib/builtins/i8x16.max_u" ;
361
+ export const i8x16_avgr_u = "~lib/builtins/i8x16.avgr_u" ;
360
362
export const i8x16_neg = "~lib/builtins/i8x16.neg" ;
361
363
export const i8x16_add_saturate_s = "~lib/builtins/i8x16.add_saturate_s" ;
362
364
export const i8x16_add_saturate_u = "~lib/builtins/i8x16.add_saturate_u" ;
@@ -391,6 +393,7 @@ export namespace BuiltinSymbols {
391
393
export const i16x8_min_u = "~lib/builtins/i16x8.min_u" ;
392
394
export const i16x8_max_s = "~lib/builtins/i16x8.max_s" ;
393
395
export const i16x8_max_u = "~lib/builtins/i16x8.max_u" ;
396
+ export const i16x8_avgr_u = "~lib/builtins/i16x8.avgr_u" ;
394
397
export const i16x8_neg = "~lib/builtins/i16x8.neg" ;
395
398
export const i16x8_add_saturate_s = "~lib/builtins/i16x8.add_saturate_s" ;
396
399
export const i16x8_add_saturate_u = "~lib/builtins/i16x8.add_saturate_u" ;
@@ -3377,6 +3380,30 @@ export function compileCall(
3377
3380
) ;
3378
3381
return module . unreachable ( ) ;
3379
3382
}
3383
+ case BuiltinSymbols . v128_avgr : { // avgr<T!>(a: v128, b: v128) -> v128
3384
+ if (
3385
+ checkFeatureEnabled ( Feature . SIMD , reportNode , compiler ) |
3386
+ checkTypeRequired ( typeArguments , reportNode , compiler ) |
3387
+ checkArgsRequired ( operands , 2 , reportNode , compiler )
3388
+ ) {
3389
+ compiler . currentType = Type . v128 ;
3390
+ return module . unreachable ( ) ;
3391
+ }
3392
+ let type = typeArguments ! [ 0 ] ;
3393
+ let arg0 = compiler . compileExpression ( operands [ 0 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
3394
+ let arg1 = compiler . compileExpression ( operands [ 1 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
3395
+ if ( ! type . is ( TypeFlags . REFERENCE ) ) {
3396
+ switch ( type . kind ) {
3397
+ case TypeKind . U8 : return module . binary ( BinaryOp . AvgrU8x16 , arg0 , arg1 ) ;
3398
+ case TypeKind . U16 : return module . binary ( BinaryOp . AvgrU16x8 , arg0 , arg1 ) ;
3399
+ }
3400
+ }
3401
+ compiler . error (
3402
+ DiagnosticCode . Operation_0_cannot_be_applied_to_type_1 ,
3403
+ reportNode . typeArgumentsRange , "v128.avgr" , type . toString ( )
3404
+ ) ;
3405
+ return module . unreachable ( ) ;
3406
+ }
3380
3407
case BuiltinSymbols . v128_eq : { // eq<T!>(a: v128, b: v128) -> v128
3381
3408
if (
3382
3409
checkFeatureEnabled ( Feature . SIMD , reportNode , compiler ) |
@@ -4516,6 +4543,7 @@ function tryDeferASM(
4516
4543
case BuiltinSymbols . i8x16_min_u : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . u8 , operands , Type . v128 , reportNode ) ;
4517
4544
case BuiltinSymbols . i8x16_max_s : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4518
4545
case BuiltinSymbols . i8x16_max_u : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . u8 , operands , Type . v128 , reportNode ) ;
4546
+ case BuiltinSymbols . i8x16_avgr_u : return deferASM ( BuiltinSymbols . v128_avgr , compiler , Type . u8 , operands , Type . v128 , reportNode ) ;
4519
4547
case BuiltinSymbols . i8x16_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4520
4548
case BuiltinSymbols . i8x16_add_saturate_s : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
4521
4549
case BuiltinSymbols . i8x16_add_saturate_u : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . u8 , operands , Type . v128 , reportNode ) ;
@@ -4550,6 +4578,7 @@ function tryDeferASM(
4550
4578
case BuiltinSymbols . i16x8_min_u : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
4551
4579
case BuiltinSymbols . i16x8_max_s : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4552
4580
case BuiltinSymbols . i16x8_max_u : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
4581
+ case BuiltinSymbols . i16x8_avgr_u : return deferASM ( BuiltinSymbols . v128_avgr , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
4553
4582
case BuiltinSymbols . i16x8_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4554
4583
case BuiltinSymbols . i16x8_add_saturate_s : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
4555
4584
case BuiltinSymbols . i16x8_add_saturate_u : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
0 commit comments