netbsd64.h revision 1.1.1.8 1 /* Definitions of target machine for GNU compiler,
2 for 64 bit PowerPC NetBSD.
3 Copyright (C) 2006-2023 Free Software Foundation, Inc.
4 Contributed by Matthew Green (mrg (at) eterna.com.au).
5
6 This file is part of GCC.
7
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.
12
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.
17
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. */
22
23 /* Undef gnu-user.h macros we don't want. */
24 #undef CPLUSPLUS_CPP_SPEC
25 #undef LINK_GCC_C_SEQUENCE_SPEC
26
27 #ifndef RS6000_BI_ARCH
28
29 #undef DEFAULT_ABI
30 #define DEFAULT_ABI ABI_AIX
31
32 #undef TARGET_64BIT
33 #define TARGET_64BIT 1
34
35 #define DEFAULT_ARCH64_P 1
36 #define RS6000_BI_ARCH_P 0
37
38 #else
39
40 #define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
41 #define RS6000_BI_ARCH_P 1
42
43 #endif
44
45 #ifdef IN_LIBGCC2
46 #undef TARGET_64BIT
47 #ifdef __powerpc64__
48 #define TARGET_64BIT 1
49 #else
50 #define TARGET_64BIT 0
51 #endif
52 #endif
53
54 #undef TARGET_AIX
55 #define TARGET_AIX TARGET_64BIT
56
57 #ifdef HAVE_LD_NO_DOT_SYMS
58 /* New ABI uses a local sym for the function entry point. */
59 extern int dot_symbols;
60 #undef DOT_SYMBOLS
61 #define DOT_SYMBOLS dot_symbols
62 #endif
63
64 #define TARGET_PROFILE_KERNEL profile_kernel
65
66 #define TARGET_USES_LINUX64_OPT 1
67 #ifdef HAVE_LD_LARGE_TOC
68 #undef TARGET_CMODEL
69 #define TARGET_CMODEL rs6000_current_cmodel
70 #define SET_CMODEL(opt) rs6000_current_cmodel = opt
71 #else
72 #define SET_CMODEL(opt) do {} while (0)
73 #endif
74
75 #undef PROCESSOR_DEFAULT
76 #define PROCESSOR_DEFAULT PROCESSOR_POWER4
77 #undef PROCESSOR_DEFAULT64
78 #define PROCESSOR_DEFAULT64 PROCESSOR_POWER4
79
80 /* We don't need to generate entries in .fixup, except when
81 -mrelocatable or -mrelocatable-lib is given. */
82 #undef RELOCATABLE_NEEDS_FIXUP
83 #define RELOCATABLE_NEEDS_FIXUP \
84 (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
85
86 #undef RS6000_ABI_NAME
87 #define RS6000_ABI_NAME "netbsd"
88
89 #define INVALID_64BIT "-m%s not supported in this configuration"
90 #define INVALID_32BIT INVALID_64BIT
91
92 #define ELFv2_ABI_CHECK (rs6000_elf_abi == 2)
93
94 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
95 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
96 do rs6000_linux64_override_options (); while (0)
97
98 #undef ASM_DEFAULT_SPEC
99 #undef ASM_SPEC
100 #undef LINK_OS_NETBSD_SPEC
101 #undef LINK_SECURE_PLT_SPEC
102
103 #ifndef RS6000_BI_ARCH
104 #define ASM_DEFAULT_SPEC "-mppc64"
105 #define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
106 #define LINK_OS_NETBSD_SPEC "%(link_os_netbsd_spec64)"
107 #define LINK_SECURE_PLT_SPEC ""
108 #else
109 #if DEFAULT_ARCH64_P
110 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
111 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
112 #define LINK_OS_NETBSD_SPEC "%{m32:%(link_os_netbsd_spec32)}%{!m32:%(link_os_netbsd_spec64)}"
113 #define LINK_SECURE_PLT_SPEC "%{m32: " LINK_SECURE_PLT_DEFAULT_SPEC "}"
114 #else
115 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
116 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
117 #define LINK_OS_NETBSD_SPEC "%{!m64:%(link_os_netbsd_spec32)}%{m64:%(link_os_netbsd_spec64)}"
118 #define LINK_SECURE_PLT_SPEC "%{!m64: " LINK_SECURE_PLT_DEFAULT_SPEC "}"
119 #endif
120 #endif
121
122 #define ASM_SPEC32 "-a32 \
123 %{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
124 %{memb|msdata=eabi: -memb}"
125
126 #define ASM_SPEC64 "-a64"
127
128 #define ASM_SPEC_COMMON "%(asm_cpu) \
129 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
130 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
131
132 #undef SUBSUBTARGET_EXTRA_SPECS
133 #define SUBSUBTARGET_EXTRA_SPECS \
134 { "asm_spec_common", ASM_SPEC_COMMON }, \
135 { "asm_spec32", ASM_SPEC32 }, \
136 { "asm_spec64", ASM_SPEC64 }, \
137 { "link_os_netbsd_spec32", LINK_OS_NETBSD_SPEC32 }, \
138 { "link_os_netbsd_spec64", LINK_OS_NETBSD_SPEC64 },
139
140 #undef MULTILIB_DEFAULTS
141 #if DEFAULT_ARCH64_P
142 #define MULTILIB_DEFAULTS { "m64" }
143 #else
144 #define MULTILIB_DEFAULTS { "m32" }
145 #endif
146
147 #ifndef RS6000_BI_ARCH
148
149 /* 64-bit PowerPC NetBSD is always big-endian. */
150 #undef TARGET_LITTLE_ENDIAN
151 #define TARGET_LITTLE_ENDIAN 0
152
153 /* 64-bit PowerPC NetBSD always has a TOC. */
154 #undef TARGET_TOC
155 #define TARGET_TOC 1
156
157 /* Some things from sysv4.h we don't do when 64 bit. */
158 #undef TARGET_RELOCATABLE
159 #define TARGET_RELOCATABLE 0
160 #undef TARGET_EABI
161 #define TARGET_EABI 0
162 #undef TARGET_PROTOTYPE
163 #define TARGET_PROTOTYPE 0
164 #undef RELOCATABLE_NEEDS_FIXUP
165 #define RELOCATABLE_NEEDS_FIXUP 0
166
167 #endif
168
169 /* We use NetBSD libc _mcount for profiling. */
170 #define NO_PROFILE_COUNTERS 1
171 #define PROFILE_HOOK(LABEL) \
172 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
173
174 /* PowerPC64 NetBSD word-aligns FP doubles when -malign-power is given. */
175 #undef ADJUST_FIELD_ALIGN
176 #define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \
177 ((TARGET_64BIT \
178 && TARGET_ALIGN_NATURAL == 0 \
179 && TYPE_MODE (strip_array_types (TYPE)) == DFmode) \
180 ? MIN ((COMPUTED), 32) \
181 : (COMPUTED))
182
183 /* PowerPC64 NetBSD increases natural record alignment to doubleword if
184 the first field is an FP double, only if in power alignment mode. */
185 #undef ROUND_TYPE_ALIGN
186 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
187 ((TARGET_64BIT \
188 && (TREE_CODE (STRUCT) == RECORD_TYPE \
189 || TREE_CODE (STRUCT) == UNION_TYPE \
190 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
191 && TARGET_ALIGN_NATURAL == 0) \
192 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
193 : MAX ((COMPUTED), (SPECIFIED)))
194
195 /* Use the default for compiling target libs. */
196 #ifdef IN_TARGET_LIBS
197 #undef TARGET_ALIGN_NATURAL
198 #define TARGET_ALIGN_NATURAL 1
199 #endif
200
201 /* Indicate that jump tables go in the text section. */
202 #undef JUMP_TABLES_IN_TEXT_SECTION
203 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
204
205 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
206 than a doubleword should be padded upward or downward. You could
207 reasonably assume that they follow the normal rules for structure
208 layout treating the parameter area as any other block of memory,
209 then map the reg param area to registers. i.e. pad upward.
210 Setting both of the following defines results in this behavior.
211 Setting just the first one will result in aggregates that fit in a
212 doubleword being padded downward, and others being padded upward.
213 Not a bad idea as this results in struct { int x; } being passed
214 the same way as an int. */
215 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
216 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
217
218 /* Specify padding for the last element of a block move between
219 registers and memory. FIRST is nonzero if this is the only
220 element. */
221 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
222 (!(FIRST) ? PAD_UPWARD : targetm.calls.function_arg_padding (MODE, TYPE))
223
224 /* NetBSD doesn't support saving and restoring 64-bit regs in a 32-bit
225 process. */
226 #define OS_MISSING_POWERPC64 (!TARGET_64BIT)
227
228 #undef TARGET_OS_CPP_BUILTINS
229 #define TARGET_OS_CPP_BUILTINS() \
230 do \
231 { \
232 NETBSD_OS_CPP_BUILTINS_ELF(); \
233 builtin_define ("__PPC__"); \
234 builtin_define ("__ppc__"); \
235 builtin_define ("__powerpc__"); \
236 if (TARGET_ISEL) \
237 builtin_define ("__PPC_ISEL__"); \
238 if (TARGET_64BIT) \
239 { \
240 builtin_define ("__arch64__"); \
241 builtin_define ("__PPC64__"); \
242 builtin_define ("__powerpc64__"); \
243 builtin_define_with_int_value ("__PIC__", 2); \
244 builtin_assert ("cpu=powerpc64"); \
245 builtin_assert ("machine=powerpc64"); \
246 } \
247 else \
248 { \
249 builtin_define_std ("PPC"); \
250 builtin_define_std ("powerpc"); \
251 builtin_assert ("cpu=powerpc"); \
252 builtin_assert ("machine=powerpc"); \
253 TARGET_OS_SYSV_CPP_BUILTINS (); \
254 } \
255 } \
256 while (0)
257
258 /* Override the default from rs6000.h to avoid conflicts with macros
259 defined in NetBSD header files. */
260
261 #undef RS6000_CPU_CPP_ENDIAN_BUILTINS
262 #define RS6000_CPU_CPP_ENDIAN_BUILTINS() \
263 do \
264 { \
265 builtin_define ("__BIG_ENDIAN__"); \
266 builtin_assert ("machine=bigendian"); \
267 } \
268 while (0)
269
270 #undef CC1_OS_NETBSD_SPEC
271 #define CC1_OS_NETBSD_SPEC \
272 NETBSD_CC1_AND_CC1PLUS_SPEC \
273 "%{!m32: %{!mrelocatable: %{!fno-pie: %{!fno-pic: \
274 %{!fpie: %{!fpic: \
275 %{!fPIE: %{!fPIC:-fPIC}}}}}}}}"
276 /* %{!m32: %{!mcmodel*: -mcmodel=medium}}" */
277
278 #undef CC1PLUS_SPEC
279 #define CC1PLUS_SPEC CC1_OS_NETBSD_SPEC
280
281 #undef CPP_OS_DEFAULT_SPEC
282 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_netbsd)"
283
284 #undef LINK_SHLIB_SPEC
285 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
286
287 #undef LIB_DEFAULT_SPEC
288 #define LIB_DEFAULT_SPEC "%(lib_netbsd)"
289
290 #undef STARTFILE_DEFAULT_SPEC
291 #define STARTFILE_DEFAULT_SPEC "%(startfile_netbsd)"
292
293 #undef ENDFILE_DEFAULT_SPEC
294 #define ENDFILE_DEFAULT_SPEC "%(endfile_netbsd)"
295
296 #undef LINK_START_DEFAULT_SPEC
297 #define LINK_START_DEFAULT_SPEC "%(link_start_netbsd)"
298
299 #undef LINK_OS_DEFAULT_SPEC
300 #define LINK_OS_DEFAULT_SPEC "%(link_os_netbsd)"
301
302 #define LINK_OS_NETBSD_SPEC32 "-m elf32ppc %{!shared: %{!static: \
303 %{rdynamic:-export-dynamic} \
304 %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}}"
305
306 #define LINK_OS_NETBSD_SPEC64 "-m elf64ppc %{!shared: %{!static: \
307 %{rdynamic:-export-dynamic} \
308 %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}}"
309
310 /* Use standard DWARF numbering for DWARF debugging information. */
311 #define RS6000_USE_DWARF_NUMBERING
312
313 #undef TOC_SECTION_ASM_OP
314 #define TOC_SECTION_ASM_OP \
315 (TARGET_64BIT \
316 ? "\t.section\t\".toc\",\"aw\"" \
317 : "\t.section\t\".got\",\"aw\"")
318
319 #undef MINIMAL_TOC_SECTION_ASM_OP
320 #define MINIMAL_TOC_SECTION_ASM_OP \
321 (TARGET_64BIT \
322 ? "\t.section\t\".toc1\",\"aw\"" \
323 : (flag_pic \
324 ? "\t.section\t\".got2\",\"aw\"" \
325 : "\t.section\t\".got1\",\"aw\""))
326
327 /* This is how to declare the size of a function. */
328 #undef ASM_DECLARE_FUNCTION_SIZE
329 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
330 do \
331 { \
332 if (!flag_inhibit_size_directive) \
333 { \
334 fputs ("\t.size\t", (FILE)); \
335 if (TARGET_64BIT && DOT_SYMBOLS) \
336 putc ('.', (FILE)); \
337 assemble_name ((FILE), (FNAME)); \
338 fputs (",.-", (FILE)); \
339 rs6000_output_function_entry (FILE, FNAME); \
340 putc ('\n', (FILE)); \
341 } \
342 } \
343 while (0)
344
345 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
346 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
347 (TARGET_TOC \
348 && (SYMBOL_REF_P (X) \
349 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
350 && SYMBOL_REF_P (XEXP (XEXP (X, 0), 0))) \
351 || GET_CODE (X) == LABEL_REF \
352 || (CONST_INT_P (X) \
353 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
354 || (CONST_DOUBLE_P (X) \
355 && ((TARGET_64BIT \
356 && (TARGET_MINIMAL_TOC \
357 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
358 && ! TARGET_NO_FP_IN_TOC))) \
359 || (!TARGET_64BIT \
360 && !TARGET_NO_FP_IN_TOC \
361 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
362 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
363
364 /* Make GCC agree with <machine/ansi.h>. */
365
366 #undef SIZE_TYPE
367 #define SIZE_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
368
369 #undef PTRDIFF_TYPE
370 #define PTRDIFF_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
371
372 #undef INTPTR_TYPE
373 #define INTPTR_TYPE PTRDIFF_TYPE
374
375 #undef UINTPTR_TYPE
376 #define UINTPTR_TYPE SIZE_TYPE
377
378 #undef WCHAR_TYPE
379 #define WCHAR_TYPE "int"
380
381 #undef INT8_TYPE
382 #define INT8_TYPE "signed char"
383
384 #undef INT16_TYPE
385 #define INT16_TYPE "short int"
386
387 #undef INT32_TYPE
388 #define INT32_TYPE "int"
389
390 #undef INT64_TYPE
391 #define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
392
393 #undef UINT8_TYPE
394 #define UINT8_TYPE "unsigned char"
395
396 #undef UINT16_TYPE
397 #define UINT16_TYPE "short unsigned int"
398
399 #undef UINT32_TYPE
400 #define UINT32_TYPE "unsigned int"
401
402 #undef UINT64_TYPE
403 #define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
404
405 #undef INT_FAST8_TYPE
406 #define INT_FAST8_TYPE "int"
407
408 #undef INT_FAST16_TYPE
409 #define INT_FAST16_TYPE "int"
410
411 #undef INT_FAST32_TYPE
412 #define INT_FAST32_TYPE "int"
413
414 #undef INT_FAST64_TYPE
415 #define INT_FAST64_TYPE INT64_TYPE
416
417 #undef UINT_FAST8_TYPE
418 #define UINT_FAST8_TYPE "unsigned int"
419
420 #undef UINT_FAST16_TYPE
421 #define UINT_FAST16_TYPE "unsigned int"
422
423 #undef UINT_FAST32_TYPE
424 #define UINT_FAST32_TYPE "unsigned int"
425
426 #undef UINT_FAST8_TYPE
427 #define UINT_FAST8_TYPE "unsigned int"
428
429 #undef UINT_FAST16_TYPE
430 #define UINT_FAST16_TYPE "unsigned int"
431
432 #undef UINT_FAST32_TYPE
433 #define UINT_FAST32_TYPE "unsigned int"
434
435 #undef UINT_FAST64_TYPE
436 #define UINT_FAST64_TYPE UINT64_TYPE
437
438 #undef INT_LEAST8_TYPE
439 #define INT_LEAST8_TYPE INT8_TYPE
440
441 #undef INT_LEAST16_TYPE
442 #define INT_LEAST16_TYPE INT16_TYPE
443
444 #undef INT_LEAST32_TYPE
445 #define INT_LEAST32_TYPE "int"
446
447 #undef INT_LEAST64_TYPE
448 #define INT_LEAST64_TYPE INT64_TYPE
449
450 #undef UINT_LEAST8_TYPE
451 #define UINT_LEAST8_TYPE UINT8_TYPE
452
453 #undef UINT_LEAST16_TYPE
454 #define UINT_LEAST16_TYPE UINT16_TYPE
455
456 #undef UINT_LEAST32_TYPE
457 #define UINT_LEAST32_TYPE "unsigned int"
458
459 #undef UINT_LEAST64_TYPE
460 #define UINT_LEAST64_TYPE UINT64_TYPE
461
462 #undef INTMAX_TYPE
463 #define INTMAX_TYPE INT64_TYPE
464
465 #undef UINTMAX_TYPE
466 #define UINTMAX_TYPE UINT64_TYPE
467
468 #if 0
469 /* Override rs6000.h definition. */
470 #undef ASM_APP_ON
471 #define ASM_APP_ON "#APP\n"
472
473 /* Override rs6000.h definition. */
474 #undef ASM_APP_OFF
475 #define ASM_APP_OFF "#NO_APP\n"
476 #endif
477
478 #undef RS6000_MCOUNT
479 #define RS6000_MCOUNT "_mcount"
480
481 #ifdef __powerpc64__
482 /* _init and _fini functions are built from bits spread across many
483 object files, each potentially with a different TOC pointer. For
484 that reason, place a nop after the call so that the linker can
485 restore the TOC pointer if a TOC adjusting call stub is needed. */
486 #if DOT_SYMBOLS
487 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
488 asm (SECTION_OP "\n" \
489 " bl ." #FUNC "\n" \
490 " nop\n" \
491 " .previous");
492 #else
493 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
494 asm (SECTION_OP "\n" \
495 " bl " #FUNC "\n" \
496 " nop\n" \
497 " .previous");
498 #endif
499 #endif
500
501 /* FP save and restore routines. */
502 #undef SAVE_FP_PREFIX
503 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
504 #undef RESTORE_FP_PREFIX
505 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
506
507 /* For backward compatibility, we must continue to use the AIX
508 structure return convention. */
509 #undef DRAFT_V4_STRUCT_RET
510 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
511
512 /* Use --as-needed -lgcc_s for eh support. */
513 #ifdef HAVE_LD_AS_NEEDED
514 #define USE_LD_AS_NEEDED 1
515 #endif
516
517 /*
518 * NetBSD ppc64 used to have 128-bit long double support.
519 * But it does not work anymore:
520 * (insn 23 22 24 5 (set (reg:CCFP 179)
521 * (compare:CCFP (reg/v:TF 171 [ a ])
522 * (reg:TF 177)))
523 * "/usr/src/sys/external/bsd/compiler_rt/dist/lib/builtins/fixxfti.c":43 -1
524 */
525 #undef RS6000_DEFAULT_LONG_DOUBLE_SIZE
526 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
527
528 #define POWERPC_NETBSD
529
530 /* The IEEE 128-bit emulator is only built on Linux systems. Flag that we
531 should enable the type handling for KFmode on VSX systems even if we are not
532 enabling the __float128 keyword. */
533 #undef TARGET_FLOAT128_ENABLE_TYPE
534 #define TARGET_FLOAT128_ENABLE_TYPE 1
535