]> git.ipfire.org Git - thirdparty/gcc.git/blob - libitm/config/riscv/sjlj.S
Update copyright years.
[thirdparty/gcc.git] / libitm / config / riscv / sjlj.S
1 /* Copyright (C) 2022-2024 Free Software Foundation, Inc.
2 Contributed by Xiongchuan Tan <xc-tan@outlook.com>.
3
4 This file is part of the GNU Transactional Memory Library (libitm).
5
6 Libitm is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
19
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
24
25 #include "asmcfi.h"
26 #include "asm.h"
27
28 .text
29 .align 2
30 .global _ITM_beginTransaction
31 .type _ITM_beginTransaction, @function
32
33 _ITM_beginTransaction:
34 cfi_startproc
35 mv a1, sp
36 addi sp, sp, -ADJ_STACK_SIZE
37 cfi_adjust_cfa_offset(ADJ_STACK_SIZE)
38
39 /* Return Address */
40 GPR_S ra, 0*SZ_GPR(sp)
41 cfi_rel_offset(ra, 0*SZ_GPR)
42
43 /* Caller's sp */
44 GPR_S a1, 1*SZ_GPR(sp)
45
46 /* Caller's s0/fp */
47 GPR_S fp, 2*SZ_GPR(sp)
48 cfi_rel_offset(fp, 2*SZ_GPR)
49
50 /* Callee-saved registers */
51 GPR_S s1, 3*SZ_GPR(sp)
52 GPR_S s2, 4*SZ_GPR(sp)
53 GPR_S s3, 5*SZ_GPR(sp)
54 GPR_S s4, 6*SZ_GPR(sp)
55 GPR_S s5, 7*SZ_GPR(sp)
56 GPR_S s6, 8*SZ_GPR(sp)
57 GPR_S s7, 9*SZ_GPR(sp)
58 GPR_S s8, 10*SZ_GPR(sp)
59 GPR_S s9, 11*SZ_GPR(sp)
60 GPR_S s10, 12*SZ_GPR(sp)
61 GPR_S s11, 13*SZ_GPR(sp)
62
63 #if defined(__riscv_flen)
64 /* Callee-saved floating-point registers */
65 FPR_S fs0, 0*SZ_FPR+LEN_GPR*SZ_GPR(sp)
66 FPR_S fs1, 1*SZ_FPR+LEN_GPR*SZ_GPR(sp)
67 FPR_S fs2, 2*SZ_FPR+LEN_GPR*SZ_GPR(sp)
68 FPR_S fs3, 3*SZ_FPR+LEN_GPR*SZ_GPR(sp)
69 FPR_S fs4, 4*SZ_FPR+LEN_GPR*SZ_GPR(sp)
70 FPR_S fs5, 5*SZ_FPR+LEN_GPR*SZ_GPR(sp)
71 FPR_S fs6, 6*SZ_FPR+LEN_GPR*SZ_GPR(sp)
72 FPR_S fs7, 7*SZ_FPR+LEN_GPR*SZ_GPR(sp)
73 FPR_S fs8, 8*SZ_FPR+LEN_GPR*SZ_GPR(sp)
74 FPR_S fs9, 9*SZ_FPR+LEN_GPR*SZ_GPR(sp)
75 FPR_S fs10, 10*SZ_FPR+LEN_GPR*SZ_GPR(sp)
76 FPR_S fs11, 11*SZ_FPR+LEN_GPR*SZ_GPR(sp)
77 #endif
78 mv fp, sp
79
80 /* Invoke GTM_begin_transaction with the struct we've just built. */
81 mv a1, sp
82 jal ra, GTM_begin_transaction
83
84 /* Return; we don't need to restore any of the call-saved regs. */
85 GPR_L ra, 0*SZ_GPR(sp)
86 cfi_restore(ra)
87 GPR_L fp, 2*SZ_GPR(sp)
88 cfi_restore(fp)
89
90 addi sp, sp, ADJ_STACK_SIZE
91 cfi_adjust_cfa_offset(-ADJ_STACK_SIZE)
92
93 ret
94 cfi_endproc
95 .size _ITM_beginTransaction, . - _ITM_beginTransaction
96
97 .align 2
98 .global GTM_longjmp
99 .hidden GTM_longjmp
100 .type GTM_longjmp, @function
101
102 GTM_longjmp:
103 /* The first parameter becomes the return value (a0).
104 The third parameter is ignored for now. */
105 cfi_startproc
106 GPR_L s1, 3*SZ_GPR(a1)
107 GPR_L s2, 4*SZ_GPR(a1)
108 GPR_L s3, 5*SZ_GPR(a1)
109 GPR_L s4, 6*SZ_GPR(a1)
110 GPR_L s5, 7*SZ_GPR(a1)
111 GPR_L s6, 8*SZ_GPR(a1)
112 GPR_L s7, 9*SZ_GPR(a1)
113 GPR_L s8, 10*SZ_GPR(a1)
114 GPR_L s9, 11*SZ_GPR(a1)
115 GPR_L s10, 12*SZ_GPR(a1)
116 GPR_L s11, 13*SZ_GPR(a1)
117
118 #if defined(__riscv_flen)
119 FPR_L fs0, 0*SZ_FPR+LEN_GPR*SZ_GPR(a1)
120 FPR_L fs1, 1*SZ_FPR+LEN_GPR*SZ_GPR(a1)
121 FPR_L fs2, 2*SZ_FPR+LEN_GPR*SZ_GPR(a1)
122 FPR_L fs3, 3*SZ_FPR+LEN_GPR*SZ_GPR(a1)
123 FPR_L fs4, 4*SZ_FPR+LEN_GPR*SZ_GPR(a1)
124 FPR_L fs5, 5*SZ_FPR+LEN_GPR*SZ_GPR(a1)
125 FPR_L fs6, 6*SZ_FPR+LEN_GPR*SZ_GPR(a1)
126 FPR_L fs7, 7*SZ_FPR+LEN_GPR*SZ_GPR(a1)
127 FPR_L fs8, 8*SZ_FPR+LEN_GPR*SZ_GPR(a1)
128 FPR_L fs9, 9*SZ_FPR+LEN_GPR*SZ_GPR(a1)
129 FPR_L fs10, 10*SZ_FPR+LEN_GPR*SZ_GPR(a1)
130 FPR_L fs11, 11*SZ_FPR+LEN_GPR*SZ_GPR(a1)
131 #endif
132
133 GPR_L ra, 0*SZ_GPR(a1)
134 GPR_L fp, 2*SZ_GPR(a1)
135 GPR_L a3, 1*SZ_GPR(a1)
136 cfi_def_cfa(a1, 0)
137 mv sp, a3
138 jr ra
139 cfi_endproc
140 .size GTM_longjmp, . - GTM_longjmp
141
142 #ifdef __linux__
143 .section .note.GNU-stack, "", @progbits
144 #endif