]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/nextstep.c
a701776ff27f9017bc0ecc1af36cfbacebfe6d76
[thirdparty/gcc.git] / gcc / config / nextstep.c
1 /* Functions for generic NeXT as target machine for GNU C compiler.
2 Copyright (C) 1989, 1990, 1991, 1992, 1993, 1996, 1997, 1998,
3 2000, 2002 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC 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 GNU CC 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 GNU CC; 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 #include "config.h"
23 #include "system.h"
24 #include "flags.h"
25 #include "tree.h"
26 #include "rtl.h"
27 #include "toplev.h"
28 #include "output.h"
29 #include "tm_p.h"
30
31 /* Make everything that used to go in the text section really go there. */
32
33 int flag_no_mach_text_sections = 0;
34
35 #define OPT_STRCMP(opt) (!strncmp (opt, p, sizeof (opt)-1))
36
37 /* 1 if handle_pragma has been called yet. */
38
39 static int pragma_initialized;
40
41 /* Initial setting of `optimize'. */
42
43 static int initial_optimize_flag;
44
45 /* Called from check_newline via the macro HANDLE_PRAGMA.
46 FINPUT is the source file input stream.
47 CH is the first character after `#pragma'.
48 The result is 1 if the pragma was handled. */
49
50 int
51 handle_pragma (p_getc, p_ungetc, pname)
52 int (* p_getc) PARAMS ((void)) ATTRIBUTE_UNUSED;
53 void (* p_ungetc) PARAMS ((int)) ATTRIBUTE_UNUSED;
54 const char *pname;
55 {
56 int retval = 0;
57
58 /* Record initial setting of optimize flag, so we can restore it. */
59 if (!pragma_initialized)
60 {
61 pragma_initialized = 1;
62 initial_optimize_flag = optimize;
63 }
64
65 if (strcmp (pname, "CC_OPT_ON") == 0)
66 {
67 optimize = 1;
68 warning ("optimization turned on");
69 retval = 1;
70 }
71 else if (strcmp (pname, "CC_OPT_OFF") == 0)
72 {
73 optimize = 0;
74 warning ("optimization turned off");
75 retval = 1;
76 }
77 else if (strcmp (pname, "CC_OPT_RESTORE") == 0)
78 {
79 extern int initial_optimize_flag;
80
81 if (optimize != initial_optimize_flag)
82 optimize = initial_optimize_flag;
83 warning ("optimization level restored");
84 retval = 1;
85 }
86 else if (strcmp (pname, "CC_WRITABLE_STRINGS") == 0)
87 flag_writable_strings = retval = 1;
88 else if (strcmp (pname, "CC_NON_WRITABLE_STRINGS") == 0)
89 flag_writable_strings = 0, retval = 1;
90 else if (strcmp (pname, "CC_NO_MACH_TEXT_SECTIONS") == 0)
91 flag_no_mach_text_sections = retval = 1;
92
93 return retval;
94 }
95
96 void
97 nextstep_asm_out_constructor (symbol, priority)
98 rtx symbol;
99 int priority ATTRIBUTE_UNUSED;
100 {
101 constructor_section ();
102 assemble_align (POINTER_SIZE);
103 assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
104 fprintf (asm_out_file, ".reference .constructors_used\n");
105 }
106
107 void
108 nextstep_asm_out_destructor (symbol, priority)
109 rtx symbol;
110 int priority ATTRIBUTE_UNUSED;
111 {
112 destructor_section ();
113 assemble_align (POINTER_SIZE);
114 assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
115 fprintf (asm_out_file, ".reference .destructors_used\n");
116 }
117
118 void
119 nextstep_select_section (exp, reloc, align)
120 tree exp;
121 int reloc;
122 unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
123 {
124 if (TREE_CODE (exp) == STRING_CST)
125 {
126 if (flag_writable_strings)
127 data_section ();
128 else if (TREE_STRING_LENGTH (exp)
129 != strlen (TREE_STRING_POINTER (exp)) + 1)
130 readonly_data_section ();
131 else
132 cstring_section ();
133 }
134 else if (TREE_CODE (exp) == INTEGER_CST
135 || TREE_CODE (exp) == REAL_CST)
136 {
137 tree size = TYPE_SIZE (TREE_TYPE (exp));
138 HOST_WIDE_INT size_int;
139
140 if (TREE_CODE (size) == INTEGER_CST)
141 size_int = tree_low_cst (size, 1);
142 else
143 size_int = 0;
144
145 if (size_int == 4)
146 literal4_section ();
147 else if (size_int == 8)
148 literal8_section ();
149 else
150 readonly_data_section ();
151 }
152 else if (TREE_CODE (exp) == CONSTRUCTOR
153 && TREE_TYPE (exp)
154 && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
155 && TYPE_NAME (TREE_TYPE (exp))
156 && TREE_CODE (TYPE_NAME (TREE_TYPE (exp))) == IDENTIFIER_NODE
157 && IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))))
158 {
159 if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))),
160 "NXConstantString"))
161 objc_string_object_section ();
162 else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))
163 && !TREE_SIDE_EFFECTS (exp))
164 readonly_data_section ();
165 else
166 data_section ();
167 }
168 else if (TREE_CODE (exp) == VAR_DECL
169 && DECL_NAME (exp)
170 && TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE
171 && IDENTIFIER_POINTER (DECL_NAME (exp))
172 && !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6))
173 {
174 const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));
175
176 if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))
177 objc_cls_meth_section ();
178 else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))
179 objc_inst_meth_section ();
180 else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20))
181 objc_cat_cls_meth_section ();
182 else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23))
183 objc_cat_inst_meth_section ();
184 else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))
185 objc_class_vars_section ();
186 else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))
187 objc_instance_vars_section ();
188 else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))
189 objc_cat_cls_meth_section ();
190 else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))
191 objc_class_names_section ();
192 else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))
193 objc_meth_var_names_section ();
194 else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))
195 objc_meth_var_types_section ();
196 else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))
197 objc_cls_refs_section ();
198 else if (!strncmp (name, "_OBJC_CLASS_", 12))
199 objc_class_section ();
200 else if (!strncmp (name, "_OBJC_METACLASS_", 16))
201 objc_meta_class_section ();
202 else if (!strncmp (name, "_OBJC_CATEGORY_", 15))
203 objc_category_section ();
204 else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))
205 objc_selector_refs_section ();
206 else if (!strncmp (name, "_OBJC_SYMBOLS", 13))
207 objc_symbols_section ();
208 else if (!strncmp (name, "_OBJC_MODULES", 13))
209 objc_module_info_section ();
210 else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32))
211 objc_cat_inst_meth_section ();
212 else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29))
213 objc_cat_cls_meth_section ();
214 else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))
215 objc_cat_cls_meth_section ();
216 else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))
217 objc_protocol_section ();
218 else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))
219 && !TREE_SIDE_EFFECTS (exp))
220 readonly_data_section ();
221 else
222 data_section ();
223 }
224 else if (TREE_CODE (exp) == VAR_DECL)
225 {
226 if ((flag_pic && reloc)
227 || !TREE_READONLY (exp) || TREE_SIDE_EFFECTS (exp)
228 || !DECL_INITIAL (exp)
229 || (DECL_INITIAL (exp) != error_mark_node
230 && !TREE_CONSTANT (DECL_INITIAL (exp))))
231 data_section ();
232 else
233 readonly_data_section ();
234 }
235 else
236 readonly_data_section ();
237 }