OSDN Git Service

2004-04-11 Andrew Pinski <pinskia@physics.uc.edu>
[pf3gnuchains/gcc-fork.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 #define IRIX_STARTFILE_SPEC "\
139 %{!static: \
140   %{!shared:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}}} \
141 %{static: \
142   %{pg:gcrt1.o%s} \
143   %{!pg:%{p:/usr/lib/nonshared/mcrt1.o%s libprof1.a%s} \
144   %{!p:/usr/lib/nonshared/crt1.o%s}}}"
145
146 #undef STARTFILE_SPEC
147 #define STARTFILE_SPEC "%(irix_startfile_spec)"
148
149 #undef LIB_SPEC
150 #define LIB_SPEC "%{!shared:%{p:-lprof1} %{pg:-lprof1} -lc}"
151
152 #define IRIX_ENDFILE_SPEC "%{!shared:crtn.o%s}"
153
154 #undef ENDFILE_SPEC
155 #define ENDFILE_SPEC "%(irix_endfile_spec)"
156
157 /* We do not want to run mips-tfile!  */
158 #undef ASM_FINAL_SPEC
159
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
166    fixing.  */
167 #define NO_IMPLICIT_EXTERN_C 1
168
169 /* We don't support debugging info for now.  */
170 #undef DBX_DEBUGGING_INFO
171 #undef MIPS_DEBUGGING_INFO
172 #undef PREFERRED_DEBUGGING_TYPE
173
174 /* Likewise, the assembler doesn't handle DWARF2 directives.  */
175 #define DWARF2_UNWIND_INFO 0
176
177 #undef MACHINE_TYPE
178 #define MACHINE_TYPE "SGI running IRIX 5.x"
179
180 /* Always use 1 for .file number.  I [meissner@osf.org] wonder why
181    IRIX needs this.  */
182
183 #undef SET_FILE_NUMBER
184 #define SET_FILE_NUMBER() num_source_filenames = 1
185
186 /* Put out a label after a .loc.  I [meissner@osf.org] wonder why
187    IRIX needs this.  */
188
189 #undef LABEL_AFTER_LOC
190 #define LABEL_AFTER_LOC(STREAM) fprintf (STREAM, "LM%d:\n", ++sym_lineno)
191
192  /* Dollar signs are OK in IRIX 5 but not in IRIX 3.  */
193 #undef DOLLARS_IN_IDENTIFIERS
194 #undef NO_DOLLAR_IN_LABEL
195
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
200
201 /* Switch into a generic section.  */
202 #undef TARGET_ASM_NAMED_SECTION
203 #define TARGET_ASM_NAMED_SECTION  irix_asm_named_section
204
205 /* Define functions to read the name and flags of the current section.
206    They are used by irix_asm_output_align.  */
207
208 #undef EXTRA_SECTION_FUNCTIONS
209 #define EXTRA_SECTION_FUNCTIONS                                         \
210 const char *                                                            \
211 current_section_name (void)                                             \
212 {                                                                       \
213   switch (in_section)                                                   \
214     {                                                                   \
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)                    \
222         return ".rodata";                                               \
223       else                                                              \
224         return ".rdata";                                                \
225     case in_named:                                                      \
226       return in_named_name;                                             \
227     default: abort();                                                   \
228     }                                                                   \
229 }                                                                       \
230                                                                         \
231 unsigned int                                                            \
232 current_section_flags (void)                                            \
233 {                                                                       \
234   switch (in_section)                                                   \
235     {                                                                   \
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); \
242     }                                                                   \
243   abort ();                                                             \
244 }
245
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)                          \
252 do {                                                            \
253   const unsigned char *s_ = (const unsigned char *)(PTR);       \
254   unsigned len_ = (LEN);                                        \
255   unsigned i_;                                                  \
256   mips_output_ascii (FILE, (const char *) s_, len_, "\t# ");    \
257   for (i_ = 0; i_ < len_; s_++, i_++)                           \
258     {                                                           \
259       if ((i_ % 8) == 0)                                        \
260         fputs ("\n\t.byte\t", (FILE));                          \
261       fprintf ((FILE), "%s0x%x", (i_%8?",":""), *s_);           \
262     }                                                           \
263   fputs ("\n", (FILE));                                         \
264 } while (0)
265
266 /* Also do this for libcalls.  */
267 #undef TARGET_ASM_EXTERNAL_LIBCALL
268 #define TARGET_ASM_EXTERNAL_LIBCALL irix_output_external_libcall
269
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)   \
273 do {                                                    \
274   tree name_tree = get_identifier (NAME);               \
275   TREE_ASM_WRITTEN (name_tree) = 1;                     \
276 } while (0)
277
278 /* This is how we tell the assembler that a symbol is weak.  */
279
280 #define ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, VALUE)        \
281   do                                                    \
282     {                                                   \
283       (*targetm.asm_out.globalize_label) (FILE, NAME);  \
284       fputs ("\t.weakext\t", FILE);                     \
285       assemble_name (FILE, NAME);                       \
286       if (VALUE)                                        \
287         {                                               \
288           fputc (' ', FILE);                            \
289           assemble_name (FILE, VALUE);                  \
290         }                                               \
291       fputc ('\n', FILE);                               \
292     }                                                   \
293   while (0)
294
295 #define ASM_WEAKEN_LABEL(FILE, NAME) ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, 0)
296
297 /* Handle #pragma weak and #pragma pack.  */
298 #define HANDLE_SYSV_PRAGMA 1
299
300 #undef SUBTARGET_EXTRA_SPECS
301 #define SUBTARGET_EXTRA_SPECS \
302   { "irix_startfile_spec", IRIX_STARTFILE_SPEC }, \
303   { "irix_endfile_spec", IRIX_ENDFILE_SPEC },