ed755daa8a03f575ee00db83652e58e24bad4a12
[gcc.git] / libitm / config / x86 / sjlj.S
1 /* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <rth@redhat.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
26 #include "asmcfi.h"
27
28 .text
29
30 .align 4
31 .globl _ITM_beginTransaction
32
33 _ITM_beginTransaction:
34 cfi_startproc
35 #ifdef __x86_64__
36 leaq 8(%rsp), %rax
37 movq (%rsp), %r8
38 subq $72, %rsp
39 cfi_def_cfa_offset(80)
40 movq %rax, (%rsp)
41 movq %r8, 8(%rsp)
42 movq %rbx, 16(%rsp)
43 movq %rbp, 24(%rsp)
44 movq %r12, 32(%rsp)
45 movq %r13, 40(%rsp)
46 movq %r14, 48(%rsp)
47 movq %r15, 56(%rsp)
48 movq %rsp, %rsi
49 call GTM_begin_transaction
50 addq $72, %rsp
51 cfi_def_cfa_offset(8)
52 ret
53 #else
54 leal 4(%esp), %ecx
55 subl $28, %esp
56 cfi_def_cfa_offset(32)
57 movl %ecx, 8(%esp)
58 movl %ebx, 12(%esp)
59 movl %esi, 16(%esp)
60 movl %edi, 20(%esp)
61 movl %ebp, 24(%esp)
62 leal 8(%esp), %edx
63 #if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
64 call GTM_begin_transaction
65 #elif defined __ELF__
66 call 1f
67 1: popl %ebx
68 addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
69 call GTM_begin_transaction@PLT
70 movl 12(%esp), %ebx
71 #else
72 # error "Unsupported PIC sequence"
73 #endif
74 addl $28, %esp
75 cfi_def_cfa_offset(4)
76 ret
77 #endif
78 cfi_endproc
79
80 #ifdef __ELF__
81 .type _ITM_beginTransaction, @function
82 .size _ITM_beginTransaction, .-_ITM_beginTransaction
83 #endif
84
85 .align 4
86 .globl GTM_longjmp
87
88 GTM_longjmp:
89 cfi_startproc
90 #ifdef __x86_64__
91 movq (%rdi), %rcx
92 movq 8(%rdi), %rdx
93 movq 16(%rdi), %rbx
94 movq 24(%rdi), %rbp
95 movq 32(%rdi), %r12
96 movq 40(%rdi), %r13
97 movq 48(%rdi), %r14
98 movq 56(%rdi), %r15
99 movl %esi, %eax
100 cfi_def_cfa(%rcx, 0)
101 cfi_register(%rip, %rdx)
102 movq %rcx, %rsp
103 jmp *%rdx
104 #else
105 xchgl %eax, %edx
106 movl (%edx), %ecx
107 movl 4(%edx), %ebx
108 movl 8(%edx), %esi
109 movl 12(%edx), %edi
110 movl 16(%edx), %ebp
111 movl 20(%edx), %edx
112 cfi_def_cfa(%ecx, 0)
113 cfi_register(%eip, %edx)
114 movl %ecx, %esp
115 jmp *%edx
116 #endif
117 cfi_endproc
118
119 #ifdef __ELF__
120 .type GTM_longjmp, @function
121 #ifdef HAVE_ATTRIBUTE_VISIBILITY
122 .hidden GTM_longjmp
123 #endif
124 .size GTM_longjmp, .-GTM_longjmp
125 #endif
126
127 #ifdef __linux__
128 .section .note.GNU-stack, "", @progbits
129 #endif