__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. see <http://www.gnu.org/licenses/>. */
  15. #define _SETJMP_H
  16. #define _ASM
  17. #include <bits/setjmp.h>
  18. #define INTEGER(reg,offset) ld.q r2, offset*8, reg
  19. #define DOUBLE(reg,offset) fld.d r2, offset*8, reg
  20. .file "__longjmp.S"
  21. .section .text64,"xa"
  22. .align 2
  23. .global __longjmp
  24. .type __longjmp,@function
  25. __longjmp:
  26. /*
  27. * extern void __longjmp(jmp_buf env, int val);
  28. *
  29. * r2 == env
  30. * r3 == val
  31. * r4 == temporary
  32. */
  33. /* callee-save registers R10-R16 */
  34. INTEGER(r10, __SETJMP_INT(0))
  35. INTEGER(r11, __SETJMP_INT(1))
  36. INTEGER(r12, __SETJMP_INT(2))
  37. INTEGER(r13, __SETJMP_INT(3))
  38. INTEGER(r14, __SETJMP_INT(4))
  39. INTEGER(r15, __SETJMP_INT(5))
  40. INTEGER(r16, __SETJMP_INT(6))
  41. /* callee-save registers R28-R35 */
  42. INTEGER(r28, __SETJMP_INT(7))
  43. INTEGER(r29, __SETJMP_INT(8))
  44. INTEGER(r30, __SETJMP_INT(9))
  45. INTEGER(r31, __SETJMP_INT(10))
  46. INTEGER(r32, __SETJMP_INT(11))
  47. INTEGER(r33, __SETJMP_INT(12))
  48. INTEGER(r34, __SETJMP_INT(13))
  49. INTEGER(r35, __SETJMP_INT(14))
  50. /* callee-save registers R44-R59 */
  51. INTEGER(r44, __SETJMP_INT(15))
  52. INTEGER(r45, __SETJMP_INT(16))
  53. INTEGER(r46, __SETJMP_INT(17))
  54. INTEGER(r47, __SETJMP_INT(18))
  55. INTEGER(r48, __SETJMP_INT(19))
  56. INTEGER(r49, __SETJMP_INT(20))
  57. INTEGER(r50, __SETJMP_INT(21))
  58. INTEGER(r51, __SETJMP_INT(22))
  59. INTEGER(r52, __SETJMP_INT(23))
  60. INTEGER(r53, __SETJMP_INT(24))
  61. INTEGER(r54, __SETJMP_INT(25))
  62. INTEGER(r55, __SETJMP_INT(26))
  63. INTEGER(r56, __SETJMP_INT(27))
  64. INTEGER(r57, __SETJMP_INT(28))
  65. INTEGER(r58, __SETJMP_INT(29))
  66. INTEGER(r59, __SETJMP_INT(30))
  67. #if __SETJMP_NUM_INT != 31
  68. #error __SETJMP_NUM_INT does agree with expected value
  69. #endif
  70. #if __SETJMP_NUM_DBL > 0
  71. /* callee-save registers FR12-FR15 */
  72. DOUBLE(d12, __SETJMP_DBL(0))
  73. DOUBLE(d14, __SETJMP_DBL(1))
  74. /* callee-save registers FR36-FR63 */
  75. DOUBLE(d36, __SETJMP_DBL(2))
  76. DOUBLE(d38, __SETJMP_DBL(3))
  77. DOUBLE(d40, __SETJMP_DBL(4))
  78. DOUBLE(d42, __SETJMP_DBL(5))
  79. DOUBLE(d44, __SETJMP_DBL(6))
  80. DOUBLE(d46, __SETJMP_DBL(7))
  81. DOUBLE(d48, __SETJMP_DBL(8))
  82. DOUBLE(d50, __SETJMP_DBL(9))
  83. DOUBLE(d52, __SETJMP_DBL(10))
  84. DOUBLE(d54, __SETJMP_DBL(11))
  85. DOUBLE(d56, __SETJMP_DBL(12))
  86. DOUBLE(d58, __SETJMP_DBL(13))
  87. DOUBLE(d60, __SETJMP_DBL(14))
  88. DOUBLE(d62, __SETJMP_DBL(15))
  89. #if __SETJMP_NUM_DBL != 16
  90. #error __SETJMP_NUM_DBL does agree with expected value
  91. #endif
  92. #endif /* __SETJMP_NUM_DBL > 0 */
  93. /* callee-save registers TR5-TR7 */
  94. INTEGER(r4, __SETJMP_TRG(0))
  95. ptabs r4, tr5
  96. INTEGER(r4, __SETJMP_TRG(1))
  97. ptabs r4, tr6
  98. INTEGER(r4, __SETJMP_TRG(2))
  99. ptabs r4, tr7
  100. #if __SETJMP_NUM_TRG != 3
  101. #error __SETJMP_NUM_TRG does agree with expected value
  102. #endif
  103. /* restore Linkage Register (LR) for __longjmp return */
  104. INTEGER(r18, __SETJMP_LR)
  105. ptabs/l r18, tr0
  106. /*
  107. * must ensure __longjmp() never returns 0.
  108. * if 'val' == 0, then return 1.
  109. */
  110. cmpeq r3, r63, r2 /* r2 = (r3==0) ? 1 : 0; */
  111. add.l r3, r2, r2 /* return value */
  112. /* return to caller */
  113. blink tr0, r63
  114. libc_hidden_def(__longjmp)