1 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -stop-after=finalize-isel < %s | FileCheck %s
3 ; Test that z8 and z9, passed in by reference, are correctly loaded from x0 and x1.
9 define aarch64_sve_vector_pcs <vscale x 4 x i32> @callee_with_many_sve_arg(<vscale x 4 x i32> %z0, <vscale x 4 x i32> %z1, <vscale x 4 x i32> %z2, <vscale x 4 x i32> %z3, <vscale x 4 x i32> %z4, <vscale x 4 x i32> %z5, <vscale x 4 x i32> %z6, <vscale x 4 x i32> %z7, <vscale x 4 x i32> %z8, <vscale x 4 x i32> %z9) {
10 ; CHECK: name: callee_with_many_sve_arg
11 ; CHECK-DAG: [[BASE:%[0-9]+]]:gpr64common = COPY $x1
12 ; CHECK-DAG: [[PTRUE:%[0-9]+]]:ppr_3b = PTRUE_S 31
13 ; CHECK-DAG: [[RES:%[0-9]+]]:zpr = LD1W_IMM killed [[PTRUE]], [[BASE]]
14 ; CHECK-DAG: $z0 = COPY [[RES]]
15 ; CHECK: RET_ReallyLR implicit $z0
16 ret <vscale x 4 x i32> %z9
19 ; Test that z8 and z9 are passed by reference.
20 define aarch64_sve_vector_pcs <vscale x 4 x i32> @caller_with_many_sve_arg(<vscale x 4 x i32> %z) {
21 ; CHECK: name: caller_with_many_sve_arg
23 ; CHECK: - { id: 0, name: '', type: default, offset: 0, size: 16, alignment: 16,
24 ; CHECK-NEXT: stack-id: scalable-vector
25 ; CHECK: - { id: 1, name: '', type: default, offset: 0, size: 16, alignment: 16,
26 ; CHECK-NEXT: stack-id: scalable-vector
27 ; CHECK-DAG: [[PTRUE:%[0-9]+]]:ppr_3b = PTRUE_S 31
28 ; CHECK-DAG: ST1W_IMM %{{[0-9]+}}, [[PTRUE]], %stack.1, 0
29 ; CHECK-DAG: ST1W_IMM %{{[0-9]+}}, [[PTRUE]], %stack.0, 0
30 ; CHECK-DAG: [[BASE2:%[0-9]+]]:gpr64sp = ADDXri %stack.1, 0
31 ; CHECK-DAG: [[BASE1:%[0-9]+]]:gpr64sp = ADDXri %stack.0, 0
32 ; CHECK-DAG: $x0 = COPY [[BASE1]]
33 ; CHECK-DAG: $x1 = COPY [[BASE2]]
34 ; CHECK-NEXT: BL @callee_with_many_sve_arg
35 ; CHECK: RET_ReallyLR implicit $z0
36 %ret = call aarch64_sve_vector_pcs <vscale x 4 x i32> @callee_with_many_sve_arg(<vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z)
37 ret <vscale x 4 x i32> %ret
40 ; Test that p4 and p5, passed in by reference, are correctly loaded from register x0 and x1.
46 define aarch64_sve_vector_pcs <vscale x 16 x i1> @callee_with_many_svepred_arg(<vscale x 16 x i1> %p0, <vscale x 16 x i1> %p1, <vscale x 16 x i1> %p2, <vscale x 16 x i1> %p3, <vscale x 16 x i1> %p4, <vscale x 16 x i1> %p5) {
47 ; CHECK: name: callee_with_many_svepred_arg
48 ; CHECK-DAG: [[BASE:%[0-9]+]]:gpr64common = COPY $x1
49 ; CHECK-DAG: [[RES:%[0-9]+]]:ppr = LDR_PXI [[BASE]], 0
50 ; CHECK-DAG: $p0 = COPY [[RES]]
51 ; CHECK: RET_ReallyLR implicit $p0
52 ret <vscale x 16 x i1> %p5
55 ; Test that p4 and p5 are passed by reference.
56 define aarch64_sve_vector_pcs <vscale x 16 x i1> @caller_with_many_svepred_arg(<vscale x 16 x i1> %p) {
57 ; CHECK: name: caller_with_many_svepred_arg
59 ; CHECK: - { id: 0, name: '', type: default, offset: 0, size: 2, alignment: 2,
60 ; CHECK-NEXT: stack-id: scalable-vector
61 ; CHECK: - { id: 1, name: '', type: default, offset: 0, size: 2, alignment: 2,
62 ; CHECK-NEXT: stack-id: scalable-vector
63 ; CHECK-DAG: STR_PXI %{{[0-9]+}}, %stack.0, 0
64 ; CHECK-DAG: STR_PXI %{{[0-9]+}}, %stack.1, 0
65 ; CHECK-DAG: [[BASE1:%[0-9]+]]:gpr64sp = ADDXri %stack.0, 0
66 ; CHECK-DAG: [[BASE2:%[0-9]+]]:gpr64sp = ADDXri %stack.1, 0
67 ; CHECK-DAG: $x0 = COPY [[BASE1]]
68 ; CHECK-DAG: $x1 = COPY [[BASE2]]
69 ; CHECK-NEXT: BL @callee_with_many_svepred_arg
70 ; CHECK: RET_ReallyLR implicit $p0
71 %ret = call aarch64_sve_vector_pcs <vscale x 16 x i1> @callee_with_many_svepred_arg(<vscale x 16 x i1> %p, <vscale x 16 x i1> %p, <vscale x 16 x i1> %p, <vscale x 16 x i1> %p, <vscale x 16 x i1> %p, <vscale x 16 x i1> %p)
72 ret <vscale x 16 x i1> %ret
75 ; Test that z8 and z9, passed by reference, are loaded from a location that is passed on the stack.
85 define aarch64_sve_vector_pcs <vscale x 4 x i32> @callee_with_many_gpr_sve_arg(i64 %x0, i64 %x1, i64 %x2, i64 %x3, i64 %x4, i64 %x5, i64 %x6, i64 %x7, <vscale x 4 x i32> %z0, <vscale x 4 x i32> %z1, <vscale x 4 x i32> %z2, <vscale x 4 x i32> %z3, <vscale x 4 x i32> %z4, <vscale x 4 x i32> %z5, <vscale x 4 x i32> %z6, <vscale x 4 x i32> %z7, <vscale x 2 x i64> %z8, <vscale x 4 x i32> %z9) {
86 ; CHECK: name: callee_with_many_gpr_sve_arg
88 ; CHECK: - { id: 0, type: default, offset: 8, size: 8, alignment: 8, stack-id: default,
89 ; CHECK-DAG: [[BASE:%[0-9]+]]:gpr64common = LDRXui %fixed-stack.0, 0
90 ; CHECK-DAG: [[PTRUE:%[0-9]+]]:ppr_3b = PTRUE_S 31
91 ; CHECK-DAG: [[RES:%[0-9]+]]:zpr = LD1W_IMM killed [[PTRUE]], killed [[BASE]]
92 ; CHECK-DAG: $z0 = COPY [[RES]]
93 ; CHECK: RET_ReallyLR implicit $z0
94 ret <vscale x 4 x i32> %z9
97 ; Test that z8 and z9 are passed by reference, where reference is passed on the stack.
98 define aarch64_sve_vector_pcs <vscale x 4 x i32> @caller_with_many_gpr_sve_arg(i64 %x, <vscale x 4 x i32> %z, <vscale x 2 x i64> %z2) {
99 ; CHECK: name: caller_with_many_gpr_sve_arg
101 ; CHECK: - { id: 0, name: '', type: default, offset: 0, size: 16, alignment: 16,
102 ; CHECK-NEXT: stack-id: scalable-vector
103 ; CHECK: - { id: 1, name: '', type: default, offset: 0, size: 16, alignment: 16,
104 ; CHECK-NEXT: stack-id: scalable-vector
105 ; CHECK-DAG: [[PTRUE_S:%[0-9]+]]:ppr_3b = PTRUE_S 31
106 ; CHECK-DAG: [[PTRUE_D:%[0-9]+]]:ppr_3b = PTRUE_D 31
107 ; CHECK-DAG: ST1D_IMM %{{[0-9]+}}, killed [[PTRUE_D]], %stack.0, 0
108 ; CHECK-DAG: ST1W_IMM %{{[0-9]+}}, killed [[PTRUE_S]], %stack.1, 0
109 ; CHECK-DAG: [[BASE1:%[0-9]+]]:gpr64common = ADDXri %stack.0, 0
110 ; CHECK-DAG: [[BASE2:%[0-9]+]]:gpr64common = ADDXri %stack.1, 0
111 ; CHECK-DAG: [[SP:%[0-9]+]]:gpr64sp = COPY $sp
112 ; CHECK-DAG: STRXui killed [[BASE1]], [[SP]], 0
113 ; CHECK-DAG: STRXui killed [[BASE2]], [[SP]], 1
114 ; CHECK: BL @callee_with_many_gpr_sve_arg
115 ; CHECK: RET_ReallyLR implicit $z0
116 %ret = call aarch64_sve_vector_pcs <vscale x 4 x i32> @callee_with_many_gpr_sve_arg(i64 %x, i64 %x, i64 %x, i64 %x, i64 %x, i64 %x, i64 %x, i64 %x, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 4 x i32> %z, <vscale x 2 x i64> %z2, <vscale x 4 x i32> %z)
117 ret <vscale x 4 x i32> %ret