1 /* Definitions of target machine for GNU compiler,
2 for 64 bit PowerPC linux.
3 Copyright (C) 2000-2015 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 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 #define TARGET_PROFILE_KERNEL profile_kernel
62 #define TARGET_USES_LINUX64_OPT 1
63 #ifdef HAVE_LD_LARGE_TOC
65 #define TARGET_CMODEL rs6000_current_cmodel
66 #define SET_CMODEL(opt) rs6000_current_cmodel = opt
68 #define SET_CMODEL(opt) do {} while (0)
71 #undef PROCESSOR_DEFAULT
72 #define PROCESSOR_DEFAULT PROCESSOR_POWER7
73 #undef PROCESSOR_DEFAULT64
74 #define PROCESSOR_DEFAULT64 PROCESSOR_POWER8
76 /* We don't need to generate entries in .fixup, except when
77 -mrelocatable or -mrelocatable-lib is given. */
78 #undef RELOCATABLE_NEEDS_FIXUP
79 #define RELOCATABLE_NEEDS_FIXUP \
80 (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
82 #undef RS6000_ABI_NAME
83 #define RS6000_ABI_NAME "linux"
85 #define INVALID_64BIT "-m%s not supported in this configuration"
86 #define INVALID_32BIT INVALID_64BIT
88 #ifdef LINUX64_DEFAULT_ABI_ELFv2
89 #define ELFv2_ABI_CHECK (rs6000_elf_abi != 1)
91 #define ELFv2_ABI_CHECK (rs6000_elf_abi == 2)
94 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
95 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
98 if (!global_options_set.x_rs6000_alignment_flags) \
99 rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
102 if (DEFAULT_ABI != ABI_AIX) \
104 rs6000_current_abi = ABI_AIX; \
105 error (INVALID_64BIT, "call"); \
107 dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
108 if (ELFv2_ABI_CHECK) \
110 rs6000_current_abi = ABI_ELFv2; \
112 error ("-mcall-aixdesc incompatible with -mabi=elfv2"); \
114 if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \
116 rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
117 error (INVALID_64BIT, "relocatable"); \
119 if (rs6000_isa_flags & OPTION_MASK_EABI) \
121 rs6000_isa_flags &= ~OPTION_MASK_EABI; \
122 error (INVALID_64BIT, "eabi"); \
124 if (TARGET_PROTOTYPE) \
126 target_prototype = 0; \
127 error (INVALID_64BIT, "prototype"); \
129 if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \
131 rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
132 error ("-m64 requires a PowerPC64 cpu"); \
134 if ((rs6000_isa_flags_explicit \
135 & OPTION_MASK_MINIMAL_TOC) != 0) \
137 if (global_options_set.x_rs6000_current_cmodel \
138 && rs6000_current_cmodel != CMODEL_SMALL) \
139 error ("-mcmodel incompatible with other toc options"); \
140 SET_CMODEL (CMODEL_SMALL); \
144 if (!global_options_set.x_rs6000_current_cmodel) \
145 SET_CMODEL (CMODEL_MEDIUM); \
146 if (rs6000_current_cmodel != CMODEL_SMALL) \
148 if (!global_options_set.x_TARGET_NO_FP_IN_TOC) \
149 TARGET_NO_FP_IN_TOC \
150 = rs6000_current_cmodel == CMODEL_MEDIUM; \
151 if (!global_options_set.x_TARGET_NO_SUM_IN_TOC) \
152 TARGET_NO_SUM_IN_TOC = 0; \
158 if (!RS6000_BI_ARCH_P) \
159 error (INVALID_32BIT, "32"); \
160 if (TARGET_PROFILE_KERNEL) \
162 TARGET_PROFILE_KERNEL = 0; \
163 error (INVALID_32BIT, "profile-kernel"); \
165 if (global_options_set.x_rs6000_current_cmodel) \
167 SET_CMODEL (CMODEL_SMALL); \
168 error (INVALID_32BIT, "cmodel"); \
174 #undef ASM_DEFAULT_SPEC
176 #undef LINK_OS_LINUX_SPEC
178 #ifndef RS6000_BI_ARCH
179 #define ASM_DEFAULT_SPEC "-mppc64"
180 #define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
181 #define LINK_OS_LINUX_SPEC "%(link_os_linux_spec64)"
184 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
185 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
186 #define LINK_OS_LINUX_SPEC "%{m32:%(link_os_linux_spec32)}%{!m32:%(link_os_linux_spec64)}"
188 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
189 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
190 #define LINK_OS_LINUX_SPEC "%{!m64:%(link_os_linux_spec32)}%{m64:%(link_os_linux_spec64)}"
194 #define ASM_SPEC32 "-a32 \
195 %{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \
196 %{memb|msdata=eabi: -memb}"
198 #define ASM_SPEC64 "-a64"
200 #define ASM_SPEC_COMMON "%(asm_cpu) \
201 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
202 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
204 #undef SUBSUBTARGET_EXTRA_SPECS
205 #define SUBSUBTARGET_EXTRA_SPECS \
206 { "asm_spec_common", ASM_SPEC_COMMON }, \
207 { "asm_spec32", ASM_SPEC32 }, \
208 { "asm_spec64", ASM_SPEC64 }, \
209 { "link_os_linux_spec32", LINK_OS_LINUX_SPEC32 }, \
210 { "link_os_linux_spec64", LINK_OS_LINUX_SPEC64 },
212 #undef MULTILIB_DEFAULTS
214 #define MULTILIB_DEFAULTS { "m64" }
216 #define MULTILIB_DEFAULTS { "m32" }
219 #ifndef RS6000_BI_ARCH
221 /* 64-bit PowerPC Linux always has a TOC. */
225 /* Some things from sysv4.h we don't do when 64 bit. */
226 #undef OPTION_RELOCATABLE
227 #define OPTION_RELOCATABLE 0
229 #define OPTION_EABI 0
230 #undef OPTION_PROTOTYPE
231 #define OPTION_PROTOTYPE 0
232 #undef RELOCATABLE_NEEDS_FIXUP
233 #define RELOCATABLE_NEEDS_FIXUP 0
237 /* We use glibc _mcount for profiling. */
238 #define NO_PROFILE_COUNTERS 1
239 #define PROFILE_HOOK(LABEL) \
240 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
242 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */
243 #undef ADJUST_FIELD_ALIGN
244 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
245 (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED)) \
248 && TARGET_ALIGN_NATURAL == 0 \
249 && TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode) \
250 ? MIN ((COMPUTED), 32) \
253 /* PowerPC64 Linux increases natural record alignment to doubleword if
254 the first field is an FP double, only if in power alignment mode. */
255 #undef ROUND_TYPE_ALIGN
256 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
258 && (TREE_CODE (STRUCT) == RECORD_TYPE \
259 || TREE_CODE (STRUCT) == UNION_TYPE \
260 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
261 && TARGET_ALIGN_NATURAL == 0) \
262 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
263 : MAX ((COMPUTED), (SPECIFIED)))
265 /* Use the default for compiling target libs. */
266 #ifdef IN_TARGET_LIBS
267 #undef TARGET_ALIGN_NATURAL
268 #define TARGET_ALIGN_NATURAL 1
271 /* Indicate that jump tables go in the text section. */
272 #undef JUMP_TABLES_IN_TEXT_SECTION
273 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
275 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
276 than a doubleword should be padded upward or downward. You could
277 reasonably assume that they follow the normal rules for structure
278 layout treating the parameter area as any other block of memory,
279 then map the reg param area to registers. i.e. pad upward.
280 Setting both of the following defines results in this behavior.
281 Setting just the first one will result in aggregates that fit in a
282 doubleword being padded downward, and others being padded upward.
283 Not a bad idea as this results in struct { int x; } being passed
284 the same way as an int. */
285 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
286 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
288 /* Specify padding for the last element of a block move between
289 registers and memory. FIRST is nonzero if this is the only
291 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
292 (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
294 /* Linux doesn't support saving and restoring 64-bit regs in a 32-bit
296 #define OS_MISSING_POWERPC64 !TARGET_64BIT
299 #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
300 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
301 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
303 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
304 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
305 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
308 /* Determine what functions are present at the runtime;
309 this includes full c99 runtime and sincos. */
310 #undef TARGET_LIBC_HAS_FUNCTION
311 #define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function
313 #undef TARGET_OS_CPP_BUILTINS
314 #define TARGET_OS_CPP_BUILTINS() \
319 builtin_define ("__PPC__"); \
320 builtin_define ("__PPC64__"); \
321 builtin_define ("__powerpc__"); \
322 builtin_define ("__powerpc64__"); \
324 builtin_define ("_CALL_LINUX"); \
325 builtin_assert ("cpu=powerpc64"); \
326 builtin_assert ("machine=powerpc64"); \
330 builtin_define_std ("PPC"); \
331 builtin_define_std ("powerpc"); \
332 builtin_assert ("cpu=powerpc"); \
333 builtin_assert ("machine=powerpc"); \
334 TARGET_OS_SYSV_CPP_BUILTINS (); \
339 #undef CPP_OS_DEFAULT_SPEC
340 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
342 #undef LINK_SHLIB_SPEC
343 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
345 #undef LIB_DEFAULT_SPEC
346 #define LIB_DEFAULT_SPEC "%(lib_linux)"
348 #undef STARTFILE_DEFAULT_SPEC
349 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
351 #undef ENDFILE_DEFAULT_SPEC
352 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
354 #undef LINK_START_DEFAULT_SPEC
355 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
357 #undef LINK_OS_DEFAULT_SPEC
358 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
360 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
361 #ifdef LINUX64_DEFAULT_ABI_ELFv2
362 #define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:/lib64/ld64.so.1;:/lib64/ld64.so.2}"
364 #define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:/lib64/ld64.so.2;:/lib64/ld64.so.1}"
366 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
367 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
368 #if DEFAULT_LIBC == LIBC_UCLIBC
369 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
370 #elif DEFAULT_LIBC == LIBC_GLIBC
371 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
373 #error "Unsupported DEFAULT_LIBC"
375 #define GNU_USER_DYNAMIC_LINKER32 \
376 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
377 #define GNU_USER_DYNAMIC_LINKER64 \
378 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
380 #undef DEFAULT_ASM_ENDIAN
381 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
382 #define DEFAULT_ASM_ENDIAN " -mlittle"
383 #define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \
384 " -m elf32lppclinux", \
385 " -m elf32lppclinux")
386 #define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \
390 #define DEFAULT_ASM_ENDIAN " -mbig"
391 #define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \
392 " -m elf32lppclinux", \
394 #define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \
399 #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
400 %{rdynamic:-export-dynamic} \
401 -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}"
403 #define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \
404 %{rdynamic:-export-dynamic} \
405 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}"
407 #undef TOC_SECTION_ASM_OP
408 #define TOC_SECTION_ASM_OP \
410 ? "\t.section\t\".toc\",\"aw\"" \
411 : "\t.section\t\".got\",\"aw\"")
413 #undef MINIMAL_TOC_SECTION_ASM_OP
414 #define MINIMAL_TOC_SECTION_ASM_OP \
416 ? "\t.section\t\".toc1\",\"aw\"" \
417 : ((TARGET_RELOCATABLE || flag_pic) \
418 ? "\t.section\t\".got2\",\"aw\"" \
419 : "\t.section\t\".got1\",\"aw\""))
421 /* Must be at least as big as our pointer type. */
423 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
426 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
429 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
430 #undef WCHAR_TYPE_SIZE
431 #define WCHAR_TYPE_SIZE 32
434 #define RS6000_MCOUNT "_mcount"
437 /* _init and _fini functions are built from bits spread across many
438 object files, each potentially with a different TOC pointer. For
439 that reason, place a nop after the call so that the linker can
440 restore the TOC pointer if a TOC adjusting call stub is needed. */
442 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
443 asm (SECTION_OP "\n" \
448 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
449 asm (SECTION_OP "\n" \
456 /* FP save and restore routines. */
457 #undef SAVE_FP_PREFIX
458 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
459 #undef SAVE_FP_SUFFIX
460 #define SAVE_FP_SUFFIX ""
461 #undef RESTORE_FP_PREFIX
462 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
463 #undef RESTORE_FP_SUFFIX
464 #define RESTORE_FP_SUFFIX ""
466 /* Dwarf2 debugging. */
467 #undef PREFERRED_DEBUGGING_TYPE
468 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
470 /* This is how to declare the size of a function. */
471 #undef ASM_DECLARE_FUNCTION_SIZE
472 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
475 if (!flag_inhibit_size_directive) \
477 fputs ("\t.size\t", (FILE)); \
478 if (TARGET_64BIT && DOT_SYMBOLS) \
479 putc ('.', (FILE)); \
480 assemble_name ((FILE), (FNAME)); \
481 fputs (",.-", (FILE)); \
482 rs6000_output_function_entry (FILE, FNAME); \
483 putc ('\n', (FILE)); \
488 /* Return nonzero if this entry is to be written into the constant
489 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
490 or a CONST containing one of them. If -mfp-in-toc (the default),
491 we also do this for floating-point constants. We actually can only
492 do this if the FP formats of the target and host machines are the
493 same, but we can't check that since not every file that uses
494 the macros includes real.h. We also do this when we can write the
495 entry into the TOC and the entry is not larger than a TOC entry. */
497 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
498 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
500 && (GET_CODE (X) == SYMBOL_REF \
501 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
502 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
503 || GET_CODE (X) == LABEL_REF \
504 || (GET_CODE (X) == CONST_INT \
505 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
506 || (GET_CODE (X) == CONST_DOUBLE \
508 && (TARGET_MINIMAL_TOC \
509 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
510 && ! TARGET_NO_FP_IN_TOC))) \
512 && !TARGET_NO_FP_IN_TOC \
513 && !TARGET_RELOCATABLE \
514 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
515 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
517 /* Select a format to encode pointers in exception handling data. CODE
518 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
519 true if the symbol may be affected by dynamic relocations. */
520 #undef ASM_PREFERRED_EH_DATA_FORMAT
521 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
522 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
523 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
524 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
527 /* For backward compatibility, we must continue to use the AIX
528 structure return convention. */
529 #undef DRAFT_V4_STRUCT_RET
530 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
532 #ifdef TARGET_LIBC_PROVIDES_SSP
533 /* ppc32 glibc provides __stack_chk_guard in -0x7008(2),
534 ppc64 glibc provides it at -0x7010(13). */
535 #define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? -0x7010 : -0x7008)
538 #define POWERPC_LINUX
540 /* ppc{32,64} linux has 128-bit long double support in glibc 2.4 and later. */
541 #ifdef TARGET_DEFAULT_LONG_DOUBLE_128
542 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
545 /* Static stack checking is supported by means of probes. */
546 #define STACK_CHECK_STATIC_BUILTIN 1
548 /* The default value isn't sufficient in 64-bit mode. */
549 #define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024)
551 /* Software floating point support for exceptions and rounding modes
552 depends on the C library in use. */
553 #undef TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P
554 #define TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P \
555 rs6000_linux_float_exceptions_rounding_supported_p
557 /* Support for TARGET_ATOMIC_ASSIGN_EXPAND_FENV without FPRs depends
558 on glibc 2.19 or greater. */
559 #if TARGET_GLIBC_MAJOR > 2 \
560 || (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 19)
561 #define RS6000_GLIBC_ATOMIC_FENV 1