Skip to content

Commit d56e892

Browse files
committed
rustc_target: rename abi::Align to AbiAndPrefAlign.
1 parent 780658a commit d56e892

File tree

26 files changed

+220
-218
lines changed

26 files changed

+220
-218
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use super::{Pointer, EvalResult, AllocId};
1414

15-
use ty::layout::{Size, Align};
15+
use ty::layout::{Size, AbiAndPrefAlign};
1616
use syntax::ast::Mutability;
1717
use std::iter;
1818
use mir;
@@ -40,7 +40,7 @@ pub struct Allocation<Tag=(),Extra=()> {
4040
/// Denotes undefined memory. Reading from undefined memory is forbidden in miri
4141
pub undef_mask: UndefMask,
4242
/// The alignment of the allocation to detect unaligned reads.
43-
pub align: Align,
43+
pub align: AbiAndPrefAlign,
4444
/// Whether the allocation is mutable.
4545
/// Also used by codegen to determine if a static should be put into mutable memory,
4646
/// which happens for `static mut` and `static` with interior mutability.
@@ -90,7 +90,7 @@ impl AllocationExtra<()> for () {}
9090

9191
impl<Tag, Extra: Default> Allocation<Tag, Extra> {
9292
/// Creates a read-only allocation initialized by the given bytes
93-
pub fn from_bytes(slice: &[u8], align: Align) -> Self {
93+
pub fn from_bytes(slice: &[u8], align: AbiAndPrefAlign) -> Self {
9494
let mut undef_mask = UndefMask::new(Size::ZERO);
9595
undef_mask.grow(Size::from_bytes(slice.len() as u64), true);
9696
Self {
@@ -104,10 +104,10 @@ impl<Tag, Extra: Default> Allocation<Tag, Extra> {
104104
}
105105

106106
pub fn from_byte_aligned_bytes(slice: &[u8]) -> Self {
107-
Allocation::from_bytes(slice, Align::from_bytes(1, 1).unwrap())
107+
Allocation::from_bytes(slice, AbiAndPrefAlign::from_bytes(1, 1).unwrap())
108108
}
109109

110-
pub fn undef(size: Size, align: Align) -> Self {
110+
pub fn undef(size: Size, align: AbiAndPrefAlign) -> Self {
111111
assert_eq!(size.bytes() as usize as u64, size.bytes());
112112
Allocation {
113113
bytes: vec![0; size.bytes() as usize],

src/librustc/mir/interpret/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{fmt, env};
1313
use hir::map::definitions::DefPathData;
1414
use mir;
1515
use ty::{self, Ty, layout};
16-
use ty::layout::{Size, Align, LayoutError};
16+
use ty::layout::{Size, AbiAndPrefAlign, LayoutError};
1717
use rustc_target::spec::abi::Abi;
1818

1919
use super::{RawConst, Pointer, InboundsCheck, ScalarMaybeUndef};
@@ -301,8 +301,8 @@ pub enum EvalErrorKind<'tcx, O> {
301301
TlsOutOfBounds,
302302
AbiViolation(String),
303303
AlignmentCheckFailed {
304-
required: Align,
305-
has: Align,
304+
required: AbiAndPrefAlign,
305+
has: AbiAndPrefAlign,
306306
},
307307
ValidationFailure(String),
308308
CalledClosureAsFunction,
@@ -315,7 +315,7 @@ pub enum EvalErrorKind<'tcx, O> {
315315
DeallocatedWrongMemoryKind(String, String),
316316
ReallocateNonBasePtr,
317317
DeallocateNonBasePtr,
318-
IncorrectAllocationInformation(Size, Size, Align, Align),
318+
IncorrectAllocationInformation(Size, Size, AbiAndPrefAlign, AbiAndPrefAlign),
319319
Layout(layout::LayoutError<'tcx>),
320320
HeapAllocZeroBytes,
321321
HeapAllocNonPowerOfTwoAlignment(u64),

src/librustc/session/code_stats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc_target::abi::{Align, Size};
11+
use rustc_target::abi::{AbiAndPrefAlign, Size};
1212
use rustc_data_structures::fx::{FxHashSet};
1313
use std::cmp::{self, Ordering};
1414

@@ -63,7 +63,7 @@ impl CodeStats {
6363
pub fn record_type_size<S: ToString>(&mut self,
6464
kind: DataTypeKind,
6565
type_desc: S,
66-
align: Align,
66+
align: AbiAndPrefAlign,
6767
overall_size: Size,
6868
packed: bool,
6969
opt_discr_size: Option<Size>,

src/librustc/ty/layout.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
248248
/// A univariant, the last field of which may be coerced to unsized.
249249
MaybeUnsized,
250250
/// A univariant, but with a prefix of an arbitrary size & alignment (e.g. enum tag).
251-
Prefixed(Size, Align),
251+
Prefixed(Size, AbiAndPrefAlign),
252252
}
253253

254254
let univariant_uninterned = |fields: &[TyLayout<'_>], repr: &ReprOptions, kind| {
@@ -259,7 +259,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
259259

260260
let pack = {
261261
let pack = repr.pack as u64;
262-
Align::from_bytes(pack, pack).unwrap()
262+
AbiAndPrefAlign::from_bytes(pack, pack).unwrap()
263263
};
264264

265265
let mut align = if packed {
@@ -352,7 +352,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
352352

353353
if repr.align > 0 {
354354
let repr_align = repr.align as u64;
355-
align = align.max(Align::from_bytes(repr_align, repr_align).unwrap());
355+
align = align.max(AbiAndPrefAlign::from_bytes(repr_align, repr_align).unwrap());
356356
debug!("univariant repr_align: {:?}", repr_align);
357357
}
358358

@@ -682,7 +682,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
682682

683683
let pack = {
684684
let pack = def.repr.pack as u64;
685-
Align::from_bytes(pack, pack).unwrap()
685+
AbiAndPrefAlign::from_bytes(pack, pack).unwrap()
686686
};
687687

688688
let mut align = if packed {
@@ -694,7 +694,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
694694
if def.repr.align > 0 {
695695
let repr_align = def.repr.align as u64;
696696
align = align.max(
697-
Align::from_bytes(repr_align, repr_align).unwrap());
697+
AbiAndPrefAlign::from_bytes(repr_align, repr_align).unwrap());
698698
}
699699

700700
let optimize = !def.repr.inhibit_union_abi_opt();
@@ -964,7 +964,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
964964
let mut size = Size::ZERO;
965965

966966
// We're interested in the smallest alignment, so start large.
967-
let mut start_align = Align::from_bytes(256, 256).unwrap();
967+
let mut start_align = AbiAndPrefAlign::from_bytes(256, 256).unwrap();
968968
assert_eq!(Integer::for_abi_align(dl, start_align), None);
969969

970970
// repr(C) on an enum tells us to make a (tag, union) layout,
@@ -1994,7 +1994,7 @@ impl_stable_hash_for!(enum ::ty::layout::Primitive {
19941994
Pointer
19951995
});
19961996

1997-
impl<'gcx> HashStable<StableHashingContext<'gcx>> for Align {
1997+
impl<'gcx> HashStable<StableHashingContext<'gcx>> for AbiAndPrefAlign {
19981998
fn hash_stable<W: StableHasherResult>(&self,
19991999
hcx: &mut StableHashingContext<'gcx>,
20002000
hasher: &mut StableHasher<W>) {

src/librustc_codegen_llvm/builder.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use type_of::LayoutLlvmExt;
1919
use value::Value;
2020
use libc::{c_uint, c_char};
2121
use rustc::ty::{self, Ty, TyCtxt};
22-
use rustc::ty::layout::{self, Align, Size, TyLayout};
22+
use rustc::ty::layout::{self, AbiAndPrefAlign, Size, TyLayout};
2323
use rustc::session::config;
2424
use rustc_data_structures::small_c_str::SmallCStr;
2525
use rustc_codegen_ssa::traits::*;
@@ -457,15 +457,15 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
457457
}
458458
}
459459

460-
fn alloca(&mut self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value {
460+
fn alloca(&mut self, ty: &'ll Type, name: &str, align: AbiAndPrefAlign) -> &'ll Value {
461461
let mut bx = Builder::with_cx(self.cx);
462462
bx.position_at_start(unsafe {
463463
llvm::LLVMGetFirstBasicBlock(self.llfn())
464464
});
465465
bx.dynamic_alloca(ty, name, align)
466466
}
467467

468-
fn dynamic_alloca(&mut self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value {
468+
fn dynamic_alloca(&mut self, ty: &'ll Type, name: &str, align: AbiAndPrefAlign) -> &'ll Value {
469469
self.count_insn("alloca");
470470
unsafe {
471471
let alloca = if name.is_empty() {
@@ -484,7 +484,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
484484
ty: &'ll Type,
485485
len: &'ll Value,
486486
name: &str,
487-
align: Align) -> &'ll Value {
487+
align: AbiAndPrefAlign) -> &'ll Value {
488488
self.count_insn("alloca");
489489
unsafe {
490490
let alloca = if name.is_empty() {
@@ -499,7 +499,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
499499
}
500500
}
501501

502-
fn load(&mut self, ptr: &'ll Value, align: Align) -> &'ll Value {
502+
fn load(&mut self, ptr: &'ll Value, align: AbiAndPrefAlign) -> &'ll Value {
503503
self.count_insn("load");
504504
unsafe {
505505
let load = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname());
@@ -639,15 +639,15 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
639639
}
640640
}
641641

642-
fn store(&mut self, val: &'ll Value, ptr: &'ll Value, align: Align) -> &'ll Value {
642+
fn store(&mut self, val: &'ll Value, ptr: &'ll Value, align: AbiAndPrefAlign) -> &'ll Value {
643643
self.store_with_flags(val, ptr, align, MemFlags::empty())
644644
}
645645

646646
fn store_with_flags(
647647
&mut self,
648648
val: &'ll Value,
649649
ptr: &'ll Value,
650-
align: Align,
650+
align: AbiAndPrefAlign,
651651
flags: MemFlags,
652652
) -> &'ll Value {
653653
debug!("Store {:?} -> {:?} ({:?})", val, ptr, flags);
@@ -878,8 +878,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
878878
}
879879
}
880880

881-
fn memcpy(&mut self, dst: &'ll Value, dst_align: Align,
882-
src: &'ll Value, src_align: Align,
881+
fn memcpy(&mut self, dst: &'ll Value, dst_align: AbiAndPrefAlign,
882+
src: &'ll Value, src_align: AbiAndPrefAlign,
883883
size: &'ll Value, flags: MemFlags) {
884884
if flags.contains(MemFlags::NONTEMPORAL) {
885885
// HACK(nox): This is inefficient but there is no nontemporal memcpy.
@@ -898,8 +898,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
898898
}
899899
}
900900

901-
fn memmove(&mut self, dst: &'ll Value, dst_align: Align,
902-
src: &'ll Value, src_align: Align,
901+
fn memmove(&mut self, dst: &'ll Value, dst_align: AbiAndPrefAlign,
902+
src: &'ll Value, src_align: AbiAndPrefAlign,
903903
size: &'ll Value, flags: MemFlags) {
904904
if flags.contains(MemFlags::NONTEMPORAL) {
905905
// HACK(nox): This is inefficient but there is no nontemporal memmove.
@@ -923,7 +923,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
923923
ptr: &'ll Value,
924924
fill_byte: &'ll Value,
925925
size: &'ll Value,
926-
align: Align,
926+
align: AbiAndPrefAlign,
927927
flags: MemFlags,
928928
) {
929929
let ptr_width = &self.cx().sess().target.target.target_pointer_width;

src/librustc_codegen_llvm/consts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use value::Value;
2828
use rustc::ty::{self, Ty};
2929
use rustc_codegen_ssa::traits::*;
3030

31-
use rustc::ty::layout::{self, Size, Align, LayoutOf};
31+
use rustc::ty::layout::{self, Size, AbiAndPrefAlign, LayoutOf};
3232

3333
use rustc::hir::{self, CodegenFnAttrs, CodegenFnAttrFlags};
3434

@@ -89,12 +89,12 @@ pub fn codegen_static_initializer(
8989

9090
fn set_global_alignment(cx: &CodegenCx<'ll, '_>,
9191
gv: &'ll Value,
92-
mut align: Align) {
92+
mut align: AbiAndPrefAlign) {
9393
// The target may require greater alignment for globals than the type does.
9494
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
9595
// which can force it to be smaller. Rust doesn't support this yet.
9696
if let Some(min) = cx.sess().target.target.options.min_global_align {
97-
match ty::layout::Align::from_bits(min, min) {
97+
match ty::layout::AbiAndPrefAlign::from_bits(min, min) {
9898
Ok(min) => align = align.max(min),
9999
Err(err) => {
100100
cx.sess().err(&format!("invalid minimum global alignment: {}", err));
@@ -186,7 +186,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
186186
fn static_addr_of_mut(
187187
&self,
188188
cv: &'ll Value,
189-
align: Align,
189+
align: AbiAndPrefAlign,
190190
kind: Option<&str>,
191191
) -> &'ll Value {
192192
unsafe {
@@ -212,7 +212,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
212212
fn static_addr_of(
213213
&self,
214214
cv: &'ll Value,
215-
align: Align,
215+
align: AbiAndPrefAlign,
216216
kind: Option<&str>,
217217
) -> &'ll Value {
218218
if let Some(&gv) = self.const_globals.borrow().get(&cv) {

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
3535
use rustc::ty::Instance;
3636
use common::CodegenCx;
3737
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
38-
use rustc::ty::layout::{self, Align, HasDataLayout, Integer, IntegerExt, LayoutOf,
38+
use rustc::ty::layout::{self, AbiAndPrefAlign, HasDataLayout, Integer, IntegerExt, LayoutOf,
3939
PrimitiveExt, Size, TyLayout};
4040
use rustc::session::config;
4141
use rustc::util::nodemap::FxHashMap;
@@ -923,7 +923,7 @@ struct MemberDescription<'ll> {
923923
type_metadata: &'ll DIType,
924924
offset: Size,
925925
size: Size,
926-
align: Align,
926+
align: AbiAndPrefAlign,
927927
flags: DIFlags,
928928
discriminant: Option<u64>,
929929
}
@@ -985,13 +985,12 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> {
985985
f.ident.to_string()
986986
};
987987
let field = layout.field(cx, i);
988-
let (size, align) = field.size_and_align();
989988
MemberDescription {
990989
name,
991990
type_metadata: type_metadata(cx, field.ty, self.span),
992991
offset: layout.fields.offset(i),
993-
size,
994-
align,
992+
size: field.size,
993+
align: field.align,
995994
flags: DIFlags::FlagZero,
996995
discriminant: None,
997996
}
@@ -1109,13 +1108,12 @@ impl<'tcx> UnionMemberDescriptionFactory<'tcx> {
11091108
-> Vec<MemberDescription<'ll>> {
11101109
self.variant.fields.iter().enumerate().map(|(i, f)| {
11111110
let field = self.layout.field(cx, i);
1112-
let (size, align) = field.size_and_align();
11131111
MemberDescription {
11141112
name: f.ident.to_string(),
11151113
type_metadata: type_metadata(cx, field.ty, self.span),
11161114
offset: Size::ZERO,
1117-
size,
1118-
align,
1115+
size: field.size,
1116+
align: field.align,
11191117
flags: DIFlags::FlagZero,
11201118
discriminant: None,
11211119
}
@@ -1587,8 +1585,6 @@ fn prepare_enum_metadata(
15871585
_ => {}
15881586
}
15891587

1590-
let (enum_type_size, enum_type_align) = layout.size_and_align();
1591-
15921588
let enum_name = SmallCStr::new(&enum_name);
15931589
let unique_type_id_str = SmallCStr::new(
15941590
debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id)
@@ -1610,8 +1606,8 @@ fn prepare_enum_metadata(
16101606
enum_name.as_ptr(),
16111607
file_metadata,
16121608
UNKNOWN_LINE_NUMBER,
1613-
enum_type_size.bits(),
1614-
enum_type_align.abi_bits() as u32,
1609+
layout.size.bits(),
1610+
layout.align.abi_bits() as u32,
16151611
DIFlags::FlagZero,
16161612
None,
16171613
0, // RuntimeLang
@@ -1695,8 +1691,8 @@ fn prepare_enum_metadata(
16951691
ptr::null_mut(),
16961692
file_metadata,
16971693
UNKNOWN_LINE_NUMBER,
1698-
enum_type_size.bits(),
1699-
enum_type_align.abi_bits() as u32,
1694+
layout.size.bits(),
1695+
layout.align.abi_bits() as u32,
17001696
DIFlags::FlagZero,
17011697
discriminator_metadata,
17021698
empty_array,
@@ -1712,8 +1708,8 @@ fn prepare_enum_metadata(
17121708
enum_name.as_ptr(),
17131709
file_metadata,
17141710
UNKNOWN_LINE_NUMBER,
1715-
enum_type_size.bits(),
1716-
enum_type_align.abi_bits() as u32,
1711+
layout.size.bits(),
1712+
layout.align.abi_bits() as u32,
17171713
DIFlags::FlagZero,
17181714
None,
17191715
type_array,

0 commit comments

Comments
 (0)