longjmp.S 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* longjmp for SH-5.
  2. Copyright (C) 1999, 2000 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #define _SETJMP_H
  17. #define _ASM
  18. #include <bits/setjmp.h>
  19. #define INTEGER(reg,offset) ld.q r2, offset*8, reg
  20. #define DOUBLE(reg,offset) fld.d r2, offset*8, reg
  21. .file "longjmp.S"
  22. .section .text64,"xa"
  23. .align 2
  24. .global longjmp
  25. .type longjmp,@function
  26. longjmp:
  27. /*
  28. * extern void longjmp(jmp_buf env, int val);
  29. *
  30. * r2 == env
  31. * r3 == val
  32. * r4 == temporary
  33. */
  34. /* callee-save registers R10-R16 */
  35. INTEGER(r10, __SETJMP_INT(0))
  36. INTEGER(r11, __SETJMP_INT(1))
  37. INTEGER(r12, __SETJMP_INT(2))
  38. INTEGER(r13, __SETJMP_INT(3))
  39. INTEGER(r14, __SETJMP_INT(4))
  40. INTEGER(r15, __SETJMP_INT(5))
  41. INTEGER(r16, __SETJMP_INT(6))
  42. /* callee-save registers R28-R35 */
  43. INTEGER(r28, __SETJMP_INT(7))
  44. INTEGER(r29, __SETJMP_INT(8))
  45. INTEGER(r30, __SETJMP_INT(9))
  46. INTEGER(r31, __SETJMP_INT(10))
  47. INTEGER(r32, __SETJMP_INT(11))
  48. INTEGER(r33, __SETJMP_INT(12))
  49. INTEGER(r34, __SETJMP_INT(13))
  50. INTEGER(r35, __SETJMP_INT(14))
  51. /* callee-save registers R44-R59 */
  52. INTEGER(r44, __SETJMP_INT(15))
  53. INTEGER(r45, __SETJMP_INT(16))
  54. INTEGER(r46, __SETJMP_INT(17))
  55. INTEGER(r47, __SETJMP_INT(18))
  56. INTEGER(r48, __SETJMP_INT(19))
  57. INTEGER(r49, __SETJMP_INT(20))
  58. INTEGER(r50, __SETJMP_INT(21))
  59. INTEGER(r51, __SETJMP_INT(22))
  60. INTEGER(r52, __SETJMP_INT(23))
  61. INTEGER(r53, __SETJMP_INT(24))
  62. INTEGER(r54, __SETJMP_INT(25))
  63. INTEGER(r55, __SETJMP_INT(26))
  64. INTEGER(r56, __SETJMP_INT(27))
  65. INTEGER(r57, __SETJMP_INT(28))
  66. INTEGER(r58, __SETJMP_INT(29))
  67. INTEGER(r59, __SETJMP_INT(30))
  68. #if __SETJMP_NUM_INT != 31
  69. #error __SETJMP_NUM_INT does agree with expected value
  70. #endif
  71. #if __SETJMP_NUM_DBL > 0
  72. /* callee-save registers FR12-FR15 */
  73. DOUBLE(d12, __SETJMP_DBL(0))
  74. DOUBLE(d14, __SETJMP_DBL(1))
  75. /* callee-save registers FR36-FR63 */
  76. DOUBLE(d36, __SETJMP_DBL(2))
  77. DOUBLE(d38, __SETJMP_DBL(3))
  78. DOUBLE(d40, __SETJMP_DBL(4))
  79. DOUBLE(d42, __SETJMP_DBL(5))
  80. DOUBLE(d44, __SETJMP_DBL(6))
  81. DOUBLE(d46, __SETJMP_DBL(7))
  82. DOUBLE(d48, __SETJMP_DBL(8))
  83. DOUBLE(d50, __SETJMP_DBL(9))
  84. DOUBLE(d52, __SETJMP_DBL(10))
  85. DOUBLE(d54, __SETJMP_DBL(11))
  86. DOUBLE(d56, __SETJMP_DBL(12))
  87. DOUBLE(d58, __SETJMP_DBL(13))
  88. DOUBLE(d60, __SETJMP_DBL(14))
  89. DOUBLE(d62, __SETJMP_DBL(15))
  90. #if __SETJMP_NUM_DBL != 16
  91. #error __SETJMP_NUM_DBL does agree with expected value
  92. #endif
  93. #endif /* __SETJMP_NUM_DBL > 0 */
  94. /* callee-save registers TR5-TR7 */
  95. INTEGER(r4, __SETJMP_TRG(0))
  96. ptabs r4, tr5
  97. INTEGER(r4, __SETJMP_TRG(1))
  98. ptabs r4, tr6
  99. INTEGER(r4, __SETJMP_TRG(2))
  100. ptabs r4, tr7
  101. #if __SETJMP_NUM_TRG != 3
  102. #error __SETJMP_NUM_TRG does agree with expected value
  103. #endif
  104. /* restore Linkage Register (LR) for longjmp return */
  105. INTEGER(r18, __SETJMP_LR)
  106. ptabs/l r18, tr0
  107. /*
  108. * must ensure longjmp() never returns 0.
  109. * if 'val' == 0, then return 1.
  110. */
  111. cmpeq r3, r63, r2 /* r2 = (r3==0) ? 1 : 0; */
  112. add.l r3, r2, r2 /* return value */
  113. /* return to caller */
  114. blink tr0, r63