mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
rustc: Rename llalign_of_real to llalign_of_pref
This alignment is the "preferred" alignment of a type, which is not necessarily the alignment the compiler will use when packing the type into structures - that is the "ABI" alignment (in LLVM terms). On x86, 64-bit ints have 8-byte preferred alignment, but 4-byte ABI alignment.
This commit is contained in:
parent
3c16693760
commit
43751e45d9
@ -1896,7 +1896,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: [ty::t],
|
|||||||
!ty::type_needs_drop(ccx.tcx, subst) {
|
!ty::type_needs_drop(ccx.tcx, subst) {
|
||||||
let llty = type_of(ccx, subst);
|
let llty = type_of(ccx, subst);
|
||||||
let size = shape::llsize_of_real(ccx, llty);
|
let size = shape::llsize_of_real(ccx, llty);
|
||||||
let align = shape::llalign_of_real(ccx, llty);
|
let align = shape::llalign_of_pref(ccx, llty);
|
||||||
// Special value for nil to prevent problems with undef
|
// Special value for nil to prevent problems with undef
|
||||||
// return pointers.
|
// return pointers.
|
||||||
if size == 1u && ty::type_is_nil(subst) {
|
if size == 1u && ty::type_is_nil(subst) {
|
||||||
|
@ -282,7 +282,7 @@ fn create_block(cx: block) -> @metadata<block_md> {
|
|||||||
fn size_and_align_of(cx: @crate_ctxt, t: ty::t) -> (int, int) {
|
fn size_and_align_of(cx: @crate_ctxt, t: ty::t) -> (int, int) {
|
||||||
let llty = type_of::type_of(cx, t);
|
let llty = type_of::type_of(cx, t);
|
||||||
(shape::llsize_of_real(cx, llty) as int,
|
(shape::llsize_of_real(cx, llty) as int,
|
||||||
shape::llalign_of_real(cx, llty) as int)
|
shape::llalign_of_pref(cx, llty) as int)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
|
fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
|
||||||
|
@ -765,7 +765,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
|
|||||||
fcx.llretptr);
|
fcx.llretptr);
|
||||||
}
|
}
|
||||||
"align_of" {
|
"align_of" {
|
||||||
Store(bcx, C_uint(ccx, shape::llalign_of_real(ccx, lltp_ty)),
|
Store(bcx, C_uint(ccx, shape::llalign_of_pref(ccx, lltp_ty)),
|
||||||
fcx.llretptr);
|
fcx.llretptr);
|
||||||
}
|
}
|
||||||
"get_tydesc" {
|
"get_tydesc" {
|
||||||
|
@ -117,7 +117,7 @@ fn largest_variants(ccx: @crate_ctxt, tag_id: ast::def_id) -> [uint] {
|
|||||||
} else {
|
} else {
|
||||||
let llty = type_of::type_of(ccx, elem_t);
|
let llty = type_of::type_of(ccx, elem_t);
|
||||||
min_size += llsize_of_real(ccx, llty);
|
min_size += llsize_of_real(ccx, llty);
|
||||||
min_align += llalign_of_real(ccx, llty);
|
min_align += llalign_of_pref(ccx, llty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ fn compute_static_enum_size(ccx: @crate_ctxt, largest_variants: [uint],
|
|||||||
|
|
||||||
let llty = trans::common::T_struct(lltys);
|
let llty = trans::common::T_struct(lltys);
|
||||||
let dp = llsize_of_real(ccx, llty) as u16;
|
let dp = llsize_of_real(ccx, llty) as u16;
|
||||||
let variant_align = llalign_of_real(ccx, llty) as u8;
|
let variant_align = llalign_of_pref(ccx, llty) as u8;
|
||||||
|
|
||||||
if max_size < dp { max_size = dp; }
|
if max_size < dp { max_size = dp; }
|
||||||
if max_align < variant_align { max_align = variant_align; }
|
if max_align < variant_align { max_align = variant_align; }
|
||||||
@ -202,7 +202,7 @@ fn compute_static_enum_size(ccx: @crate_ctxt, largest_variants: [uint],
|
|||||||
if vec::len(*variants) > 1u {
|
if vec::len(*variants) > 1u {
|
||||||
let variant_t = T_enum_variant(ccx);
|
let variant_t = T_enum_variant(ccx);
|
||||||
max_size += llsize_of_real(ccx, variant_t) as u16;
|
max_size += llsize_of_real(ccx, variant_t) as u16;
|
||||||
let align = llalign_of_real(ccx, variant_t) as u8;
|
let align = llalign_of_pref(ccx, variant_t) as u8;
|
||||||
if max_align < align { max_align = align; }
|
if max_align < align { max_align = align; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,8 +630,10 @@ fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
|
|||||||
ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint;
|
ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the real alignment of the given type for the current target.
|
// Returns the preferred alignment of the given type for the current target.
|
||||||
fn llalign_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
|
// The preffered alignment may be larger than the alignment used when
|
||||||
|
// packing the type into structs
|
||||||
|
fn llalign_of_pref(cx: @crate_ctxt, t: TypeRef) -> uint {
|
||||||
ret llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t) as uint;
|
ret llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t) as uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user