268 lines · plain
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-exception6//7//===----------------------------------------------------------------------===//8 9// Functions that implement common sequences in function prologues and epilogues10// used to save code size11 12 .macro FUNCTION_BEGIN name13 .p2align 214 .section .text.\name,"ax",@progbits15 .globl \name16 .type \name, @function17\name:18 .endm19 20 .macro FUNCTION_END name21 .size \name, . - \name22 .endm23 24 .macro FALLTHROUGH_TAIL_CALL name0 name125 .p2align 226 .size \name0, . - \name027 .globl \name128 .type \name1, @function29\name1:30 .endm31 32 33 34 35// Save r17:16 at fp+#-8, r19:18 at fp+#-16, r21:20 at fp+#-24, r23:22 at36// fp+#-32, r25:24 at fp+#-40, and r27:26 at fp+#-48.37// The compiler knows that the __save_* functions clobber LR. No other38// registers should be used without informing the compiler.39 40FUNCTION_BEGIN __save_r16_through_r2741 {42 memd(fp+#-48) = r27:2643 memd(fp+#-40) = r25:2444 }45 {46 memd(fp+#-32) = r23:2247 memd(fp+#-24) = r21:2048 }49 {50 memd(fp+#-16) = r19:1851 memd(fp+#-8) = r17:1652 jumpr lr53 }54FUNCTION_END __save_r16_through_r2755 56FUNCTION_BEGIN __save_r16_through_r2557 {58 memd(fp+#-40) = r25:2459 memd(fp+#-32) = r23:2260 }61 {62 memd(fp+#-24) = r21:2063 memd(fp+#-16) = r19:1864 }65 {66 memd(fp+#-8) = r17:1667 jumpr lr68 }69FUNCTION_END __save_r16_through_r2570 71FUNCTION_BEGIN __save_r16_through_r2372 {73 memd(fp+#-32) = r23:2274 memd(fp+#-24) = r21:2075 }76 {77 memd(fp+#-16) = r19:1878 memd(fp+#-8) = r17:1679 jumpr lr80 }81FUNCTION_END __save_r16_through_r2382 83FUNCTION_BEGIN __save_r16_through_r2184 {85 memd(fp+#-24) = r21:2086 memd(fp+#-16) = r19:1887 }88 {89 memd(fp+#-8) = r17:1690 jumpr lr91 }92FUNCTION_END __save_r16_through_r2193 94FUNCTION_BEGIN __save_r16_through_r1995 {96 memd(fp+#-16) = r19:1897 memd(fp+#-8) = r17:1698 jumpr lr99 }100FUNCTION_END __save_r16_through_r19101 102FUNCTION_BEGIN __save_r16_through_r17103 {104 memd(fp+#-8) = r17:16105 jumpr lr106 }107FUNCTION_END __save_r16_through_r17108 109// For each of the *_before_tailcall functions, jumpr lr is executed in parallel110// with deallocframe. That way, the return gets the old value of lr, which is111// where these functions need to return, and at the same time, lr gets the value112// it needs going into the tail call.113 114 115FUNCTION_BEGIN __restore_r16_through_r27_and_deallocframe_before_tailcall116 r27:26 = memd(fp+#-48)117 {118 r25:24 = memd(fp+#-40)119 r23:22 = memd(fp+#-32)120 }121 {122 r21:20 = memd(fp+#-24)123 r19:18 = memd(fp+#-16)124 }125 {126 r17:16 = memd(fp+#-8)127 deallocframe128 jumpr lr129 }130FUNCTION_END __restore_r16_through_r27_and_deallocframe_before_tailcall131 132FUNCTION_BEGIN __restore_r16_through_r25_and_deallocframe_before_tailcall133 {134 r25:24 = memd(fp+#-40)135 r23:22 = memd(fp+#-32)136 }137 {138 r21:20 = memd(fp+#-24)139 r19:18 = memd(fp+#-16)140 }141 {142 r17:16 = memd(fp+#-8)143 deallocframe144 jumpr lr145 }146FUNCTION_END __restore_r16_through_r25_and_deallocframe_before_tailcall147 148FUNCTION_BEGIN __restore_r16_through_r23_and_deallocframe_before_tailcall149 {150 r23:22 = memd(fp+#-32)151 r21:20 = memd(fp+#-24)152 }153 r19:18 = memd(fp+#-16)154 {155 r17:16 = memd(fp+#-8)156 deallocframe157 jumpr lr158 }159FUNCTION_END __restore_r16_through_r23_and_deallocframe_before_tailcall160 161 162FUNCTION_BEGIN __restore_r16_through_r21_and_deallocframe_before_tailcall163 {164 r21:20 = memd(fp+#-24)165 r19:18 = memd(fp+#-16)166 }167 {168 r17:16 = memd(fp+#-8)169 deallocframe170 jumpr lr171 }172FUNCTION_END __restore_r16_through_r19_and_deallocframe_before_tailcall173 174FUNCTION_BEGIN __restore_r16_through_r19_and_deallocframe_before_tailcall175 r19:18 = memd(fp+#-16)176 {177 r17:16 = memd(fp+#-8)178 deallocframe179 jumpr lr180 }181FUNCTION_END __restore_r16_through_r19_and_deallocframe_before_tailcall182 183FUNCTION_BEGIN __restore_r16_through_r17_and_deallocframe_before_tailcall184 {185 r17:16 = memd(fp+#-8)186 deallocframe187 jumpr lr188 }189FUNCTION_END __restore_r16_through_r17_and_deallocframe_before_tailcall190 191 192FUNCTION_BEGIN __restore_r16_through_r27_and_deallocframe193 r27:26 = memd(fp+#-48)194 {195 r25:24 = memd(fp+#-40)196 r23:22 = memd(fp+#-32)197 }198 {199 r21:20 = memd(fp+#-24)200 r19:18 = memd(fp+#-16)201 }202 {203 r17:16 = memd(fp+#-8)204 dealloc_return205 }206FUNCTION_END __restore_r16_through_r27_and_deallocframe207 208FUNCTION_BEGIN __restore_r16_through_r25_and_deallocframe209 {210 r25:24 = memd(fp+#-40)211 r23:22 = memd(fp+#-32)212 }213 {214 r21:20 = memd(fp+#-24)215 r19:18 = memd(fp+#-16)216 }217 {218 r17:16 = memd(fp+#-8)219 dealloc_return220 }221FUNCTION_END __restore_r16_through_r25_and_deallocframe222 223FUNCTION_BEGIN __restore_r16_through_r23_and_deallocframe224 {225 r23:22 = memd(fp+#-32)226 }227 {228 r21:20 = memd(fp+#-24)229 r19:18 = memd(fp+#-16)230 }231 {232 r17:16 = memd(fp+#-8)233 dealloc_return234 }235FUNCTION_END __restore_r16_through_r23_and_deallocframe236 237FUNCTION_BEGIN __restore_r16_through_r21_and_deallocframe238 {239 r21:20 = memd(fp+#-24)240 r19:18 = memd(fp+#-16)241 }242 {243 r17:16 = memd(fp+#-8)244 dealloc_return245 }246FUNCTION_END __restore_r16_through_r21_and_deallocframe247 248FUNCTION_BEGIN __restore_r16_through_r19_and_deallocframe249 {250 r19:18 = memd(fp+#-16)251 r17:16 = memd(fp+#-8)252 }253 {254 dealloc_return255 }256FUNCTION_END __restore_r16_through_r19_and_deallocframe257 258FUNCTION_BEGIN __restore_r16_through_r17_and_deallocframe259 {260 r17:16 = memd(fp+#-8)261 dealloc_return262 }263FUNCTION_END __restore_r16_through_r17_and_deallocframe264 265FUNCTION_BEGIN __deallocframe266 dealloc_return267FUNCTION_END __deallocframe268