1 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
2 ; RUN: | FileCheck %s -check-prefix=RV32I
3 ; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi ilp32f -verify-machineinstrs < %s \
4 ; RUN: | FileCheck %s -check-prefix=RV32I
5 ; RUN: llc -mtriple=riscv32 -mattr=+d -target-abi ilp32f -verify-machineinstrs < %s \
6 ; RUN: | FileCheck %s -check-prefix=RV32I
7 ; RUN: llc -mtriple=riscv32 -mattr=+d -target-abi ilp32d -verify-machineinstrs < %s \
8 ; RUN: | FileCheck %s -check-prefix=RV32I
9 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs -frame-pointer=all < %s \
10 ; RUN: | FileCheck %s -check-prefix=RV32I-WITH-FP
11 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
12 ; RUN: | FileCheck %s -check-prefix=RV64I
13 ; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi lp64f -verify-machineinstrs < %s \
14 ; RUN: | FileCheck %s -check-prefix=RV64I
15 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi lp64f -verify-machineinstrs < %s \
16 ; RUN: | FileCheck %s -check-prefix=RV64I
17 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi lp64d -verify-machineinstrs < %s \
18 ; RUN: | FileCheck %s -check-prefix=RV64I
19 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs -frame-pointer=all < %s \
20 ; RUN: | FileCheck %s -check-prefix=RV64I-WITH-FP
22 @var = global [32 x i32] zeroinitializer
24 ; This function tests that RISCVRegisterInfo::getCalleeSavedRegs returns
25 ; something appropriate.
27 define void @callee() nounwind {
28 ; RV32I-LABEL: callee:
30 ; RV32I-NEXT: addi sp, sp, -80
31 ; RV32I-NEXT: sw s0, 76(sp)
32 ; RV32I-NEXT: sw s1, 72(sp)
33 ; RV32I-NEXT: sw s2, 68(sp)
34 ; RV32I-NEXT: sw s3, 64(sp)
35 ; RV32I-NEXT: sw s4, 60(sp)
36 ; RV32I-NEXT: sw s5, 56(sp)
37 ; RV32I-NEXT: sw s6, 52(sp)
38 ; RV32I-NEXT: sw s7, 48(sp)
39 ; RV32I-NEXT: sw s8, 44(sp)
40 ; RV32I-NEXT: sw s9, 40(sp)
41 ; RV32I-NEXT: sw s10, 36(sp)
42 ; RV32I-NEXT: sw s11, 32(sp)
43 ; RV32I-NEXT: lui a0, %hi(var)
44 ; RV32I-NEXT: lw a1, %lo(var)(a0)
45 ; RV32I-NEXT: sw a1, 28(sp)
46 ; RV32I-NEXT: addi a2, a0, %lo(var)
48 ; RV32I-WITH-FP-LABEL: callee:
49 ; RV32I-WITH-FP: # %bb.0:
50 ; RV32I-WITH-FP-NEXT: addi sp, sp, -80
51 ; RV32I-WITH-FP-NEXT: sw ra, 76(sp)
52 ; RV32I-WITH-FP-NEXT: sw s0, 72(sp)
53 ; RV32I-WITH-FP-NEXT: sw s1, 68(sp)
54 ; RV32I-WITH-FP-NEXT: sw s2, 64(sp)
55 ; RV32I-WITH-FP-NEXT: sw s3, 60(sp)
56 ; RV32I-WITH-FP-NEXT: sw s4, 56(sp)
57 ; RV32I-WITH-FP-NEXT: sw s5, 52(sp)
58 ; RV32I-WITH-FP-NEXT: sw s6, 48(sp)
59 ; RV32I-WITH-FP-NEXT: sw s7, 44(sp)
60 ; RV32I-WITH-FP-NEXT: sw s8, 40(sp)
61 ; RV32I-WITH-FP-NEXT: sw s9, 36(sp)
62 ; RV32I-WITH-FP-NEXT: sw s10, 32(sp)
63 ; RV32I-WITH-FP-NEXT: sw s11, 28(sp)
64 ; RV32I-WITH-FP-NEXT: addi s0, sp, 80
65 ; RV32I-WITH-FP-NEXT: lui a0, %hi(var)
66 ; RV32I-WITH-FP-NEXT: lw a1, %lo(var)(a0)
67 ; RV32I-WITH-FP-NEXT: sw a1, -56(s0)
68 ; RV32I-WITH-FP-NEXT: addi a2, a0, %lo(var)
70 ; RV64I-LABEL: callee:
72 ; RV64I-NEXT: addi sp, sp, -144
73 ; RV64I-NEXT: sd s0, 136(sp)
74 ; RV64I-NEXT: sd s1, 128(sp)
75 ; RV64I-NEXT: sd s2, 120(sp)
76 ; RV64I-NEXT: sd s3, 112(sp)
77 ; RV64I-NEXT: sd s4, 104(sp)
78 ; RV64I-NEXT: sd s5, 96(sp)
79 ; RV64I-NEXT: sd s6, 88(sp)
80 ; RV64I-NEXT: sd s7, 80(sp)
81 ; RV64I-NEXT: sd s8, 72(sp)
82 ; RV64I-NEXT: sd s9, 64(sp)
83 ; RV64I-NEXT: sd s10, 56(sp)
84 ; RV64I-NEXT: sd s11, 48(sp)
85 ; RV64I-NEXT: lui a0, %hi(var)
86 ; RV64I-NEXT: lw a1, %lo(var)(a0)
87 ; RV64I-NEXT: sd a1, 40(sp)
88 ; RV64I-NEXT: addi a2, a0, %lo(var)
90 ; RV64I-WITH-FP-LABEL: callee:
91 ; RV64I-WITH-FP: # %bb.0:
92 ; RV64I-WITH-FP-NEXT: addi sp, sp, -160
93 ; RV64I-WITH-FP-NEXT: sd ra, 152(sp)
94 ; RV64I-WITH-FP-NEXT: sd s0, 144(sp)
95 ; RV64I-WITH-FP-NEXT: sd s1, 136(sp)
96 ; RV64I-WITH-FP-NEXT: sd s2, 128(sp)
97 ; RV64I-WITH-FP-NEXT: sd s3, 120(sp)
98 ; RV64I-WITH-FP-NEXT: sd s4, 112(sp)
99 ; RV64I-WITH-FP-NEXT: sd s5, 104(sp)
100 ; RV64I-WITH-FP-NEXT: sd s6, 96(sp)
101 ; RV64I-WITH-FP-NEXT: sd s7, 88(sp)
102 ; RV64I-WITH-FP-NEXT: sd s8, 80(sp)
103 ; RV64I-WITH-FP-NEXT: sd s9, 72(sp)
104 ; RV64I-WITH-FP-NEXT: sd s10, 64(sp)
105 ; RV64I-WITH-FP-NEXT: sd s11, 56(sp)
106 ; RV64I-WITH-FP-NEXT: addi s0, sp, 160
107 ; RV64I-WITH-FP-NEXT: lui a0, %hi(var)
108 ; RV64I-WITH-FP-NEXT: lw a1, %lo(var)(a0)
109 ; RV64I-WITH-FP-NEXT: sd a1, -112(s0)
110 ; RV64I-WITH-FP-NEXT: addi a2, a0, %lo(var)
111 %val = load [32 x i32], [32 x i32]* @var
112 store volatile [32 x i32] %val, [32 x i32]* @var
116 ; This function tests that RISCVRegisterInfo::getCallPreservedMask returns
117 ; something appropriate.
119 define void @caller() nounwind {
120 ; RV32I-LABEL: caller:
121 ; RV32I: lui a0, %hi(var)
122 ; RV32I-NEXT: lw a1, %lo(var)(a0)
123 ; RV32I-NEXT: sw a1, 88(sp)
124 ; RV32I-NEXT: addi s0, a0, %lo(var)
126 ; RV32I: sw a0, 8(sp)
127 ; RV32I-NEXT: lw s2, 84(s0)
128 ; RV32I-NEXT: lw s3, 88(s0)
129 ; RV32I-NEXT: lw s4, 92(s0)
130 ; RV32I-NEXT: lw s5, 96(s0)
131 ; RV32I-NEXT: lw s6, 100(s0)
132 ; RV32I-NEXT: lw s7, 104(s0)
133 ; RV32I-NEXT: lw s8, 108(s0)
134 ; RV32I-NEXT: lw s9, 112(s0)
135 ; RV32I-NEXT: lw s10, 116(s0)
136 ; RV32I-NEXT: lw s11, 120(s0)
137 ; RV32I-NEXT: lw s1, 124(s0)
138 ; RV32I-NEXT: call callee
139 ; RV32I-NEXT: sw s1, 124(s0)
140 ; RV32I-NEXT: sw s11, 120(s0)
141 ; RV32I-NEXT: sw s10, 116(s0)
142 ; RV32I-NEXT: sw s9, 112(s0)
143 ; RV32I-NEXT: sw s8, 108(s0)
144 ; RV32I-NEXT: sw s7, 104(s0)
145 ; RV32I-NEXT: sw s6, 100(s0)
146 ; RV32I-NEXT: sw s5, 96(s0)
147 ; RV32I-NEXT: sw s4, 92(s0)
148 ; RV32I-NEXT: sw s3, 88(s0)
149 ; RV32I-NEXT: sw s2, 84(s0)
150 ; RV32I-NEXT: lw a0, 8(sp)
152 ; RV32I-WITH-FP-LABEL: caller:
153 ; RV32I-WITH-FP: addi s0, sp, 144
154 ; RV32I-WITH-FP-NEXT: lui a0, %hi(var)
155 ; RV32I-WITH-FP-NEXT: lw a1, %lo(var)(a0)
156 ; RV32I-WITH-FP-NEXT: sw a1, -56(s0)
157 ; RV32I-WITH-FP-NEXT: addi s1, a0, %lo(var)
158 ; RV32I-WITH-FP: sw a0, -140(s0)
159 ; RV32I-WITH-FP-NEXT: lw s5, 88(s1)
160 ; RV32I-WITH-FP-NEXT: lw s6, 92(s1)
161 ; RV32I-WITH-FP-NEXT: lw s7, 96(s1)
162 ; RV32I-WITH-FP-NEXT: lw s8, 100(s1)
163 ; RV32I-WITH-FP-NEXT: lw s9, 104(s1)
164 ; RV32I-WITH-FP-NEXT: lw s10, 108(s1)
165 ; RV32I-WITH-FP-NEXT: lw s11, 112(s1)
166 ; RV32I-WITH-FP-NEXT: lw s2, 116(s1)
167 ; RV32I-WITH-FP-NEXT: lw s3, 120(s1)
168 ; RV32I-WITH-FP-NEXT: lw s4, 124(s1)
169 ; RV32I-WITH-FP-NEXT: call callee
170 ; RV32I-WITH-FP-NEXT: sw s4, 124(s1)
171 ; RV32I-WITH-FP-NEXT: sw s3, 120(s1)
172 ; RV32I-WITH-FP-NEXT: sw s2, 116(s1)
173 ; RV32I-WITH-FP-NEXT: sw s11, 112(s1)
174 ; RV32I-WITH-FP-NEXT: sw s10, 108(s1)
175 ; RV32I-WITH-FP-NEXT: sw s9, 104(s1)
176 ; RV32I-WITH-FP-NEXT: sw s8, 100(s1)
177 ; RV32I-WITH-FP-NEXT: sw s7, 96(s1)
178 ; RV32I-WITH-FP-NEXT: sw s6, 92(s1)
179 ; RV32I-WITH-FP-NEXT: sw s5, 88(s1)
180 ; RV32I-WITH-FP-NEXT: lw a0, -140(s0)
182 ; RV64I-LABEL: caller:
183 ; RV64I: lui a0, %hi(var)
184 ; RV64I-NEXT: lw a1, %lo(var)(a0)
185 ; RV64I-NEXT: sd a1, 160(sp)
186 ; RV64I-NEXT: addi s0, a0, %lo(var)
187 ; RV64I: sd a0, 0(sp)
188 ; RV64I-NEXT: lw s2, 84(s0)
189 ; RV64I-NEXT: lw s3, 88(s0)
190 ; RV64I-NEXT: lw s4, 92(s0)
191 ; RV64I-NEXT: lw s5, 96(s0)
192 ; RV64I-NEXT: lw s6, 100(s0)
193 ; RV64I-NEXT: lw s7, 104(s0)
194 ; RV64I-NEXT: lw s8, 108(s0)
195 ; RV64I-NEXT: lw s9, 112(s0)
196 ; RV64I-NEXT: lw s10, 116(s0)
197 ; RV64I-NEXT: lw s11, 120(s0)
198 ; RV64I-NEXT: lw s1, 124(s0)
199 ; RV64I-NEXT: call callee
200 ; RV64I-NEXT: sw s1, 124(s0)
201 ; RV64I-NEXT: sw s11, 120(s0)
202 ; RV64I-NEXT: sw s10, 116(s0)
203 ; RV64I-NEXT: sw s9, 112(s0)
204 ; RV64I-NEXT: sw s8, 108(s0)
205 ; RV64I-NEXT: sw s7, 104(s0)
206 ; RV64I-NEXT: sw s6, 100(s0)
207 ; RV64I-NEXT: sw s5, 96(s0)
208 ; RV64I-NEXT: sw s4, 92(s0)
209 ; RV64I-NEXT: sw s3, 88(s0)
210 ; RV64I-NEXT: sw s2, 84(s0)
211 ; RV64I-NEXT: ld a0, 0(sp)
213 ; RV64I-WITH-FP-LABEL: caller:
214 ; RV64I-WITH-FP: addi s0, sp, 288
215 ; RV64I-WITH-FP-NEXT: lui a0, %hi(var)
216 ; RV64I-WITH-FP-NEXT: lw a1, %lo(var)(a0)
217 ; RV64I-WITH-FP-NEXT: sd a1, -112(s0)
218 ; RV64I-WITH-FP-NEXT: addi s1, a0, %lo(var)
219 ; RV64I-WITH-FP: sd a0, -280(s0)
220 ; RV64I-WITH-FP-NEXT: lw s5, 88(s1)
221 ; RV64I-WITH-FP-NEXT: lw s6, 92(s1)
222 ; RV64I-WITH-FP-NEXT: lw s7, 96(s1)
223 ; RV64I-WITH-FP-NEXT: lw s8, 100(s1)
224 ; RV64I-WITH-FP-NEXT: lw s9, 104(s1)
225 ; RV64I-WITH-FP-NEXT: lw s10, 108(s1)
226 ; RV64I-WITH-FP-NEXT: lw s11, 112(s1)
227 ; RV64I-WITH-FP-NEXT: lw s2, 116(s1)
228 ; RV64I-WITH-FP-NEXT: lw s3, 120(s1)
229 ; RV64I-WITH-FP-NEXT: lw s4, 124(s1)
230 ; RV64I-WITH-FP-NEXT: call callee
231 ; RV64I-WITH-FP-NEXT: sw s4, 124(s1)
232 ; RV64I-WITH-FP-NEXT: sw s3, 120(s1)
233 ; RV64I-WITH-FP-NEXT: sw s2, 116(s1)
234 ; RV64I-WITH-FP-NEXT: sw s11, 112(s1)
235 ; RV64I-WITH-FP-NEXT: sw s10, 108(s1)
236 ; RV64I-WITH-FP-NEXT: sw s9, 104(s1)
237 ; RV64I-WITH-FP-NEXT: sw s8, 100(s1)
238 ; RV64I-WITH-FP-NEXT: sw s7, 96(s1)
239 ; RV64I-WITH-FP-NEXT: sw s6, 92(s1)
240 ; RV64I-WITH-FP-NEXT: sw s5, 88(s1)
241 ; RV64I-WITH-FP-NEXT: ld a0, -280(s0)
242 %val = load [32 x i32], [32 x i32]* @var
244 store volatile [32 x i32] %val, [32 x i32]* @var