xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/arm64-abi.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc     -mtriple=arm64-apple-darwin -mcpu=cyclone -enable-misched=false < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -O0 -mtriple=arm64-apple-darwin                                     < %s | FileCheck --check-prefix=FAST %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; rdar://9932559
5*9880d681SAndroid Build Coastguard Workerdefine i64 @i8i16callee(i64 %a1, i64 %a2, i64 %a3, i8 signext %a4, i16 signext %a5, i64 %a6, i64 %a7, i64 %a8, i8 signext %b1, i16 signext %b2, i8 signext %b3, i8 signext %b4) nounwind readnone noinline {
6*9880d681SAndroid Build Coastguard Workerentry:
7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: i8i16callee:
8*9880d681SAndroid Build Coastguard Worker; The 8th, 9th, 10th and 11th arguments are passed at sp, sp+2, sp+4, sp+5.
9*9880d681SAndroid Build Coastguard Worker; They are i8, i16, i8 and i8.
10*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ldrsb {{w[0-9]+}}, [sp, #5]
11*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ldrsb {{w[0-9]+}}, [sp, #4]
12*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ldrsh {{w[0-9]+}}, [sp, #2]
13*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ldrsb {{w[0-9]+}}, [sp]
14*9880d681SAndroid Build Coastguard Worker; FAST-LABEL: i8i16callee:
15*9880d681SAndroid Build Coastguard Worker; FAST-DAG: ldrsb  {{w[0-9]+}}, [sp, #5]
16*9880d681SAndroid Build Coastguard Worker; FAST-DAG: ldrsb  {{w[0-9]+}}, [sp, #4]
17*9880d681SAndroid Build Coastguard Worker; FAST-DAG: ldrsh  {{w[0-9]+}}, [sp, #2]
18*9880d681SAndroid Build Coastguard Worker; FAST-DAG: ldrsb  {{w[0-9]+}}, [sp]
19*9880d681SAndroid Build Coastguard Worker  %conv = sext i8 %a4 to i64
20*9880d681SAndroid Build Coastguard Worker  %conv3 = sext i16 %a5 to i64
21*9880d681SAndroid Build Coastguard Worker  %conv8 = sext i8 %b1 to i64
22*9880d681SAndroid Build Coastguard Worker  %conv9 = sext i16 %b2 to i64
23*9880d681SAndroid Build Coastguard Worker  %conv11 = sext i8 %b3 to i64
24*9880d681SAndroid Build Coastguard Worker  %conv13 = sext i8 %b4 to i64
25*9880d681SAndroid Build Coastguard Worker  %add10 = add i64 %a2, %a1
26*9880d681SAndroid Build Coastguard Worker  %add12 = add i64 %add10, %a3
27*9880d681SAndroid Build Coastguard Worker  %add14 = add i64 %add12, %conv
28*9880d681SAndroid Build Coastguard Worker  %add = add i64 %add14, %conv3
29*9880d681SAndroid Build Coastguard Worker  %add1 = add i64 %add, %a6
30*9880d681SAndroid Build Coastguard Worker  %add2 = add i64 %add1, %a7
31*9880d681SAndroid Build Coastguard Worker  %add4 = add i64 %add2, %a8
32*9880d681SAndroid Build Coastguard Worker  %add5 = add i64 %add4, %conv8
33*9880d681SAndroid Build Coastguard Worker  %add6 = add i64 %add5, %conv9
34*9880d681SAndroid Build Coastguard Worker  %add7 = add i64 %add6, %conv11
35*9880d681SAndroid Build Coastguard Worker  %add15 = add i64 %add7, %conv13
36*9880d681SAndroid Build Coastguard Worker  %sext = shl i64 %add15, 32
37*9880d681SAndroid Build Coastguard Worker  %conv17 = ashr exact i64 %sext, 32
38*9880d681SAndroid Build Coastguard Worker  ret i64 %conv17
39*9880d681SAndroid Build Coastguard Worker}
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workerdefine i32 @i8i16caller() nounwind readnone {
42*9880d681SAndroid Build Coastguard Workerentry:
43*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: i8i16caller
44*9880d681SAndroid Build Coastguard Worker; The 8th, 9th, 10th and 11th arguments are passed at sp, sp+2, sp+4, sp+5.
45*9880d681SAndroid Build Coastguard Worker; They are i8, i16, i8 and i8.
46*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: strb {{w[0-9]+}}, [sp, #5]
47*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: strb {{w[0-9]+}}, [sp, #4]
48*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: strh {{w[0-9]+}}, [sp, #2]
49*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: strb {{w[0-9]+}}, [sp]
50*9880d681SAndroid Build Coastguard Worker; CHECK: bl
51*9880d681SAndroid Build Coastguard Worker; FAST-LABEL: i8i16caller
52*9880d681SAndroid Build Coastguard Worker; FAST: strb {{w[0-9]+}}, [sp]
53*9880d681SAndroid Build Coastguard Worker; FAST: strh {{w[0-9]+}}, [sp, #2]
54*9880d681SAndroid Build Coastguard Worker; FAST: strb {{w[0-9]+}}, [sp, #4]
55*9880d681SAndroid Build Coastguard Worker; FAST: strb {{w[0-9]+}}, [sp, #5]
56*9880d681SAndroid Build Coastguard Worker; FAST: bl
57*9880d681SAndroid Build Coastguard Worker  %call = tail call i64 @i8i16callee(i64 0, i64 1, i64 2, i8 signext 3, i16 signext 4, i64 5, i64 6, i64 7, i8 signext 97, i16 signext 98, i8 signext 99, i8 signext 100)
58*9880d681SAndroid Build Coastguard Worker  %conv = trunc i64 %call to i32
59*9880d681SAndroid Build Coastguard Worker  ret i32 %conv
60*9880d681SAndroid Build Coastguard Worker}
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Worker; rdar://12651543
63*9880d681SAndroid Build Coastguard Workerdefine double @circle_center([2 x float] %a) nounwind ssp {
64*9880d681SAndroid Build Coastguard Worker  %call = tail call double @ext([2 x float] %a) nounwind
65*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: circle_center
66*9880d681SAndroid Build Coastguard Worker; CHECK: bl
67*9880d681SAndroid Build Coastguard Worker  ret double %call
68*9880d681SAndroid Build Coastguard Worker}
69*9880d681SAndroid Build Coastguard Workerdeclare double @ext([2 x float])
70*9880d681SAndroid Build Coastguard Worker
71*9880d681SAndroid Build Coastguard Worker; rdar://12656141
72*9880d681SAndroid Build Coastguard Worker; 16-byte vector should be aligned at 16-byte when passing on stack.
73*9880d681SAndroid Build Coastguard Worker; A double argument will be passed on stack, so vecotr should be at sp+16.
74*9880d681SAndroid Build Coastguard Workerdefine double @fixed_4i(<4 x i32>* nocapture %in) nounwind {
75*9880d681SAndroid Build Coastguard Workerentry:
76*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fixed_4i
77*9880d681SAndroid Build Coastguard Worker; CHECK: str [[REG_1:q[0-9]+]], [sp, #16]
78*9880d681SAndroid Build Coastguard Worker; FAST-LABEL: fixed_4i
79*9880d681SAndroid Build Coastguard Worker; FAST: sub sp, sp
80*9880d681SAndroid Build Coastguard Worker; FAST: mov x[[ADDR:[0-9]+]], sp
81*9880d681SAndroid Build Coastguard Worker; FAST: str [[REG_1:q[0-9]+]], [x[[ADDR]], #16]
82*9880d681SAndroid Build Coastguard Worker  %0 = load <4 x i32>, <4 x i32>* %in, align 16
83*9880d681SAndroid Build Coastguard Worker  %call = tail call double @args_vec_4i(double 3.000000e+00, <4 x i32> %0, <4 x i32> %0, <4 x i32> %0, <4 x i32> %0, <4 x i32> %0, <4 x i32> %0, <4 x i32> %0, double 3.000000e+00, <4 x i32> %0, i8 signext 3)
84*9880d681SAndroid Build Coastguard Worker  ret double %call
85*9880d681SAndroid Build Coastguard Worker}
86*9880d681SAndroid Build Coastguard Workerdeclare double @args_vec_4i(double, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, double, <4 x i32>, i8 signext)
87*9880d681SAndroid Build Coastguard Worker
88*9880d681SAndroid Build Coastguard Worker; rdar://12695237
89*9880d681SAndroid Build Coastguard Worker; d8 at sp, i in register w0.
90*9880d681SAndroid Build Coastguard Worker@g_d = common global double 0.000000e+00, align 8
91*9880d681SAndroid Build Coastguard Workerdefine void @test1(float %f1, double %d1, double %d2, double %d3, double %d4,
92*9880d681SAndroid Build Coastguard Worker       double %d5, double %d6, double %d7, double %d8, i32 %i) nounwind ssp {
93*9880d681SAndroid Build Coastguard Workerentry:
94*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test1
95*9880d681SAndroid Build Coastguard Worker; CHECK: ldr [[REG_1:d[0-9]+]], [sp]
96*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf [[REG_2:s[0-9]+]], w0
97*9880d681SAndroid Build Coastguard Worker; CHECK: fadd s0, [[REG_2]], s0
98*9880d681SAndroid Build Coastguard Worker  %conv = sitofp i32 %i to float
99*9880d681SAndroid Build Coastguard Worker  %add = fadd float %conv, %f1
100*9880d681SAndroid Build Coastguard Worker  %conv1 = fpext float %add to double
101*9880d681SAndroid Build Coastguard Worker  %add2 = fadd double %conv1, %d7
102*9880d681SAndroid Build Coastguard Worker  %add3 = fadd double %add2, %d8
103*9880d681SAndroid Build Coastguard Worker  store double %add3, double* @g_d, align 8
104*9880d681SAndroid Build Coastguard Worker  ret void
105*9880d681SAndroid Build Coastguard Worker}
106*9880d681SAndroid Build Coastguard Worker
107*9880d681SAndroid Build Coastguard Worker; i9 at sp, d1 in register s0.
108*9880d681SAndroid Build Coastguard Workerdefine void @test2(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6,
109*9880d681SAndroid Build Coastguard Worker            i32 %i7, i32 %i8, i32 %i9, float %d1) nounwind ssp {
110*9880d681SAndroid Build Coastguard Workerentry:
111*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test2
112*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf [[REG_2:s[0-9]+]], w0
113*9880d681SAndroid Build Coastguard Worker; CHECK: fadd s0, [[REG_2]], s0
114*9880d681SAndroid Build Coastguard Worker; CHECK: ldr [[REG_1:s[0-9]+]], [sp]
115*9880d681SAndroid Build Coastguard Worker  %conv = sitofp i32 %i1 to float
116*9880d681SAndroid Build Coastguard Worker  %add = fadd float %conv, %d1
117*9880d681SAndroid Build Coastguard Worker  %conv1 = fpext float %add to double
118*9880d681SAndroid Build Coastguard Worker  %conv2 = sitofp i32 %i8 to double
119*9880d681SAndroid Build Coastguard Worker  %add3 = fadd double %conv2, %conv1
120*9880d681SAndroid Build Coastguard Worker  %conv4 = sitofp i32 %i9 to double
121*9880d681SAndroid Build Coastguard Worker  %add5 = fadd double %conv4, %add3
122*9880d681SAndroid Build Coastguard Worker  store double %add5, double* @g_d, align 8
123*9880d681SAndroid Build Coastguard Worker  ret void
124*9880d681SAndroid Build Coastguard Worker}
125*9880d681SAndroid Build Coastguard Worker
126*9880d681SAndroid Build Coastguard Worker; rdar://12648441
127*9880d681SAndroid Build Coastguard Worker; Check alignment on stack for v64, f64, i64, f32, i32.
128*9880d681SAndroid Build Coastguard Workerdefine double @test3(<2 x i32>* nocapture %in) nounwind {
129*9880d681SAndroid Build Coastguard Workerentry:
130*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test3
131*9880d681SAndroid Build Coastguard Worker; CHECK: str [[REG_1:d[0-9]+]], [sp, #8]
132*9880d681SAndroid Build Coastguard Worker; FAST-LABEL: test3
133*9880d681SAndroid Build Coastguard Worker; FAST: sub sp, sp, #48
134*9880d681SAndroid Build Coastguard Worker; FAST: mov x[[ADDR:[0-9]+]], sp
135*9880d681SAndroid Build Coastguard Worker; FAST: str [[REG_1:d[0-9]+]], [x[[ADDR]], #8]
136*9880d681SAndroid Build Coastguard Worker  %0 = load <2 x i32>, <2 x i32>* %in, align 8
137*9880d681SAndroid Build Coastguard Worker  %call = tail call double @args_vec_2i(double 3.000000e+00, <2 x i32> %0,
138*9880d681SAndroid Build Coastguard Worker          <2 x i32> %0, <2 x i32> %0, <2 x i32> %0, <2 x i32> %0, <2 x i32> %0,
139*9880d681SAndroid Build Coastguard Worker          <2 x i32> %0, float 3.000000e+00, <2 x i32> %0, i8 signext 3)
140*9880d681SAndroid Build Coastguard Worker  ret double %call
141*9880d681SAndroid Build Coastguard Worker}
142*9880d681SAndroid Build Coastguard Workerdeclare double @args_vec_2i(double, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>,
143*9880d681SAndroid Build Coastguard Worker               <2 x i32>, <2 x i32>, <2 x i32>, float, <2 x i32>, i8 signext)
144*9880d681SAndroid Build Coastguard Worker
145*9880d681SAndroid Build Coastguard Workerdefine double @test4(double* nocapture %in) nounwind {
146*9880d681SAndroid Build Coastguard Workerentry:
147*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test4
148*9880d681SAndroid Build Coastguard Worker; CHECK: str [[REG_1:d[0-9]+]], [sp, #8]
149*9880d681SAndroid Build Coastguard Worker; CHECK: str [[REG_2:w[0-9]+]], [sp]
150*9880d681SAndroid Build Coastguard Worker; CHECK: orr w0, wzr, #0x3
151*9880d681SAndroid Build Coastguard Worker  %0 = load double, double* %in, align 8
152*9880d681SAndroid Build Coastguard Worker  %call = tail call double @args_f64(double 3.000000e+00, double %0, double %0,
153*9880d681SAndroid Build Coastguard Worker          double %0, double %0, double %0, double %0, double %0,
154*9880d681SAndroid Build Coastguard Worker          float 3.000000e+00, double %0, i8 signext 3)
155*9880d681SAndroid Build Coastguard Worker  ret double %call
156*9880d681SAndroid Build Coastguard Worker}
157*9880d681SAndroid Build Coastguard Workerdeclare double @args_f64(double, double, double, double, double, double, double,
158*9880d681SAndroid Build Coastguard Worker               double, float, double, i8 signext)
159*9880d681SAndroid Build Coastguard Worker
160*9880d681SAndroid Build Coastguard Workerdefine i64 @test5(i64* nocapture %in) nounwind {
161*9880d681SAndroid Build Coastguard Workerentry:
162*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test5
163*9880d681SAndroid Build Coastguard Worker; CHECK: strb [[REG_3:w[0-9]+]], [sp, #16]
164*9880d681SAndroid Build Coastguard Worker; CHECK: str [[REG_1:x[0-9]+]], [sp, #8]
165*9880d681SAndroid Build Coastguard Worker; CHECK: str [[REG_2:w[0-9]+]], [sp]
166*9880d681SAndroid Build Coastguard Worker  %0 = load i64, i64* %in, align 8
167*9880d681SAndroid Build Coastguard Worker  %call = tail call i64 @args_i64(i64 3, i64 %0, i64 %0, i64 %0, i64 %0, i64 %0,
168*9880d681SAndroid Build Coastguard Worker                         i64 %0, i64 %0, i32 3, i64 %0, i8 signext 3)
169*9880d681SAndroid Build Coastguard Worker  ret i64 %call
170*9880d681SAndroid Build Coastguard Worker}
171*9880d681SAndroid Build Coastguard Workerdeclare i64 @args_i64(i64, i64, i64, i64, i64, i64, i64, i64, i32, i64,
172*9880d681SAndroid Build Coastguard Worker             i8 signext)
173*9880d681SAndroid Build Coastguard Worker
174*9880d681SAndroid Build Coastguard Workerdefine i32 @test6(float* nocapture %in) nounwind {
175*9880d681SAndroid Build Coastguard Workerentry:
176*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test6
177*9880d681SAndroid Build Coastguard Worker; CHECK: strb [[REG_2:w[0-9]+]], [sp, #8]
178*9880d681SAndroid Build Coastguard Worker; CHECK: str [[REG_1:s[0-9]+]], [sp, #4]
179*9880d681SAndroid Build Coastguard Worker; CHECK: strh [[REG_3:w[0-9]+]], [sp]
180*9880d681SAndroid Build Coastguard Worker  %0 = load float, float* %in, align 4
181*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @args_f32(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6,
182*9880d681SAndroid Build Coastguard Worker          i32 7, i32 8, float 1.0, float 2.0, float 3.0, float 4.0, float 5.0,
183*9880d681SAndroid Build Coastguard Worker          float 6.0, float 7.0, float 8.0, i16 signext 3, float %0,
184*9880d681SAndroid Build Coastguard Worker          i8 signext 3)
185*9880d681SAndroid Build Coastguard Worker  ret i32 %call
186*9880d681SAndroid Build Coastguard Worker}
187*9880d681SAndroid Build Coastguard Workerdeclare i32 @args_f32(i32, i32, i32, i32, i32, i32, i32, i32,
188*9880d681SAndroid Build Coastguard Worker                      float, float, float, float, float, float, float, float,
189*9880d681SAndroid Build Coastguard Worker                      i16 signext, float, i8 signext)
190*9880d681SAndroid Build Coastguard Worker
191*9880d681SAndroid Build Coastguard Workerdefine i32 @test7(i32* nocapture %in) nounwind {
192*9880d681SAndroid Build Coastguard Workerentry:
193*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test7
194*9880d681SAndroid Build Coastguard Worker; CHECK: strb [[REG_2:w[0-9]+]], [sp, #8]
195*9880d681SAndroid Build Coastguard Worker; CHECK: str [[REG_1:w[0-9]+]], [sp, #4]
196*9880d681SAndroid Build Coastguard Worker; CHECK: strh [[REG_3:w[0-9]+]], [sp]
197*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %in, align 4
198*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @args_i32(i32 3, i32 %0, i32 %0, i32 %0, i32 %0, i32 %0,
199*9880d681SAndroid Build Coastguard Worker                         i32 %0, i32 %0, i16 signext 3, i32 %0, i8 signext 4)
200*9880d681SAndroid Build Coastguard Worker  ret i32 %call
201*9880d681SAndroid Build Coastguard Worker}
202*9880d681SAndroid Build Coastguard Workerdeclare i32 @args_i32(i32, i32, i32, i32, i32, i32, i32, i32, i16 signext, i32,
203*9880d681SAndroid Build Coastguard Worker             i8 signext)
204*9880d681SAndroid Build Coastguard Worker
205*9880d681SAndroid Build Coastguard Workerdefine i32 @test8(i32 %argc, i8** nocapture %argv) nounwind {
206*9880d681SAndroid Build Coastguard Workerentry:
207*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test8
208*9880d681SAndroid Build Coastguard Worker; CHECK: strb {{w[0-9]+}}, [sp, #3]
209*9880d681SAndroid Build Coastguard Worker; CHECK: strb wzr, [sp, #2]
210*9880d681SAndroid Build Coastguard Worker; CHECK: strb {{w[0-9]+}}, [sp, #1]
211*9880d681SAndroid Build Coastguard Worker; CHECK: strb wzr, [sp]
212*9880d681SAndroid Build Coastguard Worker; CHECK: bl
213*9880d681SAndroid Build Coastguard Worker; FAST-LABEL: test8
214*9880d681SAndroid Build Coastguard Worker; FAST: strb {{w[0-9]+}}, [sp]
215*9880d681SAndroid Build Coastguard Worker; FAST: strb {{w[0-9]+}}, [sp, #1]
216*9880d681SAndroid Build Coastguard Worker; FAST: strb {{w[0-9]+}}, [sp, #2]
217*9880d681SAndroid Build Coastguard Worker; FAST: strb {{w[0-9]+}}, [sp, #3]
218*9880d681SAndroid Build Coastguard Worker; FAST: bl
219*9880d681SAndroid Build Coastguard Worker  tail call void @args_i1(i1 zeroext false, i1 zeroext true, i1 zeroext false,
220*9880d681SAndroid Build Coastguard Worker                  i1 zeroext true, i1 zeroext false, i1 zeroext true,
221*9880d681SAndroid Build Coastguard Worker                  i1 zeroext false, i1 zeroext true, i1 zeroext false,
222*9880d681SAndroid Build Coastguard Worker                  i1 zeroext true, i1 zeroext false, i1 zeroext true)
223*9880d681SAndroid Build Coastguard Worker  ret i32 0
224*9880d681SAndroid Build Coastguard Worker}
225*9880d681SAndroid Build Coastguard Worker
226*9880d681SAndroid Build Coastguard Workerdeclare void @args_i1(i1 zeroext, i1 zeroext, i1 zeroext, i1 zeroext,
227*9880d681SAndroid Build Coastguard Worker                      i1 zeroext, i1 zeroext, i1 zeroext, i1 zeroext,
228*9880d681SAndroid Build Coastguard Worker                      i1 zeroext, i1 zeroext, i1 zeroext, i1 zeroext)
229*9880d681SAndroid Build Coastguard Worker
230*9880d681SAndroid Build Coastguard Workerdefine i32 @i1_stack_incoming(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e, i64 %f,
231*9880d681SAndroid Build Coastguard Worker                               i64 %g, i64 %h, i64 %i, i1 zeroext %j) {
232*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: i1_stack_incoming:
233*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb w0, [sp, #8]
234*9880d681SAndroid Build Coastguard Worker; CHECK: ret
235*9880d681SAndroid Build Coastguard Worker  %v = zext i1 %j to i32
236*9880d681SAndroid Build Coastguard Worker  ret i32 %v
237*9880d681SAndroid Build Coastguard Worker}
238