@@ -27,6 +27,7 @@ use rustc_span::{Symbol, sym};
2727
2828pub ( crate ) use self :: llvm:: codegen_llvm_intrinsic_call;
2929use crate :: cast:: clif_intcast;
30+ use crate :: codegen_f16_f128;
3031use crate :: prelude:: * ;
3132
3233fn bug_on_incorrect_arg_count ( intrinsic : impl std:: fmt:: Display ) -> ! {
@@ -1118,6 +1119,20 @@ fn codegen_regular_intrinsic_call<'tcx>(
11181119 ret. write_cvalue ( fx, old) ;
11191120 }
11201121
1122+ sym:: minimumf16 => {
1123+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1124+ let a = a. load_scalar ( fx) ;
1125+ let b = b. load_scalar ( fx) ;
1126+
1127+ // FIXME(bytecodealliance/wasmtime#8312): Use `fmin` directly once
1128+ // Cranelift backend lowerings are implemented.
1129+ let a = codegen_f16_f128:: f16_to_f32 ( fx, a) ;
1130+ let b = codegen_f16_f128:: f16_to_f32 ( fx, b) ;
1131+ let val = fx. bcx . ins ( ) . fmin ( a, b) ;
1132+ let val = codegen_f16_f128:: f32_to_f16 ( fx, val) ;
1133+ let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f16 ) ) ;
1134+ ret. write_cvalue ( fx, val) ;
1135+ }
11211136 sym:: minimumf32 => {
11221137 intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
11231138 let a = a. load_scalar ( fx) ;
@@ -1136,6 +1151,31 @@ fn codegen_regular_intrinsic_call<'tcx>(
11361151 let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f64 ) ) ;
11371152 ret. write_cvalue ( fx, val) ;
11381153 }
1154+ sym:: minimumf128 => {
1155+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1156+ let a = a. load_scalar ( fx) ;
1157+ let b = b. load_scalar ( fx) ;
1158+
1159+ // FIXME(bytecodealliance/wasmtime#8312): Use `fmin` once Cranelift
1160+ // backend lowerings are implemented.
1161+ let val = codegen_f16_f128:: fmin_f128 ( fx, a, b) ;
1162+ let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f128 ) ) ;
1163+ ret. write_cvalue ( fx, val) ;
1164+ }
1165+ sym:: maximumf16 => {
1166+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1167+ let a = a. load_scalar ( fx) ;
1168+ let b = b. load_scalar ( fx) ;
1169+
1170+ // FIXME(bytecodealliance/wasmtime#8312): Use `fmax` directly once
1171+ // Cranelift backend lowerings are implemented.
1172+ let a = codegen_f16_f128:: f16_to_f32 ( fx, a) ;
1173+ let b = codegen_f16_f128:: f16_to_f32 ( fx, b) ;
1174+ let val = fx. bcx . ins ( ) . fmax ( a, b) ;
1175+ let val = codegen_f16_f128:: f32_to_f16 ( fx, val) ;
1176+ let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f16 ) ) ;
1177+ ret. write_cvalue ( fx, val) ;
1178+ }
11391179 sym:: maximumf32 => {
11401180 intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
11411181 let a = a. load_scalar ( fx) ;
@@ -1154,7 +1194,27 @@ fn codegen_regular_intrinsic_call<'tcx>(
11541194 let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f64 ) ) ;
11551195 ret. write_cvalue ( fx, val) ;
11561196 }
1197+ sym:: maximumf128 => {
1198+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1199+ let a = a. load_scalar ( fx) ;
1200+ let b = b. load_scalar ( fx) ;
1201+
1202+ // FIXME(bytecodealliance/wasmtime#8312): Use `fmax` once Cranelift
1203+ // backend lowerings are implemented.
1204+ let val = codegen_f16_f128:: fmax_f128 ( fx, a, b) ;
1205+ let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f128 ) ) ;
1206+ ret. write_cvalue ( fx, val) ;
1207+ }
1208+
1209+ sym:: minnumf16 => {
1210+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1211+ let a = a. load_scalar ( fx) ;
1212+ let b = b. load_scalar ( fx) ;
11571213
1214+ let val = crate :: num:: codegen_float_min ( fx, a, b) ;
1215+ let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f16 ) ) ;
1216+ ret. write_cvalue ( fx, val) ;
1217+ }
11581218 sym:: minnumf32 => {
11591219 intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
11601220 let a = a. load_scalar ( fx) ;
@@ -1173,6 +1233,24 @@ fn codegen_regular_intrinsic_call<'tcx>(
11731233 let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f64 ) ) ;
11741234 ret. write_cvalue ( fx, val) ;
11751235 }
1236+ sym:: minnumf128 => {
1237+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1238+ let a = a. load_scalar ( fx) ;
1239+ let b = b. load_scalar ( fx) ;
1240+
1241+ let val = crate :: num:: codegen_float_min ( fx, a, b) ;
1242+ let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f128 ) ) ;
1243+ ret. write_cvalue ( fx, val) ;
1244+ }
1245+ sym:: maxnumf16 => {
1246+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1247+ let a = a. load_scalar ( fx) ;
1248+ let b = b. load_scalar ( fx) ;
1249+
1250+ let val = crate :: num:: codegen_float_max ( fx, a, b) ;
1251+ let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f16 ) ) ;
1252+ ret. write_cvalue ( fx, val) ;
1253+ }
11761254 sym:: maxnumf32 => {
11771255 intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
11781256 let a = a. load_scalar ( fx) ;
@@ -1191,6 +1269,15 @@ fn codegen_regular_intrinsic_call<'tcx>(
11911269 let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f64 ) ) ;
11921270 ret. write_cvalue ( fx, val) ;
11931271 }
1272+ sym:: maxnumf128 => {
1273+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1274+ let a = a. load_scalar ( fx) ;
1275+ let b = b. load_scalar ( fx) ;
1276+
1277+ let val = crate :: num:: codegen_float_max ( fx, a, b) ;
1278+ let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f128 ) ) ;
1279+ ret. write_cvalue ( fx, val) ;
1280+ }
11941281
11951282 sym:: catch_unwind => {
11961283 intrinsic_args ! ( fx, args => ( f, data, catch_fn) ; intrinsic) ;
0 commit comments