1 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -stop-after=finalize-isel < %s | FileCheck %s
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -stop-after=prologepilog < %s | FileCheck %s --check-prefix=CHECKCSR
4 ; CHECK-LABEL: name: nosve_signature
5 define i32 @nosve_signature() nounwind {
9 ; CHECK-LABEL: name: sve_signature_ret_vec
10 define <vscale x 4 x i32> @sve_signature_ret_vec() nounwind {
11 ret <vscale x 4 x i32> undef
14 ; CHECK-LABEL: name: sve_signature_ret_pred
15 define <vscale x 4 x i1> @sve_signature_ret_pred() nounwind {
16 ret <vscale x 4 x i1> undef
19 ; CHECK-LABEL: name: sve_signature_arg_vec
20 define void @sve_signature_arg_vec(<vscale x 4 x i32> %arg) nounwind {
24 ; CHECK-LABEL: name: sve_signature_arg_pred
25 define void @sve_signature_arg_pred(<vscale x 4 x i1> %arg) nounwind {
29 ; CHECK-LABEL: name: caller_nosve_signature
30 ; CHECK: BL @nosve_signature, csr_aarch64_aapcs
31 define i32 @caller_nosve_signature() nounwind {
32 %res = call i32 @nosve_signature()
36 ; CHECK-LABEL: name: caller_nosve_signature_fastcc
37 ; CHECK: BL @nosve_signature, csr_aarch64_aapcs
38 define i32 @caller_nosve_signature_fastcc() nounwind {
39 %res = call fastcc i32 @nosve_signature()
43 ; CHECK-LABEL: name: sve_signature_ret_vec_caller
44 ; CHECK: BL @sve_signature_ret_vec, csr_aarch64_sve_aapcs
45 define <vscale x 4 x i32> @sve_signature_ret_vec_caller() nounwind {
46 %res = call <vscale x 4 x i32> @sve_signature_ret_vec()
47 ret <vscale x 4 x i32> %res
50 ; CHECK-LABEL: name: sve_signature_ret_vec_caller_fastcc
51 ; CHECK: BL @sve_signature_ret_vec, csr_aarch64_sve_aapcs
52 define <vscale x 4 x i32> @sve_signature_ret_vec_caller_fastcc() nounwind {
53 %res = call fastcc <vscale x 4 x i32> @sve_signature_ret_vec()
54 ret <vscale x 4 x i32> %res
57 ; CHECK-LABEL: name: sve_signature_ret_pred_caller
58 ; CHECK: BL @sve_signature_ret_pred, csr_aarch64_sve_aapcs
59 define <vscale x 4 x i1> @sve_signature_ret_pred_caller() nounwind {
60 %res = call <vscale x 4 x i1> @sve_signature_ret_pred()
61 ret <vscale x 4 x i1> %res
64 ; CHECK-LABEL: name: sve_signature_ret_pred_caller_fastcc
65 ; CHECK: BL @sve_signature_ret_pred, csr_aarch64_sve_aapcs
66 define <vscale x 4 x i1> @sve_signature_ret_pred_caller_fastcc() nounwind {
67 %res = call fastcc <vscale x 4 x i1> @sve_signature_ret_pred()
68 ret <vscale x 4 x i1> %res
71 ; CHECK-LABEL: name: sve_signature_arg_vec_caller
72 ; CHECK: BL @sve_signature_arg_vec, csr_aarch64_sve_aapcs
73 define void @sve_signature_arg_vec_caller(<vscale x 4 x i32> %arg) nounwind {
74 call void @sve_signature_arg_vec(<vscale x 4 x i32> %arg)
78 ; CHECK-LABEL: name: sve_signature_arg_vec_caller_fastcc
79 ; CHECK: BL @sve_signature_arg_vec, csr_aarch64_sve_aapcs
80 define void @sve_signature_arg_vec_caller_fastcc(<vscale x 4 x i32> %arg) nounwind {
81 call fastcc void @sve_signature_arg_vec(<vscale x 4 x i32> %arg)
85 ; CHECK-LABEL: name: sve_signature_arg_pred_caller
86 ; CHECK: BL @sve_signature_arg_pred, csr_aarch64_sve_aapcs
87 define void @sve_signature_arg_pred_caller(<vscale x 4 x i1> %arg) nounwind {
88 call void @sve_signature_arg_pred(<vscale x 4 x i1> %arg)
92 ; CHECK-LABEL: name: sve_signature_arg_pred_caller_fastcc
93 ; CHECK: BL @sve_signature_arg_pred, csr_aarch64_sve_aapcs
94 define void @sve_signature_arg_pred_caller_fastcc(<vscale x 4 x i1> %arg) nounwind {
95 call fastcc void @sve_signature_arg_pred(<vscale x 4 x i1> %arg)
99 ; CHECK-LABEL: name: sve_signature_many_arg_vec
100 ; CHECK: [[RES:%[0-9]+]]:zpr = COPY $z7
101 ; CHECK: $z0 = COPY [[RES]]
102 ; CHECK: RET_ReallyLR implicit $z0
103 define <vscale x 4 x i32> @sve_signature_many_arg_vec(<vscale x 4 x i32> %arg1, <vscale x 4 x i32> %arg2, <vscale x 4 x i32> %arg3, <vscale x 4 x i32> %arg4, <vscale x 4 x i32> %arg5, <vscale x 4 x i32> %arg6, <vscale x 4 x i32> %arg7, <vscale x 4 x i32> %arg8) nounwind {
104 ret <vscale x 4 x i32> %arg8
107 ; CHECK-LABEL: name: sve_signature_many_arg_pred
108 ; CHECK: [[RES:%[0-9]+]]:ppr = COPY $p3
109 ; CHECK: $p0 = COPY [[RES]]
110 ; CHECK: RET_ReallyLR implicit $p0
111 define <vscale x 4 x i1> @sve_signature_many_arg_pred(<vscale x 4 x i1> %arg1, <vscale x 4 x i1> %arg2, <vscale x 4 x i1> %arg3, <vscale x 4 x i1> %arg4) nounwind {
112 ret <vscale x 4 x i1> %arg4
115 ; CHECK-LABEL: name: sve_signature_vec
116 ; CHECK: [[RES:%[0-9]+]]:zpr = COPY $z1
117 ; CHECK: $z0 = COPY [[RES]]
118 ; CHECK: RET_ReallyLR implicit $z0
119 define <vscale x 4 x i32> @sve_signature_vec(<vscale x 4 x i32> %arg1, <vscale x 4 x i32> %arg2) nounwind {
120 ret <vscale x 4 x i32> %arg2
123 ; CHECK-LABEL: name: sve_signature_pred
124 ; CHECK: [[RES:%[0-9]+]]:ppr = COPY $p1
125 ; CHECK: $p0 = COPY [[RES]]
126 ; CHECK: RET_ReallyLR implicit $p0
127 define <vscale x 4 x i1> @sve_signature_pred(<vscale x 4 x i1> %arg1, <vscale x 4 x i1> %arg2) nounwind {
128 ret <vscale x 4 x i1> %arg2
131 ; CHECK-LABEL: name: sve_signature_vec_caller
132 ; CHECK-DAG: [[ARG2:%[0-9]+]]:zpr = COPY $z1
133 ; CHECK-DAG: [[ARG1:%[0-9]+]]:zpr = COPY $z0
134 ; CHECK-DAG: $z0 = COPY [[ARG2]]
135 ; CHECK-DAG: $z1 = COPY [[ARG1]]
136 ; CHECK-NEXT: BL @sve_signature_vec, csr_aarch64_sve_aapcs
137 ; CHECK: [[RES:%[0-9]+]]:zpr = COPY $z0
138 ; CHECK: $z0 = COPY [[RES]]
139 ; CHECK: RET_ReallyLR implicit $z0
140 define <vscale x 4 x i32> @sve_signature_vec_caller(<vscale x 4 x i32> %arg1, <vscale x 4 x i32> %arg2) nounwind {
141 %res = call <vscale x 4 x i32> @sve_signature_vec(<vscale x 4 x i32> %arg2, <vscale x 4 x i32> %arg1)
142 ret <vscale x 4 x i32> %res
145 ; CHECK-LABEL: name: sve_signature_pred_caller
146 ; CHECK-DAG: [[ARG2:%[0-9]+]]:ppr = COPY $p1
147 ; CHECK-DAG: [[ARG1:%[0-9]+]]:ppr = COPY $p0
148 ; CHECK-DAG: $p0 = COPY [[ARG2]]
149 ; CHECK-DAG: $p1 = COPY [[ARG1]]
150 ; CHECK-NEXT: BL @sve_signature_pred, csr_aarch64_sve_aapcs
151 ; CHECK: [[RES:%[0-9]+]]:ppr = COPY $p0
152 ; CHECK: $p0 = COPY [[RES]]
153 ; CHECK: RET_ReallyLR implicit $p0
154 define <vscale x 4 x i1> @sve_signature_pred_caller(<vscale x 4 x i1> %arg1, <vscale x 4 x i1> %arg2) nounwind {
155 %res = call <vscale x 4 x i1> @sve_signature_pred(<vscale x 4 x i1> %arg2, <vscale x 4 x i1> %arg1)
156 ret <vscale x 4 x i1> %res
159 ; Test that functions returning or taking SVE arguments use the correct
160 ; callee-saved set when using the default C calling convention (as opposed
161 ; to aarch64_sve_vector_pcs)
163 ; CHECKCSR-LABEL: name: sve_signature_vec_ret_callee
164 ; CHECKCSR: callee-saved-register: '$z8'
165 ; CHECKCSR: callee-saved-register: '$p4'
166 ; CHECKCSR: RET_ReallyLR
167 define <vscale x 4 x i32> @sve_signature_vec_ret_callee() nounwind {
168 call void asm sideeffect "nop", "~{z8},~{p4}"()
169 ret <vscale x 4 x i32> zeroinitializer
172 ; CHECKCSR-LABEL: name: sve_signature_vec_arg_callee
173 ; CHECKCSR: callee-saved-register: '$z8'
174 ; CHECKCSR: callee-saved-register: '$p4'
175 ; CHECKCSR: RET_ReallyLR
176 define void @sve_signature_vec_arg_callee(<vscale x 4 x i32> %v) nounwind {
177 call void asm sideeffect "nop", "~{z8},~{p4}"()