]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/linux64.h
1 /* Definitions of target machine for GNU compiler,
2 for 64 bit PowerPC linux.
3 Copyright (C) 2000-2013 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License 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 #ifndef RS6000_BI_ARCH
29 #define DEFAULT_ABI ABI_AIX
32 #define TARGET_64BIT 1
34 #define DEFAULT_ARCH64_P 1
35 #define RS6000_BI_ARCH_P 0
39 #define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
40 #define RS6000_BI_ARCH_P 1
47 #define TARGET_64BIT 1
49 #define TARGET_64BIT 0
54 #define TARGET_AIX TARGET_64BIT
56 #ifdef HAVE_LD_NO_DOT_SYMS
57 /* New ABI uses a local sym for the function entry point. */
58 extern int dot_symbols
;
60 #define DOT_SYMBOLS dot_symbols
63 #define TARGET_PROFILE_KERNEL profile_kernel
65 #define TARGET_USES_LINUX64_OPT 1
66 #ifdef HAVE_LD_LARGE_TOC
68 #define TARGET_CMODEL rs6000_current_cmodel
69 #define SET_CMODEL(opt) rs6000_current_cmodel = opt
71 #define SET_CMODEL(opt) do {} while (0)
74 #undef PROCESSOR_DEFAULT
75 #define PROCESSOR_DEFAULT PROCESSOR_POWER7
76 #undef PROCESSOR_DEFAULT64
77 #define PROCESSOR_DEFAULT64 PROCESSOR_POWER7
79 /* We don't need to generate entries in .fixup, except when
80 -mrelocatable or -mrelocatable-lib is given. */
81 #undef RELOCATABLE_NEEDS_FIXUP
82 #define RELOCATABLE_NEEDS_FIXUP \
83 (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
85 #undef RS6000_ABI_NAME
86 #define RS6000_ABI_NAME "linux"
88 #define INVALID_64BIT "-m%s not supported in this configuration"
89 #define INVALID_32BIT INVALID_64BIT
91 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
92 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
95 if (!global_options_set.x_rs6000_alignment_flags) \
96 rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
99 if (DEFAULT_ABI != ABI_AIX) \
101 rs6000_current_abi = ABI_AIX; \
102 error (INVALID_64BIT, "call"); \
104 dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
105 if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \
107 rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
108 error (INVALID_64BIT, "relocatable"); \
110 if (rs6000_isa_flags & OPTION_MASK_EABI) \
112 rs6000_isa_flags &= ~OPTION_MASK_EABI; \
113 error (INVALID_64BIT, "eabi"); \
115 if (TARGET_PROTOTYPE) \
117 target_prototype = 0; \
118 error (INVALID_64BIT, "prototype"); \
120 if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \
122 rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
123 error ("-m64 requires a PowerPC64 cpu"); \
125 if ((rs6000_isa_flags_explicit \
126 & OPTION_MASK_MINIMAL_TOC) != 0) \
128 if (global_options_set.x_rs6000_current_cmodel \
129 && rs6000_current_cmodel != CMODEL_SMALL) \
130 error ("-mcmodel incompatible with other toc options"); \
131 SET_CMODEL (CMODEL_SMALL); \
135 if (!global_options_set.x_rs6000_current_cmodel) \
136 SET_CMODEL (CMODEL_MEDIUM); \
137 if (rs6000_current_cmodel != CMODEL_SMALL) \
139 if (!global_options_set.x_TARGET_NO_FP_IN_TOC) \
140 TARGET_NO_FP_IN_TOC \
141 = rs6000_current_cmodel == CMODEL_MEDIUM; \
142 if (!global_options_set.x_TARGET_NO_SUM_IN_TOC) \
143 TARGET_NO_SUM_IN_TOC = 0; \
149 if (!RS6000_BI_ARCH_P) \
150 error (INVALID_32BIT, "32"); \
151 if (TARGET_PROFILE_KERNEL) \
153 TARGET_PROFILE_KERNEL = 0; \
154 error (INVALID_32BIT, "profile-kernel"); \
156 if (global_options_set.x_rs6000_current_cmodel) \
158 SET_CMODEL (CMODEL_SMALL); \
159 error (INVALID_32BIT, "cmodel"); \
165 #undef ASM_DEFAULT_SPEC
167 #undef LINK_OS_LINUX_SPEC
169 #ifndef RS6000_BI_ARCH
170 #define ASM_DEFAULT_SPEC "-mppc64"
171 #define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
172 #define LINK_OS_LINUX_SPEC "%(link_os_linux_spec64)"
175 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
176 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
177 #define LINK_OS_LINUX_SPEC "%{m32:%(link_os_linux_spec32)}%{!m32:%(link_os_linux_spec64)}"
179 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
180 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
181 #define LINK_OS_LINUX_SPEC "%{!m64:%(link_os_linux_spec32)}%{m64:%(link_os_linux_spec64)}"
185 #define ASM_SPEC32 "-a32 \
186 %{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \
187 %{memb|msdata=eabi: -memb}"
189 #define ASM_SPEC64 "-a64"
191 #define ASM_SPEC_COMMON "%(asm_cpu) \
192 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
193 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
195 #undef SUBSUBTARGET_EXTRA_SPECS
196 #define SUBSUBTARGET_EXTRA_SPECS \
197 { "asm_spec_common", ASM_SPEC_COMMON }, \
198 { "asm_spec32", ASM_SPEC32 }, \
199 { "asm_spec64", ASM_SPEC64 }, \
200 { "link_os_linux_spec32", LINK_OS_LINUX_SPEC32 }, \
201 { "link_os_linux_spec64", LINK_OS_LINUX_SPEC64 },
203 #undef MULTILIB_DEFAULTS
205 #define MULTILIB_DEFAULTS { "m64" }
207 #define MULTILIB_DEFAULTS { "m32" }
210 #ifndef RS6000_BI_ARCH
212 /* 64-bit PowerPC Linux always has a TOC. */
216 /* Some things from sysv4.h we don't do when 64 bit. */
217 #undef OPTION_RELOCATABLE
218 #define OPTION_RELOCATABLE 0
220 #define OPTION_EABI 0
221 #undef OPTION_PROTOTYPE
222 #define OPTION_PROTOTYPE 0
223 #undef RELOCATABLE_NEEDS_FIXUP
224 #define RELOCATABLE_NEEDS_FIXUP 0
228 /* We use glibc _mcount for profiling. */
229 #define NO_PROFILE_COUNTERS 1
230 #define PROFILE_HOOK(LABEL) \
231 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
233 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */
234 #undef ADJUST_FIELD_ALIGN
235 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
236 ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \
239 && TARGET_ALIGN_NATURAL == 0 \
240 && TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode) \
241 ? MIN ((COMPUTED), 32) \
244 /* PowerPC64 Linux increases natural record alignment to doubleword if
245 the first field is an FP double, only if in power alignment mode. */
246 #undef ROUND_TYPE_ALIGN
247 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
249 && (TREE_CODE (STRUCT) == RECORD_TYPE \
250 || TREE_CODE (STRUCT) == UNION_TYPE \
251 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
252 && TARGET_ALIGN_NATURAL == 0) \
253 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
254 : MAX ((COMPUTED), (SPECIFIED)))
256 /* Use the default for compiling target libs. */
257 #ifdef IN_TARGET_LIBS
258 #undef TARGET_ALIGN_NATURAL
259 #define TARGET_ALIGN_NATURAL 1
262 /* Indicate that jump tables go in the text section. */
263 #undef JUMP_TABLES_IN_TEXT_SECTION
264 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
266 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
267 than a doubleword should be padded upward or downward. You could
268 reasonably assume that they follow the normal rules for structure
269 layout treating the parameter area as any other block of memory,
270 then map the reg param area to registers. i.e. pad upward.
271 Setting both of the following defines results in this behavior.
272 Setting just the first one will result in aggregates that fit in a
273 doubleword being padded downward, and others being padded upward.
274 Not a bad idea as this results in struct { int x; } being passed
275 the same way as an int. */
276 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
277 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
279 /* Specify padding for the last element of a block move between
280 registers and memory. FIRST is nonzero if this is the only
282 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
283 (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
285 /* Linux doesn't support saving and restoring 64-bit regs in a 32-bit
287 #define OS_MISSING_POWERPC64 !TARGET_64BIT
290 #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
291 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
292 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
294 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
295 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
296 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
299 /* Determine what functions are present at the runtime;
300 this includes full c99 runtime and sincos. */
301 #undef TARGET_LIBC_HAS_FUNCTION
302 #define TARGET_LIBC_HAS_FUNCTION linux_android_libc_has_function
304 #undef TARGET_OS_CPP_BUILTINS
305 #define TARGET_OS_CPP_BUILTINS() \
310 builtin_define ("__PPC__"); \
311 builtin_define ("__PPC64__"); \
312 builtin_define ("__powerpc__"); \
313 builtin_define ("__powerpc64__"); \
315 builtin_define ("_CALL_LINUX"); \
316 builtin_assert ("cpu=powerpc64"); \
317 builtin_assert ("machine=powerpc64"); \
321 builtin_define_std ("PPC"); \
322 builtin_define_std ("powerpc"); \
323 builtin_assert ("cpu=powerpc"); \
324 builtin_assert ("machine=powerpc"); \
325 TARGET_OS_SYSV_CPP_BUILTINS (); \
330 #undef CPP_OS_DEFAULT_SPEC
331 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
333 /* The GNU C++ standard library currently requires _GNU_SOURCE being
334 defined on glibc-based systems. This temporary hack accomplishes this,
335 it should go away as soon as libstdc++-v3 has a real fix. */
336 #undef CPLUSPLUS_CPP_SPEC
337 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
339 #undef LINK_SHLIB_SPEC
340 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
342 #undef LIB_DEFAULT_SPEC
343 #define LIB_DEFAULT_SPEC "%(lib_linux)"
345 #undef STARTFILE_DEFAULT_SPEC
346 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
348 #undef ENDFILE_DEFAULT_SPEC
349 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
351 #undef LINK_START_DEFAULT_SPEC
352 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
354 #undef LINK_OS_DEFAULT_SPEC
355 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
357 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
358 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
359 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
360 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
361 #if DEFAULT_LIBC == LIBC_UCLIBC
362 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
363 #elif DEFAULT_LIBC == LIBC_GLIBC
364 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
366 #error "Unsupported DEFAULT_LIBC"
368 #define GNU_USER_DYNAMIC_LINKER32 \
369 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
370 #define GNU_USER_DYNAMIC_LINKER64 \
371 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
373 #undef DEFAULT_ASM_ENDIAN
374 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
375 #define DEFAULT_ASM_ENDIAN " -mlittle"
376 #define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \
377 " -m elf32lppclinux", \
378 " -m elf32lppclinux")
379 #define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \
383 #define DEFAULT_ASM_ENDIAN " -mbig"
384 #define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \
385 " -m elf32lppclinux", \
387 #define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \
392 #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
393 %{rdynamic:-export-dynamic} \
394 -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}"
396 #define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \
397 %{rdynamic:-export-dynamic} \
398 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}"
400 #undef TOC_SECTION_ASM_OP
401 #define TOC_SECTION_ASM_OP \
403 ? "\t.section\t\".toc\",\"aw\"" \
404 : "\t.section\t\".got\",\"aw\"")
406 #undef MINIMAL_TOC_SECTION_ASM_OP
407 #define MINIMAL_TOC_SECTION_ASM_OP \
409 ? "\t.section\t\".toc1\",\"aw\"" \
410 : ((TARGET_RELOCATABLE || flag_pic) \
411 ? "\t.section\t\".got2\",\"aw\"" \
412 : "\t.section\t\".got1\",\"aw\""))
414 /* Must be at least as big as our pointer type. */
416 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
419 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
422 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
423 #undef WCHAR_TYPE_SIZE
424 #define WCHAR_TYPE_SIZE 32
426 /* Override rs6000.h definition. */
428 #define ASM_APP_ON "#APP\n"
430 /* Override rs6000.h definition. */
432 #define ASM_APP_OFF "#NO_APP\n"
435 #define RS6000_MCOUNT "_mcount"
438 /* _init and _fini functions are built from bits spread across many
439 object files, each potentially with a different TOC pointer. For
440 that reason, place a nop after the call so that the linker can
441 restore the TOC pointer if a TOC adjusting call stub is needed. */
443 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
444 asm (SECTION_OP "\n" \
449 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
450 asm (SECTION_OP "\n" \
457 /* FP save and restore routines. */
458 #undef SAVE_FP_PREFIX
459 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
460 #undef SAVE_FP_SUFFIX
461 #define SAVE_FP_SUFFIX ""
462 #undef RESTORE_FP_PREFIX
463 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
464 #undef RESTORE_FP_SUFFIX
465 #define RESTORE_FP_SUFFIX ""
467 /* Dwarf2 debugging. */
468 #undef PREFERRED_DEBUGGING_TYPE
469 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
471 /* This is how to declare the size of a function. */
472 #undef ASM_DECLARE_FUNCTION_SIZE
473 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
476 if (!flag_inhibit_size_directive) \
478 fputs ("\t.size\t", (FILE)); \
479 if (TARGET_64BIT && DOT_SYMBOLS) \
480 putc ('.', (FILE)); \
481 assemble_name ((FILE), (FNAME)); \
482 fputs (",.-", (FILE)); \
483 rs6000_output_function_entry (FILE, FNAME); \
484 putc ('\n', (FILE)); \
489 /* Return nonzero if this entry is to be written into the constant
490 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
491 or a CONST containing one of them. If -mfp-in-toc (the default),
492 we also do this for floating-point constants. We actually can only
493 do this if the FP formats of the target and host machines are the
494 same, but we can't check that since not every file that uses
495 the macros includes real.h. We also do this when we can write the
496 entry into the TOC and the entry is not larger than a TOC entry. */
498 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
499 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
501 && (GET_CODE (X) == SYMBOL_REF \
502 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
503 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
504 || GET_CODE (X) == LABEL_REF \
505 || (GET_CODE (X) == CONST_INT \
506 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
507 || (GET_CODE (X) == CONST_DOUBLE \
509 && (TARGET_MINIMAL_TOC \
510 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
511 && ! TARGET_NO_FP_IN_TOC))) \
513 && !TARGET_NO_FP_IN_TOC \
514 && !TARGET_RELOCATABLE \
515 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
516 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
518 /* Select a format to encode pointers in exception handling data. CODE
519 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
520 true if the symbol may be affected by dynamic relocations. */
521 #undef ASM_PREFERRED_EH_DATA_FORMAT
522 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
523 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
524 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
525 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
528 /* For backward compatibility, we must continue to use the AIX
529 structure return convention. */
530 #undef DRAFT_V4_STRUCT_RET
531 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
533 #define TARGET_POSIX_IO
535 #define LINK_GCC_C_SEQUENCE_SPEC \
536 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
538 /* Use --as-needed -lgcc_s for eh support. */
539 #ifdef HAVE_LD_AS_NEEDED
540 #define USE_LD_AS_NEEDED 1
543 #ifdef TARGET_LIBC_PROVIDES_SSP
544 /* ppc32 glibc provides __stack_chk_guard in -0x7008(2),
545 ppc64 glibc provides it at -0x7010(13). */
546 #define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? -0x7010 : -0x7008)
549 #define POWERPC_LINUX
551 /* ppc{32,64} linux has 128-bit long double support in glibc 2.4 and later. */
552 #ifdef TARGET_DEFAULT_LONG_DOUBLE_128
553 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
556 /* Static stack checking is supported by means of probes. */
557 #define STACK_CHECK_STATIC_BUILTIN 1
559 /* The default value isn't sufficient in 64-bit mode. */
560 #define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024)