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. */
21 #define EXTRA_FORMAT_FUNCTIONS \
22 "NXPrintf", FALSE, 2, FALSE, \
23 "NXScanf", TRUE, 2, FALSE, \
24 "NXVPrintf", FALSE, 2, TRUE, \
25 "NXVScanf", TRUE, 2, TRUE, \
26 "DPSPrintf", FALSE, 2, FALSE, \
27 "bsd_sprintf", FALSE, 2, FALSE, \
28 "bsd_vsprintf", FALSE, 2, TRUE,
30 /* Use NeXT's special calling convention for sending an Objc message. */
31 #define NEXT_OBJC_RUNTIME
36 /* Enable recent gcc to compile under the old gcc in Next release 1.0. */
37 #define __inline inline
39 /* See m68k.h. 0407 means 68040 (or 68030 or 68020, with 68881/2). */
41 #define TARGET_DEFAULT 0407
43 /* wchar_t is unsigned short */
46 #undef WCHAR_TYPE_SIZE
47 #define WCHAR_TYPE "short unsigned int"
48 #define WCHAR_TYPE_SIZE (BITS_PER_WORD / 2)
50 /* Give methods pretty symbol names on NeXT. */
52 #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME) \
54 sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
55 (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
57 sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
58 (CLASS_NAME), (SEL_NAME)); \
61 /* Wrap new method names in quotes so the assembler doesn't gag.
62 Make Objective-C internal symbols local. */
64 #undef ASM_OUTPUT_LABELREF
65 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
66 do { if (NAME[0] == '+' || NAME[0] == '-') fprintf (FILE, "\"%s\"", NAME); \
67 else if (!strncmp (NAME, "_OBJC_", 6)) fprintf (FILE, "L%s", NAME); \
68 else if (!strncmp (NAME, ".objc_class_name_", 17)) \
69 fprintf (FILE, "%s", NAME); \
70 else fprintf (FILE, "_%s", NAME); } while (0)
73 /* Boundary (in *bits*) on which stack pointer should be aligned. */
74 #define STACK_BOUNDARY 32
76 /* These compiler options take n arguments. */
78 #define WORD_SWITCH_TAKES_ARG(STR) \
79 (!strcmp (STR, "Ttext") ? 1 : \
80 !strcmp (STR, "Tdata") ? 1 : \
81 !strcmp (STR, "include") ? 1 : \
82 !strcmp (STR, "imacros") ? 1 : \
83 !strcmp (STR, "segalign") ? 1 : \
84 !strcmp (STR, "seg1addr") ? 1 : \
85 !strcmp (STR, "segaddr") ? 2 : \
86 !strcmp (STR, "sectobjectsymbols") ? 2 : \
87 !strcmp (STR, "segprot") ? 3 : \
88 !strcmp (STR, "sectcreate") ? 3 : \
89 !strcmp (STR, "sectalign") ? 3 : \
90 !strcmp (STR, "segcreate") ? 3 : \
91 !strcmp (STR, "sectorder") ? 3 : \
92 !strcmp (STR, "aux-info") ? 1 : \
95 /* Names to predefine in the preprocessor for this target machine. */
97 #define CPP_PREDEFINES "-Dmc68000 -Dm68k -DNeXT -Dunix -D__MACH__"
99 /* Machine dependent ccp options. */
101 /* This option used to be called -bsd, but that conflicts with the
102 general -b option. */
103 #define CPP_SPEC "%{strict-bsd:-D__STRICT_BSD__}"
105 /* Machine dependent ld options. */
107 #define LINK_SPEC "%{Z} %{M} \
108 %{execute*} %{object*} %{preload*} %{fvmlib*} \
109 %{segalign*} %{seg1addr*} %{segaddr*} %{segprot*} \
110 %{seglinkedit*} %{noseglinkedit*} \
111 %{sectcreate*} %{sectalign*} %{sectobjectsymbols}\
112 %{segcreate*} %{Mach*} %{whyload} %{w} \
113 %{sectorder*} %{whatsloaded}"
115 /* Machine dependent libraries. */
117 #define LIB_SPEC "%{!p:%{!pg:-lsys_s}} %{pg:-lsys_p}"
119 /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
120 #define STARTFILE_SPEC \
121 "%{pg:-lgcrt0.o}%{!pg: \
122 %{p:%e-p profiling is no longer supported. Use -pg instead.} \
125 /* Every structure or union's size must be a multiple of 2 bytes.
126 (Why isn't this in m68k.h?) */
128 #define STRUCTURE_SIZE_BOUNDARY 16
132 #define DOLLARS_IN_IDENTIFIERS 2
134 /* Allow #sscs (but don't do anything). */
136 #define SCCS_DIRECTIVE
138 /* We use Dbx symbol format. */
140 #define DBX_DEBUGGING_INFO
142 /* This saves a fair amount of space. */
144 #define DBX_CONTIN_LENGTH 0
146 /* These screw up NeXT's gdb at the moment, so don't use them. */
148 #define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(FILE, FILENAME)
150 /* gdb needs a null N_SO at the end of each file for scattered loading. */
152 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
154 "\t.text\n\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n", \
157 /* Don't use .gcc_compiled symbols to communicate with GDB;
158 They interfere with numerically sorted symbol lists. */
160 #define ASM_IDENTIFY_GCC(asm_out_file)
162 /* This is how to output an assembler line defining a `double' constant. */
164 #undef ASM_OUTPUT_DOUBLE
165 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
166 (REAL_VALUE_ISINF ((VALUE)) \
167 ? fprintf (FILE, "\t.double 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
168 : fprintf (FILE, "\t.double 0r%.20e\n", (VALUE)))
170 /* This is how to output an assembler line defining a `float' constant. */
172 #undef ASM_OUTPUT_FLOAT
173 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
174 (REAL_VALUE_ISINF ((VALUE)) \
175 ? fprintf (FILE, "\t.single 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
176 : fprintf (FILE, "\t.single 0r%.20e\n", (VALUE)))
178 #undef ASM_OUTPUT_FLOAT_OPERAND
179 #define ASM_OUTPUT_FLOAT_OPERAND(FILE,VALUE) \
180 (REAL_VALUE_ISINF ((VALUE)) \
181 ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
182 : fprintf (FILE, "#0r%.9g", (VALUE)))
184 #undef ASM_OUTPUT_DOUBLE_OPERAND
185 #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
186 (REAL_VALUE_ISINF ((VALUE)) \
187 ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
188 : fprintf (FILE, "#0r%.20g", (VALUE)))
190 #if 0 /* This is for system verson 3.0, which isn't out yet. */
191 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
192 do { constructor_section (); \
193 ASM_OUTPUT_ALIGN (FILE, 1); \
194 fprintf (FILE, "\t.long "); \
195 assemble_name (FILE, NAME); \
196 fprintf (FILE, "\n"); } while (0)
198 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
199 do { destructor_section (); \
200 ASM_OUTPUT_ALIGN (FILE, 1); \
201 fprintf (FILE, "\t.long "); \
202 assemble_name (FILE, NAME); \
203 fprintf (FILE, "\n"); } while (0)
206 /* How to parse #pragma's */
208 #define HANDLE_PRAGMA(finput) handle_pragma (finput)
210 /* Create new Mach-O sections. */
212 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT) \
216 extern void text_section (); \
217 extern int flag_no_mach_text_sections; \
219 if (WAS_TEXT && flag_no_mach_text_sections) \
221 else if (in_section != SECTION) \
223 fprintf (asm_out_file, "%s\n", DIRECTIVE); \
224 in_section = SECTION; \
228 #define EXTRA_SECTIONS \
229 in_const, in_cstring, in_literal4, in_literal8, \
230 in_constructor, in_destructor, \
231 in_objc_class, in_objc_meta_class, in_objc_category, \
232 in_objc_class_vars, in_objc_instance_vars, \
233 in_objc_cls_meth, in_objc_inst_meth, \
234 in_objc_cat_cls_meth, in_objc_cat_inst_meth, \
235 in_objc_selector_strs, in_objc_selector_refs, \
236 in_objc_symbols, in_objc_module_info
238 #define EXTRA_SECTION_FUNCTIONS \
239 SECTION_FUNCTION (const_section, \
242 SECTION_FUNCTION (cstring_section, \
245 SECTION_FUNCTION (literal4_section, \
248 SECTION_FUNCTION (literal8_section, \
251 SECTION_FUNCTION (constructor_section, \
254 SECTION_FUNCTION (destructor_section, \
257 SECTION_FUNCTION (objc_class_section, \
260 SECTION_FUNCTION (objc_meta_class_section, \
261 in_objc_meta_class, \
262 ".objc_meta_class", 0) \
263 SECTION_FUNCTION (objc_category_section, \
265 ".objc_category", 0) \
266 SECTION_FUNCTION (objc_class_vars_section, \
267 in_objc_class_vars, \
268 ".objc_class_vars", 0) \
269 SECTION_FUNCTION (objc_instance_vars_section, \
270 in_objc_instance_vars, \
271 ".objc_instance_vars", 0) \
272 SECTION_FUNCTION (objc_cls_meth_section, \
274 ".objc_cls_meth", 0) \
275 SECTION_FUNCTION (objc_inst_meth_section, \
277 ".objc_inst_meth", 0) \
278 SECTION_FUNCTION (objc_cat_cls_meth_section, \
279 in_objc_cat_cls_meth, \
280 ".objc_cat_cls_meth", 0) \
281 SECTION_FUNCTION (objc_cat_inst_meth_section, \
282 in_objc_cat_inst_meth, \
283 ".objc_cat_inst_meth", 0) \
284 SECTION_FUNCTION (objc_selector_strs_section, \
285 in_objc_selector_strs, \
286 ".objc_selector_strs", 0) \
287 SECTION_FUNCTION (objc_selector_refs_section, \
288 in_objc_selector_refs, \
289 ".objc_selector_refs", 0) \
290 SECTION_FUNCTION (objc_symbols_section, \
292 ".objc_symbols", 0) \
293 SECTION_FUNCTION (objc_module_info_section, \
294 in_objc_module_info, \
295 ".objc_module_info", 0)
297 #define READONLY_DATA_SECTION const_section
299 #define SELECT_SECTION(exp,reloc) \
302 if (TREE_CODE (exp) == STRING_CST) \
304 if (flag_writable_strings) \
306 else if (TREE_STRING_LENGTH (exp) != \
307 strlen (TREE_STRING_POINTER (exp)) + 1) \
308 readonly_data_section (); \
310 cstring_section (); \
312 else if (TREE_CODE (exp) == INTEGER_CST \
313 || TREE_CODE (exp) == REAL_CST) \
315 tree size = TYPE_SIZE (TREE_TYPE (exp)); \
317 if (TREE_CODE (size) == INTEGER_CST && \
318 TREE_INT_CST_LOW (size) == 4 && \
319 TREE_INT_CST_HIGH (size) == 0) \
320 literal4_section (); \
321 else if (TREE_CODE (size) == INTEGER_CST && \
322 TREE_INT_CST_LOW (size) == 8 && \
323 TREE_INT_CST_HIGH (size) == 0) \
324 literal8_section (); \
326 readonly_data_section (); \
328 else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
329 && !TREE_SIDE_EFFECTS (exp)) \
330 readonly_data_section (); \
331 else if (TREE_CODE (exp) == VAR_DECL && \
333 TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \
334 IDENTIFIER_POINTER (DECL_NAME (exp)) && \
335 !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
337 const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \
339 if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \
340 objc_cls_meth_section (); \
341 else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \
342 objc_inst_meth_section (); \
343 else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
344 objc_cat_cls_meth_section (); \
345 else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
346 objc_cat_inst_meth_section (); \
347 else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \
348 objc_class_vars_section (); \
349 else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \
350 objc_instance_vars_section (); \
351 else if (!strncmp (name, "_OBJC_CLASS_", 12)) \
352 objc_class_section (); \
353 else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \
354 objc_meta_class_section (); \
355 else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \
356 objc_category_section (); \
357 else if (!strncmp (name, "_OBJC_STRINGS", 13)) \
358 objc_selector_strs_section (); \
359 else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \
360 objc_selector_refs_section (); \
361 else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \
362 objc_symbols_section (); \
363 else if (!strncmp (name, "_OBJC_MODULES", 13)) \
364 objc_module_info_section (); \
373 /* Force the assembler to create all the Objective-C sections,
374 so that their order is guaranteed. */
376 #define OBJC_PROLOGUE \
378 extern void objc_class_section (); \
379 extern void objc_meta_class_section (); \
380 extern void objc_cat_cls_meth_section (); \
381 extern void objc_cat_inst_meth_section (); \
382 extern void objc_cls_meth_section (); \
383 extern void objc_inst_meth_section (); \
384 extern void objc_selector_refs_section (); \
385 extern void objc_symbols_section (); \
386 extern void objc_category_section (); \
387 extern void objc_class_vars_section (); \
388 extern void objc_instance_vars_section (); \
389 extern void objc_module_info_section (); \
390 extern void objc_selector_strs_section (); \
392 objc_class_section (); \
393 objc_meta_class_section (); \
394 objc_cat_cls_meth_section (); \
395 objc_cat_inst_meth_section (); \
396 objc_cls_meth_section (); \
397 objc_inst_meth_section (); \
398 objc_selector_refs_section (); \
399 objc_symbols_section (); \
400 objc_category_section (); \
401 objc_class_vars_section (); \
402 objc_instance_vars_section (); \
403 objc_module_info_section (); \
404 objc_selector_strs_section (); \
407 /* We do not define JUMP_TABLES_IN_TEXT_SECTION, since we wish to keep
408 the text section pure. There is no point in addressing the jump
409 tables using pc relative addressing, since they are not in the text
410 section, so we undefine CASE_VECTOR_PC_RELATIVE. This also
411 causes the compiler to use absolute addresses in the jump table,
412 so we redefine CASE_VECTOR_MODE to be SImode. */
414 #undef CASE_VECTOR_MODE
415 #define CASE_VECTOR_MODE SImode
417 #undef CASE_VECTOR_PC_RELATIVE
419 /* Don't treat addresses involving labels differently from symbol names.
420 Previously, references to labels generated pc-relative addressing modes
421 while references to symbol names generated absolute addressing modes. */
423 #undef GO_IF_INDEXABLE_BASE(X, ADDR)
424 #define GO_IF_INDEXABLE_BASE(X, ADDR) \
425 { if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR; }
427 #define ALIGN_ASM_OP ".align"
429 #undef ASM_OUTPUT_ALIGN
430 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
432 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
434 /* The maximum alignment which the object file format can support.
435 For NeXT's Mach-O format, this is 2^15. */
437 #define MAX_OFILE_ALIGNMENT 0x8000