common_entry_exit_abi2.S 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. //===----------------------Hexagon builtin routine ------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // Functions that implement common sequences in function prologues and epilogues
  9. // used to save code size
  10. .macro FUNCTION_BEGIN name
  11. .p2align 2
  12. .section .text.\name,"ax",@progbits
  13. .globl \name
  14. .type \name, @function
  15. \name:
  16. .endm
  17. .macro FUNCTION_END name
  18. .size \name, . - \name
  19. .endm
  20. .macro FALLTHROUGH_TAIL_CALL name0 name1
  21. .p2align 2
  22. .size \name0, . - \name0
  23. .globl \name1
  24. .type \name1, @function
  25. \name1:
  26. .endm
  27. // Save r17:16 at fp+#-8, r19:18 at fp+#-16, r21:20 at fp+#-24, r23:22 at
  28. // fp+#-32, r25:24 at fp+#-40, and r27:26 at fp+#-48.
  29. // The compiler knows that the __save_* functions clobber LR. No other
  30. // registers should be used without informing the compiler.
  31. FUNCTION_BEGIN __save_r16_through_r27
  32. {
  33. memd(fp+#-48) = r27:26
  34. memd(fp+#-40) = r25:24
  35. }
  36. {
  37. memd(fp+#-32) = r23:22
  38. memd(fp+#-24) = r21:20
  39. }
  40. {
  41. memd(fp+#-16) = r19:18
  42. memd(fp+#-8) = r17:16
  43. jumpr lr
  44. }
  45. FUNCTION_END __save_r16_through_r27
  46. FUNCTION_BEGIN __save_r16_through_r25
  47. {
  48. memd(fp+#-40) = r25:24
  49. memd(fp+#-32) = r23:22
  50. }
  51. {
  52. memd(fp+#-24) = r21:20
  53. memd(fp+#-16) = r19:18
  54. }
  55. {
  56. memd(fp+#-8) = r17:16
  57. jumpr lr
  58. }
  59. FUNCTION_END __save_r16_through_r25
  60. FUNCTION_BEGIN __save_r16_through_r23
  61. {
  62. memd(fp+#-32) = r23:22
  63. memd(fp+#-24) = r21:20
  64. }
  65. {
  66. memd(fp+#-16) = r19:18
  67. memd(fp+#-8) = r17:16
  68. jumpr lr
  69. }
  70. FUNCTION_END __save_r16_through_r23
  71. FUNCTION_BEGIN __save_r16_through_r21
  72. {
  73. memd(fp+#-24) = r21:20
  74. memd(fp+#-16) = r19:18
  75. }
  76. {
  77. memd(fp+#-8) = r17:16
  78. jumpr lr
  79. }
  80. FUNCTION_END __save_r16_through_r21
  81. FUNCTION_BEGIN __save_r16_through_r19
  82. {
  83. memd(fp+#-16) = r19:18
  84. memd(fp+#-8) = r17:16
  85. jumpr lr
  86. }
  87. FUNCTION_END __save_r16_through_r19
  88. FUNCTION_BEGIN __save_r16_through_r17
  89. {
  90. memd(fp+#-8) = r17:16
  91. jumpr lr
  92. }
  93. FUNCTION_END __save_r16_through_r17
  94. // For each of the *_before_tailcall functions, jumpr lr is executed in parallel
  95. // with deallocframe. That way, the return gets the old value of lr, which is
  96. // where these functions need to return, and at the same time, lr gets the value
  97. // it needs going into the tail call.
  98. FUNCTION_BEGIN __restore_r16_through_r27_and_deallocframe_before_tailcall
  99. r27:26 = memd(fp+#-48)
  100. {
  101. r25:24 = memd(fp+#-40)
  102. r23:22 = memd(fp+#-32)
  103. }
  104. {
  105. r21:20 = memd(fp+#-24)
  106. r19:18 = memd(fp+#-16)
  107. }
  108. {
  109. r17:16 = memd(fp+#-8)
  110. deallocframe
  111. jumpr lr
  112. }
  113. FUNCTION_END __restore_r16_through_r27_and_deallocframe_before_tailcall
  114. FUNCTION_BEGIN __restore_r16_through_r25_and_deallocframe_before_tailcall
  115. {
  116. r25:24 = memd(fp+#-40)
  117. r23:22 = memd(fp+#-32)
  118. }
  119. {
  120. r21:20 = memd(fp+#-24)
  121. r19:18 = memd(fp+#-16)
  122. }
  123. {
  124. r17:16 = memd(fp+#-8)
  125. deallocframe
  126. jumpr lr
  127. }
  128. FUNCTION_END __restore_r16_through_r25_and_deallocframe_before_tailcall
  129. FUNCTION_BEGIN __restore_r16_through_r23_and_deallocframe_before_tailcall
  130. {
  131. r23:22 = memd(fp+#-32)
  132. r21:20 = memd(fp+#-24)
  133. }
  134. r19:18 = memd(fp+#-16)
  135. {
  136. r17:16 = memd(fp+#-8)
  137. deallocframe
  138. jumpr lr
  139. }
  140. FUNCTION_END __restore_r16_through_r23_and_deallocframe_before_tailcall
  141. FUNCTION_BEGIN __restore_r16_through_r21_and_deallocframe_before_tailcall
  142. {
  143. r21:20 = memd(fp+#-24)
  144. r19:18 = memd(fp+#-16)
  145. }
  146. {
  147. r17:16 = memd(fp+#-8)
  148. deallocframe
  149. jumpr lr
  150. }
  151. FUNCTION_END __restore_r16_through_r19_and_deallocframe_before_tailcall
  152. FUNCTION_BEGIN __restore_r16_through_r19_and_deallocframe_before_tailcall
  153. r19:18 = memd(fp+#-16)
  154. {
  155. r17:16 = memd(fp+#-8)
  156. deallocframe
  157. jumpr lr
  158. }
  159. FUNCTION_END __restore_r16_through_r19_and_deallocframe_before_tailcall
  160. FUNCTION_BEGIN __restore_r16_through_r17_and_deallocframe_before_tailcall
  161. {
  162. r17:16 = memd(fp+#-8)
  163. deallocframe
  164. jumpr lr
  165. }
  166. FUNCTION_END __restore_r16_through_r17_and_deallocframe_before_tailcall
  167. FUNCTION_BEGIN __restore_r16_through_r27_and_deallocframe
  168. r27:26 = memd(fp+#-48)
  169. {
  170. r25:24 = memd(fp+#-40)
  171. r23:22 = memd(fp+#-32)
  172. }
  173. {
  174. r21:20 = memd(fp+#-24)
  175. r19:18 = memd(fp+#-16)
  176. }
  177. {
  178. r17:16 = memd(fp+#-8)
  179. dealloc_return
  180. }
  181. FUNCTION_END __restore_r16_through_r27_and_deallocframe
  182. FUNCTION_BEGIN __restore_r16_through_r25_and_deallocframe
  183. {
  184. r25:24 = memd(fp+#-40)
  185. r23:22 = memd(fp+#-32)
  186. }
  187. {
  188. r21:20 = memd(fp+#-24)
  189. r19:18 = memd(fp+#-16)
  190. }
  191. {
  192. r17:16 = memd(fp+#-8)
  193. dealloc_return
  194. }
  195. FUNCTION_END __restore_r16_through_r25_and_deallocframe
  196. FUNCTION_BEGIN __restore_r16_through_r23_and_deallocframe
  197. {
  198. r23:22 = memd(fp+#-32)
  199. }
  200. {
  201. r21:20 = memd(fp+#-24)
  202. r19:18 = memd(fp+#-16)
  203. }
  204. {
  205. r17:16 = memd(fp+#-8)
  206. dealloc_return
  207. }
  208. FUNCTION_END __restore_r16_through_r23_and_deallocframe
  209. FUNCTION_BEGIN __restore_r16_through_r21_and_deallocframe
  210. {
  211. r21:20 = memd(fp+#-24)
  212. r19:18 = memd(fp+#-16)
  213. }
  214. {
  215. r17:16 = memd(fp+#-8)
  216. dealloc_return
  217. }
  218. FUNCTION_END __restore_r16_through_r21_and_deallocframe
  219. FUNCTION_BEGIN __restore_r16_through_r19_and_deallocframe
  220. {
  221. r19:18 = memd(fp+#-16)
  222. r17:16 = memd(fp+#-8)
  223. }
  224. {
  225. dealloc_return
  226. }
  227. FUNCTION_END __restore_r16_through_r19_and_deallocframe
  228. FUNCTION_BEGIN __restore_r16_through_r17_and_deallocframe
  229. {
  230. r17:16 = memd(fp+#-8)
  231. dealloc_return
  232. }
  233. FUNCTION_END __restore_r16_through_r17_and_deallocframe
  234. FUNCTION_BEGIN __deallocframe
  235. dealloc_return
  236. FUNCTION_END __deallocframe