1 /* Copyright (C) 2012-2013 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <rth@redhat.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/>. */
29 #if defined(__powerpc64__) && defined(__ELF__)
35 .quad .\name, .TOC.@tocbase, 0
37 .type .\name, @function
42 .size .\name, . - .\name
51 #elif defined(__ELF__)
54 .type \name, @function
58 .size \name, . - \name
66 #elif defined(_CALL_DARWIN)
85 #error "unsupported system"
88 /* Parameterize the naming of registers. */
93 #elif defined(__MACH__)
103 /* Parameterize the code for 32-bit vs 64-bit. */
104 #if defined(__powerpc64__) || defined(__ppc64__)
116 /* Parameterize the code for call frame constants. */
117 #if defined(_CALL_AIXDESC)
119 # define LR_SAVE 2*WS
120 #elif defined(_CALL_SYSV)
122 # define LR_SAVE 1*WS
123 #elif defined(_CALL_DARWIN)
124 # define BASE (6*WS + 2*WS)
125 # define LR_SAVE 2*WS
127 # error "unsupported system"
130 #if defined(__ALTIVEC__) || defined(__VSX__)
132 # define OFS_VSCR 12*16
133 # define OFS_VR_END OFS_VSCR + 8
135 # define OFS_VR_END 0
138 # define OFS_FR OFS_VR_END
139 # define OFS_FPSCR OFS_FR + 18*8
140 # define OFS_FR_END OFS_FPSCR + 8
142 # define OFS_FR_END OFS_VR_END
144 #define OFS_GR OFS_FR_END
145 #define OFS_CFA OFS_GR + 18*WS
146 #define OFS_LR OFS_CFA + WS
147 #define OFS_TOC OFS_LR + WS
148 #define OFS_CR OFS_TOC + WS
149 #define OFS_END (((OFS_CR + WS + 15) / 16) * 16)
151 #define FRAME (((BASE + OFS_END + 15) / 16) * 16)
155 FUNC _ITM_beginTransaction
159 addi r(4), r(1), -OFS_END
161 streg r(0), LR_SAVE(r(1))
162 stregu r(1), -FRAME(r(1))
163 cfi_def_cfa_offset(FRAME)
164 cfi_offset(65, LR_SAVE)
165 streg r(6), OFS_CFA(r(4))
166 streg r(0), OFS_LR(r(4))
168 streg r(13), OFS_TOC(r(4))
170 streg r(2), OFS_TOC(r(4))
172 streg r(5), OFS_CR(r(4))
173 streg r(14), 0*WS+OFS_GR(r(4))
174 streg r(15), 1*WS+OFS_GR(r(4))
175 streg r(16), 2*WS+OFS_GR(r(4))
176 streg r(17), 3*WS+OFS_GR(r(4))
177 streg r(18), 4*WS+OFS_GR(r(4))
178 streg r(19), 5*WS+OFS_GR(r(4))
179 streg r(20), 6*WS+OFS_GR(r(4))
180 streg r(21), 7*WS+OFS_GR(r(4))
181 streg r(22), 8*WS+OFS_GR(r(4))
182 streg r(23), 9*WS+OFS_GR(r(4))
183 streg r(24), 10*WS+OFS_GR(r(4))
184 streg r(25), 11*WS+OFS_GR(r(4))
185 streg r(26), 12*WS+OFS_GR(r(4))
186 streg r(27), 13*WS+OFS_GR(r(4))
187 streg r(28), 14*WS+OFS_GR(r(4))
188 streg r(29), 15*WS+OFS_GR(r(4))
189 streg r(30), 16*WS+OFS_GR(r(4))
190 streg r(31), 17*WS+OFS_GR(r(4))
193 /* ??? Determine when FPRs not present. */
194 /* ??? Test r(3) for pr_hasNoFloatUpdate and skip the fp save.
195 This is not yet set by the compiler. */
197 stfd f(14), 0+OFS_FR(r(4))
198 stfd f(15), 8+OFS_FR(r(4))
199 stfd f(16), 16+OFS_FR(r(4))
200 stfd f(17), 24+OFS_FR(r(4))
201 stfd f(18), 32+OFS_FR(r(4))
202 stfd f(19), 40+OFS_FR(r(4))
203 stfd f(20), 48+OFS_FR(r(4))
204 stfd f(21), 56+OFS_FR(r(4))
205 stfd f(22), 64+OFS_FR(r(4))
206 stfd f(23), 72+OFS_FR(r(4))
207 stfd f(24), 80+OFS_FR(r(4))
208 stfd f(25), 88+OFS_FR(r(4))
209 stfd f(26), 96+OFS_FR(r(4))
210 stfd f(27),104+OFS_FR(r(4))
211 stfd f(28),112+OFS_FR(r(4))
212 stfd f(29),120+OFS_FR(r(4))
213 stfd f(30),128+OFS_FR(r(4))
214 stfd f(31),136+OFS_FR(r(4))
215 stfd f(0), OFS_FPSCR(r(4))
218 #if defined(__ALTIVEC__)
219 /* ??? Determine when VRs not present. */
220 /* ??? Test r(3) for pr_hasNoVectorUpdate and skip the vr save.
221 This is not yet set by the compiler. */
222 addi r(5), r(4), OFS_VR
223 addi r(6), r(4), OFS_VR+16
247 streg r(0), OFS_VSCR(r(4))
250 CALL GTM_begin_transaction
252 ldreg r(0), LR_SAVE+FRAME(r(1))
254 addi r(1), r(1), FRAME
255 cfi_def_cfa_offset(0)
259 END _ITM_beginTransaction
265 #if defined(__ALTIVEC__) || defined(__VSX__)
266 /* ??? Determine when VRs not present. */
267 /* ??? Test r(5) for pr_hasNoVectorUpdate and skip the vr restore.
268 This is not yet set by the compiler. */
269 addi r(6), r(4), OFS_VR
270 addi r(7), r(4), OFS_VR+16
271 ldreg r(0), OFS_VSCR(r(4))
310 /* ??? Determine when FPRs not present. */
311 /* ??? Test r(5) for pr_hasNoFloatUpdate and skip the fp load.
312 This is not yet set by the compiler. */
313 lfd f(0), OFS_FPSCR(r(4))
332 lfd f(14), 0+OFS_FR(r(4))
333 lfd f(15), 8+OFS_FR(r(4))
334 lfd f(16), 16+OFS_FR(r(4))
335 lfd f(17), 24+OFS_FR(r(4))
336 lfd f(18), 32+OFS_FR(r(4))
337 lfd f(19), 40+OFS_FR(r(4))
338 lfd f(20), 48+OFS_FR(r(4))
339 lfd f(21), 56+OFS_FR(r(4))
340 lfd f(22), 64+OFS_FR(r(4))
341 lfd f(23), 72+OFS_FR(r(4))
342 lfd f(24), 80+OFS_FR(r(4))
343 lfd f(25), 88+OFS_FR(r(4))
344 lfd f(26), 96+OFS_FR(r(4))
345 lfd f(27),104+OFS_FR(r(4))
346 lfd f(28),112+OFS_FR(r(4))
347 lfd f(29),120+OFS_FR(r(4))
348 lfd f(30),128+OFS_FR(r(4))
349 lfd f(31),136+OFS_FR(r(4))
353 ldreg r(6), OFS_CFA(r(4))
354 ldreg r(0), OFS_LR(r(4))
356 ldreg r(13), OFS_TOC(r(4))
358 ldreg r(2), OFS_TOC(r(4))
360 ldreg r(7), OFS_CR(r(4))
361 /* At the instant we restore the LR, the only coherent view of
362 the world we have is into the new stack frame. Define the
363 CFA in terms of the not-yet-restored stack pointer. This will
364 last until the end of the function. */
386 ldreg r(14), 0*WS+OFS_GR(r(4))
387 ldreg r(15), 1*WS+OFS_GR(r(4))
388 ldreg r(16), 2*WS+OFS_GR(r(4))
389 ldreg r(17), 3*WS+OFS_GR(r(4))
390 ldreg r(18), 4*WS+OFS_GR(r(4))
391 ldreg r(19), 5*WS+OFS_GR(r(4))
392 ldreg r(20), 6*WS+OFS_GR(r(4))
393 ldreg r(21), 7*WS+OFS_GR(r(4))
394 ldreg r(22), 8*WS+OFS_GR(r(4))
395 ldreg r(23), 9*WS+OFS_GR(r(4))
396 ldreg r(24), 10*WS+OFS_GR(r(4))
397 ldreg r(25), 11*WS+OFS_GR(r(4))
398 ldreg r(26), 12*WS+OFS_GR(r(4))
399 ldreg r(27), 13*WS+OFS_GR(r(4))
400 ldreg r(28), 14*WS+OFS_GR(r(4))
401 ldreg r(29), 15*WS+OFS_GR(r(4))
402 ldreg r(30), 16*WS+OFS_GR(r(4))
403 ldreg r(31), 17*WS+OFS_GR(r(4))
410 .section .note.GNU-stack, "", @progbits