]>
Commit | Line | Data |
---|---|---|
2bfcf297 | 1 | /* Definitions of target machine for GNU compiler, |
88cad84b | 2 | for 64 bit PowerPC linux. |
79c4e63f | 3 | Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. |
2bfcf297 DB |
4 | |
5 | This file is part of GNU CC. | |
6 | ||
7 | GNU CC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GNU CC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GNU CC; see the file COPYING. If not, write to | |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | /* Yes! We are AIX! Err. Wait. We're Linux!. No, wait, we're a | |
23 | combo of both!*/ | |
362b68a8 | 24 | #undef DEFAULT_ABI |
2bfcf297 DB |
25 | #define DEFAULT_ABI ABI_AIX |
26 | ||
4001af0e | 27 | #undef TARGET_AIX |
2bfcf297 DB |
28 | #define TARGET_AIX 1 |
29 | ||
4001af0e AM |
30 | #undef TARGET_DEFAULT |
31 | #define TARGET_DEFAULT \ | |
32 | (MASK_POWERPC | MASK_POWERPC64 | MASK_64BIT | MASK_NEW_MNEMONICS) | |
33 | ||
309323c2 DE |
34 | #undef PROCESSOR_DEFAULT |
35 | #define PROCESSOR_DEFAULT PROCESSOR_PPC630 | |
79ef6299 DE |
36 | #undef PROCESSOR_DEFAULT64 |
37 | #define PROCESSOR_DEFAULT64 PROCESSOR_PPC630 | |
309323c2 | 38 | |
4001af0e AM |
39 | #undef ASM_DEFAULT_SPEC |
40 | #define ASM_DEFAULT_SPEC "-mppc64" | |
41 | ||
a35f8b74 AM |
42 | #undef ASM_SPEC |
43 | #define ASM_SPEC "%{.s: %{mregnames} %{mno-regnames}} \ | |
44 | %{.S: %{mregnames} %{mno-regnames}} \ | |
45 | %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian} \ | |
46 | %{v:-V} %{Qy:} %{!Qn:-Qy} -a64 %(asm_cpu) %{Wa,*:%*}" | |
47 | ||
4001af0e AM |
48 | /* 64-bit PowerPC Linux always has a TOC. */ |
49 | #undef TARGET_NO_TOC | |
50 | #define TARGET_NO_TOC 0 | |
51 | #undef TARGET_TOC | |
52 | #define TARGET_TOC 1 | |
53 | ||
54 | /* We use glibc _mcount for profiling. */ | |
55 | #define NO_PROFILE_COUNTERS 1 | |
56 | #undef PROFILE_BEFORE_PROLOGUE | |
57 | ||
58 | /* Define this for kernel profiling, which just saves LR then calls | |
59 | _mcount without worrying about arg saves. The idea is to change | |
60 | the function prologue as little as possible as it isn't easy to | |
61 | account for arg save/restore code added just for _mcount. */ | |
62 | /* #define PROFILE_KERNEL 1 */ | |
63 | #if PROFILE_KERNEL | |
64 | #define PROFILE_BEFORE_PROLOGUE 1 | |
65 | #undef PROFILE_HOOK | |
66 | #else | |
67 | #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL) | |
68 | #endif | |
69 | ||
70 | /* We don't need to generate entries in .fixup. */ | |
71 | #undef RELOCATABLE_NEEDS_FIXUP | |
2bfcf297 | 72 | |
2bfcf297 DB |
73 | #define USER_LABEL_PREFIX "" |
74 | ||
3b85fe5f | 75 | /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */ |
f34fc46e | 76 | #undef ADJUST_FIELD_ALIGN |
3b85fe5f JJ |
77 | #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ |
78 | (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \ | |
79 | ? get_inner_array_type (FIELD) \ | |
80 | : TREE_TYPE (FIELD)) == DFmode \ | |
81 | ? MIN ((COMPUTED), 32) : (COMPUTED)) | |
82 | ||
2bfcf297 DB |
83 | /* AIX increases natural record alignment to doubleword if the first |
84 | field is an FP double while the FP fields remain word aligned. */ | |
10b2117e | 85 | #undef ROUND_TYPE_ALIGN |
2bfcf297 DB |
86 | #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ |
87 | ((TREE_CODE (STRUCT) == RECORD_TYPE \ | |
88 | || TREE_CODE (STRUCT) == UNION_TYPE \ | |
89 | || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ | |
90 | && TYPE_FIELDS (STRUCT) != 0 \ | |
91 | && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \ | |
216caa2b | 92 | ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \ |
2bfcf297 DB |
93 | : MAX ((COMPUTED), (SPECIFIED))) |
94 | ||
95 | /* Indicate that jump tables go in the text section. */ | |
362b68a8 | 96 | #undef JUMP_TABLES_IN_TEXT_SECTION |
2bfcf297 DB |
97 | #define JUMP_TABLES_IN_TEXT_SECTION 1 |
98 | ||
2bfcf297 DB |
99 | /* 64-bit PowerPC Linux always has GPR13 fixed. */ |
100 | #define FIXED_R13 1 | |
101 | ||
102 | /* __throw will restore its own return address to be the same as the | |
103 | return address of the function that the throw is being made to. | |
104 | This is unfortunate, because we want to check the original | |
105 | return address to see if we need to restore the TOC. | |
106 | So we have to squirrel it away with this. */ | |
107 | #define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init () | |
108 | ||
343f59d9 | 109 | /* Override svr4.h */ |
2bfcf297 DB |
110 | #undef MD_EXEC_PREFIX |
111 | #undef MD_STARTFILE_PREFIX | |
112 | ||
7990b46f MK |
113 | #undef TARGET_OS_CPP_BUILTINS |
114 | #define TARGET_OS_CPP_BUILTINS() \ | |
115 | do \ | |
116 | { \ | |
117 | builtin_define ("__PPC__"); \ | |
118 | builtin_define ("__PPC64__"); \ | |
119 | builtin_define ("__powerpc__"); \ | |
120 | builtin_define ("__powerpc64__"); \ | |
121 | builtin_define ("__PIC__"); \ | |
122 | builtin_define ("__ELF__"); \ | |
123 | builtin_assert ("cpu=powerpc64"); \ | |
124 | builtin_assert ("machine=powerpc64"); \ | |
125 | } \ | |
126 | while (0) | |
2bfcf297 | 127 | |
4001af0e | 128 | #undef CPP_OS_DEFAULT_SPEC |
2bfcf297 DB |
129 | #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)" |
130 | ||
131 | /* The GNU C++ standard library currently requires _GNU_SOURCE being | |
132 | defined on glibc-based systems. This temporary hack accomplishes this, | |
133 | it should go away as soon as libstdc++-v3 has a real fix. */ | |
362b68a8 | 134 | #undef CPLUSPLUS_CPP_SPEC |
2bfcf297 DB |
135 | #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)" |
136 | ||
362b68a8 | 137 | #undef LINK_SHLIB_SPEC |
2bfcf297 DB |
138 | #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}" |
139 | ||
4001af0e | 140 | #undef LIB_DEFAULT_SPEC |
2bfcf297 DB |
141 | #define LIB_DEFAULT_SPEC "%(lib_linux)" |
142 | ||
4001af0e | 143 | #undef STARTFILE_DEFAULT_SPEC |
2bfcf297 DB |
144 | #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)" |
145 | ||
146 | #undef ENDFILE_DEFAULT_SPEC | |
147 | #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)" | |
148 | ||
149 | #undef LINK_START_DEFAULT_SPEC | |
150 | #define LINK_START_DEFAULT_SPEC "%(link_start_linux)" | |
151 | ||
152 | #undef LINK_OS_DEFAULT_SPEC | |
153 | #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" | |
154 | ||
155 | #undef LINK_OS_LINUX_SPEC | |
156 | #define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \ | |
157 | %{rdynamic:-export-dynamic} \ | |
343f59d9 AM |
158 | %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}" |
159 | ||
160 | #ifdef NATIVE_CROSS | |
161 | #define STARTFILE_PREFIX_SPEC "/usr/local/lib64/ /lib64/ /usr/lib64/" | |
71c061e6 DE |
162 | #endif |
163 | ||
71c061e6 DE |
164 | #undef STARTFILE_LINUX_SPEC |
165 | #define STARTFILE_LINUX_SPEC "\ | |
343f59d9 AM |
166 | %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} crti.o%s \ |
167 | %{static:crtbeginT.o%s} \ | |
168 | %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}" | |
71c061e6 | 169 | |
71c061e6 DE |
170 | #undef ENDFILE_LINUX_SPEC |
171 | #define ENDFILE_LINUX_SPEC "\ | |
343f59d9 | 172 | %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" |
2bfcf297 | 173 | |
362b68a8 | 174 | #undef TOC_SECTION_ASM_OP |
2bfcf297 DB |
175 | #define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\"" |
176 | ||
362b68a8 | 177 | #undef MINIMAL_TOC_SECTION_ASM_OP |
4001af0e | 178 | #define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".toc1\",\"aw\"" |
2bfcf297 | 179 | |
362b68a8 | 180 | #undef TARGET_VERSION |
2bfcf297 DB |
181 | #define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)"); |
182 | ||
183 | /* Must be at least as big as our pointer type. */ | |
184 | #undef SIZE_TYPE | |
185 | #define SIZE_TYPE "long unsigned int" | |
186 | ||
187 | #undef PTRDIFF_TYPE | |
188 | #define PTRDIFF_TYPE "long int" | |
189 | ||
190 | #undef WCHAR_TYPE | |
191 | #define WCHAR_TYPE "int" | |
192 | #undef WCHAR_TYPE_SIZE | |
193 | #define WCHAR_TYPE_SIZE 32 | |
194 | ||
195 | /* Override rs6000.h definition. */ | |
362b68a8 | 196 | #undef ASM_APP_ON |
2bfcf297 DB |
197 | #define ASM_APP_ON "#APP\n" |
198 | ||
199 | /* Override rs6000.h definition. */ | |
362b68a8 | 200 | #undef ASM_APP_OFF |
2bfcf297 DB |
201 | #define ASM_APP_OFF "#NO_APP\n" |
202 | ||
2bfcf297 | 203 | /* PowerPC no-op instruction. */ |
362b68a8 | 204 | #undef RS6000_CALL_GLUE |
2bfcf297 DB |
205 | #define RS6000_CALL_GLUE "nop" |
206 | ||
362b68a8 | 207 | #undef RS6000_MCOUNT |
4001af0e | 208 | #define RS6000_MCOUNT "_mcount" |
362b68a8 DE |
209 | |
210 | /* FP save and restore routines. */ | |
211 | #undef SAVE_FP_PREFIX | |
212 | #define SAVE_FP_PREFIX "._savef" | |
213 | #undef SAVE_FP_SUFFIX | |
214 | #define SAVE_FP_SUFFIX "" | |
215 | #undef RESTORE_FP_PREFIX | |
216 | #define RESTORE_FP_PREFIX "._restf" | |
217 | #undef RESTORE_FP_SUFFIX | |
218 | #define RESTORE_FP_SUFFIX "" | |
219 | ||
2bfcf297 | 220 | /* Dwarf2 debugging. */ |
362b68a8 | 221 | #undef PREFERRED_DEBUGGING_TYPE |
4001af0e AM |
222 | #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG |
223 | ||
fb49053f RH |
224 | #undef TARGET_ENCODE_SECTION_INFO |
225 | #define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info | |
2bfcf297 | 226 | |
2bfcf297 DB |
227 | /* This is how to output a reference to a user-level label named NAME. |
228 | `assemble_name' uses this. */ | |
229 | ||
230 | /* Override elfos.h definition. */ | |
4001af0e AM |
231 | #undef ASM_OUTPUT_LABELREF |
232 | #define ASM_OUTPUT_LABELREF(FILE,NAME) \ | |
2bfcf297 DB |
233 | do { \ |
234 | const char *_name = NAME; \ | |
235 | if (*_name == '@') \ | |
236 | _name++; \ | |
237 | \ | |
238 | if (*_name == '*') \ | |
239 | fprintf (FILE, "%s", _name + 1); \ | |
240 | else \ | |
241 | asm_fprintf (FILE, "%U%s", _name); \ | |
242 | } while (0) | |
243 | ||
244 | #undef ASM_DECLARE_FUNCTION_NAME | |
245 | #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ | |
4001af0e AM |
246 | do \ |
247 | { \ | |
248 | fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", (FILE)); \ | |
249 | ASM_OUTPUT_LABEL ((FILE), (NAME)); \ | |
250 | fputs (DOUBLE_INT_ASM_OP, (FILE)); \ | |
251 | putc ('.', (FILE)); \ | |
252 | assemble_name ((FILE), (NAME)); \ | |
79c4e63f AM |
253 | fputs (",.TOC.@tocbase,0\n\t.previous\n\t.size\t", (FILE)); \ |
254 | assemble_name ((FILE), (NAME)); \ | |
255 | fputs (",24\n\t.type\t.", (FILE)); \ | |
256 | assemble_name ((FILE), (NAME)); \ | |
257 | fputs (",@function\n", (FILE)); \ | |
258 | if (TREE_PUBLIC (DECL) && ! DECL_WEAK (DECL)) \ | |
4001af0e | 259 | { \ |
79c4e63f | 260 | fputs ("\t.globl\t.", (FILE)); \ |
4001af0e AM |
261 | assemble_name ((FILE), (NAME)); \ |
262 | putc ('\n', (FILE)); \ | |
263 | } \ | |
4001af0e AM |
264 | ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL)); \ |
265 | putc ('.', (FILE)); \ | |
266 | ASM_OUTPUT_LABEL ((FILE), (NAME)); \ | |
267 | } \ | |
268 | while (0) | |
2bfcf297 | 269 | |
79c4e63f AM |
270 | /* This is how to declare the size of a function. */ |
271 | #undef ASM_DECLARE_FUNCTION_SIZE | |
272 | #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ | |
273 | do \ | |
274 | { \ | |
275 | if (!flag_inhibit_size_directive) \ | |
276 | { \ | |
277 | fputs ("\t.size\t.", (FILE)); \ | |
278 | assemble_name ((FILE), (FNAME)); \ | |
279 | fputs (",.-.", (FILE)); \ | |
280 | assemble_name ((FILE), (FNAME)); \ | |
281 | putc ('\n', (FILE)); \ | |
282 | } \ | |
283 | } \ | |
284 | while (0) | |
285 | ||
a0ab749a | 286 | /* Return nonzero if this entry is to be written into the constant |
2bfcf297 DB |
287 | pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF |
288 | or a CONST containing one of them. If -mfp-in-toc (the default), | |
289 | we also do this for floating-point constants. We actually can only | |
290 | do this if the FP formats of the target and host machines are the | |
291 | same, but we can't check that since not every file that uses | |
292 | GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when | |
293 | we can write the entry into the TOC and the entry is not larger | |
294 | than a TOC entry. */ | |
295 | ||
296 | #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P | |
297 | #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ | |
298 | (TARGET_TOC \ | |
299 | && (GET_CODE (X) == SYMBOL_REF \ | |
300 | || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ | |
301 | && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ | |
302 | || GET_CODE (X) == LABEL_REF \ | |
303 | || (GET_CODE (X) == CONST_INT \ | |
304 | && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ | |
305 | || (GET_CODE (X) == CONST_DOUBLE \ | |
306 | && (TARGET_POWERPC64 \ | |
307 | || TARGET_MINIMAL_TOC \ | |
308 | || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ | |
309 | && ! TARGET_NO_FP_IN_TOC))))) | |
310 | ||
1fd9ba59 AM |
311 | /* This is the same as the dbxelf.h version, except that we need to |
312 | use the function code label, not the function descriptor. */ | |
313 | #undef ASM_OUTPUT_SOURCE_LINE | |
314 | #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE) \ | |
315 | do \ | |
316 | { \ | |
317 | static int sym_lineno = 1; \ | |
318 | char temp[256]; \ | |
319 | ASM_GENERATE_INTERNAL_LABEL (temp, "LM", sym_lineno); \ | |
320 | fprintf (FILE, "\t.stabn 68,0,%d,", LINE); \ | |
321 | assemble_name (FILE, temp); \ | |
322 | fputs ("-.", FILE); \ | |
323 | assemble_name (FILE, \ | |
324 | XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\ | |
325 | putc ('\n', FILE); \ | |
4977bab6 | 326 | (*targetm.asm_out.internal_label) (FILE, "LM", sym_lineno); \ |
1fd9ba59 AM |
327 | sym_lineno += 1; \ |
328 | } \ | |
329 | while (0) | |
09eeeacb | 330 | |
80926cc1 AM |
331 | /* Similarly, we want the function code label here. */ |
332 | #define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \ | |
333 | do \ | |
334 | { \ | |
335 | const char *flab; \ | |
336 | fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC); \ | |
337 | assemble_name (FILE, NAME); \ | |
338 | putc ('-', FILE); \ | |
339 | if (current_function_func_begin_label != NULL_TREE) \ | |
340 | flab = IDENTIFIER_POINTER (current_function_func_begin_label); \ | |
341 | else \ | |
342 | { \ | |
343 | putc ('.', FILE); \ | |
344 | flab = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \ | |
345 | } \ | |
346 | assemble_name (FILE, flab); \ | |
347 | putc ('\n', FILE); \ | |
348 | } \ | |
349 | while (0) | |
350 | ||
351 | #define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC) | |
352 | #define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC) | |
353 | ||
374b0b7d AM |
354 | /* Another case where we want the dot name. */ |
355 | #define DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL) \ | |
356 | do \ | |
357 | { \ | |
358 | fprintf (FILE, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN); \ | |
359 | assemble_name (FILE, LSCOPE); \ | |
360 | fputs ("-.", FILE); \ | |
361 | assemble_name (FILE, XSTR (XEXP (DECL_RTL (DECL), 0), 0)); \ | |
362 | putc ('\n', FILE); \ | |
363 | } \ | |
364 | while (0) | |
365 | ||
09eeeacb AM |
366 | /* Override sysv4.h as these are ABI_V4 only. */ |
367 | #undef ASM_OUTPUT_REG_PUSH | |
368 | #undef ASM_OUTPUT_REG_POP | |
fea76d82 AM |
369 | |
370 | /* Select a format to encode pointers in exception handling data. CODE | |
371 | is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is | |
372 | true if the symbol may be affected by dynamic relocations. */ | |
373 | #undef ASM_PREFERRED_EH_DATA_FORMAT | |
374 | #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ | |
375 | (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_udata8) |