va_arg: use emit_ptr_va_arg for mips

This commit is contained in:
Folkert de Vries
2026-02-13 13:38:07 +01:00
parent 328d05309c
commit e9ab558406
2 changed files with 31 additions and 16 deletions
+19 -4
View File
@@ -1171,14 +1171,29 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
AllowHigherAlign::Yes,
ForceRightAdjust::No,
),
Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => emit_ptr_va_arg(
bx,
addr,
target_ty,
PassMode::Direct,
match &target.llvm_abiname {
LlvmAbi::N32 | LlvmAbi::N64 => SlotSize::Bytes8,
LlvmAbi::O32 => SlotSize::Bytes4,
other => bug!("unexpected LLVM ABI {other}"),
},
AllowHigherAlign::Yes,
// In big-endian mode the actual value is stored in the right side of the slot, meaning
// that when the value is smaller than a slot, we need to adjust the pointer we read
// to somewhere in the middle of the slot.
match bx.tcx().sess.target.endian {
Endian::Big => ForceRightAdjust::Yes,
Endian::Little => ForceRightAdjust::No,
},
),
Arch::Bpf => bug!("bpf does not support c-variadic functions"),
Arch::SpirV => bug!("spirv does not support c-variadic functions"),
Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => {
// FIXME: port MipsTargetLowering::lowerVAARG.
bx.va_arg(addr.immediate(), bx.cx.layout_of(target_ty).llvm_type(bx.cx))
}
Arch::Sparc | Arch::Avr | Arch::M68k | Arch::Msp430 => {
// Clang uses the LLVM implementation for these architectures.
bx.va_arg(addr.immediate(), bx.cx.layout_of(target_ty).llvm_type(bx.cx))