1 ; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s \
2 ; RUN: | FileCheck %s -check-prefix=ILP32-LP64
3 ; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s \
4 ; RUN: | FileCheck %s -check-prefix=ILP32-LP64
5 ; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi ilp32f -verify-machineinstrs < %s \
6 ; RUN: | FileCheck %s -check-prefix=ILP32F-LP64F
7 ; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi lp64f -verify-machineinstrs < %s \
8 ; RUN: | FileCheck %s -check-prefix=ILP32F-LP64F
9 ; RUN: llc -mtriple=riscv32 -mattr=+d -target-abi ilp32d -verify-machineinstrs < %s \
10 ; RUN: | FileCheck %s -check-prefix=ILP32D-LP64D
11 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi lp64d -verify-machineinstrs < %s \
12 ; RUN: | FileCheck %s -check-prefix=ILP32D-LP64D
14 @var = global [32 x float] zeroinitializer
16 ; All floating point registers are temporaries for the ilp32 and lp64 ABIs.
17 ; fs0-fs11 are callee-saved for the ilp32f, ilp32d, lp64f, and lp64d ABIs.
19 ; This function tests that RISCVRegisterInfo::getCalleeSavedRegs returns
20 ; something appropriate.
22 define void @callee() nounwind {
23 ; ILP32-LP64-LABEL: callee:
24 ; ILP32-LP64: # %bb.0:
25 ; ILP32-LP64-NEXT: lui a0, %hi(var)
26 ; ILP32-LP64-NEXT: flw ft0, %lo(var)(a0)
27 ; ILP32-LP64-NEXT: addi a1, a0, %lo(var)
28 ; ILP32-LP64-NEXT: flw ft1, 4(a1)
29 ; ILP32-LP64-NEXT: flw ft2, 8(a1)
30 ; ILP32-LP64-NEXT: flw ft3, 12(a1)
31 ; ILP32-LP64-NEXT: flw ft4, 16(a1)
32 ; ILP32-LP64-NEXT: flw ft5, 20(a1)
33 ; ILP32-LP64-NEXT: flw ft6, 24(a1)
34 ; ILP32-LP64-NEXT: flw ft7, 28(a1)
35 ; ILP32-LP64-NEXT: flw fa0, 32(a1)
36 ; ILP32-LP64-NEXT: flw fa1, 36(a1)
37 ; ILP32-LP64-NEXT: flw fa2, 40(a1)
38 ; ILP32-LP64-NEXT: flw fa3, 44(a1)
39 ; ILP32-LP64-NEXT: flw fa4, 48(a1)
40 ; ILP32-LP64-NEXT: flw fa5, 52(a1)
41 ; ILP32-LP64-NEXT: flw fa6, 56(a1)
42 ; ILP32-LP64-NEXT: flw fa7, 60(a1)
43 ; ILP32-LP64-NEXT: flw ft8, 64(a1)
44 ; ILP32-LP64-NEXT: flw ft9, 68(a1)
45 ; ILP32-LP64-NEXT: flw ft10, 72(a1)
46 ; ILP32-LP64-NEXT: flw ft11, 76(a1)
47 ; ILP32-LP64-NEXT: flw fs0, 80(a1)
48 ; ILP32-LP64-NEXT: flw fs1, 84(a1)
49 ; ILP32-LP64-NEXT: flw fs2, 88(a1)
50 ; ILP32-LP64-NEXT: flw fs3, 92(a1)
51 ; ILP32-LP64-NEXT: flw fs4, 96(a1)
52 ; ILP32-LP64-NEXT: flw fs5, 100(a1)
53 ; ILP32-LP64-NEXT: flw fs6, 104(a1)
54 ; ILP32-LP64-NEXT: flw fs7, 108(a1)
55 ; ILP32-LP64-NEXT: flw fs8, 124(a1)
56 ; ILP32-LP64-NEXT: flw fs9, 120(a1)
57 ; ILP32-LP64-NEXT: flw fs10, 116(a1)
58 ; ILP32-LP64-NEXT: flw fs11, 112(a1)
59 ; ILP32-LP64-NEXT: fsw fs8, 124(a1)
60 ; ILP32-LP64-NEXT: fsw fs9, 120(a1)
61 ; ILP32-LP64-NEXT: fsw fs10, 116(a1)
62 ; ILP32-LP64-NEXT: fsw fs11, 112(a1)
63 ; ILP32-LP64-NEXT: fsw fs7, 108(a1)
64 ; ILP32-LP64-NEXT: fsw fs6, 104(a1)
65 ; ILP32-LP64-NEXT: fsw fs5, 100(a1)
66 ; ILP32-LP64-NEXT: fsw fs4, 96(a1)
67 ; ILP32-LP64-NEXT: fsw fs3, 92(a1)
68 ; ILP32-LP64-NEXT: fsw fs2, 88(a1)
69 ; ILP32-LP64-NEXT: fsw fs1, 84(a1)
70 ; ILP32-LP64-NEXT: fsw fs0, 80(a1)
71 ; ILP32-LP64-NEXT: fsw ft11, 76(a1)
72 ; ILP32-LP64-NEXT: fsw ft10, 72(a1)
73 ; ILP32-LP64-NEXT: fsw ft9, 68(a1)
74 ; ILP32-LP64-NEXT: fsw ft8, 64(a1)
75 ; ILP32-LP64-NEXT: fsw fa7, 60(a1)
76 ; ILP32-LP64-NEXT: fsw fa6, 56(a1)
77 ; ILP32-LP64-NEXT: fsw fa5, 52(a1)
78 ; ILP32-LP64-NEXT: fsw fa4, 48(a1)
79 ; ILP32-LP64-NEXT: fsw fa3, 44(a1)
80 ; ILP32-LP64-NEXT: fsw fa2, 40(a1)
81 ; ILP32-LP64-NEXT: fsw fa1, 36(a1)
82 ; ILP32-LP64-NEXT: fsw fa0, 32(a1)
83 ; ILP32-LP64-NEXT: fsw ft7, 28(a1)
84 ; ILP32-LP64-NEXT: fsw ft6, 24(a1)
85 ; ILP32-LP64-NEXT: fsw ft5, 20(a1)
86 ; ILP32-LP64-NEXT: fsw ft4, 16(a1)
87 ; ILP32-LP64-NEXT: fsw ft3, 12(a1)
88 ; ILP32-LP64-NEXT: fsw ft2, 8(a1)
89 ; ILP32-LP64-NEXT: fsw ft1, 4(a1)
90 ; ILP32-LP64-NEXT: fsw ft0, %lo(var)(a0)
91 ; ILP32-LP64-NEXT: ret
93 ; ILP32F-LP64F-LABEL: callee:
94 ; ILP32F-LP64F: # %bb.0:
95 ; ILP32F-LP64F-NEXT: addi sp, sp, -48
96 ; ILP32F-LP64F-NEXT: fsw fs0, 44(sp)
97 ; ILP32F-LP64F-NEXT: fsw fs1, 40(sp)
98 ; ILP32F-LP64F-NEXT: fsw fs2, 36(sp)
99 ; ILP32F-LP64F-NEXT: fsw fs3, 32(sp)
100 ; ILP32F-LP64F-NEXT: fsw fs4, 28(sp)
101 ; ILP32F-LP64F-NEXT: fsw fs5, 24(sp)
102 ; ILP32F-LP64F-NEXT: fsw fs6, 20(sp)
103 ; ILP32F-LP64F-NEXT: fsw fs7, 16(sp)
104 ; ILP32F-LP64F-NEXT: fsw fs8, 12(sp)
105 ; ILP32F-LP64F-NEXT: fsw fs9, 8(sp)
106 ; ILP32F-LP64F-NEXT: fsw fs10, 4(sp)
107 ; ILP32F-LP64F-NEXT: fsw fs11, 0(sp)
108 ; ILP32F-LP64F-NEXT: lui a0, %hi(var)
109 ; ILP32F-LP64F-NEXT: flw ft0, %lo(var)(a0)
110 ; ILP32F-LP64F-NEXT: addi a1, a0, %lo(var)
112 ; ILP32D-LP64D-LABEL: callee:
113 ; ILP32D-LP64D: # %bb.0:
114 ; ILP32D-LP64D-NEXT: addi sp, sp, -96
115 ; ILP32D-LP64D-NEXT: fsd fs0, 88(sp)
116 ; ILP32D-LP64D-NEXT: fsd fs1, 80(sp)
117 ; ILP32D-LP64D-NEXT: fsd fs2, 72(sp)
118 ; ILP32D-LP64D-NEXT: fsd fs3, 64(sp)
119 ; ILP32D-LP64D-NEXT: fsd fs4, 56(sp)
120 ; ILP32D-LP64D-NEXT: fsd fs5, 48(sp)
121 ; ILP32D-LP64D-NEXT: fsd fs6, 40(sp)
122 ; ILP32D-LP64D-NEXT: fsd fs7, 32(sp)
123 ; ILP32D-LP64D-NEXT: fsd fs8, 24(sp)
124 ; ILP32D-LP64D-NEXT: fsd fs9, 16(sp)
125 ; ILP32D-LP64D-NEXT: fsd fs10, 8(sp)
126 ; ILP32D-LP64D-NEXT: fsd fs11, 0(sp)
127 ; ILP32D-LP64D-NEXT: lui a0, %hi(var)
128 ; ILP32D-LP64D-NEXT: flw ft0, %lo(var)(a0)
129 ; ILP32D-LP64D-NEXT: addi a1, a0, %lo(var)
130 %val = load [32 x float], [32 x float]* @var
131 store volatile [32 x float] %val, [32 x float]* @var
135 ; This function tests that RISCVRegisterInfo::getCallPreservedMask returns
136 ; something appropriate.
138 ; For the soft float ABIs, no floating point registers are preserved, and
139 ; codegen will use only ft0 in the body of caller. For the 'f' and 'd ABIs,
140 ; fs0-fs11 are preserved across calls.
142 define void @caller() nounwind {
143 ; ILP32-LP64-LABEL: caller:
144 ; ILP32-LP64-NOT: ft{{[1-9][0-9]*}}
145 ; ILP32-LP64-NOT: fs{{[0-9]+}}
146 ; ILP32-LP64-NOT: fa{{[0-9]+}}
147 ; ILP32-LP64: call callee
148 ; ILP32-LP64-NOT: ft{{[1-9][0-9]*}}
149 ; ILP32-LP64-NOT: fs{{[0-9]+}}
150 ; ILP32-LP64-NOT: fa{{[0-9]+}}
153 ; ILP32F-LP64F-LABEL: caller:
154 ; ILP32F-LP64F: flw fs8, 80(s1)
155 ; ILP32F-LP64F-NEXT: flw fs9, 84(s1)
156 ; ILP32F-LP64F-NEXT: flw fs10, 88(s1)
157 ; ILP32F-LP64F-NEXT: flw fs11, 92(s1)
158 ; ILP32F-LP64F-NEXT: flw fs0, 96(s1)
159 ; ILP32F-LP64F-NEXT: flw fs1, 100(s1)
160 ; ILP32F-LP64F-NEXT: flw fs2, 104(s1)
161 ; ILP32F-LP64F-NEXT: flw fs3, 108(s1)
162 ; ILP32F-LP64F-NEXT: flw fs4, 112(s1)
163 ; ILP32F-LP64F-NEXT: flw fs5, 116(s1)
164 ; ILP32F-LP64F-NEXT: flw fs6, 120(s1)
165 ; ILP32F-LP64F-NEXT: flw fs7, 124(s1)
166 ; ILP32F-LP64F-NEXT: call callee
167 ; ILP32F-LP64F-NEXT: fsw fs7, 124(s1)
168 ; ILP32F-LP64F-NEXT: fsw fs6, 120(s1)
169 ; ILP32F-LP64F-NEXT: fsw fs5, 116(s1)
170 ; ILP32F-LP64F-NEXT: fsw fs4, 112(s1)
171 ; ILP32F-LP64F-NEXT: fsw fs3, 108(s1)
172 ; ILP32F-LP64F-NEXT: fsw fs2, 104(s1)
173 ; ILP32F-LP64F-NEXT: fsw fs1, 100(s1)
174 ; ILP32F-LP64F-NEXT: fsw fs0, 96(s1)
175 ; ILP32F-LP64F-NEXT: fsw fs11, 92(s1)
176 ; ILP32F-LP64F-NEXT: fsw fs10, 88(s1)
177 ; ILP32F-LP64F-NEXT: fsw fs9, 84(s1)
178 ; ILP32F-LP64F-NEXT: fsw fs8, 80(s1)
179 ; ILP32F-LP64F-NEXT: lw ft0, {{[0-9]+}}(sp)
181 ; ILP32D-LP64D-LABEL: caller:
182 ; ILP32D-LP64D: flw fs8, 80(s1)
183 ; ILP32D-LP64D-NEXT: flw fs9, 84(s1)
184 ; ILP32D-LP64D-NEXT: flw fs10, 88(s1)
185 ; ILP32D-LP64D-NEXT: flw fs11, 92(s1)
186 ; ILP32D-LP64D-NEXT: flw fs0, 96(s1)
187 ; ILP32D-LP64D-NEXT: flw fs1, 100(s1)
188 ; ILP32D-LP64D-NEXT: flw fs2, 104(s1)
189 ; ILP32D-LP64D-NEXT: flw fs3, 108(s1)
190 ; ILP32D-LP64D-NEXT: flw fs4, 112(s1)
191 ; ILP32D-LP64D-NEXT: flw fs5, 116(s1)
192 ; ILP32D-LP64D-NEXT: flw fs6, 120(s1)
193 ; ILP32D-LP64D-NEXT: flw fs7, 124(s1)
194 ; ILP32D-LP64D-NEXT: call callee
195 ; ILP32D-LP64D-NEXT: fsw fs7, 124(s1)
196 ; ILP32D-LP64D-NEXT: fsw fs6, 120(s1)
197 ; ILP32D-LP64D-NEXT: fsw fs5, 116(s1)
198 ; ILP32D-LP64D-NEXT: fsw fs4, 112(s1)
199 ; ILP32D-LP64D-NEXT: fsw fs3, 108(s1)
200 ; ILP32D-LP64D-NEXT: fsw fs2, 104(s1)
201 ; ILP32D-LP64D-NEXT: fsw fs1, 100(s1)
202 ; ILP32D-LP64D-NEXT: fsw fs0, 96(s1)
203 ; ILP32D-LP64D-NEXT: fsw fs11, 92(s1)
204 ; ILP32D-LP64D-NEXT: fsw fs10, 88(s1)
205 ; ILP32D-LP64D-NEXT: fsw fs9, 84(s1)
206 ; ILP32D-LP64D-NEXT: fsw fs8, 80(s1)
207 ; ILP32D-LP64D-NEXT: flw ft0, {{[0-9]+}}(sp)
208 %val = load [32 x float], [32 x float]* @var
210 store volatile [32 x float] %val, [32 x float]* @var