1 /* Definitions of target machine for GNU compiler. IRIX version 6.
2 Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC 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)
12 GNU CC 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 GNU CC; 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 /* Let mips.c know we need the IRIX 6 functions. */
23 #define TARGET_IRIX6 1
25 /* Default to -mabi=n32 and -mips3. */
26 #undef MULTILIB_DEFAULTS
27 #define MULTILIB_DEFAULTS { "mabi=n32" }
29 /* IRIX 6 assembler does handle DWARF2 directives. Override setting in
31 #undef DWARF2_UNWIND_INFO
33 /* The IRIX 6 assembler will sometimes assign labels to the wrong
34 section unless the labels are within .ent/.end blocks. Therefore,
35 we avoid creating such labels. */
36 #define DWARF2_GENERATE_TEXT_SECTION_LABEL 0
38 /* wchar_t is defined differently with and without -mabi=64. */
41 #define WCHAR_TYPE (Pmode == DImode ? "int" : "long int")
43 #undef WCHAR_TYPE_SIZE
44 #define WCHAR_TYPE_SIZE 32
46 /* Same for wint_t. */
49 #define WINT_TYPE (Pmode == DImode ? "int" : "long int")
52 #define WINT_TYPE_SIZE 32
54 /* For IRIX 6, -mabi=64 implies TARGET_LONG64. */
55 /* This is handled in override_options. */
57 #undef SUBTARGET_CC1_SPEC
58 #define SUBTARGET_CC1_SPEC ""
60 /* We must pass -D_LONGLONG always, even when -ansi is used, because IRIX 6
61 system header files require it. This is OK, because gcc never warns
62 when long long is used in system header files. Alternatively, we can
63 add support for the SGI builtin type __long_long. */
65 /* The GNU C++ standard library requires that __EXTENSIONS__ and
66 _SGI_SOURCE be defined on at least IRIX 6.2 and probably all IRIX 6
67 prior to 6.5. They normally get defined if !ansi, for g++ we want
68 them regardless. We don't need this on IRIX 6.5 itself, but it
69 shouldn't hurt other than the namespace pollution. */
71 /* Undefine because this includes iris5.h. */
72 #undef TARGET_OS_CPP_BUILTINS
73 #define TARGET_OS_CPP_BUILTINS() \
75 builtin_define_std ("host_mips"); \
76 builtin_define ("_LONGLONG"); \
77 builtin_define ("_MODERN_C"); \
78 builtin_define ("_SVR4_SOURCE"); \
79 builtin_define_std ("SYSTYPE_SVR4"); \
80 builtin_define ("__DSO__"); \
81 builtin_define_std ("unix"); \
82 builtin_define_std ("sgi"); \
83 builtin_assert ("system=svr4"); \
84 builtin_assert ("system=unix"); \
85 builtin_assert ("machine=sgi"); \
87 if (mips_abi == ABI_32) \
89 builtin_define ("_MIPS_SIM=_MIPS_SIM_ABI32"); \
90 builtin_define ("_MIPS_SZLONG=32"); \
91 builtin_define ("_MIPS_SZPTR=32"); \
93 else if (mips_abi == ABI_64) \
95 builtin_define ("_ABI64=3"); \
96 builtin_define ("_MIPS_SIM=_ABI64"); \
97 builtin_define ("_MIPS_SZLONG=64"); \
98 builtin_define ("_MIPS_SZPTR=64"); \
102 builtin_define ("_ABIN32=2"); \
103 builtin_define ("_MIPS_SIM=_ABIN32"); \
104 builtin_define ("_MIPS_SZLONG=32"); \
105 builtin_define ("_MIPS_SZPTR=32"); \
108 if (!TARGET_FLOAT64) \
109 builtin_define ("_MIPS_FPSET=16"); \
111 builtin_define ("_MIPS_FPSET=32"); \
114 builtin_define ("_MIPS_SZINT=32"); \
116 builtin_define ("_MIPS_SZINT=64"); \
118 if (!ISA_MIPS1 && !ISA_MIPS2) \
119 builtin_define ("_COMPILER_VERSION=601"); \
121 /* IRIX 6.5.18 and above provide many ISO C99 \
122 features protected by the __c99 macro. \
123 libstdc++ v3 needs them as well. */ \
124 if ((!c_dialect_cxx () && flag_isoc99) \
125 || c_dialect_cxx ()) \
126 builtin_define ("__c99"); \
128 if (c_dialect_cxx ()) \
130 builtin_define ("__EXTENSIONS__"); \
131 builtin_define ("_SGI_SOURCE"); \
136 builtin_define ("__EXTENSIONS__"); \
137 builtin_define ("_SGI_SOURCE"); \
141 /* IRIX 6 uses DWARF-2. */
142 #define DWARF2_DEBUGGING_INFO 1
143 #define MIPS_DEBUGGING_INFO 1
144 #undef PREFERRED_DEBUGGING_TYPE
145 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
147 /* Force the generation of dwarf .debug_frame sections even if not
148 compiling -g. This guarantees that we can unwind the stack. */
149 #define DWARF2_FRAME_INFO 1
151 /* The size in bytes of a DWARF field indicating an offset or length
152 relative to a debug info section, specified to be 4 bytes in the DWARF-2
153 specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
154 #define DWARF_OFFSET_SIZE PTR_SIZE
156 /* The size in bytes of the initial length field in a debug info
157 section. The DWARF 3 (draft) specification defines this to be
158 either 4 or 12 (with a 4-byte "escape" word when it's 12), but the
159 SGI/MIPS ABI predates this standard and defines it to be the same
160 as DWARF_OFFSET_SIZE. */
161 #define DWARF_INITIAL_LENGTH_SIZE DWARF_OFFSET_SIZE
163 /* There is no GNU as port for IRIX 6 yet, so we set MD_EXEC_PREFIX so that
164 gcc will automatically find SGI as instead of searching the user's path.
165 The latter can fail when building a cross compiler if the user has . in
166 the path before /usr/bin, since then gcc will find and try to use the link
167 to the cross assembler which can't possibly work. */
169 #undef MD_EXEC_PREFIX
170 #define MD_EXEC_PREFIX "/usr/bin/"
172 /* We have no need for MD_STARTFILE_PREFIX. */
173 #undef MD_STARTFILE_PREFIX
176 #define MACHINE_TYPE "SGI running IRIX 6.x"
178 /* IRIX 5 stuff that we don't need for IRIX 6. */
179 /* ??? We do need this for the -mabi=32 switch though. */
180 #undef ASM_OUTPUT_UNDEF_FUNCTION
181 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
182 #undef ASM_DECLARE_FUNCTION_SIZE
184 /* Stuff we need for IRIX 6 that isn't in IRIX 5. */
186 /* The SGI assembler doesn't like labels before the .ent, so we must output
187 the .ent and function name here, which is the normal place for it. */
189 #undef ASM_DECLARE_FUNCTION_NAME
190 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
192 fputs ("\t.ent\t", STREAM); \
193 assemble_name (STREAM, NAME); \
194 fputs ("\n", STREAM); \
195 assemble_name (STREAM, NAME); \
196 fputs (":\n", STREAM); \
199 /* Likewise, the SGI assembler doesn't like labels after the .end, so we
200 must output the .end here. */
201 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
203 fputs ("\t.end\t", STREAM); \
204 assemble_name (STREAM, NAME); \
205 fputs ("\n", STREAM); \
208 /* Tell function_prologue in mips.c that we have already output the .ent/.end
210 #define FUNCTION_NAME_ALREADY_DECLARED
212 #undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */
215 /* This is *NOT* how to equate one symbol to another symbol. The assembler
216 '=' syntax just equates a name to a constant expression.
217 See ASM_OUTPUT_WEAK_ALIAS. */
219 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
220 do { fprintf ((FILE), "\t"); \
221 assemble_name (FILE, LABEL1); \
222 fprintf (FILE, " = "); \
223 assemble_name (FILE, LABEL2); \
224 fprintf (FILE, "\n"); \
228 /* Define the strings used for the special svr4 .type and .size directives. */
230 #define TYPE_ASM_OP "\t.type\t"
231 #define SIZE_ASM_OP "\t.size\t"
233 /* IRIX assembler does not support the init_priority C++ attribute. */
234 #undef SUPPORTS_INIT_PRIORITY
235 #define SUPPORTS_INIT_PRIORITY 0
237 /* A linker error can empirically be avoided by removing duplicate
238 library search directories. */
239 #define LINK_ELIMINATE_DUPLICATE_LDIRECTORIES 1
241 #define POPSECTION_ASM_OP "\t.popsection"
243 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
244 on the mipsX option. */
245 /* If no mips[3,4] option given, give the appropriate default for mabi=X */
246 #undef SUBTARGET_ASM_SPEC
247 #define SUBTARGET_ASM_SPEC "%{!mabi*:-n32} %{!mips*: %{!mabi*:-mips3} %{mabi=n32|mabi=64:-mips3}}"
249 /* Must pass -g0 to the assembler, otherwise it may overwrite our
250 debug info with its own debug info. */
251 /* Must pass -show instead of -v. */
252 /* Must pass -G 0 to the assembler, otherwise we may get warnings about
254 /* ??? We pass -w to disable all assembler warnings. The `label should be
255 inside .ent/.end block' warning that we get for DWARF II debug info labels
256 is particularly annoying. */
257 #undef SUBTARGET_MIPS_AS_ASM_SPEC
258 #define SUBTARGET_MIPS_AS_ASM_SPEC "%{v:-show} -G 0 -w"
260 #undef SUBTARGET_ASM_DEBUGGING_SPEC
261 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
263 /* The MIPS assembler occasionally misoptimizes. Since GCC should be
264 doing scheduling anyhow, just turn off optimization in the assembler. */
265 #undef SUBTARGET_ASM_OPTIMIZING_SPEC
266 #define SUBTARGET_ASM_OPTIMIZING_SPEC "-O0"
268 /* The assembler now accepts .section pseudo-ops, but it does not allow
269 one to change the section in the middle of a function, so we can't use
270 the INIT_SECTION_ASM_OP code in crtstuff. But we can build up the ctor
271 and dtor lists this way, so we use -init and -fini to invoke the
272 do_global_* functions instead of running collect2. */
274 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
276 #undef READONLY_DATA_SECTION_ASM_OP
277 #define READONLY_DATA_SECTION_ASM_OP_32 "\t.rdata"
278 #define READONLY_DATA_SECTION_ASM_OP_64 "\t.section\t.rodata"
279 #define READONLY_DATA_SECTION_ASM_OP \
280 (mips_abi != ABI_32 && mips_abi != ABI_O64 \
281 ? READONLY_DATA_SECTION_ASM_OP_64 \
282 : READONLY_DATA_SECTION_ASM_OP_32)
284 /* Define functions to read the name and flags of the current section.
285 They are used by iris6_asm_output_align. */
287 #undef EXTRA_SECTION_FUNCTIONS
288 #define EXTRA_SECTION_FUNCTIONS \
290 current_section_name () \
292 switch (in_section) \
294 case no_section: return NULL; \
295 case in_text: return ".text"; \
296 case in_data: return ".data"; \
297 case in_bss: return ".bss"; \
298 case in_readonly_data: \
299 if (mips_abi != ABI_32 && mips_abi != ABI_O64) \
304 return in_named_name; \
310 current_section_flags () \
312 switch (in_section) \
314 case no_section: return 0; \
315 case in_text: return SECTION_CODE; \
316 case in_data: return SECTION_WRITE; \
317 case in_bss: return SECTION_WRITE | SECTION_BSS; \
318 case in_readonly_data: return 0; \
319 case in_named: return get_named_section_flags (in_named_name); \
324 /* Switch into a generic section. */
325 #undef TARGET_ASM_NAMED_SECTION
326 #define TARGET_ASM_NAMED_SECTION iris6_asm_named_section
328 /* SGI assembler needs all sorts of extra help to do alignment properly. */
329 #undef ASM_OUTPUT_ALIGN
330 #define ASM_OUTPUT_ALIGN iris6_asm_output_align
332 #undef MAX_OFILE_ALIGNMENT
333 #define MAX_OFILE_ALIGNMENT (32768*8)
335 /* ??? SGI assembler may core dump when compiling with -g.
336 Sometimes as succeeds, but then we get a linker error. (cmds.c in 072.sc)
337 Getting rid of .file solves both problems. */
338 #undef ASM_OUTPUT_FILENAME
339 #define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME) \
342 fprintf (STREAM, "\t#.file\t%d ", NUM_SOURCE_FILENAMES); \
343 output_quoted_string (STREAM, NAME); \
344 fputs ("\n", STREAM); \
348 /* ??? SGI assembler gives warning whenever .lcomm is used. */
349 #undef ASM_OUTPUT_LOCAL
350 #define ASM_OUTPUT_ALIGNED_LOCAL(STREAM, NAME, SIZE, ALIGN) \
353 if (mips_abi != ABI_32 && mips_abi != ABI_O64) \
356 mips_declare_object (STREAM, NAME, "", ":\n", 0); \
357 ASM_OUTPUT_ALIGN (STREAM, floor_log2 (ALIGN / BITS_PER_UNIT)); \
358 ASM_OUTPUT_SKIP (STREAM, SIZE); \
361 mips_declare_object (STREAM, NAME, "\n\t.lcomm\t", ",%u\n", (int)(SIZE)); \
365 /* A C statement (sans semicolon) to output to the stdio stream
366 FILE the assembler definition of uninitialized global DECL named
367 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
368 Try to use asm_output_aligned_bss to implement this macro. */
370 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
371 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
373 /* Write the extra assembler code needed to declare an object properly. */
375 #undef ASM_DECLARE_OBJECT_NAME
376 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
379 HOST_WIDE_INT size; \
380 size_directive_output = 0; \
381 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
383 size_directive_output = 1; \
384 size = int_size_in_bytes (TREE_TYPE (DECL)); \
385 ASM_OUTPUT_SIZE_DIRECTIVE (STREAM, NAME, size); \
387 mips_declare_object (STREAM, NAME, "", ":\n", 0); \
391 /* Define the `__builtin_va_list' type for the ABI. On IRIX 6, this
393 #undef BUILD_VA_LIST_TYPE
394 #define BUILD_VA_LIST_TYPE(VALIST) \
395 (VALIST) = build_pointer_type (char_type_node)
397 /* Output the size directive for a decl in rest_of_decl_compilation
398 in the case where we did not do so before the initializer.
399 Once we find the error_mark_node, we know that the value of
400 size_directive_output was set
401 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
403 #undef ASM_FINISH_DECLARE_OBJECT
404 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
406 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
407 HOST_WIDE_INT size; \
408 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
409 && ! AT_END && TOP_LEVEL \
410 && DECL_INITIAL (DECL) == error_mark_node \
411 && !size_directive_output) \
413 size_directive_output = 1; \
414 size = int_size_in_bytes (TREE_TYPE (DECL)); \
415 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
419 #undef LOCAL_LABEL_PREFIX
420 #define LOCAL_LABEL_PREFIX ((mips_abi == ABI_32 || mips_abi == ABI_O64) \
423 /* Profiling is supported via libprof1.a not -lc_p as in IRIX 3. */
424 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
425 on the mipsX option. */
426 #undef STARTFILE_SPEC
427 #define STARTFILE_SPEC \
429 %{mabi=32:%{pg:gcrt1.o%s} \
430 %{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}} \
432 %{mips4:%{pg:/usr/lib32/mips4/gcrt1.o%s} \
433 %{!pg:%{p:/usr/lib32/mips4/mcrt1.o%s /usr/lib32/mips4/libprof1.a%s} \
434 %{!p:/usr/lib32/mips4/crt1.o%s}}} \
435 %{!mips4:%{pg:/usr/lib32/mips3/gcrt1.o%s} \
436 %{!pg:%{p:/usr/lib32/mips3/mcrt1.o%s /usr/lib32/mips3/libprof1.a%s} \
437 %{!p:/usr/lib32/mips3/crt1.o%s}}}} \
439 %{mips4:%{pg:/usr/lib64/mips4/gcrt1.o} \
440 %{!pg:%{p:/usr/lib64/mips4/mcrt1.o /usr/lib64/mips4/libprof1.a} \
441 %{!p:/usr/lib64/mips4/crt1.o}}} \
442 %{!mips4:%{pg:/usr/lib64/mips3/gcrt1.o} \
443 %{!pg:%{p:/usr/lib64/mips3/mcrt1.o /usr/lib64/mips3/libprof1.a} \
444 %{!p:/usr/lib64/mips3/crt1.o}}}} \
446 %{mips4:%{pg:/usr/lib32/mips4/gcrt1.o%s} \
447 %{!pg:%{p:/usr/lib32/mips4/mcrt1.o%s /usr/lib32/mips4/libprof1.a%s} \
448 %{!p:/usr/lib32/mips4/crt1.o%s}}} \
449 %{!mips4:%{pg:/usr/lib32/mips3/gcrt1.o%s} \
450 %{!pg:%{p:/usr/lib32/mips3/mcrt1.o%s /usr/lib32/mips3/libprof1.a%s} \
451 %{!p:/usr/lib32/mips3/crt1.o%s}}}}} \
456 "%{mabi=n32: %{mips4:-L/usr/lib32/mips4} %{!mips4:-L/usr/lib32/mips3} \
458 %{mabi=64: %{mips4:-L/usr/lib64/mips4} %{!mips4:-L/usr/lib64/mips3} \
460 %{!mabi*: %{mips4:-L/usr/lib32/mips4} %{!mips4:-L/usr/lib32/mips3} \
463 -dont_warn_unused %{p:libprof1.a%s}%{pg:libprof1.a%s} -lc -warn_unused}"
465 /* Avoid getting two warnings for libgcc.a everytime we link. */
467 #define LIBGCC_SPEC "-dont_warn_unused -lgcc -warn_unused"
469 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
470 on the mipsX option. */
472 #define ENDFILE_SPEC \
476 %{mabi=n32:%{mips4:/usr/lib32/mips4/crtn.o%s}\
477 %{!mips4:/usr/lib32/mips3/crtn.o%s}}\
478 %{mabi=64:%{mips4:/usr/lib64/mips4/crtn.o%s}\
479 %{!mips4:/usr/lib64/mips3/crtn.o%s}}\
480 %{!mabi*:%{mips4:/usr/lib32/mips4/crtn.o%s}\
481 %{!mips4:/usr/lib32/mips3/crtn.o%s}}}"
483 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
484 on the mipsX option. */
487 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
488 %{bestGnum} %{shared} %{non_shared} \
489 %{call_shared} %{no_archive} %{exact_version} %{w} \
490 %{!shared: %{!non_shared: %{!call_shared: -call_shared -no_unresolved}}} \
491 %{rpath} -init __do_global_ctors -fini __do_global_dtors \
492 %{shared:-hidden_symbol __do_global_ctors,__do_global_ctors_1,__do_global_dtors} \
493 -_SYSTYPE_SVR4 -woff 131 \
494 %{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64}%{!mabi*: -n32}"
496 #define MIPS_TFMODE_FORMAT mips_extended_format