1 /* Definitions of target machine for GNU compiler,
2 for 64 bit PowerPC NetBSD.
3 Copyright (C) 2006 Free Software Foundation, Inc.
4 Contributed by Matthew Green (mrg@eterna.com.au).
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 2, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the
20 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 MA 02110-1301, USA. */
23 #ifndef RS6000_BI_ARCH
26 #define DEFAULT_ABI ABI_AIX
29 #define TARGET_64BIT 1
31 #define DEFAULT_ARCH64_P 1
32 #define RS6000_BI_ARCH_P 0
36 #define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
37 #define RS6000_BI_ARCH_P 1
44 #define TARGET_64BIT 1
46 #define TARGET_64BIT 0
51 #define TARGET_AIX TARGET_64BIT
53 #ifdef HAVE_LD_NO_DOT_SYMS
54 /* New ABI uses a local sym for the function entry point. */
55 extern int dot_symbols
;
57 #define DOT_SYMBOLS dot_symbols
60 #undef PROCESSOR_DEFAULT
61 #define PROCESSOR_DEFAULT PROCESSOR_POWER4
62 #undef PROCESSOR_DEFAULT64
63 #define PROCESSOR_DEFAULT64 PROCESSOR_POWER4
65 /* We don't need to generate entries in .fixup, except when
66 -mrelocatable or -mrelocatable-lib is given. */
67 #undef RELOCATABLE_NEEDS_FIXUP
68 #define RELOCATABLE_NEEDS_FIXUP \
69 (target_flags & target_flags_explicit & MASK_RELOCATABLE)
71 #undef RS6000_ABI_NAME
72 #define RS6000_ABI_NAME "netbsd"
74 #define INVALID_64BIT "-m%s not supported in this configuration"
75 #define INVALID_32BIT INVALID_64BIT
77 #ifndef MASK_PROFILE_KERNEL /* XXXHRH */
78 #define MASK_PROFILE_KERNEL 0 /* XXXHRH */
81 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
82 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
85 if (!rs6000_explicit_options.alignment) \
86 rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
89 if (DEFAULT_ABI != ABI_AIX) \
91 rs6000_current_abi = ABI_AIX; \
92 error (INVALID_64BIT, "call"); \
94 dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
95 if (target_flags & MASK_RELOCATABLE) \
97 target_flags &= ~MASK_RELOCATABLE; \
98 error (INVALID_64BIT, "relocatable"); \
100 if (target_flags & MASK_EABI) \
102 target_flags &= ~MASK_EABI; \
103 error (INVALID_64BIT, "eabi"); \
105 if (target_flags & MASK_PROTOTYPE) \
107 target_flags &= ~MASK_PROTOTYPE; \
108 error (INVALID_64BIT, "prototype"); \
110 if ((target_flags & MASK_POWERPC64) == 0) \
112 target_flags |= MASK_POWERPC64; \
113 error ("-m64 requires a PowerPC64 cpu"); \
118 if (!RS6000_BI_ARCH_P) \
119 error (INVALID_32BIT, "32"); \
120 if (TARGET_PROFILE_KERNEL) \
122 target_flags &= ~MASK_PROFILE_KERNEL; \
123 error (INVALID_32BIT, "profile-kernel"); \
129 #ifdef RS6000_BI_ARCH
131 #undef OVERRIDE_OPTIONS
132 #define OVERRIDE_OPTIONS \
133 rs6000_override_options (((TARGET_DEFAULT ^ target_flags) & MASK_64BIT) \
134 ? (char *) 0 : TARGET_CPU_DEFAULT)
138 #undef ASM_DEFAULT_SPEC
140 #undef LINK_OS_NETBSD_SPEC
142 #ifndef RS6000_BI_ARCH
143 #define ASM_DEFAULT_SPEC "-mppc64"
144 #define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
145 #define LINK_OS_NETBSD_SPEC "%(link_os_netbsd_spec64)"
148 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
149 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
150 #define LINK_OS_NETBSD_SPEC "%{m32:%(link_os_netbsd_spec32)}%{!m32:%(link_os_netbsd_spec64)}"
152 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
153 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
154 #define LINK_OS_NETBSD_SPEC "%{!m64:%(link_os_netbsd_spec32)}%{m64:%(link_os_netbsd_spec64)}"
158 #define ASM_SPEC32 "-a32 %{n} %{T} %{Ym,*} %{Yd,*} \
159 %{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
160 %{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \
161 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
162 %{mcall-freebsd: -mbig} \
163 %{mcall-i960-old: -mlittle} \
164 %{mcall-linux: -mbig} \
165 %{mcall-netbsd: -mbig} \
166 %{mcall-gnu: -mbig} \
167 %{mcall-netbsd: -mbig} \
170 #define ASM_SPEC64 "-a64"
172 #define ASM_SPEC_COMMON "%(asm_cpu) \
173 %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
174 %{v:-V} %{Qy:} %{!Qn:-Qy} %{Wa,*:%*} \
175 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
177 #undef SUBSUBTARGET_EXTRA_SPECS
178 #define SUBSUBTARGET_EXTRA_SPECS \
179 { "asm_spec_common", ASM_SPEC_COMMON }, \
180 { "asm_spec32", ASM_SPEC32 }, \
181 { "asm_spec64", ASM_SPEC64 }, \
182 { "link_os_netbsd_spec32", LINK_OS_NETBSD_SPEC32 }, \
183 { "link_os_netbsd_spec64", LINK_OS_NETBSD_SPEC64 },
185 #undef MULTILIB_DEFAULTS
187 #define MULTILIB_DEFAULTS { "m64" }
189 #define MULTILIB_DEFAULTS { "m32" }
192 #ifndef RS6000_BI_ARCH
194 /* 64-bit PowerPC NetBSD is always big-endian. */
195 #undef TARGET_LITTLE_ENDIAN
196 #define TARGET_LITTLE_ENDIAN 0
198 /* 64-bit PowerPC NetBSD always has a TOC. */
202 /* Some things from sysv4.h we don't do when 64 bit. */
203 #undef TARGET_RELOCATABLE
204 #define TARGET_RELOCATABLE 0
206 #define TARGET_EABI 0
207 #undef TARGET_PROTOTYPE
208 #define TARGET_PROTOTYPE 0
209 #undef RELOCATABLE_NEEDS_FIXUP
210 #define RELOCATABLE_NEEDS_FIXUP 0
214 /* PowerPC64 NetBSD word-aligns FP doubles when -malign-power is given. */
215 #undef ADJUST_FIELD_ALIGN
216 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
217 ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \
220 && TARGET_ALIGN_NATURAL == 0 \
221 && TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
222 ? get_inner_array_type (FIELD) \
223 : TREE_TYPE (FIELD)) == DFmode) \
224 ? MIN ((COMPUTED), 32) \
227 /* PowerPC64 NetBSD increases natural record alignment to doubleword if
228 the first field is an FP double, only if in power alignment mode. */
229 #undef ROUND_TYPE_ALIGN
230 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
232 && (TREE_CODE (STRUCT) == RECORD_TYPE \
233 || TREE_CODE (STRUCT) == UNION_TYPE \
234 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
235 && TARGET_ALIGN_NATURAL == 0) \
236 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
237 : MAX ((COMPUTED), (SPECIFIED)))
239 /* Use the default for compiling target libs. */
240 #ifdef IN_TARGET_LIBS
241 #undef TARGET_ALIGN_NATURAL
242 #define TARGET_ALIGN_NATURAL 1
245 /* Indicate that jump tables go in the text section. */
246 #undef JUMP_TABLES_IN_TEXT_SECTION
247 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
249 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
250 than a doubleword should be padded upward or downward. You could
251 reasonably assume that they follow the normal rules for structure
252 layout treating the parameter area as any other block of memory,
253 then map the reg param area to registers. i.e. pad upward.
254 Setting both of the following defines results in this behavior.
255 Setting just the first one will result in aggregates that fit in a
256 doubleword being padded downward, and others being padded upward.
257 Not a bad idea as this results in struct { int x; } being passed
258 the same way as an int. */
259 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
260 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
262 /* Specify padding for the last element of a block move between
263 registers and memory. FIRST is nonzero if this is the only
265 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
266 (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
268 /* __throw will restore its own return address to be the same as the
269 return address of the function that the throw is being made to.
270 This is unfortunate, because we want to check the original
271 return address to see if we need to restore the TOC.
272 So we have to squirrel it away with this. */
273 #define SETUP_FRAME_ADDRESSES() \
274 do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0)
276 /* Override svr4.h */
277 #undef MD_EXEC_PREFIX
278 #undef MD_STARTFILE_PREFIX
280 /* NetBSD doesn't support saving and restoring 64-bit regs in a 32-bit
282 #define OS_MISSING_POWERPC64 !TARGET_64BIT
284 #undef TARGET_OS_CPP_BUILTINS
285 #define TARGET_OS_CPP_BUILTINS() \
288 NETBSD_OS_CPP_BUILTINS_ELF(); \
291 builtin_define ("__PPC__"); \
292 builtin_define ("__PPC64__"); \
293 builtin_define ("__powerpc__"); \
294 builtin_define ("__powerpc64__"); \
295 builtin_define ("__PIC__"); \
296 builtin_assert ("cpu=powerpc64"); \
297 builtin_assert ("machine=powerpc64"); \
301 builtin_define_std ("PPC"); \
302 builtin_define_std ("powerpc"); \
303 builtin_assert ("cpu=powerpc"); \
304 builtin_assert ("machine=powerpc"); \
305 TARGET_OS_SYSV_CPP_BUILTINS (); \
310 /* Override the default from rs6000.h to avoid conflicts with macros
311 defined in NetBSD header files. */
313 #undef RS6000_CPU_CPP_ENDIAN_BUILTINS
314 #define RS6000_CPU_CPP_ENDIAN_BUILTINS() \
317 if (BYTES_BIG_ENDIAN) \
319 builtin_define ("__BIG_ENDIAN__"); \
320 builtin_assert ("machine=bigendian"); \
324 builtin_define ("__LITTLE_ENDIAN__"); \
325 builtin_assert ("machine=littleendian"); \
330 #undef CPP_OS_DEFAULT_SPEC
331 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_netbsd)"
333 #undef LINK_SHLIB_SPEC
334 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
336 #undef LIB_DEFAULT_SPEC
337 #define LIB_DEFAULT_SPEC "%(lib_netbsd)"
339 #undef STARTFILE_DEFAULT_SPEC
340 #define STARTFILE_DEFAULT_SPEC "%(startfile_netbsd)"
342 #undef ENDFILE_DEFAULT_SPEC
343 #define ENDFILE_DEFAULT_SPEC "%(endfile_netbsd)"
345 #undef CRTSAVRES_DEFAULT_SPEC
346 #define CRTSAVRES_DEFAULT_SPEC ""
348 #undef LINK_START_DEFAULT_SPEC
349 #define LINK_START_DEFAULT_SPEC "%(link_start_netbsd)"
351 #undef LINK_OS_DEFAULT_SPEC
352 #define LINK_OS_DEFAULT_SPEC "%(link_os_netbsd)"
354 #define LINK_OS_NETBSD_SPEC32 "-m elf32ppc %{!shared: %{!static: \
355 %{rdynamic:-export-dynamic} \
356 %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}}"
358 #define LINK_OS_NETBSD_SPEC64 "-m elf64ppc %{!shared: %{!static: \
359 %{rdynamic:-export-dynamic} \
360 %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}}"
362 #undef TOC_SECTION_ASM_OP
363 #define TOC_SECTION_ASM_OP \
365 ? "\t.section\t\".toc\",\"aw\"" \
366 : "\t.section\t\".got\",\"aw\"")
368 #undef MINIMAL_TOC_SECTION_ASM_OP
369 #define MINIMAL_TOC_SECTION_ASM_OP \
371 ? "\t.section\t\".toc1\",\"aw\"" \
372 : ((TARGET_RELOCATABLE || flag_pic) \
373 ? "\t.section\t\".got2\",\"aw\"" \
374 : "\t.section\t\".got1\",\"aw\""))
376 #undef TARGET_VERSION
377 #define TARGET_VERSION fprintf (stderr, " (PowerPC64 NetBSD)");
379 /* Make GCC agree with <machine/ansi.h>. */
382 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
385 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
388 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
389 #undef WCHAR_TYPE_SIZE
390 #define WCHAR_TYPE_SIZE 32
392 /* Override rs6000.h definition. */
394 #define ASM_APP_ON "#APP\n"
396 /* Override rs6000.h definition. */
398 #define ASM_APP_OFF "#NO_APP\n"
400 /* PowerPC no-op instruction. */
401 #undef RS6000_CALL_GLUE
402 #define RS6000_CALL_GLUE (TARGET_64BIT ? "nop" : "cror 31,31,31")
405 #define RS6000_MCOUNT "_mcount"
408 /* _init and _fini functions are built from bits spread across many
409 object files, each potentially with a different TOC pointer. For
410 that reason, place a nop after the call so that the linker can
411 restore the TOC pointer if a TOC adjusting call stub is needed. */
413 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
414 asm (SECTION_OP "\n" \
419 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
420 asm (SECTION_OP "\n" \
427 /* FP save and restore routines. */
428 #undef SAVE_FP_PREFIX
429 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
430 #undef SAVE_FP_SUFFIX
431 #define SAVE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
432 #undef RESTORE_FP_PREFIX
433 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
434 #undef RESTORE_FP_SUFFIX
435 #define RESTORE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
437 /* Dwarf2 debugging. */
438 #undef PREFERRED_DEBUGGING_TYPE
439 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
441 /* This is how to declare the size of a function. */
442 #undef ASM_DECLARE_FUNCTION_SIZE
443 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
446 if (!flag_inhibit_size_directive) \
448 fputs ("\t.size\t", (FILE)); \
449 if (TARGET_64BIT && DOT_SYMBOLS) \
450 putc ('.', (FILE)); \
451 assemble_name ((FILE), (FNAME)); \
452 fputs (",.-", (FILE)); \
453 rs6000_output_function_entry (FILE, FNAME); \
454 putc ('\n', (FILE)); \
459 /* Return nonzero if this entry is to be written into the constant
460 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
461 or a CONST containing one of them. If -mfp-in-toc (the default),
462 we also do this for floating-point constants. We actually can only
463 do this if the FP formats of the target and host machines are the
464 same, but we can't check that since not every file that uses
465 GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when
466 we can write the entry into the TOC and the entry is not larger
469 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
470 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
472 && (GET_CODE (X) == SYMBOL_REF \
473 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
474 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
475 || GET_CODE (X) == LABEL_REF \
476 || (GET_CODE (X) == CONST_INT \
477 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
478 || (GET_CODE (X) == CONST_DOUBLE \
480 && (TARGET_POWERPC64 \
481 || TARGET_MINIMAL_TOC \
482 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
483 && ! TARGET_NO_FP_IN_TOC))) \
485 && !TARGET_NO_FP_IN_TOC \
486 && !TARGET_RELOCATABLE \
487 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
488 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
490 /* This ABI cannot use DBX_LINES_FUNCTION_RELATIVE, nor can it use
491 dbxout_stab_value_internal_label_diff, because we must
492 use the function code label, not the function descriptor label. */
493 #define DBX_OUTPUT_SOURCE_LINE(FILE, LINE, COUNTER) \
498 ASM_GENERATE_INTERNAL_LABEL (temp, "LM", COUNTER); \
499 dbxout_begin_stabn_sline (LINE); \
500 assemble_name (FILE, temp); \
502 s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \
503 rs6000_output_function_entry (FILE, s); \
505 targetm.asm_out.internal_label (FILE, "LM", COUNTER); \
510 /* Similarly, we want the function code label here. Cannot use
511 dbxout_stab_value_label_diff, as we have to use
512 rs6000_output_function_entry. FIXME. */
513 #define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \
517 dbxout_begin_stabn (BRAC); \
518 s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \
519 /* dbxout_block passes this macro the function name as NAME, \
520 assuming that it is the function code start label. In our \
521 case, the function name is the OPD entry. dbxout_block is \
522 broken, hack around it here. */ \
527 assemble_name (FILE, NAME); \
529 rs6000_output_function_entry (FILE, s); \
535 #define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
536 #define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
538 /* Another case where we want the dot name. */
539 #define DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL) \
543 dbxout_begin_empty_stabs (N_FUN); \
544 assemble_name (FILE, LSCOPE); \
546 s = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \
547 rs6000_output_function_entry (FILE, s); \
552 /* Select a format to encode pointers in exception handling data. CODE
553 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
554 true if the symbol may be affected by dynamic relocations. */
555 #undef ASM_PREFERRED_EH_DATA_FORMAT
556 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
557 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
558 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
559 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
562 /* For backward compatibility, we must continue to use the AIX
563 structure return convention. */
564 #undef DRAFT_V4_STRUCT_RET
565 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
567 #define TARGET_ASM_FILE_END rs6000_elf_end_indicate_exec_stack
569 #define TARGET_POSIX_IO
571 #define LINK_GCC_C_SEQUENCE_SPEC \
572 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
574 #define MD_UNWIND_SUPPORT "config/rs6000/linux-unwind.h"
576 #define POWERPC_NETBSD