@@ -352,6 +352,8 @@ export namespace BuiltinNames {
352
352
export const v128_bitmask = "~lib/builtins/v128.bitmask" ;
353
353
export const v128_min = "~lib/builtins/v128.min" ;
354
354
export const v128_max = "~lib/builtins/v128.max" ;
355
+ export const v128_pmin = "~lib/builtins/v128.pmin" ;
356
+ export const v128_pmax = "~lib/builtins/v128.pmax" ;
355
357
export const v128_dot = "~lib/builtins/v128.dot" ;
356
358
export const v128_avgr = "~lib/builtins/v128.avgr" ;
357
359
export const v128_abs = "~lib/builtins/v128.abs" ;
@@ -521,6 +523,8 @@ export namespace BuiltinNames {
521
523
export const f32x4_neg = "~lib/builtins/f32x4.neg" ;
522
524
export const f32x4_min = "~lib/builtins/f32x4.min" ;
523
525
export const f32x4_max = "~lib/builtins/f32x4.max" ;
526
+ export const f32x4_pmin = "~lib/builtins/f32x4.pmin" ;
527
+ export const f32x4_pmax = "~lib/builtins/f32x4.pmax" ;
524
528
export const f32x4_abs = "~lib/builtins/f32x4.abs" ;
525
529
export const f32x4_sqrt = "~lib/builtins/f32x4.sqrt" ;
526
530
export const f32x4_eq = "~lib/builtins/f32x4.eq" ;
@@ -544,6 +548,8 @@ export namespace BuiltinNames {
544
548
export const f64x2_neg = "~lib/builtins/f64x2.neg" ;
545
549
export const f64x2_min = "~lib/builtins/f64x2.min" ;
546
550
export const f64x2_max = "~lib/builtins/f64x2.max" ;
551
+ export const f64x2_pmin = "~lib/builtins/f64x2.pmin" ;
552
+ export const f64x2_pmax = "~lib/builtins/f64x2.pmax" ;
547
553
export const f64x2_abs = "~lib/builtins/f64x2.abs" ;
548
554
export const f64x2_sqrt = "~lib/builtins/f64x2.sqrt" ;
549
555
export const f64x2_eq = "~lib/builtins/f64x2.eq" ;
@@ -3969,6 +3975,68 @@ function builtin_v128_max(ctx: BuiltinContext): ExpressionRef {
3969
3975
}
3970
3976
builtins . set ( BuiltinNames . v128_max , builtin_v128_max ) ;
3971
3977
3978
+ // v128.pmin<T!>(a: v128, b: v128) -> v128
3979
+ function builtin_v128_pmin ( ctx : BuiltinContext ) : ExpressionRef {
3980
+ var compiler = ctx . compiler ;
3981
+ var module = compiler . module ;
3982
+ if (
3983
+ checkFeatureEnabled ( ctx , Feature . SIMD ) |
3984
+ checkTypeRequired ( ctx ) |
3985
+ checkArgsRequired ( ctx , 2 )
3986
+ ) {
3987
+ compiler . currentType = Type . v128 ;
3988
+ return module . unreachable ( ) ;
3989
+ }
3990
+ var operands = ctx . operands ;
3991
+ var typeArguments = ctx . typeArguments ! ;
3992
+ var type = typeArguments [ 0 ] ;
3993
+ var arg0 = compiler . compileExpression ( operands [ 0 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
3994
+ var arg1 = compiler . compileExpression ( operands [ 1 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
3995
+ if ( ! type . is ( TypeFlags . REFERENCE ) ) {
3996
+ switch ( type . kind ) {
3997
+ case TypeKind . F32 : return module . binary ( BinaryOp . PminF32x4 , arg0 , arg1 ) ;
3998
+ case TypeKind . F64 : return module . binary ( BinaryOp . PminF64x2 , arg0 , arg1 ) ;
3999
+ }
4000
+ }
4001
+ compiler . error (
4002
+ DiagnosticCode . Operation_0_cannot_be_applied_to_type_1 ,
4003
+ ctx . reportNode . typeArgumentsRange , "v128.pmin" , type . toString ( )
4004
+ ) ;
4005
+ return module . unreachable ( ) ;
4006
+ }
4007
+ builtins . set ( BuiltinNames . v128_pmin , builtin_v128_pmin ) ;
4008
+
4009
+ // v128.pmax<T!>(a: v128, b: v128) -> v128
4010
+ function builtin_v128_pmax ( ctx : BuiltinContext ) : ExpressionRef {
4011
+ var compiler = ctx . compiler ;
4012
+ var module = compiler . module ;
4013
+ if (
4014
+ checkFeatureEnabled ( ctx , Feature . SIMD ) |
4015
+ checkTypeRequired ( ctx ) |
4016
+ checkArgsRequired ( ctx , 2 )
4017
+ ) {
4018
+ compiler . currentType = Type . v128 ;
4019
+ return module . unreachable ( ) ;
4020
+ }
4021
+ var operands = ctx . operands ;
4022
+ var typeArguments = ctx . typeArguments ! ;
4023
+ var type = typeArguments [ 0 ] ;
4024
+ var arg0 = compiler . compileExpression ( operands [ 0 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
4025
+ var arg1 = compiler . compileExpression ( operands [ 1 ] , Type . v128 , Constraints . CONV_IMPLICIT ) ;
4026
+ if ( ! type . is ( TypeFlags . REFERENCE ) ) {
4027
+ switch ( type . kind ) {
4028
+ case TypeKind . F32 : return module . binary ( BinaryOp . PmaxF32x4 , arg0 , arg1 ) ;
4029
+ case TypeKind . F64 : return module . binary ( BinaryOp . PmaxF64x2 , arg0 , arg1 ) ;
4030
+ }
4031
+ }
4032
+ compiler . error (
4033
+ DiagnosticCode . Operation_0_cannot_be_applied_to_type_1 ,
4034
+ ctx . reportNode . typeArgumentsRange , "v128.pmax" , type . toString ( )
4035
+ ) ;
4036
+ return module . unreachable ( ) ;
4037
+ }
4038
+ builtins . set ( BuiltinNames . v128_pmax , builtin_v128_pmax ) ;
4039
+
3972
4040
// v128.dot<T!>(a: v128, b: v128) -> v128
3973
4041
function builtin_v128_dot ( ctx : BuiltinContext ) : ExpressionRef {
3974
4042
var compiler = ctx . compiler ;
@@ -7444,6 +7512,24 @@ function builtin_f32x4_max(ctx: BuiltinContext): ExpressionRef {
7444
7512
}
7445
7513
builtins . set ( BuiltinNames . f32x4_max , builtin_f32x4_max ) ;
7446
7514
7515
+ // f32x4.pmin -> v128.pmin<f32>
7516
+ function builtin_f32x4_pmin ( ctx : BuiltinContext ) : ExpressionRef {
7517
+ checkTypeAbsent ( ctx ) ;
7518
+ ctx . typeArguments = [ Type . f32 ] ;
7519
+ ctx . contextualType = Type . v128 ;
7520
+ return builtin_v128_pmin ( ctx ) ;
7521
+ }
7522
+ builtins . set ( BuiltinNames . f32x4_pmin , builtin_f32x4_pmin ) ;
7523
+
7524
+ // f32x4.pmax -> v128.pmax<f32>
7525
+ function builtin_f32x4_pmax ( ctx : BuiltinContext ) : ExpressionRef {
7526
+ checkTypeAbsent ( ctx ) ;
7527
+ ctx . typeArguments = [ Type . f32 ] ;
7528
+ ctx . contextualType = Type . v128 ;
7529
+ return builtin_v128_pmax ( ctx ) ;
7530
+ }
7531
+ builtins . set ( BuiltinNames . f32x4_pmax , builtin_f32x4_pmax ) ;
7532
+
7447
7533
// f32x4.abs -> v128.abs<f32>
7448
7534
function builtin_f32x4_abs ( ctx : BuiltinContext ) : ExpressionRef {
7449
7535
checkTypeAbsent ( ctx ) ;
@@ -7642,6 +7728,24 @@ function builtin_f64x2_max(ctx: BuiltinContext): ExpressionRef {
7642
7728
}
7643
7729
builtins . set ( BuiltinNames . f64x2_max , builtin_f64x2_max ) ;
7644
7730
7731
+ // f64x2.pmin -> v128.pmin<f64>
7732
+ function builtin_f64x2_pmin ( ctx : BuiltinContext ) : ExpressionRef {
7733
+ checkTypeAbsent ( ctx ) ;
7734
+ ctx . typeArguments = [ Type . f64 ] ;
7735
+ ctx . contextualType = Type . v128 ;
7736
+ return builtin_v128_pmin ( ctx ) ;
7737
+ }
7738
+ builtins . set ( BuiltinNames . f64x2_pmin , builtin_f64x2_pmin ) ;
7739
+
7740
+ // f64x2.pmax -> v128.pmax<f64>
7741
+ function builtin_f64x2_pmax ( ctx : BuiltinContext ) : ExpressionRef {
7742
+ checkTypeAbsent ( ctx ) ;
7743
+ ctx . typeArguments = [ Type . f64 ] ;
7744
+ ctx . contextualType = Type . v128 ;
7745
+ return builtin_v128_pmax ( ctx ) ;
7746
+ }
7747
+ builtins . set ( BuiltinNames . f64x2_pmax , builtin_f64x2_pmax ) ;
7748
+
7645
7749
// f64x2.abs -> v128.abs<f64>
7646
7750
function builtin_f64x2_abs ( ctx : BuiltinContext ) : ExpressionRef {
7647
7751
checkTypeAbsent ( ctx ) ;
0 commit comments