Skip to content

Commit 550b276

Browse files
authored
Rollup merge of #121841 - tgross35:f16-f128-step2-intrinsics, r=compiler-errors
`f16` and `f128` step 2: intrinsics Continuation of rust-lang/rust#121728, another portion of rust-lang/rust#114607. This PR adds `f16` and `f128` intrinsics, and hooks them up to both HIR and LLVM. This is all still unexposed to the frontend, which will probably be the next step. Also update itanium mangling per `@rcvalle's` in https://github.com/rust-lang/rust/pull/121728/files#r1506570300, and fix a typo from step 1. Once these types are usable in code, I will add the codegen tests from #114607 (codegen is passing on that branch) This does add more `unimplemented!`s to Clippy, but I still don't think we can do better until library support is added. r? `@compiler-errors` cc `@Nilstrieb` `@rustbot` label +T-compiler +F-f16_and_f128
2 parents aa1c9a5 + 2c8f471 commit 550b276

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

clippy_lints/src/approx_const.rs

+3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ impl ApproxConstant {
7575
fn check_lit(&self, cx: &LateContext<'_>, lit: &LitKind, e: &Expr<'_>) {
7676
match *lit {
7777
LitKind::Float(s, LitFloatType::Suffixed(fty)) => match fty {
78+
FloatTy::F16 => self.check_known_consts(cx, e, s, "f16"),
7879
FloatTy::F32 => self.check_known_consts(cx, e, s, "f32"),
7980
FloatTy::F64 => self.check_known_consts(cx, e, s, "f64"),
81+
FloatTy::F128 => self.check_known_consts(cx, e, s, "f128"),
8082
},
83+
// FIXME(f16_f128): add `f16` and `f128` when these types become stable.
8184
LitKind::Float(s, LitFloatType::Unsuffixed) => self.check_known_consts(cx, e, s, "f{32, 64}"),
8285
_ => (),
8386
}

clippy_lints/src/float_literal.rs

+2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
7676
let digits = count_digits(sym_str);
7777
let max = max_digits(fty);
7878
let type_suffix = match lit_float_ty {
79+
LitFloatType::Suffixed(ast::FloatTy::F16) => Some("f16"),
7980
LitFloatType::Suffixed(ast::FloatTy::F32) => Some("f32"),
8081
LitFloatType::Suffixed(ast::FloatTy::F64) => Some("f64"),
82+
LitFloatType::Suffixed(ast::FloatTy::F128) => Some("f128"),
8183
LitFloatType::Unsuffixed => None,
8284
};
8385
let (is_whole, is_inf, mut float_str) = match fty {

clippy_utils/src/consts.rs

+4
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,16 @@ pub fn lit_to_mir_constant<'tcx>(lit: &LitKind, ty: Option<Ty<'tcx>>) -> Constan
277277
LitKind::Char(c) => Constant::Char(c),
278278
LitKind::Int(n, _) => Constant::Int(n.get()),
279279
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {
280+
ast::FloatTy::F16 => unimplemented!("f16_f128"),
280281
ast::FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
281282
ast::FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
283+
ast::FloatTy::F128 => unimplemented!("f16_f128"),
282284
},
283285
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind() {
286+
ty::Float(FloatTy::F16) => unimplemented!("f16_f128"),
284287
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
285288
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
289+
ty::Float(FloatTy::F128) => unimplemented!("f16_f128"),
286290
_ => bug!(),
287291
},
288292
LitKind::Bool(b) => Constant::Bool(b),

0 commit comments

Comments
 (0)