Skip to content

Commit c1cdc47

Browse files
committed
abi: use scalar_pair_field_index instead of index in some places.
1 parent 2ddae10 commit c1cdc47

File tree

1 file changed

+17
-17
lines changed
  • crates/rustc_codegen_spirv/src

1 file changed

+17
-17
lines changed

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ fn trans_scalar<'tcx>(
409409
span: Span,
410410
ty: TyAndLayout<'tcx>,
411411
scalar: &Scalar,
412-
index: Option<usize>,
412+
scalar_pair_field_index: Option<usize>,
413413
is_immediate: bool,
414414
) -> Word {
415415
if is_immediate && scalar.is_bool() {
@@ -423,7 +423,7 @@ fn trans_scalar<'tcx>(
423423
Primitive::F32 => SpirvType::Float(32).def(span, cx),
424424
Primitive::F64 => SpirvType::Float(64).def(span, cx),
425425
Primitive::Pointer => {
426-
let pointee_ty = dig_scalar_pointee(cx, ty, index);
426+
let pointee_ty = dig_scalar_pointee(cx, ty, scalar_pair_field_index);
427427
// Pointers can be recursive. So, record what we're currently translating, and if we're already translating
428428
// the same type, emit an OpTypeForwardPointer and use that ID.
429429
if let Some(predefined_result) = cx
@@ -455,16 +455,16 @@ fn trans_scalar<'tcx>(
455455
fn dig_scalar_pointee<'tcx>(
456456
cx: &CodegenCx<'tcx>,
457457
ty: TyAndLayout<'tcx>,
458-
index: Option<usize>,
458+
scalar_pair_field_index: Option<usize>,
459459
) -> PointeeTy<'tcx> {
460460
match *ty.ty.kind() {
461461
TyKind::Ref(_, elem_ty, _) | TyKind::RawPtr(TypeAndMut { ty: elem_ty, .. }) => {
462462
let elem = cx.layout_of(elem_ty);
463-
match index {
463+
match scalar_pair_field_index {
464464
None => PointeeTy::Ty(elem),
465-
Some(index) => {
465+
Some(scalar_pair_field_index) => {
466466
if elem.is_unsized() {
467-
dig_scalar_pointee(cx, ty.field(cx, index), None)
467+
dig_scalar_pointee(cx, ty.field(cx, scalar_pair_field_index), None)
468468
} else {
469469
// This can sometimes happen in weird cases when going through the Adt case below - an ABI
470470
// of ScalarPair could be deduced, but it's actually e.g. a sized pointer followed by some other
@@ -475,25 +475,25 @@ fn dig_scalar_pointee<'tcx>(
475475
}
476476
}
477477
}
478-
TyKind::FnPtr(sig) if index.is_none() => PointeeTy::Fn(sig),
478+
TyKind::FnPtr(sig) if scalar_pair_field_index.is_none() => PointeeTy::Fn(sig),
479479
TyKind::Adt(def, _) if def.is_box() => {
480480
let ptr_ty = cx.layout_of(cx.tcx.mk_mut_ptr(ty.ty.boxed_ty()));
481-
dig_scalar_pointee(cx, ptr_ty, index)
481+
dig_scalar_pointee(cx, ptr_ty, scalar_pair_field_index)
482482
}
483483
TyKind::Tuple(_) | TyKind::Adt(..) | TyKind::Closure(..) => {
484-
dig_scalar_pointee_adt(cx, ty, index)
484+
dig_scalar_pointee_adt(cx, ty, scalar_pair_field_index)
485485
}
486486
ref kind => cx.tcx.sess.fatal(&format!(
487-
"TODO: Unimplemented Primitive::Pointer TyKind index={:?} ({:#?}):\n{:#?}",
488-
index, kind, ty
487+
"TODO: Unimplemented Primitive::Pointer TyKind scalar_pair_field_index={:?} ({:#?}):\n{:#?}",
488+
scalar_pair_field_index, kind, ty
489489
)),
490490
}
491491
}
492492

493493
fn dig_scalar_pointee_adt<'tcx>(
494494
cx: &CodegenCx<'tcx>,
495495
ty: TyAndLayout<'tcx>,
496-
index: Option<usize>,
496+
scalar_pair_field_index: Option<usize>,
497497
) -> PointeeTy<'tcx> {
498498
match &ty.variants {
499499
// If it's a Variants::Multiple, then we want to emit the type of the dataful variant, not the type of the
@@ -519,7 +519,7 @@ fn dig_scalar_pointee_adt<'tcx>(
519519
assert_eq!(1, adt.variants[dataful_variant].fields.len());
520520
assert_eq!(0, *tag_field);
521521
let field_ty = adt.variants[dataful_variant].fields[0].ty(cx.tcx, substs);
522-
dig_scalar_pointee(cx, cx.layout_of(field_ty), index)
522+
dig_scalar_pointee(cx, cx.layout_of(field_ty), scalar_pair_field_index)
523523
} else {
524524
bug!("Variants::Multiple not TyKind::Adt: {:#?}", ty)
525525
}
@@ -533,11 +533,11 @@ fn dig_scalar_pointee_adt<'tcx>(
533533
.map(|f| ty.field(cx, f))
534534
.filter(|f| !f.is_zst())
535535
.collect::<Vec<_>>();
536-
match index {
537-
Some(index) => match fields.len() {
538-
1 => dig_scalar_pointee(cx, fields[0], Some(index)),
536+
match scalar_pair_field_index {
537+
Some(scalar_pair_field_index) => match fields.len() {
538+
1 => dig_scalar_pointee(cx, fields[0], Some(scalar_pair_field_index)),
539539
// This case right here is the cause of the comment handling TyKind::Ref.
540-
2 => dig_scalar_pointee(cx, fields[index], None),
540+
2 => dig_scalar_pointee(cx, fields[scalar_pair_field_index], None),
541541
other => cx.tcx.sess.fatal(&format!(
542542
"Unable to dig scalar pair pointer type: fields length {}",
543543
other

0 commit comments

Comments
 (0)