sjlj.S 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. /* Copyright (C) 2012-2015 Free Software Foundation, Inc.
  2. Contributed by Richard Henderson <rth@redhat.com>.
  3. This file is part of the GNU Transactional Memory Library (libitm).
  4. Libitm is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. .text
  20. #include "asmcfi.h"
  21. #if defined(__powerpc64__) && _CALL_ELF == 2
  22. .macro FUNC name
  23. .globl \name
  24. .type \name, @function
  25. \name:
  26. 0: addis 2,12,(.TOC.-0b)@ha
  27. addi 2,2,(.TOC.-0b)@l
  28. .localentry \name, . - \name
  29. .endm
  30. .macro END name
  31. .size \name, . - \name
  32. .endm
  33. .macro HIDDEN name
  34. .hidden \name
  35. .endm
  36. .macro CALL name
  37. bl \name
  38. nop
  39. .endm
  40. #elif defined(__powerpc64__) && defined(__ELF__)
  41. .macro FUNC name
  42. .globl \name, .\name
  43. .section ".opd","aw"
  44. .align 3
  45. \name:
  46. .quad .\name, .TOC.@tocbase, 0
  47. .size \name, 24
  48. .type .\name, @function
  49. .text
  50. .\name:
  51. .endm
  52. .macro END name
  53. .size .\name, . - .\name
  54. .endm
  55. .macro HIDDEN name
  56. .hidden \name, .\name
  57. .endm
  58. .macro CALL name
  59. bl \name
  60. nop
  61. .endm
  62. #elif defined(__ELF__)
  63. .macro FUNC name
  64. .globl \name
  65. .type \name, @function
  66. \name:
  67. .endm
  68. .macro END name
  69. .size \name, . - \name
  70. .endm
  71. .macro HIDDEN name
  72. .hidden \name
  73. .endm
  74. .macro CALL name
  75. bl \name
  76. .endm
  77. #elif defined(_CALL_DARWIN)
  78. .macro FUNC
  79. .globl _$0
  80. _$0:
  81. .endmacro
  82. .macro END
  83. .endmacro
  84. .macro HIDDEN
  85. .private_extern _$0
  86. .endmacro
  87. .macro CALL
  88. bl _$0
  89. .endmacro
  90. # ifdef __ppc64__
  91. .machine ppc64
  92. # else
  93. .machine ppc7400
  94. # endif
  95. #else
  96. #error "unsupported system"
  97. #endif
  98. /* Parameterize the naming of registers. */
  99. #if defined(__ELF__)
  100. # define r(N) %r##N
  101. # define f(N) %f##N
  102. # define v(N) %v##N
  103. #elif defined(__MACH__)
  104. # define r(N) r##N
  105. # define f(N) f##N
  106. # define v(N) v##N
  107. #else
  108. # define r(N) N
  109. # define f(N) N
  110. # define v(N) N
  111. #endif
  112. /* Parameterize the code for 32-bit vs 64-bit. */
  113. #if defined(__powerpc64__) || defined(__ppc64__)
  114. #define ldreg ld
  115. #define streg std
  116. #define stregu stdu
  117. #define WS 8
  118. #else
  119. #define ldreg lwz
  120. #define streg stw
  121. #define stregu stwu
  122. #define WS 4
  123. #endif
  124. /* Parameterize the code for call frame constants. */
  125. #if defined(_CALL_AIXDESC)
  126. # define BASE 6*WS
  127. # define LR_SAVE 2*WS
  128. #elif _CALL_ELF == 2
  129. # define BASE 6*WS
  130. # define LR_SAVE 2*WS
  131. #elif defined(_CALL_SYSV)
  132. # define BASE 2*WS
  133. # define LR_SAVE 1*WS
  134. #elif defined(_CALL_DARWIN)
  135. # define BASE (6*WS + 2*WS)
  136. # define LR_SAVE 2*WS
  137. #else
  138. # error "unsupported system"
  139. #endif
  140. #if defined(__ALTIVEC__) || defined(__VSX__)
  141. # define OFS_VR 0
  142. # define OFS_VSCR 12*16
  143. # define OFS_VR_END OFS_VSCR + 8
  144. #else
  145. # define OFS_VR_END 0
  146. #endif
  147. #ifndef _SOFT_FLOAT
  148. # define OFS_FR OFS_VR_END
  149. # define OFS_FPSCR OFS_FR + 18*8
  150. # define OFS_FR_END OFS_FPSCR + 8
  151. #else
  152. # define OFS_FR_END OFS_VR_END
  153. #endif
  154. #define OFS_GR OFS_FR_END
  155. #define OFS_CFA OFS_GR + 18*WS
  156. #define OFS_LR OFS_CFA + WS
  157. #define OFS_TOC OFS_LR + WS
  158. #define OFS_CR OFS_TOC + WS
  159. #define OFS_END (((OFS_CR + WS + 15) / 16) * 16)
  160. #define FRAME (((BASE + OFS_END + 15) / 16) * 16)
  161. #define VRSAVE 256
  162. .align 4
  163. FUNC _ITM_beginTransaction
  164. cfi_startproc
  165. mflr r(0)
  166. mfcr r(5)
  167. addi r(4), r(1), -OFS_END
  168. mr r(6), r(1)
  169. streg r(0), LR_SAVE(r(1))
  170. stregu r(1), -FRAME(r(1))
  171. cfi_def_cfa_offset(FRAME)
  172. cfi_offset(65, LR_SAVE)
  173. streg r(6), OFS_CFA(r(4))
  174. streg r(0), OFS_LR(r(4))
  175. #ifdef _CALL_DARWIN
  176. streg r(13), OFS_TOC(r(4))
  177. #else
  178. streg r(2), OFS_TOC(r(4))
  179. #endif
  180. streg r(5), OFS_CR(r(4))
  181. streg r(14), 0*WS+OFS_GR(r(4))
  182. streg r(15), 1*WS+OFS_GR(r(4))
  183. streg r(16), 2*WS+OFS_GR(r(4))
  184. streg r(17), 3*WS+OFS_GR(r(4))
  185. streg r(18), 4*WS+OFS_GR(r(4))
  186. streg r(19), 5*WS+OFS_GR(r(4))
  187. streg r(20), 6*WS+OFS_GR(r(4))
  188. streg r(21), 7*WS+OFS_GR(r(4))
  189. streg r(22), 8*WS+OFS_GR(r(4))
  190. streg r(23), 9*WS+OFS_GR(r(4))
  191. streg r(24), 10*WS+OFS_GR(r(4))
  192. streg r(25), 11*WS+OFS_GR(r(4))
  193. streg r(26), 12*WS+OFS_GR(r(4))
  194. streg r(27), 13*WS+OFS_GR(r(4))
  195. streg r(28), 14*WS+OFS_GR(r(4))
  196. streg r(29), 15*WS+OFS_GR(r(4))
  197. streg r(30), 16*WS+OFS_GR(r(4))
  198. streg r(31), 17*WS+OFS_GR(r(4))
  199. #ifndef _SOFT_FLOAT
  200. /* ??? Determine when FPRs not present. */
  201. /* ??? Test r(3) for pr_hasNoFloatUpdate and skip the fp save.
  202. This is not yet set by the compiler. */
  203. mffs f(0)
  204. stfd f(14), 0+OFS_FR(r(4))
  205. stfd f(15), 8+OFS_FR(r(4))
  206. stfd f(16), 16+OFS_FR(r(4))
  207. stfd f(17), 24+OFS_FR(r(4))
  208. stfd f(18), 32+OFS_FR(r(4))
  209. stfd f(19), 40+OFS_FR(r(4))
  210. stfd f(20), 48+OFS_FR(r(4))
  211. stfd f(21), 56+OFS_FR(r(4))
  212. stfd f(22), 64+OFS_FR(r(4))
  213. stfd f(23), 72+OFS_FR(r(4))
  214. stfd f(24), 80+OFS_FR(r(4))
  215. stfd f(25), 88+OFS_FR(r(4))
  216. stfd f(26), 96+OFS_FR(r(4))
  217. stfd f(27),104+OFS_FR(r(4))
  218. stfd f(28),112+OFS_FR(r(4))
  219. stfd f(29),120+OFS_FR(r(4))
  220. stfd f(30),128+OFS_FR(r(4))
  221. stfd f(31),136+OFS_FR(r(4))
  222. stfd f(0), OFS_FPSCR(r(4))
  223. #endif
  224. #if defined(__ALTIVEC__)
  225. /* ??? Determine when VRs not present. */
  226. /* ??? Test r(3) for pr_hasNoVectorUpdate and skip the vr save.
  227. This is not yet set by the compiler. */
  228. addi r(5), r(4), OFS_VR
  229. addi r(6), r(4), OFS_VR+16
  230. mfspr r(0), VRSAVE
  231. stvx v(20), 0, r(5)
  232. addi r(5), r(5), 32
  233. stvx v(21), 0, r(6)
  234. addi r(6), r(6), 32
  235. stvx v(22), 0, r(5)
  236. addi r(5), r(5), 32
  237. stvx v(23), 0, r(6)
  238. addi r(6), r(6), 32
  239. stvx v(25), 0, r(5)
  240. addi r(5), r(5), 32
  241. stvx v(26), 0, r(6)
  242. addi r(6), r(6), 32
  243. stvx v(26), 0, r(5)
  244. addi r(5), r(5), 32
  245. stvx v(27), 0, r(6)
  246. addi r(6), r(6), 32
  247. stvx v(28), 0, r(5)
  248. addi r(5), r(5), 32
  249. stvx v(29), 0, r(6)
  250. addi r(6), r(6), 32
  251. stvx v(30), 0, r(5)
  252. stvx v(31), 0, r(6)
  253. streg r(0), OFS_VSCR(r(4))
  254. #endif
  255. CALL GTM_begin_transaction
  256. ldreg r(0), LR_SAVE+FRAME(r(1))
  257. mtlr r(0)
  258. addi r(1), r(1), FRAME
  259. cfi_def_cfa_offset(0)
  260. cfi_restore(65)
  261. blr
  262. cfi_endproc
  263. END _ITM_beginTransaction
  264. .align 4
  265. HIDDEN GTM_longjmp
  266. FUNC GTM_longjmp
  267. cfi_startproc
  268. #if defined(__ALTIVEC__) || defined(__VSX__)
  269. /* ??? Determine when VRs not present. */
  270. /* ??? Test r(5) for pr_hasNoVectorUpdate and skip the vr restore.
  271. This is not yet set by the compiler. */
  272. addi r(6), r(4), OFS_VR
  273. addi r(7), r(4), OFS_VR+16
  274. ldreg r(0), OFS_VSCR(r(4))
  275. cfi_undefined(v(20))
  276. cfi_undefined(v(21))
  277. cfi_undefined(v(22))
  278. cfi_undefined(v(23))
  279. cfi_undefined(v(24))
  280. cfi_undefined(v(25))
  281. cfi_undefined(v(26))
  282. cfi_undefined(v(27))
  283. cfi_undefined(v(28))
  284. cfi_undefined(v(29))
  285. cfi_undefined(v(30))
  286. cfi_undefined(v(31))
  287. lvx v(20), 0, r(6)
  288. addi r(6), r(6), 32
  289. lvx v(21), 0, r(7)
  290. addi r(7), r(7), 32
  291. lvx v(22), 0, r(6)
  292. addi r(6), r(6), 32
  293. lvx v(23), 0, r(7)
  294. addi r(7), r(7), 32
  295. lvx v(24), 0, r(6)
  296. addi r(6), r(6), 32
  297. lvx v(25), 0, r(7)
  298. addi r(7), r(7), 32
  299. lvx v(26), 0, r(6)
  300. addi r(6), r(6), 32
  301. lvx v(27), 0, r(7)
  302. addi r(7), r(7), 32
  303. lvx v(28), 0, r(6)
  304. addi r(6), r(6), 32
  305. lvx v(29), 0, r(7)
  306. addi r(7), r(7), 32
  307. lvx v(30), 0, r(6)
  308. lvx v(31), 0, r(7)
  309. mtspr VRSAVE, r(0)
  310. #endif
  311. #ifndef _SOFT_FLOAT
  312. /* ??? Determine when FPRs not present. */
  313. /* ??? Test r(5) for pr_hasNoFloatUpdate and skip the fp load.
  314. This is not yet set by the compiler. */
  315. lfd f(0), OFS_FPSCR(r(4))
  316. cfi_undefined(f(14))
  317. cfi_undefined(f(15))
  318. cfi_undefined(f(16))
  319. cfi_undefined(f(17))
  320. cfi_undefined(f(18))
  321. cfi_undefined(f(19))
  322. cfi_undefined(f(20))
  323. cfi_undefined(f(21))
  324. cfi_undefined(f(22))
  325. cfi_undefined(f(23))
  326. cfi_undefined(f(24))
  327. cfi_undefined(f(25))
  328. cfi_undefined(f(26))
  329. cfi_undefined(f(27))
  330. cfi_undefined(f(28))
  331. cfi_undefined(f(29))
  332. cfi_undefined(f(30))
  333. cfi_undefined(f(31))
  334. lfd f(14), 0+OFS_FR(r(4))
  335. lfd f(15), 8+OFS_FR(r(4))
  336. lfd f(16), 16+OFS_FR(r(4))
  337. lfd f(17), 24+OFS_FR(r(4))
  338. lfd f(18), 32+OFS_FR(r(4))
  339. lfd f(19), 40+OFS_FR(r(4))
  340. lfd f(20), 48+OFS_FR(r(4))
  341. lfd f(21), 56+OFS_FR(r(4))
  342. lfd f(22), 64+OFS_FR(r(4))
  343. lfd f(23), 72+OFS_FR(r(4))
  344. lfd f(24), 80+OFS_FR(r(4))
  345. lfd f(25), 88+OFS_FR(r(4))
  346. lfd f(26), 96+OFS_FR(r(4))
  347. lfd f(27),104+OFS_FR(r(4))
  348. lfd f(28),112+OFS_FR(r(4))
  349. lfd f(29),120+OFS_FR(r(4))
  350. lfd f(30),128+OFS_FR(r(4))
  351. lfd f(31),136+OFS_FR(r(4))
  352. mtfsf 0xff, f(0)
  353. #endif
  354. ldreg r(6), OFS_CFA(r(4))
  355. ldreg r(0), OFS_LR(r(4))
  356. #ifdef _CALL_DARWIN
  357. ldreg r(13), OFS_TOC(r(4))
  358. #else
  359. ldreg r(2), OFS_TOC(r(4))
  360. #endif
  361. ldreg r(7), OFS_CR(r(4))
  362. /* At the instant we restore the LR, the only coherent view of
  363. the world we have is into the new stack frame. Define the
  364. CFA in terms of the not-yet-restored stack pointer. This will
  365. last until the end of the function. */
  366. mtlr r(0)
  367. cfi_def_cfa(r(6), 0)
  368. cfi_undefined(r(14))
  369. cfi_undefined(r(15))
  370. cfi_undefined(r(16))
  371. cfi_undefined(r(17))
  372. cfi_undefined(r(18))
  373. cfi_undefined(r(19))
  374. cfi_undefined(r(20))
  375. cfi_undefined(r(21))
  376. cfi_undefined(r(22))
  377. cfi_undefined(r(23))
  378. cfi_undefined(r(24))
  379. cfi_undefined(r(25))
  380. cfi_undefined(r(26))
  381. cfi_undefined(r(27))
  382. cfi_undefined(r(28))
  383. cfi_undefined(r(29))
  384. cfi_undefined(r(30))
  385. cfi_undefined(r(31))
  386. mtcr r(7)
  387. ldreg r(14), 0*WS+OFS_GR(r(4))
  388. ldreg r(15), 1*WS+OFS_GR(r(4))
  389. ldreg r(16), 2*WS+OFS_GR(r(4))
  390. ldreg r(17), 3*WS+OFS_GR(r(4))
  391. ldreg r(18), 4*WS+OFS_GR(r(4))
  392. ldreg r(19), 5*WS+OFS_GR(r(4))
  393. ldreg r(20), 6*WS+OFS_GR(r(4))
  394. ldreg r(21), 7*WS+OFS_GR(r(4))
  395. ldreg r(22), 8*WS+OFS_GR(r(4))
  396. ldreg r(23), 9*WS+OFS_GR(r(4))
  397. ldreg r(24), 10*WS+OFS_GR(r(4))
  398. ldreg r(25), 11*WS+OFS_GR(r(4))
  399. ldreg r(26), 12*WS+OFS_GR(r(4))
  400. ldreg r(27), 13*WS+OFS_GR(r(4))
  401. ldreg r(28), 14*WS+OFS_GR(r(4))
  402. ldreg r(29), 15*WS+OFS_GR(r(4))
  403. ldreg r(30), 16*WS+OFS_GR(r(4))
  404. ldreg r(31), 17*WS+OFS_GR(r(4))
  405. mr r(1), r(6)
  406. blr
  407. cfi_endproc
  408. END GTM_longjmp
  409. #ifdef __linux__
  410. .section .note.GNU-stack, "", @progbits
  411. #endif