1/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
2
3   This file is part of the GNU Transactional Memory Library (libitm).
4
5   Libitm is free software; you can redistribute it and/or modify it
6   under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 3 of the License, or
8   (at your option) any later version.
9
10   Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
11   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13   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
26	.text
27	.align	2
28	.global	_ITM_beginTransaction
29	.type	_ITM_beginTransaction, %function
30
31_ITM_beginTransaction:
32	cfi_startproc
33	mov	r15, r1
34#ifdef __SH_FPU_ANY__
35	fmov.s	fr15, @-r15
36	fmov.s	fr14, @-r15
37	fmov.s	fr13, @-r15
38	fmov.s	fr12, @-r15
39	sts.l	fpscr, @-r15
40#endif /* __SH_FPU_ANY__ */
41	stc.l	gbr, @-r15
42	sts.l	pr, @-r15
43	mov.l	r1, @-r15
44	mov.l	r14, @-r15
45	mov.l	r13, @-r15
46	mov.l	r12, @-r15
47	mov.l	r11, @-r15
48	mov.l	r10, @-r15
49	mov.l	r9, @-r15
50	mov.l	r8, @-r15
51#ifdef __SH_FPU_ANY__
52	cfi_def_cfa_offset (4*15)
53#else
54	cfi_def_cfa_offset (4*10)
55#endif
56#if !defined __PIC__
57	mov.l	.Lbegin, r1
58	jsr	@r1
59	 mov	r15, r5
60#else
61	mov.l	.Lbegin, r1
62	bsrf	r1
63	 mov	r15, r5
64.Lbegin0:
65	mov.l	@(4*4,r15), r12
66#endif
67	mov.l	@(8*4,r15), r1
68	lds	r1, pr
69#ifdef __SH_FPU_ANY__
70	add	#(15*4), r15
71#else
72	add	#(10*5), r15
73#endif
74	cfi_def_cfa_offset (0)
75	rts
76	 nop
77	cfi_endproc
78
79	.align  2
80.Lbegin:
81#if !defined __PIC__
82	.long	GTM_begin_transaction
83#else
84	.long	GTM_begin_transaction@PCREL-(.Lbegin0-.)
85#endif
86	.size	_ITM_beginTransaction, . - _ITM_beginTransaction
87
88	.global	GTM_longjmp
89	.hidden	GTM_longjmp
90	.type	GTM_longjmp, %function
91
92GTM_longjmp:
93	mov.l	@r5+, r8
94	mov.l	@r5+, r9
95	mov.l	@r5+, r10
96	mov.l	@r5+, r11
97	mov.l	@r5+, r12
98	mov.l	@r5+, r13
99	mov.l	@r5+, r14
100	mov.l	@r5+, r15
101	lds.l	@r5+, pr
102	ldc.l	@r5+, gbr
103#ifdef __SH_FPU_ANY__
104	lds.l	@r5+, fpscr
105	fmov.s	@r5+, fr12
106	fmov.s	@r5+, fr13
107	fmov.s	@r5+, fr14
108	fmov.s	@r5+, fr15
109#endif
110	rts
111	 mov	r4, r0
112
113	.size	GTM_longjmp, . - GTM_longjmp
114
115#ifdef __linux__
116.section .note.GNU-stack, "", %progbits
117#endif
118