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.
5 This file is part of GNU CC.
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)
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.
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. */
31 /* Make everything that used to go in the text section really go there. */
33 int flag_no_mach_text_sections
= 0;
35 #define OPT_STRCMP(opt) (!strncmp (opt, p, sizeof (opt)-1))
37 /* 1 if handle_pragma has been called yet. */
39 static int pragma_initialized
;
41 /* Initial setting of `optimize'. */
43 static int initial_optimize_flag
;
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. */
51 handle_pragma (p_getc
, p_ungetc
, pname
)
52 int (* p_getc
) PARAMS ((void)) ATTRIBUTE_UNUSED
;
53 void (* p_ungetc
) PARAMS ((int)) ATTRIBUTE_UNUSED
;
58 /* Record initial setting of optimize flag, so we can restore it. */
59 if (!pragma_initialized
)
61 pragma_initialized
= 1;
62 initial_optimize_flag
= optimize
;
65 if (strcmp (pname
, "CC_OPT_ON") == 0)
68 warning ("optimization turned on");
71 else if (strcmp (pname
, "CC_OPT_OFF") == 0)
74 warning ("optimization turned off");
77 else if (strcmp (pname
, "CC_OPT_RESTORE") == 0)
79 extern int initial_optimize_flag
;
81 if (optimize
!= initial_optimize_flag
)
82 optimize
= initial_optimize_flag
;
83 warning ("optimization level restored");
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;
97 nextstep_asm_out_constructor (symbol
, priority
)
99 int priority ATTRIBUTE_UNUSED
;
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");
108 nextstep_asm_out_destructor (symbol
, priority
)
110 int priority ATTRIBUTE_UNUSED
;
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");
119 nextstep_select_section (exp
, reloc
, align
)
122 unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED
;
124 if (TREE_CODE (exp
) == STRING_CST
)
126 if (flag_writable_strings
)
128 else if (TREE_STRING_LENGTH (exp
)
129 != strlen (TREE_STRING_POINTER (exp
)) + 1)
130 readonly_data_section ();
134 else if (TREE_CODE (exp
) == INTEGER_CST
135 || TREE_CODE (exp
) == REAL_CST
)
137 tree size
= TYPE_SIZE (TREE_TYPE (exp
));
138 HOST_WIDE_INT size_int
;
140 if (TREE_CODE (size
) == INTEGER_CST
)
141 size_int
= tree_low_cst (size
, 1);
147 else if (size_int
== 8)
150 readonly_data_section ();
152 else if (TREE_CODE (exp
) == CONSTRUCTOR
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
))))
159 if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp
))),
161 objc_string_object_section ();
162 else if ((TREE_READONLY (exp
) || TREE_CONSTANT (exp
))
163 && !TREE_SIDE_EFFECTS (exp
))
164 readonly_data_section ();
168 else if (TREE_CODE (exp
) == VAR_DECL
170 && TREE_CODE (DECL_NAME (exp
)) == IDENTIFIER_NODE
171 && IDENTIFIER_POINTER (DECL_NAME (exp
))
172 && !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp
)), "_OBJC_", 6))
174 const char *name
= IDENTIFIER_POINTER (DECL_NAME (exp
));
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 ();
224 else if (TREE_CODE (exp
) == VAR_DECL
)
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
))))
233 readonly_data_section ();
236 readonly_data_section ();