1 ; RUN: llc -aarch64-load-store-renaming=true -verify-machineinstrs -mtriple=arm64-linux-gnu -pre-RA-sched=linearize -enable-misched=false -disable-post-ra < %s | FileCheck %s
3 %va_list = type {ptr, ptr, ptr, i32, i32}
5 @var = dso_local global %va_list zeroinitializer, align 8
7 declare void @llvm.va_start(ptr)
9 define dso_local void @test_simple(i32 %n, ...) {
10 ; CHECK-LABEL: test_simple:
11 ; CHECK: sub sp, sp, #[[STACKSIZE:[0-9]+]]
12 ; CHECK: add [[STACK_TOP:x[0-9]+]], sp, #[[STACKSIZE]]
14 ; CHECK: adrp x[[VA_LIST_HI:[0-9]+]], var
15 ; CHECK: add x[[VA_LIST:[0-9]+]], {{x[0-9]+}}, :lo12:var
17 ; CHECK-DAG: stp x6, x7, [sp, #
18 ; ... omit middle ones ...
19 ; CHECK-DAG: str x1, [sp, #[[GR_BASE:[0-9]+]]]
21 ; CHECK-DAG: stp q0, q1, [sp]
22 ; ... omit middle ones ...
23 ; CHECK-DAG: stp q6, q7, [sp, #
25 ; CHECK: str [[STACK_TOP]], [x[[VA_LIST]]]
27 ; CHECK: add [[GR_TOPTMP:x[0-9]+]], sp, #[[GR_BASE]]
28 ; CHECK: add [[GR_TOP:x[0-9]+]], [[GR_TOPTMP]], #56
31 ; CHECK: mov [[VR_TOPTMP:x[0-9]+]], sp
32 ; CHECK: add [[VR_TOP:x[0-9]+]], [[VR_TOPTMP]], #128
33 ; CHECK: stp [[GR_TOP]], [[VR_TOP]], [x[[VA_LIST]], #8]
35 ; CHECK: mov [[GRVR:x[0-9]+]], #-56
36 ; CHECK: movk [[GRVR]], #65408, lsl #32
37 ; CHECK: str [[GRVR]], [x[[VA_LIST]], #24]
39 call void @llvm.va_start(ptr @var)
44 define dso_local void @test_fewargs(i32 %n, i32 %n1, i32 %n2, float %m, ...) {
45 ; CHECK-LABEL: test_fewargs:
46 ; CHECK: sub sp, sp, #[[STACKSIZE:[0-9]+]]
47 ; CHECK: add [[STACK_TOP:x[0-9]+]], sp, #[[STACKSIZE]]
49 ; CHECK: adrp x[[VA_LIST_HI:[0-9]+]], var
50 ; CHECK: add x[[VA_LIST:[0-9]+]], {{x[0-9]+}}, :lo12:var
52 ; CHECK-DAG: stp x6, x7, [sp, #
53 ; ... omit middle ones ...
54 ; CHECK-DAG: str x3, [sp, #[[GR_BASE:[0-9]+]]]
56 ; CHECK-DAG: stp q6, q7, [sp, #80]
57 ; ... omit middle ones ...
58 ; CHECK-DAG: str q1, [sp]
60 ; CHECK: str [[STACK_TOP]], [x[[VA_LIST]]]
62 ; CHECK: add [[GR_TOPTMP:x[0-9]+]], sp, #[[GR_BASE]]
63 ; CHECK: add [[GR_TOP:x[0-9]+]], [[GR_TOPTMP]], #40
65 ; CHECK: mov [[VR_TOPTMP:x[0-9]+]], sp
66 ; CHECK: add [[VR_TOP:x[0-9]+]], [[VR_TOPTMP]], #112
67 ; CHECK: stp [[GR_TOP]], [[VR_TOP]], [x[[VA_LIST]], #8]
69 ; CHECK: mov [[GRVR_OFFS:x[0-9]+]], #-40
70 ; CHECK: movk [[GRVR_OFFS]], #65424, lsl #32
71 ; CHECK: str [[GRVR_OFFS]], [x[[VA_LIST]], #24]
73 call void @llvm.va_start(ptr @var)
78 define dso_local void @test_nospare([8 x i64], [8 x float], ...) {
79 ; CHECK-LABEL: test_nospare:
81 call void @llvm.va_start(ptr @var)
82 ; CHECK-NOT: sub sp, sp
83 ; CHECK: mov [[STACK:x[0-9]+]], sp
84 ; CHECK: add x[[VAR:[0-9]+]], {{x[0-9]+}}, :lo12:var
85 ; CHECK: str [[STACK]], [x[[VAR]]]
90 ; If there are non-variadic arguments on the stack (here two i64s) then the
91 ; __stack field should point just past them.
92 define dso_local void @test_offsetstack([8 x i64], [2 x i64], [3 x float], ...) {
93 ; CHECK-LABEL: test_offsetstack:
95 ; CHECK-DAG: stp {{q[0-9]+}}, {{q[0-9]+}}, [sp, #48]
96 ; CHECK-DAG: stp {{q[0-9]+}}, {{q[0-9]+}}, [sp, #16]
97 ; CHECK-DAG: str {{q[0-9]+}}, [sp]
98 ; CHECK-DAG: add [[STACK_TOP:x[0-9]+]], sp, #96
99 ; CHECK-DAG: add x[[VAR:[0-9]+]], {{x[0-9]+}}, :lo12:var
100 ; CHECK-DAG: str [[STACK_TOP]], [x[[VAR]]]
102 call void @llvm.va_start(ptr @var)
106 declare void @llvm.va_end(ptr)
108 define dso_local void @test_va_end() nounwind {
109 ; CHECK-LABEL: test_va_end:
112 call void @llvm.va_end(ptr @var)
118 declare void @llvm.va_copy(ptr %dest, ptr %src)
120 @second_list = dso_local global %va_list zeroinitializer
122 define dso_local void @test_va_copy() {
123 ; CHECK-LABEL: test_va_copy:
124 call void @llvm.va_copy(ptr @second_list, ptr @var)
126 ; CHECK: add x[[SRC:[0-9]+]], {{x[0-9]+}}, :lo12:var
128 ; CHECK: ldp [[BLOCKA:q[0-9]+]], [[BLOCKB:q[0-9]+]], [x[[SRC]]]
129 ; CHECK: add x[[DST:[0-9]+]], {{x[0-9]+}}, :lo12:second_list
130 ; CHECK: stp [[BLOCKA]], [[BLOCKB]], [x[[DST]]]