1 /* Definitions of target machine for GNU compiler. IRIX version 5.
2 Copyright (C) 1993, 1995, 1996, 1998, 2000,
3 2001, 2002, 2003, 2004 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)
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 /* We are compiling for IRIX now. */
26 /* Allow some special handling for IRIX 5. */
28 #define TARGET_IRIX5 1
30 #define ABICALLS_ASM_OP "\t.option pic2"
32 /* Dummy definition which allows EXTRA_SECTION_FUNCTIONS to be the same
34 #define BSS_SECTION_ASM_OP "\t.data"
36 /* ??? This is correct, but not very useful, because there is no file that
38 /* ??? The best way to handle global constructors under ELF is to use .init
39 and .fini sections. Unfortunately, there is apparently no way to get
40 the IRIX 5.x (x <= 2) assembler to create these sections. So we instead
41 use collect. The linker can create these sections via -init and -fini
42 options, but using this would require modifying how crtstuff works, and
43 I will leave that for another time (or someone else). */
44 #define OBJECT_FORMAT_ELF
45 #define HAS_INIT_SECTION
46 #define LD_INIT_SWITCH "-init"
47 #define LD_FINI_SWITCH "-fini"
49 /* The linker needs a space after "-o". */
50 #define SWITCHES_NEED_SPACES "o"
52 /* Specify wchar_t types. */
54 #undef WCHAR_TYPE_SIZE
56 #define WCHAR_TYPE "int"
57 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
59 /* Plain char is unsigned in the SGI compiler. */
60 #undef DEFAULT_SIGNED_CHAR
61 #define DEFAULT_SIGNED_CHAR 0
63 #define WORD_SWITCH_TAKES_ARG(STR) \
64 (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \
65 || !strcmp (STR, "rpath"))
67 /* We must pass -D_LONGLONG always, even when -ansi is used, because IRIX 5
68 system header files require it. This is OK, because gcc never warns
69 when long long is used in system header files. Alternatively, we can
70 add support for the SGI builtin type __long_long. */
72 #define TARGET_OS_CPP_BUILTINS() \
74 builtin_define_std ("host_mips"); \
75 builtin_define_std ("sgi"); \
76 builtin_define_std ("unix"); \
77 builtin_define_std ("SYSTYPE_SVR4"); \
78 builtin_define ("_LONGLONG"); \
79 builtin_define ("_MODERN_C"); \
80 builtin_define ("_SVR4_SOURCE"); \
81 builtin_define ("__DSO__"); \
82 builtin_define ("_ABIO32=1"); \
83 builtin_define ("_MIPS_SIM=_ABIO32"); \
84 builtin_define ("_MIPS_SZPTR=32"); \
85 builtin_assert ("system=unix"); \
86 builtin_assert ("system=svr4"); \
87 builtin_assert ("machine=sgi"); \
89 if (!TARGET_FLOAT64) \
90 builtin_define ("_MIPS_FPSET=16"); \
92 builtin_define ("_MIPS_FPSET=32"); \
95 builtin_define ("_MIPS_SZINT=32"); \
97 builtin_define ("_MIPS_SZINT=64"); \
100 builtin_define ("_MIPS_SZLONG=32"); \
102 builtin_define ("_MIPS_SZLONG=64"); \
106 builtin_define ("__EXTENSIONS__"); \
107 builtin_define ("_SGI_SOURCE"); \
111 #undef SUBTARGET_CC1_SPEC
112 #define SUBTARGET_CC1_SPEC "%{static: -mno-abicalls}"
114 /* Override mips.h default: the IRIX 5 assembler warns about -O3:
116 as1: Warning: <file>.s, line 1: Binasm file dictates -pic: 2
118 No ucode object file linked -- please use -O2 or lower.
120 So avoid passing it in the first place. */
121 #undef SUBTARGET_ASM_OPTIMIZING_SPEC
122 #define SUBTARGET_ASM_OPTIMIZING_SPEC "\
124 %{!noasmopt:%{O|O1|O2|O3:-O2}}"
128 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
129 %{bestGnum} %{shared} %{non_shared} \
130 %{call_shared} %{no_archive} %{exact_version} \
131 %{static: -non_shared} \
133 %{!shared:%{!non_shared:%{!call_shared: -call_shared -no_unresolved}}}} \
137 /* We now support shared libraries. */
138 #define IRIX_STARTFILE_SPEC "\
140 %{!shared:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}}} \
143 %{!pg:%{p:/usr/lib/nonshared/mcrt1.o%s libprof1.a%s} \
144 %{!p:/usr/lib/nonshared/crt1.o%s}}}"
146 #undef STARTFILE_SPEC
147 #define STARTFILE_SPEC "%(irix_startfile_spec)"
150 #define LIB_SPEC "%{!shared:%{p:-lprof1} %{pg:-lprof1} -lc}"
152 #define IRIX_ENDFILE_SPEC "%{!shared:crtn.o%s}"
155 #define ENDFILE_SPEC "%(irix_endfile_spec)"
157 /* We do not want to run mips-tfile! */
158 #undef ASM_FINAL_SPEC
160 /* The system header files are C++ aware. */
161 /* ??? Unfortunately, most but not all of the headers are C++ aware.
162 Specifically, curses.h is not, and as a consequence, defining this
163 used to prevent libg++ building. This is no longer the case so
164 define it again to prevent other problems, e.g. with getopt in
165 unistd.h. We still need some way to fix just those files that need
167 #define NO_IMPLICIT_EXTERN_C 1
169 /* We don't support debugging info for now. */
170 #undef DBX_DEBUGGING_INFO
171 #undef MIPS_DEBUGGING_INFO
172 #undef PREFERRED_DEBUGGING_TYPE
174 /* Likewise, the assembler doesn't handle DWARF2 directives. */
175 #define DWARF2_UNWIND_INFO 0
178 #define MACHINE_TYPE "SGI running IRIX 5.x"
180 /* Always use 1 for .file number. I [meissner@osf.org] wonder why
183 #undef SET_FILE_NUMBER
184 #define SET_FILE_NUMBER() num_source_filenames = 1
186 /* Put out a label after a .loc. I [meissner@osf.org] wonder why
189 #undef LABEL_AFTER_LOC
190 #define LABEL_AFTER_LOC(STREAM) fprintf (STREAM, "LM%d:\n", ++sym_lineno)
192 /* Dollar signs are OK in IRIX 5 but not in IRIX 3. */
193 #undef DOLLARS_IN_IDENTIFIERS
194 #undef NO_DOLLAR_IN_LABEL
196 /* -G is incompatible with -KPIC which is the default, so only allow objects
197 in the small data section if the user explicitly asks for it. */
198 #undef MIPS_DEFAULT_GVALUE
199 #define MIPS_DEFAULT_GVALUE 0
201 /* Switch into a generic section. */
202 #undef TARGET_ASM_NAMED_SECTION
203 #define TARGET_ASM_NAMED_SECTION irix_asm_named_section
205 /* Define functions to read the name and flags of the current section.
206 They are used by irix_asm_output_align. */
208 #undef EXTRA_SECTION_FUNCTIONS
209 #define EXTRA_SECTION_FUNCTIONS \
211 current_section_name (void) \
213 switch (in_section) \
215 case no_section: return NULL; \
216 case in_unlikely_executed_text: \
217 case in_text: return ".text"; \
218 case in_data: return ".data"; \
219 case in_bss: return ".bss"; \
220 case in_readonly_data: \
221 if (mips_abi != ABI_32 && mips_abi != ABI_O64) \
226 return in_named_name; \
232 current_section_flags (void) \
234 switch (in_section) \
236 case no_section: return 0; \
237 case in_text: return SECTION_CODE; \
238 case in_data: return SECTION_WRITE; \
239 case in_bss: return SECTION_WRITE | SECTION_BSS; \
240 case in_readonly_data: return 0; \
241 case in_named: return get_named_section_flags (in_named_name); \
246 /* Some assemblers have a bug that causes backslash escaped chars in .ascii
247 to be misassembled, so avoid it by using .byte instead. Write the original
248 string in a comment, partly to improve readability and partly for the sake
249 of scan-assembler-type tests. */
250 #undef ASM_OUTPUT_ASCII
251 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
253 const unsigned char *s_ = (const unsigned char *)(PTR); \
254 unsigned len_ = (LEN); \
256 mips_output_ascii (FILE, (const char *) s_, len_, "\t# "); \
257 for (i_ = 0; i_ < len_; s_++, i_++) \
260 fputs ("\n\t.byte\t", (FILE)); \
261 fprintf ((FILE), "%s0x%x", (i_%8?",":""), *s_); \
263 fputs ("\n", (FILE)); \
266 /* Also do this for libcalls. */
267 #undef TARGET_ASM_EXTERNAL_LIBCALL
268 #define TARGET_ASM_EXTERNAL_LIBCALL irix_output_external_libcall
270 /* This does for functions what ASM_DECLARE_OBJECT_NAME does for variables.
271 This is used indirectly by ASM_OUTPUT_EXTERNAL. */
272 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
274 tree name_tree = get_identifier (NAME); \
275 TREE_ASM_WRITTEN (name_tree) = 1; \
278 /* This is how we tell the assembler that a symbol is weak. */
280 #define ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, VALUE) \
283 (*targetm.asm_out.globalize_label) (FILE, NAME); \
284 fputs ("\t.weakext\t", FILE); \
285 assemble_name (FILE, NAME); \
289 assemble_name (FILE, VALUE); \
291 fputc ('\n', FILE); \
295 #define ASM_WEAKEN_LABEL(FILE, NAME) ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, 0)
297 /* Handle #pragma weak and #pragma pack. */
298 #define HANDLE_SYSV_PRAGMA 1
300 #undef SUBTARGET_EXTRA_SPECS
301 #define SUBTARGET_EXTRA_SPECS \
302 { "irix_startfile_spec", IRIX_STARTFILE_SPEC }, \
303 { "irix_endfile_spec", IRIX_ENDFILE_SPEC },