rustc_target: inline abi::FloatTy into abi::Primitive.
This commit is contained in:
parent
50f8aadd74
commit
ccde510c95
9 changed files with 29 additions and 35 deletions
|
@ -162,7 +162,6 @@ impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
|
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
|
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
|
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
|
||||||
impl_stable_hash_for!(enum ::rustc_target::abi::FloatTy { F32, F64 });
|
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
|
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
|
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
|
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
|
||||||
|
|
|
@ -132,8 +132,8 @@ impl PrimitiveExt for Primitive {
|
||||||
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||||
match *self {
|
match *self {
|
||||||
Int(i, signed) => i.to_ty(tcx, signed),
|
Int(i, signed) => i.to_ty(tcx, signed),
|
||||||
Float(FloatTy::F32) => tcx.types.f32,
|
F32 => tcx.types.f32,
|
||||||
Float(FloatTy::F64) => tcx.types.f64,
|
F64 => tcx.types.f64,
|
||||||
Pointer => tcx.mk_mut_ptr(tcx.mk_unit()),
|
Pointer => tcx.mk_mut_ptr(tcx.mk_unit()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ impl PrimitiveExt for Primitive {
|
||||||
match *self {
|
match *self {
|
||||||
Int(i, signed) => i.to_ty(tcx, signed),
|
Int(i, signed) => i.to_ty(tcx, signed),
|
||||||
Pointer => tcx.types.usize,
|
Pointer => tcx.types.usize,
|
||||||
Float(..) => bug!("floats do not have an int type"),
|
F32 | F64 => bug!("floats do not have an int type"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,10 +538,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||||
ty::Uint(ity) => {
|
ty::Uint(ity) => {
|
||||||
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
|
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
|
||||||
}
|
}
|
||||||
ty::Float(fty) => scalar(Float(match fty {
|
ty::Float(fty) => scalar(match fty {
|
||||||
ast::FloatTy::F32 => FloatTy::F32,
|
ast::FloatTy::F32 => F32,
|
||||||
ast::FloatTy::F64 => FloatTy::F64,
|
ast::FloatTy::F64 => F64,
|
||||||
})),
|
}),
|
||||||
ty::FnPtr(_) => {
|
ty::FnPtr(_) => {
|
||||||
let mut ptr = scalar_unit(Pointer);
|
let mut ptr = scalar_unit(Pointer);
|
||||||
ptr.valid_range = 1..=*ptr.valid_range.end();
|
ptr.valid_range = 1..=*ptr.valid_range.end();
|
||||||
|
@ -2457,7 +2457,8 @@ impl_stable_hash_for!(enum crate::ty::layout::Integer {
|
||||||
|
|
||||||
impl_stable_hash_for!(enum crate::ty::layout::Primitive {
|
impl_stable_hash_for!(enum crate::ty::layout::Primitive {
|
||||||
Int(integer, signed),
|
Int(integer, signed),
|
||||||
Float(fty),
|
F32,
|
||||||
|
F64,
|
||||||
Pointer
|
Pointer
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1904,8 +1904,8 @@ fn prepare_enum_metadata(
|
||||||
|
|
||||||
let discr_type = match discr.value {
|
let discr_type = match discr.value {
|
||||||
layout::Int(t, _) => t,
|
layout::Int(t, _) => t,
|
||||||
layout::Float(layout::FloatTy::F32) => Integer::I32,
|
layout::F32 => Integer::I32,
|
||||||
layout::Float(layout::FloatTy::F64) => Integer::I64,
|
layout::F64 => Integer::I64,
|
||||||
layout::Pointer => cx.data_layout().ptr_sized_integer(),
|
layout::Pointer => cx.data_layout().ptr_sized_integer(),
|
||||||
}.to_ty(cx.tcx, false);
|
}.to_ty(cx.tcx, false);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive};
|
||||||
use rustc::mir::interpret::GlobalId;
|
use rustc::mir::interpret::GlobalId;
|
||||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc_target::abi::{FloatTy, HasDataLayout};
|
use rustc_target::abi::HasDataLayout;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
|
|
||||||
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
|
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
|
||||||
|
@ -163,12 +163,12 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
emit_va_arg(self, args[0], ret_ty)
|
emit_va_arg(self, args[0], ret_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Primitive::Float(FloatTy::F64) |
|
Primitive::F64 |
|
||||||
Primitive::Pointer => {
|
Primitive::Pointer => {
|
||||||
emit_va_arg(self, args[0], ret_ty)
|
emit_va_arg(self, args[0], ret_ty)
|
||||||
}
|
}
|
||||||
// `va_arg` should never be used with the return type f32.
|
// `va_arg` should never be used with the return type f32.
|
||||||
Primitive::Float(FloatTy::F32) => {
|
Primitive::F32 => {
|
||||||
bug!("the va_arg intrinsic does not work with `f32`")
|
bug!("the va_arg intrinsic does not work with `f32`")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::common::*;
|
||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
use rustc::ty::{self, Ty, TypeFoldable};
|
use rustc::ty::{self, Ty, TypeFoldable};
|
||||||
use rustc::ty::layout::{self, Align, LayoutOf, FnAbiExt, PointeeInfo, Size, TyLayout};
|
use rustc::ty::layout::{self, Align, LayoutOf, FnAbiExt, PointeeInfo, Size, TyLayout};
|
||||||
use rustc_target::abi::{FloatTy, TyLayoutMethods};
|
use rustc_target::abi::TyLayoutMethods;
|
||||||
use rustc::ty::print::obsolete::DefPathBasedNames;
|
use rustc::ty::print::obsolete::DefPathBasedNames;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
|
|
||||||
|
@ -300,8 +300,8 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
||||||
scalar: &layout::Scalar, offset: Size) -> &'a Type {
|
scalar: &layout::Scalar, offset: Size) -> &'a Type {
|
||||||
match scalar.value {
|
match scalar.value {
|
||||||
layout::Int(i, _) => cx.type_from_integer( i),
|
layout::Int(i, _) => cx.type_from_integer( i),
|
||||||
layout::Float(FloatTy::F32) => cx.type_f32(),
|
layout::F32 => cx.type_f32(),
|
||||||
layout::Float(FloatTy::F64) => cx.type_f64(),
|
layout::F64 => cx.type_f64(),
|
||||||
layout::Pointer => {
|
layout::Pointer => {
|
||||||
// If we know the alignment, pick something better than i8.
|
// If we know the alignment, pick something better than i8.
|
||||||
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {
|
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {
|
||||||
|
|
|
@ -23,8 +23,8 @@ fn float_reg<'a, Ty, C>(cx: &C, ret: &ArgAbi<'a, Ty>, i: usize) -> Option<Reg>
|
||||||
{
|
{
|
||||||
match ret.layout.field(cx, i).abi {
|
match ret.layout.field(cx, i).abi {
|
||||||
abi::Abi::Scalar(ref scalar) => match scalar.value {
|
abi::Abi::Scalar(ref scalar) => match scalar.value {
|
||||||
abi::Float(abi::FloatTy::F32) => Some(Reg::f32()),
|
abi::F32 => Some(Reg::f32()),
|
||||||
abi::Float(abi::FloatTy::F64) => Some(Reg::f64()),
|
abi::F64 => Some(Reg::f64()),
|
||||||
_ => None
|
_ => None
|
||||||
},
|
},
|
||||||
_ => None
|
_ => None
|
||||||
|
@ -107,7 +107,7 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||||
|
|
||||||
// We only care about aligned doubles
|
// We only care about aligned doubles
|
||||||
if let abi::Abi::Scalar(ref scalar) = field.abi {
|
if let abi::Abi::Scalar(ref scalar) = field.abi {
|
||||||
if let abi::Float(abi::FloatTy::F64) = scalar.value {
|
if let abi::F64 = scalar.value {
|
||||||
if offset.is_aligned(dl.f64_align.abi) {
|
if offset.is_aligned(dl.f64_align.abi) {
|
||||||
// Insert enough integers to cover [last_offset, offset)
|
// Insert enough integers to cover [last_offset, offset)
|
||||||
assert!(last_offset.is_aligned(dl.f64_align.abi));
|
assert!(last_offset.is_aligned(dl.f64_align.abi));
|
||||||
|
|
|
@ -287,7 +287,7 @@ impl<'a, Ty> TyLayout<'a, Ty> {
|
||||||
let kind = match scalar.value {
|
let kind = match scalar.value {
|
||||||
abi::Int(..) |
|
abi::Int(..) |
|
||||||
abi::Pointer => RegKind::Integer,
|
abi::Pointer => RegKind::Integer,
|
||||||
abi::Float(_) => RegKind::Float,
|
abi::F32 | abi::F64 => RegKind::Float,
|
||||||
};
|
};
|
||||||
HomogeneousAggregate::Homogeneous(Reg {
|
HomogeneousAggregate::Homogeneous(Reg {
|
||||||
kind,
|
kind,
|
||||||
|
|
|
@ -45,7 +45,7 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &ArgAbi<'a, Ty>)
|
||||||
match scalar.value {
|
match scalar.value {
|
||||||
abi::Int(..) |
|
abi::Int(..) |
|
||||||
abi::Pointer => Class::Int,
|
abi::Pointer => Class::Int,
|
||||||
abi::Float(_) => Class::Sse
|
abi::F32 | abi::F64 => Class::Sse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -532,13 +532,6 @@ impl Integer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy,
|
|
||||||
PartialOrd, Ord, Debug)]
|
|
||||||
pub enum FloatTy {
|
|
||||||
F32,
|
|
||||||
F64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fundamental unit of memory access and layout.
|
/// Fundamental unit of memory access and layout.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub enum Primitive {
|
pub enum Primitive {
|
||||||
|
@ -550,7 +543,8 @@ pub enum Primitive {
|
||||||
/// a negative integer passed by zero-extension will appear positive in
|
/// a negative integer passed by zero-extension will appear positive in
|
||||||
/// the callee, and most operations on it will produce the wrong values.
|
/// the callee, and most operations on it will produce the wrong values.
|
||||||
Int(Integer, bool),
|
Int(Integer, bool),
|
||||||
Float(FloatTy),
|
F32,
|
||||||
|
F64,
|
||||||
Pointer
|
Pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,8 +554,8 @@ impl Primitive {
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Int(i, _) => i.size(),
|
Int(i, _) => i.size(),
|
||||||
Float(FloatTy::F32) => Size::from_bits(32),
|
F32 => Size::from_bits(32),
|
||||||
Float(FloatTy::F64) => Size::from_bits(64),
|
F64 => Size::from_bits(64),
|
||||||
Pointer => dl.pointer_size
|
Pointer => dl.pointer_size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,15 +565,15 @@ impl Primitive {
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Int(i, _) => i.align(dl),
|
Int(i, _) => i.align(dl),
|
||||||
Float(FloatTy::F32) => dl.f32_align,
|
F32 => dl.f32_align,
|
||||||
Float(FloatTy::F64) => dl.f64_align,
|
F64 => dl.f64_align,
|
||||||
Pointer => dl.pointer_align
|
Pointer => dl.pointer_align
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_float(self) -> bool {
|
pub fn is_float(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Float(_) => true,
|
F32 | F64 => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue