use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout};
use rustc_target::abi::FloatTy;
use rustc_mir::monomorphize::item::DefPathBasedNames;
-use type_::Type;
use rustc_codegen_ssa::traits::*;
+use type_::Type;
use std::fmt::Write;
match layout.fields {
layout::FieldPlacement::Union(_) => {
- let fill = cx.type_padding_filler( layout.size, layout.align);
+ let fill = cx.type_padding_filler(layout.size, layout.align.abi);
let packed = false;
match name {
None => {
- cx.type_struct( &[fill], packed)
+ cx.type_struct(&[fill], packed)
}
Some(ref name) => {
- let llty = cx.type_named_struct( name);
+ let llty = cx.type_named_struct(name);
cx.set_struct_body(llty, &[fill], packed);
llty
}
let mut packed = false;
let mut offset = Size::ZERO;
- let mut prev_effective_align = layout.align;
+ let mut prev_effective_align = layout.align.abi;
let mut result: Vec<_> = Vec::with_capacity(1 + field_count * 2);
for i in layout.fields.index_by_increasing_offset() {
let target_offset = layout.fields.offset(i as usize);
let field = layout.field(cx, i);
- let effective_field_align = layout.align
- .min(field.align)
+ let effective_field_align = layout.align.abi
+ .min(field.align.abi)
.restrict_for_offset(target_offset);
- packed |= effective_field_align.abi() < field.align.abi();
+ packed |= effective_field_align < field.align.abi;
debug!("struct_llfields: {}: {:?} offset: {:?} target_offset: {:?} \
effective_field_align: {}",
- i, field, offset, target_offset, effective_field_align.abi());
+ i, field, offset, target_offset, effective_field_align.bytes());
assert!(target_offset >= offset);
let padding = target_offset - offset;
let padding_align = prev_effective_align.min(effective_field_align);
- assert_eq!(offset.abi_align(padding_align) + padding, target_offset);
+ assert_eq!(offset.align_to(padding_align) + padding, target_offset);
result.push(cx.type_padding_filler( padding, padding_align));
debug!(" padding before: {:?}", padding);
}
let padding = layout.size - offset;
let padding_align = prev_effective_align;
- assert_eq!(offset.abi_align(padding_align) + padding, layout.size);
+ assert_eq!(offset.align_to(padding_align) + padding, layout.size);
debug!("struct_llfields: pad_bytes: {:?} offset: {:?} stride: {:?}",
padding, offset, layout.size);
result.push(cx.type_padding_filler(padding, padding_align));
impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
pub fn align_of(&self, ty: Ty<'tcx>) -> Align {
- self.layout_of(ty).align
+ self.layout_of(ty).align.abi
}
pub fn size_of(&self, ty: Ty<'tcx>) -> Size {
}
pub fn size_and_align_of(&self, ty: Ty<'tcx>) -> (Size, Align) {
- self.layout_of(ty).size_and_align()
+ let layout = self.layout_of(ty);
+ (layout.size, layout.align.abi)
}
}
}
}
- /// Get the LLVM type corresponding to a Rust type, i.e. `rustc::ty::Ty`.
+ /// Get the LLVM type corresponding to a Rust type, i.e., `rustc::ty::Ty`.
/// The pointee type of the pointer in `PlaceRef` is always this type.
/// For sized types, it is also the right LLVM type for an `alloca`
/// containing a value of that type, and most immediates (except `bool`).
layout::Pointer => {
// If we know the alignment, pick something better than i8.
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {
- cx.type_pointee_for_abi_align( pointee.align)
+ cx.type_pointee_for_align(pointee.align)
} else {
cx.type_i8()
};
let offset = if index == 0 {
Size::ZERO
} else {
- a.value.size(cx).abi_align(b.value.align(cx))
+ a.value.size(cx).align_to(b.value.align(cx).abi)
};
self.scalar_llvm_type_at(cx, scalar, offset)
}
// (according to its type), or null (which the
// niche field's scalar validity range encodes).
// This allows using `dereferenceable_or_null`
- // for e.g. `Option<&T>`, and this will continue
+ // for e.g., `Option<&T>`, and this will continue
// to work as long as we don't start using more
- // niches than just null (e.g. the first page
+ // niches than just null (e.g., the first page
// of the address space, or unaligned pointers).
if self.fields.offset(0) == offset {
Some(self.for_variant(cx, dataful_variant))