PR target/16407
[official-gcc.git] / gcc / config / mips / iris6.h
blob9730a6c0bcf25ba8fad0005c2317f7d6ea2619fc
1 /* Definitions of target machine for GNU compiler. IRIX version 6.
2 Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* No more special IRIX 5 handling. */
23 #undef TARGET_IRIX5
24 #define TARGET_IRIX5 0
26 /* Default to -mabi=n32 and -mips3. */
27 #undef MULTILIB_DEFAULTS
28 #define MULTILIB_DEFAULTS { "mabi=n32" }
30 /* The IRIX 6 O32 assembler cannot calculate label differences, while both
31 the N32/N64 assembler and gas can. Override setting in iris5.h file. */
32 #undef DWARF2_UNWIND_INFO
33 #define DWARF2_UNWIND_INFO !TARGET_SGI_O32_AS
35 /* The IRIX 6 assembler will sometimes assign labels to the wrong
36 section unless the labels are within .ent/.end blocks. Therefore,
37 we avoid creating such labels. */
38 #define DWARF2_GENERATE_TEXT_SECTION_LABEL 0
40 /* wchar_t is defined differently with and without -mabi=64. */
42 #undef WCHAR_TYPE
43 #define WCHAR_TYPE (Pmode == DImode ? "int" : "long int")
45 #undef WCHAR_TYPE_SIZE
46 #define WCHAR_TYPE_SIZE 32
48 /* Same for wint_t. */
50 #undef WINT_TYPE
51 #define WINT_TYPE (Pmode == DImode ? "int" : "long int")
53 #undef WINT_TYPE_SIZE
54 #define WINT_TYPE_SIZE 32
56 /* For IRIX 6, -mabi=64 implies TARGET_LONG64. */
57 /* This is handled in override_options. */
59 /* Default to the mips2 ISA for the O32 ABI. */
60 #undef SUBTARGET_CC1_SPEC
61 #define SUBTARGET_CC1_SPEC "%{mabi=32: %{!mips*: -mips2}}"
63 /* #line directives let the O32 assembler create object files that cause the
64 O32 linker to crash. */
65 #undef SUBTARGET_CPP_SPEC
66 #define SUBTARGET_CPP_SPEC "%{mabi=32: %{.S:-P}}"
68 /* We must pass -D_LONGLONG always, even when -ansi is used, because IRIX 6
69 system header files require it. This is OK, because gcc never warns
70 when long long is used in system header files. Alternatively, we can
71 add support for the SGI builtin type __long_long. */
73 /* The GNU C++ standard library requires that __EXTENSIONS__ and
74 _SGI_SOURCE be defined on at least IRIX 6.2 and probably all IRIX 6
75 prior to 6.5. They normally get defined if !ansi, for g++ we want
76 them regardless. We don't need this on IRIX 6.5 itself, but it
77 shouldn't hurt other than the namespace pollution. */
79 /* Undefine because this includes iris5.h. */
80 #undef TARGET_OS_CPP_BUILTINS
81 #define TARGET_OS_CPP_BUILTINS() \
82 do { \
83 builtin_define_std ("host_mips"); \
84 builtin_define ("_LONGLONG"); \
85 builtin_define ("_MODERN_C"); \
86 builtin_define ("_SVR4_SOURCE"); \
87 builtin_define_std ("SYSTYPE_SVR4"); \
88 builtin_define ("__DSO__"); \
89 builtin_define_std ("unix"); \
90 builtin_define_std ("sgi"); \
91 builtin_assert ("system=svr4"); \
92 builtin_assert ("system=unix"); \
93 builtin_assert ("machine=sgi"); \
95 if (mips_abi == ABI_32) \
96 { \
97 builtin_define ("_ABIO32=1"); \
98 builtin_define ("_MIPS_SIM=_ABIO32"); \
99 builtin_define ("_MIPS_SZLONG=32"); \
100 builtin_define ("_MIPS_SZPTR=32"); \
102 else if (mips_abi == ABI_64) \
104 builtin_define ("_ABI64=3"); \
105 builtin_define ("_MIPS_SIM=_ABI64"); \
106 builtin_define ("_MIPS_SZLONG=64"); \
107 builtin_define ("_MIPS_SZPTR=64"); \
109 else \
111 builtin_define ("_ABIN32=2"); \
112 builtin_define ("_MIPS_SIM=_ABIN32"); \
113 builtin_define ("_MIPS_SZLONG=32"); \
114 builtin_define ("_MIPS_SZPTR=32"); \
117 if (!TARGET_FLOAT64) \
118 builtin_define ("_MIPS_FPSET=16"); \
119 else \
120 builtin_define ("_MIPS_FPSET=32"); \
122 if (!TARGET_INT64) \
123 builtin_define ("_MIPS_SZINT=32"); \
124 else \
125 builtin_define ("_MIPS_SZINT=64"); \
127 if (!ISA_MIPS1 && !ISA_MIPS2) \
128 builtin_define ("_COMPILER_VERSION=601"); \
130 /* IRIX 6.5.18 and above provide many ISO C99 \
131 features protected by the __c99 macro. \
132 libstdc++ v3 needs them as well. */ \
133 if ((!c_dialect_cxx () && flag_isoc99) \
134 || c_dialect_cxx ()) \
135 builtin_define ("__c99"); \
137 if (c_dialect_cxx ()) \
139 builtin_define ("__EXTENSIONS__"); \
140 builtin_define ("_SGI_SOURCE"); \
143 if (!flag_iso) \
145 builtin_define ("__EXTENSIONS__"); \
146 builtin_define ("_SGI_SOURCE"); \
148 } while (0)
150 /* IRIX 6 uses DWARF-2. */
151 #define DWARF2_DEBUGGING_INFO 1
152 #define MIPS_DEBUGGING_INFO 1
153 #undef PREFERRED_DEBUGGING_TYPE
154 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
156 /* Force the generation of dwarf .debug_frame sections even if not
157 compiling -g. This guarantees that we can unwind the stack. */
158 #define DWARF2_FRAME_INFO !TARGET_SGI_O32_AS
160 /* The size in bytes of a DWARF field indicating an offset or length
161 relative to a debug info section, specified to be 4 bytes in the DWARF-2
162 specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
163 #define DWARF_OFFSET_SIZE PTR_SIZE
165 /* The size in bytes of the initial length field in a debug info
166 section. The DWARF 3 (draft) specification defines this to be
167 either 4 or 12 (with a 4-byte "escape" word when it's 12), but the
168 SGI/MIPS ABI predates this standard and defines it to be the same
169 as DWARF_OFFSET_SIZE. */
170 #define DWARF_INITIAL_LENGTH_SIZE DWARF_OFFSET_SIZE
172 /* There is no GNU as port for IRIX 6 yet, so we set MD_EXEC_PREFIX so that
173 gcc will automatically find SGI as instead of searching the user's path.
174 The latter can fail when building a cross compiler if the user has . in
175 the path before /usr/bin, since then gcc will find and try to use the link
176 to the cross assembler which can't possibly work. */
178 #undef MD_EXEC_PREFIX
179 #define MD_EXEC_PREFIX "/usr/bin/"
181 /* We have no need for MD_STARTFILE_PREFIX. */
182 #undef MD_STARTFILE_PREFIX
184 #undef MACHINE_TYPE
185 #define MACHINE_TYPE "SGI running IRIX 6.x"
187 /* Stuff we need for IRIX 6 that isn't in IRIX 5. */
189 /* The SGI assembler doesn't like labels before the .ent, so we must output
190 the .ent and function name here, which is the normal place for it. */
192 #undef ASM_DECLARE_FUNCTION_NAME
193 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
194 do { \
195 if (mips_abi != ABI_32) \
197 fputs ("\t.ent\t", STREAM); \
198 assemble_name (STREAM, NAME); \
199 fputs ("\n", STREAM); \
200 assemble_name (STREAM, NAME); \
201 fputs (":\n", STREAM); \
203 } while (0)
205 /* Likewise, the SGI assembler doesn't like labels after the .end, so we
206 must output the .end here. */
207 #undef ASM_DECLARE_FUNCTION_SIZE
208 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
209 do { \
210 if (mips_abi == ABI_32) \
212 tree name_tree = get_identifier (NAME); \
213 TREE_ASM_WRITTEN (name_tree) = 1; \
215 else \
217 fputs ("\t.end\t", STREAM); \
218 assemble_name (STREAM, NAME); \
219 fputs ("\n", STREAM); \
221 } while (0)
223 /* Tell function_prologue in mips.c that we have already output the .ent/.end
224 pseudo-ops. */
225 #undef FUNCTION_NAME_ALREADY_DECLARED
226 #define FUNCTION_NAME_ALREADY_DECLARED (mips_abi != ABI_32)
228 #undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */
230 #if 0
231 /* This is *NOT* how to equate one symbol to another symbol. The assembler
232 '=' syntax just equates a name to a constant expression.
233 See ASM_OUTPUT_WEAK_ALIAS. */
235 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
236 do { fprintf ((FILE), "\t"); \
237 assemble_name (FILE, LABEL1); \
238 fprintf (FILE, " = "); \
239 assemble_name (FILE, LABEL2); \
240 fprintf (FILE, "\n"); \
241 } while (0)
242 #endif
244 /* Define the strings used for the special svr4 .type and .size directives. */
246 #define TYPE_ASM_OP "\t.type\t"
247 #define SIZE_ASM_OP "\t.size\t"
249 /* IRIX assembler does not support the init_priority C++ attribute. */
250 #undef SUPPORTS_INIT_PRIORITY
251 #define SUPPORTS_INIT_PRIORITY 0
253 /* A linker error can empirically be avoided by removing duplicate
254 library search directories. */
255 #define LINK_ELIMINATE_DUPLICATE_LDIRECTORIES 1
257 #define POPSECTION_ASM_OP "\t.popsection"
259 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
260 on the mipsX option. */
261 /* If no mips[3,4] option given, give the appropriate default for mabi=X */
262 #undef SUBTARGET_ASM_SPEC
263 #define SUBTARGET_ASM_SPEC "%{!mabi*:-n32} %{mabi=32:-32} %{!mips*: %{!mabi*:-mips3} %{mabi=32:-mips2} %{mabi=n32|mabi=64:-mips3}}"
265 /* Must pass -g0 to the assembler, otherwise it may overwrite our
266 debug info with its own debug info. */
267 /* Must pass -show instead of -v. */
268 /* Must pass -G 0 to the assembler, otherwise we may get warnings about
269 GOT overflow. */
270 /* Must pass -w to the assembler to quiet warnings about .ent/.end for dwarf2. */
271 #if ((TARGET_CPU_DEFAULT | TARGET_DEFAULT) & MASK_GAS) == 0
272 /* We have a separate file for gas. */
273 #undef SUBTARGET_MIPS_AS_ASM_SPEC
274 #define SUBTARGET_MIPS_AS_ASM_SPEC "%{v:-show} -G 0 -w"
276 #undef SUBTARGET_ASM_DEBUGGING_SPEC
277 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
279 /* The MIPS assembler occasionally misoptimizes. Since GCC should be
280 doing scheduling anyhow, just turn off optimization in the assembler. */
281 #undef SUBTARGET_ASM_OPTIMIZING_SPEC
282 #define SUBTARGET_ASM_OPTIMIZING_SPEC "-O0"
283 #endif
285 /* The assembler now accepts .section pseudo-ops, but it does not allow
286 one to change the section in the middle of a function, so we can't use
287 the INIT_SECTION_ASM_OP code in crtstuff. But we can build up the ctor
288 and dtor lists this way, so we use -init and -fini to invoke the
289 do_global_* functions instead of running collect2. */
291 #undef BSS_SECTION_ASM_OP
292 #define BSS_SECTION_ASM_OP_32 "\t.data"
293 #define BSS_SECTION_ASM_OP_64 "\t.section\t.bss"
294 #define BSS_SECTION_ASM_OP \
295 (mips_abi != ABI_32 && mips_abi != ABI_O64 \
296 ? BSS_SECTION_ASM_OP_64 \
297 : BSS_SECTION_ASM_OP_32)
299 #undef READONLY_DATA_SECTION_ASM_OP
300 #define READONLY_DATA_SECTION_ASM_OP_32 "\t.rdata"
301 #define READONLY_DATA_SECTION_ASM_OP_64 "\t.section\t.rodata"
302 #define READONLY_DATA_SECTION_ASM_OP \
303 (mips_abi != ABI_32 && mips_abi != ABI_O64 \
304 ? READONLY_DATA_SECTION_ASM_OP_64 \
305 : READONLY_DATA_SECTION_ASM_OP_32)
307 /* The default definition in defaults.h cannot cope with the runtime-variable
308 definition of DWARF2_UNWIND_INFO above, so define here explicitly. */
309 #define EH_FRAME_SECTION_NAME ".eh_frame"
311 /* MUST_USE_SJLJ_EXCEPTIONS has the same problem. */
312 #define MUST_USE_SJLJ_EXCEPTIONS (DWARF2_UNWIND_INFO == 0)
314 /* The native IRIX 6 O32 assembler doesn't support named sections, while
315 the N32/N64 assembler does. We need crt{begin, end}.o for the N32/N64
316 ABIs, but there's no way to disable them for just one multilib.
317 Therefore we provide dummy definitions to allow crtstuff.c to compile,
318 but the resulting files are not used for the O32 ABI. */
320 #if (defined _ABIO32 && _MIPS_SIM == _ABIO32) \
321 && ((TARGET_CPU_DEFAULT | TARGET_DEFAULT) & MASK_GAS) == 0
323 /* Provide dummy definitions. */
324 #define CTORS_SECTION_ASM_OP ""
325 #define DTORS_SECTION_ASM_OP ""
327 /* Undef so JCR_SECTION_NAME isn't defined and __JCR_{LIST, END}__ are not
328 used. */
329 #undef TARGET_ASM_NAMED_SECTION
331 /* Undef so __EH_FRAME_BEGIN__/__FRAME_END__ are not used. */
332 #undef EH_FRAME_SECTION_NAME
334 #endif /* _MIPS_SIM == _ABIO32 && !GAS */
336 /* SGI assembler needs all sorts of extra help to do alignment properly. */
337 #undef ASM_OUTPUT_ALIGN
338 #define ASM_OUTPUT_ALIGN irix_asm_output_align
340 #undef MAX_OFILE_ALIGNMENT
341 #define MAX_OFILE_ALIGNMENT (32768*8)
343 /* ??? SGI assembler may core dump when compiling with -g.
344 Sometimes as succeeds, but then we get a linker error. (cmds.c in 072.sc)
345 Getting rid of .file solves both problems. */
346 #undef ASM_OUTPUT_FILENAME
347 #define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME) \
348 do \
350 if (mips_abi == ABI_32) \
351 fprintf (STREAM, "\t.file\t%d ", NUM_SOURCE_FILENAMES); \
352 else \
353 fprintf (STREAM, "\t#.file\t%d ", NUM_SOURCE_FILENAMES); \
354 output_quoted_string (STREAM, NAME); \
355 fputs ("\n", STREAM); \
357 while (0)
359 /* ??? SGI assembler gives warning whenever .lcomm is used. */
360 #undef ASM_OUTPUT_ALIGNED_LOCAL
361 #define ASM_OUTPUT_ALIGNED_LOCAL(STREAM, NAME, SIZE, ALIGN) \
362 do \
364 if (mips_abi != ABI_32 && mips_abi != ABI_O64) \
366 bss_section (); \
367 mips_declare_object (STREAM, NAME, "", ":\n", 0); \
368 ASM_OUTPUT_ALIGN (STREAM, floor_log2 (ALIGN / BITS_PER_UNIT)); \
369 ASM_OUTPUT_SKIP (STREAM, SIZE); \
371 else \
372 mips_declare_common_object (STREAM, NAME, "\n\t.lcomm\t", \
373 SIZE, ALIGN, false); \
375 while (0)
377 /* A C statement (sans semicolon) to output to the stdio stream
378 FILE the assembler definition of uninitialized global DECL named
379 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
380 Try to use asm_output_aligned_bss to implement this macro. */
382 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
383 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
385 #undef ASM_DECLARE_OBJECT_NAME
386 #define ASM_DECLARE_OBJECT_NAME mips_declare_object_name
388 #undef ASM_FINISH_DECLARE_OBJECT
389 #define ASM_FINISH_DECLARE_OBJECT mips_finish_declare_object
391 #undef LOCAL_LABEL_PREFIX
392 #define LOCAL_LABEL_PREFIX ((mips_abi == ABI_32 || mips_abi == ABI_O64) \
393 ? "$" : ".")
395 /* Profiling is supported via libprof1.a not -lc_p as in IRIX 3. */
396 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
397 on the mipsX option. */
398 #undef IRIX_STARTFILE_SPEC
399 #define IRIX_STARTFILE_SPEC \
400 "%{!shared: \
401 %{mabi=32:%{pg:gcrt1.o%s} \
402 %{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}} \
403 %{mabi=n32: \
404 %{mips4:%{pg:/usr/lib32/mips4/gcrt1.o%s} \
405 %{!pg:%{p:/usr/lib32/mips4/mcrt1.o%s /usr/lib32/mips4/libprof1.a%s} \
406 %{!p:/usr/lib32/mips4/crt1.o%s}}} \
407 %{!mips4:%{pg:/usr/lib32/mips3/gcrt1.o%s} \
408 %{!pg:%{p:/usr/lib32/mips3/mcrt1.o%s /usr/lib32/mips3/libprof1.a%s} \
409 %{!p:/usr/lib32/mips3/crt1.o%s}}}} \
410 %{mabi=64: \
411 %{mips4:%{pg:/usr/lib64/mips4/gcrt1.o} \
412 %{!pg:%{p:/usr/lib64/mips4/mcrt1.o /usr/lib64/mips4/libprof1.a} \
413 %{!p:/usr/lib64/mips4/crt1.o}}} \
414 %{!mips4:%{pg:/usr/lib64/mips3/gcrt1.o} \
415 %{!pg:%{p:/usr/lib64/mips3/mcrt1.o /usr/lib64/mips3/libprof1.a} \
416 %{!p:/usr/lib64/mips3/crt1.o}}}} \
417 %{!mabi*: \
418 %{mips4:%{pg:/usr/lib32/mips4/gcrt1.o%s} \
419 %{!pg:%{p:/usr/lib32/mips4/mcrt1.o%s /usr/lib32/mips4/libprof1.a%s} \
420 %{!p:/usr/lib32/mips4/crt1.o%s}}} \
421 %{!mips4:%{pg:/usr/lib32/mips3/gcrt1.o%s} \
422 %{!pg:%{p:/usr/lib32/mips3/mcrt1.o%s /usr/lib32/mips3/libprof1.a%s} \
423 %{!p:/usr/lib32/mips3/crt1.o%s}}}}}"
425 #undef STARTFILE_SPEC
426 #define STARTFILE_SPEC "%(irix_startfile_spec) crtbegin.o%s"
428 #undef LIB_SPEC
429 #define LIB_SPEC \
430 "%{mabi=n32: %{mips4:-L/usr/lib32/mips4} %{!mips4:-L/usr/lib32/mips3} \
431 -L/usr/lib32} \
432 %{mabi=64: %{mips4:-L/usr/lib64/mips4} %{!mips4:-L/usr/lib64/mips3} \
433 -L/usr/lib64} \
434 %{!mabi*: %{mips4:-L/usr/lib32/mips4} %{!mips4:-L/usr/lib32/mips3} \
435 -L/usr/lib32} \
436 %{!shared: \
437 -dont_warn_unused %{p:libprof1.a%s}%{pg:libprof1.a%s} -lc -warn_unused}"
439 /* Avoid getting two warnings for libgcc.a everytime we link. */
440 #undef LIBGCC_SPEC
441 #define LIBGCC_SPEC "-dont_warn_unused -lgcc -warn_unused"
443 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
444 on the mipsX option. */
445 #undef IRIX_ENDFILE_SPEC
446 #define IRIX_ENDFILE_SPEC \
447 "%{!shared: \
448 %{mabi=32:crtn.o%s}\
449 %{mabi=n32:%{mips4:/usr/lib32/mips4/crtn.o%s}\
450 %{!mips4:/usr/lib32/mips3/crtn.o%s}}\
451 %{mabi=64:%{mips4:/usr/lib64/mips4/crtn.o%s}\
452 %{!mips4:/usr/lib64/mips3/crtn.o%s}}\
453 %{!mabi*:%{mips4:/usr/lib32/mips4/crtn.o%s}\
454 %{!mips4:/usr/lib32/mips3/crtn.o%s}}}"
456 #undef ENDFILE_SPEC
457 #define ENDFILE_SPEC "crtend.o%s %(irix_endfile_spec)"
459 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
460 on the mipsX option. */
461 #undef LINK_SPEC
462 #define LINK_SPEC "\
463 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
464 %{bestGnum} %{shared} %{non_shared} \
465 %{call_shared} %{no_archive} %{exact_version} %{w} \
466 %{!shared: %{!non_shared: %{!call_shared:%{!r: -call_shared -no_unresolved}}}} \
467 %{rpath} %{!mabi=32: -init __do_global_ctors -fini __do_global_dtors} \
468 %{shared:-hidden_symbol __do_global_ctors,__do_global_ctors_1,__do_global_dtors} \
469 -_SYSTYPE_SVR4 -woff 131 \
470 %{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64}%{!mabi*: -n32}"
472 /* We need to disable collecting for the N32 and N64 ABIs. */
473 #define COLLECT_PARSE_FLAG(FLAG) \
474 do { \
475 if (! strcmp (FLAG, "-n32") || ! strcmp (FLAG, "-64")) \
476 do_collecting = 0; \
477 if (! strcmp (FLAG, "-32") || ! strcmp (FLAG, "-o32")) \
478 do_collecting = 1; \
479 } while (0)
481 #define MIPS_TFMODE_FORMAT mips_extended_format