freebsd64.h: Remove duplicated entries from last commit.
[gcc.git] / gcc / config / rs6000 / freebsd64.h
1 /* Definitions for 64-bit PowerPC running FreeBSD using the ELF format
2 Copyright (C) 2012 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your
9 option) any later version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
19
20 /* Override the defaults, which exist to force the proper definition. */
21
22 #ifdef IN_LIBGCC2
23 #undef TARGET_64BIT
24 #ifdef __powerpc64__
25 #define TARGET_64BIT 1
26 #else
27 #define TARGET_64BIT 0
28 #endif
29 #endif
30
31 #undef TARGET_AIX
32 #define TARGET_AIX TARGET_64BIT
33
34 #ifdef HAVE_LD_NO_DOT_SYMS
35 /* New ABI uses a local sym for the function entry point. */
36 extern int dot_symbols;
37 #undef DOT_SYMBOLS
38 #define DOT_SYMBOLS dot_symbols
39 #endif
40
41 #define TARGET_USES_LINUX64_OPT 1
42 #ifdef HAVE_LD_LARGE_TOC
43 #undef TARGET_CMODEL
44 #define TARGET_CMODEL rs6000_current_cmodel
45 #define SET_CMODEL(opt) rs6000_current_cmodel = opt
46 #else
47 #define SET_CMODEL(opt) do {} while (0)
48 #endif
49
50 /* Until now the 970 is the only Processor where FreeBSD 64-bit runs on. */
51 #undef PROCESSOR_DEFAULT
52 #define PROCESSOR_DEFAULT PROCESSOR_POWER4
53 #undef PROCESSOR_DEFAULT64
54 #define PROCESSOR_DEFAULT64 PROCESSOR_POWER4
55
56 /* We don't need to generate entries in .fixup, except when
57 -mrelocatable or -mrelocatable-lib is given. */
58 #undef RELOCATABLE_NEEDS_FIXUP
59 #define RELOCATABLE_NEEDS_FIXUP \
60 (target_flags & target_flags_explicit & MASK_RELOCATABLE)
61
62 #undef RS6000_ABI_NAME
63 #define RS6000_ABI_NAME "freebsd"
64
65 #define INVALID_64BIT "-m%s not supported in this configuration"
66 #define INVALID_32BIT INVALID_64BIT
67
68 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
69 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
70 do \
71 { \
72 if (!global_options_set.x_rs6000_alignment_flags) \
73 rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
74 if (TARGET_64BIT) \
75 { \
76 if (DEFAULT_ABI != ABI_AIX) \
77 { \
78 rs6000_current_abi = ABI_AIX; \
79 error (INVALID_64BIT, "call"); \
80 } \
81 dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
82 if (target_flags & MASK_RELOCATABLE) \
83 { \
84 target_flags &= ~MASK_RELOCATABLE; \
85 error (INVALID_64BIT, "relocatable"); \
86 } \
87 if (target_flags & MASK_EABI) \
88 { \
89 target_flags &= ~MASK_EABI; \
90 error (INVALID_64BIT, "eabi"); \
91 } \
92 if (TARGET_PROTOTYPE) \
93 { \
94 target_prototype = 0; \
95 error (INVALID_64BIT, "prototype"); \
96 } \
97 if ((target_flags & MASK_POWERPC64) == 0) \
98 { \
99 target_flags |= MASK_POWERPC64; \
100 error ("-m64 requires a PowerPC64 cpu"); \
101 } \
102 if ((target_flags_explicit & MASK_MINIMAL_TOC) != 0) \
103 { \
104 if (global_options_set.x_rs6000_current_cmodel \
105 && rs6000_current_cmodel != CMODEL_SMALL) \
106 error ("-mcmodel incompatible with other toc options"); \
107 SET_CMODEL (CMODEL_SMALL); \
108 } \
109 else \
110 { \
111 if (!global_options_set.x_rs6000_current_cmodel) \
112 SET_CMODEL (CMODEL_MEDIUM); \
113 if (rs6000_current_cmodel != CMODEL_SMALL) \
114 { \
115 TARGET_NO_FP_IN_TOC = 0; \
116 TARGET_NO_SUM_IN_TOC = 0; \
117 } \
118 } \
119 } \
120 } \
121 while (0)
122
123 #undef ASM_DEFAULT_SPEC
124 #undef ASM_SPEC
125 #undef LINK_OS_FREEBSD_SPEC
126
127 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
128 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
129 #define LINK_OS_FREEBSD_SPEC "%{m32:%(link_os_freebsd_spec32)}%{!m32:%(link_os_freebsd_spec64)}"
130
131 #define ASM_SPEC32 "-a32 \
132 %{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
133 %{memb} %{!memb: %{msdata=eabi: -memb}} \
134 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
135 %{mcall-freebsd: -mbig} \
136 %{mcall-i960-old: -mlittle} \
137 %{mcall-linux: -mbig} \
138 %{mcall-gnu: -mbig} \
139 %{mcall-netbsd: -mbig} \
140 }}}}"
141
142 #define ASM_SPEC64 "-a64"
143
144 #define ASM_SPEC_COMMON "%(asm_cpu) \
145 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \
146 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
147
148 #undef SUBSUBTARGET_EXTRA_SPECS
149 #define SUBSUBTARGET_EXTRA_SPECS \
150 { "asm_spec_common", ASM_SPEC_COMMON }, \
151 { "asm_spec32", ASM_SPEC32 }, \
152 { "asm_spec64", ASM_SPEC64 }, \
153 { "link_os_freebsd_spec32", LINK_OS_FREEBSD_SPEC32 }, \
154 { "link_os_freebsd_spec64", LINK_OS_FREEBSD_SPEC64 },
155
156 #define FREEBSD_DYNAMIC_LINKER32 "/libexec/ld-elf32.so.1"
157 #define FREEBSD_DYNAMIC_LINKER64 "/libexec/ld-elf.so.1"
158
159 #define LINK_OS_FREEBSD_SPEC_DEF32 "\
160 %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
161 %{v:-V} \
162 %{assert*} %{R*} %{rpath*} %{defsym*} \
163 %{shared:-Bshareable %{h*} %{soname*}} \
164 %{!shared: \
165 %{!static: \
166 %{rdynamic: -export-dynamic} \
167 %{!dynamic-linker:-dynamic-linker " FREEBSD_DYNAMIC_LINKER32 "}} \
168 %{static:-Bstatic}} \
169 %{symbolic:-Bsymbolic}"
170
171 #define LINK_OS_FREEBSD_SPEC_DEF64 "\
172 %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
173 %{v:-V} \
174 %{assert*} %{R*} %{rpath*} %{defsym*} \
175 %{shared:-Bshareable %{h*} %{soname*}} \
176 %{!shared: \
177 %{!static: \
178 %{rdynamic: -export-dynamic} \
179 %{!dynamic-linker:-dynamic-linker " FREEBSD_DYNAMIC_LINKER64 "}} \
180 %{static:-Bstatic}} \
181 %{symbolic:-Bsymbolic}"
182
183 #define LINK_OS_FREEBSD_SPEC32 "-melf32ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF32
184
185 #define LINK_OS_FREEBSD_SPEC64 "-melf64ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF64
186
187 #undef MULTILIB_DEFAULTS
188 #define MULTILIB_DEFAULTS { "m64" }
189
190 /* PowerPC-64 FreeBSD increases natural record alignment to doubleword if
191 the first field is an FP double, only if in power alignment mode. */
192 #undef ROUND_TYPE_ALIGN
193 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
194 ((TARGET_64BIT \
195 && (TREE_CODE (STRUCT) == RECORD_TYPE \
196 || TREE_CODE (STRUCT) == UNION_TYPE \
197 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
198 && TARGET_ALIGN_NATURAL == 0) \
199 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
200 : MAX ((COMPUTED), (SPECIFIED)))
201
202 /* Use the default for compiling target libs. */
203 #ifdef IN_TARGET_LIBS
204 #undef TARGET_ALIGN_NATURAL
205 #define TARGET_ALIGN_NATURAL 1
206 #endif
207
208 /* Indicate that jump tables go in the text section. */
209 #undef JUMP_TABLES_IN_TEXT_SECTION
210 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
211
212 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
213 than a doubleword should be padded upward or downward. You could
214 reasonably assume that they follow the normal rules for structure
215 layout treating the parameter area as any other block of memory,
216 then map the reg param area to registers. i.e. pad upward.
217 Setting both of the following defines results in this behavior.
218 Setting just the first one will result in aggregates that fit in a
219 doubleword being padded downward, and others being padded upward.
220 Not a bad idea as this results in struct { int x; } being passed
221 the same way as an int. */
222 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
223 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
224
225 /* Specify padding for the last element of a block move between
226 registers and memory. FIRST is nonzero if this is the only
227 element. */
228 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
229 (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
230
231 /* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit
232 kernel. This is supported when running on a 64-bit kernel with
233 COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries
234 are compatible. */
235 #define OS_MISSING_POWERPC64 !TARGET_64BIT
236
237 #undef FBSD_TARGET_CPU_CPP_BUILTINS
238 #define FBSD_TARGET_CPU_CPP_BUILTINS() \
239 do \
240 { \
241 builtin_define ("__PPC__"); \
242 builtin_define ("__ppc__"); \
243 builtin_define ("__powerpc__"); \
244 if (TARGET_64BIT) \
245 { \
246 builtin_define ("__arch64__"); \
247 builtin_define ("__LP64__"); \
248 builtin_define ("__PPC64__"); \
249 builtin_define ("__powerpc64__"); \
250 builtin_assert ("cpu=powerpc64"); \
251 builtin_assert ("machine=powerpc64"); \
252 } \
253 else \
254 { \
255 builtin_define_std ("PPC"); \
256 builtin_define_std ("powerpc"); \
257 builtin_assert ("cpu=powerpc"); \
258 builtin_assert ("machine=powerpc"); \
259 TARGET_OS_SYSV_CPP_BUILTINS (); \
260 } \
261 } \
262 while (0)
263
264 #undef CPP_OS_DEFAULT_SPEC
265 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_freebsd)"
266
267 #undef CPP_OS_FREEBSD_SPEC
268 #define CPP_OS_FREEBSD_SPEC ""
269
270 #undef STARTFILE_DEFAULT_SPEC
271 #define STARTFILE_DEFAULT_SPEC "%(startfile_freebsd)"
272
273 #undef ENDFILE_DEFAULT_SPEC
274 #define ENDFILE_DEFAULT_SPEC "%(endfile_freebsd)"
275
276 #undef LIB_DEFAULT_SPEC
277 #define LIB_DEFAULT_SPEC "%(lib_freebsd)"
278
279 #undef LINK_START_DEFAULT_SPEC
280 #define LINK_START_DEFAULT_SPEC "%(link_start_freebsd)"
281
282 #undef LINK_OS_DEFAULT_SPEC
283 #define LINK_OS_DEFAULT_SPEC "%(link_os_freebsd)"
284
285 /* XXX: This is wrong for many platforms in sysv4.h.
286 We should work on getting that definition fixed. */
287 #undef LINK_SHLIB_SPEC
288 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
289
290
291 /************************[ Target stuff ]***********************************/
292
293 /* Define the actual types of some ANSI-mandated types.
294 Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c,
295 c-common.c, and config/<arch>/<arch>.h. */
296
297
298 #undef SIZE_TYPE
299 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
300
301 #undef PTRDIFF_TYPE
302 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
303
304 /* rs6000.h gets this wrong for FreeBSD. We use the GCC defaults instead. */
305 #undef WCHAR_TYPE
306 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
307 #undef WCHAR_TYPE_SIZE
308 #define WCHAR_TYPE_SIZE 32
309
310
311 /* Override rs6000.h definition. */
312 #undef ASM_APP_ON
313 #define ASM_APP_ON "#APP\n"
314
315 /* Override rs6000.h definition. */
316 #undef ASM_APP_OFF
317 #define ASM_APP_OFF "#NO_APP\n"
318
319 /* PowerPC no-op instruction. */
320 #undef RS6000_CALL_GLUE
321 #define RS6000_CALL_GLUE (TARGET_64BIT ? "nop" : "cror 31,31,31")
322
323 /* Function profiling bits */
324 #undef RS6000_MCOUNT
325 #define RS6000_MCOUNT "_mcount"
326
327 #define PROFILE_HOOK(LABEL) \
328 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
329
330 /* _init and _fini functions are built from bits spread across many
331 object files, each potentially with a different TOC pointer. For
332 that reason, place a nop after the call so that the linker can
333 restore the TOC pointer if a TOC adjusting call stub is needed. */
334 #ifdef __powerpc64__
335 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
336 asm (SECTION_OP "\n" \
337 " bl " #FUNC "\n" \
338 " nop\n" \
339 " .previous");
340 #endif
341
342 /* FP save and restore routines. */
343 #undef SAVE_FP_PREFIX
344 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
345 #undef SAVE_FP_SUFFIX
346 #define SAVE_FP_SUFFIX ""
347 #undef RESTORE_FP_PREFIX
348 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
349 #undef RESTORE_FP_SUFFIX
350 #define RESTORE_FP_SUFFIX ""
351
352 /* Select a format to encode pointers in exception handling data. CODE
353 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
354 true if the symbol may be affected by dynamic relocations. */
355 #undef ASM_PREFERRED_EH_DATA_FORMAT
356 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
357 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
358 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
359 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
360 : DW_EH_PE_absptr)
361
362 /* Static stack checking is supported by means of probes. */
363 #define STACK_CHECK_STATIC_BUILTIN 1
364
365 /* The default value isn't sufficient in 64-bit mode. */
366 #define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024)
367
368 #define DBX_REGISTER_NUMBER(REGNO) rs6000_dbx_register_number (REGNO)
369
370 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */
371 #undef ADJUST_FIELD_ALIGN
372 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
373 ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \
374 ? 128 \
375 : (TARGET_64BIT \
376 && TARGET_ALIGN_NATURAL == 0 \
377 && TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode) \
378 ? MIN ((COMPUTED), 32) \
379 : (COMPUTED))
380
381 #undef TOC_SECTION_ASM_OP
382 #define TOC_SECTION_ASM_OP \
383 (TARGET_64BIT \
384 ? "\t.section\t\".toc\",\"aw\"" \
385 : "\t.section\t\".got\",\"aw\"")
386
387 #undef MINIMAL_TOC_SECTION_ASM_OP
388 #define MINIMAL_TOC_SECTION_ASM_OP \
389 (TARGET_64BIT \
390 ? "\t.section\t\".toc1\",\"aw\"" \
391 : ((TARGET_RELOCATABLE || flag_pic) \
392 ? "\t.section\t\".got2\",\"aw\"" \
393 : "\t.section\t\".got1\",\"aw\""))
394
395 /* This is how to declare the size of a function. */
396 #undef ASM_DECLARE_FUNCTION_SIZE
397 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
398 do \
399 { \
400 if (!flag_inhibit_size_directive) \
401 { \
402 fputs ("\t.size\t", (FILE)); \
403 if (TARGET_64BIT && DOT_SYMBOLS) \
404 putc ('.', (FILE)); \
405 assemble_name ((FILE), (FNAME)); \
406 fputs (",.-", (FILE)); \
407 rs6000_output_function_entry (FILE, FNAME); \
408 putc ('\n', (FILE)); \
409 } \
410 } \
411 while (0)
412
413 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
414 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
415 (TARGET_TOC \
416 && (GET_CODE (X) == SYMBOL_REF \
417 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
418 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
419 || GET_CODE (X) == LABEL_REF \
420 || (GET_CODE (X) == CONST_INT \
421 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
422 || (GET_CODE (X) == CONST_DOUBLE \
423 && ((TARGET_64BIT \
424 && (TARGET_MINIMAL_TOC \
425 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
426 && ! TARGET_NO_FP_IN_TOC))) \
427 || (!TARGET_64BIT \
428 && !TARGET_NO_FP_IN_TOC \
429 && !TARGET_RELOCATABLE \
430 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
431 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
432
433 /* Use --as-needed -lgcc_s for eh support. */
434 #ifdef HAVE_LD_AS_NEEDED
435 #define USE_LD_AS_NEEDED 1
436 #endif
437
438 #define POWERPC_FREEBSD