Skip to content

Commit f259470

Browse files
committed
rustc_target::abi: rename FieldPlacement to FieldsShape.
1 parent 2113659 commit f259470

File tree

9 files changed

+64
-64
lines changed

9 files changed

+64
-64
lines changed

src/librustc_codegen_llvm/type_of.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn uncached_llvm_type<'a, 'tcx>(
7979
};
8080

8181
match layout.fields {
82-
layout::FieldPlacement::Union(_) => {
82+
layout::FieldsShape::Union(_) => {
8383
let fill = cx.type_padding_filler(layout.size, layout.align.abi);
8484
let packed = false;
8585
match name {
@@ -91,10 +91,10 @@ fn uncached_llvm_type<'a, 'tcx>(
9191
}
9292
}
9393
}
94-
layout::FieldPlacement::Array { count, .. } => {
94+
layout::FieldsShape::Array { count, .. } => {
9595
cx.type_array(layout.field(cx, 0).llvm_type(cx), count)
9696
}
97-
layout::FieldPlacement::Arbitrary { .. } => match name {
97+
layout::FieldsShape::Arbitrary { .. } => match name {
9898
None => {
9999
let (llfields, packed) = struct_llfields(cx, layout);
100100
cx.type_struct(&llfields, packed)
@@ -371,13 +371,13 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
371371
_ => {}
372372
}
373373
match self.fields {
374-
layout::FieldPlacement::Union(_) => {
374+
layout::FieldsShape::Union(_) => {
375375
bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self)
376376
}
377377

378-
layout::FieldPlacement::Array { .. } => index as u64,
378+
layout::FieldsShape::Array { .. } => index as u64,
379379

380-
layout::FieldPlacement::Arbitrary { .. } => {
380+
layout::FieldsShape::Arbitrary { .. } => {
381381
1 + (self.fields.memory_index(index) as u64) * 2
382382
}
383383
}

src/librustc_codegen_ssa/mir/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
6666
}
6767

6868
pub fn len<Cx: ConstMethods<'tcx, Value = V>>(&self, cx: &Cx) -> V {
69-
if let layout::FieldPlacement::Array { count, .. } = self.layout.fields {
69+
if let layout::FieldsShape::Array { count, .. } = self.layout.fields {
7070
if self.layout.is_unsized() {
7171
assert_eq!(count, 0);
7272
self.llextra.unwrap()

src/librustc_middle/ty/layout.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ enum StructKind {
229229
// Invert a bijective mapping, i.e. `invert(map)[y] = x` if `map[x] = y`.
230230
// This is used to go between `memory_index` (source field order to memory order)
231231
// and `inverse_memory_index` (memory order to source field order).
232-
// See also `FieldPlacement::Arbitrary::memory_index` for more details.
232+
// See also `FieldsShape::Arbitrary::memory_index` for more details.
233233
// FIXME(eddyb) build a better abstraction for permutations, if possible.
234234
fn invert_mapping(map: &[u32]) -> Vec<u32> {
235235
let mut inverse = vec![0; map.len()];
@@ -256,7 +256,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
256256

257257
Layout {
258258
variants: Variants::Single { index: VariantIdx::new(0) },
259-
fields: FieldPlacement::Arbitrary {
259+
fields: FieldsShape::Arbitrary {
260260
offsets: vec![Size::ZERO, b_offset],
261261
memory_index: vec![0, 1],
262262
},
@@ -442,7 +442,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
442442
};
443443
let pair = self.scalar_pair(a.clone(), b.clone());
444444
let pair_offsets = match pair.fields {
445-
FieldPlacement::Arbitrary { ref offsets, ref memory_index } => {
445+
FieldsShape::Arbitrary { ref offsets, ref memory_index } => {
446446
assert_eq!(memory_index, &[0, 1]);
447447
offsets
448448
}
@@ -470,7 +470,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
470470

471471
Ok(Layout {
472472
variants: Variants::Single { index: VariantIdx::new(0) },
473-
fields: FieldPlacement::Arbitrary { offsets, memory_index },
473+
fields: FieldsShape::Arbitrary { offsets, memory_index },
474474
abi,
475475
largest_niche,
476476
align,
@@ -519,7 +519,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
519519
// The never type.
520520
ty::Never => tcx.intern_layout(Layout {
521521
variants: Variants::Single { index: VariantIdx::new(0) },
522-
fields: FieldPlacement::Union(0),
522+
fields: FieldsShape::Union(0),
523523
abi: Abi::Uninhabited,
524524
largest_niche: None,
525525
align: dl.i8_align,
@@ -580,7 +580,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
580580

581581
tcx.intern_layout(Layout {
582582
variants: Variants::Single { index: VariantIdx::new(0) },
583-
fields: FieldPlacement::Array { stride: element.size, count },
583+
fields: FieldsShape::Array { stride: element.size, count },
584584
abi,
585585
largest_niche,
586586
align: element.align,
@@ -591,7 +591,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
591591
let element = self.layout_of(element)?;
592592
tcx.intern_layout(Layout {
593593
variants: Variants::Single { index: VariantIdx::new(0) },
594-
fields: FieldPlacement::Array { stride: element.size, count: 0 },
594+
fields: FieldsShape::Array { stride: element.size, count: 0 },
595595
abi: Abi::Aggregate { sized: false },
596596
largest_niche: None,
597597
align: element.align,
@@ -600,7 +600,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
600600
}
601601
ty::Str => tcx.intern_layout(Layout {
602602
variants: Variants::Single { index: VariantIdx::new(0) },
603-
fields: FieldPlacement::Array { stride: Size::from_bytes(1), count: 0 },
603+
fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 },
604604
abi: Abi::Aggregate { sized: false },
605605
largest_niche: None,
606606
align: dl.i8_align,
@@ -669,7 +669,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
669669

670670
tcx.intern_layout(Layout {
671671
variants: Variants::Single { index: VariantIdx::new(0) },
672-
fields: FieldPlacement::Array { stride: element.size, count },
672+
fields: FieldsShape::Array { stride: element.size, count },
673673
abi: Abi::Vector { element: scalar, count },
674674
largest_niche: element.largest_niche.clone(),
675675
size,
@@ -745,7 +745,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
745745

746746
return Ok(tcx.intern_layout(Layout {
747747
variants: Variants::Single { index },
748-
fields: FieldPlacement::Union(variants[index].len()),
748+
fields: FieldsShape::Union(variants[index].len()),
749749
abi,
750750
largest_niche: None,
751751
align,
@@ -979,7 +979,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
979979
discr_index: 0,
980980
variants: st,
981981
},
982-
fields: FieldPlacement::Arbitrary {
982+
fields: FieldsShape::Arbitrary {
983983
offsets: vec![offset],
984984
memory_index: vec![0],
985985
},
@@ -1120,7 +1120,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
11201120
let new_ity_size = ity.size();
11211121
for variant in &mut layout_variants {
11221122
match variant.fields {
1123-
FieldPlacement::Arbitrary { ref mut offsets, .. } => {
1123+
FieldsShape::Arbitrary { ref mut offsets, .. } => {
11241124
for i in offsets {
11251125
if *i <= old_ity_size {
11261126
assert_eq!(*i, old_ity_size);
@@ -1150,7 +1150,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
11501150
let mut common_prim = None;
11511151
for (field_layouts, layout_variant) in variants.iter().zip(&layout_variants) {
11521152
let offsets = match layout_variant.fields {
1153-
FieldPlacement::Arbitrary { ref offsets, .. } => offsets,
1153+
FieldsShape::Arbitrary { ref offsets, .. } => offsets,
11541154
_ => bug!(),
11551155
};
11561156
let mut fields =
@@ -1186,7 +1186,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
11861186
if let Some((prim, offset)) = common_prim {
11871187
let pair = self.scalar_pair(tag.clone(), scalar_unit(prim));
11881188
let pair_offsets = match pair.fields {
1189-
FieldPlacement::Arbitrary { ref offsets, ref memory_index } => {
1189+
FieldsShape::Arbitrary { ref offsets, ref memory_index } => {
11901190
assert_eq!(memory_index, &[0, 1]);
11911191
offsets
11921192
}
@@ -1217,7 +1217,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12171217
discr_index: 0,
12181218
variants: layout_variants,
12191219
},
1220-
fields: FieldPlacement::Arbitrary {
1220+
fields: FieldsShape::Arbitrary {
12211221
offsets: vec![Size::ZERO],
12221222
memory_index: vec![0],
12231223
},
@@ -1434,7 +1434,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
14341434
// GeneratorLayout.
14351435
debug!("prefix = {:#?}", prefix);
14361436
let (outer_fields, promoted_offsets, promoted_memory_index) = match prefix.fields {
1437-
FieldPlacement::Arbitrary { mut offsets, memory_index } => {
1437+
FieldsShape::Arbitrary { mut offsets, memory_index } => {
14381438
let mut inverse_memory_index = invert_mapping(&memory_index);
14391439

14401440
// "a" (`0..b_start`) and "b" (`b_start..`) correspond to
@@ -1457,7 +1457,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
14571457
let memory_index_b = invert_mapping(&inverse_memory_index_b);
14581458

14591459
let outer_fields =
1460-
FieldPlacement::Arbitrary { offsets: offsets_a, memory_index: memory_index_a };
1460+
FieldsShape::Arbitrary { offsets: offsets_a, memory_index: memory_index_a };
14611461
(outer_fields, offsets_b, memory_index_b)
14621462
}
14631463
_ => bug!(),
@@ -1491,7 +1491,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
14911491
variant.variants = Variants::Single { index };
14921492

14931493
let (offsets, memory_index) = match variant.fields {
1494-
FieldPlacement::Arbitrary { offsets, memory_index } => (offsets, memory_index),
1494+
FieldsShape::Arbitrary { offsets, memory_index } => (offsets, memory_index),
14951495
_ => bug!(),
14961496
};
14971497

@@ -1534,7 +1534,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
15341534
combined_inverse_memory_index.retain(|&i| i != INVALID_FIELD_IDX);
15351535
let combined_memory_index = invert_mapping(&combined_inverse_memory_index);
15361536

1537-
variant.fields = FieldPlacement::Arbitrary {
1537+
variant.fields = FieldsShape::Arbitrary {
15381538
offsets: combined_offsets,
15391539
memory_index: combined_memory_index,
15401540
};
@@ -1989,7 +1989,7 @@ where
19891989
if index == variant_index &&
19901990
// Don't confuse variants of uninhabited enums with the enum itself.
19911991
// For more details see https://github.com/rust-lang/rust/issues/69763.
1992-
this.fields != FieldPlacement::Union(0) =>
1992+
this.fields != FieldsShape::Union(0) =>
19931993
{
19941994
this.layout
19951995
}
@@ -2007,7 +2007,7 @@ where
20072007
let tcx = cx.tcx();
20082008
tcx.intern_layout(Layout {
20092009
variants: Variants::Single { index: variant_index },
2010-
fields: FieldPlacement::Union(fields),
2010+
fields: FieldsShape::Union(fields),
20112011
abi: Abi::Uninhabited,
20122012
largest_niche: None,
20132013
align: tcx.data_layout.i8_align,
@@ -2053,7 +2053,7 @@ where
20532053
// Reuse the fat `*T` type as its own thin pointer data field.
20542054
// This provides information about, e.g., DST struct pointees
20552055
// (which may have no non-DST form), and will work as long
2056-
// as the `Abi` or `FieldPlacement` is checked by users.
2056+
// as the `Abi` or `FieldsShape` is checked by users.
20572057
if i == 0 {
20582058
let nil = tcx.mk_unit();
20592059
let ptr_ty = if this.ty.is_unsafe_ptr() {
@@ -2218,7 +2218,7 @@ where
22182218

22192219
if let Some(variant) = data_variant {
22202220
// We're not interested in any unions.
2221-
if let FieldPlacement::Union(_) = variant.fields {
2221+
if let FieldsShape::Union(_) = variant.fields {
22222222
data_variant = None;
22232223
}
22242224
}

src/librustc_mir/interpret/place.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
219219
// Go through the layout. There are lots of types that support a length,
220220
// e.g., SIMD types.
221221
match self.layout.fields {
222-
layout::FieldPlacement::Array { count, .. } => Ok(count),
222+
layout::FieldsShape::Array { count, .. } => Ok(count),
223223
_ => bug!("len not supported on sized type {:?}", self.layout.ty),
224224
}
225225
}
@@ -437,7 +437,7 @@ where
437437
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
438438
// Not using the layout method because we want to compute on u64
439439
match base.layout.fields {
440-
layout::FieldPlacement::Array { stride, .. } => {
440+
layout::FieldsShape::Array { stride, .. } => {
441441
let len = base.len(self)?;
442442
if index >= len {
443443
// This can only be reached in ConstProp and non-rustc-MIR.
@@ -463,7 +463,7 @@ where
463463
{
464464
let len = base.len(self)?; // also asserts that we have a type where this makes sense
465465
let stride = match base.layout.fields {
466-
layout::FieldPlacement::Array { stride, .. } => stride,
466+
layout::FieldsShape::Array { stride, .. } => stride,
467467
_ => bug!("mplace_array_fields: expected an array layout"),
468468
};
469469
let layout = base.layout.field(self, 0)?;
@@ -493,7 +493,7 @@ where
493493
// Not using layout method because that works with usize, and does not work with slices
494494
// (that have count 0 in their layout).
495495
let from_offset = match base.layout.fields {
496-
layout::FieldPlacement::Array { stride, .. } => stride * from, // `Size` multiplication is checked
496+
layout::FieldsShape::Array { stride, .. } => stride * from, // `Size` multiplication is checked
497497
_ => bug!("Unexpected layout of index access: {:#?}", base.layout),
498498
};
499499

src/librustc_mir/interpret/visitor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ macro_rules! make_value_visitor {
207207

208208
// Visit the fields of this value.
209209
match v.layout().fields {
210-
layout::FieldPlacement::Union(fields) => {
210+
layout::FieldsShape::Union(fields) => {
211211
self.visit_union(v, fields)?;
212212
},
213-
layout::FieldPlacement::Arbitrary { ref offsets, .. } => {
213+
layout::FieldsShape::Arbitrary { ref offsets, .. } => {
214214
// FIXME: We collect in a vec because otherwise there are lifetime
215215
// errors: Projecting to a field needs access to `ecx`.
216216
let fields: Vec<InterpResult<'tcx, Self::V>> =
@@ -220,7 +220,7 @@ macro_rules! make_value_visitor {
220220
.collect();
221221
self.visit_aggregate(v, fields.into_iter())?;
222222
},
223-
layout::FieldPlacement::Array { .. } => {
223+
layout::FieldsShape::Array { .. } => {
224224
// Let's get an mplace first.
225225
let mplace = v.to_op(self.ecx())?.assert_mem_place(self.ecx());
226226
// Now we can go over all the fields.

src/librustc_target/abi/call/mips64.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ where
4949
// use of float registers to structures (not unions) containing exactly one or two
5050
// float fields.
5151

52-
if let abi::FieldPlacement::Arbitrary { .. } = ret.layout.fields {
52+
if let abi::FieldsShape::Arbitrary { .. } = ret.layout.fields {
5353
if ret.layout.fields.count() == 1 {
5454
if let Some(reg) = float_reg(cx, ret, 0) {
5555
ret.cast_to(reg);
@@ -88,15 +88,15 @@ where
8888
let mut prefix_index = 0;
8989

9090
match arg.layout.fields {
91-
abi::FieldPlacement::Array { .. } => {
91+
abi::FieldsShape::Array { .. } => {
9292
// Arrays are passed indirectly
9393
arg.make_indirect();
9494
return;
9595
}
96-
abi::FieldPlacement::Union(_) => {
96+
abi::FieldsShape::Union(_) => {
9797
// Unions and are always treated as a series of 64-bit integer chunks
9898
}
99-
abi::FieldPlacement::Arbitrary { .. } => {
99+
abi::FieldsShape::Arbitrary { .. } => {
100100
// Structures are split up into a series of 64-bit integer chunks, but any aligned
101101
// doubles not part of another aggregate are passed as floats.
102102
let mut last_offset = Size::ZERO;

src/librustc_target/abi/call/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::abi::{self, Abi, Align, FieldPlacement, Size};
1+
use crate::abi::{self, Abi, Align, FieldsShape, Size};
22
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
33
use crate::spec::{self, HasTargetSpec};
44

@@ -315,7 +315,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
315315
start: Size|
316316
-> Result<(HomogeneousAggregate, Size), Heterogeneous> {
317317
let is_union = match layout.fields {
318-
FieldPlacement::Array { count, .. } => {
318+
FieldsShape::Array { count, .. } => {
319319
assert_eq!(start, Size::ZERO);
320320

321321
let result = if count > 0 {
@@ -325,8 +325,8 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
325325
};
326326
return Ok((result, layout.size));
327327
}
328-
FieldPlacement::Union(_) => true,
329-
FieldPlacement::Arbitrary { .. } => false,
328+
FieldsShape::Union(_) => true,
329+
FieldsShape::Arbitrary { .. } => false,
330330
};
331331

332332
let mut result = HomogeneousAggregate::NoData;

src/librustc_target/abi/call/riscv.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use crate::abi::call::{ArgAbi, ArgAttribute, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
88
use crate::abi::{
9-
self, Abi, FieldPlacement, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods,
9+
self, Abi, FieldsShape, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods,
1010
};
1111
use crate::spec::HasTargetSpec;
1212

@@ -87,12 +87,12 @@ where
8787
},
8888
Abi::Vector { .. } | Abi::Uninhabited => return Err(CannotUseFpConv),
8989
Abi::ScalarPair(..) | Abi::Aggregate { .. } => match arg_layout.fields {
90-
FieldPlacement::Union(_) => {
90+
FieldsShape::Union(_) => {
9191
if !arg_layout.is_zst() {
9292
return Err(CannotUseFpConv);
9393
}
9494
}
95-
FieldPlacement::Array { count, .. } => {
95+
FieldsShape::Array { count, .. } => {
9696
for _ in 0..count {
9797
let elem_layout = arg_layout.field(cx, 0);
9898
should_use_fp_conv_helper(
@@ -105,7 +105,7 @@ where
105105
)?;
106106
}
107107
}
108-
FieldPlacement::Arbitrary { .. } => {
108+
FieldsShape::Arbitrary { .. } => {
109109
match arg_layout.variants {
110110
abi::Variants::Multiple { .. } => return Err(CannotUseFpConv),
111111
abi::Variants::Single { .. } => (),

0 commit comments

Comments
 (0)