a172986310870e06d3a67b6e11e162ad768b66f5
[gcc.git] / gcc / config / mips / iris5.h
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.
4
5 This file is part of GCC.
6
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.
11
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.
16
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. */
21
22 /* We are compiling for IRIX now. */
23 #undef TARGET_IRIX
24 #define TARGET_IRIX 1
25
26 /* Allow some special handling for IRIX 5. */
27 #undef TARGET_IRIX5
28 #define TARGET_IRIX5 1
29
30 #define ABICALLS_ASM_OP "\t.option pic2"
31
32 /* Dummy definition which allows EXTRA_SECTION_FUNCTIONS to be the same
33 for IRIX 5 and 6. */
34 #define BSS_SECTION_ASM_OP "\t.data"
35
36 /* ??? This is correct, but not very useful, because there is no file that
37 uses this macro. */
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"
48
49 /* The linker needs a space after "-o". */
50 #define SWITCHES_NEED_SPACES "o"
51
52 /* Specify wchar_t types. */
53 #undef WCHAR_TYPE
54 #undef WCHAR_TYPE_SIZE
55
56 #define WCHAR_TYPE "int"
57 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
58
59 /* Plain char is unsigned in the SGI compiler. */
60 #undef DEFAULT_SIGNED_CHAR
61 #define DEFAULT_SIGNED_CHAR 0
62
63 #define WORD_SWITCH_TAKES_ARG(STR) \
64 (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \
65 || !strcmp (STR, "rpath"))
66
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. */
71
72 #define TARGET_OS_CPP_BUILTINS() \
73 do { \
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"); \
88 \
89 if (!TARGET_FLOAT64) \
90 builtin_define ("_MIPS_FPSET=16"); \
91 else \
92 builtin_define ("_MIPS_FPSET=32"); \
93 \
94 if (!TARGET_INT64) \
95 builtin_define ("_MIPS_SZINT=32"); \
96 else \
97 builtin_define ("_MIPS_SZINT=64"); \
98 \
99 if (!TARGET_LONG64) \
100 builtin_define ("_MIPS_SZLONG=32"); \
101 else \
102 builtin_define ("_MIPS_SZLONG=64"); \
103 \
104 if (!flag_iso) \
105 { \
106 builtin_define ("__EXTENSIONS__"); \
107 builtin_define ("_SGI_SOURCE"); \
108 } \
109 } while (0);
110
111 #undef SUBTARGET_CC1_SPEC
112 #define SUBTARGET_CC1_SPEC "%{static: -mno-abicalls}"
113
114 /* Override mips.h default: the IRIX 5 assembler warns about -O3:
115
116 as1: Warning: <file>.s, line 1: Binasm file dictates -pic: 2
117 uld:
118 No ucode object file linked -- please use -O2 or lower.
119
120 So avoid passing it in the first place. */
121 #undef SUBTARGET_ASM_OPTIMIZING_SPEC
122 #define SUBTARGET_ASM_OPTIMIZING_SPEC "\
123 %{noasmopt:-O0} \
124 %{!noasmopt:%{O|O1|O2|O3:-O2}}"
125
126 #undef LINK_SPEC
127 #define LINK_SPEC "\
128 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
129 %{bestGnum} %{shared} %{non_shared} \
130 %{call_shared} %{no_archive} %{exact_version} \
131 %{static: -non_shared} \
132 %{!static: \
133 %{!shared:%{!non_shared:%{!call_shared: -call_shared -no_unresolved}}}} \
134 %{rpath} \
135 -_SYSTYPE_SVR4"
136
137 /* We now support shared libraries. */
138 #undef STARTFILE_SPEC
139 #define STARTFILE_SPEC "\
140 %{!static: \
141 %{!shared:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}}} \
142 %{static: \
143 %{pg:gcrt1.o%s} \
144 %{!pg:%{p:/usr/lib/nonshared/mcrt1.o%s libprof1.a%s} \
145 %{!p:/usr/lib/nonshared/crt1.o%s}}}"
146
147 #undef LIB_SPEC
148 #define LIB_SPEC "%{!shared:%{p:-lprof1} %{pg:-lprof1} -lc}"
149
150 #undef ENDFILE_SPEC
151 #define ENDFILE_SPEC "%{!shared:crtn.o%s}"
152
153 /* We do not want to run mips-tfile! */
154 #undef ASM_FINAL_SPEC
155
156 /* The system header files are C++ aware. */
157 /* ??? Unfortunately, most but not all of the headers are C++ aware.
158 Specifically, curses.h is not, and as a consequence, defining this
159 used to prevent libg++ building. This is no longer the case so
160 define it again to prevent other problems, e.g. with getopt in
161 unistd.h. We still need some way to fix just those files that need
162 fixing. */
163 #define NO_IMPLICIT_EXTERN_C 1
164
165 /* We don't support debugging info for now. */
166 #undef DBX_DEBUGGING_INFO
167 #undef MIPS_DEBUGGING_INFO
168 #undef PREFERRED_DEBUGGING_TYPE
169
170 /* Likewise, the assembler doesn't handle DWARF2 directives. */
171 #define DWARF2_UNWIND_INFO 0
172
173 #undef MACHINE_TYPE
174 #define MACHINE_TYPE "SGI running IRIX 5.x"
175
176 /* Always use 1 for .file number. I [meissner@osf.org] wonder why
177 IRIX needs this. */
178
179 #undef SET_FILE_NUMBER
180 #define SET_FILE_NUMBER() num_source_filenames = 1
181
182 /* Put out a label after a .loc. I [meissner@osf.org] wonder why
183 IRIX needs this. */
184
185 #undef LABEL_AFTER_LOC
186 #define LABEL_AFTER_LOC(STREAM) fprintf (STREAM, "LM%d:\n", ++sym_lineno)
187
188 /* Dollar signs are OK in IRIX 5 but not in IRIX 3. */
189 #undef DOLLARS_IN_IDENTIFIERS
190 #undef NO_DOLLAR_IN_LABEL
191
192 /* -G is incompatible with -KPIC which is the default, so only allow objects
193 in the small data section if the user explicitly asks for it. */
194 #undef MIPS_DEFAULT_GVALUE
195 #define MIPS_DEFAULT_GVALUE 0
196
197 /* Switch into a generic section. */
198 #undef TARGET_ASM_NAMED_SECTION
199 #define TARGET_ASM_NAMED_SECTION irix_asm_named_section
200
201 /* Define functions to read the name and flags of the current section.
202 They are used by irix_asm_output_align. */
203
204 #undef EXTRA_SECTION_FUNCTIONS
205 #define EXTRA_SECTION_FUNCTIONS \
206 const char * \
207 current_section_name (void) \
208 { \
209 switch (in_section) \
210 { \
211 case no_section: return NULL; \
212 case in_text: return ".text"; \
213 case in_data: return ".data"; \
214 case in_bss: return ".bss"; \
215 case in_readonly_data: \
216 if (mips_abi != ABI_32 && mips_abi != ABI_O64) \
217 return ".rodata"; \
218 else \
219 return ".rdata"; \
220 case in_named: \
221 return in_named_name; \
222 } \
223 abort (); \
224 } \
225 \
226 unsigned int \
227 current_section_flags (void) \
228 { \
229 switch (in_section) \
230 { \
231 case no_section: return 0; \
232 case in_text: return SECTION_CODE; \
233 case in_data: return SECTION_WRITE; \
234 case in_bss: return SECTION_WRITE | SECTION_BSS; \
235 case in_readonly_data: return 0; \
236 case in_named: return get_named_section_flags (in_named_name); \
237 } \
238 abort (); \
239 }
240
241 /* Some assemblers have a bug that causes backslash escaped chars in .ascii
242 to be misassembled, so avoid it by using .byte instead. Write the original
243 string in a comment, partly to improve readability and partly for the sake
244 of scan-assembler-type tests. */
245 #undef ASM_OUTPUT_ASCII
246 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
247 do { \
248 const unsigned char *s_ = (const unsigned char *)(PTR); \
249 unsigned len_ = (LEN); \
250 unsigned i_; \
251 mips_output_ascii (FILE, (const char *) s_, len_, "\t# "); \
252 for (i_ = 0; i_ < len_; s_++, i_++) \
253 { \
254 if ((i_ % 8) == 0) \
255 fputs ("\n\t.byte\t", (FILE)); \
256 fprintf ((FILE), "%s0x%x", (i_%8?",":""), *s_); \
257 } \
258 fputs ("\n", (FILE)); \
259 } while (0)
260
261 /* Also do this for libcalls. */
262 #undef TARGET_ASM_EXTERNAL_LIBCALL
263 #define TARGET_ASM_EXTERNAL_LIBCALL irix_output_external_libcall
264
265 /* This does for functions what ASM_DECLARE_OBJECT_NAME does for variables.
266 This is used indirectly by ASM_OUTPUT_EXTERNAL. */
267 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
268 do { \
269 tree name_tree = get_identifier (NAME); \
270 TREE_ASM_WRITTEN (name_tree) = 1; \
271 } while (0)
272
273 /* This is how we tell the assembler that a symbol is weak. */
274
275 #define ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, VALUE) \
276 do \
277 { \
278 (*targetm.asm_out.globalize_label) (FILE, NAME); \
279 fputs ("\t.weakext\t", FILE); \
280 assemble_name (FILE, NAME); \
281 if (VALUE) \
282 { \
283 fputc (' ', FILE); \
284 assemble_name (FILE, VALUE); \
285 } \
286 fputc ('\n', FILE); \
287 } \
288 while (0)
289
290 #define ASM_WEAKEN_LABEL(FILE, NAME) ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, 0)
291
292 /* Handle #pragma weak and #pragma pack. */
293 #define HANDLE_SYSV_PRAGMA 1