OSDN Git Service

libitm: Conversion to c++11 atomics.
[pf3gnuchains/gcc-fork.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 #define CONCAT1(a, b) CONCAT2(a, b)
29 #define CONCAT2(a, b) a ## b
30
31 #ifdef __USER_LABEL_PREFIX__
32 #  define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
33 #else
34 #  define SYM(x) x
35 #endif
36
37 #ifdef __ELF__
38 #  define TYPE(x) .type SYM(x), @function
39 #  define SIZE(x) .size SYM(x), . - SYM(x)
40 #  ifdef HAVE_ATTRIBUTE_VISIBILITY
41 #    define HIDDEN(x) .hidden SYM(x)
42 #  else
43 #    define HIDDEN(x)
44 #  endif
45 #else
46 #  define TYPE(x)
47 #  define SIZE(x)
48 #  ifdef __MACH__
49 #    define HIDDEN(x) .private_extern SYM(x)
50 #  else
51 #    define HIDDEN(x)
52 #  endif
53 #endif
54
55         .text
56
57         .align 4
58         .globl  SYM(_ITM_beginTransaction)
59
60 SYM(_ITM_beginTransaction):
61         cfi_startproc
62 #ifdef __x86_64__
63         leaq    8(%rsp), %rax
64         movq    (%rsp), %r8
65         subq    $72, %rsp
66         cfi_def_cfa_offset(80)
67         movq    %rax, (%rsp)
68         movq    %r8, 8(%rsp)
69         movq    %rbx, 16(%rsp)
70         movq    %rbp, 24(%rsp)
71         movq    %r12, 32(%rsp)
72         movq    %r13, 40(%rsp)
73         movq    %r14, 48(%rsp)
74         movq    %r15, 56(%rsp)
75         movq    %rsp, %rsi
76         call    SYM(GTM_begin_transaction)
77         addq    $72, %rsp
78         cfi_def_cfa_offset(8)
79         ret
80 #else
81         leal    4(%esp), %ecx
82         subl    $28, %esp
83         cfi_def_cfa_offset(32)
84         movl    %ecx, 8(%esp)
85         movl    %ebx, 12(%esp)
86         movl    %esi, 16(%esp)
87         movl    %edi, 20(%esp)
88         movl    %ebp, 24(%esp)
89         leal    8(%esp), %edx
90 #if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
91         call    SYM(GTM_begin_transaction)
92 #elif defined __ELF__
93         call    1f
94 1:      popl    %ebx
95         addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
96         call    SYM(GTM_begin_transaction)@PLT
97         movl    12(%esp), %ebx
98 #else
99 # error "Unsupported PIC sequence"
100 #endif
101         addl    $28, %esp
102         cfi_def_cfa_offset(4)
103         ret
104 #endif
105         cfi_endproc
106
107         TYPE(_ITM_beginTransaction)
108         SIZE(_ITM_beginTransaction)
109
110         .align 4
111         .globl  SYM(GTM_longjmp)
112
113 SYM(GTM_longjmp):
114         cfi_startproc
115 #ifdef __x86_64__
116         movq    (%rsi), %rcx
117         movq    8(%rsi), %rdx
118         movq    16(%rsi), %rbx
119         movq    24(%rsi), %rbp
120         movq    32(%rsi), %r12
121         movq    40(%rsi), %r13
122         movq    48(%rsi), %r14
123         movq    56(%rsi), %r15
124         movl    %edi, %eax
125         cfi_def_cfa(%rcx, 0)
126         cfi_register(%rip, %rdx)
127         movq    %rcx, %rsp
128         jmp     *%rdx
129 #else
130         movl    (%edx), %ecx
131         movl    4(%edx), %ebx
132         movl    8(%edx), %esi
133         movl    12(%edx), %edi
134         movl    16(%edx), %ebp
135         movl    20(%edx), %edx
136         cfi_def_cfa(%ecx, 0)
137         cfi_register(%eip, %edx)
138         movl    %ecx, %esp
139         jmp     *%edx
140 #endif
141         cfi_endproc
142
143         TYPE(GTM_longjmp)
144         HIDDEN(GTM_longjmp)
145         SIZE(GTM_longjmp)
146
147 #ifdef __linux__
148 .section .note.GNU-stack, "", @progbits
149 #endif