Debian Codegraph @

llvm/test/CodeGen/Thumb2/bf16-pcs.ll

raw
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=armv8m.main-none-eabi < %s -frame-pointer=none -mattr=+fp-armv8d16 | FileCheck %s --check-prefix=LE
3 ; RUN: llc -mtriple=armebv8m.main-none-eabi < %s -frame-pointer=none -mattr=+fp-armv8d16 | FileCheck %s --check-prefix=BE
4 ; RUN: llc -mtriple=armv8m.main-none-eabi < %s -frame-pointer=none -mattr=+fp-armv8d16,+bf16 | FileCheck %s --check-prefix=LE-BF16
5 ; RUN: llc -mtriple=armebv8m.main-none-eabi < %s -frame-pointer=none -mattr=+fp-armv8d16,+bf16 | FileCheck %s --check-prefix=BE-BF16
6
7 ;; Global ISel successfully generates code for some functions for little-endian
8 ;; without +bf16, and falls back to SelectionDAG in all others.
9 ; RUN: llc -mtriple=armv8m.main-none-eabi < %s -frame-pointer=none -mattr=+fp-armv8d16 -global-isel=1 -global-isel-abort=2 | FileCheck %s --check-prefix=LE-GISEL
10 ; RUN: llc -mtriple=armebv8m.main-none-eabi < %s -frame-pointer=none -mattr=+fp-armv8d16 -global-isel=1 -global-isel-abort=2 | FileCheck %s --check-prefix=BE
11 ; RUN: llc -mtriple=armv8m.main-none-eabi < %s -frame-pointer=none -mattr=+fp-armv8d16,+bf16 -global-isel=1 -global-isel-abort=2 | FileCheck %s --check-prefix=LE-BF16
12 ; RUN: llc -mtriple=armebv8m.main-none-eabi < %s -frame-pointer=none -mattr=+fp-armv8d16,+bf16 -global-isel=1 -global-isel-abort=2 | FileCheck %s --check-prefix=BE-BF16
13
14 define arm_aapcscc bfloat @callee_soft_bfloat_in_reg(bfloat %f) {
15 ; LE-LABEL: callee_soft_bfloat_in_reg:
16 ; LE: @ %bb.0: @ %entry
17 ; LE-NEXT: bx lr
18 ;
19 ; BE-LABEL: callee_soft_bfloat_in_reg:
20 ; BE: @ %bb.0: @ %entry
21 ; BE-NEXT: bx lr
22 ;
23 ; LE-BF16-LABEL: callee_soft_bfloat_in_reg:
24 ; LE-BF16: @ %bb.0: @ %entry
25 ; LE-BF16-NEXT: .pad #4
26 ; LE-BF16-NEXT: sub sp, #4
27 ; LE-BF16-NEXT: strh.w r0, [sp, #2]
28 ; LE-BF16-NEXT: ldrh.w r0, [sp, #2]
29 ; LE-BF16-NEXT: add sp, #4
30 ; LE-BF16-NEXT: bx lr
31 ;
32 ; BE-BF16-LABEL: callee_soft_bfloat_in_reg:
33 ; BE-BF16: @ %bb.0: @ %entry
34 ; BE-BF16-NEXT: .pad #4
35 ; BE-BF16-NEXT: sub sp, #4
36 ; BE-BF16-NEXT: strh.w r0, [sp, #2]
37 ; BE-BF16-NEXT: ldrh.w r0, [sp, #2]
38 ; BE-BF16-NEXT: add sp, #4
39 ; BE-BF16-NEXT: bx lr
40 ;
41 ; LE-GISEL-LABEL: callee_soft_bfloat_in_reg:
42 ; LE-GISEL: @ %bb.0: @ %entry
43 ; LE-GISEL-NEXT: bx lr
44 entry:
45 ret bfloat %f
46 }
47
48 define void @caller_soft_bfloat_in_reg() {
49 ; LE-LABEL: caller_soft_bfloat_in_reg:
50 ; LE: @ %bb.0: @ %entry
51 ; LE-NEXT: .save {r7, lr}
52 ; LE-NEXT: push {r7, lr}
53 ; LE-NEXT: mov.w r0, #16256
54 ; LE-NEXT: bl callee_soft_bfloat_in_reg
55 ; LE-NEXT: pop {r7, pc}
56 ;
57 ; BE-LABEL: caller_soft_bfloat_in_reg:
58 ; BE: @ %bb.0: @ %entry
59 ; BE-NEXT: .save {r7, lr}
60 ; BE-NEXT: push {r7, lr}
61 ; BE-NEXT: mov.w r0, #16256
62 ; BE-NEXT: bl callee_soft_bfloat_in_reg
63 ; BE-NEXT: pop {r7, pc}
64 ;
65 ; LE-BF16-LABEL: caller_soft_bfloat_in_reg:
66 ; LE-BF16: @ %bb.0: @ %entry
67 ; LE-BF16-NEXT: .save {r7, lr}
68 ; LE-BF16-NEXT: push {r7, lr}
69 ; LE-BF16-NEXT: mov.w r0, #16256
70 ; LE-BF16-NEXT: bl callee_soft_bfloat_in_reg
71 ; LE-BF16-NEXT: pop {r7, pc}
72 ;
73 ; BE-BF16-LABEL: caller_soft_bfloat_in_reg:
74 ; BE-BF16: @ %bb.0: @ %entry
75 ; BE-BF16-NEXT: .save {r7, lr}
76 ; BE-BF16-NEXT: push {r7, lr}
77 ; BE-BF16-NEXT: mov.w r0, #16256
78 ; BE-BF16-NEXT: bl callee_soft_bfloat_in_reg
79 ; BE-BF16-NEXT: pop {r7, pc}
80 ;
81 ; LE-GISEL-LABEL: caller_soft_bfloat_in_reg:
82 ; LE-GISEL: @ %bb.0: @ %entry
83 ; LE-GISEL-NEXT: .save {r7, lr}
84 ; LE-GISEL-NEXT: push {r7, lr}
85 ; LE-GISEL-NEXT: mov.w r0, #16256
86 ; LE-GISEL-NEXT: bl callee_soft_bfloat_in_reg
87 ; LE-GISEL-NEXT: pop {r7, pc}
88 entry:
89 %ret = call arm_aapcscc bfloat @callee_soft_bfloat_in_reg(bfloat 1.0)
90 ret void
91 }
92
93 define arm_aapcscc bfloat @callee_soft_bfloat_on_stack(float %r0, float %r1, float %r2, float %r3, bfloat %f) {
94 ; LE-LABEL: callee_soft_bfloat_on_stack:
95 ; LE: @ %bb.0: @ %entry
96 ; LE-NEXT: ldr r0, [sp]
97 ; LE-NEXT: bx lr
98 ;
99 ; BE-LABEL: callee_soft_bfloat_on_stack:
100 ; BE: @ %bb.0: @ %entry
101 ; BE-NEXT: ldr r0, [sp]
102 ; BE-NEXT: bx lr
103 ;
104 ; LE-BF16-LABEL: callee_soft_bfloat_on_stack:
105 ; LE-BF16: @ %bb.0: @ %entry
106 ; LE-BF16-NEXT: ldrh.w r0, [sp]
107 ; LE-BF16-NEXT: bx lr
108 ;
109 ; BE-BF16-LABEL: callee_soft_bfloat_on_stack:
110 ; BE-BF16: @ %bb.0: @ %entry
111 ; BE-BF16-NEXT: ldrh.w r0, [sp, #2]
112 ; BE-BF16-NEXT: bx lr
113 ;
114 ; LE-GISEL-LABEL: callee_soft_bfloat_on_stack:
115 ; LE-GISEL: @ %bb.0: @ %entry
116 ; LE-GISEL-NEXT: mov r0, sp
117 ; LE-GISEL-NEXT: ldr r0, [r0]
118 ; LE-GISEL-NEXT: bx lr
119 entry:
120 ret bfloat %f
121 }
122
123 define void @caller_soft_bfloat_on_stack() {
124 ; LE-LABEL: caller_soft_bfloat_on_stack:
125 ; LE: @ %bb.0: @ %entry
126 ; LE-NEXT: .save {r7, lr}
127 ; LE-NEXT: push {r7, lr}
128 ; LE-NEXT: .pad #8
129 ; LE-NEXT: sub sp, #8
130 ; LE-NEXT: mov.w r0, #16256
131 ; LE-NEXT: str r0, [sp]
132 ; LE-NEXT: bl callee_soft_bfloat_on_stack
133 ; LE-NEXT: add sp, #8
134 ; LE-NEXT: pop {r7, pc}
135 ;
136 ; BE-LABEL: caller_soft_bfloat_on_stack:
137 ; BE: @ %bb.0: @ %entry
138 ; BE-NEXT: .save {r7, lr}
139 ; BE-NEXT: push {r7, lr}
140 ; BE-NEXT: .pad #8
141 ; BE-NEXT: sub sp, #8
142 ; BE-NEXT: mov.w r0, #16256
143 ; BE-NEXT: str r0, [sp]
144 ; BE-NEXT: bl callee_soft_bfloat_on_stack
145 ; BE-NEXT: add sp, #8
146 ; BE-NEXT: pop {r7, pc}
147 ;
148 ; LE-BF16-LABEL: caller_soft_bfloat_on_stack:
149 ; LE-BF16: @ %bb.0: @ %entry
150 ; LE-BF16-NEXT: .save {r7, lr}
151 ; LE-BF16-NEXT: push {r7, lr}
152 ; LE-BF16-NEXT: .pad #8
153 ; LE-BF16-NEXT: sub sp, #8
154 ; LE-BF16-NEXT: mov.w r0, #16256
155 ; LE-BF16-NEXT: str r0, [sp]
156 ; LE-BF16-NEXT: bl callee_soft_bfloat_on_stack
157 ; LE-BF16-NEXT: add sp, #8
158 ; LE-BF16-NEXT: pop {r7, pc}
159 ;
160 ; BE-BF16-LABEL: caller_soft_bfloat_on_stack:
161 ; BE-BF16: @ %bb.0: @ %entry
162 ; BE-BF16-NEXT: .save {r7, lr}
163 ; BE-BF16-NEXT: push {r7, lr}
164 ; BE-BF16-NEXT: .pad #8
165 ; BE-BF16-NEXT: sub sp, #8
166 ; BE-BF16-NEXT: mov.w r0, #16256
167 ; BE-BF16-NEXT: str r0, [sp]
168 ; BE-BF16-NEXT: bl callee_soft_bfloat_on_stack
169 ; BE-BF16-NEXT: add sp, #8
170 ; BE-BF16-NEXT: pop {r7, pc}
171 ;
172 ; LE-GISEL-LABEL: caller_soft_bfloat_on_stack:
173 ; LE-GISEL: @ %bb.0: @ %entry
174 ; LE-GISEL-NEXT: .save {r7, lr}
175 ; LE-GISEL-NEXT: push {r7, lr}
176 ; LE-GISEL-NEXT: .pad #8
177 ; LE-GISEL-NEXT: sub sp, #8
178 ; LE-GISEL-NEXT: mov.w r0, #16256
179 ; LE-GISEL-NEXT: str r0, [sp]
180 ; LE-GISEL-NEXT: bl callee_soft_bfloat_on_stack
181 ; LE-GISEL-NEXT: add sp, #8
182 ; LE-GISEL-NEXT: pop {r7, pc}
183 entry:
184 %ret = call arm_aapcscc bfloat @callee_soft_bfloat_on_stack(float poison, float poison, float poison, float poison, bfloat 1.0)
185 ret void
186 }
187
188 define arm_aapcs_vfpcc bfloat @callee_hard_bfloat_in_reg(bfloat %f) {
189 ; LE-LABEL: callee_hard_bfloat_in_reg:
190 ; LE: @ %bb.0: @ %entry
191 ; LE-NEXT: bx lr
192 ;
193 ; BE-LABEL: callee_hard_bfloat_in_reg:
194 ; BE: @ %bb.0: @ %entry
195 ; BE-NEXT: bx lr
196 ;
197 ; LE-BF16-LABEL: callee_hard_bfloat_in_reg:
198 ; LE-BF16: @ %bb.0: @ %entry
199 ; LE-BF16-NEXT: .pad #4
200 ; LE-BF16-NEXT: sub sp, #4
201 ; LE-BF16-NEXT: vmov r0, s0
202 ; LE-BF16-NEXT: strh.w r0, [sp, #2]
203 ; LE-BF16-NEXT: ldrh.w r0, [sp, #2]
204 ; LE-BF16-NEXT: vmov s0, r0
205 ; LE-BF16-NEXT: add sp, #4
206 ; LE-BF16-NEXT: bx lr
207 ;
208 ; BE-BF16-LABEL: callee_hard_bfloat_in_reg:
209 ; BE-BF16: @ %bb.0: @ %entry
210 ; BE-BF16-NEXT: .pad #4
211 ; BE-BF16-NEXT: sub sp, #4
212 ; BE-BF16-NEXT: vmov r0, s0
213 ; BE-BF16-NEXT: strh.w r0, [sp, #2]
214 ; BE-BF16-NEXT: ldrh.w r0, [sp, #2]
215 ; BE-BF16-NEXT: vmov s0, r0
216 ; BE-BF16-NEXT: add sp, #4
217 ; BE-BF16-NEXT: bx lr
218 ;
219 ; LE-GISEL-LABEL: callee_hard_bfloat_in_reg:
220 ; LE-GISEL: @ %bb.0: @ %entry
221 ; LE-GISEL-NEXT: bx lr
222 entry:
223 ret bfloat %f
224 }
225
226 define void @caller_hard_bfloat_in_reg() {
227 ; LE-LABEL: caller_hard_bfloat_in_reg:
228 ; LE: @ %bb.0: @ %entry
229 ; LE-NEXT: .save {r7, lr}
230 ; LE-NEXT: push {r7, lr}
231 ; LE-NEXT: vldr s0, .LCPI5_0
232 ; LE-NEXT: bl callee_hard_bfloat_in_reg
233 ; LE-NEXT: pop {r7, pc}
234 ; LE-NEXT: .p2align 2
235 ; LE-NEXT: @ %bb.1:
236 ; LE-NEXT: .LCPI5_0:
237 ; LE-NEXT: .long 0x00003f80 @ float 2.27795078E-41
238 ;
239 ; BE-LABEL: caller_hard_bfloat_in_reg:
240 ; BE: @ %bb.0: @ %entry
241 ; BE-NEXT: .save {r7, lr}
242 ; BE-NEXT: push {r7, lr}
243 ; BE-NEXT: vldr s0, .LCPI5_0
244 ; BE-NEXT: bl callee_hard_bfloat_in_reg
245 ; BE-NEXT: pop {r7, pc}
246 ; BE-NEXT: .p2align 2
247 ; BE-NEXT: @ %bb.1:
248 ; BE-NEXT: .LCPI5_0:
249 ; BE-NEXT: .long 0x00003f80 @ float 2.27795078E-41
250 ;
251 ; LE-BF16-LABEL: caller_hard_bfloat_in_reg:
252 ; LE-BF16: @ %bb.0: @ %entry
253 ; LE-BF16-NEXT: .save {r7, lr}
254 ; LE-BF16-NEXT: push {r7, lr}
255 ; LE-BF16-NEXT: vldr s0, .LCPI5_0
256 ; LE-BF16-NEXT: bl callee_hard_bfloat_in_reg
257 ; LE-BF16-NEXT: pop {r7, pc}
258 ; LE-BF16-NEXT: .p2align 2
259 ; LE-BF16-NEXT: @ %bb.1:
260 ; LE-BF16-NEXT: .LCPI5_0:
261 ; LE-BF16-NEXT: .long 0x00003f80 @ float 2.27795078E-41
262 ;
263 ; BE-BF16-LABEL: caller_hard_bfloat_in_reg:
264 ; BE-BF16: @ %bb.0: @ %entry
265 ; BE-BF16-NEXT: .save {r7, lr}
266 ; BE-BF16-NEXT: push {r7, lr}
267 ; BE-BF16-NEXT: vldr s0, .LCPI5_0
268 ; BE-BF16-NEXT: bl callee_hard_bfloat_in_reg
269 ; BE-BF16-NEXT: pop {r7, pc}
270 ; BE-BF16-NEXT: .p2align 2
271 ; BE-BF16-NEXT: @ %bb.1:
272 ; BE-BF16-NEXT: .LCPI5_0:
273 ; BE-BF16-NEXT: .long 0x00003f80 @ float 2.27795078E-41
274 ;
275 ; LE-GISEL-LABEL: caller_hard_bfloat_in_reg:
276 ; LE-GISEL: @ %bb.0: @ %entry
277 ; LE-GISEL-NEXT: .save {r7, lr}
278 ; LE-GISEL-NEXT: push {r7, lr}
279 ; LE-GISEL-NEXT: vldr s0, .LCPI5_0
280 ; LE-GISEL-NEXT: bl callee_hard_bfloat_in_reg
281 ; LE-GISEL-NEXT: pop {r7, pc}
282 ; LE-GISEL-NEXT: .p2align 2
283 ; LE-GISEL-NEXT: @ %bb.1:
284 ; LE-GISEL-NEXT: .LCPI5_0:
285 ; LE-GISEL-NEXT: .long 0x00003f80 @ float 2.27795078E-41
286 entry:
287 %ret = call arm_aapcs_vfpcc bfloat @callee_hard_bfloat_in_reg(bfloat 1.0)
288 ret void
289 }
290
291 define arm_aapcs_vfpcc bfloat @callee_hard_bfloat_on_stack(float %s0, float %s1, float %s2, float %s3, float %s4, float %s5, float %s6, float %s7,float %s8, float %s9, float %s10, float %s11, float %s12, float %s13, float %s14, float %s15, bfloat %f) {
292 ; LE-LABEL: callee_hard_bfloat_on_stack:
293 ; LE: @ %bb.0: @ %entry
294 ; LE-NEXT: vldr s0, [sp]
295 ; LE-NEXT: bx lr
296 ;
297 ; BE-LABEL: callee_hard_bfloat_on_stack:
298 ; BE: @ %bb.0: @ %entry
299 ; BE-NEXT: vldr s0, [sp]
300 ; BE-NEXT: bx lr
301 ;
302 ; LE-BF16-LABEL: callee_hard_bfloat_on_stack:
303 ; LE-BF16: @ %bb.0: @ %entry
304 ; LE-BF16-NEXT: ldrh.w r0, [sp]
305 ; LE-BF16-NEXT: vmov s0, r0
306 ; LE-BF16-NEXT: bx lr
307 ;
308 ; BE-BF16-LABEL: callee_hard_bfloat_on_stack:
309 ; BE-BF16: @ %bb.0: @ %entry
310 ; BE-BF16-NEXT: ldrh.w r0, [sp, #2]
311 ; BE-BF16-NEXT: vmov s0, r0
312 ; BE-BF16-NEXT: bx lr
313 ;
314 ; LE-GISEL-LABEL: callee_hard_bfloat_on_stack:
315 ; LE-GISEL: @ %bb.0: @ %entry
316 ; LE-GISEL-NEXT: mov r0, sp
317 ; LE-GISEL-NEXT: ldr r0, [r0]
318 ; LE-GISEL-NEXT: vmov s0, r0
319 ; LE-GISEL-NEXT: bx lr
320 entry:
321 ret bfloat %f
322 }
323
324
325 define void @caller_hard_bfloat_on_stack() {
326 ; LE-LABEL: caller_hard_bfloat_on_stack:
327 ; LE: @ %bb.0: @ %entry
328 ; LE-NEXT: .save {r7, lr}
329 ; LE-NEXT: push {r7, lr}
330 ; LE-NEXT: .pad #8
331 ; LE-NEXT: sub sp, #8
332 ; LE-NEXT: mov.w r0, #16256
333 ; LE-NEXT: str r0, [sp]
334 ; LE-NEXT: bl callee_hard_bfloat_on_stack
335 ; LE-NEXT: add sp, #8
336 ; LE-NEXT: pop {r7, pc}
337 ;
338 ; BE-LABEL: caller_hard_bfloat_on_stack:
339 ; BE: @ %bb.0: @ %entry
340 ; BE-NEXT: .save {r7, lr}
341 ; BE-NEXT: push {r7, lr}
342 ; BE-NEXT: .pad #8
343 ; BE-NEXT: sub sp, #8
344 ; BE-NEXT: mov.w r0, #16256
345 ; BE-NEXT: str r0, [sp]
346 ; BE-NEXT: bl callee_hard_bfloat_on_stack
347 ; BE-NEXT: add sp, #8
348 ; BE-NEXT: pop {r7, pc}
349 ;
350 ; LE-BF16-LABEL: caller_hard_bfloat_on_stack:
351 ; LE-BF16: @ %bb.0: @ %entry
352 ; LE-BF16-NEXT: .save {r7, lr}
353 ; LE-BF16-NEXT: push {r7, lr}
354 ; LE-BF16-NEXT: .pad #8
355 ; LE-BF16-NEXT: sub sp, #8
356 ; LE-BF16-NEXT: mov.w r0, #16256
357 ; LE-BF16-NEXT: str r0, [sp]
358 ; LE-BF16-NEXT: bl callee_hard_bfloat_on_stack
359 ; LE-BF16-NEXT: add sp, #8
360 ; LE-BF16-NEXT: pop {r7, pc}
361 ;
362 ; BE-BF16-LABEL: caller_hard_bfloat_on_stack:
363 ; BE-BF16: @ %bb.0: @ %entry
364 ; BE-BF16-NEXT: .save {r7, lr}
365 ; BE-BF16-NEXT: push {r7, lr}
366 ; BE-BF16-NEXT: .pad #8
367 ; BE-BF16-NEXT: sub sp, #8
368 ; BE-BF16-NEXT: mov.w r0, #16256
369 ; BE-BF16-NEXT: str r0, [sp]
370 ; BE-BF16-NEXT: bl callee_hard_bfloat_on_stack
371 ; BE-BF16-NEXT: add sp, #8
372 ; BE-BF16-NEXT: pop {r7, pc}
373 ;
374 ; LE-GISEL-LABEL: caller_hard_bfloat_on_stack:
375 ; LE-GISEL: @ %bb.0: @ %entry
376 ; LE-GISEL-NEXT: .save {r7, lr}
377 ; LE-GISEL-NEXT: push {r7, lr}
378 ; LE-GISEL-NEXT: .pad #8
379 ; LE-GISEL-NEXT: sub sp, #8
380 ; LE-GISEL-NEXT: mov.w r0, #16256
381 ; LE-GISEL-NEXT: str r0, [sp]
382 ; LE-GISEL-NEXT: bl callee_hard_bfloat_on_stack
383 ; LE-GISEL-NEXT: add sp, #8
384 ; LE-GISEL-NEXT: pop {r7, pc}
385 entry:
386 %ret = call arm_aapcs_vfpcc bfloat @callee_hard_bfloat_on_stack(float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison, bfloat 1.0)
387 ret void
388 }