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