1 /* PowerPC asm definitions for GNU C.
2 
3 Copyright (C) 2002-2018 Free Software Foundation, Inc.
4 
5 This file is part of GCC.
6 
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11 
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16 
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20 
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 <http://www.gnu.org/licenses/>.  */
25 
26 /* Under winnt, 1) gas supports the following as names and 2) in particular
27    defining "toc" breaks the FUNC_START macro as ".toc" becomes ".2" */
28 
29 #define r0	0
30 #define sp	1
31 #define toc	2
32 #define r3	3
33 #define r4	4
34 #define r5	5
35 #define r6	6
36 #define r7	7
37 #define r8	8
38 #define r9	9
39 #define r10	10
40 #define r11	11
41 #define r12	12
42 #define r13	13
43 #define r14	14
44 #define r15	15
45 #define r16	16
46 #define r17	17
47 #define r18	18
48 #define r19     19
49 #define r20	20
50 #define r21	21
51 #define r22	22
52 #define r23	23
53 #define r24	24
54 #define r25	25
55 #define r26	26
56 #define r27	27
57 #define r28	28
58 #define r29	29
59 #define r30	30
60 #define r31	31
61 
62 #define cr0	0
63 #define cr1	1
64 #define cr2	2
65 #define cr3	3
66 #define cr4	4
67 #define cr5	5
68 #define cr6	6
69 #define cr7	7
70 
71 #define f0	0
72 #define f1	1
73 #define f2	2
74 #define f3	3
75 #define f4	4
76 #define f5	5
77 #define f6	6
78 #define f7	7
79 #define f8	8
80 #define f9	9
81 #define f10	10
82 #define f11	11
83 #define f12	12
84 #define f13	13
85 #define f14	14
86 #define f15	15
87 #define f16	16
88 #define f17	17
89 #define f18	18
90 #define f19	19
91 #define f20	20
92 #define f21	21
93 #define f22	22
94 #define f23	23
95 #define f24	24
96 #define f25	25
97 #define f26	26
98 #define f27	27
99 #define f28	28
100 #define f29	29
101 #define f30	30
102 #define f31	31
103 
104 #ifdef __VSX__
105 #define f32	32
106 #define f33	33
107 #define f34	34
108 #define f35	35
109 #define f36	36
110 #define f37	37
111 #define f38	38
112 #define f39	39
113 #define f40	40
114 #define f41	41
115 #define f42	42
116 #define f43	43
117 #define f44	44
118 #define f45	45
119 #define f46	46
120 #define f47	47
121 #define f48	48
122 #define f49	49
123 #define f50	30
124 #define f51	51
125 #define f52	52
126 #define f53	53
127 #define f54	54
128 #define f55	55
129 #define f56	56
130 #define f57	57
131 #define f58	58
132 #define f59	59
133 #define f60	60
134 #define f61	61
135 #define f62	62
136 #define f63	63
137 #endif
138 
139 #ifdef __ALTIVEC__
140 #define v0	0
141 #define v1	1
142 #define v2	2
143 #define v3	3
144 #define v4	4
145 #define v5	5
146 #define v6	6
147 #define v7	7
148 #define v8	8
149 #define v9	9
150 #define v10	10
151 #define v11	11
152 #define v12	12
153 #define v13	13
154 #define v14	14
155 #define v15	15
156 #define v16	16
157 #define v17	17
158 #define v18	18
159 #define v19	19
160 #define v20	20
161 #define v21	21
162 #define v22	22
163 #define v23	23
164 #define v24	24
165 #define v25	25
166 #define v26	26
167 #define v27	27
168 #define v28	28
169 #define v29	29
170 #define v30	30
171 #define v31	31
172 #endif
173 
174 #ifdef __VSX__
175 #define vs0	0
176 #define vs1	1
177 #define vs2	2
178 #define vs3	3
179 #define vs4	4
180 #define vs5	5
181 #define vs6	6
182 #define vs7	7
183 #define vs8	8
184 #define vs9	9
185 #define vs10	10
186 #define vs11	11
187 #define vs12	12
188 #define vs13	13
189 #define vs14	14
190 #define vs15	15
191 #define vs16	16
192 #define vs17	17
193 #define vs18	18
194 #define vs19	19
195 #define vs20	20
196 #define vs21	21
197 #define vs22	22
198 #define vs23	23
199 #define vs24	24
200 #define vs25	25
201 #define vs26	26
202 #define vs27	27
203 #define vs28	28
204 #define vs29	29
205 #define vs30	30
206 #define vs31	31
207 #define vs32	32
208 #define vs33	33
209 #define vs34	34
210 #define vs35	35
211 #define vs36	36
212 #define vs37	37
213 #define vs38	38
214 #define vs39	39
215 #define vs40	40
216 #define vs41	41
217 #define vs42	42
218 #define vs43	43
219 #define vs44	44
220 #define vs45	45
221 #define vs46	46
222 #define vs47	47
223 #define vs48	48
224 #define vs49	49
225 #define vs50	30
226 #define vs51	51
227 #define vs52	52
228 #define vs53	53
229 #define vs54	54
230 #define vs55	55
231 #define vs56	56
232 #define vs57	57
233 #define vs58	58
234 #define vs59	59
235 #define vs60	60
236 #define vs61	61
237 #define vs62	62
238 #define vs63	63
239 #endif
240 
241 /*
242  * Macros to glue together two tokens.
243  */
244 
245 #ifdef __STDC__
246 #define XGLUE(a,b) a##b
247 #else
248 #define XGLUE(a,b) a/**/b
249 #endif
250 
251 #define GLUE(a,b) XGLUE(a,b)
252 
253 /*
254  * Macros to begin and end a function written in assembler.  If -mcall-aixdesc
255  * or -mcall-nt, create a function descriptor with the given name, and create
256  * the real function with one or two leading periods respectively.
257  */
258 
259 #if defined(__powerpc64__) && _CALL_ELF == 2
260 
261 /* Defining "toc" above breaks @toc in assembler code.  */
262 #undef toc
263 
264 #define FUNC_NAME(name) GLUE(__USER_LABEL_PREFIX__,name)
265 #define JUMP_TARGET(name) FUNC_NAME(name)
266 #define FUNC_START(name) \
267 	.type FUNC_NAME(name),@function; \
268 	.globl FUNC_NAME(name); \
269 FUNC_NAME(name): \
270 0:	addis 2,12,(.TOC.-0b)@ha; \
271 	addi 2,2,(.TOC.-0b)@l; \
272 	.localentry FUNC_NAME(name),.-FUNC_NAME(name)
273 
274 #define HIDDEN_FUNC(name) \
275   FUNC_START(name) \
276   .hidden FUNC_NAME(name);
277 
278 #define FUNC_END(name) \
279 	.size FUNC_NAME(name),.-FUNC_NAME(name)
280 
281 #elif defined (__powerpc64__)
282 
283 #define FUNC_NAME(name) GLUE(.,name)
284 #define JUMP_TARGET(name) FUNC_NAME(name)
285 #define FUNC_START(name) \
286 	.section ".opd","aw"; \
287 name: \
288 	.quad GLUE(.,name); \
289 	.quad .TOC.@tocbase; \
290 	.quad 0; \
291 	.previous; \
292 	.type GLUE(.,name),@function; \
293 	.globl name; \
294 	.globl GLUE(.,name); \
295 GLUE(.,name):
296 
297 #define HIDDEN_FUNC(name) \
298   FUNC_START(name) \
299   .hidden name;	\
300   .hidden GLUE(.,name);
301 
302 #define FUNC_END(name) \
303 GLUE(.L,name): \
304 	.size GLUE(.,name),GLUE(.L,name)-GLUE(.,name)
305 
306 #elif defined(_CALL_AIXDESC)
307 
308 #ifdef _RELOCATABLE
309 #define DESC_SECTION ".got2"
310 #else
311 #define DESC_SECTION ".got1"
312 #endif
313 
314 #define FUNC_NAME(name) GLUE(.,name)
315 #define JUMP_TARGET(name) FUNC_NAME(name)
316 #define FUNC_START(name) \
317 	.section DESC_SECTION,"aw"; \
318 name: \
319 	.long GLUE(.,name); \
320 	.long _GLOBAL_OFFSET_TABLE_; \
321 	.long 0; \
322 	.previous; \
323 	.type GLUE(.,name),@function; \
324 	.globl name; \
325 	.globl GLUE(.,name); \
326 GLUE(.,name):
327 
328 #define HIDDEN_FUNC(name) \
329   FUNC_START(name) \
330   .hidden name; \
331   .hidden GLUE(.,name);
332 
333 #define FUNC_END(name) \
334 GLUE(.L,name): \
335 	.size GLUE(.,name),GLUE(.L,name)-GLUE(.,name)
336 
337 #else
338 
339 #define FUNC_NAME(name) GLUE(__USER_LABEL_PREFIX__,name)
340 #if defined __PIC__ || defined __pic__
341 #define JUMP_TARGET(name) FUNC_NAME(name@plt)
342 #else
343 #define JUMP_TARGET(name) FUNC_NAME(name)
344 #endif
345 #define FUNC_START(name) \
346 	.type FUNC_NAME(name),@function; \
347 	.globl FUNC_NAME(name); \
348 FUNC_NAME(name):
349 
350 #define HIDDEN_FUNC(name) \
351   FUNC_START(name) \
352   .hidden FUNC_NAME(name);
353 
354 #define FUNC_END(name) \
355 GLUE(.L,name): \
356 	.size FUNC_NAME(name),GLUE(.L,name)-FUNC_NAME(name)
357 #endif
358 
359 #ifdef IN_GCC
360 /* For HAVE_GAS_CFI_DIRECTIVE.  */
361 #include "auto-host.h"
362 
363 #ifdef HAVE_GAS_CFI_DIRECTIVE
364 # define CFI_STARTPROC			.cfi_startproc
365 # define CFI_ENDPROC			.cfi_endproc
366 # define CFI_OFFSET(reg, off)		.cfi_offset reg, off
367 # define CFI_DEF_CFA_REGISTER(reg)	.cfi_def_cfa_register reg
368 # define CFI_RESTORE(reg)		.cfi_restore reg
369 #else
370 # define CFI_STARTPROC
371 # define CFI_ENDPROC
372 # define CFI_OFFSET(reg, off)
373 # define CFI_DEF_CFA_REGISTER(reg)
374 # define CFI_RESTORE(reg)
375 #endif
376 #endif
377 
378 #if defined __linux__ && !defined __powerpc64__
379 	.section .note.GNU-stack
380 	.previous
381 #endif
382