]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/hexagon/common_entry_exit_legacy.S
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / builtins / hexagon / common_entry_exit_legacy.S
1 //===----------------------Hexagon builtin routine ------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10
11 /* Functions that implement common sequences in function prologues and epilogues
12    used to save code size */
13
14         .macro FUNCTION_BEGIN name
15         .text
16         .globl \name
17         .type  \name, @function
18         .falign
19 \name:
20         .endm
21
22         .macro FUNCTION_END name
23         .size  \name, . - \name
24         .endm
25
26         .macro FALLTHROUGH_TAIL_CALL name0 name1
27         .size \name0, . - \name0
28         .globl \name1
29         .type \name1, @function
30         .falign
31 \name1:
32         .endm
33
34
35
36
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. */
39
40
41
42
43 /* The compiler knows that the __save_* functions clobber LR.  No other
44    registers should be used without informing the compiler. */
45
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. */
48
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
59         {
60                 memd(fp+#-8) = r27:26
61                 jumpr lr
62         }
63 FUNCTION_END __save_r27_through_r24
64
65
66
67
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. */
72
73 FUNCTION_BEGIN __restore_r27_through_r20_and_deallocframe_before_sibcall
74         {
75                 r21:20 = memd(fp+#-32)
76                 r23:22 = memd(fp+#-24)
77         }
78 FALLTHROUGH_TAIL_CALL __restore_r27_through_r20_and_deallocframe_before_sibcall __restore_r27_through_r24_and_deallocframe_before_sibcall
79         {
80                 r25:24 = memd(fp+#-16)
81                 jump __restore_r27_through_r26_and_deallocframe_before_sibcall
82         }
83 FUNCTION_END __restore_r27_through_r24_and_deallocframe_before_sibcall
84
85
86
87
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
91         {
92                 r19:18 = memd(fp+#-40)
93                 r21:20 = memd(fp+#-32)
94         }
95 FALLTHROUGH_TAIL_CALL __restore_r27_through_r18_and_deallocframe_before_sibcall __restore_r27_through_r22_and_deallocframe_before_sibcall
96         {
97                 r23:22 = memd(fp+#-24)
98                 r25:24 = memd(fp+#-16)
99         }
100 FALLTHROUGH_TAIL_CALL __restore_r27_through_r22_and_deallocframe_before_sibcall __restore_r27_through_r26_and_deallocframe_before_sibcall
101         {
102                 r27:26 = memd(fp+#-8)
103                 deallocframe
104                 jumpr lr
105         }
106 FUNCTION_END __restore_r27_through_r26_and_deallocframe_before_sibcall
107
108
109
110
111 /* Here we use the extra load bandwidth to restore LR early, allowing the return
112    to occur in parallel with the deallocframe. */
113
114 FUNCTION_BEGIN __restore_r27_through_r16_and_deallocframe
115         {
116                 r17:16 = memd(fp+#-48)
117                 r19:18 = memd(fp+#-40)
118         }
119 FALLTHROUGH_TAIL_CALL __restore_r27_through_r16_and_deallocframe __restore_r27_through_r20_and_deallocframe
120         {
121                 r21:20 = memd(fp+#-32)
122                 r23:22 = memd(fp+#-24)
123         }
124 FALLTHROUGH_TAIL_CALL __restore_r27_through_r20_and_deallocframe __restore_r27_through_r24_and_deallocframe
125         {
126                 lr = memw(fp+#4)
127                 r25:24 = memd(fp+#-16)
128         }
129         {
130                 r27:26 = memd(fp+#-8)
131                 deallocframe
132                 jumpr lr
133         }
134 FUNCTION_END __restore_r27_through_r24_and_deallocframe
135
136
137
138
139 /* Here the load bandwidth is maximized for all three functions. */
140
141 FUNCTION_BEGIN __restore_r27_through_r18_and_deallocframe
142         {
143                 r19:18 = memd(fp+#-40)
144                 r21:20 = memd(fp+#-32)
145         }
146 FALLTHROUGH_TAIL_CALL __restore_r27_through_r18_and_deallocframe __restore_r27_through_r22_and_deallocframe
147         {
148                 r23:22 = memd(fp+#-24)
149                 r25:24 = memd(fp+#-16)
150         }
151 FALLTHROUGH_TAIL_CALL __restore_r27_through_r22_and_deallocframe __restore_r27_through_r26_and_deallocframe
152         {
153                 r27:26 = memd(fp+#-8)
154                 deallocframe
155         }
156                 jumpr lr
157 FUNCTION_END __restore_r27_through_r26_and_deallocframe