about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-01 03:36:11 +0000
committerbors <bors@rust-lang.org>2024-03-01 03:36:11 +0000
commit6cbf0926d54c80ea6d15df333be9281f65bbeb36 (patch)
treea68611bb2c60aed0f51ecea1c44568b40bfa61a5 /src
parent6f435eb0eb2926cdb6640b3382b9e3e21ef05f07 (diff)
parent406790e9d1f2a02f3b4d004cca7d33e69ef7dca5 (diff)
downloadrust-6cbf0926d54c80ea6d15df333be9281f65bbeb36.tar.gz
rust-6cbf0926d54c80ea6d15df333be9281f65bbeb36.zip
Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errors
Add stubs in IR and ABI for `f16` and `f128`

This is the very first step toward the changes in https://github.com/rust-lang/rust/pull/114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary.

These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`.

The next steps will probably be AST support with parsing and the feature gate.

r? `@compiler-errors`
cc `@Nilstrieb` suggested breaking the PR up in https://github.com/rust-lang/rust/pull/120645#issuecomment-1925900572
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/types.rs6
-rw-r--r--src/tools/clippy/clippy_lints/src/float_literal.rs4
-rw-r--r--src/tools/clippy/clippy_utils/src/consts.rs2
-rw-r--r--src/tools/miri/src/shims/intrinsics/simd.rs10
4 files changed, 22 insertions, 0 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 30cadfe7dac..1707b514ef8 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -1743,8 +1743,10 @@ pub(crate) enum PrimitiveType {
     U32,
     U64,
     U128,
+    F16,
     F32,
     F64,
+    F128,
     Char,
     Bool,
     Str,
@@ -1890,8 +1892,10 @@ impl PrimitiveType {
             U32 => sym::u32,
             U64 => sym::u64,
             U128 => sym::u128,
+            F16 => sym::f16,
             F32 => sym::f32,
             F64 => sym::f64,
+            F128 => sym::f128,
             Str => sym::str,
             Bool => sym::bool,
             Char => sym::char,
@@ -2008,8 +2012,10 @@ impl From<ty::UintTy> for PrimitiveType {
 impl From<ty::FloatTy> for PrimitiveType {
     fn from(float_ty: ty::FloatTy) -> PrimitiveType {
         match float_ty {
+            ty::FloatTy::F16 => PrimitiveType::F16,
             ty::FloatTy::F32 => PrimitiveType::F32,
             ty::FloatTy::F64 => PrimitiveType::F64,
+            ty::FloatTy::F128 => PrimitiveType::F128,
         }
     }
 }
diff --git a/src/tools/clippy/clippy_lints/src/float_literal.rs b/src/tools/clippy/clippy_lints/src/float_literal.rs
index 38a16c5c8b0..cffca952e47 100644
--- a/src/tools/clippy/clippy_lints/src/float_literal.rs
+++ b/src/tools/clippy/clippy_lints/src/float_literal.rs
@@ -81,6 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
                 LitFloatType::Unsuffixed => None,
             };
             let (is_whole, is_inf, mut float_str) = match fty {
+                FloatTy::F16 => unimplemented!("f16_f128"),
                 FloatTy::F32 => {
                     let value = sym_str.parse::<f32>().unwrap();
 
@@ -91,6 +92,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
 
                     (value.fract() == 0.0, value.is_infinite(), formatter.format(value))
                 },
+                FloatTy::F128 => unimplemented!("f16_f128"),
             };
 
             if is_inf {
@@ -135,8 +137,10 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
 #[must_use]
 fn max_digits(fty: FloatTy) -> u32 {
     match fty {
+        FloatTy::F16 => unimplemented!("f16_f128"),
         FloatTy::F32 => f32::DIGITS,
         FloatTy::F64 => f64::DIGITS,
+        FloatTy::F128 => unimplemented!("f16_f128"),
     }
 }
 
diff --git a/src/tools/clippy/clippy_utils/src/consts.rs b/src/tools/clippy/clippy_utils/src/consts.rs
index 79c691992a8..1f2b2d54efd 100644
--- a/src/tools/clippy/clippy_utils/src/consts.rs
+++ b/src/tools/clippy/clippy_utils/src/consts.rs
@@ -778,8 +778,10 @@ pub fn mir_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::Const<'tcx>) ->
                 let range = alloc_range(offset + size * idx, size);
                 let val = alloc.read_scalar(&lcx.tcx, range, /* read_provenance */ false).ok()?;
                 res.push(match flt {
+                    FloatTy::F16 => unimplemented!("f16_f128"),
                     FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().ok()?)),
                     FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().ok()?)),
+                    FloatTy::F128 => unimplemented!("f16_f128"),
                 });
             }
             Some(Constant::Vec(res))
diff --git a/src/tools/miri/src/shims/intrinsics/simd.rs b/src/tools/miri/src/shims/intrinsics/simd.rs
index ca8773cac14..bb18fba5c98 100644
--- a/src/tools/miri/src/shims/intrinsics/simd.rs
+++ b/src/tools/miri/src/shims/intrinsics/simd.rs
@@ -83,8 +83,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                             let op = op.to_scalar();
                             // "Bitwise" operation, no NaN adjustments
                             match float_ty {
+                                FloatTy::F16 => unimplemented!("f16_f128"),
                                 FloatTy::F32 => Scalar::from_f32(op.to_f32()?.abs()),
                                 FloatTy::F64 => Scalar::from_f64(op.to_f64()?.abs()),
+                                FloatTy::F128 => unimplemented!("f16_f128"),
                             }
                         }
                         Op::Sqrt => {
@@ -93,6 +95,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                             };
                             // FIXME using host floats
                             match float_ty {
+                                FloatTy::F16 => unimplemented!("f16_f128"),
                                 FloatTy::F32 => {
                                     let f = op.to_scalar().to_f32()?;
                                     let res = f.to_host().sqrt().to_soft();
@@ -105,6 +108,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                                     let res = this.adjust_nan(res, &[f]);
                                     Scalar::from(res)
                                 }
+                                FloatTy::F128 => unimplemented!("f16_f128"),
                             }
                         }
                         Op::Round(rounding) => {
@@ -112,6 +116,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                                 span_bug!(this.cur_span(), "{} operand is not a float", intrinsic_name)
                             };
                             match float_ty {
+                                FloatTy::F16 => unimplemented!("f16_f128"),
                                 FloatTy::F32 => {
                                     let f = op.to_scalar().to_f32()?;
                                     let res = f.round_to_integral(rounding).value;
@@ -124,6 +129,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                                     let res = this.adjust_nan(res, &[f]);
                                     Scalar::from_f64(res)
                                 }
+                                FloatTy::F128 => unimplemented!("f16_f128"),
                             }
                         }
                         Op::Numeric(name) => {
@@ -267,6 +273,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                         span_bug!(this.cur_span(), "{} operand is not a float", intrinsic_name)
                     };
                     let val = match float_ty {
+                        FloatTy::F16 => unimplemented!("f16_f128"),
                         FloatTy::F32 => {
                             let a = a.to_f32()?;
                             let b = b.to_f32()?;
@@ -283,6 +290,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                             let res = this.adjust_nan(res, &[a, b, c]);
                             Scalar::from(res)
                         }
+                        FloatTy::F128 => unimplemented!("f16_f128"),
                     };
                     this.write_scalar(val, &dest)?;
                 }
@@ -724,6 +732,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
         let left = left.to_scalar();
         let right = right.to_scalar();
         Ok(match float_ty {
+            FloatTy::F16 => unimplemented!("f16_f128"),
             FloatTy::F32 => {
                 let left = left.to_f32()?;
                 let right = right.to_f32()?;
@@ -744,6 +753,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                 let res = this.adjust_nan(res, &[left, right]);
                 Scalar::from_f64(res)
             }
+            FloatTy::F128 => unimplemented!("f16_f128"),
         })
     }
 }