1 /* next.h: definitions for NeXT.
3 This file is part of GNU CC.
5 GNU CC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GNU CC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU CC; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19 #include "m68k/m68k.h"
21 /* Use new NeXT include file search path. */
23 #ifndef CROSS_COMPILE /* In a cross compiler with NeXT as target, don't expect
24 the host to use Next's directory scheme. */
25 #define INCLUDE_DEFAULTS \
27 { GPLUSPLUS_INCLUDE_DIR, 1}, \
28 { GCC_INCLUDE_DIR, 0}, \
29 { LOCAL_INCLUDE_DIR, 0}, \
30 { "/NextDeveloper/Headers", 0}, \
31 { "/NextDeveloper/Headers/ansi", 0}, \
32 { "/NextDeveloper/Headers/bsd", 0}, \
33 { "/LocalDeveloper/Headers", 0}, \
34 { "/LocalDeveloper/Headers/ansi", 0}, \
35 { "/LocalDeveloper/Headers/bsd", 0}, \
36 { "/NextDeveloper/2.0CompatibleHeaders", 0}, \
37 { STANDARD_INCLUDE_DIR, 0}, \
40 #endif /* CROSS_COMPILE */
42 #define EXTRA_FORMAT_FUNCTIONS \
43 "NXPrintf", FALSE, 2, FALSE, \
44 "NXScanf", TRUE, 2, FALSE, \
45 "NXVPrintf", FALSE, 2, TRUE, \
46 "NXVScanf", TRUE, 2, TRUE, \
47 "DPSPrintf", FALSE, 2, FALSE, \
48 "bsd_sprintf", FALSE, 2, FALSE, \
49 "bsd_vsprintf", FALSE, 2, TRUE,
51 /* Use NeXT's special calling convention for sending an Objc message. */
52 #define NEXT_OBJC_RUNTIME
57 /* Enable recent gcc to compile under the old gcc in Next release 1.0. */
58 #define __inline inline
60 /* See m68k.h. 0407 means 68040 (or 68030 or 68020, with 68881/2). */
62 #define TARGET_DEFAULT 0407
64 /* wchar_t is unsigned short */
67 #undef WCHAR_TYPE_SIZE
68 #define WCHAR_TYPE "short unsigned int"
69 #define WCHAR_TYPE_SIZE (BITS_PER_WORD / 2)
71 /* Give methods pretty symbol names on NeXT. */
73 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \
75 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
76 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
78 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
79 (CLASS_NAME), (SEL_NAME)); \
82 /* Wrap new method names in quotes so the assembler doesn't gag.
83 Make Objective-C internal symbols local. */
85 #undef ASM_OUTPUT_LABELREF
86 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
87 do { if (NAME[0] == '+' || NAME[0] == '-') fprintf (FILE, "\"%s\"", NAME); \
88 else if (!strncmp (NAME, "_OBJC_", 6)) fprintf (FILE, "L%s", NAME); \
89 else if (!strncmp (NAME, ".objc_class_name_", 17)) \
90 fprintf (FILE, "%s", NAME); \
91 else fprintf (FILE, "_%s", NAME); } while (0)
94 /* Boundary (in *bits*) on which stack pointer should be aligned. */
95 #define STACK_BOUNDARY 32
97 /* These compiler options take n arguments. */
99 #define WORD_SWITCH_TAKES_ARG(STR) \
100 (!strcmp (STR, "Ttext") ? 1 : \
101 !strcmp (STR, "Tdata") ? 1 : \
102 !strcmp (STR, "Tbss") ? 1 : \
103 !strcmp (STR, "include") ? 1 : \
104 !strcmp (STR, "imacros") ? 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, "aux-info") ? 1 : \
117 /* Names to predefine in the preprocessor for this target machine. */
119 #define CPP_PREDEFINES "-Dmc68000 -Dm68k -DNeXT -Dunix -D__MACH__ -D__ARCHITECTURE__=\"m68k\""
121 /* Machine dependent ccp options. */
123 /* This option used to be called -bsd, but that conflicts with the
124 general -b option. */
125 #define CPP_SPEC "%{strict-bsd:-D__STRICT_BSD__}"
127 /* Machine dependent ld options. */
129 #define LINK_SPEC "%{Z} %{M} \
130 %{execute*} %{object*} %{preload*} %{fvmlib*} \
131 %{segalign*} %{seg1addr*} %{segaddr*} %{segprot*} \
132 %{seglinkedit*} %{noseglinkedit*} \
133 %{sectcreate*} %{sectalign*} %{sectobjectsymbols}\
134 %{segcreate*} %{Mach*} %{whyload} %{w} \
135 %{sectorder*} %{whatsloaded}"
137 /* Machine dependent libraries. */
139 #define LIB_SPEC "%{!p:%{!pg:-lsys_s}} %{pg:-lsys_p}"
141 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
142 #define STARTFILE_SPEC \
143 "%{pg:-lgcrt0.o}%{!pg: \
144 %{p:%e-p profiling is no longer supported. Use -pg instead.} \
147 /* Every structure or union's size must be a multiple of 2 bytes.
148 (Why isn't this in m68k.h?) */
150 #define STRUCTURE_SIZE_BOUNDARY 16
154 #define DOLLARS_IN_IDENTIFIERS 2
156 /* Allow #sscs (but don't do anything). */
158 #define SCCS_DIRECTIVE
160 /* We use Dbx symbol format. */
162 #define DBX_DEBUGGING_INFO
164 /* This saves a fair amount of space. */
166 #define DBX_CONTIN_LENGTH 0
168 /* These screw up NeXT's gdb at the moment, so don't use them. */
170 #define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(FILE, FILENAME)
172 /* gdb needs a null N_SO at the end of each file for scattered loading. */
174 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
176 "\t.text\n\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n", \
179 /* Don't use .gcc_compiled symbols to communicate with GDB;
180 They interfere with numerically sorted symbol lists. */
182 #define ASM_IDENTIFY_GCC(asm_out_file)
184 /* This is how to output an assembler line defining a `double' constant. */
186 #undef ASM_OUTPUT_DOUBLE
187 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
188 (REAL_VALUE_ISINF ((VALUE)) \
189 ? fprintf (FILE, "\t.double 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
190 : fprintf (FILE, "\t.double 0r%.20e\n", (VALUE)))
192 /* This is how to output an assembler line defining a `float' constant. */
194 #undef ASM_OUTPUT_FLOAT
195 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
196 (REAL_VALUE_ISINF ((VALUE)) \
197 ? fprintf (FILE, "\t.single 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
198 : fprintf (FILE, "\t.single 0r%.20e\n", (VALUE)))
200 #undef ASM_OUTPUT_FLOAT_OPERAND
201 #define ASM_OUTPUT_FLOAT_OPERAND(FILE,VALUE) \
202 (REAL_VALUE_ISINF ((VALUE)) \
203 ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
204 : fprintf (FILE, "#0r%.9g", (VALUE)))
206 #undef ASM_OUTPUT_DOUBLE_OPERAND
207 #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
208 (REAL_VALUE_ISINF ((VALUE)) \
209 ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
210 : fprintf (FILE, "#0r%.20g", (VALUE)))
212 #if 0 /* This is for system verson 3.0, which isn't out yet. */
213 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
214 do { constructor_section (); \
215 ASM_OUTPUT_ALIGN (FILE, 1); \
216 fprintf (FILE, "\t.long "); \
217 assemble_name (FILE, NAME); \
218 fprintf (FILE, "\n"); } while (0)
220 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
221 do { destructor_section (); \
222 ASM_OUTPUT_ALIGN (FILE, 1); \
223 fprintf (FILE, "\t.long "); \
224 assemble_name (FILE, NAME); \
225 fprintf (FILE, "\n"); } while (0)
228 /* How to parse #pragma's */
230 #define HANDLE_PRAGMA(finput) handle_pragma (finput, &get_directive_line)
232 /* Create new Mach-O sections. */
234 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT) \
238 extern void text_section (); \
239 extern int flag_no_mach_text_sections; \
241 if (WAS_TEXT && flag_no_mach_text_sections) \
243 else if (in_section != SECTION) \
245 fprintf (asm_out_file, "%s\n", DIRECTIVE); \
246 in_section = SECTION; \
250 #define EXTRA_SECTIONS \
251 in_const, in_cstring, in_literal4, in_literal8, \
252 in_constructor, in_destructor, \
253 in_objc_class, in_objc_meta_class, in_objc_category, \
254 in_objc_class_vars, in_objc_instance_vars, \
255 in_objc_cls_meth, in_objc_inst_meth, \
256 in_objc_cat_cls_meth, in_objc_cat_inst_meth, \
257 in_objc_selector_strs, in_objc_selector_refs, \
258 in_objc_symbols, in_objc_module_info
260 #define EXTRA_SECTION_FUNCTIONS \
261 SECTION_FUNCTION (const_section, \
264 SECTION_FUNCTION (cstring_section, \
267 SECTION_FUNCTION (literal4_section, \
270 SECTION_FUNCTION (literal8_section, \
273 SECTION_FUNCTION (constructor_section, \
276 SECTION_FUNCTION (destructor_section, \
279 SECTION_FUNCTION (objc_class_section, \
282 SECTION_FUNCTION (objc_meta_class_section, \
283 in_objc_meta_class, \
284 ".objc_meta_class", 0) \
285 SECTION_FUNCTION (objc_category_section, \
287 ".objc_category", 0) \
288 SECTION_FUNCTION (objc_class_vars_section, \
289 in_objc_class_vars, \
290 ".objc_class_vars", 0) \
291 SECTION_FUNCTION (objc_instance_vars_section, \
292 in_objc_instance_vars, \
293 ".objc_instance_vars", 0) \
294 SECTION_FUNCTION (objc_cls_meth_section, \
296 ".objc_cls_meth", 0) \
297 SECTION_FUNCTION (objc_inst_meth_section, \
299 ".objc_inst_meth", 0) \
300 SECTION_FUNCTION (objc_cat_cls_meth_section, \
301 in_objc_cat_cls_meth, \
302 ".objc_cat_cls_meth", 0) \
303 SECTION_FUNCTION (objc_cat_inst_meth_section, \
304 in_objc_cat_inst_meth, \
305 ".objc_cat_inst_meth", 0) \
306 SECTION_FUNCTION (objc_selector_strs_section, \
307 in_objc_selector_strs, \
308 ".objc_selector_strs", 0) \
309 SECTION_FUNCTION (objc_selector_refs_section, \
310 in_objc_selector_refs, \
311 ".objc_selector_refs", 0) \
312 SECTION_FUNCTION (objc_symbols_section, \
314 ".objc_symbols", 0) \
315 SECTION_FUNCTION (objc_module_info_section, \
316 in_objc_module_info, \
317 ".objc_module_info", 0)
319 #define READONLY_DATA_SECTION const_section
321 #define SELECT_SECTION(exp,reloc) \
324 if (TREE_CODE (exp) == STRING_CST) \
326 if (flag_writable_strings) \
328 else if (TREE_STRING_LENGTH (exp) != \
329 strlen (TREE_STRING_POINTER (exp)) + 1) \
330 readonly_data_section (); \
332 cstring_section (); \
334 else if (TREE_CODE (exp) == INTEGER_CST \
335 || TREE_CODE (exp) == REAL_CST) \
337 tree size = TYPE_SIZE (TREE_TYPE (exp)); \
339 if (TREE_CODE (size) == INTEGER_CST && \
340 TREE_INT_CST_LOW (size) == 4 && \
341 TREE_INT_CST_HIGH (size) == 0) \
342 literal4_section (); \
343 else if (TREE_CODE (size) == INTEGER_CST && \
344 TREE_INT_CST_LOW (size) == 8 && \
345 TREE_INT_CST_HIGH (size) == 0) \
346 literal8_section (); \
348 readonly_data_section (); \
350 else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
351 && !TREE_SIDE_EFFECTS (exp)) \
352 readonly_data_section (); \
353 else if (TREE_CODE (exp) == VAR_DECL && \
355 TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \
356 IDENTIFIER_POINTER (DECL_NAME (exp)) && \
357 !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
359 const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \
361 if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \
362 objc_cls_meth_section (); \
363 else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \
364 objc_inst_meth_section (); \
365 else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
366 objc_cat_cls_meth_section (); \
367 else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
368 objc_cat_inst_meth_section (); \
369 else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \
370 objc_class_vars_section (); \
371 else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \
372 objc_instance_vars_section (); \
373 else if (!strncmp (name, "_OBJC_CLASS_", 12)) \
374 objc_class_section (); \
375 else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \
376 objc_meta_class_section (); \
377 else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \
378 objc_category_section (); \
379 else if (!strncmp (name, "_OBJC_STRINGS", 13)) \
380 objc_selector_strs_section (); \
381 else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \
382 objc_selector_refs_section (); \
383 else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \
384 objc_symbols_section (); \
385 else if (!strncmp (name, "_OBJC_MODULES", 13)) \
386 objc_module_info_section (); \
395 /* Force the assembler to create all the Objective-C sections,
396 so that their order is guaranteed. */
398 #define OBJC_PROLOGUE \
400 extern void objc_class_section (); \
401 extern void objc_meta_class_section (); \
402 extern void objc_cat_cls_meth_section (); \
403 extern void objc_cat_inst_meth_section (); \
404 extern void objc_cls_meth_section (); \
405 extern void objc_inst_meth_section (); \
406 extern void objc_selector_refs_section (); \
407 extern void objc_symbols_section (); \
408 extern void objc_category_section (); \
409 extern void objc_class_vars_section (); \
410 extern void objc_instance_vars_section (); \
411 extern void objc_module_info_section (); \
412 extern void objc_selector_strs_section (); \
414 objc_class_section (); \
415 objc_meta_class_section (); \
416 objc_cat_cls_meth_section (); \
417 objc_cat_inst_meth_section (); \
418 objc_cls_meth_section (); \
419 objc_inst_meth_section (); \
420 objc_selector_refs_section (); \
421 objc_symbols_section (); \
422 objc_category_section (); \
423 objc_class_vars_section (); \
424 objc_instance_vars_section (); \
425 objc_module_info_section (); \
426 objc_selector_strs_section (); \
429 /* We do not define JUMP_TABLES_IN_TEXT_SECTION, since we wish to keep
430 the text section pure. There is no point in addressing the jump
431 tables using pc relative addressing, since they are not in the text
432 section, so we undefine CASE_VECTOR_PC_RELATIVE. This also
433 causes the compiler to use absolute addresses in the jump table,
434 so we redefine CASE_VECTOR_MODE to be SImode. */
436 #undef CASE_VECTOR_MODE
437 #define CASE_VECTOR_MODE SImode
439 #undef CASE_VECTOR_PC_RELATIVE
441 /* Don't treat addresses involving labels differently from symbol names.
442 Previously, references to labels generated pc-relative addressing modes
443 while references to symbol names generated absolute addressing modes. */
445 #undef GO_IF_INDEXABLE_BASE(X, ADDR)
446 #define GO_IF_INDEXABLE_BASE(X, ADDR) \
447 { if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR; }
449 #define ALIGN_ASM_OP ".align"
451 #undef ASM_OUTPUT_ALIGN
452 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
454 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
456 /* The maximum alignment which the object file format can support.
457 For NeXT's Mach-O format, this is 2^15. */
459 #define MAX_OFILE_ALIGNMENT 0x8000
461 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
462 we want to retain compatibility with older gcc versions. */
463 #define DEFAULT_PCC_STRUCT_RETURN 0