Debian Codegraph @

libitm/config/loongarch/sjlj.S

raw
1 /* Copyright (C) 2022-2025 Free Software Foundation, Inc.
2 Contributed by Loongson Co. Ltd.
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 more details.
14
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
23
24 #include "asmcfi.h"
25 #include "asm.h"
26
27 .text
28 .align 2
29 .global _ITM_beginTransaction
30 .type _ITM_beginTransaction, @function
31
32 _ITM_beginTransaction:
33 cfi_startproc
34 move $r5, $sp
35 ADDSP(-(12*SZ_GPR+8*SZ_FPR))
36 cfi_adjust_cfa_offset(12*SZ_GPR+8*SZ_FPR)
37
38 /* Frame Pointer */
39 GPR_S $fp, $sp, 0*SZ_GPR
40 cfi_rel_offset(22, 0)
41
42 /* Return Address */
43 GPR_S $r1, $sp, 1*SZ_GPR
44 cfi_rel_offset(1, SZ_GPR)
45
46 /* Caller's $sp */
47 GPR_S $r5, $sp, 2*SZ_GPR
48
49 /* Callee-saved scratch GPRs (r23-r31) */
50 GPR_S $s0, $sp, 3*SZ_GPR
51 GPR_S $s1, $sp, 4*SZ_GPR
52 GPR_S $s2, $sp, 5*SZ_GPR
53 GPR_S $s3, $sp, 6*SZ_GPR
54 GPR_S $s4, $sp, 7*SZ_GPR
55 GPR_S $s5, $sp, 8*SZ_GPR
56 GPR_S $s6, $sp, 9*SZ_GPR
57 GPR_S $s7, $sp, 10*SZ_GPR
58 GPR_S $s8, $sp, 11*SZ_GPR
59
60 #if !defined(__loongarch_soft_float)
61 /* Callee-saved scratch FPRs (f24-f31) */
62 FPR_S $f24, $sp, 12*SZ_GPR + 0*SZ_FPR
63 FPR_S $f25, $sp, 12*SZ_GPR + 1*SZ_FPR
64 FPR_S $f26, $sp, 12*SZ_GPR + 2*SZ_FPR
65 FPR_S $f27, $sp, 12*SZ_GPR + 3*SZ_FPR
66 FPR_S $f28, $sp, 12*SZ_GPR + 4*SZ_FPR
67 FPR_S $f29, $sp, 12*SZ_GPR + 5*SZ_FPR
68 FPR_S $f30, $sp, 12*SZ_GPR + 6*SZ_FPR
69 FPR_S $f31, $sp, 12*SZ_GPR + 7*SZ_FPR
70 #endif
71 move $fp, $sp
72
73 /* Invoke GTM_begin_transaction with the struct we've just built. */
74 move $r5, $sp
75 bl %plt(GTM_begin_transaction)
76
77 /* Return. (no call-saved scratch reg needs to be restored here) */
78 GPR_L $fp, $sp, 0*SZ_GPR
79 cfi_restore(22)
80 GPR_L $r1, $sp, 1*SZ_GPR
81 cfi_restore(1)
82
83 ADDSP(12*SZ_GPR+8*SZ_FPR)
84 cfi_adjust_cfa_offset(-(12*SZ_GPR+8*SZ_FPR))
85
86 jr $r1
87 cfi_endproc
88 .size _ITM_beginTransaction, . - _ITM_beginTransaction
89
90 .align 2
91 .global GTM_longjmp
92 .hidden GTM_longjmp
93 .type GTM_longjmp, @function
94
95 GTM_longjmp:
96 cfi_startproc
97 GPR_L $s0, $r5, 3*SZ_GPR
98 GPR_L $s1, $r5, 4*SZ_GPR
99 GPR_L $s2, $r5, 5*SZ_GPR
100 GPR_L $s3, $r5, 6*SZ_GPR
101 GPR_L $s4, $r5, 7*SZ_GPR
102 GPR_L $s5, $r5, 8*SZ_GPR
103 GPR_L $s6, $r5, 9*SZ_GPR
104 GPR_L $s7, $r5, 10*SZ_GPR
105 GPR_L $s8, $r5, 11*SZ_GPR
106
107 #if !defined(__loongarch_soft_float)
108 /* Callee-saved scratch FPRs (f24-f31) */
109 FPR_L $f24, $r5, 12*SZ_GPR + 0*SZ_FPR
110 FPR_L $f25, $r5, 12*SZ_GPR + 1*SZ_FPR
111 FPR_L $f26, $r5, 12*SZ_GPR + 2*SZ_FPR
112 FPR_L $f27, $r5, 12*SZ_GPR + 3*SZ_FPR
113 FPR_L $f28, $r5, 12*SZ_GPR + 4*SZ_FPR
114 FPR_L $f29, $r5, 12*SZ_GPR + 5*SZ_FPR
115 FPR_L $f30, $r5, 12*SZ_GPR + 6*SZ_FPR
116 FPR_L $f31, $r5, 12*SZ_GPR + 7*SZ_FPR
117 #endif
118
119 GPR_L $r7, $r5, 2*SZ_GPR
120 GPR_L $fp, $r5, 0*SZ_GPR
121 GPR_L $r1, $r5, 1*SZ_GPR
122 cfi_def_cfa(5, 0)
123 move $sp, $r7
124 jr $r1
125 cfi_endproc
126 .size GTM_longjmp, . - GTM_longjmp
127
128 #ifdef __linux__
129 .section .note.GNU-stack, "", @progbits
130 #endif