Skip to content

Commit 48b9a6c

Browse files
Rollup merge of rust-lang#151527 - tgross35:f16-fixme-cleanup, r=folkertdev
Clean up or resolve cfg-related instances of `FIXME(f16_f128)` * Replace target-specific config that has a `FIXME` with `cfg(target_has_reliable_f*)` * Take care of trivial intrinsic-related FIXMEs * Split `FIXME(f16_f128)` into `FIXME(f16)`, `FIXME(f128)`, or `FIXME(f16,f128)` to more clearly identify what they block The individual commit messages have more details.
2 parents fe07e74 + 490b307 commit 48b9a6c

17 files changed

Lines changed: 59 additions & 108 deletions

File tree

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@ impl MsvcBasicName for ty::UintTy {
665665

666666
impl MsvcBasicName for ty::FloatTy {
667667
fn msvc_basic_name(self) -> &'static str {
668-
// FIXME(f16_f128): `f16` and `f128` have no MSVC representation. We could improve the
669-
// debuginfo. See: <https://github.com/rust-lang/rust/issues/121837>
668+
// FIXME(f128): `f128` has no MSVC representation. We could improve the debuginfo.
669+
// See: <https://github.com/rust-lang/rust/issues/121837>
670670
match self {
671671
ty::FloatTy::F16 => {
672672
bug!("`f16` should have been handled in `build_basic_type_di_node`")

compiler/rustc_target/src/asm/riscv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl RiscVInlineAsmRegClass {
4747
types! { _: I8, I16, I32, F16, F32; }
4848
}
4949
}
50-
// FIXME(f16_f128): Add `q: F128;` once LLVM support the `Q` extension.
50+
// FIXME(f128): Add `q: F128;` once LLVM support the `Q` extension.
5151
Self::freg => types! { f: F16, F32; d: F64; },
5252
Self::vreg => &[],
5353
}

library/core/src/convert/num.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl_from!(i16 => isize, #[stable(feature = "lossless_iusize_conv", since = "1.2
154154
// * 53 bits in f64
155155
// * 113 bits in f128
156156
// Lossy float conversions are not implemented at this time.
157-
// FIXME(f16_f128): The `f16`/`f128` impls `#[stable]` attributes should be changed to reference
157+
// FIXME(f16,f128): The `f16`/`f128` impls `#[stable]` attributes should be changed to reference
158158
// `f16`/`f128` when they are stabilised (trait impls have to have a `#[stable]` attribute, but none
159159
// of the `f16`/`f128` impls can be used on stable as the `f16` and `f128` types are unstable).
160160

@@ -168,7 +168,7 @@ impl_from!(i16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0"
168168
impl_from!(i16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
169169
impl_from!(i32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
170170
impl_from!(i32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
171-
// FIXME(f16_f128): This impl would allow using `f128` on stable before it is stabilised.
171+
// FIXME(f128): This impl would allow using `f128` on stable before it is stabilised.
172172
// impl_from!(i64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
173173

174174
// unsigned integer -> float
@@ -181,11 +181,11 @@ impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0"
181181
impl_from!(u16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
182182
impl_from!(u32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
183183
impl_from!(u32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
184-
// FIXME(f16_f128): This impl would allow using `f128` on stable before it is stabilised.
184+
// FIXME(f128): This impl would allow using `f128` on stable before it is stabilised.
185185
// impl_from!(u64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
186186

187187
// float -> float
188-
// FIXME(f16_f128): adding additional `From<{float}>` impls to `f32` breaks inference. See
188+
// FIXME(f16,f128): adding additional `From<{float}>` impls to `f32` breaks inference. See
189189
// <https://github.com/rust-lang/rust/issues/123831>
190190
impl_from!(f16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
191191
impl_from!(f16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);

library/core/src/fmt/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ floating! { f32 f64 }
236236
#[cfg(target_has_reliable_f16)]
237237
floating! { f16 }
238238

239-
// FIXME(f16_f128): A fallback is used when the backend+target does not support f16 well, in order
239+
// FIXME(f16): A fallback is used when the backend+target does not support f16 well, in order
240240
// to avoid ICEs.
241241

242242
#[cfg(not(target_has_reliable_f16))]

library/core/src/num/dec2flt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ from_str_float_impl!(f16);
179179
from_str_float_impl!(f32);
180180
from_str_float_impl!(f64);
181181

182-
// FIXME(f16_f128): A fallback is used when the backend+target does not support f16 well, in order
182+
// FIXME(f16): A fallback is used when the backend+target does not support f16 well, in order
183183
// to avoid ICEs.
184184

185185
#[cfg(not(target_has_reliable_f16))]

library/core/src/num/f128.rs

Lines changed: 30 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@ pub mod consts {
137137
pub const LN_10: f128 = 2.30258509299404568401799145468436420760110148862877297603333_f128;
138138
}
139139

140+
#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), allow(internal_features))))]
140141
impl f128 {
141-
// FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const
142-
// implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE.
143-
144142
/// The radix or base of the internal representation of `f128`.
145143
#[unstable(feature = "f128", issue = "116909")]
146144
pub const RADIX: u32 = 2;
@@ -277,8 +275,7 @@ impl f128 {
277275
///
278276
/// ```
279277
/// #![feature(f128)]
280-
/// # // FIXME(f16_f128): remove when `unordtf2` is available
281-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
278+
/// # #[cfg(target_has_reliable_f128)] {
282279
///
283280
/// let nan = f128::NAN;
284281
/// let f = 7.0_f128;
@@ -300,8 +297,7 @@ impl f128 {
300297
///
301298
/// ```
302299
/// #![feature(f128)]
303-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
304-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
300+
/// # #[cfg(target_has_reliable_f128)] {
305301
///
306302
/// let f = 7.0f128;
307303
/// let inf = f128::INFINITY;
@@ -326,8 +322,7 @@ impl f128 {
326322
///
327323
/// ```
328324
/// #![feature(f128)]
329-
/// # // FIXME(f16_f128): remove when `lttf2` is available
330-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
325+
/// # #[cfg(target_has_reliable_f128)] {
331326
///
332327
/// let f = 7.0f128;
333328
/// let inf: f128 = f128::INFINITY;
@@ -355,8 +350,7 @@ impl f128 {
355350
///
356351
/// ```
357352
/// #![feature(f128)]
358-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
359-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
353+
/// # #[cfg(target_has_reliable_f128)] {
360354
///
361355
/// let min = f128::MIN_POSITIVE; // 3.362103143e-4932f128
362356
/// let max = f128::MAX;
@@ -386,8 +380,7 @@ impl f128 {
386380
///
387381
/// ```
388382
/// #![feature(f128)]
389-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
390-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
383+
/// # #[cfg(target_has_reliable_f128)] {
391384
///
392385
/// let min = f128::MIN_POSITIVE; // 3.362103143e-4932f128
393386
/// let max = f128::MAX;
@@ -419,8 +412,7 @@ impl f128 {
419412
///
420413
/// ```
421414
/// #![feature(f128)]
422-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
423-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
415+
/// # #[cfg(target_has_reliable_f128)] {
424416
///
425417
/// use std::num::FpCategory;
426418
///
@@ -514,8 +506,7 @@ impl f128 {
514506
///
515507
/// ```rust
516508
/// #![feature(f128)]
517-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
518-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
509+
/// # #[cfg(target_has_reliable_f128)] {
519510
///
520511
/// // f128::EPSILON is the difference between 1.0 and the next number up.
521512
/// assert_eq!(1.0f128.next_up(), 1.0 + f128::EPSILON);
@@ -569,8 +560,7 @@ impl f128 {
569560
///
570561
/// ```rust
571562
/// #![feature(f128)]
572-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
573-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
563+
/// # #[cfg(target_has_reliable_f128)] {
574564
///
575565
/// let x = 1.0f128;
576566
/// // Clamp value into range [0, 1).
@@ -613,8 +603,7 @@ impl f128 {
613603
///
614604
/// ```
615605
/// #![feature(f128)]
616-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
617-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
606+
/// # #[cfg(target_has_reliable_f128)] {
618607
///
619608
/// let x = 2.0_f128;
620609
/// let abs_difference = (x.recip() - (1.0 / x)).abs();
@@ -640,8 +629,7 @@ impl f128 {
640629
///
641630
/// ```
642631
/// #![feature(f128)]
643-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
644-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
632+
/// # #[cfg(target_has_reliable_f128)] {
645633
///
646634
/// let angle = std::f128::consts::PI;
647635
///
@@ -671,8 +659,7 @@ impl f128 {
671659
///
672660
/// ```
673661
/// #![feature(f128)]
674-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
675-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
662+
/// # #[cfg(target_has_reliable_f128)] {
676663
///
677664
/// let angle = 180.0f128;
678665
///
@@ -706,8 +693,7 @@ impl f128 {
706693
///
707694
/// ```
708695
/// #![feature(f128)]
709-
/// # // Using aarch64 because `reliable_f128_math` is needed
710-
/// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] {
696+
/// # #[cfg(target_has_reliable_f128_math)] {
711697
///
712698
/// let x = 1.0f128;
713699
/// let y = 2.0f128;
@@ -738,8 +724,7 @@ impl f128 {
738724
///
739725
/// ```
740726
/// #![feature(f128)]
741-
/// # // Using aarch64 because `reliable_f128_math` is needed
742-
/// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] {
727+
/// # #[cfg(target_has_reliable_f128_math)] {
743728
///
744729
/// let x = 1.0f128;
745730
/// let y = 2.0f128;
@@ -771,8 +756,7 @@ impl f128 {
771756
/// ```
772757
/// #![feature(f128)]
773758
/// #![feature(float_minimum_maximum)]
774-
/// # // Using aarch64 because `reliable_f128_math` is needed
775-
/// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] {
759+
/// # #[cfg(target_has_reliable_f128_math)] {
776760
///
777761
/// let x = 1.0f128;
778762
/// let y = 2.0f128;
@@ -804,8 +788,7 @@ impl f128 {
804788
/// ```
805789
/// #![feature(f128)]
806790
/// #![feature(float_minimum_maximum)]
807-
/// # // Using aarch64 because `reliable_f128_math` is needed
808-
/// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] {
791+
/// # #[cfg(target_has_reliable_f128_math)] {
809792
///
810793
/// let x = 1.0f128;
811794
/// let y = 2.0f128;
@@ -831,8 +814,7 @@ impl f128 {
831814
///
832815
/// ```
833816
/// #![feature(f128)]
834-
/// # // Using aarch64 because `reliable_f128_math` is needed
835-
/// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] {
817+
/// # #[cfg(target_has_reliable_f128)] {
836818
///
837819
/// assert_eq!(1f128.midpoint(4.0), 2.5);
838820
/// assert_eq!((-5.5f128).midpoint(8.0), 1.25);
@@ -862,8 +844,7 @@ impl f128 {
862844
///
863845
/// ```
864846
/// #![feature(f128)]
865-
/// # // FIXME(f16_f128): remove when `float*itf` is available
866-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
847+
/// # #[cfg(target_has_reliable_f128)] {
867848
///
868849
/// let value = 4.6_f128;
869850
/// let rounded = unsafe { value.to_int_unchecked::<u16>() };
@@ -906,10 +887,11 @@ impl f128 {
906887
///
907888
/// ```
908889
/// #![feature(f128)]
890+
/// # #[cfg(target_has_reliable_f128)] {
909891
///
910-
/// # // FIXME(f16_f128): enable this once const casting works
911-
/// # // assert_ne!((1f128).to_bits(), 1f128 as u128); // to_bits() is not casting!
892+
/// assert_ne!((1f128).to_bits(), 1f128 as u128); // to_bits() is not casting!
912893
/// assert_eq!((12.5f128).to_bits(), 0x40029000000000000000000000000000);
894+
/// # }
913895
/// ```
914896
#[inline]
915897
#[unstable(feature = "f128", issue = "116909")]
@@ -952,8 +934,7 @@ impl f128 {
952934
///
953935
/// ```
954936
/// #![feature(f128)]
955-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
956-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
937+
/// # #[cfg(target_has_reliable_f128)] {
957938
///
958939
/// let v = f128::from_bits(0x40029000000000000000000000000000);
959940
/// assert_eq!(v, 12.5);
@@ -1064,8 +1045,7 @@ impl f128 {
10641045
///
10651046
/// ```
10661047
/// #![feature(f128)]
1067-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
1068-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
1048+
/// # #[cfg(target_has_reliable_f128)] {
10691049
///
10701050
/// let value = f128::from_be_bytes(
10711051
/// [0x40, 0x02, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1090,8 +1070,7 @@ impl f128 {
10901070
///
10911071
/// ```
10921072
/// #![feature(f128)]
1093-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
1094-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
1073+
/// # #[cfg(target_has_reliable_f128)] {
10951074
///
10961075
/// let value = f128::from_le_bytes(
10971076
/// [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1123,8 +1102,7 @@ impl f128 {
11231102
///
11241103
/// ```
11251104
/// #![feature(f128)]
1126-
/// # // FIXME(f16_f128): remove when `eqtf2` is available
1127-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
1105+
/// # #[cfg(target_has_reliable_f128)] {
11281106
///
11291107
/// let value = f128::from_ne_bytes(if cfg!(target_endian = "big") {
11301108
/// [0x40, 0x02, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1257,8 +1235,7 @@ impl f128 {
12571235
///
12581236
/// ```
12591237
/// #![feature(f128)]
1260-
/// # // FIXME(f16_f128): remove when `{eq,gt,unord}tf` are available
1261-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
1238+
/// # #[cfg(target_has_reliable_f128)] {
12621239
///
12631240
/// assert!((-3.0f128).clamp(-2.0, 1.0) == -2.0);
12641241
/// assert!((0.0f128).clamp(-2.0, 1.0) == 0.0);
@@ -1333,7 +1310,7 @@ impl f128 {
13331310
///
13341311
/// ```
13351312
/// #![feature(f128)]
1336-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
1313+
/// # #[cfg(target_has_reliable_f128)] {
13371314
///
13381315
/// let x = 3.5_f128;
13391316
/// let y = -3.5_f128;
@@ -1349,9 +1326,7 @@ impl f128 {
13491326
#[rustc_const_unstable(feature = "f128", issue = "116909")]
13501327
#[must_use = "method returns a new number and does not mutate the original value"]
13511328
pub const fn abs(self) -> Self {
1352-
// FIXME(f16_f128): replace with `intrinsics::fabsf128` when available
1353-
// We don't do this now because LLVM has lowering bugs for f128 math.
1354-
Self::from_bits(self.to_bits() & !(1 << 127))
1329+
intrinsics::fabsf128(self)
13551330
}
13561331

13571332
/// Returns a number that represents the sign of `self`.
@@ -1364,7 +1339,7 @@ impl f128 {
13641339
///
13651340
/// ```
13661341
/// #![feature(f128)]
1367-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
1342+
/// # #[cfg(target_has_reliable_f128)] {
13681343
///
13691344
/// let f = 3.5_f128;
13701345
///
@@ -1400,7 +1375,7 @@ impl f128 {
14001375
///
14011376
/// ```
14021377
/// #![feature(f128)]
1403-
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
1378+
/// # #[cfg(target_has_reliable_f128)] {
14041379
///
14051380
/// let f = 3.5_f128;
14061381
///
@@ -1477,8 +1452,6 @@ impl f128 {
14771452
}
14781453

14791454
// Functions in this module fall into `core_float_math`
1480-
// FIXME(f16_f128): all doctests must be gated to platforms that have `long double` === `_Float128`
1481-
// due to https://github.com/llvm/llvm-project/issues/44744. aarch64 linux matches this.
14821455
// #[unstable(feature = "core_float_math", issue = "137578")]
14831456
#[cfg(not(test))]
14841457
#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))]

library/core/src/num/f16.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ pub mod consts {
134134

135135
#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), allow(internal_features))))]
136136
impl f16 {
137-
// FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const
138-
// implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE.
139-
140137
/// The radix or base of the internal representation of `f16`.
141138
#[unstable(feature = "f16", issue = "116909")]
142139
pub const RADIX: u32 = 2;
@@ -887,8 +884,7 @@ impl f16 {
887884
/// #![feature(f16)]
888885
/// # #[cfg(target_has_reliable_f16)] {
889886
///
890-
/// # // FIXME(f16_f128): enable this once const casting works
891-
/// # // assert_ne!((1f16).to_bits(), 1f16 as u128); // to_bits() is not casting!
887+
/// assert_ne!((1f16).to_bits(), 1f16 as u16); // to_bits() is not casting!
892888
/// assert_eq!((12.5f16).to_bits(), 0x4a40);
893889
/// # }
894890
/// ```

0 commit comments

Comments
 (0)