aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/builtins/hexagon/common_entry_exit_abi2.S
blob: 3b85aea2f6008b8138868c0e63107700840a851d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
//===----------------------Hexagon builtin routine ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// Functions that implement common sequences in function prologues and epilogues
// used to save code size

	.macro FUNCTION_BEGIN name
	.p2align 2
        .section .text.\name,"ax",@progbits
	.globl \name
	.type  \name, @function
\name:
	.endm

	.macro FUNCTION_END name
	.size  \name, . - \name
	.endm

	.macro FALLTHROUGH_TAIL_CALL name0 name1
	.p2align 2
	.size \name0, . - \name0
	.globl \name1
	.type \name1, @function
\name1:
	.endm




// Save r17:16 at fp+#-8, r19:18 at fp+#-16, r21:20 at fp+#-24, r23:22 at
// fp+#-32, r25:24 at fp+#-40, and r27:26 at fp+#-48.
// The compiler knows that the __save_* functions clobber LR.  No other
// registers should be used without informing the compiler.

FUNCTION_BEGIN __save_r16_through_r27
        {
                memd(fp+#-48) = r27:26
                memd(fp+#-40) = r25:24
        }
        {
                memd(fp+#-32) = r23:22
                memd(fp+#-24) = r21:20
        }
        {
                memd(fp+#-16) = r19:18
                memd(fp+#-8) = r17:16
                jumpr lr
        }
FUNCTION_END __save_r16_through_r27

FUNCTION_BEGIN __save_r16_through_r25
        {
                memd(fp+#-40) = r25:24
                memd(fp+#-32) = r23:22
        }
        {
                memd(fp+#-24) = r21:20
                memd(fp+#-16) = r19:18
        }
        {
                memd(fp+#-8) = r17:16
                jumpr lr
        }
FUNCTION_END __save_r16_through_r25

FUNCTION_BEGIN __save_r16_through_r23
        {
                memd(fp+#-32) = r23:22
                memd(fp+#-24) = r21:20
        }
        {
                memd(fp+#-16) = r19:18
                memd(fp+#-8) = r17:16
                jumpr lr
        }
FUNCTION_END __save_r16_through_r23

FUNCTION_BEGIN __save_r16_through_r21
        {
                memd(fp+#-24) = r21:20
                memd(fp+#-16) = r19:18
        }
        {
                memd(fp+#-8) = r17:16
                jumpr lr
        }
FUNCTION_END __save_r16_through_r21

FUNCTION_BEGIN __save_r16_through_r19
        {
                memd(fp+#-16) = r19:18
                memd(fp+#-8) = r17:16
                jumpr lr
        }
FUNCTION_END __save_r16_through_r19

FUNCTION_BEGIN __save_r16_through_r17
        {
                memd(fp+#-8) = r17:16
                jumpr lr
        }
FUNCTION_END __save_r16_through_r17

// For each of the *_before_tailcall functions, jumpr lr is executed in parallel
// with deallocframe.  That way, the return gets the old value of lr, which is
// where these functions need to return, and at the same time, lr gets the value
// it needs going into the tail call.


FUNCTION_BEGIN __restore_r16_through_r27_and_deallocframe_before_tailcall
                r27:26 = memd(fp+#-48)
        {
                r25:24 = memd(fp+#-40)
                r23:22 = memd(fp+#-32)
        }
        {
                r21:20 = memd(fp+#-24)
                r19:18 = memd(fp+#-16)
        }
        {
                r17:16 = memd(fp+#-8)
                deallocframe
                jumpr lr
        }
FUNCTION_END __restore_r16_through_r27_and_deallocframe_before_tailcall

FUNCTION_BEGIN __restore_r16_through_r25_and_deallocframe_before_tailcall
        {
                r25:24 = memd(fp+#-40)
                r23:22 = memd(fp+#-32)
        }
        {
                r21:20 = memd(fp+#-24)
                r19:18 = memd(fp+#-16)
        }
        {
                r17:16 = memd(fp+#-8)
                deallocframe
                jumpr lr
        }
FUNCTION_END __restore_r16_through_r25_and_deallocframe_before_tailcall

FUNCTION_BEGIN __restore_r16_through_r23_and_deallocframe_before_tailcall
        {
                r23:22 = memd(fp+#-32)
                r21:20 = memd(fp+#-24)
        }
                r19:18 = memd(fp+#-16)
        {
                r17:16 = memd(fp+#-8)
                deallocframe
                jumpr lr
        }
FUNCTION_END __restore_r16_through_r23_and_deallocframe_before_tailcall


FUNCTION_BEGIN __restore_r16_through_r21_and_deallocframe_before_tailcall
        {
                r21:20 = memd(fp+#-24)
                r19:18 = memd(fp+#-16)
        }
        {
                r17:16 = memd(fp+#-8)
                deallocframe
                jumpr lr
        }
FUNCTION_END __restore_r16_through_r19_and_deallocframe_before_tailcall

FUNCTION_BEGIN __restore_r16_through_r19_and_deallocframe_before_tailcall
                r19:18 = memd(fp+#-16)
        {
                r17:16 = memd(fp+#-8)
                deallocframe
                jumpr lr
        }
FUNCTION_END __restore_r16_through_r19_and_deallocframe_before_tailcall

FUNCTION_BEGIN __restore_r16_through_r17_and_deallocframe_before_tailcall
        {
                r17:16 = memd(fp+#-8)
                deallocframe
                jumpr lr
        }
FUNCTION_END __restore_r16_through_r17_and_deallocframe_before_tailcall


FUNCTION_BEGIN __restore_r16_through_r27_and_deallocframe
                r27:26 = memd(fp+#-48)
        {
                r25:24 = memd(fp+#-40)
                r23:22 = memd(fp+#-32)
        }
        {
                r21:20 = memd(fp+#-24)
                r19:18 = memd(fp+#-16)
        }
	{
		r17:16 = memd(fp+#-8)
		dealloc_return
	}
FUNCTION_END __restore_r16_through_r27_and_deallocframe

FUNCTION_BEGIN __restore_r16_through_r25_and_deallocframe
        {
                r25:24 = memd(fp+#-40)
                r23:22 = memd(fp+#-32)
        }
        {
                r21:20 = memd(fp+#-24)
                r19:18 = memd(fp+#-16)
        }
	{
		r17:16 = memd(fp+#-8)
		dealloc_return
	}
FUNCTION_END __restore_r16_through_r25_and_deallocframe

FUNCTION_BEGIN __restore_r16_through_r23_and_deallocframe
        {
                r23:22 = memd(fp+#-32)
        }
        {
                r21:20 = memd(fp+#-24)
                r19:18 = memd(fp+#-16)
        }
	{
		r17:16 = memd(fp+#-8)
		dealloc_return
	}
FUNCTION_END __restore_r16_through_r23_and_deallocframe

FUNCTION_BEGIN __restore_r16_through_r21_and_deallocframe
        {
                r21:20 = memd(fp+#-24)
                r19:18 = memd(fp+#-16)
        }
	{
		r17:16 = memd(fp+#-8)
		dealloc_return
	}
FUNCTION_END __restore_r16_through_r21_and_deallocframe

FUNCTION_BEGIN __restore_r16_through_r19_and_deallocframe
	{
                r19:18 = memd(fp+#-16)
		r17:16 = memd(fp+#-8)
        }
        {
		dealloc_return
	}
FUNCTION_END __restore_r16_through_r19_and_deallocframe

FUNCTION_BEGIN __restore_r16_through_r17_and_deallocframe
	{
		r17:16 = memd(fp+#-8)
		dealloc_return
	}
FUNCTION_END __restore_r16_through_r17_and_deallocframe

FUNCTION_BEGIN __deallocframe
        dealloc_return
FUNCTION_END __deallocframe