1 //===----------------------Hexagon builtin routine ------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // Functions that implement common sequences in function prologues and epilogues
10 // used to save code size
12 .macro FUNCTION_BEGIN name
14 .section .text.\name,"ax",@progbits
16 .type \name, @function
20 .macro FUNCTION_END name
21 .size \name, . - \name
24 .macro FALLTHROUGH_TAIL_CALL name0 name1
26 .size \name0, . - \name0
28 .type \name1, @function
35 // Save r17:16 at fp+#-8, r19:18 at fp+#-16, r21:20 at fp+#-24, r23:22 at
36 // fp+#-32, r25:24 at fp+#-40, and r27:26 at fp+#-48.
37 // The compiler knows that the __save_* functions clobber LR. No other
38 // registers should be used without informing the compiler.
40 FUNCTION_BEGIN __save_r16_through_r27
42 memd(fp+#-48) = r27:26
43 memd(fp+#-40) = r25:24
46 memd(fp+#-32) = r23:22
47 memd(fp+#-24) = r21:20
50 memd(fp+#-16) = r19:18
54 FUNCTION_END __save_r16_through_r27
56 FUNCTION_BEGIN __save_r16_through_r25
58 memd(fp+#-40) = r25:24
59 memd(fp+#-32) = r23:22
62 memd(fp+#-24) = r21:20
63 memd(fp+#-16) = r19:18
69 FUNCTION_END __save_r16_through_r25
71 FUNCTION_BEGIN __save_r16_through_r23
73 memd(fp+#-32) = r23:22
74 memd(fp+#-24) = r21:20
77 memd(fp+#-16) = r19:18
81 FUNCTION_END __save_r16_through_r23
83 FUNCTION_BEGIN __save_r16_through_r21
85 memd(fp+#-24) = r21:20
86 memd(fp+#-16) = r19:18
92 FUNCTION_END __save_r16_through_r21
94 FUNCTION_BEGIN __save_r16_through_r19
96 memd(fp+#-16) = r19:18
100 FUNCTION_END __save_r16_through_r19
102 FUNCTION_BEGIN __save_r16_through_r17
104 memd(fp+#-8) = r17:16
107 FUNCTION_END __save_r16_through_r17
109 // For each of the *_before_tailcall functions, jumpr lr is executed in parallel
110 // with deallocframe. That way, the return gets the old value of lr, which is
111 // where these functions need to return, and at the same time, lr gets the value
112 // it needs going into the tail call.
115 FUNCTION_BEGIN __restore_r16_through_r27_and_deallocframe_before_tailcall
116 r27:26 = memd(fp+#-48)
118 r25:24 = memd(fp+#-40)
119 r23:22 = memd(fp+#-32)
122 r21:20 = memd(fp+#-24)
123 r19:18 = memd(fp+#-16)
126 r17:16 = memd(fp+#-8)
130 FUNCTION_END __restore_r16_through_r27_and_deallocframe_before_tailcall
132 FUNCTION_BEGIN __restore_r16_through_r25_and_deallocframe_before_tailcall
134 r25:24 = memd(fp+#-40)
135 r23:22 = memd(fp+#-32)
138 r21:20 = memd(fp+#-24)
139 r19:18 = memd(fp+#-16)
142 r17:16 = memd(fp+#-8)
146 FUNCTION_END __restore_r16_through_r25_and_deallocframe_before_tailcall
148 FUNCTION_BEGIN __restore_r16_through_r23_and_deallocframe_before_tailcall
150 r23:22 = memd(fp+#-32)
151 r21:20 = memd(fp+#-24)
153 r19:18 = memd(fp+#-16)
155 r17:16 = memd(fp+#-8)
159 FUNCTION_END __restore_r16_through_r23_and_deallocframe_before_tailcall
162 FUNCTION_BEGIN __restore_r16_through_r21_and_deallocframe_before_tailcall
164 r21:20 = memd(fp+#-24)
165 r19:18 = memd(fp+#-16)
168 r17:16 = memd(fp+#-8)
172 FUNCTION_END __restore_r16_through_r19_and_deallocframe_before_tailcall
174 FUNCTION_BEGIN __restore_r16_through_r19_and_deallocframe_before_tailcall
175 r19:18 = memd(fp+#-16)
177 r17:16 = memd(fp+#-8)
181 FUNCTION_END __restore_r16_through_r19_and_deallocframe_before_tailcall
183 FUNCTION_BEGIN __restore_r16_through_r17_and_deallocframe_before_tailcall
185 r17:16 = memd(fp+#-8)
189 FUNCTION_END __restore_r16_through_r17_and_deallocframe_before_tailcall
192 FUNCTION_BEGIN __restore_r16_through_r27_and_deallocframe
193 r27:26 = memd(fp+#-48)
195 r25:24 = memd(fp+#-40)
196 r23:22 = memd(fp+#-32)
199 r21:20 = memd(fp+#-24)
200 r19:18 = memd(fp+#-16)
203 r17:16 = memd(fp+#-8)
206 FUNCTION_END __restore_r16_through_r27_and_deallocframe
208 FUNCTION_BEGIN __restore_r16_through_r25_and_deallocframe
210 r25:24 = memd(fp+#-40)
211 r23:22 = memd(fp+#-32)
214 r21:20 = memd(fp+#-24)
215 r19:18 = memd(fp+#-16)
218 r17:16 = memd(fp+#-8)
221 FUNCTION_END __restore_r16_through_r25_and_deallocframe
223 FUNCTION_BEGIN __restore_r16_through_r23_and_deallocframe
225 r23:22 = memd(fp+#-32)
228 r21:20 = memd(fp+#-24)
229 r19:18 = memd(fp+#-16)
232 r17:16 = memd(fp+#-8)
235 FUNCTION_END __restore_r16_through_r23_and_deallocframe
237 FUNCTION_BEGIN __restore_r16_through_r21_and_deallocframe
239 r21:20 = memd(fp+#-24)
240 r19:18 = memd(fp+#-16)
243 r17:16 = memd(fp+#-8)
246 FUNCTION_END __restore_r16_through_r21_and_deallocframe
248 FUNCTION_BEGIN __restore_r16_through_r19_and_deallocframe
250 r19:18 = memd(fp+#-16)
251 r17:16 = memd(fp+#-8)
256 FUNCTION_END __restore_r16_through_r19_and_deallocframe
258 FUNCTION_BEGIN __restore_r16_through_r17_and_deallocframe
260 r17:16 = memd(fp+#-8)
263 FUNCTION_END __restore_r16_through_r17_and_deallocframe
265 FUNCTION_BEGIN __deallocframe
267 FUNCTION_END __deallocframe