1 //===----------------------Hexagon builtin routine ------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /* Functions that implement common sequences in function prologues and epilogues
12 used to save code size */
14 .macro FUNCTION_BEGIN name
17 .type \name, @function
22 .macro FUNCTION_END name
23 .size \name, . - \name
26 .macro FALLTHROUGH_TAIL_CALL name0 name1
27 .size \name0, . - \name0
29 .type \name1, @function
37 /* Save r27:26 at fp+#-8, r25:24 at fp+#-16, r23:22 at fp+#-24, r21:20 at
38 fp+#-32, r19:18 at fp+#-40, and r17:16 at fp+#-48. */
43 /* The compiler knows that the __save_* functions clobber LR. No other
44 registers should be used without informing the compiler. */
46 /* Since we can only issue one store per packet, we don't hurt performance by
47 simply jumping to the right point in this sequence of stores. */
49 FUNCTION_BEGIN __save_r27_through_r16
50 memd(fp+#-48) = r17:16
51 FALLTHROUGH_TAIL_CALL __save_r27_through_r16 __save_r27_through_r18
52 memd(fp+#-40) = r19:18
53 FALLTHROUGH_TAIL_CALL __save_r27_through_r18 __save_r27_through_r20
54 memd(fp+#-32) = r21:20
55 FALLTHROUGH_TAIL_CALL __save_r27_through_r20 __save_r27_through_r22
56 memd(fp+#-24) = r23:22
57 FALLTHROUGH_TAIL_CALL __save_r27_through_r22 __save_r27_through_r24
58 memd(fp+#-16) = r25:24
63 FUNCTION_END __save_r27_through_r24
68 /* For each of the *_before_sibcall functions, jumpr lr is executed in parallel
69 with deallocframe. That way, the return gets the old value of lr, which is
70 where these functions need to return, and at the same time, lr gets the value
71 it needs going into the sibcall. */
73 FUNCTION_BEGIN __restore_r27_through_r20_and_deallocframe_before_sibcall
75 r21:20 = memd(fp+#-32)
76 r23:22 = memd(fp+#-24)
78 FALLTHROUGH_TAIL_CALL __restore_r27_through_r20_and_deallocframe_before_sibcall __restore_r27_through_r24_and_deallocframe_before_sibcall
80 r25:24 = memd(fp+#-16)
81 jump __restore_r27_through_r26_and_deallocframe_before_sibcall
83 FUNCTION_END __restore_r27_through_r24_and_deallocframe_before_sibcall
88 FUNCTION_BEGIN __restore_r27_through_r16_and_deallocframe_before_sibcall
89 r17:16 = memd(fp+#-48)
90 FALLTHROUGH_TAIL_CALL __restore_r27_through_r16_and_deallocframe_before_sibcall __restore_r27_through_r18_and_deallocframe_before_sibcall
92 r19:18 = memd(fp+#-40)
93 r21:20 = memd(fp+#-32)
95 FALLTHROUGH_TAIL_CALL __restore_r27_through_r18_and_deallocframe_before_sibcall __restore_r27_through_r22_and_deallocframe_before_sibcall
97 r23:22 = memd(fp+#-24)
98 r25:24 = memd(fp+#-16)
100 FALLTHROUGH_TAIL_CALL __restore_r27_through_r22_and_deallocframe_before_sibcall __restore_r27_through_r26_and_deallocframe_before_sibcall
102 r27:26 = memd(fp+#-8)
106 FUNCTION_END __restore_r27_through_r26_and_deallocframe_before_sibcall
111 /* Here we use the extra load bandwidth to restore LR early, allowing the return
112 to occur in parallel with the deallocframe. */
114 FUNCTION_BEGIN __restore_r27_through_r16_and_deallocframe
116 r17:16 = memd(fp+#-48)
117 r19:18 = memd(fp+#-40)
119 FALLTHROUGH_TAIL_CALL __restore_r27_through_r16_and_deallocframe __restore_r27_through_r20_and_deallocframe
121 r21:20 = memd(fp+#-32)
122 r23:22 = memd(fp+#-24)
124 FALLTHROUGH_TAIL_CALL __restore_r27_through_r20_and_deallocframe __restore_r27_through_r24_and_deallocframe
127 r25:24 = memd(fp+#-16)
130 r27:26 = memd(fp+#-8)
134 FUNCTION_END __restore_r27_through_r24_and_deallocframe
139 /* Here the load bandwidth is maximized for all three functions. */
141 FUNCTION_BEGIN __restore_r27_through_r18_and_deallocframe
143 r19:18 = memd(fp+#-40)
144 r21:20 = memd(fp+#-32)
146 FALLTHROUGH_TAIL_CALL __restore_r27_through_r18_and_deallocframe __restore_r27_through_r22_and_deallocframe
148 r23:22 = memd(fp+#-24)
149 r25:24 = memd(fp+#-16)
151 FALLTHROUGH_TAIL_CALL __restore_r27_through_r22_and_deallocframe __restore_r27_through_r26_and_deallocframe
153 r27:26 = memd(fp+#-8)
157 FUNCTION_END __restore_r27_through_r26_and_deallocframe