xref: /llvm-project/llvm/test/CodeGen/AArch64/arm64_32-va.ll (revision 5ddce70ef0e5a641d7fea95e31fc5e2439cb98cb)
1; RUN: llc -mtriple=arm64_32-apple-ios %s -o - | FileCheck %s
2
3define void @test_va_copy(ptr %dst, ptr %src) {
4; CHECK-LABEL: test_va_copy:
5; CHECK: ldr [[PTR:w[0-9]+]], [x1]
6; CHECK: str [[PTR]], [x0]
7
8  call void @llvm.va_copy(ptr %dst, ptr %src)
9  ret void
10}
11
12define void @test_va_start(i32, ...)  {
13; CHECK-LABEL: test_va_start
14; CHECK: add x[[LIST:[0-9]+]], sp, #16
15; CHECK: str w[[LIST]],
16  %slot = alloca ptr, align 4
17  call void @llvm.va_start(ptr %slot)
18  ret void
19}
20
21define void @test_va_start_odd([8 x i64], i32, ...) {
22; CHECK-LABEL: test_va_start_odd:
23; CHECK: add x[[LIST:[0-9]+]], sp, #20
24; CHECK: str w[[LIST]],
25  %slot = alloca ptr, align 4
26  call void @llvm.va_start(ptr %slot)
27  ret void
28}
29
30define ptr @test_va_arg(ptr %list) {
31; CHECK-LABEL: test_va_arg:
32; CHECK: ldr w[[LOC:[0-9]+]], [x0]
33; CHECK: add [[NEXTLOC:w[0-9]+]], w[[LOC]], #4
34; CHECK: str [[NEXTLOC]], [x0]
35; CHECK: ldr w0, [x[[LOC]]]
36  %res = va_arg ptr %list, ptr
37  ret ptr %res
38}
39
40define ptr @really_test_va_arg(ptr %list, i1 %tst) {
41; CHECK-LABEL: really_test_va_arg:
42; CHECK: ldr w[[LOC:[0-9]+]], [x0]
43; CHECK: add [[NEXTLOC:w[0-9]+]], w[[LOC]], #4
44; CHECK: str [[NEXTLOC]], [x0]
45; CHECK: ldr w[[VAARG:[0-9]+]], [x[[LOC]]]
46; CHECK: csel x0, x[[VAARG]], xzr
47  %tmp = va_arg ptr %list, ptr
48  %res = select i1 %tst, ptr %tmp, ptr null
49  ret ptr %res
50}
51
52declare void @llvm.va_start(ptr)
53
54declare void @llvm.va_copy(ptr, ptr)
55