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 ilp32f -verify-machineinstrs < %s \
14 ; RUN: | FileCheck %s -check-prefix=RV64I
15 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi ilp32f -verify-machineinstrs < %s \
16 ; RUN: | FileCheck %s -check-prefix=RV64I
17 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi ilp32d -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: addi a1, a0, %lo(var)
46 ; RV32I-WITH-FP-LABEL: callee:
47 ; RV32I-WITH-FP: # %bb.0:
48 ; RV32I-WITH-FP-NEXT: addi sp, sp, -80
49 ; RV32I-WITH-FP-NEXT: sw ra, 76(sp)
50 ; RV32I-WITH-FP-NEXT: sw s0, 72(sp)
51 ; RV32I-WITH-FP-NEXT: sw s1, 68(sp)
52 ; RV32I-WITH-FP-NEXT: sw s2, 64(sp)
53 ; RV32I-WITH-FP-NEXT: sw s3, 60(sp)
54 ; RV32I-WITH-FP-NEXT: sw s4, 56(sp)
55 ; RV32I-WITH-FP-NEXT: sw s5, 52(sp)
56 ; RV32I-WITH-FP-NEXT: sw s6, 48(sp)
57 ; RV32I-WITH-FP-NEXT: sw s7, 44(sp)
58 ; RV32I-WITH-FP-NEXT: sw s8, 40(sp)
59 ; RV32I-WITH-FP-NEXT: sw s9, 36(sp)
60 ; RV32I-WITH-FP-NEXT: sw s10, 32(sp)
61 ; RV32I-WITH-FP-NEXT: sw s11, 28(sp)
62 ; RV32I-WITH-FP-NEXT: addi s0, sp, 80
63 ; RV32I-WITH-FP-NEXT: lui a0, %hi(var)
64 ; RV32I-WITH-FP-NEXT: addi a1, a0, %lo(var)
66 ; RV64I-LABEL: callee:
68 ; RV64I-NEXT: addi sp, sp, -144
69 ; RV64I-NEXT: sd s0, 136(sp)
70 ; RV64I-NEXT: sd s1, 128(sp)
71 ; RV64I-NEXT: sd s2, 120(sp)
72 ; RV64I-NEXT: sd s3, 112(sp)
73 ; RV64I-NEXT: sd s4, 104(sp)
74 ; RV64I-NEXT: sd s5, 96(sp)
75 ; RV64I-NEXT: sd s6, 88(sp)
76 ; RV64I-NEXT: sd s7, 80(sp)
77 ; RV64I-NEXT: sd s8, 72(sp)
78 ; RV64I-NEXT: sd s9, 64(sp)
79 ; RV64I-NEXT: sd s10, 56(sp)
80 ; RV64I-NEXT: sd s11, 48(sp)
81 ; RV64I-NEXT: lui a0, %hi(var)
82 ; RV64I-NEXT: addi a1, a0, %lo(var)
84 ; RV64I-WITH-FP-LABEL: callee:
85 ; RV64I-WITH-FP: # %bb.0:
86 ; RV64I-WITH-FP-NEXT: addi sp, sp, -160
87 ; RV64I-WITH-FP-NEXT: sd ra, 152(sp)
88 ; RV64I-WITH-FP-NEXT: sd s0, 144(sp)
89 ; RV64I-WITH-FP-NEXT: sd s1, 136(sp)
90 ; RV64I-WITH-FP-NEXT: sd s2, 128(sp)
91 ; RV64I-WITH-FP-NEXT: sd s3, 120(sp)
92 ; RV64I-WITH-FP-NEXT: sd s4, 112(sp)
93 ; RV64I-WITH-FP-NEXT: sd s5, 104(sp)
94 ; RV64I-WITH-FP-NEXT: sd s6, 96(sp)
95 ; RV64I-WITH-FP-NEXT: sd s7, 88(sp)
96 ; RV64I-WITH-FP-NEXT: sd s8, 80(sp)
97 ; RV64I-WITH-FP-NEXT: sd s9, 72(sp)
98 ; RV64I-WITH-FP-NEXT: sd s10, 64(sp)
99 ; RV64I-WITH-FP-NEXT: sd s11, 56(sp)
100 ; RV64I-WITH-FP-NEXT: addi s0, sp, 160
101 ; RV64I-WITH-FP-NEXT: lui a0, %hi(var)
102 ; RV64I-WITH-FP-NEXT: addi a1, a0, %lo(var)
103 %val = load [32 x i32], [32 x i32]* @var
104 store volatile [32 x i32] %val, [32 x i32]* @var
108 ; This function tests that RISCVRegisterInfo::getCallPreservedMask returns
109 ; something appropriate.
111 define void @caller() nounwind {
112 ; RV32I-LABEL: caller:
113 ; RV32I: lui a0, %hi(var)
114 ; RV32I-NEXT: addi s1, a0, %lo(var)
115 ; RV32I: sw a0, 8(sp)
116 ; RV32I-NEXT: lw s2, 84(s1)
117 ; RV32I-NEXT: lw s3, 88(s1)
118 ; RV32I-NEXT: lw s4, 92(s1)
119 ; RV32I-NEXT: lw s5, 96(s1)
120 ; RV32I-NEXT: lw s6, 100(s1)
121 ; RV32I-NEXT: lw s7, 104(s1)
122 ; RV32I-NEXT: lw s8, 108(s1)
123 ; RV32I-NEXT: lw s9, 112(s1)
124 ; RV32I-NEXT: lw s10, 116(s1)
125 ; RV32I-NEXT: lw s11, 120(s1)
126 ; RV32I-NEXT: lw s0, 124(s1)
127 ; RV32I-NEXT: call callee
128 ; RV32I-NEXT: sw s0, 124(s1)
129 ; RV32I-NEXT: sw s11, 120(s1)
130 ; RV32I-NEXT: sw s10, 116(s1)
131 ; RV32I-NEXT: sw s9, 112(s1)
132 ; RV32I-NEXT: sw s8, 108(s1)
133 ; RV32I-NEXT: sw s7, 104(s1)
134 ; RV32I-NEXT: sw s6, 100(s1)
135 ; RV32I-NEXT: sw s5, 96(s1)
136 ; RV32I-NEXT: sw s4, 92(s1)
137 ; RV32I-NEXT: sw s3, 88(s1)
138 ; RV32I-NEXT: sw s2, 84(s1)
139 ; RV32I-NEXT: lw a0, 8(sp)
141 ; RV32I-WITH-FP-LABEL: caller:
142 ; RV32I-WITH-FP: addi s0, sp, 144
143 ; RV32I-WITH-FP-NEXT: lui a0, %hi(var)
144 ; RV32I-WITH-FP-NEXT: addi s1, a0, %lo(var)
145 ; RV32I-WITH-FP: sw a0, -140(s0)
146 ; RV32I-WITH-FP-NEXT: lw s5, 88(s1)
147 ; RV32I-WITH-FP-NEXT: lw s6, 92(s1)
148 ; RV32I-WITH-FP-NEXT: lw s7, 96(s1)
149 ; RV32I-WITH-FP-NEXT: lw s8, 100(s1)
150 ; RV32I-WITH-FP-NEXT: lw s9, 104(s1)
151 ; RV32I-WITH-FP-NEXT: lw s10, 108(s1)
152 ; RV32I-WITH-FP-NEXT: lw s11, 112(s1)
153 ; RV32I-WITH-FP-NEXT: lw s2, 116(s1)
154 ; RV32I-WITH-FP-NEXT: lw s3, 120(s1)
155 ; RV32I-WITH-FP-NEXT: lw s4, 124(s1)
156 ; RV32I-WITH-FP-NEXT: call callee
157 ; RV32I-WITH-FP-NEXT: sw s4, 124(s1)
158 ; RV32I-WITH-FP-NEXT: sw s3, 120(s1)
159 ; RV32I-WITH-FP-NEXT: sw s2, 116(s1)
160 ; RV32I-WITH-FP-NEXT: sw s11, 112(s1)
161 ; RV32I-WITH-FP-NEXT: sw s10, 108(s1)
162 ; RV32I-WITH-FP-NEXT: sw s9, 104(s1)
163 ; RV32I-WITH-FP-NEXT: sw s8, 100(s1)
164 ; RV32I-WITH-FP-NEXT: sw s7, 96(s1)
165 ; RV32I-WITH-FP-NEXT: sw s6, 92(s1)
166 ; RV32I-WITH-FP-NEXT: sw s5, 88(s1)
167 ; RV32I-WITH-FP-NEXT: lw a0, -140(s0)
169 ; RV64I-LABEL: caller:
170 ; RV64I: lui a0, %hi(var)
171 ; RV64I-NEXT: addi s1, a0, %lo(var)
172 ; RV64I: sd a0, 0(sp)
173 ; RV64I-NEXT: lw s2, 84(s1)
174 ; RV64I-NEXT: lw s3, 88(s1)
175 ; RV64I-NEXT: lw s4, 92(s1)
176 ; RV64I-NEXT: lw s5, 96(s1)
177 ; RV64I-NEXT: lw s6, 100(s1)
178 ; RV64I-NEXT: lw s7, 104(s1)
179 ; RV64I-NEXT: lw s8, 108(s1)
180 ; RV64I-NEXT: lw s9, 112(s1)
181 ; RV64I-NEXT: lw s10, 116(s1)
182 ; RV64I-NEXT: lw s11, 120(s1)
183 ; RV64I-NEXT: lw s0, 124(s1)
184 ; RV64I-NEXT: call callee
185 ; RV64I-NEXT: sw s0, 124(s1)
186 ; RV64I-NEXT: sw s11, 120(s1)
187 ; RV64I-NEXT: sw s10, 116(s1)
188 ; RV64I-NEXT: sw s9, 112(s1)
189 ; RV64I-NEXT: sw s8, 108(s1)
190 ; RV64I-NEXT: sw s7, 104(s1)
191 ; RV64I-NEXT: sw s6, 100(s1)
192 ; RV64I-NEXT: sw s5, 96(s1)
193 ; RV64I-NEXT: sw s4, 92(s1)
194 ; RV64I-NEXT: sw s3, 88(s1)
195 ; RV64I-NEXT: sw s2, 84(s1)
196 ; RV64I-NEXT: ld a0, 0(sp)
198 ; RV64I-WITH-FP-LABEL: caller:
199 ; RV64I-WITH-FP: addi s0, sp, 288
200 ; RV64I-WITH-FP-NEXT: lui a0, %hi(var)
201 ; RV64I-WITH-FP-NEXT: addi s1, a0, %lo(var)
202 ; RV64I-WITH-FP: sd a0, -280(s0)
203 ; RV64I-WITH-FP-NEXT: lw s5, 88(s1)
204 ; RV64I-WITH-FP-NEXT: lw s6, 92(s1)
205 ; RV64I-WITH-FP-NEXT: lw s7, 96(s1)
206 ; RV64I-WITH-FP-NEXT: lw s8, 100(s1)
207 ; RV64I-WITH-FP-NEXT: lw s9, 104(s1)
208 ; RV64I-WITH-FP-NEXT: lw s10, 108(s1)
209 ; RV64I-WITH-FP-NEXT: lw s11, 112(s1)
210 ; RV64I-WITH-FP-NEXT: lw s2, 116(s1)
211 ; RV64I-WITH-FP-NEXT: lw s3, 120(s1)
212 ; RV64I-WITH-FP-NEXT: lw s4, 124(s1)
213 ; RV64I-WITH-FP-NEXT: call callee
214 ; RV64I-WITH-FP-NEXT: sw s4, 124(s1)
215 ; RV64I-WITH-FP-NEXT: sw s3, 120(s1)
216 ; RV64I-WITH-FP-NEXT: sw s2, 116(s1)
217 ; RV64I-WITH-FP-NEXT: sw s11, 112(s1)
218 ; RV64I-WITH-FP-NEXT: sw s10, 108(s1)
219 ; RV64I-WITH-FP-NEXT: sw s9, 104(s1)
220 ; RV64I-WITH-FP-NEXT: sw s8, 100(s1)
221 ; RV64I-WITH-FP-NEXT: sw s7, 96(s1)
222 ; RV64I-WITH-FP-NEXT: sw s6, 92(s1)
223 ; RV64I-WITH-FP-NEXT: sw s5, 88(s1)
224 ; RV64I-WITH-FP-NEXT: ld a0, -280(s0)
225 %val = load [32 x i32], [32 x i32]* @var
227 store volatile [32 x i32] %val, [32 x i32]* @var