OSDN Git Service

* config/i386/i386.c (ix86_expand_call): New function, extracted
[pf3gnuchains/gcc-fork.git] / gcc / config / nextstep.h
1 /* Operating system specific defines to be used when targeting GCC
2    for NeXTSTEP.
3    Copyright (C) 1989, 1990, 1991, 1992, 1993, 1996, 1997,
4    1999, 2002 Free Software Foundation, Inc.
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 /* Use new NeXT include file search path.
24    In a cross compiler with NeXT as target, don't expect
25    the host to use Next's directory scheme.  */
26
27 #ifndef CROSS_COMPILE
28 #undef  INCLUDE_DEFAULTS
29 #define INCLUDE_DEFAULTS                                \
30   {                                                     \
31     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },             \
32     { LOCAL_INCLUDE_DIR, 0, 0, 1 },                     \
33     { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },             \
34     { GCC_INCLUDE_DIR, "GCC", 0, 0 },                   \
35     /* These are for fixincludes-fixed ansi/bsd headers \
36        which wouldn't be found otherwise.               \
37        (The use of string catenation here is OK since   \
38         NeXT's native compiler is derived from GCC.) */ \
39     { GCC_INCLUDE_DIR "/ansi", 0, 0, 0 },               \
40     { GCC_INCLUDE_DIR "/bsd", 0, 0, 0 },                \
41     { "/NextDeveloper/Headers", 0, 0, 0 },              \
42     { "/NextDeveloper/Headers/ansi", 0, 0, 0 },         \
43     { "/NextDeveloper/Headers/bsd", 0, 0, 0 },          \
44     { "/LocalDeveloper/Headers", 0, 0, 0 },             \
45     { "/LocalDeveloper/Headers/ansi", 0, 0, 0 },        \
46     { "/LocalDeveloper/Headers/bsd", 0, 0, 0 },         \
47     { "/NextDeveloper/2.0CompatibleHeaders", 0, 0, 0 }, \
48     { STANDARD_INCLUDE_DIR, 0, 0, 0 },                  \
49     { "/usr/include/bsd", 0, 0, 0 },                    \
50     { 0, 0, 0, 0 }                                      \
51   }
52 #else /* CROSS_COMPILE */
53 #undef  INCLUDE_DEFAULTS
54 #define INCLUDE_DEFAULTS                                \
55   {                                                     \
56     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },             \
57     { GPLUSPLUS_INCLUDE_DIR, 0, 1, 1 },                 \
58     { GCC_INCLUDE_DIR, "GCC", 0, 0 },                   \
59     { GCC_INCLUDE_DIR "/ansi", 0, 0, 0 },               \
60     { GCC_INCLUDE_DIR "/bsd", 0, 0, 0 },                \
61     { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },             \
62     { TOOL_INCLUDE_DIR "/ansi", 0, 0, 0 },              \
63     { TOOL_INCLUDE_DIR "/bsd", 0, 0, 0 },               \
64     { "/usr/include/bsd", 0, 0, 0 },                    \
65     { 0, 0, 0, 0 }                                      \
66   }
67 #endif /* CROSS_COMPILE */
68
69 #undef  EXTRA_FORMAT_FUNCTIONS
70 #define EXTRA_FORMAT_FUNCTIONS \
71       "NXPrintf",       FALSE,  2,      FALSE,  \
72       "NXScanf",        TRUE,   2,      FALSE,  \
73       "NXVPrintf",      FALSE,  2,      TRUE,   \
74       "NXVScanf",       TRUE,   2,      TRUE,   \
75       "DPSPrintf",      FALSE,  2,      FALSE,  \
76       "bsd_sprintf",    FALSE,  2,      FALSE,  \
77       "bsd_vsprintf",   FALSE,  2,      TRUE,
78
79 /* Make -fnext-runtime the default.  */
80
81 #define NEXT_OBJC_RUNTIME
82
83 /* Enable recent gcc to compile under the old gcc in Next release 1.0.  */
84
85 #define __inline inline
86
87 /* wchar_t is unsigned short */
88
89 #undef  WCHAR_TYPE
90 #define WCHAR_TYPE "short unsigned int"
91 #undef  WCHAR_TYPE_SIZE
92 #define WCHAR_TYPE_SIZE (BITS_PER_WORD / 2)
93
94 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
95    we want to retain compatibility with older gcc versions.  */
96
97 #undef  DEFAULT_PCC_STRUCT_RETURN
98 #define DEFAULT_PCC_STRUCT_RETURN 0
99
100 /* These compiler options take n arguments.  */
101
102 #undef  WORD_SWITCH_TAKES_ARG
103 #define WORD_SWITCH_TAKES_ARG(STR)              \
104   (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) ? 1 :    \
105    !strcmp (STR, "segalign") ? 1 :              \
106    !strcmp (STR, "seg1addr") ? 1 :              \
107    !strcmp (STR, "segaddr") ? 2 :               \
108    !strcmp (STR, "sectobjectsymbols") ? 2 :     \
109    !strcmp (STR, "segprot") ? 3 :               \
110    !strcmp (STR, "sectcreate") ? 3 :            \
111    !strcmp (STR, "sectalign") ? 3 :             \
112    !strcmp (STR, "segcreate") ? 3 :             \
113    !strcmp (STR, "sectorder") ? 3 :             \
114    !strcmp (STR, "siff-mask") ? 1 :             \
115    !strcmp (STR, "siff-filter") ? 1 :           \
116    !strcmp (STR, "siff-warning") ? 1 :          \
117    !strcmp (STR, "arch") ? 1 :                  \
118    !strcmp (STR, "pagezero_size") ? 1 :         \
119    0)
120
121 #undef  WORD_SWITCH
122 #define WORD_SWITCH(STR)                        \
123   (WORD_SWITCH_TAKES_ARG (STR)                  \
124    || !strcmp (STR, "bsd")                      \
125    || !strcmp (STR, "object")                   \
126    || !strcmp (STR, "ObjC")                     \
127    || !strcmp (STR, "all_load"))
128
129 /* Machine dependent ccp options.  */
130
131 #undef  CPP_SPEC
132 #define CPP_SPEC "%{posixstrict:-D_POSIX_SOURCE}         \
133                   %{!posixstrict:%{bsd:-D__STRICT_BSD__} \
134                   %{posix:-D_POSIX_SOURCE}               \
135                   %{!ansi:-D_NEXT_SOURCE}}               \
136                   %{MD:-MD %M} %{MMD:-MMD %M}"
137
138 /* Machine dependent ld options.  */
139
140 #undef  LINK_SPEC
141 #define LINK_SPEC "%{Z} %{M} \
142 %{execute*} %{preload*} %{fvmlib*} \
143 %{segalign*} %{seg1addr*} %{segaddr*} %{segprot*} \
144 %{pagezero_size*} \
145 %{seglinkedit*} %{noseglinkedit*} \
146 %{sectcreate*} %{sectalign*} %{sectobjectsymbols}\
147 %{segcreate*} %{Mach*} %{whyload} %{w} \
148 %{sectorder*} %{whatsloaded} %{ObjC} %{all_load} %{object}"
149
150 /* Machine dependent libraries.  */
151
152 #undef  LIB_SPEC
153 #define LIB_SPEC "%{!posix*:-lsys_s} %{posix*:-lposix}"
154
155 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
156
157 #undef  STARTFILE_SPEC
158 #define STARTFILE_SPEC  \
159     "%{!posix*:%{pg:-lgcrt0.o}%{!pg: \
160      %{p:%e-p profiling is no longer supported.  Use -pg instead} \
161      %{!p:-lcrt0.o}}}\
162      %{posix*:%{pg:-lgposixcrt0.o}%{!pg: \
163      %{p:%e-p profiling is no longer supported.  Use -pg instead} \
164      %{!p:-lposixcrt0.o}}} \
165      -lcrtbegin.o"
166
167 #undef  ENDFILE_SPEC
168 #define ENDFILE_SPEC \
169     "-lcrtend.o"
170
171 /* Allow #sscs (but don't do anything). */
172
173 #define SCCS_DIRECTIVE
174
175 /* We use Dbx symbol format.  */
176
177 #undef  SDB_DEBUGGING_INFO
178 #undef  XCOFF_DEBUGGING_INFO
179 #define DBX_DEBUGGING_INFO
180
181 /* This saves a fair amount of space. */
182
183 #undef  DBX_CONTIN_LENGTH
184 #define DBX_CONTIN_LENGTH 0
185
186 /* These screw up NeXT's gdb at the moment, so don't use them. */
187
188 #undef  DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
189 #define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(FILE, FILENAME)
190
191 /* These come from bsd386.h, but are specific to sequent, so make sure
192    they don't bite us.  */
193
194 #undef  DBX_NO_XREFS
195 #undef  DBX_CONTIN_LENGTH
196
197 /* gdb needs a null N_SO at the end of each file for scattered loading. */
198
199 #undef  DBX_OUTPUT_MAIN_SOURCE_FILE_END
200 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME)                 \
201   fprintf (FILE,                                                        \
202            "\t.text\n\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n",         \
203            "" , N_SO)
204
205 /* Define our object format type for crtstuff.c */
206 #define OBJECT_FORMAT_MACHO
207
208 #undef  INIT_SECTION_ASM_OP
209 #define INIT_SECTION_ASM_OP
210 #undef  INVOKE__main
211
212 #define TARGET_ASM_CONSTRUCTOR  nextstep_asm_out_constructor
213 #define TARGET_ASM_DESTRUCTOR   nextstep_asm_out_destructor
214
215 #define TARGET_ASM_EXCEPTION_SECTION nextstep_exception_section
216
217 #define TARGET_ASM_EH_FRAME_SECTION nextstep_eh_frame_section
218   
219 /* Don't output a .file directive.  That is only used by the assembler for
220    error reporting.  */
221 #undef  ASM_FILE_START
222 #define ASM_FILE_START(FILE)
223
224 #undef  ASM_FILE_END
225 #define ASM_FILE_END(FILE)                                      \
226   do {                                                          \
227     if (strcmp (lang_hooks.name, "GNU C++") == 0)               \
228       {                                                         \
229         constructor_section ();                                 \
230         destructor_section ();                                  \
231         ASM_OUTPUT_ALIGN (FILE, 1);                             \
232       }                                                         \
233   } while (0)
234
235 /* How to parse #pragma's */
236
237 #undef  HANDLE_PRAGMA
238 #define HANDLE_PRAGMA(GETC, UNGETC, NAME) handle_pragma (GETC, UNGETC, NAME)
239
240 /* Give methods pretty symbol names on NeXT. */
241
242 #undef  OBJC_GEN_METHOD_LABEL
243 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
244   do { if (CAT_NAME)                                                    \
245          sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+',          \
246                   (CLASS_NAME), (CAT_NAME), (SEL_NAME));                \
247        else                                                             \
248          sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+',              \
249                   (CLASS_NAME), (SEL_NAME));                            \
250      } while (0)
251
252 /* The prefix to add to user-visible assembler symbols. */
253
254 #undef USER_LABEL_PREFIX
255 #define USER_LABEL_PREFIX "_"
256
257 /* Wrap new method names in quotes so the assembler doesn't gag.
258    Make Objective-C internal symbols local.  */
259
260 #undef  ASM_OUTPUT_LABELREF
261 #define ASM_OUTPUT_LABELREF(FILE,NAME)  \
262   do { if (NAME[0] == '+' || NAME[0] == '-') fprintf (FILE, "\"%s\"", NAME); \
263        else if (!strncmp (NAME, "_OBJC_", 6)) fprintf (FILE, "L%s", NAME);   \
264        else if (!strncmp (NAME, ".objc_class_name_", 17))               \
265          fprintf (FILE, "%s", NAME);                                    \
266        else asm_fprintf (FILE, "%U%s", NAME); } while (0)
267
268 #undef  ALIGN_ASM_OP
269 #define ALIGN_ASM_OP            "\t.align\t"
270
271 #undef  ASM_OUTPUT_ALIGN
272 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
273   if ((LOG) != 0)                       \
274     fprintf (FILE, "%s%d\n", ALIGN_ASM_OP, (LOG))
275
276 /* Ensure correct alignment of bss data.  */
277
278 #undef  ASM_OUTPUT_ALIGNED_LOCAL
279 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
280 ( fputs (".lcomm ", (FILE)),                            \
281   assemble_name ((FILE), (NAME)),                       \
282   fprintf ((FILE), ",%u,%u\n", (SIZE), floor_log2 ((ALIGN) / BITS_PER_UNIT)))
283
284 /* Output #ident as a .ident.  */
285
286 #undef  ASM_OUTPUT_IDENT
287 #define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME);
288
289 /* The maximum alignment which the object file format can support.
290    For NeXT's Mach-O format, this is 2^15.  */
291
292 #undef  MAX_OFILE_ALIGNMENT
293 #define MAX_OFILE_ALIGNMENT 0x8000
294
295 /* Create new Mach-O sections. */
296
297 #undef  SECTION_FUNCTION
298 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT, OBJC)  \
299 extern void FUNCTION PARAMS ((void));                                   \
300 void                                                                    \
301 FUNCTION ()                                                             \
302 {                                                                       \
303   extern int flag_no_mach_text_sections;                                \
304                                                                         \
305   if (WAS_TEXT && flag_no_mach_text_sections)                           \
306     text_section ();                                                    \
307   else if (in_section != SECTION)                                       \
308     {                                                                   \
309       if (OBJC)                                                         \
310         objc_section_init ();                                           \
311       fprintf (asm_out_file, "%s\n", DIRECTIVE);                        \
312       in_section = SECTION;                                             \
313     }                                                                   \
314 }                                                                       \
315
316 #undef  EXTRA_SECTIONS
317 #define EXTRA_SECTIONS                                  \
318   in_const, in_cstring, in_literal4, in_literal8,       \
319   in_constructor, in_destructor,                        \
320   in_nextstep_exception, in_nextstep_eh_frame,          \
321   in_objc_class, in_objc_meta_class, in_objc_category,  \
322   in_objc_class_vars, in_objc_instance_vars,            \
323   in_objc_cls_meth, in_objc_inst_meth,                  \
324   in_objc_cat_cls_meth, in_objc_cat_inst_meth,          \
325   in_objc_selector_refs,                                \
326   in_objc_symbols, in_objc_module_info,                 \
327   in_objc_protocol, in_objc_string_object,              \
328   in_objc_class_names, in_objc_meth_var_names,          \
329   in_objc_meth_var_types, in_objc_cls_refs
330
331 #undef  EXTRA_SECTION_FUNCTIONS
332 #define EXTRA_SECTION_FUNCTIONS                 \
333 extern void objc_section_init PARAMS ((void));  \
334 SECTION_FUNCTION (const_section,                \
335                   in_const,                     \
336                   ".const", 1, 0)               \
337 SECTION_FUNCTION (cstring_section,              \
338                   in_cstring,                   \
339                   ".cstring", 1, 0)             \
340 SECTION_FUNCTION (literal4_section,             \
341                   in_literal4,                  \
342                   ".literal4", 1, 0)            \
343 SECTION_FUNCTION (literal8_section,             \
344                   in_literal8,                  \
345                   ".literal8", 1, 0)            \
346 SECTION_FUNCTION (constructor_section,          \
347                   in_constructor,               \
348                   ".constructor", 0, 0)         \
349 SECTION_FUNCTION (destructor_section,           \
350                   in_destructor,                \
351                   ".destructor", 0, 0)          \
352 SECTION_FUNCTION (nextstep_exception_section,   \
353                   in_nextstep_exception,        \
354                   ".section __TEXT,__gcc_except_tab,regular", 0, 0)     \
355 SECTION_FUNCTION (nextstep_eh_frame_section,    \
356                   in_nextstep_eh_frame,         \
357                   ".section __TEXT,__eh_frame,regular", 0, 0)           \
358 SECTION_FUNCTION (objc_class_section,           \
359                   in_objc_class,                \
360                   ".objc_class", 0, 1)          \
361 SECTION_FUNCTION (objc_meta_class_section,      \
362                   in_objc_meta_class,           \
363                   ".objc_meta_class", 0, 1)     \
364 SECTION_FUNCTION (objc_category_section,        \
365                   in_objc_category,             \
366                 ".objc_category", 0, 1)         \
367 SECTION_FUNCTION (objc_class_vars_section,      \
368                   in_objc_class_vars,           \
369                   ".objc_class_vars", 0, 1)     \
370 SECTION_FUNCTION (objc_instance_vars_section,   \
371                   in_objc_instance_vars,        \
372                   ".objc_instance_vars", 0, 1)  \
373 SECTION_FUNCTION (objc_cls_meth_section,        \
374                   in_objc_cls_meth,             \
375                   ".objc_cls_meth", 0, 1)       \
376 SECTION_FUNCTION (objc_inst_meth_section,       \
377                   in_objc_inst_meth,            \
378                   ".objc_inst_meth", 0, 1)      \
379 SECTION_FUNCTION (objc_cat_cls_meth_section,    \
380                   in_objc_cat_cls_meth,         \
381                   ".objc_cat_cls_meth", 0, 1)   \
382 SECTION_FUNCTION (objc_cat_inst_meth_section,   \
383                   in_objc_cat_inst_meth,        \
384                   ".objc_cat_inst_meth", 0, 1)  \
385 SECTION_FUNCTION (objc_selector_refs_section,   \
386                   in_objc_selector_refs,        \
387                   ".objc_message_refs", 0, 1)   \
388 SECTION_FUNCTION (objc_symbols_section,         \
389                   in_objc_symbols,              \
390                   ".objc_symbols", 0, 1)        \
391 SECTION_FUNCTION (objc_module_info_section,     \
392                   in_objc_module_info,          \
393                   ".objc_module_info", 0, 1)    \
394 SECTION_FUNCTION (objc_protocol_section,        \
395                   in_objc_protocol,             \
396                   ".objc_protocol", 0, 1)       \
397 SECTION_FUNCTION (objc_string_object_section,   \
398                   in_objc_string_object,        \
399                   ".objc_string_object", 0, 1)  \
400 SECTION_FUNCTION (objc_class_names_section,     \
401                 in_objc_class_names,            \
402                 ".objc_class_names", 0, 1)      \
403 SECTION_FUNCTION (objc_meth_var_names_section,  \
404                 in_objc_meth_var_names,         \
405                 ".objc_meth_var_names", 0, 1)   \
406 SECTION_FUNCTION (objc_meth_var_types_section,  \
407                 in_objc_meth_var_types,         \
408                 ".objc_meth_var_types", 0, 1)   \
409 SECTION_FUNCTION (objc_cls_refs_section,        \
410                 in_objc_cls_refs,               \
411                 ".objc_cls_refs", 0, 1)         \
412                                                 \
413 void                                            \
414 objc_section_init ()                            \
415 {                                               \
416   static int been_here = 0;                     \
417                                                 \
418   if (been_here == 0)                           \
419     {                                           \
420       been_here = 1;                            \
421       objc_class_section ();                    \
422       objc_meta_class_section ();               \
423       objc_cat_cls_meth_section ();             \
424       objc_cat_inst_meth_section ();            \
425       objc_cls_meth_section ();                 \
426       objc_inst_meth_section ();                \
427       objc_selector_refs_section ();            \
428       objc_symbols_section ();                  \
429       objc_category_section ();                 \
430       objc_protocol_section ();                 \
431       objc_class_vars_section ();               \
432       objc_instance_vars_section ();            \
433       objc_module_info_section ();              \
434       objc_string_object_section ();            \
435       objc_class_names_section ();              \
436       objc_meth_var_names_section ();           \
437       objc_meth_var_types_section ();           \
438       objc_cls_refs_section ();                 \
439     }                                           \
440 }
441
442 #define READONLY_DATA_SECTION const_section
443
444 #undef  TARGET_ASM_SELECT_SECTION
445 #define TARGET_ASM_SELECT_SECTION nextstep_select_section
446 #undef  TARGET_ASM_SELECT_RTX_SECTION
447 #define TARGET_ASM_SELECT_RTX_SECTION nextstep_select_rtx_section
448
449 #ifdef ASM_COMMENT_START
450 # undef ASM_COMMENT_START
451 #endif
452
453 #define ASM_COMMENT_START ";#"