Fix PR 47408 and 47385
[official-gcc.git] / gcc / config / rs6000 / ppc-asm.h
blobc963eb98abbccb44e57e87bde275ffa1571db4ff
1 /* PowerPC asm definitions for GNU C.
3 Copyright (C) 2002, 2003, 2008, 2009 Free Software Foundation, Inc.
5 This file is part of GCC.
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.
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.
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.
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/>. */
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" */
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
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
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
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
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
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
242 * Macros to glue together two tokens.
245 #ifdef __STDC__
246 #define XGLUE(a,b) a##b
247 #else
248 #define XGLUE(a,b) a/**/b
249 #endif
251 #define GLUE(a,b) XGLUE(a,b)
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.
259 #if defined (__powerpc64__)
260 #define FUNC_NAME(name) GLUE(.,name)
261 #define JUMP_TARGET(name) FUNC_NAME(name)
262 #define FUNC_START(name) \
263 .section ".opd","aw"; \
264 name: \
265 .quad GLUE(.,name); \
266 .quad .TOC.@tocbase; \
267 .quad 0; \
268 .previous; \
269 .type GLUE(.,name),@function; \
270 .globl name; \
271 .globl GLUE(.,name); \
272 GLUE(.,name):
274 #define HIDDEN_FUNC(name) \
275 FUNC_START(name) \
276 .hidden name; \
277 .hidden GLUE(.,name);
279 #define FUNC_END(name) \
280 GLUE(.L,name): \
281 .size GLUE(.,name),GLUE(.L,name)-GLUE(.,name)
283 #elif defined(_CALL_AIXDESC)
285 #ifdef _RELOCATABLE
286 #define DESC_SECTION ".got2"
287 #else
288 #define DESC_SECTION ".got1"
289 #endif
291 #define FUNC_NAME(name) GLUE(.,name)
292 #define JUMP_TARGET(name) FUNC_NAME(name)
293 #define FUNC_START(name) \
294 .section DESC_SECTION,"aw"; \
295 name: \
296 .long GLUE(.,name); \
297 .long _GLOBAL_OFFSET_TABLE_; \
298 .long 0; \
299 .previous; \
300 .type GLUE(.,name),@function; \
301 .globl name; \
302 .globl GLUE(.,name); \
303 GLUE(.,name):
305 #define HIDDEN_FUNC(name) \
306 FUNC_START(name) \
307 .hidden name; \
308 .hidden GLUE(.,name);
310 #define FUNC_END(name) \
311 GLUE(.L,name): \
312 .size GLUE(.,name),GLUE(.L,name)-GLUE(.,name)
314 #else
316 #define FUNC_NAME(name) GLUE(__USER_LABEL_PREFIX__,name)
317 #if defined __PIC__ || defined __pic__
318 #define JUMP_TARGET(name) FUNC_NAME(name@plt)
319 #else
320 #define JUMP_TARGET(name) FUNC_NAME(name)
321 #endif
322 #define FUNC_START(name) \
323 .type FUNC_NAME(name),@function; \
324 .globl FUNC_NAME(name); \
325 FUNC_NAME(name):
327 #define HIDDEN_FUNC(name) \
328 FUNC_START(name) \
329 .hidden FUNC_NAME(name);
331 #define FUNC_END(name) \
332 GLUE(.L,name): \
333 .size FUNC_NAME(name),GLUE(.L,name)-FUNC_NAME(name)
334 #endif
336 #ifdef IN_GCC
337 /* For HAVE_GAS_CFI_DIRECTIVE. */
338 #include "auto-host.h"
340 #ifdef HAVE_GAS_CFI_DIRECTIVE
341 # define CFI_STARTPROC .cfi_startproc
342 # define CFI_ENDPROC .cfi_endproc
343 # define CFI_OFFSET(reg, off) .cfi_offset reg, off
344 # define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg
345 # define CFI_RESTORE(reg) .cfi_restore reg
346 #else
347 # define CFI_STARTPROC
348 # define CFI_ENDPROC
349 # define CFI_OFFSET(reg, off)
350 # define CFI_DEF_CFA_REGISTER(reg)
351 # define CFI_RESTORE(reg)
352 #endif
353 #endif
355 #if defined __linux__ && !defined __powerpc64__
356 .section .note.GNU-stack
357 .previous
358 #endif