rustc: remove redundant/unused fields from layout::Abi::Vector.
This commit is contained in:
parent
b203a26efb
commit
5df25c4aed
6 changed files with 19 additions and 28 deletions
|
@ -740,10 +740,7 @@ impl FieldPlacement {
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub enum Abi {
|
pub enum Abi {
|
||||||
Scalar(Primitive),
|
Scalar(Primitive),
|
||||||
Vector {
|
Vector,
|
||||||
element: Primitive,
|
|
||||||
count: u64
|
|
||||||
},
|
|
||||||
Aggregate {
|
Aggregate {
|
||||||
/// If true, the size is exact, otherwise it's only a lower bound.
|
/// If true, the size is exact, otherwise it's only a lower bound.
|
||||||
sized: bool,
|
sized: bool,
|
||||||
|
@ -755,7 +752,7 @@ impl Abi {
|
||||||
/// Returns true if the layout corresponds to an unsized type.
|
/// Returns true if the layout corresponds to an unsized type.
|
||||||
pub fn is_unsized(&self) -> bool {
|
pub fn is_unsized(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
Abi::Scalar(_) | Abi::Vector { .. } => false,
|
Abi::Scalar(_) | Abi::Vector => false,
|
||||||
Abi::Aggregate { sized, .. } => !sized
|
Abi::Aggregate { sized, .. } => !sized
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -763,7 +760,7 @@ impl Abi {
|
||||||
/// Returns true if the fields of the layout are packed.
|
/// Returns true if the fields of the layout are packed.
|
||||||
pub fn is_packed(&self) -> bool {
|
pub fn is_packed(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
Abi::Scalar(_) | Abi::Vector { .. } => false,
|
Abi::Scalar(_) | Abi::Vector => false,
|
||||||
Abi::Aggregate { packed, .. } => packed
|
Abi::Aggregate { packed, .. } => packed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1202,14 +1199,14 @@ impl<'a, 'tcx> CachedLayout {
|
||||||
ty::TyAdt(def, ..) if def.repr.simd() => {
|
ty::TyAdt(def, ..) if def.repr.simd() => {
|
||||||
let count = ty.simd_size(tcx) as u64;
|
let count = ty.simd_size(tcx) as u64;
|
||||||
let element = cx.layout_of(ty.simd_type(tcx))?;
|
let element = cx.layout_of(ty.simd_type(tcx))?;
|
||||||
let element_scalar = match element.abi {
|
match element.abi {
|
||||||
Abi::Scalar(value) => value,
|
Abi::Scalar(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.fatal(&format!("monomorphising SIMD type `{}` with \
|
tcx.sess.fatal(&format!("monomorphising SIMD type `{}` with \
|
||||||
a non-machine element type `{}`",
|
a non-machine element type `{}`",
|
||||||
ty, element.ty));
|
ty, element.ty));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
let size = element.size.checked_mul(count, dl)
|
let size = element.size.checked_mul(count, dl)
|
||||||
.ok_or(LayoutError::SizeOverflow(ty))?;
|
.ok_or(LayoutError::SizeOverflow(ty))?;
|
||||||
let align = dl.vector_align(size);
|
let align = dl.vector_align(size);
|
||||||
|
@ -1221,10 +1218,7 @@ impl<'a, 'tcx> CachedLayout {
|
||||||
stride: element.size,
|
stride: element.size,
|
||||||
count
|
count
|
||||||
},
|
},
|
||||||
abi: Abi::Vector {
|
abi: Abi::Vector,
|
||||||
element: element_scalar,
|
|
||||||
count
|
|
||||||
},
|
|
||||||
size,
|
size,
|
||||||
align,
|
align,
|
||||||
primitive_align: align
|
primitive_align: align
|
||||||
|
@ -2076,7 +2070,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
|
||||||
pub fn is_zst(&self) -> bool {
|
pub fn is_zst(&self) -> bool {
|
||||||
match self.abi {
|
match self.abi {
|
||||||
Abi::Scalar(_) => false,
|
Abi::Scalar(_) => false,
|
||||||
Abi::Vector { count, .. } => count == 0,
|
Abi::Vector => self.size.bytes() == 0,
|
||||||
Abi::Aggregate { sized, .. } => sized && self.size.bytes() == 0
|
Abi::Aggregate { sized, .. } => sized && self.size.bytes() == 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2233,10 +2227,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for Abi {
|
||||||
Scalar(ref value) => {
|
Scalar(ref value) => {
|
||||||
value.hash_stable(hcx, hasher);
|
value.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
Vector { ref element, count } => {
|
Vector => {}
|
||||||
element.hash_stable(hcx, hasher);
|
|
||||||
count.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
Aggregate { packed, sized } => {
|
Aggregate { packed, sized } => {
|
||||||
packed.hash_stable(hcx, hasher);
|
packed.hash_stable(hcx, hasher);
|
||||||
sized.hash_stable(hcx, hasher);
|
sized.hash_stable(hcx, hasher);
|
||||||
|
|
|
@ -279,7 +279,7 @@ impl<'tcx> LayoutExt<'tcx> for TyLayout<'tcx> {
|
||||||
fn is_aggregate(&self) -> bool {
|
fn is_aggregate(&self) -> bool {
|
||||||
match self.abi {
|
match self.abi {
|
||||||
layout::Abi::Scalar(_) |
|
layout::Abi::Scalar(_) |
|
||||||
layout::Abi::Vector { .. } => false,
|
layout::Abi::Vector => false,
|
||||||
layout::Abi::Aggregate { .. } => true
|
layout::Abi::Aggregate { .. } => true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ impl<'tcx> LayoutExt<'tcx> for TyLayout<'tcx> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
layout::Abi::Vector { .. } => {
|
layout::Abi::Vector => {
|
||||||
Some(Reg {
|
Some(Reg {
|
||||||
kind: RegKind::Vector,
|
kind: RegKind::Vector,
|
||||||
size: self.size
|
size: self.size
|
||||||
|
|
|
@ -75,14 +75,14 @@ fn classify_arg<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &ArgType<'tcx>)
|
||||||
unify(cls, off, reg);
|
unify(cls, off, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout::Abi::Vector { element, count } => {
|
layout::Abi::Vector => {
|
||||||
unify(cls, off, Class::Sse);
|
unify(cls, off, Class::Sse);
|
||||||
|
|
||||||
// everything after the first one is the upper
|
// everything after the first one is the upper
|
||||||
// half of a register.
|
// half of a register.
|
||||||
let eltsz = element.size(ccx);
|
for i in 1..layout.fields.count() {
|
||||||
for i in 1..count {
|
let field_off = off + layout.fields.offset(i);
|
||||||
unify(cls, off + eltsz * (i as u64), Class::SseUp);
|
unify(cls, field_off, Class::SseUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub fn compute_abi_info(fty: &mut FnType) {
|
||||||
_ => a.make_indirect()
|
_ => a.make_indirect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layout::Abi::Vector { .. } => {
|
layout::Abi::Vector => {
|
||||||
// FIXME(eddyb) there should be a size cap here
|
// FIXME(eddyb) there should be a size cap here
|
||||||
// (probably what clang calls "illegal vectors").
|
// (probably what clang calls "illegal vectors").
|
||||||
}
|
}
|
||||||
|
|
|
@ -1098,7 +1098,7 @@ fn trans_const_adt<'a, 'tcx>(
|
||||||
match l.variants {
|
match l.variants {
|
||||||
layout::Variants::Single { index } => {
|
layout::Variants::Single { index } => {
|
||||||
assert_eq!(variant_index, index);
|
assert_eq!(variant_index, index);
|
||||||
if let layout::Abi::Vector { .. } = l.abi {
|
if let layout::Abi::Vector = l.abi {
|
||||||
Const::new(C_vector(&vals.iter().map(|x| x.llval).collect::<Vec<_>>()), t)
|
Const::new(C_vector(&vals.iter().map(|x| x.llval).collect::<Vec<_>>()), t)
|
||||||
} else if let layout::FieldPlacement::Union(_) = l.fields {
|
} else if let layout::FieldPlacement::Union(_) = l.fields {
|
||||||
assert_eq!(variant_index, 0);
|
assert_eq!(variant_index, 0);
|
||||||
|
|
|
@ -23,7 +23,7 @@ fn uncached_llvm_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||||
-> Type {
|
-> Type {
|
||||||
match layout.abi {
|
match layout.abi {
|
||||||
layout::Abi::Scalar(_) => bug!("handled elsewhere"),
|
layout::Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||||
layout::Abi::Vector { .. } => {
|
layout::Abi::Vector => {
|
||||||
return Type::vector(&layout.field(ccx, 0).llvm_type(ccx),
|
return Type::vector(&layout.field(ccx, 0).llvm_type(ccx),
|
||||||
layout.fields.count() as u64);
|
layout.fields.count() as u64);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ pub trait LayoutLlvmExt<'tcx> {
|
||||||
impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
||||||
fn is_llvm_immediate(&self) -> bool {
|
fn is_llvm_immediate(&self) -> bool {
|
||||||
match self.abi {
|
match self.abi {
|
||||||
layout::Abi::Scalar(_) | layout::Abi::Vector { .. } => true,
|
layout::Abi::Scalar(_) | layout::Abi::Vector => true,
|
||||||
|
|
||||||
layout::Abi::Aggregate { .. } => self.is_zst()
|
layout::Abi::Aggregate { .. } => self.is_zst()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue