1 /* Definitions of target machine for GNU compiler. Iris version 6.
2 Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002
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 Irix6 functions. */
23 #define TARGET_IRIX6 1
25 /* Default to -mabi=n32 and -mips3. */
26 #define MIPS_ISA_DEFAULT 3
27 #define MIPS_ABI_DEFAULT ABI_N32
28 #define MULTILIB_DEFAULTS { "mabi=n32" }
30 #ifndef TARGET_DEFAULT
31 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_FLOAT64|MASK_64BIT)
34 #include "mips/iris5.h"
35 #include "mips/abi64.h"
37 /* Irix6 assembler does handle DWARF2 directives. Override setting in
39 #undef DWARF2_UNWIND_INFO
41 /* The Irix6 assembler will sometimes assign labels to the wrong
42 section unless the labels are within .ent/.end blocks. Therefore,
43 we avoid creating such labels. */
44 #define DWARF2_GENERATE_TEXT_SECTION_LABEL 0
46 /* wchar_t is defined differently with and without -mabi=64. */
49 #define WCHAR_TYPE (Pmode == DImode ? "int" : "long int")
51 #undef WCHAR_TYPE_SIZE
52 #define WCHAR_TYPE_SIZE 32
54 /* Same for wint_t. */
57 #define WINT_TYPE (Pmode == DImode ? "int" : "long int")
60 #define WINT_TYPE_SIZE 32
62 /* For Irix 6, -mabi=64 implies TARGET_LONG64. */
63 /* This is handled in override_options. */
65 #undef SUBTARGET_CC1_SPEC
66 #define SUBTARGET_CC1_SPEC ""
68 /* We must pass -D_LONGLONG always, even when -ansi is used, because irix6
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 #define CPP_PREDEFINES \
74 "-Dunix -Dmips -Dsgi -Dhost_mips -DMIPSEB -D_MIPSEB -DSYSTYPE_SVR4 \
75 -D_LONGLONG -D_SVR4_SOURCE -D_MODERN_C -D__DSO__ \
76 -Asystem=unix -Asystem=svr4 -Acpu=mips -Amachine=sgi"
78 /* We must make -mips3 do what -mlong64 used to do. */
79 /* ??? If no mipsX option given, but a mabi=X option is, then should set
80 _MIPS_ISA based on the mabi=X option. */
81 /* ??? If no mabi=X option give, but a mipsX option is, then should set
82 _MIPS_SIM based on the mipsX option. */
83 /* ??? Same for _MIPS_SZINT. */
84 /* ??? Same for _MIPS_SZPTR. */
85 #undef SUBTARGET_CPP_SPEC
86 #define SUBTARGET_CPP_SPEC "\
87 %{!ansi:-D__EXTENSIONS__ -D_SGI_SOURCE} \
88 %{mfp32: -D_MIPS_FPSET=16}%{!mfp32: -D_MIPS_FPSET=32} \
89 %{mips1: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
90 %{mips2: -D_MIPS_ISA=_MIPS_ISA_MIPS2} \
91 %{mips3: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
92 %{mips4: -D_MIPS_ISA=_MIPS_ISA_MIPS4} \
93 %{!mips*: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
94 %{mabi=32: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
95 %{mabi=n32: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
96 %{mabi=64: -D_ABI64=3 -D_MIPS_SIM=_ABI64} \
97 %{!mabi*: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
98 %{!mint64: -D_MIPS_SZINT=32}%{mint64: -D_MIPS_SZINT=64} \
99 %{mabi=32: -D_MIPS_SZLONG=32} \
100 %{mabi=n32: -D_MIPS_SZLONG=32} \
101 %{mabi=64: -D_MIPS_SZLONG=64} \
102 %{!mabi*: -D_MIPS_SZLONG=32} \
103 %{mabi=32: -D_MIPS_SZPTR=32} \
104 %{mabi=n32: -D_MIPS_SZPTR=32} \
105 %{mabi=64: -D_MIPS_SZPTR=64} \
106 %{!mabi*: -D_MIPS_SZPTR=32} \
107 %{!mips1:%{!mips2: -D_COMPILER_VERSION=601}} \
108 %{!mips*: -U__mips -D__mips=3} \
109 %{mabi=32: -U__mips64} \
110 %{mabi=n32: -D__mips64} \
111 %{mabi=64: -D__mips64} \
112 %{!mabi*: -D__mips64}"
114 /* The GNU C++ standard library requires that __EXTENSIONS__ and
115 _SGI_SOURCE be defined on at least irix6.2 and probably all irix6
116 prior to 6.5. They normally get defined in SUBTARGET_CPP_SPEC if
117 !ansi, for g++ we want them regardless. We don't need this on
118 irix6.5 itself, but it shouldn't hurt other than the namespace
120 #undef CPLUSPLUS_CPP_SPEC
121 #define CPLUSPLUS_CPP_SPEC "\
122 -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS \
123 %{ansi:-D__EXTENSIONS__ -D_SGI_SOURCE} %(cpp) \
126 /* Irix 6 uses DWARF-2. */
127 #define DWARF2_DEBUGGING_INFO
128 #define MIPS_DEBUGGING_INFO
129 #undef PREFERRED_DEBUGGING_TYPE
130 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
132 /* Force the generation of dwarf .debug_frame sections even if not
133 compiling -g. This guarantees that we can unwind the stack. */
134 #define DWARF2_FRAME_INFO 1
136 /* The size in bytes of a DWARF field indicating an offset or length
137 relative to a debug info section, specified to be 4 bytes in the DWARF-2
138 specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
139 #define DWARF_OFFSET_SIZE PTR_SIZE
141 /* There is no GNU as port for Irix6 yet, so we set MD_EXEC_PREFIX so that
142 gcc will automatically find SGI as instead of searching the user's path.
143 The latter can fail when building a cross compiler if the user has . in
144 the path before /usr/bin, since then gcc will find and try to use the link
145 to the cross assembler which can't possibly work. */
147 #undef MD_EXEC_PREFIX
148 #define MD_EXEC_PREFIX "/usr/bin/"
150 /* We have no need for MD_STARTFILE_PREFIX. */
151 #undef MD_STARTFILE_PREFIX
154 #define MACHINE_TYPE "SGI running IRIX 6.x"
156 /* Irix 5 stuff that we don't need for Irix 6. */
157 /* ??? We do need this for the -mabi=32 switch though. */
158 #undef ASM_OUTPUT_UNDEF_FUNCTION
159 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
160 #undef ASM_DECLARE_FUNCTION_SIZE
162 /* Stuff we need for Irix 6 that isn't in Irix 5. */
164 /* The SGI assembler doesn't like labels before the .ent, so we must output
165 the .ent and function name here, which is the normal place for it. */
167 #undef ASM_DECLARE_FUNCTION_NAME
168 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
170 fputs ("\t.ent\t", STREAM); \
171 assemble_name (STREAM, NAME); \
172 fputs ("\n", STREAM); \
173 assemble_name (STREAM, NAME); \
174 fputs (":\n", STREAM); \
177 /* Likewise, the SGI assembler doesn't like labels after the .end, so we
178 must output the .end here. */
179 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
181 fputs ("\t.end\t", STREAM); \
182 assemble_name (STREAM, NAME); \
183 fputs ("\n", STREAM); \
186 /* Tell function_prologue in mips.c that we have already output the .ent/.end
188 #define FUNCTION_NAME_ALREADY_DECLARED
190 #undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */
193 /* This is *NOT* how to equate one symbol to another symbol. The assembler
194 '=' syntax just equates a name to a constant expression.
195 See ASM_OUTPUT_WEAK_ALIAS. */
197 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
198 do { fprintf ((FILE), "\t"); \
199 assemble_name (FILE, LABEL1); \
200 fprintf (FILE, " = "); \
201 assemble_name (FILE, LABEL2); \
202 fprintf (FILE, "\n"); \
206 /* Define the strings used for the special svr4 .type and .size directives. */
208 #define TYPE_ASM_OP "\t.type\t"
209 #define SIZE_ASM_OP "\t.size\t"
211 /* Irix assembler does not support the init_priority C++ attribute. */
212 #undef SUPPORTS_INIT_PRIORITY
213 #define SUPPORTS_INIT_PRIORITY 0
215 /* A linker error can empirically be avoided by removing duplicate
216 library search directories. */
217 #define LINK_ELIMINATE_DUPLICATE_LDIRECTORIES 1
219 #define POPSECTION_ASM_OP "\t.popsection"
221 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
222 on the mipsX option. */
223 /* If no mips[3,4] option given, give the appropriate default for mabi=X */
224 #undef SUBTARGET_ASM_SPEC
225 #define SUBTARGET_ASM_SPEC "%{!mabi*:-n32} %{!mips*: %{!mabi*:-mips3} %{mabi=n32:-mips3} %{mabi=64:-mips4}}"
227 /* Must pass -g0 to the assembler, otherwise it may overwrite our
228 debug info with its own debug info. */
229 /* Must pass -show instead of -v. */
230 /* Must pass -G 0 to the assembler, otherwise we may get warnings about
232 /* ??? We pass -w to disable all assembler warnings. The `label should be
233 inside .ent/.end block' warning that we get for DWARF II debug info labels
234 is particularly annoying. */
235 #undef SUBTARGET_MIPS_AS_ASM_SPEC
236 #define SUBTARGET_MIPS_AS_ASM_SPEC "%{v:-show} -G 0 -w"
238 #undef SUBTARGET_ASM_DEBUGGING_SPEC
239 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
241 /* The MIPS assembler occasionally misoptimizes. Since GCC should be
242 doing scheduling anyhow, just turn off optimization in the assembler. */
243 #undef SUBTARGET_ASM_OPTIMIZING_SPEC
244 #define SUBTARGET_ASM_OPTIMIZING_SPEC "-O0"
246 /* The assembler now accepts .section pseudo-ops, but it does not allow
247 one to change the section in the middle of a function, so we can't use
248 the INIT_SECTION_ASM_OP code in crtstuff. But we can build up the ctor
249 and dtor lists this way, so we use -init and -fini to invoke the
250 do_global_* functions instead of running collect2. */
252 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
254 #define READONLY_DATA_SECTION_ASM_OP_32 "\t.rdata"
255 #define READONLY_DATA_SECTION_ASM_OP_64 "\t.section\t.rodata"
256 #define READONLY_DATA_SECTION_ASM_OP \
257 (mips_abi != ABI_32 && mips_abi != ABI_O64 \
258 ? READONLY_DATA_SECTION_ASM_OP_64 \
259 : READONLY_DATA_SECTION_ASM_OP_32)
261 /* A default list of other sections which we might be "in" at any given
262 time. For targets that use additional sections (e.g. .tdesc) you
263 should override this definition in the target-specific file which
264 includes this file. */
266 #undef EXTRA_SECTIONS
267 #define EXTRA_SECTIONS in_sdata
269 /* A default list of extra section function definitions. For targets
270 that use additional sections (e.g. .tdesc) you should override this
271 definition in the target-specific file which includes this file. */
273 #undef EXTRA_SECTION_FUNCTIONS
274 #define EXTRA_SECTION_FUNCTIONS \
278 if (in_section != in_sdata) \
280 fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP); \
281 in_section = in_sdata; \
286 current_section_name () \
288 switch (in_section) \
290 case no_section: return NULL; \
291 case in_text: return ".text"; \
292 case in_data: return ".data"; \
293 case in_sdata: return ".sdata"; \
294 case in_bss: return ".bss"; \
295 case in_readonly_data: \
296 if (mips_abi != ABI_32 && mips_abi != ABI_O64) \
301 return in_named_name; \
307 current_section_flags () \
309 switch (in_section) \
311 case no_section: return 0; \
312 case in_text: return SECTION_CODE; \
313 case in_data: return SECTION_WRITE; \
314 case in_sdata: return SECTION_WRITE | SECTION_SMALL; \
315 case in_bss: return SECTION_WRITE | SECTION_BSS; \
316 case in_readonly_data: return 0; \
317 case in_named: return get_named_section_flags (in_named_name); \
322 /* Switch into a generic section. */
323 #undef TARGET_ASM_NAMED_SECTION
324 #define TARGET_ASM_NAMED_SECTION iris6_asm_named_section
326 /* SGI assembler needs all sorts of extra help to do alignment properly. */
327 #undef ASM_OUTPUT_ALIGN
328 #define ASM_OUTPUT_ALIGN iris6_asm_output_align
329 #undef ASM_FILE_START
330 #define ASM_FILE_START iris6_asm_file_start
332 #define ASM_FILE_END iris6_asm_file_end
334 #undef MAX_OFILE_ALIGNMENT
335 #define MAX_OFILE_ALIGNMENT (32768*8)
337 /* ??? SGI assembler may core dump when compiling with -g.
338 Sometimes as succeeds, but then we get a linker error. (cmds.c in 072.sc)
339 Getting rid of .file solves both problems. */
340 #undef ASM_OUTPUT_FILENAME
341 #define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME) \
344 fprintf (STREAM, "\t#.file\t%d ", NUM_SOURCE_FILENAMES); \
345 output_quoted_string (STREAM, NAME); \
346 fputs ("\n", STREAM); \
350 /* ??? SGI assembler gives warning whenever .lcomm is used. */
351 #undef ASM_OUTPUT_LOCAL
352 #define ASM_OUTPUT_ALIGNED_LOCAL(STREAM, NAME, SIZE, ALIGN) \
355 if (mips_abi != ABI_32 && mips_abi != ABI_O64) \
358 mips_declare_object (STREAM, NAME, "", ":\n", 0); \
359 ASM_OUTPUT_ALIGN (STREAM, floor_log2 (ALIGN / BITS_PER_UNIT)); \
360 ASM_OUTPUT_SKIP (STREAM, SIZE); \
363 mips_declare_object (STREAM, NAME, "\n\t.lcomm\t", ",%u\n", (SIZE)); \
367 /* A C statement (sans semicolon) to output to the stdio stream
368 FILE the assembler definition of uninitialized global DECL named
369 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
370 Try to use asm_output_aligned_bss to implement this macro. */
372 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
373 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
375 /* Write the extra assembler code needed to declare an object properly. */
377 #undef ASM_DECLARE_OBJECT_NAME
378 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
381 size_directive_output = 0; \
382 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
384 size_directive_output = 1; \
385 fprintf (STREAM, "%s", SIZE_ASM_OP); \
386 assemble_name (STREAM, NAME); \
387 fprintf (STREAM, ","); \
388 fprintf (STREAM, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (TREE_TYPE (DECL))); \
389 fprintf (STREAM, "\n"); \
391 mips_declare_object (STREAM, NAME, "", ":\n", 0); \
395 /* Define the `__builtin_va_list' type for the ABI. On Irix6, this
397 #undef BUILD_VA_LIST_TYPE
398 #define BUILD_VA_LIST_TYPE(VALIST) \
399 (VALIST) = build_pointer_type (char_type_node)
401 /* Output the size directive for a decl in rest_of_decl_compilation
402 in the case where we did not do so before the initializer.
403 Once we find the error_mark_node, we know that the value of
404 size_directive_output was set
405 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
407 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
409 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
410 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
411 && ! AT_END && TOP_LEVEL \
412 && DECL_INITIAL (DECL) == error_mark_node \
413 && !size_directive_output) \
415 size_directive_output = 1; \
416 fprintf (FILE, "%s", SIZE_ASM_OP); \
417 assemble_name (FILE, name); \
418 fprintf (FILE, ","); \
419 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (TREE_TYPE (DECL))); \
420 fprintf (FILE, "\n"); \
424 #undef LOCAL_LABEL_PREFIX
425 #define LOCAL_LABEL_PREFIX ((mips_abi == ABI_32 || mips_abi == ABI_O64) \
428 /* Profiling is supported via libprof1.a not -lc_p as in Irix 3. */
429 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
430 on the mipsX option. */
431 #undef STARTFILE_SPEC
432 #define STARTFILE_SPEC \
434 %{mabi=32:%{pg:gcrt1.o%s} \
435 %{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}} \
437 %{mips4:%{pg:/usr/lib32/mips4/gcrt1.o%s} \
438 %{!pg:%{p:/usr/lib32/mips4/mcrt1.o%s /usr/lib32/mips4/libprof1.a%s} \
439 %{!p:/usr/lib32/mips4/crt1.o%s}}} \
440 %{!mips4:%{pg:/usr/lib32/mips3/gcrt1.o%s} \
441 %{!pg:%{p:/usr/lib32/mips3/mcrt1.o%s /usr/lib32/mips3/libprof1.a%s} \
442 %{!p:/usr/lib32/mips3/crt1.o%s}}}} \
444 %{mips4:%{pg:/usr/lib64/mips4/gcrt1.o} \
445 %{!pg:%{p:/usr/lib64/mips4/mcrt1.o /usr/lib64/mips4/libprof1.a} \
446 %{!p:/usr/lib64/mips4/crt1.o}}} \
447 %{!mips4:%{pg:/usr/lib64/mips3/gcrt1.o} \
448 %{!pg:%{p:/usr/lib64/mips3/mcrt1.o /usr/lib64/mips3/libprof1.a} \
449 %{!p:/usr/lib64/mips3/crt1.o}}}} \
451 %{mips4:%{pg:/usr/lib32/mips4/gcrt1.o%s} \
452 %{!pg:%{p:/usr/lib32/mips4/mcrt1.o%s /usr/lib32/mips4/libprof1.a%s} \
453 %{!p:/usr/lib32/mips4/crt1.o%s}}} \
454 %{!mips4:%{pg:/usr/lib32/mips3/gcrt1.o%s} \
455 %{!pg:%{p:/usr/lib32/mips3/mcrt1.o%s /usr/lib32/mips3/libprof1.a%s} \
456 %{!p:/usr/lib32/mips3/crt1.o%s}}}}} \
461 "%{mabi=n32: %{mips4:-L/usr/lib32/mips4} %{!mips4:-L/usr/lib32/mips3} \
463 %{mabi=64: %{mips4:-L/usr/lib64/mips4} %{!mips4:-L/usr/lib64/mips3} \
465 %{!mabi*: %{mips4:-L/usr/lib32/mips4} %{!mips4:-L/usr/lib32/mips3} \
468 -dont_warn_unused %{p:libprof1.a%s}%{pg:libprof1.a%s} -lc -warn_unused}"
470 /* Avoid getting two warnings for libgcc.a everytime we link. */
472 #define LIBGCC_SPEC "-dont_warn_unused -lgcc -warn_unused"
474 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
475 on the mipsX option. */
477 #define ENDFILE_SPEC \
481 %{mabi=n32:%{mips4:/usr/lib32/mips4/crtn.o%s}\
482 %{!mips4:/usr/lib32/mips3/crtn.o%s}}\
483 %{mabi=64:%{mips4:/usr/lib64/mips4/crtn.o%s}\
484 %{!mips4:/usr/lib64/mips3/crtn.o%s}}\
485 %{!mabi*:%{mips4:/usr/lib32/mips4/crtn.o%s}\
486 %{!mips4:/usr/lib32/mips3/crtn.o%s}}}"
488 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
489 on the mipsX option. */
492 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
493 %{bestGnum} %{shared} %{non_shared} \
494 %{call_shared} %{no_archive} %{exact_version} %{w} \
495 %{!shared: %{!non_shared: %{!call_shared: -call_shared -no_unresolved}}} \
496 %{rpath} -init __do_global_ctors -fini __do_global_dtors \
497 %{shared:-hidden_symbol __do_global_ctors,__do_global_ctors_1,__do_global_dtors} \
498 -_SYSTYPE_SVR4 -woff 131 \
499 %{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64}%{!mabi*: -n32}"