1 /* Definitions of target machine for GNU compiler. Iris version 6.
2 Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Default to -mabi=n32 and -mips3. */
22 #define MIPS_ISA_DEFAULT 3
23 #define MIPS_ABI_DEFAULT ABI_N32
24 #define MULTILIB_DEFAULTS { "mabi=n32" }
26 #ifndef TARGET_DEFAULT
27 #define TARGET_DEFAULT MASK_ABICALLS|MASK_FLOAT64|MASK_64BIT
30 #include "mips/iris5.h"
31 #include "mips/abi64.h"
33 /* For Irix 6, -mips3 implies TARGET_LONG64. */
35 #define TARGET_LONG64 (mips_abi == ABI_64)
37 /* We must pass -D_LONGLONG always, even when -ansi is used, because irix6
38 system header files require it. This is OK, because gcc never warns
39 when long long is used in system header files. Alternatively, we can
40 add support for the SGI builtin type __long_long. */
42 #define CPP_PREDEFINES \
43 "-Dunix -Dmips -Dsgi -Dhost_mips -DMIPSEB -D_MIPSEB -DSYSTYPE_SVR4 \
44 -D_LONGLONG -D_SVR4_SOURCE -D_MODERN_C -D__DSO__ \
45 -Asystem(unix) -Asystem(svr4) -Acpu(mips) -Amachine(sgi)"
47 #undef SUBTARGET_CPP_SIZE_SPEC
48 #define SUBTARGET_CPP_SIZE_SPEC "\
49 %{mabi=32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
50 %{mabi=n32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
51 %{mabi=64: -D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int} \
52 %{!mabi*: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}"
54 /* We must make -mips3 do what -mlong64 used to do. */
55 /* ??? If no mipsX option given, but a mabi=X option is, then should set
56 _MIPS_ISA based on the mabi=X option. */
57 /* ??? If no mabi=X option give, but a mipsX option is, then should set
58 _MIPS_SIM based on the mipsX option. */
59 /* ??? Same for _MIPS_SZINT. */
60 /* ??? Same for _MIPS_SZPTR. */
61 /* ??? Same for __SIZE_TYPE and __PTRDIFF_TYPE. */
62 #undef SUBTARGET_CPP_SPEC
63 #define SUBTARGET_CPP_SPEC "\
64 %{!ansi:-D__EXTENSIONS__ -D_SGI_SOURCE} \
65 %{mfp32: -D_MIPS_FPSET=16}%{!mfp32: -D_MIPS_FPSET=32} \
66 %{mips1: -D_MIPS_ISA=_MIPS_ISA_MIPS1} \
67 %{mips2: -D_MIPS_ISA=_MIPS_ISA_MIPS2} \
68 %{mips3: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
69 %{mips4: -D_MIPS_ISA=_MIPS_ISA_MIPS4} \
70 %{!mips*: -D_MIPS_ISA=_MIPS_ISA_MIPS3} \
71 %{mabi=32: -D_MIPS_SIM=_MIPS_SIM_ABI32} \
72 %{mabi=n32: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
73 %{mabi=64: -D_ABI64=3 -D_MIPS_SIM=_ABI64} \
74 %{!mabi*: -D_ABIN32=2 -D_MIPS_SIM=_ABIN32} \
75 %{!mint64: -D_MIPS_SZINT=32}%{mint64: -D_MIPS_SZINT=64} \
76 %{mabi=32: -D_MIPS_SZLONG=32} \
77 %{mabi=n32: -D_MIPS_SZLONG=32} \
78 %{mabi=64: -D_MIPS_SZLONG=64} \
79 %{!mabi*: -D_MIPS_SZLONG=32} \
80 %{mabi=32: -D_MIPS_SZPTR=32} \
81 %{mabi=n32: -D_MIPS_SZPTR=32} \
82 %{mabi=64: -D_MIPS_SZPTR=64} \
83 %{!mabi*: -D_MIPS_SZPTR=32} \
84 %{!mips1:%{!mips2: -D_COMPILER_VERSION=601}} \
85 %{!mips*: -U__mips -D__mips=3} \
86 %{mabi=32: -U__mips64} \
87 %{mabi=n32: -D__mips64} \
88 %{mabi=64: -D__mips64} \
89 %{!mabi*: -D__mips64}"
91 /* Irix 6 uses DWARF. */
92 #define DWARF_DEBUGGING_INFO
93 #define DWARF_VERSION 2
94 #define MIPS_DEBUGGING_INFO
95 #undef PREFERRED_DEBUGGING_TYPE
96 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
98 /* The size in bytes of a DWARF field indicating an offset or length
99 relative to a debug info section, specified to be 4 bytes in the DWARF-2
100 specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
101 #define DWARF_OFFSET_SIZE PTR_SIZE
104 #define MACHINE_TYPE "SGI running IRIX 6.x"
106 /* The Irix 6.0.1 assembler doesn't like labels in the text section, so
107 just avoid emitting them. */
108 #define ASM_IDENTIFY_GCC
109 #define ASM_IDENTIFY_LANGUAGE
111 /* Irix 5 stuff that we don't need for Irix 6. */
112 /* ??? We do need this for the -mabi=32 switch though. */
113 #undef ASM_OUTPUT_UNDEF_FUNCTION
114 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
115 #undef ASM_DECLARE_FUNCTION_SIZE
117 /* Stuff we need for Irix 6 that isn't in Irix 5. */
119 /* The SGI assembler doesn't like labels before the .ent, so we must output
120 the .ent and function name here, which is the normal place for it. */
122 #undef ASM_DECLARE_FUNCTION_NAME
123 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
125 fputs ("\t.ent\t", STREAM); \
126 assemble_name (STREAM, NAME); \
127 fputs ("\n", STREAM); \
128 assemble_name (STREAM, NAME); \
129 fputs (":\n", STREAM); \
132 /* Likewise, the SGI assembler doesn't like labels after the .end, so we
133 must output the .end here. */
134 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
136 fputs ("\t.end\t", STREAM); \
137 assemble_name (STREAM, NAME); \
138 fputs ("\n", STREAM); \
141 /* Tell function_prologue in mips.c that we have already output the .ent/.end
143 #define FUNCTION_NAME_ALREADY_DECLARED
145 #undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */
148 /* This is *NOT* how to equate one symbol to another symbol. The assembler
149 '=' syntax just equates a name to a constant expression.
150 See ASM_OUTPUT_WEAK_ALIAS. */
152 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
153 do { fprintf ((FILE), "\t"); \
154 assemble_name (FILE, LABEL1); \
155 fprintf (FILE, " = "); \
156 assemble_name (FILE, LABEL2); \
157 fprintf (FILE, "\n"); \
161 /* Define the strings used for the special svr4 .type and .size directives. */
163 #define TYPE_ASM_OP ".type"
164 #define SIZE_ASM_OP ".size"
166 /* This is how we tell the assembler that a symbol is weak. */
168 #define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE) \
170 fputs ("\t.weakext\t", FILE); \
171 assemble_name (FILE, NAME); \
175 assemble_name (FILE, VALUE); \
177 fputc ('\n', FILE); \
180 #define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,0)
182 #define POPSECTION_ASM_OP ".popsection"
184 #define DEBUG_SECTION ".debug_info,0x7000001e,0,0,1"
185 #define LINE_SECTION ".debug_line,0x7000001e,0,0,1"
186 #define SFNAMES_SECTION ".debug_sfnames,0x7000001e,0,0,1"
187 #define SRCINFO_SECTION ".debug_srcinfo,0x7000001e,0,0,1"
188 #define MACINFO_SECTION ".debug_macinfo,0x7000001e,0,0,1"
189 #define PUBNAMES_SECTION ".debug_pubnames,0x7000001e,0,0,1"
190 #define ARANGES_SECTION ".debug_aranges,0x7000001e,0,0,1"
191 #define FRAME_SECTION ".debug_frame,0x7000001e,0x08000000,0,1"
192 #define ABBREV_SECTION ".debug_abbrev,0x7000001e,0,0,1"
194 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
195 on the mipsX option. */
196 #undef SUBTARGET_ASM_SPEC
197 #define SUBTARGET_ASM_SPEC "%{!mabi*:-n32}"
199 /* Must pass -g0 to the assembler, otherwise it may overwrite our
200 debug info with its own debug info. */
201 /* Must pass -show instead of -v. */
202 /* Must pass -G 0 to the assembler, otherwise we may get warnings about
204 /* ??? We pass -w to disable all assembler warnings. The `label should be
205 inside .ent/.end block' warning that we get for DWARF II debug info labels
206 is particularly annoying. */
207 #undef SUBTARGET_MIPS_AS_ASM_SPEC
208 #define SUBTARGET_MIPS_AS_ASM_SPEC "%{v:-show} -G 0 -w"
210 #undef SUBTARGET_ASM_DEBUGGING_SPEC
211 #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
213 /* Stuff for constructors. Start here. */
215 /* The assembler now accepts .section pseudo-ops, but it does not allow
216 one to change the section in the middle of a function, so we can't use
217 the INIT_SECTION_ASM_OP code in crtstuff. But we can build up the ctor
218 and dtor lists this way, so we use -init and -fini to invoke the
219 do_global_* functions instead of running collect2. */
221 #define BSS_SECTION_ASM_OP ".section\t.bss"
222 #define CONST_SECTION_ASM_OP_32 "\t.rdata"
223 #define CONST_SECTION_ASM_OP_64 ".section\t.rodata"
224 #define CTORS_SECTION_ASM_OP ".section\t.ctors,1,2,0,4"
225 #define DTORS_SECTION_ASM_OP ".section\t.dtors,1,2,0,4"
227 /* This is the pseudo-op used to generate a 32-bit word of data with a
228 specific value in some section. This is the same for all known svr4
231 #define INT_ASM_OP ".word"
233 /* A default list of other sections which we might be "in" at any given
234 time. For targets that use additional sections (e.g. .tdesc) you
235 should override this definition in the target-specific file which
236 includes this file. */
238 #undef EXTRA_SECTIONS
239 #define EXTRA_SECTIONS in_sdata, in_rdata, in_const, in_ctors, in_dtors
241 /* A default list of extra section function definitions. For targets
242 that use additional sections (e.g. .tdesc) you should override this
243 definition in the target-specific file which includes this file. */
245 /* ??? rdata_section is now same as svr4 const_section. */
247 #undef EXTRA_SECTION_FUNCTIONS
248 #define EXTRA_SECTION_FUNCTIONS \
252 if (in_section != in_sdata) \
254 fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP); \
255 in_section = in_sdata; \
262 if (in_section != in_rdata) \
264 if (mips_abi != ABI_32) \
265 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP_64); \
267 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP_32); \
268 in_section = in_rdata; \
271 CTORS_SECTION_FUNCTION \
272 DTORS_SECTION_FUNCTION
274 #define CTORS_SECTION_FUNCTION \
278 if (in_section != in_ctors) \
280 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
281 in_section = in_ctors; \
285 #define DTORS_SECTION_FUNCTION \
289 if (in_section != in_dtors) \
291 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
292 in_section = in_dtors; \
296 /* A C statement (sans semicolon) to output an element in the table of
297 global constructors. */
298 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
301 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
302 assemble_name (FILE, NAME); \
303 fprintf (FILE, "\n"); \
306 /* A C statement (sans semicolon) to output an element in the table of
307 global destructors. */
308 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
311 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
312 assemble_name (FILE, NAME); \
313 fprintf (FILE, "\n"); \
316 /* A C statement to output something to the assembler file to switch to section
317 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
320 #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \
322 extern FILE *asm_out_text_file; \
323 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
324 fprintf (asm_out_text_file, "\t.section %s,1,6,4,4\n", (NAME)); \
325 else if ((DECL) && TREE_READONLY (DECL)) \
326 fprintf (F, "\t.section %s,1,2,0,8\n", (NAME)); \
328 fprintf (F, "\t.section %s,1,3,0,8\n", (NAME)); \
331 /* Stuff for constructors. End here. */
333 /* ??? Perhaps just include svr4.h in this file? */
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) \
355 fprintf (STREAM, "%s\n", BSS_SECTION_ASM_OP); \
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); \
359 fprintf (STREAM, "\t%s\n", POPSECTION_ASM_OP); \
362 mips_declare_object (STREAM, NAME, "\n\t.lcomm\t", ",%u\n", (SIZE)); \
366 /* A C statement (sans semicolon) to output to the stdio stream
367 FILE the assembler definition of uninitialized global DECL named
368 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
369 Try to use asm_output_aligned_bss to implement this macro. */
371 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
372 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
374 /* Write the extra assembler code needed to declare an object properly. */
376 #undef ASM_DECLARE_OBJECT_NAME
377 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
380 size_directive_output = 0; \
381 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
383 size_directive_output = 1; \
384 fprintf (STREAM, "\t%s\t ", SIZE_ASM_OP); \
385 assemble_name (STREAM, NAME); \
386 fprintf (STREAM, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
388 mips_declare_object (STREAM, NAME, "", ":\n", 0); \
392 /* Output the size directive for a decl in rest_of_decl_compilation
393 in the case where we did not do so before the initializer.
394 Once we find the error_mark_node, we know that the value of
395 size_directive_output was set
396 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
398 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
400 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
401 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
402 && ! AT_END && TOP_LEVEL \
403 && DECL_INITIAL (DECL) == error_mark_node \
404 && !size_directive_output) \
406 size_directive_output = 1; \
407 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
408 assemble_name (FILE, name); \
409 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
413 #undef LOCAL_LABEL_PREFIX
414 #define LOCAL_LABEL_PREFIX (mips_abi == ABI_32 ? "$" : ".")
416 /* Profiling is supported via libprof1.a not -lc_p as in Irix 3. */
417 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
418 on the mipsX option. */
419 #undef STARTFILE_SPEC
420 #define STARTFILE_SPEC \
422 %{mabi=32:%{pg:gcrt1.o%s} \
423 %{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}} \
425 %{mips4:%{pg:/usr/lib32/mips4/gcrt1.o%s} \
426 %{!pg:%{p:/usr/lib32/mips4/mcrt1.o%s /usr/lib32/mips4/libprof1.a%s} \
427 %{!p:/usr/lib32/mips4/crt1.o%s}}} \
428 %{!mips4:%{pg:/usr/lib32/mips3/gcrt1.o%s} \
429 %{!pg:%{p:/usr/lib32/mips3/mcrt1.o%s /usr/lib32/mips3/libprof1.a%s} \
430 %{!p:/usr/lib32/mips3/crt1.o%s}}}} \
432 %{mips4:%{pg:/usr/lib64/mips4/gcrt1.o} \
433 %{!pg:%{p:/usr/lib64/mips4/mcrt1.o /usr/lib64/mips4/libprof1.a} \
434 %{!p:/usr/lib64/mips4/crt1.o}}} \
435 %{!mips4:%{pg:/usr/lib64/mips3/gcrt1.o} \
436 %{!pg:%{p:/usr/lib64/mips3/mcrt1.o /usr/lib64/mips3/libprof1.a} \
437 %{!p:/usr/lib64/mips3/crt1.o}}}} \
439 %{mips4:%{pg:/usr/lib32/mips4/gcrt1.o%s} \
440 %{!pg:%{p:/usr/lib32/mips4/mcrt1.o%s /usr/lib32/mips4/libprof1.a%s} \
441 %{!p:/usr/lib32/mips4/crt1.o%s}}} \
442 %{!mips4:%{pg:/usr/lib32/mips3/gcrt1.o%s} \
443 %{!pg:%{p:/usr/lib32/mips3/mcrt1.o%s /usr/lib32/mips3/libprof1.a%s} \
444 %{!p:/usr/lib32/mips3/crt1.o%s}}}}} \
445 %{mabi=n32: %{mips4:-L/usr/lib32/mips4} %{!mips4:-L/usr/lib32/mips3} \
447 %{mabi=64: %{mips4:-L/usr/lib64/mips4} %{!mips4:-L/usr/lib64/mips3} \
449 %{!mabi*: %{mips4:-L/usr/lib32/mips4} %{!mips4:-L/usr/lib32/mips3} \
456 -dont_warn_unused %{p:libprof1.a%s}%{pg:libprof1.a%s} -lc -warn_unused}"
458 /* Avoid getting two warnings for libgcc.a everytime we link. */
460 #define LIBGCC_SPEC "-dont_warn_unused -lgcc -warn_unused"
462 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
463 on the mipsX option. */
465 #define ENDFILE_SPEC \
469 %{mabi=n32:%{mips4:/usr/lib32/mips4/crtn.o%s}\
470 %{!mips4:/usr/lib32/mips3/crtn.o%s}}\
471 %{mabi=64:%{mips4:/usr/lib64/mips4/crtn.o%s}\
472 %{!mips4:/usr/lib64/mips3/crtn.o%s}}\
473 %{!mabi*:%{mips4:/usr/lib32/mips4/crtn.o%s}\
474 %{!mips4:/usr/lib32/mips3/crtn.o%s}}}"
476 /* ??? If no mabi=X option give, but a mipsX option is, then should depend
477 on the mipsX option. */
480 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
481 %{bestGnum} %{shared} %{non_shared} \
482 %{call_shared} %{no_archive} %{exact_version} \
483 %{!shared: %{!non_shared: %{!call_shared: -call_shared -no_unresolved}}} \
484 %{rpath} -init __do_global_ctors -fini __do_global_dtors \
485 %{shared:-hidden_symbol __do_global_ctors,__do_global_dtors} \
486 -_SYSTYPE_SVR4 %{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64} %{!mabi*: -n32}"