@@ -1142,6 +1142,19 @@ extern "rust-intrinsic" {
1142
1142
/// Returns the absolute value of an `f64`.
1143
1143
pub fn fabsf64 ( x : f64 ) -> f64 ;
1144
1144
1145
+ /// Returns the minimum of two `f32` values.
1146
+ #[ cfg( not( stage0) ) ]
1147
+ pub fn minnumf32 ( x : f32 , y : f32 ) -> f32 ;
1148
+ /// Returns the minimum of two `f64` values.
1149
+ #[ cfg( not( stage0) ) ]
1150
+ pub fn minnumf64 ( x : f64 , y : f64 ) -> f64 ;
1151
+ /// Returns the maximum of two `f32` values.
1152
+ #[ cfg( not( stage0) ) ]
1153
+ pub fn maxnumf32 ( x : f32 , y : f32 ) -> f32 ;
1154
+ /// Returns the maximum of two `f64` values.
1155
+ #[ cfg( not( stage0) ) ]
1156
+ pub fn maxnumf64 ( x : f64 , y : f64 ) -> f64 ;
1157
+
1145
1158
/// Copies the sign from `y` to `x` for `f32` values.
1146
1159
pub fn copysignf32 ( x : f32 , y : f32 ) -> f32 ;
1147
1160
/// Copies the sign from `y` to `x` for `f64` values.
@@ -1393,3 +1406,44 @@ extern "rust-intrinsic" {
1393
1406
#[ cfg( not( stage0) ) ]
1394
1407
pub fn nontemporal_store < T > ( ptr : * mut T , val : T ) ;
1395
1408
}
1409
+
1410
+ // Simple bootstrap implementations for stage0 compilation
1411
+
1412
+ /// Returns the minimum of two `f32` values.
1413
+ #[ cfg( stage0) ]
1414
+ pub unsafe fn minnumf32 ( x : f32 , y : f32 ) -> f32 {
1415
+ // IEEE754 says: minNum(x, y) is the canonicalized number x if x < y, y if y < x, the
1416
+ // canonicalized number if one operand is a number and the other a quiet NaN. Otherwise it
1417
+ // is either x or y, canonicalized (this means results might differ among implementations).
1418
+ // When either x or y is a signalingNaN, then the result is according to 6.2.
1419
+ //
1420
+ // Since we do not support sNaN in Rust yet, we do not need to handle them.
1421
+ // FIXME(nagisa): due to https://bugs.llvm.org/show_bug.cgi?id=33303 we canonicalize by
1422
+ // multiplying by 1.0. Should switch to the `canonicalize` when it works.
1423
+ ( if x < y || y != y { x } else { y } ) * 1.0
1424
+ }
1425
+ /// Returns the minimum of two `f64` values.
1426
+ #[ cfg( stage0) ]
1427
+ pub unsafe fn minnumf64 ( x : f64 , y : f64 ) -> f64 {
1428
+ // Identical to the `f32` case.
1429
+ ( if x < y || y != y { x } else { y } ) * 1.0
1430
+ }
1431
+ /// Returns the maximum of two `f32` values.
1432
+ #[ cfg( stage0) ]
1433
+ pub unsafe fn maxnumf32 ( x : f32 , y : f32 ) -> f32 {
1434
+ // IEEE754 says: maxNum(x, y) is the canonicalized number y if x < y, x if y < x, the
1435
+ // canonicalized number if one operand is a number and the other a quiet NaN. Otherwise it
1436
+ // is either x or y, canonicalized (this means results might differ among implementations).
1437
+ // When either x or y is a signalingNaN, then the result is according to 6.2.
1438
+ //
1439
+ // Since we do not support sNaN in Rust yet, we do not need to handle them.
1440
+ // FIXME(nagisa): due to https://bugs.llvm.org/show_bug.cgi?id=33303 we canonicalize by
1441
+ // multiplying by 1.0. Should switch to the `canonicalize` when it works.
1442
+ ( if x < y || x != x { y } else { x } ) * 1.0
1443
+ }
1444
+ /// Returns the maximum of two `f64` values.
1445
+ #[ cfg( stage0) ]
1446
+ pub unsafe fn maxnumf64 ( x : f64 , y : f64 ) -> f64 {
1447
+ // Identical to the `f32` case.
1448
+ ( if x < y || x != x { y } else { x } ) * 1.0
1449
+ }
0 commit comments