@@ -27,6 +27,7 @@ use rustc_span::{Symbol, sym};
27
27
28
28
pub ( crate ) use self :: llvm:: codegen_llvm_intrinsic_call;
29
29
use crate :: cast:: clif_intcast;
30
+ use crate :: codegen_f16_f128;
30
31
use crate :: prelude:: * ;
31
32
32
33
fn bug_on_incorrect_arg_count ( intrinsic : impl std:: fmt:: Display ) -> ! {
@@ -1118,6 +1119,20 @@ fn codegen_regular_intrinsic_call<'tcx>(
1118
1119
ret. write_cvalue ( fx, old) ;
1119
1120
}
1120
1121
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
+ }
1121
1136
sym:: minimumf32 => {
1122
1137
intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1123
1138
let a = a. load_scalar ( fx) ;
@@ -1136,6 +1151,31 @@ fn codegen_regular_intrinsic_call<'tcx>(
1136
1151
let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f64 ) ) ;
1137
1152
ret. write_cvalue ( fx, val) ;
1138
1153
}
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
+ }
1139
1179
sym:: maximumf32 => {
1140
1180
intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1141
1181
let a = a. load_scalar ( fx) ;
@@ -1154,7 +1194,27 @@ fn codegen_regular_intrinsic_call<'tcx>(
1154
1194
let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f64 ) ) ;
1155
1195
ret. write_cvalue ( fx, val) ;
1156
1196
}
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) ;
1157
1213
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
+ }
1158
1218
sym:: minnumf32 => {
1159
1219
intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1160
1220
let a = a. load_scalar ( fx) ;
@@ -1173,6 +1233,24 @@ fn codegen_regular_intrinsic_call<'tcx>(
1173
1233
let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f64 ) ) ;
1174
1234
ret. write_cvalue ( fx, val) ;
1175
1235
}
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
+ }
1176
1254
sym:: maxnumf32 => {
1177
1255
intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
1178
1256
let a = a. load_scalar ( fx) ;
@@ -1191,6 +1269,15 @@ fn codegen_regular_intrinsic_call<'tcx>(
1191
1269
let val = CValue :: by_val ( val, fx. layout_of ( fx. tcx . types . f64 ) ) ;
1192
1270
ret. write_cvalue ( fx, val) ;
1193
1271
}
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
+ }
1194
1281
1195
1282
sym:: catch_unwind => {
1196
1283
intrinsic_args ! ( fx, args => ( f, data, catch_fn) ; intrinsic) ;
0 commit comments