@@ -323,6 +323,7 @@ export namespace BuiltinSymbols {
323323 export const v128_min = "~lib/builtins/v128.min" ;
324324 export const v128_max = "~lib/builtins/v128.max" ;
325325 export const v128_dot = "~lib/builtins/v128.dot" ;
326+ export const v128_avgr = "~lib/builtins/v128.avgr" ;
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" ;
@@ -357,6 +358,7 @@ export namespace BuiltinSymbols {
357358 export const i8x16_min_u = "~lib/builtins/i8x16.min_u" ;
358359 export const i8x16_max_s = "~lib/builtins/i8x16.max_s" ;
359360 export const i8x16_max_u = "~lib/builtins/i8x16.max_u" ;
361+ export const i8x16_avgr_u = "~lib/builtins/i8x16.avgr_u" ;
360362 export const i8x16_neg = "~lib/builtins/i8x16.neg" ;
361363 export const i8x16_add_saturate_s = "~lib/builtins/i8x16.add_saturate_s" ;
362364 export const i8x16_add_saturate_u = "~lib/builtins/i8x16.add_saturate_u" ;
@@ -391,6 +393,7 @@ export namespace BuiltinSymbols {
391393 export const i16x8_min_u = "~lib/builtins/i16x8.min_u" ;
392394 export const i16x8_max_s = "~lib/builtins/i16x8.max_s" ;
393395 export const i16x8_max_u = "~lib/builtins/i16x8.max_u" ;
396+ export const i16x8_avgr_u = "~lib/builtins/i16x8.avgr_u" ;
394397 export const i16x8_neg = "~lib/builtins/i16x8.neg" ;
395398 export const i16x8_add_saturate_s = "~lib/builtins/i16x8.add_saturate_s" ;
396399 export const i16x8_add_saturate_u = "~lib/builtins/i16x8.add_saturate_u" ;
@@ -850,7 +853,7 @@ export function compileCall(
850853 }
851854 offset = ( < Field > field ) . memoryOffset ;
852855 } else {
853- offset = classType . currentMemoryOffset ;
856+ offset = classType . nextMemoryOffset ;
854857 }
855858 if ( compiler . options . isWasm64 ) {
856859 // implicitly wrap if contextual type is a 32-bit integer
@@ -3377,6 +3380,30 @@ export function compileCall(
33773380 ) ;
33783381 return module . unreachable ( ) ;
33793382 }
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+ }
33803407 case BuiltinSymbols . v128_eq : { // eq<T!>(a: v128, b: v128) -> v128
33813408 if (
33823409 checkFeatureEnabled ( Feature . SIMD , reportNode , compiler ) |
@@ -4516,6 +4543,7 @@ function tryDeferASM(
45164543 case BuiltinSymbols . i8x16_min_u : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . u8 , operands , Type . v128 , reportNode ) ;
45174544 case BuiltinSymbols . i8x16_max_s : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
45184545 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 ) ;
45194547 case BuiltinSymbols . i8x16_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
45204548 case BuiltinSymbols . i8x16_add_saturate_s : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . i8 , operands , Type . v128 , reportNode ) ;
45214549 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(
45504578 case BuiltinSymbols . i16x8_min_u : return deferASM ( BuiltinSymbols . v128_min , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
45514579 case BuiltinSymbols . i16x8_max_s : return deferASM ( BuiltinSymbols . v128_max , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
45524580 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 ) ;
45534582 case BuiltinSymbols . i16x8_neg : return deferASM ( BuiltinSymbols . v128_neg , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
45544583 case BuiltinSymbols . i16x8_add_saturate_s : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . i16 , operands , Type . v128 , reportNode ) ;
45554584 case BuiltinSymbols . i16x8_add_saturate_u : return deferASM ( BuiltinSymbols . v128_add_saturate , compiler , Type . u16 , operands , Type . v128 , reportNode ) ;
0 commit comments