1 /* Copyright (C) 2022-2023 Free Software Foundation, Inc.
2 Contributed by Xiongchuan Tan <xc-tan@outlook.com>.
4 This file is part of the GNU Transactional Memory Library (libitm).
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.
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
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.
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/>. */
30 .global _ITM_beginTransaction
31 .type _ITM_beginTransaction, @function
33 _ITM_beginTransaction:
36 addi sp, sp, -ADJ_STACK_SIZE
37 cfi_adjust_cfa_offset(ADJ_STACK_SIZE)
40 GPR_S ra, 0*SZ_GPR(sp)
41 cfi_rel_offset(ra, 0*SZ_GPR)
44 GPR_S a1, 1*SZ_GPR(sp)
47 GPR_S fp, 2*SZ_GPR(sp)
48 cfi_rel_offset(fp, 2*SZ_GPR)
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)
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)
80 /* Invoke GTM_begin_transaction with the struct we've just built. */
82 jal ra, GTM_begin_transaction
84 /* Return; we don't need to restore any of the call-saved regs. */
85 GPR_L ra, 0*SZ_GPR(sp)
87 GPR_L fp, 2*SZ_GPR(sp)
90 addi sp, sp, ADJ_STACK_SIZE
91 cfi_adjust_cfa_offset(-ADJ_STACK_SIZE)
95 .size _ITM_beginTransaction, . - _ITM_beginTransaction
100 .type GTM_longjmp, @function
103 /* The first parameter becomes the return value (a0).
104 The third parameter is ignored for now. */
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)
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)
133 GPR_L ra, 0*SZ_GPR(a1)
134 GPR_L fp, 2*SZ_GPR(a1)
135 GPR_L a3, 1*SZ_GPR(a1)
140 .size GTM_longjmp, . - GTM_longjmp
143 .section .note.GNU-stack, "", @progbits