103 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 .text14 .globl \name15 .type \name, @function16 .falign17\name:18 .endm19 20 .macro FUNCTION_END name21 .size \name, . - \name22 .endm23 24 .macro FALLTHROUGH_TAIL_CALL name0 name125 .size \name0, . - \name026 .globl \name127 .type \name1, @function28 .falign29\name1:30 .endm31 32 33 34 35// Save r25:24 at fp+#-8 and r27:26 at fp+#-16.36 37 38 39 40// The compiler knows that the __save_* functions clobber LR. No other41// registers should be used without informing the compiler.42 43// Since we can only issue one store per packet, we don't hurt performance by44// simply jumping to the right point in this sequence of stores.45 46FUNCTION_BEGIN __save_r24_through_r2747 memd(fp+#-16) = r27:2648FALLTHROUGH_TAIL_CALL __save_r24_through_r27 __save_r24_through_r2549 {50 memd(fp+#-8) = r25:2451 jumpr lr52 }53FUNCTION_END __save_r24_through_r2554 55 56 57 58// For each of the *_before_tailcall functions, jumpr lr is executed in parallel59// with deallocframe. That way, the return gets the old value of lr, which is60// where these functions need to return, and at the same time, lr gets the value61// it needs going into the tail call.62 63FUNCTION_BEGIN __restore_r24_through_r27_and_deallocframe_before_tailcall64 r27:26 = memd(fp+#-16)65FALLTHROUGH_TAIL_CALL __restore_r24_through_r27_and_deallocframe_before_tailcall __restore_r24_through_r25_and_deallocframe_before_tailcall66 {67 r25:24 = memd(fp+#-8)68 deallocframe69 jumpr lr70 }71FUNCTION_END __restore_r24_through_r25_and_deallocframe_before_tailcall72 73 74 75 76// Here we use the extra load bandwidth to restore LR early, allowing the return77// to occur in parallel with the deallocframe.78 79FUNCTION_BEGIN __restore_r24_through_r27_and_deallocframe80 {81 lr = memw(fp+#4)82 r27:26 = memd(fp+#-16)83 }84 {85 r25:24 = memd(fp+#-8)86 deallocframe87 jumpr lr88 }89FUNCTION_END __restore_r24_through_r27_and_deallocframe90 91 92 93 94// Here the load bandwidth is maximized.95 96FUNCTION_BEGIN __restore_r24_through_r25_and_deallocframe97 {98 r25:24 = memd(fp+#-8)99 deallocframe100 }101 jumpr lr102FUNCTION_END __restore_r24_through_r25_and_deallocframe103