blob: aaa918ffc343ed9b2a1870e7ba39da5a97f02cc8 [file] [log] [blame]
Wesley Pecka70f28c2010-02-23 19:15:24 +00001; Test some of the calling convention lowering done by the MBlaze backend.
2; We test that integer values are passed in the correct registers and
3; returned in the correct registers. Additionally, we test that the stack
4; is used as appropriate for passing arguments that cannot be placed into
5; registers.
6;
7; RUN: llc < %s -march=mblaze | FileCheck %s
8
9declare i32 @printf(i8*, ...)
10@MSG = internal constant [13 x i8] c"Message: %d\0A\00"
11
12define void @params0_noret() {
13 ; CHECK: params0_noret:
14 ret void
Wesley Peck60e71272010-10-21 03:34:22 +000015 ; CHECK-NOT: {{.* r3, r0, 1}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000016 ; CHECK-NOT: {{.* r4, .*, .*}}
17 ; CHECK: rtsd
18}
19
20define i8 @params0_8bitret() {
21 ; CHECK: params0_8bitret:
22 ret i8 1
Wesley Peck60e71272010-10-21 03:34:22 +000023 ; CHECK: {{.* r3, r0, 1}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000024 ; CHECK-NOT: {{.* r4, .*, .*}}
25 ; CHECK: rtsd
26}
27
28define i16 @params0_16bitret() {
29 ; CHECK: params0_16bitret:
30 ret i16 1
31 ; CHECK: {{.* r3, r0, 1}}
32 ; CHECK-NOT: {{.* r4, .*, .*}}
Wesley Peck60e71272010-10-21 03:34:22 +000033 ; CHECK: rtsd
Wesley Pecka70f28c2010-02-23 19:15:24 +000034}
35
36define i32 @params0_32bitret() {
37 ; CHECK: params0_32bitret:
38 ret i32 1
Wesley Peck60e71272010-10-21 03:34:22 +000039 ; CHECK: {{.* r3, r0, 1}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000040 ; CHECK-NOT: {{.* r4, .*, .*}}
41 ; CHECK: rtsd
42}
43
44define i64 @params0_64bitret() {
45 ; CHECK: params0_64bitret:
46 ret i64 1
47 ; CHECK: {{.* r3, r0, .*}}
Wesley Peck13a94902010-10-21 03:09:55 +000048 ; CHECK: {{.* r4, r0, 1}}
Wesley Peck60e71272010-10-21 03:34:22 +000049 ; CHECK: rtsd
Wesley Pecka70f28c2010-02-23 19:15:24 +000050}
51
52define i32 @params1_32bitret(i32 %a) {
53 ; CHECK: params1_32bitret:
54 ret i32 %a
Wesley Peck60e71272010-10-21 03:34:22 +000055 ; CHECK: {{.* r3, r5, r0}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000056 ; CHECK-NOT: {{.* r4, .*, .*}}
57 ; CHECK: rtsd
58}
59
60define i32 @params2_32bitret(i32 %a, i32 %b) {
61 ; CHECK: params2_32bitret:
62 ret i32 %b
Wesley Peck60e71272010-10-21 03:34:22 +000063 ; CHECK: {{.* r3, r6, r0}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000064 ; CHECK-NOT: {{.* r4, .*, .*}}
65 ; CHECK: rtsd
66}
67
68define i32 @params3_32bitret(i32 %a, i32 %b, i32 %c) {
69 ; CHECK: params3_32bitret:
70 ret i32 %c
Wesley Peck60e71272010-10-21 03:34:22 +000071 ; CHECK: {{.* r3, r7, r0}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000072 ; CHECK-NOT: {{.* r4, .*, .*}}
73 ; CHECK: rtsd
74}
75
76define i32 @params4_32bitret(i32 %a, i32 %b, i32 %c, i32 %d) {
77 ; CHECK: params4_32bitret:
78 ret i32 %d
Wesley Peck60e71272010-10-21 03:34:22 +000079 ; CHECK: {{.* r3, r8, r0}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000080 ; CHECK-NOT: {{.* r4, .*, .*}}
81 ; CHECK: rtsd
82}
83
84define i32 @params5_32bitret(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
85 ; CHECK: params5_32bitret:
86 ret i32 %e
Wesley Peck60e71272010-10-21 03:34:22 +000087 ; CHECK: {{.* r3, r9, r0}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000088 ; CHECK-NOT: {{.* r4, .*, .*}}
89 ; CHECK: rtsd
90}
91
92define i32 @params6_32bitret(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f) {
93 ; CHECK: params6_32bitret:
94 ret i32 %f
Wesley Peck60e71272010-10-21 03:34:22 +000095 ; CHECK: {{.* r3, r10, r0}}
Wesley Pecka70f28c2010-02-23 19:15:24 +000096 ; CHECK-NOT: {{.* r4, .*, .*}}
97 ; CHECK: rtsd
98}
99
100define i32 @params7_32bitret(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
101 i32 %g) {
102 ; CHECK: params7_32bitret:
103 ret i32 %g
Wesley Peckc2bf2bb2010-03-06 23:23:12 +0000104 ; CHECK: {{lwi? r3, r1, 32}}
Wesley Pecka70f28c2010-02-23 19:15:24 +0000105 ; CHECK-NOT: {{.* r4, .*, .*}}
106 ; CHECK: rtsd
107}
108
109define i32 @params8_32bitret(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
110 i32 %g, i32 %h) {
111 ; CHECK: params8_32bitret:
112 ret i32 %h
Wesley Peckc2bf2bb2010-03-06 23:23:12 +0000113 ; CHECK: {{lwi? r3, r1, 36}}
Wesley Pecka70f28c2010-02-23 19:15:24 +0000114 ; CHECK-NOT: {{.* r4, .*, .*}}
115 ; CHECK: rtsd
116}
117
118define i32 @params9_32bitret(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
119 i32 %g, i32 %h, i32 %i) {
120 ; CHECK: params9_32bitret:
121 ret i32 %i
Wesley Peckc2bf2bb2010-03-06 23:23:12 +0000122 ; CHECK: {{lwi? r3, r1, 40}}
Wesley Pecka70f28c2010-02-23 19:15:24 +0000123 ; CHECK-NOT: {{.* r4, .*, .*}}
124 ; CHECK: rtsd
125}
126
127define i32 @params10_32bitret(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
128 i32 %g, i32 %h, i32 %i, i32 %j) {
129 ; CHECK: params10_32bitret:
130 ret i32 %j
Wesley Peckc2bf2bb2010-03-06 23:23:12 +0000131 ; CHECK: {{lwi? r3, r1, 44}}
Wesley Pecka70f28c2010-02-23 19:15:24 +0000132 ; CHECK-NOT: {{.* r4, .*, .*}}
133 ; CHECK: rtsd
134}
135
136define void @testing() {
137 %MSG.1 = getelementptr [13 x i8]* @MSG, i32 0, i32 0
138
139 call void @params0_noret()
140 ; CHECK: brlid
141
142 %tmp.1 = call i8 @params0_8bitret()
143 ; CHECK: brlid
144 call i32 (i8*,...)* @printf(i8* %MSG.1, i8 %tmp.1)
Wesley Peck60e71272010-10-21 03:34:22 +0000145 ; CHECK: {{.* r5, .*, .*}}
146 ; CHECK: {{.* r6, r3, r0}}
147 ; CHECK-NOT: {{.* r7, .*, .*}}
148 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000149
150 %tmp.2 = call i16 @params0_16bitret()
151 ; CHECK: brlid
152 call i32 (i8*,...)* @printf(i8* %MSG.1, i16 %tmp.2)
Wesley Peck60e71272010-10-21 03:34:22 +0000153 ; CHECK: {{.* r5, .*, .*}}
154 ; CHECK: {{.* r6, r3, r0}}
155 ; CHECK-NOT: {{.* r7, .*, .*}}
156 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000157
158 %tmp.3 = call i32 @params0_32bitret()
159 ; CHECK: brlid
160 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.3)
Wesley Peck60e71272010-10-21 03:34:22 +0000161 ; CHECK: {{.* r5, .*, .*}}
162 ; CHECK: {{.* r6, r3, r0}}
163 ; CHECK-NOT: {{.* r7, .*, .*}}
164 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000165
166 %tmp.4 = call i64 @params0_64bitret()
167 ; CHECK: brlid
168 call i32 (i8*,...)* @printf(i8* %MSG.1, i64 %tmp.4)
Wesley Peck60e71272010-10-21 03:34:22 +0000169 ; CHECK: {{.* r5, .*, .*}}
170 ; CHECK: {{.* r6, r3, r0}}
171 ; CHECK: {{.* r7, r4, r0}}
172 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000173
174 %tmp.5 = call i32 @params1_32bitret(i32 1)
175 ; CHECK: {{.* r5, .*, .*}}
176 ; CHECK: brlid
177 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.5)
Wesley Peck60e71272010-10-21 03:34:22 +0000178 ; CHECK: {{.* r5, .*, .*}}
179 ; CHECK: {{.* r6, r3, r0}}
180 ; CHECK-NOT: {{.* r7, .*, .*}}
181 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000182
183 %tmp.6 = call i32 @params2_32bitret(i32 1, i32 2)
184 ; CHECK: {{.* r5, .*, .*}}
185 ; CHECK: {{.* r6, .*, .*}}
186 ; CHECK: brlid
187 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.6)
Wesley Peck60e71272010-10-21 03:34:22 +0000188 ; CHECK: {{.* r5, .*, .*}}
189 ; CHECK: {{.* r6, r3, r0}}
190 ; CHECK-NOT: {{.* r7, .*, .*}}
191 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000192
193 %tmp.7 = call i32 @params3_32bitret(i32 1, i32 2, i32 3)
194 ; CHECK: {{.* r5, .*, .*}}
195 ; CHECK: {{.* r6, .*, .*}}
196 ; CHECK: {{.* r7, .*, .*}}
197 ; CHECK: brlid
198 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.7)
Wesley Peck60e71272010-10-21 03:34:22 +0000199 ; CHECK: {{.* r5, .*, .*}}
200 ; CHECK: {{.* r6, r3, r0}}
201 ; CHECK-NOT: {{.* r7, .*, .*}}
202 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000203
204 %tmp.8 = call i32 @params4_32bitret(i32 1, i32 2, i32 3, i32 4)
205 ; CHECK: {{.* r5, .*, .*}}
206 ; CHECK: {{.* r6, .*, .*}}
207 ; CHECK: {{.* r7, .*, .*}}
208 ; CHECK: {{.* r8, .*, .*}}
209 ; CHECK: brlid
210 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.8)
Wesley Peck60e71272010-10-21 03:34:22 +0000211 ; CHECK: {{.* r5, .*, .*}}
212 ; CHECK: {{.* r6, r3, r0}}
213 ; CHECK-NOT: {{.* r7, .*, .*}}
214 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000215
216 %tmp.9 = call i32 @params5_32bitret(i32 1, i32 2, i32 3, i32 4, i32 5)
217 ; CHECK: {{.* r5, .*, .*}}
218 ; CHECK: {{.* r6, .*, .*}}
219 ; CHECK: {{.* r7, .*, .*}}
220 ; CHECK: {{.* r8, .*, .*}}
221 ; CHECK: {{.* r9, .*, .*}}
222 ; CHECK: brlid
223 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.9)
Wesley Peck60e71272010-10-21 03:34:22 +0000224 ; CHECK: {{.* r5, .*, .*}}
225 ; CHECK: {{.* r6, r3, r0}}
226 ; CHECK-NOT: {{.* r7, .*, .*}}
227 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000228
229 %tmp.10 = call i32 @params6_32bitret(i32 1, i32 2, i32 3, i32 4, i32 5,
230 i32 6)
231 ; CHECK: {{.* r5, .*, .*}}
232 ; CHECK: {{.* r6, .*, .*}}
233 ; CHECK: {{.* r7, .*, .*}}
234 ; CHECK: {{.* r8, .*, .*}}
235 ; CHECK: {{.* r9, .*, .*}}
236 ; CHECK: {{.* r10, .*, .*}}
237 ; CHECK: brlid
238 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.10)
Wesley Peck60e71272010-10-21 03:34:22 +0000239 ; CHECK: {{.* r5, .*, .*}}
240 ; CHECK: {{.* r6, r3, r0}}
241 ; CHECK-NOT: {{.* r7, .*, .*}}
242 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000243
244 %tmp.11 = call i32 @params7_32bitret(i32 1, i32 2, i32 3, i32 4, i32 5,
245 i32 6, i32 7)
Wesley Peckc2bf2bb2010-03-06 23:23:12 +0000246 ; CHECK: {{swi? .*, r1, 28}}
Wesley Pecka70f28c2010-02-23 19:15:24 +0000247 ; CHECK: {{.* r5, .*, .*}}
248 ; CHECK: {{.* r6, .*, .*}}
249 ; CHECK: {{.* r7, .*, .*}}
250 ; CHECK: {{.* r8, .*, .*}}
251 ; CHECK: {{.* r9, .*, .*}}
252 ; CHECK: {{.* r10, .*, .*}}
253 ; CHECK: brlid
254 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.11)
Wesley Peck60e71272010-10-21 03:34:22 +0000255 ; CHECK: {{.* r5, .*, .*}}
256 ; CHECK: {{.* r6, r3, r0}}
257 ; CHECK-NOT: {{.* r7, .*, .*}}
258 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000259
260 %tmp.12 = call i32 @params8_32bitret(i32 1, i32 2, i32 3, i32 4, i32 5,
261 i32 6, i32 7, i32 8)
Wesley Peckc2bf2bb2010-03-06 23:23:12 +0000262 ; CHECK: {{swi? .*, r1, 28}}
263 ; CHECK: {{swi? .*, r1, 32}}
Wesley Pecka70f28c2010-02-23 19:15:24 +0000264 ; CHECK: {{.* r5, .*, .*}}
265 ; CHECK: {{.* r6, .*, .*}}
266 ; CHECK: {{.* r7, .*, .*}}
267 ; CHECK: {{.* r8, .*, .*}}
268 ; CHECK: {{.* r9, .*, .*}}
269 ; CHECK: {{.* r10, .*, .*}}
270 ; CHECK: brlid
271 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.12)
Wesley Peck60e71272010-10-21 03:34:22 +0000272 ; CHECK: {{.* r5, .*, .*}}
273 ; CHECK: {{.* r6, r3, r0}}
274 ; CHECK-NOT: {{.* r7, .*, .*}}
275 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000276
277 %tmp.13 = call i32 @params9_32bitret(i32 1, i32 2, i32 3, i32 4, i32 5,
278 i32 6, i32 7, i32 8, i32 9)
Wesley Peckc2bf2bb2010-03-06 23:23:12 +0000279 ; CHECK: {{swi? .*, r1, 28}}
280 ; CHECK: {{swi? .*, r1, 32}}
281 ; CHECK: {{swi? .*, r1, 36}}
Wesley Pecka70f28c2010-02-23 19:15:24 +0000282 ; CHECK: {{.* r5, .*, .*}}
283 ; CHECK: {{.* r6, .*, .*}}
284 ; CHECK: {{.* r7, .*, .*}}
285 ; CHECK: {{.* r8, .*, .*}}
286 ; CHECK: {{.* r9, .*, .*}}
287 ; CHECK: {{.* r10, .*, .*}}
288 ; CHECK: brlid
289 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.13)
Wesley Peck60e71272010-10-21 03:34:22 +0000290 ; CHECK: {{.* r5, .*, .*}}
291 ; CHECK: {{.* r6, r3, r0}}
292 ; CHECK-NOT: {{.* r7, .*, .*}}
293 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000294
295 %tmp.14 = call i32 @params10_32bitret(i32 1, i32 2, i32 3, i32 4, i32 5,
296 i32 6, i32 7, i32 8, i32 9, i32 10)
Wesley Peckc2bf2bb2010-03-06 23:23:12 +0000297 ; CHECK: {{swi? .*, r1, 28}}
298 ; CHECK: {{swi? .*, r1, 32}}
299 ; CHECK: {{swi? .*, r1, 36}}
300 ; CHECK: {{swi? .*, r1, 40}}
Wesley Pecka70f28c2010-02-23 19:15:24 +0000301 ; CHECK: {{.* r5, .*, .*}}
302 ; CHECK: {{.* r6, .*, .*}}
303 ; CHECK: {{.* r7, .*, .*}}
304 ; CHECK: {{.* r8, .*, .*}}
305 ; CHECK: {{.* r9, .*, .*}}
306 ; CHECK: {{.* r10, .*, .*}}
307 ; CHECK: brlid
308 call i32 (i8*,...)* @printf(i8* %MSG.1, i32 %tmp.14)
Wesley Peck60e71272010-10-21 03:34:22 +0000309 ; CHECK: {{.* r5, .*, .*}}
310 ; CHECK: {{.* r6, r3, r0}}
311 ; CHECK-NOT: {{.* r7, .*, .*}}
312 ; CHECK: brlid
Wesley Pecka70f28c2010-02-23 19:15:24 +0000313
314 ret void
315}