__longjmp.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA.
  15. Note that __sigsetjmp() did NOT flush the register stack. Instead,
  16. we do it here since __longjmp() is usually much less frequently
  17. invoked than __sigsetjmp(). The only difficulty is that __sigsetjmp()
  18. didn't (and wouldn't be able to) save ar.rnat either. This is a problem
  19. because if we're not careful, we could end up loading random NaT bits.
  20. There are two cases:
  21. (i) ar.bsp < ia64_rse_rnat_addr(jmpbuf.ar_bsp)
  22. ar.rnat contains the desired bits---preserve ar.rnat
  23. across loadrs and write to ar.bspstore
  24. (ii) ar.bsp >= ia64_rse_rnat_addr(jmpbuf.ar_bsp)
  25. The desired ar.rnat is stored in
  26. ia64_rse_rnat_addr(jmpbuf.ar_bsp). Load those
  27. bits into ar.rnat after setting ar.bspstore. */
  28. #include "sysdep.h"
  29. #include <features.h>
  30. # define pPos p6 /* is rotate count positive? */
  31. # define pNeg p7 /* is rotate count negative? */
  32. /* __longjmp(__jmp_buf buf, int val) */
  33. LEAF(__longjmp)
  34. alloc r8=ar.pfs,2,1,0,0
  35. mov r27=ar.rsc
  36. add r2=0x98,in0 // r2 <- &jmpbuf.orig_jmp_buf_addr
  37. ;;
  38. ld8 r8=[r2],-16 // r8 <- orig_jmp_buf_addr
  39. mov r10=ar.bsp
  40. and r11=~0x3,r27 // clear ar.rsc.mode
  41. ;;
  42. flushrs // flush dirty regs to backing store (must be first in insn grp)
  43. ld8 r23=[r2],8 // r23 <- jmpbuf.ar_bsp
  44. sub r8=r8,in0 // r8 <- &orig_jmpbuf - &jmpbuf
  45. ;;
  46. ld8 r25=[r2] // r25 <- jmpbuf.ar_unat
  47. extr.u r8=r8,3,6 // r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f
  48. ;;
  49. cmp.lt pNeg,pPos=r8,r0
  50. mov r2=in0
  51. ;;
  52. (pPos) mov r16=r8
  53. (pNeg) add r16=64,r8
  54. (pPos) sub r17=64,r8
  55. (pNeg) sub r17=r0,r8
  56. ;;
  57. mov ar.rsc=r11 // put RSE in enforced lazy mode
  58. shr.u r8=r25,r16
  59. add r3=8,in0 // r3 <- &jmpbuf.r1
  60. shl r9=r25,r17
  61. ;;
  62. or r25=r8,r9
  63. ;;
  64. mov r26=ar.rnat
  65. mov ar.unat=r25 // setup ar.unat (NaT bits for r1, r4-r7, and r12)
  66. ;;
  67. ld8.fill.nta sp=[r2],16 // r12 (sp)
  68. ld8.fill.nta gp=[r3],16 // r1 (gp)
  69. dep r11=-1,r23,3,6 // r11 <- ia64_rse_rnat_addr(jmpbuf.ar_bsp)
  70. ;;
  71. ld8.nta r16=[r2],16 // caller's unat
  72. ld8.nta r17=[r3],16 // fpsr
  73. ;;
  74. ld8.fill.nta r4=[r2],16 // r4
  75. ld8.fill.nta r5=[r3],16 // r5 (gp)
  76. cmp.geu p8,p0=r10,r11 // p8 <- (ar.bsp >= jmpbuf.ar_bsp)
  77. ;;
  78. ld8.fill.nta r6=[r2],16 // r6
  79. ld8.fill.nta r7=[r3],16 // r7
  80. ;;
  81. mov ar.unat=r16 // restore caller's unat
  82. mov ar.fpsr=r17 // restore fpsr
  83. ;;
  84. ld8.nta r16=[r2],16 // b0
  85. ld8.nta r17=[r3],16 // b1
  86. ;;
  87. (p8) ld8 r26=[r11] // r26 <- *ia64_rse_rnat_addr(jmpbuf.ar_bsp)
  88. mov ar.bspstore=r23 // restore ar.bspstore
  89. ;;
  90. ld8.nta r18=[r2],16 // b2
  91. ld8.nta r19=[r3],16 // b3
  92. ;;
  93. ld8.nta r20=[r2],16 // b4
  94. ld8.nta r21=[r3],16 // b5
  95. ;;
  96. ld8.nta r11=[r2],16 // ar.pfs
  97. ld8.nta r22=[r3],56 // ar.lc
  98. ;;
  99. ld8.nta r24=[r2],32 // pr
  100. mov b0=r16
  101. ;;
  102. ldf.fill.nta f2=[r2],32
  103. ldf.fill.nta f3=[r3],32
  104. mov b1=r17
  105. ;;
  106. ldf.fill.nta f4=[r2],32
  107. ldf.fill.nta f5=[r3],32
  108. mov b2=r18
  109. ;;
  110. ldf.fill.nta f16=[r2],32
  111. ldf.fill.nta f17=[r3],32
  112. mov b3=r19
  113. ;;
  114. ldf.fill.nta f18=[r2],32
  115. ldf.fill.nta f19=[r3],32
  116. mov b4=r20
  117. ;;
  118. ldf.fill.nta f20=[r2],32
  119. ldf.fill.nta f21=[r3],32
  120. mov b5=r21
  121. ;;
  122. ldf.fill.nta f22=[r2],32
  123. ldf.fill.nta f23=[r3],32
  124. mov ar.lc=r22
  125. ;;
  126. ldf.fill.nta f24=[r2],32
  127. ldf.fill.nta f25=[r3],32
  128. cmp.eq p8,p9=0,in1
  129. ;;
  130. ldf.fill.nta f26=[r2],32
  131. ldf.fill.nta f27=[r3],32
  132. mov ar.pfs=r11
  133. ;;
  134. ldf.fill.nta f28=[r2],32
  135. ldf.fill.nta f29=[r3],32
  136. ;;
  137. ldf.fill.nta f30=[r2]
  138. ldf.fill.nta f31=[r3]
  139. (p8) mov r8=1
  140. mov ar.rnat=r26 // restore ar.rnat
  141. ;;
  142. mov ar.rsc=r27 // restore ar.rsc
  143. (p9) mov r8=in1
  144. invala // virt. -> phys. regnum mapping may change
  145. mov pr=r24,-1
  146. ret
  147. END(__longjmp)