Skip to content

Commit 1969f41

Browse files
authored
Rollup merge of rust-lang#66190 - eddyb:primflt, r=Centril
rustc_target: inline abi::FloatTy into abi::Primitive. This effectively undoes a small part of @oli-obk's rust-lang#50967, now that the rest of the compiler doesn't use the `FloatTy` definition from `rustc_target`, post-rust-lang#65884.
2 parents 63a4551 + ccde510 commit 1969f41

File tree

9 files changed

+29
-35
lines changed

9 files changed

+29
-35
lines changed

src/librustc/ich/impls_syntax.rs

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
162162
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
163163
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
164164
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
165-
impl_stable_hash_for!(enum ::rustc_target::abi::FloatTy { F32, F64 });
166165
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
167166
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
168167
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });

src/librustc/ty/layout.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ impl PrimitiveExt for Primitive {
132132
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
133133
match *self {
134134
Int(i, signed) => i.to_ty(tcx, signed),
135-
Float(FloatTy::F32) => tcx.types.f32,
136-
Float(FloatTy::F64) => tcx.types.f64,
135+
F32 => tcx.types.f32,
136+
F64 => tcx.types.f64,
137137
Pointer => tcx.mk_mut_ptr(tcx.mk_unit()),
138138
}
139139
}
@@ -144,7 +144,7 @@ impl PrimitiveExt for Primitive {
144144
match *self {
145145
Int(i, signed) => i.to_ty(tcx, signed),
146146
Pointer => tcx.types.usize,
147-
Float(..) => bug!("floats do not have an int type"),
147+
F32 | F64 => bug!("floats do not have an int type"),
148148
}
149149
}
150150
}
@@ -538,10 +538,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
538538
ty::Uint(ity) => {
539539
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
540540
}
541-
ty::Float(fty) => scalar(Float(match fty {
542-
ast::FloatTy::F32 => FloatTy::F32,
543-
ast::FloatTy::F64 => FloatTy::F64,
544-
})),
541+
ty::Float(fty) => scalar(match fty {
542+
ast::FloatTy::F32 => F32,
543+
ast::FloatTy::F64 => F64,
544+
}),
545545
ty::FnPtr(_) => {
546546
let mut ptr = scalar_unit(Pointer);
547547
ptr.valid_range = 1..=*ptr.valid_range.end();
@@ -2457,7 +2457,8 @@ impl_stable_hash_for!(enum crate::ty::layout::Integer {
24572457

24582458
impl_stable_hash_for!(enum crate::ty::layout::Primitive {
24592459
Int(integer, signed),
2460-
Float(fty),
2460+
F32,
2461+
F64,
24612462
Pointer
24622463
});
24632464

src/librustc_codegen_llvm/debuginfo/metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1904,8 +1904,8 @@ fn prepare_enum_metadata(
19041904

19051905
let discr_type = match discr.value {
19061906
layout::Int(t, _) => t,
1907-
layout::Float(layout::FloatTy::F32) => Integer::I32,
1908-
layout::Float(layout::FloatTy::F64) => Integer::I64,
1907+
layout::F32 => Integer::I32,
1908+
layout::F64 => Integer::I64,
19091909
layout::Pointer => cx.data_layout().ptr_sized_integer(),
19101910
}.to_ty(cx.tcx, false);
19111911

src/librustc_codegen_llvm/intrinsic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive};
1818
use rustc::mir::interpret::GlobalId;
1919
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
2020
use rustc::hir;
21-
use rustc_target::abi::{FloatTy, HasDataLayout};
21+
use rustc_target::abi::HasDataLayout;
2222
use syntax::ast;
2323

2424
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
@@ -163,12 +163,12 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
163163
emit_va_arg(self, args[0], ret_ty)
164164
}
165165
}
166-
Primitive::Float(FloatTy::F64) |
166+
Primitive::F64 |
167167
Primitive::Pointer => {
168168
emit_va_arg(self, args[0], ret_ty)
169169
}
170170
// `va_arg` should never be used with the return type f32.
171-
Primitive::Float(FloatTy::F32) => {
171+
Primitive::F32 => {
172172
bug!("the va_arg intrinsic does not work with `f32`")
173173
}
174174
}

src/librustc_codegen_llvm/type_of.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::common::*;
33
use crate::type_::Type;
44
use rustc::ty::{self, Ty, TypeFoldable};
55
use rustc::ty::layout::{self, Align, LayoutOf, FnAbiExt, PointeeInfo, Size, TyLayout};
6-
use rustc_target::abi::{FloatTy, TyLayoutMethods};
6+
use rustc_target::abi::TyLayoutMethods;
77
use rustc::ty::print::obsolete::DefPathBasedNames;
88
use rustc_codegen_ssa::traits::*;
99

@@ -300,8 +300,8 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
300300
scalar: &layout::Scalar, offset: Size) -> &'a Type {
301301
match scalar.value {
302302
layout::Int(i, _) => cx.type_from_integer( i),
303-
layout::Float(FloatTy::F32) => cx.type_f32(),
304-
layout::Float(FloatTy::F64) => cx.type_f64(),
303+
layout::F32 => cx.type_f32(),
304+
layout::F64 => cx.type_f64(),
305305
layout::Pointer => {
306306
// If we know the alignment, pick something better than i8.
307307
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {

src/librustc_target/abi/call/mips64.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ fn float_reg<'a, Ty, C>(cx: &C, ret: &ArgAbi<'a, Ty>, i: usize) -> Option<Reg>
2323
{
2424
match ret.layout.field(cx, i).abi {
2525
abi::Abi::Scalar(ref scalar) => match scalar.value {
26-
abi::Float(abi::FloatTy::F32) => Some(Reg::f32()),
27-
abi::Float(abi::FloatTy::F64) => Some(Reg::f64()),
26+
abi::F32 => Some(Reg::f32()),
27+
abi::F64 => Some(Reg::f64()),
2828
_ => None
2929
},
3030
_ => None
@@ -107,7 +107,7 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
107107

108108
// We only care about aligned doubles
109109
if let abi::Abi::Scalar(ref scalar) = field.abi {
110-
if let abi::Float(abi::FloatTy::F64) = scalar.value {
110+
if let abi::F64 = scalar.value {
111111
if offset.is_aligned(dl.f64_align.abi) {
112112
// Insert enough integers to cover [last_offset, offset)
113113
assert!(last_offset.is_aligned(dl.f64_align.abi));

src/librustc_target/abi/call/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl<'a, Ty> TyLayout<'a, Ty> {
287287
let kind = match scalar.value {
288288
abi::Int(..) |
289289
abi::Pointer => RegKind::Integer,
290-
abi::Float(_) => RegKind::Float,
290+
abi::F32 | abi::F64 => RegKind::Float,
291291
};
292292
HomogeneousAggregate::Homogeneous(Reg {
293293
kind,

src/librustc_target/abi/call/x86_64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &ArgAbi<'a, Ty>)
4545
match scalar.value {
4646
abi::Int(..) |
4747
abi::Pointer => Class::Int,
48-
abi::Float(_) => Class::Sse
48+
abi::F32 | abi::F64 => Class::Sse
4949
}
5050
}
5151

src/librustc_target/abi/mod.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,6 @@ impl Integer {
532532
}
533533
}
534534

535-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy,
536-
PartialOrd, Ord, Debug)]
537-
pub enum FloatTy {
538-
F32,
539-
F64,
540-
}
541-
542535
/// Fundamental unit of memory access and layout.
543536
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
544537
pub enum Primitive {
@@ -550,7 +543,8 @@ pub enum Primitive {
550543
/// a negative integer passed by zero-extension will appear positive in
551544
/// the callee, and most operations on it will produce the wrong values.
552545
Int(Integer, bool),
553-
Float(FloatTy),
546+
F32,
547+
F64,
554548
Pointer
555549
}
556550

@@ -560,8 +554,8 @@ impl Primitive {
560554

561555
match self {
562556
Int(i, _) => i.size(),
563-
Float(FloatTy::F32) => Size::from_bits(32),
564-
Float(FloatTy::F64) => Size::from_bits(64),
557+
F32 => Size::from_bits(32),
558+
F64 => Size::from_bits(64),
565559
Pointer => dl.pointer_size
566560
}
567561
}
@@ -571,15 +565,15 @@ impl Primitive {
571565

572566
match self {
573567
Int(i, _) => i.align(dl),
574-
Float(FloatTy::F32) => dl.f32_align,
575-
Float(FloatTy::F64) => dl.f64_align,
568+
F32 => dl.f32_align,
569+
F64 => dl.f64_align,
576570
Pointer => dl.pointer_align
577571
}
578572
}
579573

580574
pub fn is_float(self) -> bool {
581575
match self {
582-
Float(_) => true,
576+
F32 | F64 => true,
583577
_ => false
584578
}
585579
}

0 commit comments

Comments
 (0)