|
|
1.1 root 1: /* next.h: definitions for NeXT.
2:
3: This file is part of GNU CC.
4:
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)
8: any later version.
9:
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.
14:
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. */
18:
19: #include "m68k.h"
20:
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,
29:
30: /* Use NeXT's special calling convention for sending an Objc message. */
31: #define NEXT_OBJC_RUNTIME
32:
33: /* We have atexit. */
34: #define HAVE_ATEXIT
35:
36: /* Enable recent gcc to compile under the old gcc in Next release 1.0. */
37: #define __inline inline
38:
39: /* See m68k.h. 0407 means 68040 (or 68030 or 68020, with 68881/2). */
40:
41: #define TARGET_DEFAULT 0407
42:
43: /* wchar_t is unsigned short */
44:
45: #undef WCHAR_TYPE
46: #undef WCHAR_TYPE_SIZE
47: #define WCHAR_TYPE "short unsigned int"
48: #define WCHAR_TYPE_SIZE (BITS_PER_WORD / 2)
49:
50: /* Give methods pretty symbol names on NeXT. */
51:
52: #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME) \
53: do { if (CAT_NAME) \
54: sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \
55: (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \
56: else \
57: sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \
58: (CLASS_NAME), (SEL_NAME)); \
59: } while (0)
60:
61: /* Wrap new method names in quotes so the assembler doesn't gag.
62: Make Objective-C internal symbols local. */
63:
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 fprintf (FILE, "_%s", NAME); } while (0)
69:
70: #undef STACK_BOUNDARY
71: /* Boundary (in *bits*) on which stack pointer should be aligned. */
72: #define STACK_BOUNDARY 32
73:
74: /* These compiler options take n arguments. */
75:
76: #define WORD_SWITCH_TAKES_ARG(STR) \
77: (!strcmp (STR, "Ttext") ? 1 : \
78: !strcmp (STR, "Tdata") ? 1 : \
79: !strcmp (STR, "include") ? 1 : \
80: !strcmp (STR, "imacros") ? 1 : \
81: !strcmp (STR, "segalign") ? 1 : \
82: !strcmp (STR, "seg1addr") ? 1 : \
83: !strcmp (STR, "segaddr") ? 2 : \
84: !strcmp (STR, "sectobjectsymbols") ? 2 : \
85: !strcmp (STR, "segprot") ? 3 : \
86: !strcmp (STR, "sectcreate") ? 3 : \
87: !strcmp (STR, "sectalign") ? 3 : \
88: !strcmp (STR, "segcreate") ? 3 : \
89: !strcmp (STR, "sectorder") ? 3 : \
90: 0)
91:
92: /* Names to predefine in the preprocessor for this target machine. */
93:
94: #define CPP_PREDEFINES "-Dmc68000 -Dm68k -DNeXT -Dunix -D__MACH__"
95:
96: /* Machine dependent ccp options. */
97:
98: /* This option used to be called -bsd, but that conflicts with the
99: general -b option. */
100: #define CPP_SPEC "%{strict-bsd:-D__STRICT_BSD__}"
101:
102: /* Machine dependent ld options. */
103:
104: #define LINK_SPEC "%{Z} %{M} \
105: %{execute*} %{object*} %{preload*} %{fvmlib*} \
106: %{segalign*} %{seg1addr*} %{segaddr*} %{segprot*} \
107: %{seglinkedit*} %{noseglinkedit*} \
108: %{sectcreate*} %{sectalign*} %{sectobjectsymbols}\
109: %{segcreate*} %{Mach*} %{whyload} %{w} \
110: %{sectorder*} %{whatsloaded}"
111:
112: /* Machine dependent libraries. */
113:
114: #define LIB_SPEC "%{!p:%{!pg:-lsys_s}} %{pg:-lsys_p}"
115:
116: /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
117: #define STARTFILE_SPEC \
118: "%{pg:-lgcrt0.o}%{!pg: \
119: %{p:%e-p profiling is no longer supported. Use -pg instead.} \
120: %{!p:-lcrt0.o}}"
121:
122: /* Every structure or union's size must be a multiple of 2 bytes.
123: (Why isn't this in m68k.h?) */
124:
125: #define STRUCTURE_SIZE_BOUNDARY 16
126:
127: /* Why not? */
128:
129: #define DOLLARS_IN_IDENTIFIERS 2
130:
131: /* Allow #sscs (but don't do anything). */
132:
133: #define SCCS_DIRECTIVE
134:
135: /* We use Dbx symbol format. */
136:
137: #define DBX_DEBUGGING_INFO
138:
139: /* This saves a fair amount of space. */
140:
141: #define DBX_CONTIN_LENGTH 0
142:
143: /* These screw up NeXT's gdb at the moment, so don't use them. */
144:
145: #define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(FILE, FILENAME)
146:
147: /* gdb needs a null N_SO at the end of each file for scattered loading. */
148:
149: #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
150: fprintf (FILE, \
151: "\t.text\n\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n", \
152: "" , N_SO)
153:
154: /* Don't use .gcc_compiled symbols to communicate with GDB;
155: They interfere with numerically sorted symbol lists. */
156:
157: #define ASM_IDENTIFY_GCC(asm_out_file)
158:
159: /* This is how to output an assembler line defining a `double' constant. */
160:
161: #undef ASM_OUTPUT_DOUBLE
162: #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
163: (REAL_VALUE_ISINF ((VALUE)) \
164: ? fprintf (FILE, "\t.double 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
165: : fprintf (FILE, "\t.double 0r%.20e\n", (VALUE)))
166:
167: /* This is how to output an assembler line defining a `float' constant. */
168:
169: #undef ASM_OUTPUT_FLOAT
170: #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
171: (REAL_VALUE_ISINF ((VALUE)) \
172: ? fprintf (FILE, "\t.single 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
173: : fprintf (FILE, "\t.single 0r%.20e\n", (VALUE)))
174:
175: #undef ASM_OUTPUT_FLOAT_OPERAND
176: #define ASM_OUTPUT_FLOAT_OPERAND(FILE,VALUE) \
177: (REAL_VALUE_ISINF ((VALUE)) \
178: ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
179: : fprintf (FILE, "#0r%.9g", (VALUE)))
180:
181: #undef ASM_OUTPUT_DOUBLE_OPERAND
182: #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
183: (REAL_VALUE_ISINF ((VALUE)) \
184: ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
185: : fprintf (FILE, "#0r%.20g", (VALUE)))
186:
187: #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
188: do { constructor_section (); \
189: ASM_OUTPUT_ALIGN (FILE, 1); \
190: fprintf (FILE, "\t.long "); \
191: assemble_name (FILE, NAME); \
192: fprintf (FILE, "\n"); } while (0)
193:
194: #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
195: do { destructor_section (); \
196: ASM_OUTPUT_ALIGN (FILE, 1); \
197: fprintf (FILE, "\t.long "); \
198: assemble_name (FILE, NAME); \
199: fprintf (FILE, "\n"); } while (0)
200:
201: /* How to parse #pragma's */
202:
203: #define HANDLE_PRAGMA(finput) handle_pragma (finput)
204:
205: /* Create new Mach-O sections. */
206:
207: #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT) \
208: void \
209: FUNCTION () \
210: { \
211: extern void text_section (); \
212: extern int flag_no_mach_text_sections; \
213: \
214: if (WAS_TEXT && flag_no_mach_text_sections) \
215: text_section (); \
216: else if (in_section != SECTION) \
217: { \
218: fprintf (asm_out_file, "%s\n", DIRECTIVE); \
219: in_section = SECTION; \
220: } \
221: } \
222:
223: #define EXTRA_SECTIONS \
224: in_const, in_cstring, in_literal4, in_literal8, \
225: in_constructor, in_destructor, \
226: in_objc_class, in_objc_meta_class, in_objc_category, \
227: in_objc_class_vars, in_objc_instance_vars, \
228: in_objc_cls_meth, in_objc_inst_meth, \
229: in_objc_cat_cls_meth, in_objc_cat_inst_meth, \
230: in_objc_selector_strs, in_objc_selector_refs, \
231: in_objc_symbols, in_objc_module_info
232:
233: #define EXTRA_SECTION_FUNCTIONS \
234: SECTION_FUNCTION (const_section, \
235: in_const, \
236: ".const", 1) \
237: SECTION_FUNCTION (cstring_section, \
238: in_cstring, \
239: ".cstring", 1) \
240: SECTION_FUNCTION (literal4_section, \
241: in_literal4, \
242: ".literal4", 1) \
243: SECTION_FUNCTION (literal8_section, \
244: in_literal8, \
245: ".literal8", 1) \
246: SECTION_FUNCTION (constructor_section, \
247: in_constructor, \
248: ".constructor", 0) \
249: SECTION_FUNCTION (destructor_section, \
250: in_destructor, \
251: ".destructor", 0) \
252: SECTION_FUNCTION (objc_class_section, \
253: in_objc_class, \
254: ".objc_class", 0) \
255: SECTION_FUNCTION (objc_meta_class_section, \
256: in_objc_meta_class, \
257: ".objc_meta_class", 0) \
258: SECTION_FUNCTION (objc_category_section, \
259: in_objc_category, \
260: ".objc_category", 0) \
261: SECTION_FUNCTION (objc_class_vars_section, \
262: in_objc_class_vars, \
263: ".objc_class_vars", 0) \
264: SECTION_FUNCTION (objc_instance_vars_section, \
265: in_objc_instance_vars, \
266: ".objc_instance_vars", 0) \
267: SECTION_FUNCTION (objc_cls_meth_section, \
268: in_objc_cls_meth, \
269: ".objc_cls_meth", 0) \
270: SECTION_FUNCTION (objc_inst_meth_section, \
271: in_objc_inst_meth, \
272: ".objc_inst_meth", 0) \
273: SECTION_FUNCTION (objc_cat_cls_meth_section, \
274: in_objc_cat_cls_meth, \
275: ".objc_cat_cls_meth", 0) \
276: SECTION_FUNCTION (objc_cat_inst_meth_section, \
277: in_objc_cat_inst_meth, \
278: ".objc_cat_inst_meth", 0) \
279: SECTION_FUNCTION (objc_selector_strs_section, \
280: in_objc_selector_strs, \
281: ".objc_selector_strs", 0) \
282: SECTION_FUNCTION (objc_selector_refs_section, \
283: in_objc_selector_refs, \
284: ".objc_selector_refs", 0) \
285: SECTION_FUNCTION (objc_symbols_section, \
286: in_objc_symbols, \
287: ".objc_symbols", 0) \
288: SECTION_FUNCTION (objc_module_info_section, \
289: in_objc_module_info, \
290: ".objc_module_info", 0)
291:
292: #define READONLY_DATA_SECTION const_section
293:
294: #define SELECT_SECTION(exp,reloc) \
295: do \
296: { \
297: if (TREE_CODE (exp) == STRING_CST) \
298: { \
299: if (flag_writable_strings) \
300: data_section (); \
301: else if (TREE_STRING_LENGTH (exp) != \
302: strlen (TREE_STRING_POINTER (exp)) + 1) \
303: readonly_data_section (); \
304: else \
305: cstring_section (); \
306: } \
307: else if (TREE_CODE (exp) == INTEGER_CST \
308: || TREE_CODE (exp) == REAL_CST) \
309: { \
310: tree size = TYPE_SIZE (TREE_TYPE (exp)); \
311: \
312: if (TREE_CODE (size) == INTEGER_CST && \
313: TREE_INT_CST_LOW (size) == 4 && \
314: TREE_INT_CST_HIGH (size) == 0) \
315: literal4_section (); \
316: else if (TREE_CODE (size) == INTEGER_CST && \
317: TREE_INT_CST_LOW (size) == 8 && \
318: TREE_INT_CST_HIGH (size) == 0) \
319: literal8_section (); \
320: else \
321: readonly_data_section (); \
322: } \
323: else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \
324: && !TREE_SIDE_EFFECTS (exp)) \
325: readonly_data_section (); \
326: else if (TREE_CODE (exp) == VAR_DECL && \
327: DECL_NAME (exp) && \
328: TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \
329: IDENTIFIER_POINTER (DECL_NAME (exp)) && \
330: !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
331: { \
332: const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \
333: \
334: if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \
335: objc_cls_meth_section (); \
336: else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \
337: objc_inst_meth_section (); \
338: else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
339: objc_cat_cls_meth_section (); \
340: else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
341: objc_cat_inst_meth_section (); \
342: else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \
343: objc_class_vars_section (); \
344: else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \
345: objc_instance_vars_section (); \
346: else if (!strncmp (name, "_OBJC_CLASS_", 12)) \
347: objc_class_section (); \
348: else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \
349: objc_meta_class_section (); \
350: else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \
351: objc_category_section (); \
352: else if (!strncmp (name, "_OBJC_STRINGS", 13)) \
353: objc_selector_strs_section (); \
354: else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \
355: objc_selector_refs_section (); \
356: else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \
357: objc_symbols_section (); \
358: else if (!strncmp (name, "_OBJC_MODULES", 13)) \
359: objc_module_info_section (); \
360: else \
361: data_section (); \
362: } \
363: else \
364: data_section (); \
365: } \
366: while (0)
367:
368: /* Force the assembler to create all the Objective-C sections,
369: so that their order is guaranteed. */
370:
371: #define OBJC_PROLOGUE \
372: do { \
373: extern void objc_class_section (); \
374: extern void objc_meta_class_section (); \
375: extern void objc_cat_cls_meth_section (); \
376: extern void objc_cat_inst_meth_section (); \
377: extern void objc_cls_meth_section (); \
378: extern void objc_inst_meth_section (); \
379: extern void objc_selector_refs_section (); \
380: extern void objc_symbols_section (); \
381: extern void objc_category_section (); \
382: extern void objc_class_vars_section (); \
383: extern void objc_instance_vars_section (); \
384: extern void objc_module_info_section (); \
385: extern void objc_selector_strs_section (); \
386: \
387: objc_class_section (); \
388: objc_meta_class_section (); \
389: objc_cat_cls_meth_section (); \
390: objc_cat_inst_meth_section (); \
391: objc_cls_meth_section (); \
392: objc_inst_meth_section (); \
393: objc_selector_refs_section (); \
394: objc_symbols_section (); \
395: objc_category_section (); \
396: objc_class_vars_section (); \
397: objc_instance_vars_section (); \
398: objc_module_info_section (); \
399: objc_selector_strs_section (); \
400: } while (0)
401:
402: /* We do not define JUMP_TABLES_IN_TEXT_SECTION, since we wish to keep
403: the text section pure. There is no point in addressing the jump
404: tables using pc relative addressing, since they are not in the text
405: section, so we undefine CASE_VECTOR_PC_RELATIVE. This also
406: causes the compiler to use absolute addresses in the jump table,
407: so we redefine CASE_VECTOR_MODE to be SImode. */
408:
409: #undef CASE_VECTOR_MODE
410: #define CASE_VECTOR_MODE SImode
411:
412: #undef CASE_VECTOR_PC_RELATIVE
413:
414: /* Don't treat addresses involving labels differently from symbol names.
415: Previsouly, references to labels generated pc-relative addressing modes
416: while references to symbol names generated absolute addressing modes. */
417:
418: #undef GO_IF_INDEXABLE_BASE(X, ADDR)
419: #define GO_IF_INDEXABLE_BASE(X, ADDR) \
420: { if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR; }
421:
422: #define ALIGN_ASM_OP "\t.align"
423:
424: #undef ASM_OUTPUT_ALIGN
425: #define ASM_OUTPUT_ALIGN(FILE,LOG) \
426: if ((LOG) != 0) \
427: fprintf (FILE, "%s %d\n", ALIGN_ASM_OP, (LOG))
428:
429: /* The maximum alignment which the object file format can support.
430: For NeXT's Mach-O format, this is 2^15. */
431:
432: #define MAX_OFILE_ALIGNMENT 0x8000
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.