Skip to content

Commit 295c929

Browse files
committed
WIP vec3: adjust abi layout
1 parent e8a4a19 commit 295c929

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ pub(crate) fn provide(providers: &mut Providers) {
164164
}
165165
}
166166

167-
providers.layout_of = |tcx, key| {
167+
providers.layout_of = |tcx: TyCtxt<'_>,
168+
key: ty::PseudoCanonicalInput<'_, Ty<'_>>|
169+
-> Result<TyAndLayout<'_>, &'_ ty::layout::LayoutError<'_>> {
168170
// HACK(eddyb) to special-case any types at all, they must be normalized,
169171
// but when normalization would be needed, `layout_of`'s default provider
170172
// recurses (supposedly for caching reasons), i.e. its calls `layout_of`

crates/rustc_codegen_spirv/src/spirv_type.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,7 @@ impl SpirvType<'_> {
280280
Self::Bool => Size::from_bytes(1),
281281
Self::Integer(width, _) | Self::Float(width) => Size::from_bits(width),
282282
Self::Adt { size, .. } => size?,
283-
Self::Vector { element, count } => {
284-
cx.lookup_type(element).sizeof(cx)? * count.next_power_of_two() as u64
285-
}
283+
Self::Vector { element, count } => cx.lookup_type(element).sizeof(cx)? * count as u64,
286284
Self::Matrix { element, count } => cx.lookup_type(element).sizeof(cx)? * count as u64,
287285
Self::Array { element, count } => {
288286
cx.lookup_type(element).sizeof(cx)?
@@ -311,14 +309,8 @@ impl SpirvType<'_> {
311309
Self::Bool => Align::from_bytes(1).unwrap(),
312310
Self::Integer(width, _) | Self::Float(width) => Align::from_bits(width as u64).unwrap(),
313311
Self::Adt { align, .. } => align,
314-
// Vectors have size==align
315-
Self::Vector { .. } => Align::from_bytes(
316-
self.sizeof(cx)
317-
.expect("alignof: Vectors must be sized")
318-
.bytes(),
319-
)
320-
.expect("alignof: Vectors must have power-of-2 size"),
321-
Self::Array { element, .. }
312+
Self::Vector { element, .. }
313+
| Self::Array { element, .. }
322314
| Self::RuntimeArray { element }
323315
| Self::Matrix { element, .. } => cx.lookup_type(element).alignof(cx),
324316
Self::Pointer { .. } => cx.tcx.data_layout.pointer_align.abi,

0 commit comments

Comments
 (0)