1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi ilp32e -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV32IF-ILP32E
5 ; Exercises the ILP32E calling convention code in the case that f32 is a legal
6 ; type. As well as testing that lowering is correct, these tests also aim to
7 ; check that floating point load/store or integer load/store is chosen
8 ; optimally when floats are passed on the stack.
10 define float @onstack_f32_noop(i64 %a, i64 %b, i64 %c, i64 %d, float %e, float %f) nounwind {
11 ; RV32IF-ILP32E-LABEL: onstack_f32_noop:
12 ; RV32IF-ILP32E: # %bb.0:
13 ; RV32IF-ILP32E-NEXT: lw a0, 12(sp)
14 ; RV32IF-ILP32E-NEXT: ret
18 define float @onstack_f32_fadd(i64 %a, i64 %b, i64 %c, i64 %d, float %e, float %f) nounwind {
19 ; RV32IF-ILP32E-LABEL: onstack_f32_fadd:
20 ; RV32IF-ILP32E: # %bb.0:
21 ; RV32IF-ILP32E-NEXT: flw fa5, 12(sp)
22 ; RV32IF-ILP32E-NEXT: flw fa4, 8(sp)
23 ; RV32IF-ILP32E-NEXT: fadd.s fa5, fa4, fa5
24 ; RV32IF-ILP32E-NEXT: fmv.x.w a0, fa5
25 ; RV32IF-ILP32E-NEXT: ret
26 %1 = fadd float %e, %f
30 define float @caller_onstack_f32_noop(float %a) nounwind {
31 ; RV32IF-ILP32E-LABEL: caller_onstack_f32_noop:
32 ; RV32IF-ILP32E: # %bb.0:
33 ; RV32IF-ILP32E-NEXT: addi sp, sp, -20
34 ; RV32IF-ILP32E-NEXT: sw ra, 16(sp) # 4-byte Folded Spill
35 ; RV32IF-ILP32E-NEXT: sw a0, 12(sp)
36 ; RV32IF-ILP32E-NEXT: lui a0, 264704
37 ; RV32IF-ILP32E-NEXT: sw a0, 8(sp)
38 ; RV32IF-ILP32E-NEXT: sw zero, 4(sp)
39 ; RV32IF-ILP32E-NEXT: li a1, 4
40 ; RV32IF-ILP32E-NEXT: li a0, 1
41 ; RV32IF-ILP32E-NEXT: li a2, 2
42 ; RV32IF-ILP32E-NEXT: li a4, 3
43 ; RV32IF-ILP32E-NEXT: sw a1, 0(sp)
44 ; RV32IF-ILP32E-NEXT: li a1, 0
45 ; RV32IF-ILP32E-NEXT: li a3, 0
46 ; RV32IF-ILP32E-NEXT: li a5, 0
47 ; RV32IF-ILP32E-NEXT: call onstack_f32_noop
48 ; RV32IF-ILP32E-NEXT: lw ra, 16(sp) # 4-byte Folded Reload
49 ; RV32IF-ILP32E-NEXT: addi sp, sp, 20
50 ; RV32IF-ILP32E-NEXT: ret
51 %1 = call float @onstack_f32_noop(i64 1, i64 2, i64 3, i64 4, float 5.0, float %a)
55 define float @caller_onstack_f32_fadd(float %a, float %b) nounwind {
56 ; RV32IF-ILP32E-LABEL: caller_onstack_f32_fadd:
57 ; RV32IF-ILP32E: # %bb.0:
58 ; RV32IF-ILP32E-NEXT: addi sp, sp, -20
59 ; RV32IF-ILP32E-NEXT: sw ra, 16(sp) # 4-byte Folded Spill
60 ; RV32IF-ILP32E-NEXT: fmv.w.x fa5, a1
61 ; RV32IF-ILP32E-NEXT: fmv.w.x fa4, a0
62 ; RV32IF-ILP32E-NEXT: fadd.s fa3, fa4, fa5
63 ; RV32IF-ILP32E-NEXT: fsub.s fa5, fa5, fa4
64 ; RV32IF-ILP32E-NEXT: sw zero, 4(sp)
65 ; RV32IF-ILP32E-NEXT: li a0, 4
66 ; RV32IF-ILP32E-NEXT: sw a0, 0(sp)
67 ; RV32IF-ILP32E-NEXT: fsw fa5, 12(sp)
68 ; RV32IF-ILP32E-NEXT: li a0, 1
69 ; RV32IF-ILP32E-NEXT: li a2, 2
70 ; RV32IF-ILP32E-NEXT: li a4, 3
71 ; RV32IF-ILP32E-NEXT: fsw fa3, 8(sp)
72 ; RV32IF-ILP32E-NEXT: li a1, 0
73 ; RV32IF-ILP32E-NEXT: li a3, 0
74 ; RV32IF-ILP32E-NEXT: li a5, 0
75 ; RV32IF-ILP32E-NEXT: call onstack_f32_noop
76 ; RV32IF-ILP32E-NEXT: lw ra, 16(sp) # 4-byte Folded Reload
77 ; RV32IF-ILP32E-NEXT: addi sp, sp, 20
78 ; RV32IF-ILP32E-NEXT: ret
79 %1 = fadd float %a, %b
80 %2 = fsub float %b, %a
81 %3 = call float @onstack_f32_noop(i64 1, i64 2, i64 3, i64 4, float %1, float %2)