]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgcc/config/riscv/save-restore.S
Add .type and .size directives to riscv libgcc functions.
[thirdparty/gcc.git] / libgcc / config / riscv / save-restore.S
1 /* Callee-saved register spill and fill routines for RISC-V.
2
3 Copyright (C) 2016-2017 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
25
26 #include "riscv-asm.h"
27
28 .text
29
30 #if __riscv_xlen == 64
31
32 FUNC_BEGIN (__riscv_save_12)
33 .cfi_startproc
34 # __riscv_save_* routine use t0/x5 as return address
35 .cfi_return_column 5
36 addi sp, sp, -112
37 .cfi_def_cfa_offset 112
38 li t1, 0
39 sd s11, 8(sp)
40 .cfi_offset 27, -104
41 j .Ls10
42
43 FUNC_BEGIN (__riscv_save_11)
44 FUNC_BEGIN (__riscv_save_10)
45 .cfi_restore 27
46 addi sp, sp, -112
47 .cfi_def_cfa_offset 112
48 li t1, -16
49 .Ls10:
50 sd s10, 16(sp)
51 .cfi_offset 26, -96
52 sd s9, 24(sp)
53 .cfi_offset 25, -88
54 j .Ls8
55
56 FUNC_BEGIN (__riscv_save_9)
57 FUNC_BEGIN (__riscv_save_8)
58 .cfi_restore 25
59 .cfi_restore 26
60 .cfi_restore 27
61 addi sp, sp, -112
62 .cfi_def_cfa_offset 112
63 li t1, -32
64 .Ls8:
65 sd s8, 32(sp)
66 .cfi_offset 24, -80
67 sd s7, 40(sp)
68 .cfi_offset 23, -72
69 j .Ls6
70
71 FUNC_BEGIN (__riscv_save_7)
72 FUNC_BEGIN (__riscv_save_6)
73 .cfi_restore 23
74 .cfi_restore 24
75 .cfi_restore 25
76 .cfi_restore 26
77 .cfi_restore 27
78 addi sp, sp, -112
79 .cfi_def_cfa_offset 112
80 li t1, -48
81 .Ls6:
82 sd s6, 48(sp)
83 .cfi_offset 22, -64
84 sd s5, 56(sp)
85 .cfi_offset 21, -56
86 j .Ls4
87
88 FUNC_BEGIN (__riscv_save_5)
89 FUNC_BEGIN (__riscv_save_4)
90 .cfi_restore 21
91 .cfi_restore 22
92 .cfi_restore 24
93 .cfi_restore 25
94 .cfi_restore 26
95 .cfi_restore 27
96 .cfi_restore 24
97 .cfi_restore 25
98 .cfi_restore 26
99 .cfi_restore 27
100 addi sp, sp, -112
101 .cfi_def_cfa_offset 112
102 li t1, -64
103 .Ls4:
104 sd s4, 64(sp)
105 .cfi_offset 20, -48
106 sd s3, 72(sp)
107 .cfi_offset 19, -40
108 j .Ls2
109
110 FUNC_BEGIN (__riscv_save_3)
111 FUNC_BEGIN (__riscv_save_2)
112 .cfi_restore 19
113 .cfi_restore 20
114 .cfi_restore 21
115 .cfi_restore 22
116 .cfi_restore 24
117 .cfi_restore 25
118 .cfi_restore 26
119 .cfi_restore 27
120 .cfi_restore 24
121 .cfi_restore 25
122 .cfi_restore 26
123 .cfi_restore 27
124 addi sp, sp, -112
125 .cfi_def_cfa_offset 112
126 li t1, -80
127 .Ls2:
128 sd s2, 80(sp)
129 .cfi_offset 18, -32
130 sd s1, 88(sp)
131 .cfi_offset 9, -24
132 sd s0, 96(sp)
133 .cfi_offset 8, -16
134 sd ra, 104(sp)
135 .cfi_offset 1, -8
136 # CFA info is not correct in next 2 instruction since t1's
137 # value is depend on how may register really save.
138 sub sp, sp, t1
139 jr t0
140 .cfi_endproc
141 FUNC_END (__riscv_save_12)
142 FUNC_END (__riscv_save_11)
143 FUNC_END (__riscv_save_10)
144 FUNC_END (__riscv_save_9)
145 FUNC_END (__riscv_save_8)
146 FUNC_END (__riscv_save_7)
147 FUNC_END (__riscv_save_6)
148 FUNC_END (__riscv_save_5)
149 FUNC_END (__riscv_save_4)
150 FUNC_END (__riscv_save_3)
151 FUNC_END (__riscv_save_2)
152
153 FUNC_BEGIN (__riscv_save_1)
154 FUNC_BEGIN (__riscv_save_0)
155 .cfi_startproc
156 # __riscv_save_* routine use t0/x5 as return address
157 .cfi_return_column 5
158 addi sp, sp, -16
159 .cfi_def_cfa_offset 16
160 sd s0, 0(sp)
161 .cfi_offset 8, -16
162 sd ra, 8(sp)
163 .cfi_offset 1, -8
164 jr t0
165 .cfi_endproc
166 FUNC_END (__riscv_save_1)
167 FUNC_END (__riscv_save_0)
168
169 FUNC_BEGIN (__riscv_restore_12)
170 .cfi_startproc
171 .cfi_def_cfa_offset 112
172 .cfi_offset 27, -104
173 .cfi_offset 26, -96
174 .cfi_offset 25, -88
175 .cfi_offset 24, -80
176 .cfi_offset 23, -72
177 .cfi_offset 22, -64
178 .cfi_offset 21, -56
179 .cfi_offset 20, -48
180 .cfi_offset 19, -40
181 .cfi_offset 18, -32
182 .cfi_offset 9, -24
183 .cfi_offset 8, -16
184 .cfi_offset 1, -8
185 ld s11, 8(sp)
186 .cfi_restore 27
187 addi sp, sp, 16
188
189 FUNC_BEGIN (__riscv_restore_11)
190 FUNC_BEGIN (__riscv_restore_10)
191 .cfi_restore 27
192 .cfi_def_cfa_offset 96
193 ld s10, 0(sp)
194 .cfi_restore 26
195 ld s9, 8(sp)
196 .cfi_restore 25
197 addi sp, sp, 16
198
199 FUNC_BEGIN (__riscv_restore_9)
200 FUNC_BEGIN (__riscv_restore_8)
201 .cfi_restore 25
202 .cfi_restore 26
203 .cfi_restore 27
204 .cfi_def_cfa_offset 80
205 ld s8, 0(sp)
206 .cfi_restore 24
207 ld s7, 8(sp)
208 .cfi_restore 23
209 addi sp, sp, 16
210
211 FUNC_BEGIN (__riscv_restore_7)
212 FUNC_BEGIN (__riscv_restore_6)
213 .cfi_restore 23
214 .cfi_restore 24
215 .cfi_restore 25
216 .cfi_restore 26
217 .cfi_restore 27
218 .cfi_def_cfa_offset 64
219 ld s6, 0(sp)
220 .cfi_restore 22
221 ld s5, 8(sp)
222 .cfi_restore 21
223 addi sp, sp, 16
224
225 FUNC_BEGIN (__riscv_restore_5)
226 FUNC_BEGIN (__riscv_restore_4)
227 .cfi_restore 21
228 .cfi_restore 22
229 .cfi_restore 23
230 .cfi_restore 24
231 .cfi_restore 25
232 .cfi_restore 26
233 .cfi_restore 27
234 .cfi_def_cfa_offset 48
235 ld s4, 0(sp)
236 .cfi_restore 20
237 ld s3, 8(sp)
238 .cfi_restore 19
239 addi sp, sp, 16
240
241 FUNC_BEGIN (__riscv_restore_3)
242 FUNC_BEGIN (__riscv_restore_2)
243 .cfi_restore 19
244 .cfi_restore 20
245 .cfi_restore 21
246 .cfi_restore 22
247 .cfi_restore 23
248 .cfi_restore 24
249 .cfi_restore 25
250 .cfi_restore 26
251 .cfi_restore 27
252 .cfi_def_cfa_offset 32
253 ld s2, 0(sp)
254 .cfi_restore 18
255 ld s1, 8(sp)
256 .cfi_restore 9
257 addi sp, sp, 16
258
259 FUNC_BEGIN (__riscv_restore_1)
260 FUNC_BEGIN (__riscv_restore_0)
261 .cfi_restore 9
262 .cfi_restore 18
263 .cfi_restore 19
264 .cfi_restore 20
265 .cfi_restore 21
266 .cfi_restore 22
267 .cfi_restore 23
268 .cfi_restore 24
269 .cfi_restore 25
270 .cfi_restore 26
271 .cfi_restore 27
272 .cfi_def_cfa_offset 16
273 ld s0, 0(sp)
274 .cfi_restore 8
275 ld ra, 8(sp)
276 .cfi_restore 1
277 addi sp, sp, 16
278 .cfi_def_cfa_offset 0
279 ret
280 .cfi_endproc
281 FUNC_END (__riscv_restore_12)
282 FUNC_END (__riscv_restore_11)
283 FUNC_END (__riscv_restore_10)
284 FUNC_END (__riscv_restore_9)
285 FUNC_END (__riscv_restore_8)
286 FUNC_END (__riscv_restore_7)
287 FUNC_END (__riscv_restore_6)
288 FUNC_END (__riscv_restore_5)
289 FUNC_END (__riscv_restore_4)
290 FUNC_END (__riscv_restore_3)
291 FUNC_END (__riscv_restore_2)
292 FUNC_END (__riscv_restore_1)
293 FUNC_END (__riscv_restore_0)
294
295 #else
296
297 FUNC_BEGIN (__riscv_save_12)
298 .cfi_startproc
299 # __riscv_save_* routine use t0/x5 as return address
300 .cfi_return_column 5
301 addi sp, sp, -64
302 .cfi_def_cfa_offset 64
303 li t1, 0
304 sw s11, 12(sp)
305 .cfi_offset 27, -52
306 j .Ls10
307
308 FUNC_BEGIN (__riscv_save_11)
309 FUNC_BEGIN (__riscv_save_10)
310 FUNC_BEGIN (__riscv_save_9)
311 FUNC_BEGIN (__riscv_save_8)
312 .cfi_restore 27
313 addi sp, sp, -64
314 .cfi_def_cfa_offset 64
315 li t1, -16
316 .Ls10:
317 sw s10, 16(sp)
318 .cfi_offset 26, -48
319 sw s9, 20(sp)
320 .cfi_offset 25, -44
321 sw s8, 24(sp)
322 .cfi_offset 24, -40
323 sw s7, 28(sp)
324 .cfi_offset 23, -36
325 j .Ls6
326
327 FUNC_BEGIN (__riscv_save_7)
328 FUNC_BEGIN (__riscv_save_6)
329 FUNC_BEGIN (__riscv_save_5)
330 FUNC_BEGIN (__riscv_save_4)
331 .cfi_restore 23
332 .cfi_restore 24
333 .cfi_restore 25
334 .cfi_restore 26
335 .cfi_restore 27
336 addi sp, sp, -64
337 .cfi_def_cfa_offset 64
338 li t1, -32
339 .Ls6:
340 sw s6, 32(sp)
341 .cfi_offset 22, -32
342 sw s5, 36(sp)
343 .cfi_offset 21, -28
344 sw s4, 40(sp)
345 .cfi_offset 20, -24
346 sw s3, 44(sp)
347 .cfi_offset 19, -20
348 sw s2, 48(sp)
349 .cfi_offset 18, -16
350 sw s1, 52(sp)
351 .cfi_offset 9, -12
352 sw s0, 56(sp)
353 .cfi_offset 8, -8
354 sw ra, 60(sp)
355 .cfi_offset 1, -4
356 # CFA info is not correct in next 2 instruction since t1's
357 # value is depend on how may register really save.
358 sub sp, sp, t1
359 jr t0
360 .cfi_endproc
361 FUNC_END (__riscv_save_12)
362 FUNC_END (__riscv_save_11)
363 FUNC_END (__riscv_save_10)
364 FUNC_END (__riscv_save_9)
365 FUNC_END (__riscv_save_8)
366 FUNC_END (__riscv_save_7)
367 FUNC_END (__riscv_save_6)
368 FUNC_END (__riscv_save_5)
369 FUNC_END (__riscv_save_4)
370
371 FUNC_BEGIN (__riscv_save_3)
372 FUNC_BEGIN (__riscv_save_2)
373 FUNC_BEGIN (__riscv_save_1)
374 FUNC_BEGIN (__riscv_save_0)
375 .cfi_startproc
376 # __riscv_save_* routine use t0/x5 as return address
377 .cfi_return_column 5
378 addi sp, sp, -16
379 .cfi_def_cfa_offset 16
380 sw s2, 0(sp)
381 sw s1, 4(sp)
382 .cfi_offset 9, -16
383 sw s0, 8(sp)
384 .cfi_offset 8, -8
385 sw ra, 12(sp)
386 .cfi_offset 1, -4
387 jr t0
388 .cfi_endproc
389 FUNC_END (__riscv_save_3)
390 FUNC_END (__riscv_save_2)
391 FUNC_END (__riscv_save_1)
392 FUNC_END (__riscv_save_0)
393
394 FUNC_BEGIN (__riscv_restore_12)
395 .cfi_startproc
396 .cfi_def_cfa_offset 64
397 .cfi_offset 27, -52
398 .cfi_offset 26, -48
399 .cfi_offset 25, -44
400 .cfi_offset 24, -40
401 .cfi_offset 23, -36
402 .cfi_offset 22, -32
403 .cfi_offset 21, -28
404 .cfi_offset 20, -24
405 .cfi_offset 19, -20
406 .cfi_offset 18, -16
407 .cfi_offset 9, -12
408 .cfi_offset 8, -8
409 .cfi_offset 1, -4
410 lw s11, 12(sp)
411 .cfi_restore 27
412 addi sp, sp, 16
413
414 FUNC_BEGIN (__riscv_restore_11)
415 FUNC_BEGIN (__riscv_restore_10)
416 FUNC_BEGIN (__riscv_restore_9)
417 FUNC_BEGIN (__riscv_restore_8)
418 .cfi_restore 27
419 .cfi_def_cfa_offset 48
420 lw s10, 0(sp)
421 .cfi_restore 26
422 lw s9, 4(sp)
423 .cfi_restore 25
424 lw s8, 8(sp)
425 .cfi_restore 24
426 lw s7, 12(sp)
427 .cfi_restore 23
428 addi sp, sp, 16
429
430 FUNC_BEGIN (__riscv_restore_7)
431 FUNC_BEGIN (__riscv_restore_6)
432 FUNC_BEGIN (__riscv_restore_5)
433 FUNC_BEGIN (__riscv_restore_4)
434 .cfi_restore 23
435 .cfi_restore 24
436 .cfi_restore 25
437 .cfi_restore 26
438 .cfi_restore 27
439 .cfi_def_cfa_offset 32
440 lw s6, 0(sp)
441 .cfi_restore 22
442 lw s5, 4(sp)
443 .cfi_restore 21
444 lw s4, 8(sp)
445 .cfi_restore 20
446 lw s3, 12(sp)
447 .cfi_restore 19
448 addi sp, sp, 16
449
450 FUNC_BEGIN (__riscv_restore_3)
451 FUNC_BEGIN (__riscv_restore_2)
452 FUNC_BEGIN (__riscv_restore_1)
453 FUNC_BEGIN (__riscv_restore_0)
454 .cfi_restore 19
455 .cfi_restore 20
456 .cfi_restore 21
457 .cfi_restore 22
458 .cfi_restore 24
459 .cfi_restore 25
460 .cfi_restore 26
461 .cfi_restore 27
462 .cfi_def_cfa_offset 16
463 lw s2, 0(sp)
464 .cfi_restore 18
465 lw s1, 4(sp)
466 .cfi_restore 9
467 lw s0, 8(sp)
468 .cfi_restore 8
469 lw ra, 12(sp)
470 .cfi_restore 1
471 addi sp, sp, 16
472 .cfi_def_cfa_offset 0
473 ret
474 .cfi_endproc
475 FUNC_END (__riscv_restore_12)
476 FUNC_END (__riscv_restore_11)
477 FUNC_END (__riscv_restore_10)
478 FUNC_END (__riscv_restore_9)
479 FUNC_END (__riscv_restore_8)
480 FUNC_END (__riscv_restore_7)
481 FUNC_END (__riscv_restore_6)
482 FUNC_END (__riscv_restore_5)
483 FUNC_END (__riscv_restore_4)
484 FUNC_END (__riscv_restore_3)
485 FUNC_END (__riscv_restore_2)
486 FUNC_END (__riscv_restore_1)
487 FUNC_END (__riscv_restore_0)
488
489 #endif