__longjmp.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
  2. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>.
  14. Note that __sigsetjmp() did NOT flush the register stack. Instead,
  15. we do it here since __longjmp() is usually much less frequently
  16. invoked than __sigsetjmp(). The only difficulty is that __sigsetjmp()
  17. didn't (and wouldn't be able to) save ar.rnat either. This is a problem
  18. because if we're not careful, we could end up loading random NaT bits.
  19. There are two cases:
  20. (i) ar.bsp < ia64_rse_rnat_addr(jmpbuf.ar_bsp)
  21. ar.rnat contains the desired bits---preserve ar.rnat
  22. across loadrs and write to ar.bspstore
  23. (ii) ar.bsp >= ia64_rse_rnat_addr(jmpbuf.ar_bsp)
  24. The desired ar.rnat is stored in
  25. ia64_rse_rnat_addr(jmpbuf.ar_bsp). Load those
  26. bits into ar.rnat after setting ar.bspstore. */
  27. #include "sysdep.h"
  28. #include <features.h>
  29. # define pPos p6 /* is rotate count positive? */
  30. # define pNeg p7 /* is rotate count negative? */
  31. /* __longjmp(__jmp_buf buf, int val) */
  32. LEAF(__longjmp)
  33. alloc r8=ar.pfs,2,1,0,0
  34. mov r27=ar.rsc
  35. add r2=0x98,in0 /* r2 <- &jmpbuf.orig_jmp_buf_addr */
  36. ;;
  37. ld8 r8=[r2],-16 /* r8 <- orig_jmp_buf_addr */
  38. mov r10=ar.bsp
  39. and r11=~0x3,r27 /* clear ar.rsc.mode */
  40. ;;
  41. flushrs /* flush dirty regs to backing store (must be first in insn grp) */
  42. ld8 r23=[r2],8 /* r23 <- jmpbuf.ar_bsp */
  43. sub r8=r8,in0 /* r8 <- &orig_jmpbuf - &jmpbuf */
  44. ;;
  45. ld8 r25=[r2] /* r25 <- jmpbuf.ar_unat */
  46. extr.u r8=r8,3,6 /* r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f */
  47. ;;
  48. cmp.lt pNeg,pPos=r8,r0
  49. mov r2=in0
  50. ;;
  51. (pPos) mov r16=r8
  52. (pNeg) add r16=64,r8
  53. (pPos) sub r17=64,r8
  54. (pNeg) sub r17=r0,r8
  55. ;;
  56. mov ar.rsc=r11 /* put RSE in enforced lazy mode */
  57. shr.u r8=r25,r16
  58. add r3=8,in0 /* r3 <- &jmpbuf.r1 */
  59. shl r9=r25,r17
  60. ;;
  61. or r25=r8,r9
  62. ;;
  63. mov r26=ar.rnat
  64. mov ar.unat=r25 /* setup ar.unat (NaT bits for r1, r4-r7, and r12) */
  65. ;;
  66. ld8.fill.nta sp=[r2],16 /* r12 (sp) */
  67. ld8.fill.nta gp=[r3],16 /* r1 (gp) */
  68. dep r11=-1,r23,3,6 /* r11 <- ia64_rse_rnat_addr(jmpbuf.ar_bsp) */
  69. ;;
  70. ld8.nta r16=[r2],16 /* caller's unat */
  71. ld8.nta r17=[r3],16 /* fpsr */
  72. ;;
  73. ld8.fill.nta r4=[r2],16 /* r4 */
  74. ld8.fill.nta r5=[r3],16 /* r5 (gp) */
  75. cmp.geu p8,p0=r10,r11 /* p8 <- (ar.bsp >= jmpbuf.ar_bsp) */
  76. ;;
  77. ld8.fill.nta r6=[r2],16 /* r6 */
  78. ld8.fill.nta r7=[r3],16 /* r7 */
  79. ;;
  80. mov ar.unat=r16 /* restore caller's unat */
  81. mov ar.fpsr=r17 /* restore fpsr */
  82. ;;
  83. ld8.nta r16=[r2],16 /* b0 */
  84. ld8.nta r17=[r3],16 /* b1 */
  85. ;;
  86. (p8) ld8 r26=[r11] /* r26 <- *ia64_rse_rnat_addr(jmpbuf.ar_bsp) */
  87. mov ar.bspstore=r23 /* restore ar.bspstore */
  88. ;;
  89. ld8.nta r18=[r2],16 /* b2 */
  90. ld8.nta r19=[r3],16 /* b3 */
  91. ;;
  92. ld8.nta r20=[r2],16 /* b4 */
  93. ld8.nta r21=[r3],16 /* b5 */
  94. ;;
  95. ld8.nta r11=[r2],16 /* ar.pfs */
  96. ld8.nta r22=[r3],56 /* ar.lc */
  97. ;;
  98. ld8.nta r24=[r2],32 /* pr */
  99. mov b0=r16
  100. ;;
  101. ldf.fill.nta f2=[r2],32
  102. ldf.fill.nta f3=[r3],32
  103. mov b1=r17
  104. ;;
  105. ldf.fill.nta f4=[r2],32
  106. ldf.fill.nta f5=[r3],32
  107. mov b2=r18
  108. ;;
  109. ldf.fill.nta f16=[r2],32
  110. ldf.fill.nta f17=[r3],32
  111. mov b3=r19
  112. ;;
  113. ldf.fill.nta f18=[r2],32
  114. ldf.fill.nta f19=[r3],32
  115. mov b4=r20
  116. ;;
  117. ldf.fill.nta f20=[r2],32
  118. ldf.fill.nta f21=[r3],32
  119. mov b5=r21
  120. ;;
  121. ldf.fill.nta f22=[r2],32
  122. ldf.fill.nta f23=[r3],32
  123. mov ar.lc=r22
  124. ;;
  125. ldf.fill.nta f24=[r2],32
  126. ldf.fill.nta f25=[r3],32
  127. cmp.eq p8,p9=0,in1
  128. ;;
  129. ldf.fill.nta f26=[r2],32
  130. ldf.fill.nta f27=[r3],32
  131. mov ar.pfs=r11
  132. ;;
  133. ldf.fill.nta f28=[r2],32
  134. ldf.fill.nta f29=[r3],32
  135. ;;
  136. ldf.fill.nta f30=[r2]
  137. ldf.fill.nta f31=[r3]
  138. (p8) mov r8=1
  139. mov ar.rnat=r26 /* restore ar.rnat */
  140. ;;
  141. mov ar.rsc=r27 /* restore ar.rsc */
  142. (p9) mov r8=in1
  143. invala /* virt. -> phys. regnum mapping may change */
  144. mov pr=r24,-1
  145. ret
  146. END(__longjmp)
  147. libc_hidden_def(__longjmp)