Skip to content

Commit 94fbb21

Browse files
committed
implement va_arg for arm in rustc itself
1 parent 4189005 commit 94fbb21

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

compiler/rustc_codegen_llvm/src/va_arg.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,21 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
908908
)
909909
}
910910
"aarch64" => emit_aapcs_va_arg(bx, addr, target_ty),
911+
"arm" => {
912+
// Types wider than 16 bytes are not currently supported. Clang has special logic for
913+
// such types, but `VaArgSafe` is not implemented for any type that is this large.
914+
assert!(bx.cx.size_of(target_ty).bytes() <= 16);
915+
916+
emit_ptr_va_arg(
917+
bx,
918+
addr,
919+
target_ty,
920+
PassMode::Direct,
921+
SlotSize::Bytes4,
922+
AllowHigherAlign::Yes,
923+
ForceRightAdjust::No,
924+
)
925+
}
911926
"s390x" => emit_s390x_va_arg(bx, addr, target_ty),
912927
"powerpc" => emit_powerpc_va_arg(bx, addr, target_ty),
913928
"powerpc64" | "powerpc64le" => emit_ptr_va_arg(
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@ assembly-output: emit-asm
2+
//@ compile-flags: -Copt-level=3
3+
//@ only-arm
4+
//@ ignore-thumb
5+
//@ ignore-android
6+
#![no_std]
7+
#![crate_type = "lib"]
8+
#![feature(c_variadic)]
9+
10+
// Check that the assembly that rustc generates matches what clang emits.
11+
12+
#[unsafe(no_mangle)]
13+
unsafe extern "C" fn variadic(a: f64, mut args: ...) -> f64 {
14+
// CHECK-LABEL: variadic
15+
// CHECK: sub sp, sp
16+
17+
// CHECK: vldr
18+
// CHECK: vadd.f64
19+
// CHECK: vldr
20+
// CHECK: vadd.f64
21+
let b = args.arg::<f64>();
22+
let c = args.arg::<f64>();
23+
a + b + c
24+
25+
// CHECK: add sp, sp
26+
}

0 commit comments

Comments
 (0)