• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=arm64_32-apple-ios %s -o - | FileCheck %s
2
3define void @test_va_copy(i8* %dst, i8* %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(i8* %dst, i8* %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 i8*, align 4
17  %list = bitcast i8** %slot to i8*
18  call void @llvm.va_start(i8* %list)
19  ret void
20}
21
22define void @test_va_start_odd([8 x i64], i32, ...) {
23; CHECK-LABEL: test_va_start_odd:
24; CHECK: add x[[LIST:[0-9]+]], sp, #20
25; CHECK: str w[[LIST]],
26  %slot = alloca i8*, align 4
27  %list = bitcast i8** %slot to i8*
28  call void @llvm.va_start(i8* %list)
29  ret void
30}
31
32define i8* @test_va_arg(i8** %list) {
33; CHECK-LABEL: test_va_arg:
34; CHECK: ldr w[[LOC:[0-9]+]], [x0]
35; CHECK: add [[NEXTLOC:w[0-9]+]], w[[LOC]], #4
36; CHECK: str [[NEXTLOC]], [x0]
37; CHECK: ldr w0, [x[[LOC]]]
38  %res = va_arg i8** %list, i8*
39  ret i8* %res
40}
41
42define i8* @really_test_va_arg(i8** %list, i1 %tst) {
43; CHECK-LABEL: really_test_va_arg:
44; CHECK: ldr w[[LOC:[0-9]+]], [x0]
45; CHECK: add [[NEXTLOC:w[0-9]+]], w[[LOC]], #4
46; CHECK: str [[NEXTLOC]], [x0]
47; CHECK: ldr w[[VAARG:[0-9]+]], [x[[LOC]]]
48; CHECK: csel x0, x[[VAARG]], xzr
49  %tmp = va_arg i8** %list, i8*
50  %res = select i1 %tst, i8* %tmp, i8* null
51  ret i8* %res
52}
53
54declare void @llvm.va_start(i8*)
55
56declare void @llvm.va_copy(i8*, i8*)
57