Skip to content

Commit ce11a86

Browse files
authored
Rollup merge of #124797 - beetrees:primitive-float, r=davidtwco
Refactor float `Primitive`s to a separate `Float` type Now there are 4 of them, it makes sense to refactor `F16`, `F32`, `F64` and `F128` out of `Primitive` and into a separate `Float` type (like integers already are). This allows patterns like `F16 | F32 | F64 | F128` to be simplified into `Float(_)`, and is consistent with `ty::FloatTy`. As a side effect, this PR also makes the `Ty::primitive_size` method work with `f16` and `f128`. Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2 parents 6b7db50 + f26221a commit ce11a86

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/type_of.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
88
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
99
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
1010
use rustc_target::abi::{
11-
self, Abi, Align, FieldsShape, Int, Integer, PointeeInfo, Pointer, Size, TyAbiInterface,
12-
Variants, F128, F16, F32, F64,
11+
self, Abi, Align, FieldsShape, Float, Int, Integer, PointeeInfo, Pointer, Size, TyAbiInterface,
12+
Variants,
1313
};
1414

1515
use crate::abi::{FnAbiGcc, FnAbiGccExt, GccType};
@@ -283,10 +283,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
283283
match scalar.primitive() {
284284
Int(i, true) => cx.type_from_integer(i),
285285
Int(i, false) => cx.type_from_unsigned_integer(i),
286-
F16 => cx.type_f16(),
287-
F32 => cx.type_f32(),
288-
F64 => cx.type_f64(),
289-
F128 => cx.type_f128(),
286+
Float(f) => cx.type_from_float(f),
290287
Pointer(address_space) => {
291288
// If we know the alignment, pick something better than i8.
292289
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {

0 commit comments

Comments
 (0)