1 /* Copyright (C) 2012-2015 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__) && _CALL_ELF == 2
32 .type \name, @function
34 0: addis 2,12,(.TOC.-0b)@ha
36 .localentry \name, . - \name
39 .size \name, . - \name
48 #elif defined(__powerpc64__) && defined(__ELF__)
54 .quad .\name, .TOC.@tocbase, 0
56 .type .\name, @function
61 .size .\name, . - .\name
70 #elif defined(__ELF__)
73 .type \name, @function
77 .size \name, . - \name
85 #elif defined(_CALL_DARWIN)
104 #error "unsupported system"
107 /* Parameterize the naming of registers. */
112 #elif defined(__MACH__)
122 /* Parameterize the code for 32-bit vs 64-bit. */
123 #if defined(__powerpc64__) || defined(__ppc64__)
135 /* Parameterize the code for call frame constants. */
136 #if defined(_CALL_AIXDESC)
138 # define LR_SAVE 2*WS
141 # define LR_SAVE 2*WS
142 #elif defined(_CALL_SYSV)
144 # define LR_SAVE 1*WS
145 #elif defined(_CALL_DARWIN)
146 # define BASE (6*WS + 2*WS)
147 # define LR_SAVE 2*WS
149 # error "unsupported system"
152 #if defined(__ALTIVEC__) || defined(__VSX__)
154 # define OFS_VSCR 12*16
155 # define OFS_VR_END OFS_VSCR + 8
157 # define OFS_VR_END 0
160 # define OFS_FR OFS_VR_END
161 # define OFS_FPSCR OFS_FR + 18*8
162 # define OFS_FR_END OFS_FPSCR + 8
164 # define OFS_FR_END OFS_VR_END
166 #define OFS_GR OFS_FR_END
167 #define OFS_CFA OFS_GR + 18*WS
168 #define OFS_LR OFS_CFA + WS
169 #define OFS_TOC OFS_LR + WS
170 #define OFS_CR OFS_TOC + WS
171 #define OFS_END (((OFS_CR + WS + 15) / 16) * 16)
173 #define FRAME (((BASE + OFS_END + 15) / 16) * 16)
177 FUNC _ITM_beginTransaction
181 addi r(4), r(1), -OFS_END
183 streg r(0), LR_SAVE(r(1))
184 stregu r(1), -FRAME(r(1))
185 cfi_def_cfa_offset(FRAME)
186 cfi_offset(65, LR_SAVE)
187 streg r(6), OFS_CFA(r(4))
188 streg r(0), OFS_LR(r(4))
190 streg r(13), OFS_TOC(r(4))
192 streg r(2), OFS_TOC(r(4))
194 streg r(5), OFS_CR(r(4))
195 streg r(14), 0*WS+OFS_GR(r(4))
196 streg r(15), 1*WS+OFS_GR(r(4))
197 streg r(16), 2*WS+OFS_GR(r(4))
198 streg r(17), 3*WS+OFS_GR(r(4))
199 streg r(18), 4*WS+OFS_GR(r(4))
200 streg r(19), 5*WS+OFS_GR(r(4))
201 streg r(20), 6*WS+OFS_GR(r(4))
202 streg r(21), 7*WS+OFS_GR(r(4))
203 streg r(22), 8*WS+OFS_GR(r(4))
204 streg r(23), 9*WS+OFS_GR(r(4))
205 streg r(24), 10*WS+OFS_GR(r(4))
206 streg r(25), 11*WS+OFS_GR(r(4))
207 streg r(26), 12*WS+OFS_GR(r(4))
208 streg r(27), 13*WS+OFS_GR(r(4))
209 streg r(28), 14*WS+OFS_GR(r(4))
210 streg r(29), 15*WS+OFS_GR(r(4))
211 streg r(30), 16*WS+OFS_GR(r(4))
212 streg r(31), 17*WS+OFS_GR(r(4))
215 /* ??? Determine when FPRs not present. */
216 /* ??? Test r(3) for pr_hasNoFloatUpdate and skip the fp save.
217 This is not yet set by the compiler. */
219 stfd f(14), 0+OFS_FR(r(4))
220 stfd f(15), 8+OFS_FR(r(4))
221 stfd f(16), 16+OFS_FR(r(4))
222 stfd f(17), 24+OFS_FR(r(4))
223 stfd f(18), 32+OFS_FR(r(4))
224 stfd f(19), 40+OFS_FR(r(4))
225 stfd f(20), 48+OFS_FR(r(4))
226 stfd f(21), 56+OFS_FR(r(4))
227 stfd f(22), 64+OFS_FR(r(4))
228 stfd f(23), 72+OFS_FR(r(4))
229 stfd f(24), 80+OFS_FR(r(4))
230 stfd f(25), 88+OFS_FR(r(4))
231 stfd f(26), 96+OFS_FR(r(4))
232 stfd f(27),104+OFS_FR(r(4))
233 stfd f(28),112+OFS_FR(r(4))
234 stfd f(29),120+OFS_FR(r(4))
235 stfd f(30),128+OFS_FR(r(4))
236 stfd f(31),136+OFS_FR(r(4))
237 stfd f(0), OFS_FPSCR(r(4))
240 #if defined(__ALTIVEC__)
241 /* ??? Determine when VRs not present. */
242 /* ??? Test r(3) for pr_hasNoVectorUpdate and skip the vr save.
243 This is not yet set by the compiler. */
244 addi r(5), r(4), OFS_VR
245 addi r(6), r(4), OFS_VR+16
269 streg r(0), OFS_VSCR(r(4))
272 CALL GTM_begin_transaction
274 ldreg r(0), LR_SAVE+FRAME(r(1))
276 addi r(1), r(1), FRAME
277 cfi_def_cfa_offset(0)
281 END _ITM_beginTransaction
287 #if defined(__ALTIVEC__) || defined(__VSX__)
288 /* ??? Determine when VRs not present. */
289 /* ??? Test r(5) for pr_hasNoVectorUpdate and skip the vr restore.
290 This is not yet set by the compiler. */
291 addi r(6), r(4), OFS_VR
292 addi r(7), r(4), OFS_VR+16
293 ldreg r(0), OFS_VSCR(r(4))
332 /* ??? Determine when FPRs not present. */
333 /* ??? Test r(5) for pr_hasNoFloatUpdate and skip the fp load.
334 This is not yet set by the compiler. */
335 lfd f(0), OFS_FPSCR(r(4))
354 lfd f(14), 0+OFS_FR(r(4))
355 lfd f(15), 8+OFS_FR(r(4))
356 lfd f(16), 16+OFS_FR(r(4))
357 lfd f(17), 24+OFS_FR(r(4))
358 lfd f(18), 32+OFS_FR(r(4))
359 lfd f(19), 40+OFS_FR(r(4))
360 lfd f(20), 48+OFS_FR(r(4))
361 lfd f(21), 56+OFS_FR(r(4))
362 lfd f(22), 64+OFS_FR(r(4))
363 lfd f(23), 72+OFS_FR(r(4))
364 lfd f(24), 80+OFS_FR(r(4))
365 lfd f(25), 88+OFS_FR(r(4))
366 lfd f(26), 96+OFS_FR(r(4))
367 lfd f(27),104+OFS_FR(r(4))
368 lfd f(28),112+OFS_FR(r(4))
369 lfd f(29),120+OFS_FR(r(4))
370 lfd f(30),128+OFS_FR(r(4))
371 lfd f(31),136+OFS_FR(r(4))
375 ldreg r(6), OFS_CFA(r(4))
376 ldreg r(0), OFS_LR(r(4))
378 ldreg r(13), OFS_TOC(r(4))
380 ldreg r(2), OFS_TOC(r(4))
382 ldreg r(7), OFS_CR(r(4))
383 /* At the instant we restore the LR, the only coherent view of
384 the world we have is into the new stack frame. Define the
385 CFA in terms of the not-yet-restored stack pointer. This will
386 last until the end of the function. */
408 ldreg r(14), 0*WS+OFS_GR(r(4))
409 ldreg r(15), 1*WS+OFS_GR(r(4))
410 ldreg r(16), 2*WS+OFS_GR(r(4))
411 ldreg r(17), 3*WS+OFS_GR(r(4))
412 ldreg r(18), 4*WS+OFS_GR(r(4))
413 ldreg r(19), 5*WS+OFS_GR(r(4))
414 ldreg r(20), 6*WS+OFS_GR(r(4))
415 ldreg r(21), 7*WS+OFS_GR(r(4))
416 ldreg r(22), 8*WS+OFS_GR(r(4))
417 ldreg r(23), 9*WS+OFS_GR(r(4))
418 ldreg r(24), 10*WS+OFS_GR(r(4))
419 ldreg r(25), 11*WS+OFS_GR(r(4))
420 ldreg r(26), 12*WS+OFS_GR(r(4))
421 ldreg r(27), 13*WS+OFS_GR(r(4))
422 ldreg r(28), 14*WS+OFS_GR(r(4))
423 ldreg r(29), 15*WS+OFS_GR(r(4))
424 ldreg r(30), 16*WS+OFS_GR(r(4))
425 ldreg r(31), 17*WS+OFS_GR(r(4))
432 .section .note.GNU-stack, "", @progbits