]>
Commit | Line | Data |
---|---|---|
4291d9c8 | 1 | /* Top level of GNU C compiler |
87e11268 | 2 | Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc. |
4291d9c8 RS |
3 | |
4 | This file is part of GNU CC. | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
e9fa0c7c RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
4291d9c8 | 20 | |
4291d9c8 RS |
21 | /* This is the top level of cc1/c++. |
22 | It parses command args, opens files, invokes the various passes | |
23 | in the proper order, and counts the time used by each. | |
24 | Error messages and low-level interface to malloc also handled here. */ | |
25 | ||
26 | #include "config.h" | |
670ee920 KG |
27 | #undef FLOAT /* This is for hpux. They should change hpux. */ |
28 | #undef FFS /* Some systems define this in param.h. */ | |
29 | #include "system.h" | |
4291d9c8 RS |
30 | #include <signal.h> |
31 | #include <setjmp.h> | |
956d6950 JL |
32 | |
33 | #ifdef HAVE_SYS_RESOURCE_H | |
34 | # include <sys/resource.h> | |
35 | #endif | |
36 | ||
37 | #ifdef HAVE_SYS_TIMES_H | |
38 | # include <sys/times.h> | |
eb910b5a | 39 | #endif |
4291d9c8 RS |
40 | |
41 | #include "input.h" | |
42 | #include "tree.h" | |
4291d9c8 RS |
43 | #include "rtl.h" |
44 | #include "flags.h" | |
45 | #include "insn-attr.h" | |
e5e809f4 JL |
46 | #include "insn-codes.h" |
47 | #include "insn-config.h" | |
48 | #include "recog.h" | |
d0d4af87 | 49 | #include "defaults.h" |
e14417fa | 50 | #include "output.h" |
3d195391 | 51 | #include "except.h" |
a0c8e1b2 | 52 | #include "toplev.h" |
114791ea | 53 | #include "expr.h" |
b1eeb243 | 54 | #include "basic-block.h" |
ab87f8c8 | 55 | #include "intl.h" |
f246a305 | 56 | |
76ead72b RL |
57 | #ifdef DWARF_DEBUGGING_INFO |
58 | #include "dwarfout.h" | |
59 | #endif | |
60 | ||
61 | #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO) | |
62 | #include "dwarf2out.h" | |
63 | #endif | |
64 | ||
4f70758f | 65 | #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) |
76ead72b RL |
66 | #include "dbxout.h" |
67 | #endif | |
68 | ||
69 | #ifdef SDB_DEBUGGING_INFO | |
70 | #include "sdbout.h" | |
71 | #endif | |
72 | ||
f246a305 RS |
73 | #ifdef XCOFF_DEBUGGING_INFO |
74 | #include "xcoffout.h" | |
75 | #endif | |
4291d9c8 RS |
76 | \f |
77 | #ifdef VMS | |
78 | /* The extra parameters substantially improve the I/O performance. */ | |
79 | static FILE * | |
37c9f674 | 80 | vms_fopen (fname, type) |
4291d9c8 RS |
81 | char * fname; |
82 | char * type; | |
83 | { | |
37c9f674 RK |
84 | /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two |
85 | fixed arguments, which matches ANSI's specification but not VAXCRTL's | |
86 | pre-ANSI implementation. This hack circumvents the mismatch problem. */ | |
87 | FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen; | |
88 | ||
89 | if (*type == 'w') | |
90 | return (*vmslib_fopen) (fname, type, "mbc=32", | |
91 | "deq=64", "fop=tef", "shr=nil"); | |
92 | else | |
93 | return (*vmslib_fopen) (fname, type, "mbc=32"); | |
4291d9c8 | 94 | } |
37c9f674 RK |
95 | #define fopen vms_fopen |
96 | #endif /* VMS */ | |
4291d9c8 RS |
97 | |
98 | #ifndef DEFAULT_GDB_EXTENSIONS | |
99 | #define DEFAULT_GDB_EXTENSIONS 1 | |
100 | #endif | |
101 | ||
30657ee3 RK |
102 | /* If more than one debugging type is supported, you must define |
103 | PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way. | |
104 | ||
105 | This is one long line cause VAXC can't handle a \-newline. */ | |
9a666dda | 106 | #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO)) |
30657ee3 RK |
107 | #ifndef PREFERRED_DEBUGGING_TYPE |
108 | You Lose! You must define PREFERRED_DEBUGGING_TYPE! | |
109 | #endif /* no PREFERRED_DEBUGGING_TYPE */ | |
110 | #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE | |
111 | so the following code needn't care. */ | |
112 | #ifdef DBX_DEBUGGING_INFO | |
113 | #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG | |
114 | #endif | |
115 | #ifdef SDB_DEBUGGING_INFO | |
116 | #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG | |
117 | #endif | |
118 | #ifdef DWARF_DEBUGGING_INFO | |
119 | #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG | |
120 | #endif | |
9a666dda JM |
121 | #ifdef DWARF2_DEBUGGING_INFO |
122 | #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG | |
123 | #endif | |
30657ee3 RK |
124 | #ifdef XCOFF_DEBUGGING_INFO |
125 | #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG | |
126 | #endif | |
127 | #endif /* More than one debugger format enabled. */ | |
128 | ||
129 | /* If still not defined, must have been because no debugging formats | |
130 | are supported. */ | |
131 | #ifndef PREFERRED_DEBUGGING_TYPE | |
132 | #define PREFERRED_DEBUGGING_TYPE NO_DEBUG | |
133 | #endif | |
134 | ||
4291d9c8 RS |
135 | extern int rtx_equal_function_value_matters; |
136 | ||
72c8bb7f | 137 | #if ! (defined (VMS) || defined (OS2)) |
4291d9c8 | 138 | extern char **environ; |
4d7e336b | 139 | #endif |
4291d9c8 RS |
140 | extern char *version_string, *language_string; |
141 | ||
b0316e35 RS |
142 | /* Carry information from ASM_DECLARE_OBJECT_NAME |
143 | to ASM_FINISH_DECLARE_OBJECT. */ | |
144 | ||
145 | extern int size_directive_output; | |
5e10b3cc | 146 | extern tree last_assemble_variable_decl; |
b0316e35 | 147 | |
5c60e5c0 | 148 | extern char *init_parse PVPROTO((char *)); |
e56e519d | 149 | extern void finish_parse (); |
4291d9c8 RS |
150 | extern void init_decl_processing (); |
151 | extern void init_obstacks (); | |
152 | extern void init_tree_codes (); | |
153 | extern void init_rtl (); | |
34d0205f | 154 | extern void init_regs (); |
4291d9c8 RS |
155 | extern void init_optabs (); |
156 | extern void init_stmt (); | |
157 | extern void init_reg_sets (); | |
158 | extern void dump_flow_info (); | |
159 | extern void dump_sched_info (); | |
160 | extern void dump_local_alloc (); | |
9ddca353 | 161 | extern void regset_release_memory (); |
4291d9c8 | 162 | |
032713aa NC |
163 | extern void print_rtl (); |
164 | extern void print_rtl_with_bb (); | |
165 | ||
4291d9c8 | 166 | void rest_of_decl_compilation (); |
ab87f8c8 JL |
167 | void error_with_file_and_line PVPROTO((const char *file, |
168 | int line, const char *s, ...)); | |
169 | void error_with_decl PVPROTO((tree decl, const char *s, ...)); | |
170 | void error_for_asm PVPROTO((rtx insn, const char *s, ...)); | |
171 | void notice PVPROTO((const char *s, ...)); | |
172 | void error PVPROTO((const char *s, ...)); | |
173 | void fatal PVPROTO((const char *s, ...)); | |
174 | void warning_with_file_and_line PVPROTO((const char *file, | |
175 | int line, const char *s, ...)); | |
176 | void warning_with_decl PVPROTO((tree decl, const char *s, ...)); | |
177 | void warning PVPROTO((const char *s, ...)); | |
178 | void pedwarn PVPROTO((const char *s, ...)); | |
179 | void pedwarn_with_decl PVPROTO((tree decl, const char *s, ...)); | |
180 | void pedwarn_with_file_and_line PVPROTO((const char *file, | |
181 | int line, const char *s, ...)); | |
182 | void sorry PVPROTO((const char *s, ...)); | |
87e11268 | 183 | static void set_target_switch PROTO((const char *)); |
0e05e8ea | 184 | static char *decl_name PROTO((tree, int)); |
87e11268 | 185 | static void vmessage PROTO((const char *, const char *, va_list)); |
ab87f8c8 JL |
186 | static void v_message_with_file_and_line PROTO((const char *, int, int, |
187 | const char *, va_list)); | |
188 | static void v_message_with_decl PROTO((tree, int, const char *, va_list)); | |
0e05e8ea | 189 | static void file_and_line_for_asm PROTO((rtx, char **, int *)); |
87e11268 KG |
190 | static void v_error_with_file_and_line PROTO((const char *, int, |
191 | const char *, va_list)); | |
192 | static void v_error_with_decl PROTO((tree, const char *, va_list)); | |
193 | static void v_error_for_asm PROTO((rtx, const char *, va_list)); | |
194 | static void verror PROTO((const char *, va_list)); | |
195 | static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN; | |
196 | static void v_warning_with_file_and_line PROTO ((const char *, int, | |
197 | const char *, va_list)); | |
198 | static void v_warning_with_decl PROTO((tree, const char *, va_list)); | |
199 | static void v_warning_for_asm PROTO((rtx, const char *, va_list)); | |
200 | static void vwarning PROTO((const char *, va_list)); | |
201 | static void vpedwarn PROTO((const char *, va_list)); | |
202 | static void v_pedwarn_with_decl PROTO((tree, const char *, va_list)); | |
203 | static void v_pedwarn_with_file_and_line PROTO((const char *, int, | |
204 | const char *, va_list)); | |
205 | static void vsorry PROTO((const char *, va_list)); | |
bf94d1ec KG |
206 | static void float_signal PROTO((int)) ATTRIBUTE_NORETURN; |
207 | static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN; | |
444bf316 | 208 | #ifdef ASM_IDENTIFY_LANGUAGE |
47c3ed98 KG |
209 | /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */ |
210 | static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED; | |
444bf316 | 211 | #endif |
87e11268 | 212 | static void open_dump_file PROTO((const char *, const char *)); |
0e05e8ea | 213 | static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx)); |
87e11268 KG |
214 | static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx)); |
215 | static void clean_dump_file PROTO((const char *)); | |
0e05e8ea | 216 | static void compile_file PROTO((char *)); |
b8468bc7 | 217 | static void display_help PROTO ((void)); |
4291d9c8 | 218 | |
87e11268 KG |
219 | static void print_version PROTO((FILE *, const char *)); |
220 | static int print_single_switch PROTO((FILE *, int, int, const char *, | |
221 | const char *, const char *, | |
222 | const char *, const char *)); | |
223 | static void print_switch_values PROTO((FILE *, int, int, const char *, | |
224 | const char *, const char *)); | |
735a0e33 UD |
225 | |
226 | void print_rtl_graph_with_bb PROTO ((const char *, const char *, rtx)); | |
227 | void clean_graph_dump_file PROTO ((const char *, const char *)); | |
228 | void finish_graph_dump_file PROTO ((const char *, const char *)); | |
3d5cdd42 DE |
229 | /* Length of line when printing switch values. */ |
230 | #define MAX_LINE 75 | |
231 | ||
4291d9c8 RS |
232 | /* Name of program invoked, sans directories. */ |
233 | ||
234 | char *progname; | |
235 | ||
236 | /* Copy of arguments to main. */ | |
237 | int save_argc; | |
238 | char **save_argv; | |
239 | \f | |
240 | /* Name of current original source file (what was input to cpp). | |
241 | This comes from each #-command in the actual input. */ | |
242 | ||
243 | char *input_filename; | |
244 | ||
245 | /* Name of top-level original source file (what was input to cpp). | |
246 | This comes from the #-command at the beginning of the actual input. | |
247 | If there isn't any there, then this is the cc1 input file name. */ | |
248 | ||
249 | char *main_input_filename; | |
250 | ||
4291d9c8 RS |
251 | /* Current line number in real source file. */ |
252 | ||
253 | int lineno; | |
254 | ||
f1db3576 JL |
255 | /* Nonzero if it is unsafe to create any new pseudo registers. */ |
256 | int no_new_pseudos; | |
257 | ||
4291d9c8 RS |
258 | /* Stack of currently pending input files. */ |
259 | ||
260 | struct file_stack *input_file_stack; | |
261 | ||
262 | /* Incremented on each change to input_file_stack. */ | |
263 | int input_file_stack_tick; | |
264 | ||
265 | /* FUNCTION_DECL for function now being parsed or compiled. */ | |
266 | ||
267 | extern tree current_function_decl; | |
268 | ||
269 | /* Name to use as base of names for dump output files. */ | |
270 | ||
87e11268 | 271 | const char *dump_base_name; |
4291d9c8 RS |
272 | |
273 | /* Bit flags that specify the machine subtype we are compiling for. | |
274 | Bits are tested using macros TARGET_... defined in the tm.h file | |
275 | and set by `-m...' switches. Must be defined in rtlanal.c. */ | |
276 | ||
277 | extern int target_flags; | |
278 | ||
279 | /* Flags saying which kinds of debugging dump have been requested. */ | |
280 | ||
281 | int rtl_dump = 0; | |
282 | int rtl_dump_and_exit = 0; | |
283 | int jump_opt_dump = 0; | |
e9a25f70 | 284 | int addressof_dump = 0; |
4291d9c8 | 285 | int cse_dump = 0; |
7506f491 | 286 | int gcse_dump = 0; |
4291d9c8 RS |
287 | int loop_dump = 0; |
288 | int cse2_dump = 0; | |
0d332add | 289 | int branch_prob_dump = 0; |
4291d9c8 RS |
290 | int flow_dump = 0; |
291 | int combine_dump = 0; | |
8c660648 | 292 | int regmove_dump = 0; |
4291d9c8 RS |
293 | int sched_dump = 0; |
294 | int local_reg_dump = 0; | |
295 | int global_reg_dump = 0; | |
e881bb1b | 296 | int flow2_dump = 0; |
4291d9c8 RS |
297 | int sched2_dump = 0; |
298 | int jump2_opt_dump = 0; | |
bd334356 | 299 | #ifdef DELAY_SLOTS |
4291d9c8 | 300 | int dbr_sched_dump = 0; |
bd334356 | 301 | #endif |
4291d9c8 | 302 | int flag_print_asm_name = 0; |
032713aa | 303 | #ifdef STACK_REGS |
4291d9c8 | 304 | int stack_reg_dump = 0; |
032713aa NC |
305 | #endif |
306 | #ifdef MACHINE_DEPENDENT_REORG | |
307 | int mach_dep_reorg_dump = 0; | |
308 | #endif | |
735a0e33 | 309 | enum graph_dump_types graph_dump_format; |
4291d9c8 RS |
310 | |
311 | /* Name for output file of assembly code, specified with -o. */ | |
312 | ||
313 | char *asm_file_name; | |
314 | ||
315 | /* Value of the -G xx switch, and whether it was passed or not. */ | |
316 | int g_switch_value; | |
317 | int g_switch_set; | |
318 | ||
319 | /* Type(s) of debugging information we are producing (if any). | |
320 | See flags.h for the definitions of the different possible | |
321 | types of debugging information. */ | |
322 | enum debug_info_type write_symbols = NO_DEBUG; | |
323 | ||
324 | /* Level of debugging information we are producing. See flags.h | |
325 | for the definitions of the different possible levels. */ | |
326 | enum debug_info_level debug_info_level = DINFO_LEVEL_NONE; | |
327 | ||
a53d0bcc RS |
328 | /* Nonzero means use GNU-only extensions in the generated symbolic |
329 | debugging information. */ | |
330 | /* Currently, this only has an effect when write_symbols is set to | |
331 | DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */ | |
332 | int use_gnu_debug_info_extensions = 0; | |
4291d9c8 RS |
333 | |
334 | /* Nonzero means do optimizations. -O. | |
335 | Particular numeric values stand for particular amounts of optimization; | |
336 | thus, -O2 stores 2 here. However, the optimizations beyond the basic | |
337 | ones are not controlled directly by this variable. Instead, they are | |
338 | controlled by individual `flag_...' variables that are defaulted | |
339 | based on this variable. */ | |
340 | ||
341 | int optimize = 0; | |
342 | ||
c6aded7c AG |
343 | /* Nonzero means optimize for size. -Os. |
344 | The only valid values are zero and non-zero. When optimize_size is | |
345 | non-zero, optimize defaults to 2, but certain individual code | |
346 | bloating optimizations are disabled. */ | |
347 | ||
348 | int optimize_size = 0; | |
349 | ||
4291d9c8 RS |
350 | /* Number of error messages and warning messages so far. */ |
351 | ||
352 | int errorcount = 0; | |
353 | int warningcount = 0; | |
354 | int sorrycount = 0; | |
355 | ||
a1d7ffe3 JM |
356 | /* Pointer to function to compute the name to use to print a declaration. |
357 | DECL is the declaration in question. | |
358 | VERBOSITY determines what information will be printed: | |
359 | 0: DECL_NAME, demangled as necessary. | |
360 | 1: and scope information. | |
361 | 2: and any other information that might be interesting, such as function | |
362 | parameter types in C++. */ | |
4291d9c8 | 363 | |
114791ea | 364 | char *(*decl_printable_name) PROTO ((tree, int)); |
4291d9c8 RS |
365 | |
366 | /* Pointer to function to compute rtl for a language-specific tree code. */ | |
367 | ||
114791ea KG |
368 | typedef rtx (*lang_expand_expr_t) |
369 | PROTO ((union tree_node *, rtx, enum machine_mode, | |
370 | enum expand_modifier modifier)); | |
371 | ||
372 | lang_expand_expr_t lang_expand_expr = 0; | |
4291d9c8 | 373 | |
2b599527 RS |
374 | /* Pointer to function to finish handling an incomplete decl at the |
375 | end of compilation. */ | |
376 | ||
114791ea | 377 | void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0; |
2b599527 | 378 | |
4291d9c8 RS |
379 | /* Nonzero if generating code to do profiling. */ |
380 | ||
381 | int profile_flag = 0; | |
382 | ||
383 | /* Nonzero if generating code to do profiling on a line-by-line basis. */ | |
384 | ||
385 | int profile_block_flag; | |
386 | ||
0d332add DE |
387 | /* Nonzero if generating code to profile program flow graph arcs. */ |
388 | ||
389 | int profile_arc_flag = 0; | |
390 | ||
391 | /* Nonzero if generating info for gcov to calculate line test coverage. */ | |
392 | ||
393 | int flag_test_coverage = 0; | |
394 | ||
395 | /* Nonzero indicates that branch taken probabilities should be calculated. */ | |
396 | ||
397 | int flag_branch_probabilities = 0; | |
398 | ||
4291d9c8 RS |
399 | /* Nonzero for -pedantic switch: warn about anything |
400 | that standard spec forbids. */ | |
401 | ||
402 | int pedantic = 0; | |
403 | ||
404 | /* Temporarily suppress certain warnings. | |
405 | This is set while reading code from a system header file. */ | |
406 | ||
407 | int in_system_header = 0; | |
408 | ||
409 | /* Nonzero means do stupid register allocation. | |
410 | Currently, this is 1 if `optimize' is 0. */ | |
411 | ||
412 | int obey_regdecls = 0; | |
413 | ||
414 | /* Don't print functions as they are compiled and don't print | |
415 | times taken by the various passes. -quiet. */ | |
416 | ||
417 | int quiet_flag = 0; | |
418 | \f | |
419 | /* -f flags. */ | |
420 | ||
421 | /* Nonzero means `char' should be signed. */ | |
422 | ||
423 | int flag_signed_char; | |
424 | ||
425 | /* Nonzero means give an enum type only as many bytes as it needs. */ | |
426 | ||
427 | int flag_short_enums; | |
428 | ||
429 | /* Nonzero for -fcaller-saves: allocate values in regs that need to | |
430 | be saved across function calls, if that produces overall better code. | |
431 | Optional now, so people can test it. */ | |
432 | ||
433 | #ifdef DEFAULT_CALLER_SAVES | |
434 | int flag_caller_saves = 1; | |
435 | #else | |
436 | int flag_caller_saves = 0; | |
437 | #endif | |
438 | ||
958ec8ca JW |
439 | /* Nonzero if structures and unions should be returned in memory. |
440 | ||
441 | This should only be defined if compatibility with another compiler or | |
442 | with an ABI is needed, because it results in slower code. */ | |
443 | ||
444 | #ifndef DEFAULT_PCC_STRUCT_RETURN | |
445 | #define DEFAULT_PCC_STRUCT_RETURN 1 | |
446 | #endif | |
447 | ||
4291d9c8 RS |
448 | /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ |
449 | ||
958ec8ca | 450 | int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN; |
4291d9c8 RS |
451 | |
452 | /* Nonzero for -fforce-mem: load memory value into a register | |
453 | before arithmetic on it. This makes better cse but slower compilation. */ | |
454 | ||
455 | int flag_force_mem = 0; | |
456 | ||
457 | /* Nonzero for -fforce-addr: load memory address into a register before | |
458 | reference to memory. This makes better cse but slower compilation. */ | |
459 | ||
460 | int flag_force_addr = 0; | |
461 | ||
462 | /* Nonzero for -fdefer-pop: don't pop args after each function call; | |
463 | instead save them up to pop many calls' args with one insns. */ | |
464 | ||
6731a3e3 | 465 | int flag_defer_pop = 0; |
4291d9c8 RS |
466 | |
467 | /* Nonzero for -ffloat-store: don't allocate floats and doubles | |
468 | in extended-precision registers. */ | |
469 | ||
470 | int flag_float_store = 0; | |
471 | ||
472 | /* Nonzero for -fcse-follow-jumps: | |
473 | have cse follow jumps to do a more extensive job. */ | |
474 | ||
475 | int flag_cse_follow_jumps; | |
476 | ||
8b3686ed RK |
477 | /* Nonzero for -fcse-skip-blocks: |
478 | have cse follow a branch around a block. */ | |
479 | int flag_cse_skip_blocks; | |
480 | ||
4291d9c8 RS |
481 | /* Nonzero for -fexpensive-optimizations: |
482 | perform miscellaneous relatively-expensive optimizations. */ | |
483 | int flag_expensive_optimizations; | |
484 | ||
485 | /* Nonzero for -fthread-jumps: | |
486 | have jump optimize output of loop. */ | |
487 | ||
488 | int flag_thread_jumps; | |
489 | ||
490 | /* Nonzero enables strength-reduction in loop.c. */ | |
491 | ||
492 | int flag_strength_reduce = 0; | |
493 | ||
494 | /* Nonzero enables loop unrolling in unroll.c. Only loops for which the | |
495 | number of iterations can be calculated at compile-time (UNROLL_COMPLETELY, | |
496 | UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are | |
497 | unrolled. */ | |
498 | ||
499 | int flag_unroll_loops; | |
500 | ||
501 | /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled. | |
502 | This is generally not a win. */ | |
503 | ||
504 | int flag_unroll_all_loops; | |
505 | ||
e5eb27e5 JL |
506 | /* Nonzero forces all invariant computations in loops to be moved |
507 | outside the loop. */ | |
508 | ||
509 | int flag_move_all_movables = 0; | |
510 | ||
511 | /* Nonzero forces all general induction variables in loops to be | |
512 | strength reduced. */ | |
513 | ||
514 | int flag_reduce_all_givs = 0; | |
515 | ||
9ec36da5 JL |
516 | /* Nonzero to perform full register move optimization passes. This is the |
517 | default for -O2. */ | |
518 | ||
519 | int flag_regmove = 0; | |
520 | ||
4291d9c8 RS |
521 | /* Nonzero for -fwritable-strings: |
522 | store string constants in data segment and don't uniquize them. */ | |
523 | ||
524 | int flag_writable_strings = 0; | |
525 | ||
526 | /* Nonzero means don't put addresses of constant functions in registers. | |
527 | Used for compiling the Unix kernel, where strange substitutions are | |
528 | done on the assembly output. */ | |
529 | ||
530 | int flag_no_function_cse = 0; | |
531 | ||
532 | /* Nonzero for -fomit-frame-pointer: | |
533 | don't make a frame pointer in simple functions that don't require one. */ | |
534 | ||
535 | int flag_omit_frame_pointer = 0; | |
536 | ||
cf440348 JL |
537 | /* Nonzero means place each function into its own section on those platforms |
538 | which support arbitrary section names and unlimited numbers of sections. */ | |
539 | ||
540 | int flag_function_sections = 0; | |
541 | ||
fd868572 CM |
542 | /* ... and similar for data. */ |
543 | ||
544 | int flag_data_sections = 0; | |
545 | ||
4291d9c8 RS |
546 | /* Nonzero to inhibit use of define_optimization peephole opts. */ |
547 | ||
548 | int flag_no_peephole = 0; | |
549 | ||
43855b28 JL |
550 | /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math |
551 | operations in the interest of optimization. For example it allows | |
552 | GCC to assume arguments to sqrt are nonnegative numbers, allowing | |
0f41302f | 553 | faster code for sqrt to be generated. */ |
43855b28 JL |
554 | |
555 | int flag_fast_math = 0; | |
556 | ||
4291d9c8 RS |
557 | /* Nonzero means all references through pointers are volatile. */ |
558 | ||
559 | int flag_volatile; | |
c6e75897 | 560 | |
ab87f8c8 | 561 | /* Nonzero means treat all global and extern variables as volatile. */ |
c6e75897 | 562 | |
38d4d0c2 | 563 | int flag_volatile_global; |
4291d9c8 | 564 | |
ab87f8c8 JL |
565 | /* Nonzero means treat all static variables as volatile. */ |
566 | ||
567 | int flag_volatile_static; | |
568 | ||
4291d9c8 RS |
569 | /* Nonzero means just do syntax checking; don't output anything. */ |
570 | ||
571 | int flag_syntax_only = 0; | |
572 | ||
7506f491 DE |
573 | /* Nonzero means perform global cse. */ |
574 | ||
575 | static int flag_gcse; | |
576 | ||
4291d9c8 RS |
577 | /* Nonzero means to rerun cse after loop optimization. This increases |
578 | compilation time about 20% and picks up a few more common expressions. */ | |
579 | ||
580 | static int flag_rerun_cse_after_loop; | |
581 | ||
6d6d0fa0 JL |
582 | /* Nonzero means to run loop optimizations twice. */ |
583 | ||
64fde701 | 584 | int flag_rerun_loop_opt; |
6d6d0fa0 | 585 | |
4291d9c8 RS |
586 | /* Nonzero for -finline-functions: ok to inline functions that look like |
587 | good inline candidates. */ | |
588 | ||
589 | int flag_inline_functions; | |
590 | ||
591 | /* Nonzero for -fkeep-inline-functions: even if we make a function | |
ac2a9454 | 592 | go inline everywhere, keep its definition around for debugging |
4291d9c8 RS |
593 | purposes. */ |
594 | ||
595 | int flag_keep_inline_functions; | |
596 | ||
fadb3bc9 | 597 | /* Nonzero means that functions will not be inlined. */ |
4291d9c8 RS |
598 | |
599 | int flag_no_inline; | |
600 | ||
fbe912dd BK |
601 | /* Nonzero means that we should emit static const variables |
602 | regardless of whether or not optimization is turned on. */ | |
603 | ||
604 | int flag_keep_static_consts = 1; | |
605 | ||
4291d9c8 RS |
606 | /* Nonzero means we should be saving declaration info into a .X file. */ |
607 | ||
608 | int flag_gen_aux_info = 0; | |
609 | ||
f246a305 RS |
610 | /* Specified name of aux-info file. */ |
611 | ||
612 | static char *aux_info_file_name; | |
613 | ||
4291d9c8 RS |
614 | /* Nonzero means make the text shared if supported. */ |
615 | ||
616 | int flag_shared_data; | |
617 | ||
618 | /* Nonzero means schedule into delayed branch slots if supported. */ | |
619 | ||
620 | int flag_delayed_branch; | |
621 | ||
622 | /* Nonzero if we are compiling pure (sharable) code. | |
623 | Value is 1 if we are doing reasonable (i.e. simple | |
624 | offset into offset table) pic. Value is 2 if we can | |
625 | only perform register offsets. */ | |
626 | ||
627 | int flag_pic; | |
628 | ||
3d195391 MS |
629 | /* Nonzero means generate extra code for exception handling and enable |
630 | exception handling. */ | |
631 | ||
b53beeb2 | 632 | int flag_exceptions; |
3d195391 | 633 | |
a1622f83 AM |
634 | /* Nonzero means use the new model for exception handling. Replaces |
635 | -DNEW_EH_MODEL as a compile option. */ | |
636 | ||
5dd57225 | 637 | int flag_new_exceptions = 0; |
a1622f83 | 638 | |
2786cbad | 639 | /* Nonzero means don't place uninitialized global data in common storage |
3d195391 | 640 | by default. */ |
4291d9c8 RS |
641 | |
642 | int flag_no_common; | |
643 | ||
644 | /* Nonzero means pretend it is OK to examine bits of target floats, | |
645 | even if that isn't true. The resulting code will have incorrect constants, | |
646 | but the same series of instructions that the native compiler would make. */ | |
647 | ||
648 | int flag_pretend_float; | |
649 | ||
650 | /* Nonzero means change certain warnings into errors. | |
651 | Usually these are warnings about failure to conform to some standard. */ | |
652 | ||
653 | int flag_pedantic_errors = 0; | |
654 | ||
655 | /* flag_schedule_insns means schedule insns within basic blocks (before | |
656 | local_alloc). | |
657 | flag_schedule_insns_after_reload means schedule insns after | |
658 | global_alloc. */ | |
659 | ||
660 | int flag_schedule_insns = 0; | |
661 | int flag_schedule_insns_after_reload = 0; | |
662 | ||
8c660648 JL |
663 | #ifdef HAIFA |
664 | /* The following flags have effect only for scheduling before register | |
665 | allocation: | |
666 | ||
667 | flag_schedule_interblock means schedule insns accross basic blocks. | |
668 | flag_schedule_speculative means allow speculative motion of non-load insns. | |
669 | flag_schedule_speculative_load means allow speculative motion of some | |
670 | load insns. | |
671 | flag_schedule_speculative_load_dangerous allows speculative motion of more | |
8e7336f8 | 672 | load insns. */ |
8c660648 JL |
673 | |
674 | int flag_schedule_interblock = 1; | |
675 | int flag_schedule_speculative = 1; | |
676 | int flag_schedule_speculative_load = 0; | |
677 | int flag_schedule_speculative_load_dangerous = 0; | |
f1da1729 | 678 | #endif /* HAIFA */ |
8c660648 JL |
679 | |
680 | /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple | |
681 | by a cheaper branch, on a count register. */ | |
682 | int flag_branch_on_count_reg; | |
8c660648 | 683 | |
4291d9c8 RS |
684 | /* -finhibit-size-directive inhibits output of .size for ELF. |
685 | This is used only for compiling crtstuff.c, | |
686 | and it may be extended to other effects | |
687 | needed for crtstuff.c on other systems. */ | |
688 | int flag_inhibit_size_directive = 0; | |
689 | ||
9a631e8e RS |
690 | /* -fverbose-asm causes extra commentary information to be produced in |
691 | the generated assembly code (to make it more readable). This option | |
692 | is generally only of use to those who actually need to read the | |
3d5cdd42 | 693 | generated assembly code (perhaps while debugging the compiler itself). |
c85f7c16 | 694 | -fno-verbose-asm, the default, causes the extra information |
3d5cdd42 DE |
695 | to be omitted and is useful when comparing two assembler files. */ |
696 | ||
c85f7c16 | 697 | int flag_verbose_asm = 0; |
9a631e8e | 698 | |
3d5cdd42 DE |
699 | /* -dA causes debug commentary information to be produced in |
700 | the generated assembly code (to make it more readable). This option | |
701 | is generally only of use to those who actually need to read the | |
702 | generated assembly code (perhaps while debugging the compiler itself). | |
703 | Currently, this switch is only used by dwarfout.c; however, it is intended | |
704 | to be a catchall for printing debug information in the assembler file. */ | |
705 | ||
706 | int flag_debug_asm = 0; | |
9a631e8e | 707 | |
4291d9c8 | 708 | /* -fgnu-linker specifies use of the GNU linker for initializations. |
d68c507d RS |
709 | (Or, more generally, a linker that handles initializations.) |
710 | -fno-gnu-linker says that collect2 will be used. */ | |
711 | #ifdef USE_COLLECT2 | |
712 | int flag_gnu_linker = 0; | |
713 | #else | |
4291d9c8 | 714 | int flag_gnu_linker = 1; |
d68c507d | 715 | #endif |
4291d9c8 | 716 | |
566cdc73 MM |
717 | /* Tag all structures with __attribute__(packed) */ |
718 | int flag_pack_struct = 0; | |
719 | ||
bd83d0ac RK |
720 | /* Emit code to check for stack overflow; also may cause large objects |
721 | to be allocated dynamically. */ | |
722 | int flag_stack_check; | |
723 | ||
f602c208 RK |
724 | /* -fcheck-memory-usage causes extra code to be generated in order to check |
725 | memory accesses. This is used by a detector of bad memory accesses such | |
726 | as Checker. */ | |
727 | int flag_check_memory_usage = 0; | |
728 | ||
729 | /* -fprefix-function-name causes function name to be prefixed. This | |
730 | can be used with -fcheck-memory-usage to isolate code compiled with | |
731 | -fcheck-memory-usage. */ | |
732 | int flag_prefix_function_name = 0; | |
733 | ||
9ae8ffe7 JL |
734 | /* 0 if pointer arguments may alias each other. True in C. |
735 | 1 if pointer arguments may not alias each other but may alias | |
736 | global variables. | |
737 | 2 if pointer arguments may not alias each other and may not | |
738 | alias global variables. True in Fortran. | |
739 | This defaults to 0 for C. */ | |
740 | int flag_argument_noalias = 0; | |
741 | ||
41472af8 MM |
742 | /* Nonzero if we should do (language-dependent) alias analysis. |
743 | Typically, this analysis will assume that expressions of certain | |
744 | types do not alias expressions of certain other types. Only used | |
745 | if alias analysis (in general) is enabled. */ | |
746 | int flag_strict_aliasing = 0; | |
747 | ||
07417085 KR |
748 | /* Instrument functions with calls at entry and exit, for profiling. */ |
749 | int flag_instrument_function_entry_exit = 0; | |
750 | ||
be163a70 ZW |
751 | /* Nonzero means ignore `#ident' directives. 0 means handle them. |
752 | On SVR4 targets, it also controls whether or not to emit a | |
753 | string identifying the compiler. */ | |
754 | ||
755 | int flag_no_ident = 0; | |
b8468bc7 NC |
756 | |
757 | /* Table of supported debugging formats. */ | |
758 | static struct | |
759 | { | |
87e11268 | 760 | const char * arg; |
b8468bc7 NC |
761 | /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a |
762 | constant expression, we use NO_DEBUG in its place. */ | |
763 | enum debug_info_type debug_type; | |
764 | int use_extensions_p; | |
87e11268 | 765 | const char * description; |
b8468bc7 NC |
766 | } *da, |
767 | debug_args[] = | |
768 | { | |
769 | { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS, | |
770 | "Generate default debug format output" }, | |
771 | { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" }, | |
772 | #ifdef DBX_DEBUGGING_INFO | |
773 | { "gstabs", DBX_DEBUG, 0, "Generate STABS format debug output" }, | |
774 | { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" }, | |
775 | #endif | |
776 | #ifdef DWARF_DEBUGGING_INFO | |
777 | { "gdwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"}, | |
778 | { "gdwarf+", DWARF_DEBUG, 1, | |
779 | "Generated extended DWARF-1 format debug output" }, | |
780 | #endif | |
781 | #ifdef DWARF2_DEBUGGING_INFO | |
782 | { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" }, | |
783 | #endif | |
784 | #ifdef XCOFF_DEBUGGING_INFO | |
785 | { "gxcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" }, | |
786 | { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" }, | |
787 | #endif | |
788 | #ifdef SDB_DEBUGGING_INFO | |
789 | { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" }, | |
790 | #endif | |
c84e2712 | 791 | { 0, 0, 0, 0 } |
b8468bc7 NC |
792 | }; |
793 | ||
794 | typedef struct | |
795 | { | |
87e11268 | 796 | const char * string; |
b8468bc7 NC |
797 | int * variable; |
798 | int on_value; | |
87e11268 | 799 | const char * description; |
b8468bc7 NC |
800 | } |
801 | lang_independent_options; | |
802 | ||
19283265 RH |
803 | /* Add or remove a leading underscore from user symbols. */ |
804 | int flag_leading_underscore = -1; | |
805 | ||
806 | /* The user symbol prefix after having resolved same. */ | |
87e11268 | 807 | const char *user_label_prefix; |
19283265 RH |
808 | |
809 | /* A default for same. */ | |
810 | #ifndef USER_LABEL_PREFIX | |
811 | #define USER_LABEL_PREFIX "" | |
812 | #endif | |
813 | ||
4291d9c8 RS |
814 | /* Table of language-independent -f options. |
815 | STRING is the option name. VARIABLE is the address of the variable. | |
816 | ON_VALUE is the value to store in VARIABLE | |
817 | if `-fSTRING' is seen as an option. | |
818 | (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ | |
819 | ||
b8468bc7 | 820 | lang_independent_options f_options[] = |
4291d9c8 | 821 | { |
b8468bc7 NC |
822 | {"float-store", &flag_float_store, 1, |
823 | "Do not store floats in registers" }, | |
824 | {"volatile", &flag_volatile, 1, | |
825 | "Consider all mem refs through pointers as volatile"}, | |
826 | {"volatile-global", &flag_volatile_global, 1, | |
827 | "Consider all mem refs to global data to be volatile" }, | |
ab87f8c8 JL |
828 | {"volatile-static", &flag_volatile_static, 1, |
829 | "Consider all mem refs to static data to be volatile" }, | |
b8468bc7 NC |
830 | {"defer-pop", &flag_defer_pop, 1, |
831 | "Defer popping functions args from stack until later" }, | |
832 | {"omit-frame-pointer", &flag_omit_frame_pointer, 1, | |
833 | "When possible do not generate stack frames"}, | |
834 | {"cse-follow-jumps", &flag_cse_follow_jumps, 1, | |
835 | "When running CSE, follow jumps to their targets" }, | |
836 | {"cse-skip-blocks", &flag_cse_skip_blocks, 1, | |
837 | "When running CSE, follow conditional jumps" }, | |
838 | {"expensive-optimizations", &flag_expensive_optimizations, 1, | |
839 | "Perform a number of minor, expensive optimisations" }, | |
840 | {"thread-jumps", &flag_thread_jumps, 1, | |
841 | "Perform jump threading optimisations"}, | |
842 | {"strength-reduce", &flag_strength_reduce, 1, | |
843 | "Perform strength reduction optimisations" }, | |
844 | {"unroll-loops", &flag_unroll_loops, 1, | |
62e7b719 | 845 | "Perform loop unrolling when iteration count is known" }, |
b8468bc7 | 846 | {"unroll-all-loops", &flag_unroll_all_loops, 1, |
f1da1729 | 847 | "Perform loop unrolling for all loops" }, |
b8468bc7 NC |
848 | {"move-all-movables", &flag_move_all_movables, 1, |
849 | "Force all loop invariant computations out of loops" }, | |
850 | {"reduce-all-givs", &flag_reduce_all_givs, 1, | |
851 | "Strength reduce all loop general induction variables" }, | |
852 | {"writable-strings", &flag_writable_strings, 1, | |
853 | "Store strings in writable data section" }, | |
854 | {"peephole", &flag_no_peephole, 0, | |
855 | "Enable machine specific peephole optimisations" }, | |
856 | {"force-mem", &flag_force_mem, 1, | |
857 | "Copy memory operands into registers before using" }, | |
858 | {"force-addr", &flag_force_addr, 1, | |
859 | "Copy memory address constants into regs before using" }, | |
860 | {"function-cse", &flag_no_function_cse, 0, | |
861 | "Allow function addresses to be held in registers" }, | |
862 | {"inline-functions", &flag_inline_functions, 1, | |
863 | "Integrate simple functions into their callers" }, | |
864 | {"keep-inline-functions", &flag_keep_inline_functions, 1, | |
865 | "Generate code for funcs even if they are fully inlined" }, | |
866 | {"inline", &flag_no_inline, 0, | |
867 | "Pay attention to the 'inline' keyword"}, | |
868 | {"keep-static-consts", &flag_keep_static_consts, 1, | |
869 | "Emit static const variables even if they are not used" }, | |
870 | {"syntax-only", &flag_syntax_only, 1, | |
871 | "Check for syntax errors, then stop" }, | |
872 | {"shared-data", &flag_shared_data, 1, | |
873 | "Mark data as shared rather than private" }, | |
874 | {"caller-saves", &flag_caller_saves, 1, | |
875 | "Enable saving registers around function calls" }, | |
876 | {"pcc-struct-return", &flag_pcc_struct_return, 1, | |
877 | "Return 'short' aggregates in memory, not registers" }, | |
878 | {"reg-struct-return", &flag_pcc_struct_return, 0, | |
879 | "Return 'short' aggregates in registers" }, | |
880 | {"delayed-branch", &flag_delayed_branch, 1, | |
881 | "Attempt to fill delay slots of branch instructions" }, | |
882 | {"gcse", &flag_gcse, 1, | |
883 | "Perform the global common subexpression elimination" }, | |
884 | {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1, | |
885 | "Run CSE pass after loop optimisations"}, | |
886 | {"rerun-loop-opt", &flag_rerun_loop_opt, 1, | |
887 | "Run the loop optimiser twice"}, | |
888 | {"pretend-float", &flag_pretend_float, 1, | |
889 | "Pretend that host and target use the same FP format"}, | |
890 | {"schedule-insns", &flag_schedule_insns, 1, | |
891 | "Reschedule instructions to avoid pipeline stalls"}, | |
892 | {"schedule-insns2", &flag_schedule_insns_after_reload, 1, | |
893 | "Run two passes of the instruction scheduler"}, | |
8c660648 | 894 | #ifdef HAIFA |
b8468bc7 NC |
895 | {"sched-interblock",&flag_schedule_interblock, 1, |
896 | "Enable scheduling across basic blocks" }, | |
897 | {"sched-spec",&flag_schedule_speculative, 1, | |
898 | "Allow speculative motion of non-loads" }, | |
899 | {"sched-spec-load",&flag_schedule_speculative_load, 1, | |
900 | "Allow speculative motion of some loads" }, | |
901 | {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1, | |
902 | "Allow speculative motion of more loads" }, | |
f1da1729 | 903 | #endif /* HAIFA */ |
b8468bc7 | 904 | {"branch-count-reg",&flag_branch_on_count_reg, 1, |
40f943dd | 905 | "Replace add,compare,branch with branch on count reg"}, |
b8468bc7 NC |
906 | {"pic", &flag_pic, 1, |
907 | "Generate position independent code, if possible"}, | |
908 | {"PIC", &flag_pic, 2, ""}, | |
909 | {"exceptions", &flag_exceptions, 1, | |
910 | "Enable exception handling" }, | |
911 | {"new-exceptions", &flag_new_exceptions, 1, | |
912 | "Use the new model for exception handling" }, | |
913 | {"sjlj-exceptions", &exceptions_via_longjmp, 1, | |
914 | "Use setjmp/longjmp to handle exceptions" }, | |
915 | {"asynchronous-exceptions", &asynchronous_exceptions, 1, | |
916 | "Support asynchronous exceptions" }, | |
917 | {"profile-arcs", &profile_arc_flag, 1, | |
918 | "Insert arc based program profiling code" }, | |
919 | {"test-coverage", &flag_test_coverage, 1, | |
920 | "Create data files needed by gcov" }, | |
921 | {"branch-probabilities", &flag_branch_probabilities, 1, | |
62e7b719 | 922 | "Use profiling information for branch probabilities" }, |
b8468bc7 NC |
923 | {"fast-math", &flag_fast_math, 1, |
924 | "Improve FP speed by violating ANSI & IEEE rules" }, | |
925 | {"common", &flag_no_common, 0, | |
926 | "Do not put unitialised globals in the common section" }, | |
927 | {"inhibit-size-directive", &flag_inhibit_size_directive, 1, | |
928 | "Do not generate .size directives" }, | |
929 | {"function-sections", &flag_function_sections, 1, | |
930 | "place each function into its own section" }, | |
257441db CM |
931 | {"data-sections", &flag_data_sections, 1, |
932 | "place data items into their own section" }, | |
b8468bc7 NC |
933 | {"verbose-asm", &flag_verbose_asm, 1, |
934 | "Add extra commentry to assembler output"}, | |
935 | {"gnu-linker", &flag_gnu_linker, 1, | |
936 | "Output GNU ld formatted global initialisers"}, | |
937 | {"regmove", &flag_regmove, 1, | |
c84e2712 KG |
938 | "Enables a register move optimisation"}, |
939 | {"optimize-register-move", &flag_regmove, 1, | |
940 | "Do the full regmove optimization pass"}, | |
b8468bc7 NC |
941 | {"pack-struct", &flag_pack_struct, 1, |
942 | "Pack structure members together without holes" }, | |
943 | {"stack-check", &flag_stack_check, 1, | |
944 | "Insert stack checking code into the program" }, | |
945 | {"argument-alias", &flag_argument_noalias, 0, | |
946 | "Specify that arguments may alias each other & globals"}, | |
947 | {"argument-noalias", &flag_argument_noalias, 1, | |
948 | "Assume arguments may alias globals but not each other"}, | |
949 | {"argument-noalias-global", &flag_argument_noalias, 2, | |
950 | "Assume arguments do not alias each other or globals" }, | |
951 | {"strict-aliasing", &flag_strict_aliasing, 1, | |
952 | "Assume strict aliasing rules apply" }, | |
953 | {"check-memory-usage", &flag_check_memory_usage, 1, | |
954 | "Generate code to check every memory access" }, | |
955 | {"prefix-function-name", &flag_prefix_function_name, 1, | |
956 | "Add a prefix to all function names" }, | |
c84e2712 KG |
957 | {"dump-unnumbered", &flag_dump_unnumbered, 1, |
958 | "Suppress output of instruction numbers and line number notes in debugging dumps"}, | |
07417085 KR |
959 | {"instrument-functions", &flag_instrument_function_entry_exit, 1, |
960 | "Instrument function entry/exit with profiling calls"}, | |
19283265 | 961 | {"leading-underscore", &flag_leading_underscore, 1, |
be163a70 ZW |
962 | "External symbols have a leading underscore" }, |
963 | {"ident", &flag_no_ident, 0, | |
964 | "Process #ident directives"} | |
4291d9c8 | 965 | }; |
b99933c7 | 966 | |
b8468bc7 NC |
967 | #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0])) |
968 | ||
b99933c7 RS |
969 | /* Table of language-specific options. */ |
970 | ||
b8468bc7 NC |
971 | static struct lang_opt |
972 | { | |
87e11268 KG |
973 | const char * option; |
974 | const char * description; | |
b8468bc7 NC |
975 | } |
976 | documented_lang_options[] = | |
b99933c7 | 977 | { |
b8468bc7 NC |
978 | /* In order not to overload the --help output, the convention |
979 | used here is to only describe those options which are not | |
980 | enabled by default. */ | |
981 | ||
982 | { "-ansi", "Compile just for ANSI C" }, | |
983 | { "-fallow-single-precision", | |
984 | "Do not promote floats to double if using -traditional" }, | |
6f4d7222 | 985 | { "-std= ", "Determine language standard"}, |
b8468bc7 NC |
986 | |
987 | { "-fsigned-bitfields", "" }, | |
988 | { "-funsigned-bitfields","Make bitfields by unsigned by default" }, | |
989 | { "-fno-signed-bitfields", "" }, | |
990 | { "-fno-unsigned-bitfields","" }, | |
991 | { "-fsigned-char", "Make 'char' be signed by default"}, | |
992 | { "-funsigned-char", "Make 'char' be unsigned by default"}, | |
993 | { "-fno-signed-char", "" }, | |
994 | { "-fno-unsigned-char", "" }, | |
995 | ||
996 | { "-ftraditional", "" }, | |
997 | { "-traditional", "Attempt to support traditional K&R style C"}, | |
998 | { "-fnotraditional", "" }, | |
999 | { "-fno-traditional", "" }, | |
1000 | ||
1001 | { "-fasm", "" }, | |
1002 | { "-fno-asm", "Do not recognise the 'asm' keyword" }, | |
1003 | { "-fbuiltin", "" }, | |
1004 | { "-fno-builtin", "Do not recognise any built in functions" }, | |
1005 | { "-fhosted", "Assume normal C execution environment" }, | |
1006 | { "-fno-hosted", "" }, | |
1007 | { "-ffreestanding", | |
1008 | "Assume that standard libraries & main might not exist" }, | |
1009 | { "-fno-freestanding", "" }, | |
1010 | { "-fcond-mismatch", "Allow different types as args of ? operator"}, | |
1011 | { "-fno-cond-mismatch", "" }, | |
62e7b719 | 1012 | { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" }, |
b8468bc7 | 1013 | { "-fno-dollars-in-identifiers", "" }, |
b8468bc7 NC |
1014 | { "-fshort-double", "Use the same size for double as for float" }, |
1015 | { "-fno-short-double", "" }, | |
1016 | { "-fshort-enums", "Use the smallest fitting integer to hold enums"}, | |
1017 | { "-fno-short-enums", "" }, | |
1018 | ||
1019 | { "-Wall", "Enable most warning messages" }, | |
1020 | { "-Wbad-function-cast", | |
1021 | "Warn about casting functions to incompatible types" }, | |
1022 | { "-Wno-bad-function-cast", "" }, | |
0ca3fb0a KG |
1023 | { "-Wmissing-noreturn", |
1024 | "Warn about functions which might be candidates for attribute noreturn" }, | |
1025 | { "-Wno-missing-noreturn", "" }, | |
b8468bc7 NC |
1026 | { "-Wcast-qual", "Warn about casts which discard qualifiers"}, |
1027 | { "-Wno-cast-qual", "" }, | |
630962bf | 1028 | { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"}, |
b8468bc7 NC |
1029 | { "-Wno-char-subscripts", "" }, |
1030 | { "-Wcomment", "Warn if nested comments are detected" }, | |
c84e2712 KG |
1031 | { "-Wno-comment", "" }, |
1032 | { "-Wcomments", "Warn if nested comments are detected" }, | |
1033 | { "-Wno-comments", "" }, | |
b8468bc7 NC |
1034 | { "-Wconversion", "Warn about possibly confusing type conversions" }, |
1035 | { "-Wno-conversion", "" }, | |
1036 | { "-Wformat", "Warn about printf format anomalies" }, | |
1037 | { "-Wno-format", "" }, | |
1038 | { "-Wimplicit-function-declaration", | |
1039 | "Warn about implicit function declarations" }, | |
1040 | { "-Wno-implicit-function-declaration", "" }, | |
1041 | { "-Werror-implicit-function-declaration", "" }, | |
1042 | { "-Wimplicit-int", "Warn when a declaration does not specify a type" }, | |
1043 | { "-Wno-implicit-int", "" }, | |
1044 | { "-Wimplicit", "" }, | |
1045 | { "-Wno-implicit", "" }, | |
1046 | { "-Wimport", "Warn about the use of the #import directive" }, | |
1047 | { "-Wno-import", "" }, | |
1048 | { "-Wlong-long","" }, | |
1049 | { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" }, | |
1050 | { "-Wmain", "Warn about suspicious declarations of main" }, | |
1051 | { "-Wno-main", "" }, | |
1052 | { "-Wmissing-braces", | |
1053 | "Warn about possibly missing braces around initialisers" }, | |
1054 | { "-Wno-missing-braces", "" }, | |
1055 | { "-Wmissing-declarations", | |
1056 | "Warn about global funcs without previous declarations"}, | |
1057 | { "-Wno-missing-declarations", "" }, | |
1058 | { "-Wmissing-prototypes", "Warn about global funcs without prototypes" }, | |
1059 | { "-Wno-missing-prototypes", "" }, | |
1060 | { "-Wmultichar", "Warn about use of multicharacter literals"}, | |
1061 | { "-Wno-multichar", "" }, | |
1062 | { "-Wnested-externs", "Warn about externs not at file scope level" }, | |
1063 | { "-Wno-nested-externs", "" }, | |
1064 | { "-Wparentheses", "Warn about possible missing parentheses" }, | |
1065 | { "-Wno-parentheses", "" }, | |
1066 | { "-Wpointer-arith", "Warn about function pointer arithmetic" }, | |
1067 | { "-Wno-pointer-arith", "" }, | |
1068 | { "-Wredundant-decls", | |
1069 | "Warn about multiple declarations of the same object" }, | |
1070 | { "-Wno-redundant-decls", "" }, | |
1071 | { "-Wsign-compare", "Warn about signed/unsigned comparisons" }, | |
1072 | { "-Wno-sign-compare", "" }, | |
1073 | { "-Wunknown-pragmas", "Warn about unrecognised pragmas" }, | |
1074 | { "-Wno-unknown-pragmas", "" }, | |
1075 | { "-Wstrict-prototypes", "Warn about non-prototyped function decls" }, | |
1076 | { "-Wno-strict-prototypes", "" }, | |
630962bf | 1077 | { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"}, |
b8468bc7 NC |
1078 | { "-Wno-traditional", "" }, |
1079 | { "-Wtrigraphs", "Warn when trigraphs are encountered" }, | |
1080 | { "-Wno-trigraphs", "" }, | |
1081 | { "-Wundef", "" }, | |
1082 | { "-Wno-undef", "" }, | |
1083 | { "-Wwrite-strings", "Mark strings as 'const char *'"}, | |
1084 | { "-Wno-write-strings", "" }, | |
a457294f | 1085 | |
a0d85b75 | 1086 | /* These are for languages with USE_CPPLIB. */ |
b8468bc7 | 1087 | /* These options are already documented in cpplib.c */ |
40f943dd | 1088 | { "--help", "" }, |
b8468bc7 NC |
1089 | { "-A", "" }, |
1090 | { "-D", "" }, | |
1091 | { "-I", "" }, | |
1092 | { "-U", "" }, | |
add7091b | 1093 | { "-H", "" }, |
b8468bc7 | 1094 | { "-idirafter", "" }, |
6fa72945 ZW |
1095 | { "-imacros", "" }, |
1096 | { "-include", "" }, | |
b8468bc7 NC |
1097 | { "-iprefix", "" }, |
1098 | { "-isystem", "" }, | |
6fa72945 ZW |
1099 | { "-iwithprefix", "" }, |
1100 | { "-iwithprefixbefore", "" }, | |
b8468bc7 NC |
1101 | { "-lang-c", "" }, |
1102 | { "-lang-c89", "" }, | |
1103 | { "-lang-c++", "" }, | |
6fa72945 | 1104 | { "-remap", "" }, |
b8468bc7 NC |
1105 | { "-nostdinc", "" }, |
1106 | { "-nostdinc++", "" }, | |
1107 | { "-trigraphs", "" }, | |
1108 | { "-undef", "" }, | |
b8468bc7 NC |
1109 | |
1110 | #define DEFINE_LANG_NAME(NAME) { NULL, NAME }, | |
1111 | ||
1112 | /* These are for obj c. */ | |
1113 | DEFINE_LANG_NAME ("Objective C") | |
1114 | ||
1115 | { "-lang-objc", "" }, | |
1116 | { "-gen-decls", "Dump decls to a .decl file" }, | |
62e7b719 | 1117 | { "-fgnu-runtime", "Generate code for GNU runtime environment" }, |
b8468bc7 NC |
1118 | { "-fno-gnu-runtime", "" }, |
1119 | { "-fnext-runtime", "Generate code for NeXT runtime environment" }, | |
1120 | { "-fno-next-runtime", "" }, | |
1121 | { "-Wselector", "Warn if a selector has multiple methods" }, | |
1122 | { "-Wno-selector", "" }, | |
1123 | { "-Wprotocol", "" }, | |
1124 | { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"}, | |
1125 | { "-print-objc-runtime-info", | |
1126 | "Generate C header of platform specific features" }, | |
a0d85b75 | 1127 | |
2a95de17 | 1128 | #include "options.h" |
b8468bc7 | 1129 | |
b99933c7 | 1130 | }; |
b8468bc7 NC |
1131 | |
1132 | /* Here is a table, controlled by the tm.h file, listing each -m switch | |
1133 | and which bits in `target_switches' it should set or clear. | |
1134 | If VALUE is positive, it is bits to set. | |
1135 | If VALUE is negative, -VALUE is bits to clear. | |
1136 | (The sign bit is not used so there is no confusion.) */ | |
1137 | ||
1138 | struct | |
1139 | { | |
87e11268 | 1140 | const char * name; |
b8468bc7 | 1141 | int value; |
87e11268 | 1142 | const char * description; |
b8468bc7 NC |
1143 | } |
1144 | target_switches [] = TARGET_SWITCHES; | |
1145 | ||
1146 | /* This table is similar, but allows the switch to have a value. */ | |
1147 | ||
1148 | #ifdef TARGET_OPTIONS | |
1149 | struct | |
1150 | { | |
87e11268 KG |
1151 | const char * prefix; |
1152 | const char ** variable; | |
1153 | const char * description; | |
b8468bc7 NC |
1154 | } |
1155 | target_options [] = TARGET_OPTIONS; | |
1156 | #endif | |
4291d9c8 RS |
1157 | \f |
1158 | /* Options controlling warnings */ | |
1159 | ||
1160 | /* Don't print warning messages. -w. */ | |
1161 | ||
1162 | int inhibit_warnings = 0; | |
1163 | ||
1164 | /* Print various extra warnings. -W. */ | |
1165 | ||
1166 | int extra_warnings = 0; | |
1167 | ||
1168 | /* Treat warnings as errors. -Werror. */ | |
1169 | ||
1170 | int warnings_are_errors = 0; | |
1171 | ||
1172 | /* Nonzero to warn about unused local variables. */ | |
1173 | ||
1174 | int warn_unused; | |
1175 | ||
1176 | /* Nonzero to warn about variables used before they are initialized. */ | |
1177 | ||
1178 | int warn_uninitialized; | |
1179 | ||
1180 | /* Nonzero means warn about all declarations which shadow others. */ | |
1181 | ||
1182 | int warn_shadow; | |
1183 | ||
1184 | /* Warn if a switch on an enum fails to have a case for every enum value. */ | |
1185 | ||
1186 | int warn_switch; | |
1187 | ||
1188 | /* Nonzero means warn about function definitions that default the return type | |
1189 | or that use a null return and have a return-type other than void. */ | |
1190 | ||
1191 | int warn_return_type; | |
1192 | ||
1193 | /* Nonzero means warn about pointer casts that increase the required | |
1194 | alignment of the target type (and might therefore lead to a crash | |
1195 | due to a misaligned access). */ | |
1196 | ||
1197 | int warn_cast_align; | |
1198 | ||
1199 | /* Nonzero means warn about any identifiers that match in the first N | |
1200 | characters. The value N is in `id_clash_len'. */ | |
1201 | ||
1202 | int warn_id_clash; | |
b51e9c62 RK |
1203 | unsigned id_clash_len; |
1204 | ||
1205 | /* Nonzero means warn about any objects definitions whose size is larger | |
1206 | than N bytes. Also want about function definitions whose returned | |
1207 | values are larger than N bytes. The value N is in `larger_than_size'. */ | |
1208 | ||
1209 | int warn_larger_than; | |
1210 | unsigned larger_than_size; | |
4291d9c8 RS |
1211 | |
1212 | /* Nonzero means warn if inline function is too large. */ | |
1213 | ||
1214 | int warn_inline; | |
1215 | ||
1216 | /* Warn if a function returns an aggregate, | |
1217 | since there are often incompatible calling conventions for doing this. */ | |
1218 | ||
1219 | int warn_aggregate_return; | |
1220 | ||
1221 | /* Likewise for -W. */ | |
1222 | ||
b8468bc7 | 1223 | lang_independent_options W_options[] = |
4291d9c8 | 1224 | { |
b8468bc7 NC |
1225 | {"unused", &warn_unused, 1, "Warn when a variable is unused" }, |
1226 | {"error", &warnings_are_errors, 1, ""}, | |
1227 | {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" }, | |
1228 | {"switch", &warn_switch, 1, | |
1229 | "Warn about enumerated switches missing a specific case" }, | |
1230 | {"aggregate-return", &warn_aggregate_return, 1, | |
1231 | "Warn about returning structures, unions or arrays" }, | |
1232 | {"cast-align", &warn_cast_align, 1, | |
1233 | "Warn about pointer casts which increase alignment" }, | |
1234 | {"uninitialized", &warn_uninitialized, 1, | |
1235 | "Warn about unitialized automatic variables"}, | |
1236 | {"inline", &warn_inline, 1, | |
1237 | "Warn when an inlined function cannot be inlined"} | |
4291d9c8 RS |
1238 | }; |
1239 | \f | |
1240 | /* Output files for assembler code (real compiler output) | |
1241 | and debugging dumps. */ | |
1242 | ||
1243 | FILE *asm_out_file; | |
1244 | FILE *aux_info_file; | |
032713aa | 1245 | FILE *rtl_dump_file = NULL; |
4291d9c8 | 1246 | |
132e01b1 TP |
1247 | /* Decode the string P as an integral parameter. |
1248 | If the string is indeed an integer return its numeric value else | |
192babfd TP |
1249 | issue an Invalid Option error for the option PNAME and return DEFVAL. |
1250 | If PNAME is zero just return DEFVAL, do not call error. */ | |
132e01b1 TP |
1251 | |
1252 | int | |
1253 | read_integral_parameter (p, pname, defval) | |
192babfd TP |
1254 | const char *p; |
1255 | const char *pname; | |
1256 | const int defval; | |
132e01b1 | 1257 | { |
192babfd | 1258 | const char *endp = p; |
132e01b1 TP |
1259 | |
1260 | while (*endp) | |
1261 | { | |
1262 | if (*endp >= '0' && *endp <= '9') | |
1263 | endp++; | |
1264 | else | |
192babfd TP |
1265 | break; |
1266 | } | |
1267 | ||
1268 | if (*endp != 0) | |
1269 | { | |
1270 | if (pname != 0) | |
1271 | error ("Invalid option `%s'", pname); | |
1272 | return defval; | |
132e01b1 TP |
1273 | } |
1274 | ||
1275 | return atoi (p); | |
1276 | } | |
1277 | ||
1278 | ||
4291d9c8 RS |
1279 | /* Time accumulators, to count the total time spent in various passes. */ |
1280 | ||
1281 | int parse_time; | |
1282 | int varconst_time; | |
1283 | int integration_time; | |
1284 | int jump_time; | |
1285 | int cse_time; | |
7506f491 | 1286 | int gcse_time; |
4291d9c8 RS |
1287 | int loop_time; |
1288 | int cse2_time; | |
0d332add | 1289 | int branch_prob_time; |
4291d9c8 RS |
1290 | int flow_time; |
1291 | int combine_time; | |
8c660648 | 1292 | int regmove_time; |
4291d9c8 RS |
1293 | int sched_time; |
1294 | int local_alloc_time; | |
1295 | int global_alloc_time; | |
e881bb1b | 1296 | int flow2_time; |
4291d9c8 | 1297 | int sched2_time; |
bd334356 | 1298 | #ifdef DELAY_SLOTS |
4291d9c8 | 1299 | int dbr_sched_time; |
bd334356 | 1300 | #endif |
4291d9c8 RS |
1301 | int shorten_branch_time; |
1302 | int stack_reg_time; | |
1303 | int final_time; | |
1304 | int symout_time; | |
1305 | int dump_time; | |
1306 | \f | |
1307 | /* Return time used so far, in microseconds. */ | |
1308 | ||
2778b98d | 1309 | long |
4291d9c8 RS |
1310 | get_run_time () |
1311 | { | |
4291d9c8 RS |
1312 | if (quiet_flag) |
1313 | return 0; | |
83c8ddef | 1314 | |
332c1bb4 JL |
1315 | #ifdef __BEOS__ |
1316 | return 0; | |
1317 | #else /* not BeOS */ | |
cae21ae8 | 1318 | #if defined (_WIN32) && !defined (__CYGWIN__) |
15f00097 RK |
1319 | if (clock() < 0) |
1320 | return 0; | |
1321 | else | |
1322 | return (clock() * 1000); | |
9580b583 | 1323 | #else /* not _WIN32 */ |
4e762a38 JC |
1324 | #ifdef _SC_CLK_TCK |
1325 | { | |
1326 | static int tick; | |
83c8ddef | 1327 | struct tms tms; |
4e762a38 JC |
1328 | if (tick == 0) |
1329 | tick = 1000000 / sysconf(_SC_CLK_TCK); | |
1330 | times (&tms); | |
1331 | return (tms.tms_utime + tms.tms_stime) * tick; | |
1332 | } | |
1333 | #else | |
4291d9c8 | 1334 | #ifdef USG |
83c8ddef RH |
1335 | { |
1336 | struct tms tms; | |
e5e809f4 JL |
1337 | # if HAVE_SYSCONF && defined _SC_CLK_TCK |
1338 | # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */ | |
1339 | # else | |
1340 | # ifdef CLK_TCK | |
1341 | # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */ | |
1342 | # else | |
1343 | # define TICKS_PER_SECOND HZ /* traditional UNIX */ | |
1344 | # endif | |
1345 | # endif | |
83c8ddef | 1346 | times (&tms); |
e5e809f4 | 1347 | return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND); |
83c8ddef | 1348 | } |
4291d9c8 RS |
1349 | #else |
1350 | #ifndef VMS | |
83c8ddef RH |
1351 | { |
1352 | struct rusage rusage; | |
1353 | getrusage (0, &rusage); | |
1354 | return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec | |
1355 | + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); | |
1356 | } | |
4291d9c8 | 1357 | #else /* VMS */ |
83c8ddef RH |
1358 | { |
1359 | struct | |
1360 | { | |
1361 | int proc_user_time; | |
1362 | int proc_system_time; | |
1363 | int child_user_time; | |
1364 | int child_system_time; | |
1365 | } vms_times; | |
1366 | times ((void *) &vms_times); | |
1367 | return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; | |
1368 | } | |
c55dcc7d FF |
1369 | #endif /* VMS */ |
1370 | #endif /* USG */ | |
4e762a38 | 1371 | #endif /* _SC_CLK_TCK */ |
c55dcc7d FF |
1372 | #endif /* _WIN32 */ |
1373 | #endif /* __BEOS__ */ | |
4291d9c8 RS |
1374 | } |
1375 | ||
1376 | #define TIMEVAR(VAR, BODY) \ | |
1377 | do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0) | |
1378 | ||
1379 | void | |
1380 | print_time (str, total) | |
87e11268 | 1381 | const char *str; |
4291d9c8 RS |
1382 | int total; |
1383 | { | |
1384 | fprintf (stderr, | |
1385 | "time in %s: %d.%06d\n", | |
1386 | str, total / 1000000, total % 1000000); | |
1387 | } | |
1388 | ||
1389 | /* Count an error or warning. Return 1 if the message should be printed. */ | |
1390 | ||
1391 | int | |
1392 | count_error (warningp) | |
1393 | int warningp; | |
1394 | { | |
1395 | if (warningp && inhibit_warnings) | |
1396 | return 0; | |
1397 | ||
1398 | if (warningp && !warnings_are_errors) | |
1399 | warningcount++; | |
1400 | else | |
1401 | { | |
1402 | static int warning_message = 0; | |
1403 | ||
1404 | if (warningp && !warning_message) | |
1405 | { | |
ab87f8c8 | 1406 | notice ("%s: warnings being treated as errors\n", progname); |
4291d9c8 RS |
1407 | warning_message = 1; |
1408 | } | |
1409 | errorcount++; | |
1410 | } | |
1411 | ||
1412 | return 1; | |
1413 | } | |
1414 | ||
1415 | /* Print a fatal error message. NAME is the text. | |
1416 | Also include a system error message based on `errno'. */ | |
1417 | ||
1418 | void | |
1419 | pfatal_with_name (name) | |
87e11268 | 1420 | const char *name; |
4291d9c8 RS |
1421 | { |
1422 | fprintf (stderr, "%s: ", progname); | |
1423 | perror (name); | |
299846f2 | 1424 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
1425 | } |
1426 | ||
1427 | void | |
1428 | fatal_io_error (name) | |
87e11268 | 1429 | const char *name; |
4291d9c8 | 1430 | { |
ab87f8c8 | 1431 | notice ("%s: %s: I/O error\n", progname, name); |
299846f2 | 1432 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
1433 | } |
1434 | ||
a89b2cc4 MM |
1435 | /* Called to give a better error message for a bad insn rather than |
1436 | just calling abort(). */ | |
4291d9c8 RS |
1437 | |
1438 | void | |
34487bf8 | 1439 | fatal_insn VPROTO((const char *msgid, rtx insn, ...)) |
4291d9c8 | 1440 | { |
34487bf8 RH |
1441 | #ifndef ANSI_PROTOTYPES |
1442 | const char *msgid; | |
1443 | rtx insn; | |
1444 | #endif | |
1445 | va_list ap; | |
1446 | ||
1447 | VA_START (ap, insn); | |
1448 | ||
1449 | #ifndef ANSI_PROTOTYPES | |
1450 | msgid = va_arg (ap, const char *); | |
1451 | insn = va_arg (ap, rtx); | |
1452 | #endif | |
1453 | ||
1454 | verror (msgid, ap); | |
b93a436e | 1455 | debug_rtx (insn); |
34487bf8 | 1456 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
1457 | } |
1458 | ||
a89b2cc4 MM |
1459 | /* Called to give a better error message when we don't have an insn to match |
1460 | what we are looking for or if the insn's constraints aren't satisfied, | |
1461 | rather than just calling abort(). */ | |
1462 | ||
1463 | void | |
1464 | fatal_insn_not_found (insn) | |
1465 | rtx insn; | |
1466 | { | |
1467 | if (INSN_CODE (insn) < 0) | |
1468 | fatal_insn ("internal error--unrecognizable insn:", insn); | |
1469 | else | |
1470 | fatal_insn ("internal error--insn does not satisfy its constraints:", insn); | |
1471 | } | |
1472 | ||
4291d9c8 RS |
1473 | /* This is the default decl_printable_name function. */ |
1474 | ||
1475 | static char * | |
a1d7ffe3 | 1476 | decl_name (decl, verbosity) |
4291d9c8 | 1477 | tree decl; |
114791ea | 1478 | int verbosity ATTRIBUTE_UNUSED; |
4291d9c8 RS |
1479 | { |
1480 | return IDENTIFIER_POINTER (DECL_NAME (decl)); | |
1481 | } | |
1482 | \f | |
1483 | static int need_error_newline; | |
1484 | ||
1485 | /* Function of last error message; | |
1486 | more generally, function such that if next error message is in it | |
1487 | then we don't have to mention the function name. */ | |
1488 | static tree last_error_function = NULL; | |
1489 | ||
1490 | /* Used to detect when input_file_stack has changed since last described. */ | |
1491 | static int last_error_tick; | |
1492 | ||
1493 | /* Called when the start of a function definition is parsed, | |
1494 | this function prints on stderr the name of the function. */ | |
1495 | ||
1496 | void | |
1497 | announce_function (decl) | |
1498 | tree decl; | |
1499 | { | |
1500 | if (! quiet_flag) | |
1501 | { | |
4291d9c8 RS |
1502 | if (rtl_dump_and_exit) |
1503 | fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); | |
1504 | else | |
a1d7ffe3 | 1505 | fprintf (stderr, " %s", (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
1506 | fflush (stderr); |
1507 | need_error_newline = 1; | |
1508 | last_error_function = current_function_decl; | |
1509 | } | |
1510 | } | |
1511 | ||
b64e9948 PB |
1512 | /* The default function to print out name of current function that caused |
1513 | an error. */ | |
4291d9c8 RS |
1514 | |
1515 | void | |
b64e9948 | 1516 | default_print_error_function (file) |
87e11268 | 1517 | const char *file; |
4291d9c8 | 1518 | { |
4291d9c8 RS |
1519 | if (last_error_function != current_function_decl) |
1520 | { | |
4291d9c8 RS |
1521 | if (file) |
1522 | fprintf (stderr, "%s: ", file); | |
1523 | ||
1524 | if (current_function_decl == NULL) | |
ab87f8c8 | 1525 | notice ("At top level:\n"); |
4291d9c8 | 1526 | else |
ab87f8c8 JL |
1527 | notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE |
1528 | ? "In method `%s':\n" | |
1529 | : "In function `%s':\n"), | |
1530 | (*decl_printable_name) (current_function_decl, 2)); | |
4291d9c8 RS |
1531 | |
1532 | last_error_function = current_function_decl; | |
1533 | } | |
b64e9948 PB |
1534 | } |
1535 | ||
1536 | /* Called by report_error_function to print out function name. | |
0f41302f | 1537 | * Default may be overridden by language front-ends. */ |
b64e9948 | 1538 | |
87e11268 KG |
1539 | void (*print_error_function) PROTO((const char *)) = |
1540 | default_print_error_function; | |
b64e9948 PB |
1541 | |
1542 | /* Prints out, if necessary, the name of the current function | |
1543 | that caused an error. Called from all error and warning functions. */ | |
1544 | ||
1545 | void | |
1546 | report_error_function (file) | |
87e11268 | 1547 | const char *file; |
b64e9948 PB |
1548 | { |
1549 | struct file_stack *p; | |
1550 | ||
1551 | if (need_error_newline) | |
1552 | { | |
1553 | fprintf (stderr, "\n"); | |
1554 | need_error_newline = 0; | |
1555 | } | |
1556 | ||
1557 | (*print_error_function) (file); | |
1558 | ||
4291d9c8 | 1559 | if (input_file_stack && input_file_stack->next != 0 |
2efc92ed RK |
1560 | && input_file_stack_tick != last_error_tick |
1561 | && file == input_filename) | |
4291d9c8 | 1562 | { |
4291d9c8 | 1563 | for (p = input_file_stack->next; p; p = p->next) |
ab87f8c8 JL |
1564 | notice ((p == input_file_stack->next |
1565 | ? "In file included from %s:%d" | |
1566 | : ",\n from %s:%d"), | |
1567 | p->name, p->line); | |
4291d9c8 RS |
1568 | fprintf (stderr, ":\n"); |
1569 | last_error_tick = input_file_stack_tick; | |
1570 | } | |
1571 | } | |
eb711c86 RK |
1572 | \f |
1573 | /* Print a message. */ | |
4291d9c8 | 1574 | |
eb711c86 | 1575 | static void |
ab87f8c8 JL |
1576 | vnotice (file, msgid, ap) |
1577 | FILE *file; | |
1578 | char *msgid; | |
1579 | va_list ap; | |
1580 | { | |
1581 | vfprintf (file, _(msgid), ap); | |
1582 | } | |
1583 | ||
1584 | void | |
1585 | notice VPROTO((const char *msgid, ...)) | |
1586 | { | |
96df87b8 | 1587 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 JL |
1588 | char *msgid; |
1589 | #endif | |
1590 | va_list ap; | |
1591 | ||
1592 | VA_START (ap, msgid); | |
1593 | ||
96df87b8 | 1594 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 JL |
1595 | msgid = va_arg (ap, char *); |
1596 | #endif | |
1597 | ||
1598 | vnotice (stderr, msgid, ap); | |
1599 | va_end (ap); | |
1600 | } | |
1601 | ||
1602 | void | |
644f3d7e | 1603 | fnotice VPROTO((FILE *file, const char *msgid, ...)) |
ab87f8c8 | 1604 | { |
96df87b8 | 1605 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 1606 | FILE *file; |
644f3d7e | 1607 | const char *msgid; |
ab87f8c8 JL |
1608 | #endif |
1609 | va_list ap; | |
1610 | ||
1611 | VA_START (ap, msgid); | |
1612 | ||
96df87b8 | 1613 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 1614 | file = va_arg (ap, FILE *); |
644f3d7e | 1615 | msgid = va_arg (ap, const char *); |
ab87f8c8 JL |
1616 | #endif |
1617 | ||
1618 | vnotice (file, msgid, ap); | |
1619 | va_end (ap); | |
1620 | } | |
1621 | ||
1622 | /* Report FILE and LINE (or program name), and optionally just WARN. */ | |
1623 | ||
1624 | static void | |
1625 | report_file_and_line (file, line, warn) | |
1626 | char *file; | |
1627 | int line; | |
1628 | int warn; | |
1629 | { | |
1630 | if (file) | |
1631 | fprintf (stderr, "%s:%d: ", file, line); | |
1632 | else | |
1633 | fprintf (stderr, "%s: ", progname); | |
1634 | ||
1635 | if (warn) | |
1636 | notice ("warning: "); | |
1637 | } | |
1638 | ||
1639 | /* Print a message. */ | |
1640 | ||
1641 | static void | |
1642 | vmessage (prefix, msgid, ap) | |
87e11268 | 1643 | const char *prefix; |
ab87f8c8 | 1644 | const char *msgid; |
eb711c86 | 1645 | va_list ap; |
4291d9c8 | 1646 | { |
eb711c86 RK |
1647 | if (prefix) |
1648 | fprintf (stderr, "%s: ", prefix); | |
1649 | ||
ab87f8c8 | 1650 | vfprintf (stderr, msgid, ap); |
4291d9c8 RS |
1651 | } |
1652 | ||
eb711c86 | 1653 | /* Print a message relevant to line LINE of file FILE. */ |
4291d9c8 | 1654 | |
eb711c86 | 1655 | static void |
ab87f8c8 | 1656 | v_message_with_file_and_line (file, line, warn, msgid, ap) |
87e11268 | 1657 | const char *file; |
4291d9c8 | 1658 | int line; |
ab87f8c8 JL |
1659 | int warn; |
1660 | const char *msgid; | |
eb711c86 | 1661 | va_list ap; |
4291d9c8 | 1662 | { |
ab87f8c8 JL |
1663 | report_file_and_line (file, line, warn); |
1664 | vnotice (stderr, msgid, ap); | |
eb711c86 | 1665 | fputc ('\n', stderr); |
4291d9c8 RS |
1666 | } |
1667 | ||
eb711c86 | 1668 | /* Print a message relevant to the given DECL. */ |
4291d9c8 | 1669 | |
eb711c86 | 1670 | static void |
ab87f8c8 | 1671 | v_message_with_decl (decl, warn, msgid, ap) |
4291d9c8 | 1672 | tree decl; |
ab87f8c8 JL |
1673 | int warn; |
1674 | const char *msgid; | |
eb711c86 | 1675 | va_list ap; |
4291d9c8 | 1676 | { |
87e11268 | 1677 | const char *p; |
4291d9c8 | 1678 | |
ab87f8c8 JL |
1679 | report_file_and_line (DECL_SOURCE_FILE (decl), |
1680 | DECL_SOURCE_LINE (decl), warn); | |
eb711c86 RK |
1681 | |
1682 | /* Do magic to get around lack of varargs support for insertion | |
1683 | of arguments into existing list. We know that the decl is first; | |
1684 | we ass_u_me that it will be printed with "%s". */ | |
1685 | ||
ab87f8c8 | 1686 | for (p = _(msgid); *p; ++p) |
eb711c86 RK |
1687 | { |
1688 | if (*p == '%') | |
1689 | { | |
1690 | if (*(p + 1) == '%') | |
1691 | ++p; | |
ab87f8c8 JL |
1692 | else if (*(p + 1) != 's') |
1693 | abort (); | |
eb711c86 RK |
1694 | else |
1695 | break; | |
1696 | } | |
1697 | } | |
1698 | ||
ab87f8c8 | 1699 | if (p > _(msgid)) /* Print the left-hand substring. */ |
cb039f8a RK |
1700 | { |
1701 | char fmt[sizeof "%.255s"]; | |
ab87f8c8 | 1702 | long width = p - _(msgid); |
cb039f8a RK |
1703 | |
1704 | if (width > 255L) width = 255L; /* arbitrary */ | |
1705 | sprintf (fmt, "%%.%lds", width); | |
ab87f8c8 | 1706 | fprintf (stderr, fmt, _(msgid)); |
cb039f8a | 1707 | } |
eb711c86 | 1708 | |
cb039f8a | 1709 | if (*p == '%') /* Print the name. */ |
eb711c86 | 1710 | { |
87e11268 | 1711 | const char *n = (DECL_NAME (decl) |
a1d7ffe3 | 1712 | ? (*decl_printable_name) (decl, 2) |
eb711c86 RK |
1713 | : "((anonymous))"); |
1714 | fputs (n, stderr); | |
1715 | while (*p) | |
1716 | { | |
1717 | ++p; | |
e9a780ec | 1718 | if (ISALPHA (*(p - 1) & 0xFF)) |
eb711c86 RK |
1719 | break; |
1720 | } | |
1721 | } | |
1722 | ||
cb039f8a | 1723 | if (*p) /* Print the rest of the message. */ |
eb711c86 RK |
1724 | vmessage ((char *)NULL, p, ap); |
1725 | ||
1726 | fputc ('\n', stderr); | |
4291d9c8 RS |
1727 | } |
1728 | ||
eb711c86 | 1729 | /* Figure file and line of the given INSN. */ |
4291d9c8 | 1730 | |
eb711c86 RK |
1731 | static void |
1732 | file_and_line_for_asm (insn, pfile, pline) | |
4291d9c8 | 1733 | rtx insn; |
eb711c86 RK |
1734 | char **pfile; |
1735 | int *pline; | |
4291d9c8 | 1736 | { |
4291d9c8 RS |
1737 | rtx body = PATTERN (insn); |
1738 | rtx asmop; | |
1739 | ||
1740 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ | |
1741 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
1742 | asmop = SET_SRC (body); | |
1743 | else if (GET_CODE (body) == ASM_OPERANDS) | |
1744 | asmop = body; | |
1745 | else if (GET_CODE (body) == PARALLEL | |
1746 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
1747 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
1748 | else if (GET_CODE (body) == PARALLEL | |
1749 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
1750 | asmop = XVECEXP (body, 0, 0); | |
eb711c86 RK |
1751 | else |
1752 | asmop = NULL; | |
1753 | ||
1754 | if (asmop) | |
1755 | { | |
1756 | *pfile = ASM_OPERANDS_SOURCE_FILE (asmop); | |
1757 | *pline = ASM_OPERANDS_SOURCE_LINE (asmop); | |
1758 | } | |
1759 | else | |
1760 | { | |
1761 | *pfile = input_filename; | |
1762 | *pline = lineno; | |
1763 | } | |
1764 | } | |
4291d9c8 | 1765 | |
eb711c86 | 1766 | /* Report an error at line LINE of file FILE. */ |
4291d9c8 | 1767 | |
eb711c86 | 1768 | static void |
ab87f8c8 | 1769 | v_error_with_file_and_line (file, line, msgid, ap) |
87e11268 | 1770 | const char *file; |
eb711c86 | 1771 | int line; |
ab87f8c8 | 1772 | const char *msgid; |
eb711c86 RK |
1773 | va_list ap; |
1774 | { | |
1775 | count_error (0); | |
1776 | report_error_function (file); | |
ab87f8c8 | 1777 | v_message_with_file_and_line (file, line, 0, msgid, ap); |
d78c6ad5 RK |
1778 | } |
1779 | ||
1780 | void | |
87e11268 | 1781 | error_with_file_and_line VPROTO((const char *file, int line, |
ab87f8c8 | 1782 | const char *msgid, ...)) |
d78c6ad5 | 1783 | { |
5148a72b | 1784 | #ifndef ANSI_PROTOTYPES |
87e11268 | 1785 | const char *file; |
eb711c86 | 1786 | int line; |
ab87f8c8 | 1787 | const char *msgid; |
e0e2a8da RK |
1788 | #endif |
1789 | va_list ap; | |
1790 | ||
ab87f8c8 | 1791 | VA_START (ap, msgid); |
eb711c86 | 1792 | |
5148a72b | 1793 | #ifndef ANSI_PROTOTYPES |
87e11268 | 1794 | file = va_arg (ap, const char *); |
eb711c86 | 1795 | line = va_arg (ap, int); |
ab87f8c8 | 1796 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
1797 | #endif |
1798 | ||
ab87f8c8 | 1799 | v_error_with_file_and_line (file, line, msgid, ap); |
eb711c86 | 1800 | va_end (ap); |
4291d9c8 RS |
1801 | } |
1802 | ||
eb711c86 | 1803 | /* Report an error at the declaration DECL. |
ab87f8c8 | 1804 | MSGID is a format string which uses %s to substitute the declaration |
eb711c86 RK |
1805 | name; subsequent substitutions are a la printf. */ |
1806 | ||
1807 | static void | |
ab87f8c8 | 1808 | v_error_with_decl (decl, msgid, ap) |
eb711c86 | 1809 | tree decl; |
ab87f8c8 | 1810 | const char *msgid; |
eb711c86 RK |
1811 | va_list ap; |
1812 | { | |
1813 | count_error (0); | |
1814 | report_error_function (DECL_SOURCE_FILE (decl)); | |
ab87f8c8 | 1815 | v_message_with_decl (decl, 0, msgid, ap); |
eb711c86 | 1816 | } |
4291d9c8 RS |
1817 | |
1818 | void | |
ab87f8c8 | 1819 | error_with_decl VPROTO((tree decl, const char *msgid, ...)) |
eb711c86 | 1820 | { |
5148a72b | 1821 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 1822 | tree decl; |
ab87f8c8 | 1823 | const char *msgid; |
e0e2a8da RK |
1824 | #endif |
1825 | va_list ap; | |
eb711c86 | 1826 | |
ab87f8c8 | 1827 | VA_START (ap, msgid); |
e0e2a8da | 1828 | |
5148a72b | 1829 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 1830 | decl = va_arg (ap, tree); |
ab87f8c8 | 1831 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
1832 | #endif |
1833 | ||
ab87f8c8 | 1834 | v_error_with_decl (decl, msgid, ap); |
eb711c86 RK |
1835 | va_end (ap); |
1836 | } | |
1837 | ||
1838 | /* Report an error at the line number of the insn INSN. | |
1839 | This is used only when INSN is an `asm' with operands, | |
1840 | and each ASM_OPERANDS records its own source file and line. */ | |
1841 | ||
1842 | static void | |
ab87f8c8 | 1843 | v_error_for_asm (insn, msgid, ap) |
eb711c86 | 1844 | rtx insn; |
ab87f8c8 | 1845 | const char *msgid; |
eb711c86 | 1846 | va_list ap; |
4291d9c8 | 1847 | { |
eb711c86 RK |
1848 | char *file; |
1849 | int line; | |
4291d9c8 | 1850 | |
eb711c86 RK |
1851 | count_error (0); |
1852 | file_and_line_for_asm (insn, &file, &line); | |
4291d9c8 | 1853 | report_error_function (file); |
ab87f8c8 | 1854 | v_message_with_file_and_line (file, line, 0, msgid, ap); |
eb711c86 | 1855 | } |
4291d9c8 | 1856 | |
eb711c86 | 1857 | void |
ab87f8c8 | 1858 | error_for_asm VPROTO((rtx insn, const char *msgid, ...)) |
eb711c86 | 1859 | { |
5148a72b | 1860 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 1861 | rtx insn; |
ab87f8c8 | 1862 | const char *msgid; |
e0e2a8da RK |
1863 | #endif |
1864 | va_list ap; | |
eb711c86 | 1865 | |
ab87f8c8 | 1866 | VA_START (ap, msgid); |
e0e2a8da | 1867 | |
5148a72b | 1868 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 1869 | insn = va_arg (ap, rtx); |
ab87f8c8 | 1870 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
1871 | #endif |
1872 | ||
ab87f8c8 | 1873 | v_error_for_asm (insn, msgid, ap); |
eb711c86 | 1874 | va_end (ap); |
4291d9c8 RS |
1875 | } |
1876 | ||
eb711c86 | 1877 | /* Report an error at the current line number. */ |
4291d9c8 | 1878 | |
eb711c86 | 1879 | static void |
ab87f8c8 JL |
1880 | verror (msgid, ap) |
1881 | const char *msgid; | |
eb711c86 | 1882 | va_list ap; |
4291d9c8 | 1883 | { |
ab87f8c8 | 1884 | v_error_with_file_and_line (input_filename, lineno, msgid, ap); |
4291d9c8 RS |
1885 | } |
1886 | ||
eb711c86 | 1887 | void |
ab87f8c8 | 1888 | error VPROTO((const char *msgid, ...)) |
eb711c86 | 1889 | { |
5148a72b | 1890 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 1891 | const char *msgid; |
e0e2a8da RK |
1892 | #endif |
1893 | va_list ap; | |
1894 | ||
ab87f8c8 | 1895 | VA_START (ap, msgid); |
eb711c86 | 1896 | |
5148a72b | 1897 | #ifndef ANSI_PROTOTYPES |
1c5d09e4 | 1898 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
1899 | #endif |
1900 | ||
ab87f8c8 | 1901 | verror (msgid, ap); |
eb711c86 RK |
1902 | va_end (ap); |
1903 | } | |
1904 | ||
1905 | /* Report a fatal error at the current line number. */ | |
1906 | ||
1907 | static void | |
ab87f8c8 JL |
1908 | vfatal (msgid, ap) |
1909 | const char *msgid; | |
eb711c86 RK |
1910 | va_list ap; |
1911 | { | |
ab87f8c8 | 1912 | verror (msgid, ap); |
299846f2 | 1913 | exit (FATAL_EXIT_CODE); |
eb711c86 | 1914 | } |
4291d9c8 RS |
1915 | |
1916 | void | |
ab87f8c8 | 1917 | fatal VPROTO((const char *msgid, ...)) |
eb711c86 | 1918 | { |
5148a72b | 1919 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 1920 | const char *msgid; |
e0e2a8da RK |
1921 | #endif |
1922 | va_list ap; | |
1923 | ||
ab87f8c8 | 1924 | VA_START (ap, msgid); |
eb711c86 | 1925 | |
5148a72b | 1926 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 1927 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
1928 | #endif |
1929 | ||
ab87f8c8 | 1930 | vfatal (msgid, ap); |
eb711c86 RK |
1931 | va_end (ap); |
1932 | } | |
1933 | ||
1934 | /* Report a warning at line LINE of file FILE. */ | |
1935 | ||
1936 | static void | |
ab87f8c8 | 1937 | v_warning_with_file_and_line (file, line, msgid, ap) |
87e11268 | 1938 | const char *file; |
eb711c86 | 1939 | int line; |
ab87f8c8 | 1940 | const char *msgid; |
eb711c86 | 1941 | va_list ap; |
4291d9c8 | 1942 | { |
eb711c86 RK |
1943 | if (count_error (1)) |
1944 | { | |
1945 | report_error_function (file); | |
ab87f8c8 | 1946 | v_message_with_file_and_line (file, line, 1, msgid, ap); |
eb711c86 RK |
1947 | } |
1948 | } | |
4291d9c8 | 1949 | |
eb711c86 | 1950 | void |
87e11268 | 1951 | warning_with_file_and_line VPROTO((const char *file, int line, |
ab87f8c8 | 1952 | const char *msgid, ...)) |
eb711c86 | 1953 | { |
5148a72b | 1954 | #ifndef ANSI_PROTOTYPES |
87e11268 | 1955 | const char *file; |
eb711c86 | 1956 | int line; |
ab87f8c8 | 1957 | const char *msgid; |
e0e2a8da RK |
1958 | #endif |
1959 | va_list ap; | |
1960 | ||
ab87f8c8 | 1961 | VA_START (ap, msgid); |
eb711c86 | 1962 | |
5148a72b | 1963 | #ifndef ANSI_PROTOTYPES |
87e11268 | 1964 | file = va_arg (ap, const char *); |
eb711c86 | 1965 | line = va_arg (ap, int); |
ab87f8c8 | 1966 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
1967 | #endif |
1968 | ||
ab87f8c8 | 1969 | v_warning_with_file_and_line (file, line, msgid, ap); |
eb711c86 RK |
1970 | va_end (ap); |
1971 | } | |
4291d9c8 | 1972 | |
eb711c86 | 1973 | /* Report a warning at the declaration DECL. |
ab87f8c8 | 1974 | MSGID is a format string which uses %s to substitute the declaration |
eb711c86 | 1975 | name; subsequent substitutions are a la printf. */ |
4291d9c8 | 1976 | |
eb711c86 | 1977 | static void |
ab87f8c8 | 1978 | v_warning_with_decl (decl, msgid, ap) |
eb711c86 | 1979 | tree decl; |
ab87f8c8 | 1980 | const char *msgid; |
eb711c86 RK |
1981 | va_list ap; |
1982 | { | |
1983 | if (count_error (1)) | |
1984 | { | |
1985 | report_error_function (DECL_SOURCE_FILE (decl)); | |
ab87f8c8 | 1986 | v_message_with_decl (decl, 1, msgid, ap); |
eb711c86 RK |
1987 | } |
1988 | } | |
4291d9c8 | 1989 | |
eb711c86 | 1990 | void |
ab87f8c8 | 1991 | warning_with_decl VPROTO((tree decl, const char *msgid, ...)) |
eb711c86 | 1992 | { |
5148a72b | 1993 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 1994 | tree decl; |
ab87f8c8 | 1995 | const char *msgid; |
e0e2a8da RK |
1996 | #endif |
1997 | va_list ap; | |
eb711c86 | 1998 | |
ab87f8c8 | 1999 | VA_START (ap, msgid); |
e0e2a8da | 2000 | |
5148a72b | 2001 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 2002 | decl = va_arg (ap, tree); |
ab87f8c8 | 2003 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
2004 | #endif |
2005 | ||
ab87f8c8 | 2006 | v_warning_with_decl (decl, msgid, ap); |
eb711c86 | 2007 | va_end (ap); |
4291d9c8 RS |
2008 | } |
2009 | ||
2010 | /* Report a warning at the line number of the insn INSN. | |
4291d9c8 RS |
2011 | This is used only when INSN is an `asm' with operands, |
2012 | and each ASM_OPERANDS records its own source file and line. */ | |
2013 | ||
eb711c86 | 2014 | static void |
ab87f8c8 | 2015 | v_warning_for_asm (insn, msgid, ap) |
4291d9c8 | 2016 | rtx insn; |
ab87f8c8 | 2017 | const char *msgid; |
eb711c86 | 2018 | va_list ap; |
4291d9c8 | 2019 | { |
eb711c86 RK |
2020 | if (count_error (1)) |
2021 | { | |
2022 | char *file; | |
2023 | int line; | |
4291d9c8 | 2024 | |
eb711c86 RK |
2025 | file_and_line_for_asm (insn, &file, &line); |
2026 | report_error_function (file); | |
ab87f8c8 | 2027 | v_message_with_file_and_line (file, line, 1, msgid, ap); |
eb711c86 RK |
2028 | } |
2029 | } | |
4291d9c8 | 2030 | |
eb711c86 | 2031 | void |
ab87f8c8 | 2032 | warning_for_asm VPROTO((rtx insn, const char *msgid, ...)) |
eb711c86 | 2033 | { |
5148a72b | 2034 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 2035 | rtx insn; |
ab87f8c8 | 2036 | const char *msgid; |
e0e2a8da RK |
2037 | #endif |
2038 | va_list ap; | |
2039 | ||
ab87f8c8 | 2040 | VA_START (ap, msgid); |
eb711c86 | 2041 | |
5148a72b | 2042 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 2043 | insn = va_arg (ap, rtx); |
ab87f8c8 | 2044 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
2045 | #endif |
2046 | ||
ab87f8c8 | 2047 | v_warning_for_asm (insn, msgid, ap); |
eb711c86 RK |
2048 | va_end (ap); |
2049 | } | |
4291d9c8 | 2050 | |
eb711c86 RK |
2051 | /* Report a warning at the current line number. */ |
2052 | ||
2053 | static void | |
ab87f8c8 JL |
2054 | vwarning (msgid, ap) |
2055 | const char *msgid; | |
eb711c86 RK |
2056 | va_list ap; |
2057 | { | |
ab87f8c8 | 2058 | v_warning_with_file_and_line (input_filename, lineno, msgid, ap); |
4291d9c8 | 2059 | } |
eb711c86 RK |
2060 | |
2061 | void | |
ab87f8c8 | 2062 | warning VPROTO((const char *msgid, ...)) |
eb711c86 | 2063 | { |
5148a72b | 2064 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 2065 | const char *msgid; |
e0e2a8da RK |
2066 | #endif |
2067 | va_list ap; | |
2068 | ||
ab87f8c8 | 2069 | VA_START (ap, msgid); |
eb711c86 | 2070 | |
5148a72b | 2071 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 2072 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
2073 | #endif |
2074 | ||
ab87f8c8 | 2075 | vwarning (msgid, ap); |
eb711c86 RK |
2076 | va_end (ap); |
2077 | } | |
2078 | ||
4291d9c8 RS |
2079 | /* These functions issue either warnings or errors depending on |
2080 | -pedantic-errors. */ | |
2081 | ||
eb711c86 | 2082 | static void |
ab87f8c8 JL |
2083 | vpedwarn (msgid, ap) |
2084 | const char *msgid; | |
eb711c86 | 2085 | va_list ap; |
4291d9c8 RS |
2086 | { |
2087 | if (flag_pedantic_errors) | |
ab87f8c8 | 2088 | verror (msgid, ap); |
4291d9c8 | 2089 | else |
ab87f8c8 | 2090 | vwarning (msgid, ap); |
4291d9c8 RS |
2091 | } |
2092 | ||
2093 | void | |
ab87f8c8 | 2094 | pedwarn VPROTO((const char *msgid, ...)) |
eb711c86 | 2095 | { |
5148a72b | 2096 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 2097 | const char *msgid; |
e0e2a8da RK |
2098 | #endif |
2099 | va_list ap; | |
2100 | ||
ab87f8c8 | 2101 | VA_START (ap, msgid); |
eb711c86 | 2102 | |
5148a72b | 2103 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 2104 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
2105 | #endif |
2106 | ||
ab87f8c8 | 2107 | vpedwarn (msgid, ap); |
eb711c86 RK |
2108 | va_end (ap); |
2109 | } | |
2110 | ||
2111 | static void | |
ab87f8c8 | 2112 | v_pedwarn_with_decl (decl, msgid, ap) |
4291d9c8 | 2113 | tree decl; |
ab87f8c8 | 2114 | const char *msgid; |
eb711c86 | 2115 | va_list ap; |
4291d9c8 | 2116 | { |
1554cdf5 DE |
2117 | /* We don't want -pedantic-errors to cause the compilation to fail from |
2118 | "errors" in system header files. Sometimes fixincludes can't fix what's | |
2119 | broken (eg: unsigned char bitfields - fixing it may change the alignment | |
2120 | which will cause programs to mysteriously fail because the C library | |
22d74562 DE |
2121 | or kernel uses the original layout). There's no point in issuing a |
2122 | warning either, it's just unnecessary noise. */ | |
1554cdf5 | 2123 | |
22d74562 DE |
2124 | if (! DECL_IN_SYSTEM_HEADER (decl)) |
2125 | { | |
2126 | if (flag_pedantic_errors) | |
ab87f8c8 | 2127 | v_error_with_decl (decl, msgid, ap); |
22d74562 | 2128 | else |
ab87f8c8 | 2129 | v_warning_with_decl (decl, msgid, ap); |
22d74562 | 2130 | } |
4291d9c8 RS |
2131 | } |
2132 | ||
2133 | void | |
ab87f8c8 | 2134 | pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...)) |
eb711c86 | 2135 | { |
5148a72b | 2136 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 2137 | tree decl; |
ab87f8c8 | 2138 | const char *msgid; |
e0e2a8da RK |
2139 | #endif |
2140 | va_list ap; | |
eb711c86 | 2141 | |
ab87f8c8 | 2142 | VA_START (ap, msgid); |
e0e2a8da | 2143 | |
5148a72b | 2144 | #ifndef ANSI_PROTOTYPES |
eb711c86 | 2145 | decl = va_arg (ap, tree); |
ab87f8c8 | 2146 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
2147 | #endif |
2148 | ||
ab87f8c8 | 2149 | v_pedwarn_with_decl (decl, msgid, ap); |
eb711c86 RK |
2150 | va_end (ap); |
2151 | } | |
2152 | ||
2153 | static void | |
ab87f8c8 | 2154 | v_pedwarn_with_file_and_line (file, line, msgid, ap) |
87e11268 | 2155 | const char *file; |
4291d9c8 | 2156 | int line; |
ab87f8c8 | 2157 | const char *msgid; |
eb711c86 | 2158 | va_list ap; |
4291d9c8 RS |
2159 | { |
2160 | if (flag_pedantic_errors) | |
ab87f8c8 | 2161 | v_error_with_file_and_line (file, line, msgid, ap); |
4291d9c8 | 2162 | else |
ab87f8c8 | 2163 | v_warning_with_file_and_line (file, line, msgid, ap); |
4291d9c8 RS |
2164 | } |
2165 | ||
4291d9c8 | 2166 | void |
87e11268 | 2167 | pedwarn_with_file_and_line VPROTO((const char *file, int line, |
ab87f8c8 | 2168 | const char *msgid, ...)) |
eb711c86 | 2169 | { |
5148a72b | 2170 | #ifndef ANSI_PROTOTYPES |
87e11268 | 2171 | const char *file; |
eb711c86 | 2172 | int line; |
ab87f8c8 | 2173 | const char *msgid; |
e0e2a8da RK |
2174 | #endif |
2175 | va_list ap; | |
eb711c86 | 2176 | |
ab87f8c8 | 2177 | VA_START (ap, msgid); |
e0e2a8da | 2178 | |
5148a72b | 2179 | #ifndef ANSI_PROTOTYPES |
87e11268 | 2180 | file = va_arg (ap, const char *); |
eb711c86 | 2181 | line = va_arg (ap, int); |
ab87f8c8 | 2182 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
2183 | #endif |
2184 | ||
ab87f8c8 | 2185 | v_pedwarn_with_file_and_line (file, line, msgid, ap); |
eb711c86 RK |
2186 | va_end (ap); |
2187 | } | |
2188 | ||
2189 | /* Apologize for not implementing some feature. */ | |
2190 | ||
2191 | static void | |
ab87f8c8 JL |
2192 | vsorry (msgid, ap) |
2193 | const char *msgid; | |
eb711c86 | 2194 | va_list ap; |
4291d9c8 RS |
2195 | { |
2196 | sorrycount++; | |
2197 | if (input_filename) | |
2198 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
2199 | else | |
2200 | fprintf (stderr, "%s: ", progname); | |
ab87f8c8 JL |
2201 | notice ("sorry, not implemented: "); |
2202 | vnotice (stderr, msgid, ap); | |
eb711c86 RK |
2203 | fputc ('\n', stderr); |
2204 | } | |
4291d9c8 | 2205 | |
eb711c86 | 2206 | void |
ab87f8c8 | 2207 | sorry VPROTO((const char *msgid, ...)) |
eb711c86 | 2208 | { |
5148a72b | 2209 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 2210 | const char *msgid; |
e0e2a8da RK |
2211 | #endif |
2212 | va_list ap; | |
2213 | ||
ab87f8c8 | 2214 | VA_START (ap, msgid); |
eb711c86 | 2215 | |
5148a72b | 2216 | #ifndef ANSI_PROTOTYPES |
ab87f8c8 | 2217 | msgid = va_arg (ap, const char *); |
e0e2a8da RK |
2218 | #endif |
2219 | ||
ab87f8c8 | 2220 | vsorry (msgid, ap); |
eb711c86 RK |
2221 | va_end (ap); |
2222 | } | |
4291d9c8 RS |
2223 | \f |
2224 | /* More 'friendly' abort that prints the line and file. | |
2225 | config.h can #define abort fancy_abort if you like that sort of thing. | |
2226 | ||
2227 | I don't think this is actually a good idea. | |
2228 | Other sorts of crashes will look a certain way. | |
2229 | It is a good thing if crashes from calling abort look the same way. | |
2230 | -- RMS */ | |
2231 | ||
2232 | void | |
2233 | fancy_abort () | |
2234 | { | |
2235 | fatal ("internal gcc abort"); | |
2236 | } | |
2237 | ||
2238 | /* This calls abort and is used to avoid problems when abort if a macro. | |
2239 | It is used when we need to pass the address of abort. */ | |
2240 | ||
2241 | void | |
2242 | do_abort () | |
2243 | { | |
2244 | abort (); | |
2245 | } | |
2246 | ||
2247 | /* When `malloc.c' is compiled with `rcheck' defined, | |
2248 | it calls this function to report clobberage. */ | |
2249 | ||
2250 | void | |
2251 | botch (s) | |
87e11268 | 2252 | const char * s ATTRIBUTE_UNUSED; |
4291d9c8 RS |
2253 | { |
2254 | abort (); | |
2255 | } | |
2256 | ||
2257 | /* Same as `malloc' but report error if no memory available. */ | |
2258 | ||
2778b98d | 2259 | PTR |
4291d9c8 | 2260 | xmalloc (size) |
2778b98d | 2261 | size_t size; |
4291d9c8 | 2262 | { |
2778b98d | 2263 | register PTR value; |
848205e6 MM |
2264 | |
2265 | if (size == 0) | |
2266 | size = 1; | |
2267 | ||
2778b98d | 2268 | value = (PTR) malloc (size); |
848205e6 MM |
2269 | if (value == 0) |
2270 | fatal ("virtual memory exhausted"); | |
2271 | return value; | |
2272 | } | |
2273 | ||
2274 | /* Same as `calloc' but report error if no memory available. */ | |
2275 | ||
2778b98d | 2276 | PTR |
848205e6 | 2277 | xcalloc (size1, size2) |
2778b98d | 2278 | size_t size1, size2; |
848205e6 | 2279 | { |
2778b98d | 2280 | register PTR value; |
848205e6 MM |
2281 | |
2282 | if (size1 == 0 || size2 == 0) | |
2283 | size1 = size2 = 1; | |
2284 | ||
2778b98d | 2285 | value = (PTR) calloc (size1, size2); |
848205e6 | 2286 | if (value == 0) |
4291d9c8 RS |
2287 | fatal ("virtual memory exhausted"); |
2288 | return value; | |
2289 | } | |
2290 | ||
848205e6 | 2291 | |
e9a25f70 JL |
2292 | /* Same as `realloc' but report error if no memory available. |
2293 | Also handle null PTR even if the vendor realloc gets it wrong. */ | |
4291d9c8 | 2294 | |
2778b98d | 2295 | PTR |
4291d9c8 | 2296 | xrealloc (ptr, size) |
2778b98d KG |
2297 | PTR ptr; |
2298 | size_t size; | |
4291d9c8 | 2299 | { |
2778b98d | 2300 | register PTR result; |
848205e6 MM |
2301 | |
2302 | if (size == 0) | |
2303 | size = 1; | |
2304 | ||
2778b98d | 2305 | result = (ptr ? (PTR) realloc (ptr, size) : (PTR) malloc (size)); |
848205e6 | 2306 | |
4291d9c8 RS |
2307 | if (!result) |
2308 | fatal ("virtual memory exhausted"); | |
848205e6 | 2309 | |
4291d9c8 RS |
2310 | return result; |
2311 | } | |
3e386b9e RK |
2312 | |
2313 | /* Same as `strdup' but report error if no memory available. */ | |
2314 | ||
2315 | char * | |
2316 | xstrdup (s) | |
2778b98d | 2317 | register const char *s; |
3e386b9e RK |
2318 | { |
2319 | register char *result = (char *) malloc (strlen (s) + 1); | |
2320 | ||
2321 | if (! result) | |
2322 | fatal ("virtual memory exhausted"); | |
2323 | strcpy (result, s); | |
2324 | return result; | |
2325 | } | |
4291d9c8 RS |
2326 | \f |
2327 | /* Return the logarithm of X, base 2, considering X unsigned, | |
37366632 RK |
2328 | if X is a power of 2. Otherwise, returns -1. |
2329 | ||
2330 | This should be used via the `exact_log2' macro. */ | |
4291d9c8 RS |
2331 | |
2332 | int | |
37366632 RK |
2333 | exact_log2_wide (x) |
2334 | register unsigned HOST_WIDE_INT x; | |
4291d9c8 RS |
2335 | { |
2336 | register int log = 0; | |
2337 | /* Test for 0 or a power of 2. */ | |
2338 | if (x == 0 || x != (x & -x)) | |
2339 | return -1; | |
2340 | while ((x >>= 1) != 0) | |
2341 | log++; | |
2342 | return log; | |
2343 | } | |
2344 | ||
2345 | /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. | |
37366632 RK |
2346 | If X is 0, return -1. |
2347 | ||
2348 | This should be used via the floor_log2 macro. */ | |
4291d9c8 RS |
2349 | |
2350 | int | |
37366632 RK |
2351 | floor_log2_wide (x) |
2352 | register unsigned HOST_WIDE_INT x; | |
4291d9c8 RS |
2353 | { |
2354 | register int log = -1; | |
2355 | while (x != 0) | |
2356 | log++, | |
2357 | x >>= 1; | |
2358 | return log; | |
2359 | } | |
2360 | ||
3bbfa296 | 2361 | static int float_handler_set; |
4291d9c8 RS |
2362 | int float_handled; |
2363 | jmp_buf float_handler; | |
2364 | ||
3bbfa296 RK |
2365 | /* Signals actually come here. */ |
2366 | ||
2367 | static void | |
2368 | float_signal (signo) | |
2369 | /* If this is missing, some compilers complain. */ | |
d6f4ec51 | 2370 | int signo ATTRIBUTE_UNUSED; |
3bbfa296 RK |
2371 | { |
2372 | if (float_handled == 0) | |
2373 | abort (); | |
2374 | #if defined (USG) || defined (hpux) | |
2375 | signal (SIGFPE, float_signal); /* re-enable the signal catcher */ | |
2376 | #endif | |
2377 | float_handled = 0; | |
2378 | signal (SIGFPE, float_signal); | |
2379 | longjmp (float_handler, 1); | |
2380 | } | |
2381 | ||
4291d9c8 RS |
2382 | /* Specify where to longjmp to when a floating arithmetic error happens. |
2383 | If HANDLER is 0, it means don't handle the errors any more. */ | |
2384 | ||
2385 | void | |
2386 | set_float_handler (handler) | |
2387 | jmp_buf handler; | |
2388 | { | |
2389 | float_handled = (handler != 0); | |
2390 | if (handler) | |
4c9a05bc | 2391 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); |
3bbfa296 RK |
2392 | |
2393 | if (float_handled && ! float_handler_set) | |
2394 | { | |
2395 | signal (SIGFPE, float_signal); | |
2396 | float_handler_set = 1; | |
2397 | } | |
4291d9c8 RS |
2398 | } |
2399 | ||
1a87eea2 KG |
2400 | /* This is a wrapper function for code which might elicit an |
2401 | arithmetic exception. That code should be passed in as a function | |
2402 | pointer FN, and one argument DATA. DATA is usually a struct which | |
2403 | contains the real input and output for function FN. This function | |
2404 | returns 0 (failure) if longjmp was called (i.e. an exception | |
2405 | occured.) It returns 1 (success) otherwise. */ | |
2406 | ||
2407 | int | |
2408 | do_float_handler (fn, data) | |
2409 | void (*fn) PROTO ((PTR)); | |
2410 | PTR data; | |
2411 | { | |
2412 | jmp_buf buf; | |
2413 | ||
2414 | if (setjmp (buf)) | |
2415 | { | |
2416 | /* We got here via longjmp() caused by an exception in function fn() */ | |
2417 | set_float_handler (NULL); | |
2418 | return 0; | |
2419 | } | |
2420 | ||
2421 | set_float_handler (buf); | |
2422 | (*fn)(data); | |
2423 | set_float_handler (NULL); | |
2424 | return 1; | |
2425 | } | |
2426 | ||
bff4b641 RS |
2427 | /* Specify, in HANDLER, where to longjmp to when a floating arithmetic |
2428 | error happens, pushing the previous specification into OLD_HANDLER. | |
2429 | Return an indication of whether there was a previous handler in effect. */ | |
2430 | ||
2431 | int | |
2432 | push_float_handler (handler, old_handler) | |
dc2b15dc | 2433 | jmp_buf handler, old_handler; |
bff4b641 RS |
2434 | { |
2435 | int was_handled = float_handled; | |
2436 | ||
2437 | float_handled = 1; | |
2438 | if (was_handled) | |
7e2231e7 | 2439 | memcpy ((char *) old_handler, (char *) float_handler, |
4c9a05bc RK |
2440 | sizeof (float_handler)); |
2441 | ||
7e2231e7 | 2442 | memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler)); |
bff4b641 RS |
2443 | return was_handled; |
2444 | } | |
2445 | ||
2446 | /* Restore the previous specification of whether and where to longjmp to | |
2447 | when a floating arithmetic error happens. */ | |
2448 | ||
2449 | void | |
2450 | pop_float_handler (handled, handler) | |
2451 | int handled; | |
2452 | jmp_buf handler; | |
2453 | { | |
2454 | float_handled = handled; | |
2455 | if (handled) | |
4c9a05bc | 2456 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); |
bff4b641 RS |
2457 | } |
2458 | ||
4291d9c8 RS |
2459 | /* Handler for SIGPIPE. */ |
2460 | ||
2461 | static void | |
2462 | pipe_closed (signo) | |
2463 | /* If this is missing, some compilers complain. */ | |
d6f4ec51 | 2464 | int signo ATTRIBUTE_UNUSED; |
4291d9c8 RS |
2465 | { |
2466 | fatal ("output pipe has been closed"); | |
2467 | } | |
2468 | ||
2469 | /* Strip off a legitimate source ending from the input string NAME of | |
c62bdc79 | 2470 | length LEN. Rather than having to know the names used by all of |
2290e0ec PB |
2471 | our front ends, we strip off an ending of a period followed by |
2472 | up to five characters. (Java uses ".class".) */ | |
4291d9c8 RS |
2473 | |
2474 | void | |
2475 | strip_off_ending (name, len) | |
2476 | char *name; | |
2477 | int len; | |
2478 | { | |
2290e0ec PB |
2479 | int i; |
2480 | for (i = 2; i < 6 && len > i; i++) | |
2481 | { | |
2482 | if (name[len - i] == '.') | |
2483 | { | |
2484 | name[len - i] = '\0'; | |
2485 | break; | |
2486 | } | |
2487 | } | |
4291d9c8 RS |
2488 | } |
2489 | ||
7dce5088 | 2490 | /* Output a quoted string. */ |
0f41302f | 2491 | |
7dce5088 PE |
2492 | void |
2493 | output_quoted_string (asm_file, string) | |
2494 | FILE *asm_file; | |
87e11268 | 2495 | const char *string; |
7dce5088 | 2496 | { |
e9a25f70 JL |
2497 | #ifdef OUTPUT_QUOTED_STRING |
2498 | OUTPUT_QUOTED_STRING (asm_file, string); | |
2499 | #else | |
7dce5088 PE |
2500 | char c; |
2501 | ||
2502 | putc ('\"', asm_file); | |
2503 | while ((c = *string++) != 0) | |
2504 | { | |
2505 | if (c == '\"' || c == '\\') | |
2506 | putc ('\\', asm_file); | |
2507 | putc (c, asm_file); | |
2508 | } | |
2509 | putc ('\"', asm_file); | |
e9a25f70 | 2510 | #endif |
7dce5088 PE |
2511 | } |
2512 | ||
4291d9c8 RS |
2513 | /* Output a file name in the form wanted by System V. */ |
2514 | ||
2515 | void | |
2516 | output_file_directive (asm_file, input_name) | |
2517 | FILE *asm_file; | |
87e11268 | 2518 | const char *input_name; |
4291d9c8 RS |
2519 | { |
2520 | int len = strlen (input_name); | |
87e11268 | 2521 | const char *na = input_name + len; |
4291d9c8 RS |
2522 | |
2523 | /* NA gets INPUT_NAME sans directory names. */ | |
2524 | while (na > input_name) | |
2525 | { | |
73532e43 JL |
2526 | if (na[-1] == '/') |
2527 | break; | |
2528 | #ifdef DIR_SEPARATOR | |
fed3e408 | 2529 | if (na[-1] == DIR_SEPARATOR) |
4291d9c8 | 2530 | break; |
73532e43 | 2531 | #endif |
4291d9c8 RS |
2532 | na--; |
2533 | } | |
2534 | ||
2535 | #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME | |
2536 | ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na); | |
2537 | #else | |
2538 | #ifdef ASM_OUTPUT_SOURCE_FILENAME | |
2539 | ASM_OUTPUT_SOURCE_FILENAME (asm_file, na); | |
2540 | #else | |
7dce5088 PE |
2541 | fprintf (asm_file, "\t.file\t"); |
2542 | output_quoted_string (asm_file, na); | |
2543 | fputc ('\n', asm_file); | |
4291d9c8 RS |
2544 | #endif |
2545 | #endif | |
2546 | } | |
2547 | \f | |
444bf316 | 2548 | #ifdef ASM_IDENTIFY_LANGUAGE |
0f41302f | 2549 | /* Routine to build language identifier for object file. */ |
d0d4af87 MS |
2550 | static void |
2551 | output_lang_identify (asm_out_file) | |
2552 | FILE *asm_out_file; | |
2553 | { | |
2554 | int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1; | |
2555 | char *s = (char *) alloca (len); | |
2556 | sprintf (s, "__gnu_compiled_%s", lang_identify ()); | |
2557 | ASM_OUTPUT_LABEL (asm_out_file, s); | |
2558 | } | |
444bf316 | 2559 | #endif |
d0d4af87 | 2560 | |
dfe1a916 | 2561 | /* Routine to open a dump file. */ |
032713aa NC |
2562 | static void |
2563 | open_dump_file (suffix, function_name) | |
87e11268 KG |
2564 | const char *suffix; |
2565 | const char *function_name; | |
032713aa NC |
2566 | { |
2567 | char *dumpname; | |
0f41302f | 2568 | |
032713aa NC |
2569 | TIMEVAR |
2570 | (dump_time, | |
2571 | { | |
2572 | dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1); | |
2573 | ||
2574 | if (rtl_dump_file != NULL) | |
2575 | fclose (rtl_dump_file); | |
2576 | ||
2577 | strcpy (dumpname, dump_base_name); | |
2578 | strcat (dumpname, suffix); | |
2579 | ||
2580 | rtl_dump_file = fopen (dumpname, "a"); | |
2581 | ||
2582 | if (rtl_dump_file == NULL) | |
2583 | pfatal_with_name (dumpname); | |
2584 | ||
2585 | free (dumpname); | |
2586 | ||
2587 | if (function_name) | |
2588 | fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name); | |
2589 | }); | |
2590 | ||
2591 | return; | |
2592 | } | |
2593 | ||
2594 | /* Routine to close a dump file. */ | |
2595 | static void | |
2596 | close_dump_file (func, insns) | |
eed90b2c | 2597 | void (*func) PROTO ((FILE *, rtx)); |
032713aa NC |
2598 | rtx insns; |
2599 | { | |
2600 | TIMEVAR | |
2601 | (dump_time, | |
2602 | { | |
2603 | if (func) | |
2604 | func (rtl_dump_file, insns); | |
2605 | ||
2606 | fflush (rtl_dump_file); | |
2607 | fclose (rtl_dump_file); | |
2608 | ||
2609 | rtl_dump_file = NULL; | |
2610 | }); | |
2611 | ||
2612 | return; | |
2613 | } | |
2614 | ||
2615 | /* Routine to dump rtl into a file. */ | |
2616 | static void | |
2617 | dump_rtl (suffix, decl, func, insns) | |
87e11268 | 2618 | const char *suffix; |
032713aa | 2619 | tree decl; |
eed90b2c | 2620 | void (*func) PROTO ((FILE *, rtx)); |
032713aa | 2621 | rtx insns; |
dfe1a916 | 2622 | { |
032713aa NC |
2623 | open_dump_file (suffix, decl_printable_name (decl, 2)); |
2624 | close_dump_file (func, insns); | |
2625 | } | |
2626 | ||
2627 | /* Routine to empty a dump file. */ | |
2628 | static void | |
2629 | clean_dump_file (suffix) | |
87e11268 | 2630 | const char *suffix; |
032713aa | 2631 | { |
6f4d7222 | 2632 | char *dumpname; |
dfe1a916 | 2633 | |
032713aa NC |
2634 | dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1); |
2635 | ||
2636 | strcpy (dumpname, dump_base_name); | |
dfe1a916 | 2637 | strcat (dumpname, suffix); |
032713aa NC |
2638 | |
2639 | rtl_dump_file = fopen (dumpname, "w"); | |
2640 | ||
2641 | if (rtl_dump_file == NULL) | |
2642 | pfatal_with_name (dumpname); | |
2643 | ||
2644 | free (dumpname); | |
2645 | ||
2646 | fclose (rtl_dump_file); | |
2647 | rtl_dump_file = NULL; | |
2648 | ||
2649 | return; | |
dfe1a916 DE |
2650 | } |
2651 | ||
032713aa | 2652 | |
4291d9c8 RS |
2653 | /* Compile an entire file of output from cpp, named NAME. |
2654 | Write a file of assembly output and various debugging dumps. */ | |
2655 | ||
2656 | static void | |
2657 | compile_file (name) | |
2658 | char *name; | |
2659 | { | |
2660 | tree globals; | |
2661 | int start_time; | |
4291d9c8 RS |
2662 | |
2663 | int name_specified = name != 0; | |
2664 | ||
2665 | if (dump_base_name == 0) | |
2666 | dump_base_name = name ? name : "gccdump"; | |
4291d9c8 RS |
2667 | |
2668 | parse_time = 0; | |
2669 | varconst_time = 0; | |
2670 | integration_time = 0; | |
2671 | jump_time = 0; | |
2672 | cse_time = 0; | |
7506f491 | 2673 | gcse_time = 0; |
4291d9c8 RS |
2674 | loop_time = 0; |
2675 | cse2_time = 0; | |
0d332add | 2676 | branch_prob_time = 0; |
4291d9c8 RS |
2677 | flow_time = 0; |
2678 | combine_time = 0; | |
8c660648 | 2679 | regmove_time = 0; |
4291d9c8 RS |
2680 | sched_time = 0; |
2681 | local_alloc_time = 0; | |
2682 | global_alloc_time = 0; | |
e881bb1b | 2683 | flow2_time = 0; |
4291d9c8 | 2684 | sched2_time = 0; |
bd334356 | 2685 | #ifdef DELAY_SLOTS |
4291d9c8 | 2686 | dbr_sched_time = 0; |
bd334356 | 2687 | #endif |
4291d9c8 RS |
2688 | shorten_branch_time = 0; |
2689 | stack_reg_time = 0; | |
2690 | final_time = 0; | |
2691 | symout_time = 0; | |
2692 | dump_time = 0; | |
2693 | ||
4291d9c8 RS |
2694 | /* Initialize data in various passes. */ |
2695 | ||
2696 | init_obstacks (); | |
2697 | init_tree_codes (); | |
5c60e5c0 | 2698 | name = init_parse (name); |
4291d9c8 RS |
2699 | init_rtl (); |
2700 | init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL | |
0d332add DE |
2701 | || debug_info_level == DINFO_LEVEL_VERBOSE |
2702 | || flag_test_coverage); | |
7f21d440 | 2703 | init_regs (); |
4291d9c8 RS |
2704 | init_decl_processing (); |
2705 | init_optabs (); | |
2706 | init_stmt (); | |
2707 | init_expmed (); | |
4fa52007 | 2708 | init_expr_once (); |
4291d9c8 RS |
2709 | init_loop (); |
2710 | init_reload (); | |
6e73e666 | 2711 | init_alias_once (); |
4291d9c8 RS |
2712 | |
2713 | if (flag_caller_saves) | |
2714 | init_caller_save (); | |
2715 | ||
f246a305 RS |
2716 | /* If auxiliary info generation is desired, open the output file. |
2717 | This goes in the same directory as the source file--unlike | |
2718 | all the other output files. */ | |
4291d9c8 RS |
2719 | if (flag_gen_aux_info) |
2720 | { | |
4291d9c8 RS |
2721 | aux_info_file = fopen (aux_info_file_name, "w"); |
2722 | if (aux_info_file == 0) | |
2723 | pfatal_with_name (aux_info_file_name); | |
2724 | } | |
2725 | ||
735a0e33 | 2726 | /* Clear the dump files. */ |
4291d9c8 | 2727 | if (rtl_dump) |
032713aa | 2728 | clean_dump_file (".rtl"); |
4291d9c8 | 2729 | if (jump_opt_dump) |
735a0e33 UD |
2730 | { |
2731 | clean_dump_file (".jump"); | |
2732 | if (graph_dump_format != no_graph) | |
2733 | clean_graph_dump_file (dump_base_name, ".jump"); | |
2734 | } | |
e9a25f70 | 2735 | if (addressof_dump) |
735a0e33 UD |
2736 | { |
2737 | clean_dump_file (".addressof"); | |
2738 | if (graph_dump_format != no_graph) | |
2739 | clean_graph_dump_file (dump_base_name, ".addressof"); | |
2740 | } | |
4291d9c8 | 2741 | if (cse_dump) |
735a0e33 UD |
2742 | { |
2743 | clean_dump_file (".cse"); | |
2744 | if (graph_dump_format != no_graph) | |
2745 | clean_graph_dump_file (dump_base_name, ".cse"); | |
2746 | } | |
4291d9c8 | 2747 | if (loop_dump) |
735a0e33 UD |
2748 | { |
2749 | clean_dump_file (".loop"); | |
2750 | if (graph_dump_format != no_graph) | |
2751 | clean_graph_dump_file (dump_base_name, ".loop"); | |
2752 | } | |
4291d9c8 | 2753 | if (cse2_dump) |
735a0e33 UD |
2754 | { |
2755 | clean_dump_file (".cse2"); | |
2756 | if (graph_dump_format != no_graph) | |
2757 | clean_graph_dump_file (dump_base_name, ".cse2"); | |
2758 | } | |
0d332add | 2759 | if (branch_prob_dump) |
735a0e33 UD |
2760 | { |
2761 | clean_dump_file (".bp"); | |
2762 | if (graph_dump_format != no_graph) | |
2763 | clean_graph_dump_file (dump_base_name, ".bp"); | |
2764 | } | |
4291d9c8 | 2765 | if (flow_dump) |
735a0e33 UD |
2766 | { |
2767 | clean_dump_file (".flow"); | |
2768 | if (graph_dump_format != no_graph) | |
2769 | clean_graph_dump_file (dump_base_name, ".flow"); | |
2770 | } | |
4291d9c8 | 2771 | if (combine_dump) |
735a0e33 UD |
2772 | { |
2773 | clean_dump_file (".combine"); | |
2774 | if (graph_dump_format != no_graph) | |
2775 | clean_graph_dump_file (dump_base_name, ".combine"); | |
2776 | } | |
8c660648 | 2777 | if (regmove_dump) |
735a0e33 UD |
2778 | { |
2779 | clean_dump_file (".regmove"); | |
2780 | if (graph_dump_format != no_graph) | |
2781 | clean_graph_dump_file (dump_base_name, ".regmove"); | |
2782 | } | |
4291d9c8 | 2783 | if (sched_dump) |
735a0e33 UD |
2784 | { |
2785 | clean_dump_file (".sched"); | |
2786 | if (graph_dump_format != no_graph) | |
2787 | clean_graph_dump_file (dump_base_name, ".sched"); | |
2788 | } | |
4291d9c8 | 2789 | if (local_reg_dump) |
735a0e33 UD |
2790 | { |
2791 | clean_dump_file (".lreg"); | |
2792 | if (graph_dump_format != no_graph) | |
2793 | clean_graph_dump_file (dump_base_name, ".lreg"); | |
2794 | } | |
4291d9c8 | 2795 | if (global_reg_dump) |
735a0e33 UD |
2796 | { |
2797 | clean_dump_file (".greg"); | |
2798 | if (graph_dump_format != no_graph) | |
2799 | clean_graph_dump_file (dump_base_name, ".greg"); | |
2800 | } | |
e881bb1b RH |
2801 | if (flow2_dump) |
2802 | { | |
2803 | clean_dump_file (".flow2"); | |
2804 | if (graph_dump_format != no_graph) | |
2805 | clean_graph_dump_file (dump_base_name, ".flow2"); | |
2806 | } | |
4291d9c8 | 2807 | if (sched2_dump) |
735a0e33 UD |
2808 | { |
2809 | clean_dump_file (".sched2"); | |
2810 | if (graph_dump_format != no_graph) | |
2811 | clean_graph_dump_file (dump_base_name, ".sched2"); | |
2812 | } | |
4291d9c8 | 2813 | if (jump2_opt_dump) |
735a0e33 UD |
2814 | { |
2815 | clean_dump_file (".jump2"); | |
2816 | if (graph_dump_format != no_graph) | |
2817 | clean_graph_dump_file (dump_base_name, ".jump2"); | |
2818 | } | |
bd334356 | 2819 | #ifdef DELAY_SLOTS |
4291d9c8 | 2820 | if (dbr_sched_dump) |
735a0e33 UD |
2821 | { |
2822 | clean_dump_file (".dbr"); | |
2823 | if (graph_dump_format != no_graph) | |
2824 | clean_graph_dump_file (dump_base_name, ".dbr"); | |
2825 | } | |
bd334356 | 2826 | #endif |
7506f491 | 2827 | if (gcse_dump) |
735a0e33 UD |
2828 | { |
2829 | clean_dump_file (".gcse"); | |
2830 | if (graph_dump_format != no_graph) | |
2831 | clean_graph_dump_file (dump_base_name, ".gcse"); | |
2832 | } | |
4291d9c8 | 2833 | #ifdef STACK_REGS |
4291d9c8 | 2834 | if (stack_reg_dump) |
735a0e33 UD |
2835 | { |
2836 | clean_dump_file (".stack"); | |
2837 | if (graph_dump_format != no_graph) | |
2838 | clean_graph_dump_file (dump_base_name, ".stack"); | |
2839 | } | |
032713aa NC |
2840 | #endif |
2841 | #ifdef MACHINE_DEPENDENT_REORG | |
2842 | if (mach_dep_reorg_dump) | |
735a0e33 UD |
2843 | { |
2844 | clean_dump_file (".mach"); | |
2845 | if (graph_dump_format != no_graph) | |
2846 | clean_graph_dump_file (dump_base_name, ".mach"); | |
2847 | } | |
4291d9c8 RS |
2848 | #endif |
2849 | ||
2850 | /* Open assembler code output file. */ | |
2851 | ||
1fe65c00 PB |
2852 | if (flag_syntax_only) |
2853 | asm_out_file = NULL; | |
4291d9c8 RS |
2854 | else |
2855 | { | |
1fe65c00 | 2856 | if (! name_specified && asm_file_name == 0) |
4291d9c8 RS |
2857 | asm_out_file = stdout; |
2858 | else | |
1fe65c00 PB |
2859 | { |
2860 | int len = strlen (dump_base_name); | |
2861 | register char *dumpname = (char *) xmalloc (len + 6); | |
2862 | strcpy (dumpname, dump_base_name); | |
2863 | strip_off_ending (dumpname, len); | |
2864 | strcat (dumpname, ".s"); | |
2865 | if (asm_file_name == 0) | |
2866 | { | |
2867 | asm_file_name = (char *) xmalloc (strlen (dumpname) + 1); | |
2868 | strcpy (asm_file_name, dumpname); | |
2869 | } | |
2870 | if (!strcmp (asm_file_name, "-")) | |
2871 | asm_out_file = stdout; | |
2872 | else | |
2873 | asm_out_file = fopen (asm_file_name, "w"); | |
2874 | if (asm_out_file == 0) | |
2875 | pfatal_with_name (asm_file_name); | |
2876 | } | |
4291d9c8 | 2877 | |
f246a305 | 2878 | #ifdef IO_BUFFER_SIZE |
1fe65c00 PB |
2879 | setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), |
2880 | _IOFBF, IO_BUFFER_SIZE); | |
f246a305 | 2881 | #endif |
1fe65c00 | 2882 | } |
f246a305 | 2883 | |
4291d9c8 RS |
2884 | input_filename = name; |
2885 | ||
18736654 RK |
2886 | /* Put an entry on the input file stack for the main input file. */ |
2887 | input_file_stack | |
2888 | = (struct file_stack *) xmalloc (sizeof (struct file_stack)); | |
2889 | input_file_stack->next = 0; | |
2890 | input_file_stack->name = input_filename; | |
2891 | ||
4291d9c8 RS |
2892 | /* Perform language-specific initialization. |
2893 | This may set main_input_filename. */ | |
2894 | lang_init (); | |
2895 | ||
2896 | /* If the input doesn't start with a #line, use the input name | |
2897 | as the official input file name. */ | |
2898 | if (main_input_filename == 0) | |
2899 | main_input_filename = name; | |
2900 | ||
1fe65c00 PB |
2901 | if (flag_syntax_only) |
2902 | { | |
2903 | write_symbols = NO_DEBUG; | |
2904 | profile_flag = 0; | |
2905 | profile_block_flag = 0; | |
2906 | } | |
2907 | else | |
2908 | { | |
2909 | ASM_FILE_START (asm_out_file); | |
3d5cdd42 DE |
2910 | |
2911 | #ifdef ASM_COMMENT_START | |
1fe65c00 PB |
2912 | if (flag_verbose_asm) |
2913 | { | |
2914 | /* Print the list of options in effect. */ | |
2915 | print_version (asm_out_file, ASM_COMMENT_START); | |
2916 | print_switch_values (asm_out_file, 0, MAX_LINE, | |
3d5cdd42 | 2917 | ASM_COMMENT_START, " ", "\n"); |
1fe65c00 PB |
2918 | /* Add a blank line here so it appears in assembler output but not |
2919 | screen output. */ | |
2920 | fprintf (asm_out_file, "\n"); | |
2921 | } | |
b93a436e | 2922 | #endif |
4291d9c8 | 2923 | |
1fe65c00 | 2924 | /* Output something to inform GDB that this compilation was by GCC. */ |
4291d9c8 | 2925 | #ifndef ASM_IDENTIFY_GCC |
1fe65c00 | 2926 | fprintf (asm_out_file, "gcc2_compiled.:\n"); |
4291d9c8 | 2927 | #else |
1fe65c00 | 2928 | ASM_IDENTIFY_GCC (asm_out_file); |
4291d9c8 | 2929 | #endif |
d0d4af87 | 2930 | |
0f41302f | 2931 | /* Output something to identify which front-end produced this file. */ |
d0d4af87 | 2932 | #ifdef ASM_IDENTIFY_LANGUAGE |
1fe65c00 | 2933 | ASM_IDENTIFY_LANGUAGE (asm_out_file); |
d0d4af87 | 2934 | #endif |
1fe65c00 | 2935 | } /* ! flag_syntax_only */ |
d0d4af87 | 2936 | |
cf440348 JL |
2937 | #ifndef ASM_OUTPUT_SECTION_NAME |
2938 | if (flag_function_sections) | |
2939 | { | |
2940 | warning ("-ffunction-sections not supported for this target."); | |
2941 | flag_function_sections = 0; | |
2942 | } | |
257441db CM |
2943 | if (flag_data_sections) |
2944 | { | |
2945 | warning ("-fdata-sections not supported for this target."); | |
2946 | flag_data_sections = 0; | |
2947 | } | |
cf440348 JL |
2948 | #endif |
2949 | ||
2950 | if (flag_function_sections | |
2951 | && (profile_flag || profile_block_flag)) | |
2952 | { | |
2953 | warning ("-ffunction-sections disabled; it makes profiling impossible."); | |
2954 | flag_function_sections = 0; | |
2955 | } | |
2956 | ||
1746404b | 2957 | #ifndef OBJECT_FORMAT_ELF |
cf440348 JL |
2958 | if (flag_function_sections && write_symbols != NO_DEBUG) |
2959 | warning ("-ffunction-sections may affect debugging on some targets."); | |
1746404b | 2960 | #endif |
cf440348 | 2961 | |
b93a436e JL |
2962 | /* ??? Note: There used to be a conditional here |
2963 | to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined. | |
2964 | This was to guarantee separation between gcc_compiled. and | |
2965 | the first function, for the sake of dbx on Suns. | |
2966 | However, having the extra zero here confused the Emacs | |
2967 | code for unexec, and might confuse other programs too. | |
2968 | Therefore, I took out that change. | |
2969 | In future versions we should find another way to solve | |
2970 | that dbx problem. -- rms, 23 May 93. */ | |
ca695ac9 | 2971 | |
b93a436e JL |
2972 | /* Don't let the first function fall at the same address |
2973 | as gcc_compiled., if profiling. */ | |
2974 | if (profile_flag || profile_block_flag) | |
e5e809f4 JL |
2975 | { |
2976 | /* It's best if we can write a nop here since some | |
2977 | assemblers don't tolerate zeros in the text section. */ | |
2978 | if (insn_template[CODE_FOR_nop] != 0) | |
2979 | output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR); | |
2980 | else | |
2981 | assemble_zeros (UNITS_PER_WORD); | |
2982 | } | |
4291d9c8 RS |
2983 | |
2984 | /* If dbx symbol table desired, initialize writing it | |
2985 | and output the predefined types. */ | |
f246a305 RS |
2986 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2987 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2988 | TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename, |
2989 | getdecls ())); | |
2990 | #endif | |
2991 | #ifdef SDB_DEBUGGING_INFO | |
2992 | if (write_symbols == SDB_DEBUG) | |
2993 | TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename, | |
2994 | getdecls ())); | |
2995 | #endif | |
2996 | #ifdef DWARF_DEBUGGING_INFO | |
2997 | if (write_symbols == DWARF_DEBUG) | |
2998 | TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename)); | |
2999 | #endif | |
0021b564 JM |
3000 | #ifdef DWARF2_UNWIND_INFO |
3001 | if (dwarf2out_do_frame ()) | |
3002 | dwarf2out_frame_init (); | |
3003 | #endif | |
9a666dda JM |
3004 | #ifdef DWARF2_DEBUGGING_INFO |
3005 | if (write_symbols == DWARF2_DEBUG) | |
3006 | TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename)); | |
3007 | #endif | |
4291d9c8 RS |
3008 | |
3009 | /* Initialize yet another pass. */ | |
3010 | ||
b93a436e | 3011 | init_final (main_input_filename); |
0d332add | 3012 | init_branch_prob (dump_base_name); |
4291d9c8 RS |
3013 | |
3014 | start_time = get_run_time (); | |
3015 | ||
3016 | /* Call the parser, which parses the entire file | |
3017 | (calling rest_of_compilation for each function). */ | |
3018 | ||
3019 | if (yyparse () != 0) | |
453dfc78 JW |
3020 | { |
3021 | if (errorcount == 0) | |
ab87f8c8 | 3022 | notice ("Errors detected in input file (your bison.simple is out of date)\n"); |
453dfc78 JW |
3023 | |
3024 | /* In case there were missing closebraces, | |
3025 | get us back to the global binding level. */ | |
3026 | while (! global_bindings_p ()) | |
3027 | poplevel (0, 0, 0); | |
3028 | } | |
4291d9c8 RS |
3029 | |
3030 | /* Compilation is now finished except for writing | |
3031 | what's left of the symbol table output. */ | |
3032 | ||
3033 | parse_time += get_run_time () - start_time; | |
3034 | ||
3035 | parse_time -= integration_time; | |
3036 | parse_time -= varconst_time; | |
3037 | ||
1fe65c00 PB |
3038 | if (flag_syntax_only) |
3039 | goto finish_syntax; | |
3040 | ||
4291d9c8 RS |
3041 | globals = getdecls (); |
3042 | ||
3043 | /* Really define vars that have had only a tentative definition. | |
3044 | Really output inline functions that must actually be callable | |
3045 | and have not been output so far. */ | |
3046 | ||
3047 | { | |
3048 | int len = list_length (globals); | |
3049 | tree *vec = (tree *) alloca (sizeof (tree) * len); | |
3050 | int i; | |
3051 | tree decl; | |
2b6c54d6 | 3052 | int reconsider = 1; |
4291d9c8 RS |
3053 | |
3054 | /* Process the decls in reverse order--earliest first. | |
3055 | Put them into VEC from back to front, then take out from front. */ | |
3056 | ||
3057 | for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) | |
3058 | vec[len - i - 1] = decl; | |
3059 | ||
3060 | for (i = 0; i < len; i++) | |
3061 | { | |
3062 | decl = vec[i]; | |
07af9d16 JM |
3063 | |
3064 | /* We're not deferring this any longer. */ | |
3065 | DECL_DEFER_OUTPUT (decl) = 0; | |
3066 | ||
488b1f4f RS |
3067 | if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0 |
3068 | && incomplete_decl_finalize_hook != 0) | |
2b599527 | 3069 | (*incomplete_decl_finalize_hook) (decl); |
2b6c54d6 | 3070 | } |
2b599527 | 3071 | |
2b6c54d6 JM |
3072 | /* Now emit any global variables or functions that we have been putting |
3073 | off. We need to loop in case one of the things emitted here | |
3074 | references another one which comes earlier in the list. */ | |
3075 | while (reconsider) | |
3076 | { | |
3077 | reconsider = 0; | |
3078 | for (i = 0; i < len; i++) | |
4291d9c8 | 3079 | { |
2b6c54d6 JM |
3080 | decl = vec[i]; |
3081 | ||
3082 | if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl)) | |
3083 | continue; | |
3084 | ||
6b2bd61e PB |
3085 | /* Don't write out static consts, unless we still need them. |
3086 | ||
fbe912dd BK |
3087 | We also keep static consts if not optimizing (for debugging), |
3088 | unless the user specified -fno-keep-static-consts. | |
6b2bd61e PB |
3089 | ??? They might be better written into the debug information. |
3090 | This is possible when using DWARF. | |
3091 | ||
3092 | A language processor that wants static constants to be always | |
3093 | written out (even if it is not used) is responsible for | |
3094 | calling rest_of_decl_compilation itself. E.g. the C front-end | |
3095 | calls rest_of_decl_compilation from finish_decl. | |
3096 | One motivation for this is that is conventional in some | |
3097 | environments to write things like: | |
3098 | static const char rcsid[] = "... version string ..."; | |
3099 | intending to force the string to be in the executable. | |
3100 | ||
3101 | A language processor that would prefer to have unneeded | |
3102 | static constants "optimized away" would just defer writing | |
3103 | them out until here. E.g. C++ does this, because static | |
3104 | constants are often defined in header files. | |
3105 | ||
3106 | ??? A tempting alternative (for both C and C++) would be | |
3107 | to force a constant to be written if and only if it is | |
0f41302f | 3108 | defined in a main file, as opposed to an include file. */ |
6b2bd61e | 3109 | |
2b6c54d6 JM |
3110 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) |
3111 | && (! TREE_READONLY (decl) | |
3112 | || TREE_PUBLIC (decl) | |
fbe912dd | 3113 | || (!optimize && flag_keep_static_consts) |
2b6c54d6 JM |
3114 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) |
3115 | { | |
3116 | reconsider = 1; | |
3117 | rest_of_decl_compilation (decl, NULL_PTR, 1, 1); | |
3118 | } | |
3119 | ||
3120 | if (TREE_CODE (decl) == FUNCTION_DECL | |
3121 | && DECL_INITIAL (decl) != 0 | |
3122 | && DECL_SAVED_INSNS (decl) != 0 | |
3123 | && (flag_keep_inline_functions | |
2f8844a8 | 3124 | || TREE_PUBLIC (decl) |
2b6c54d6 JM |
3125 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) |
3126 | { | |
3127 | reconsider = 1; | |
3128 | temporary_allocation (); | |
3129 | output_inline_function (decl); | |
3130 | permanent_allocation (1); | |
3131 | } | |
4291d9c8 | 3132 | } |
2b6c54d6 | 3133 | } |
4291d9c8 | 3134 | |
2668793e JL |
3135 | /* This must occur after the loop to output deferred functions. Else |
3136 | the profiler initializer would not be emitted if all the functions | |
3137 | in this compilation unit were deferred. | |
3138 | ||
3139 | output_func_start_profiler can not cause any additional functions or | |
3140 | data to need to be output, so it need not be in the deferred function | |
3141 | loop above. */ | |
3142 | output_func_start_profiler (); | |
3143 | ||
3d195391 MS |
3144 | /* Now that all possible functions have been output, we can dump |
3145 | the exception table. */ | |
3146 | ||
0021b564 | 3147 | output_exception_table (); |
3d195391 | 3148 | |
2b6c54d6 JM |
3149 | for (i = 0; i < len; i++) |
3150 | { | |
3151 | decl = vec[i]; | |
3152 | ||
3153 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) | |
3154 | && ! TREE_ASM_WRITTEN (decl)) | |
3155 | /* Cancel the RTL for this decl so that, if debugging info | |
3156 | output for global variables is still to come, | |
3157 | this one will be omitted. */ | |
3158 | DECL_RTL (decl) = NULL; | |
4291d9c8 | 3159 | |
ac266247 RS |
3160 | /* Warn about any function |
3161 | declared static but not defined. | |
3162 | We don't warn about variables, | |
3163 | because many programs have static variables | |
3164 | that exist only to get some text into the object file. */ | |
8c461ea1 JM |
3165 | if (TREE_CODE (decl) == FUNCTION_DECL |
3166 | && (warn_unused | |
3167 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) | |
4291d9c8 | 3168 | && DECL_INITIAL (decl) == 0 |
216d5cdd | 3169 | && DECL_EXTERNAL (decl) |
d1b01681 | 3170 | && ! DECL_ARTIFICIAL (decl) |
4291d9c8 | 3171 | && ! TREE_PUBLIC (decl)) |
7d429c41 | 3172 | { |
1f288b3f JM |
3173 | if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) |
3174 | pedwarn_with_decl (decl, | |
3175 | "`%s' used but never defined"); | |
3176 | else | |
3177 | warning_with_decl (decl, | |
3178 | "`%s' declared `static' but never defined"); | |
7d429c41 RS |
3179 | /* This symbol is effectively an "extern" declaration now. */ |
3180 | TREE_PUBLIC (decl) = 1; | |
3181 | assemble_external (decl); | |
7d429c41 | 3182 | } |
8c461ea1 | 3183 | |
4291d9c8 | 3184 | /* Warn about static fns or vars defined but not used, |
7062b881 PB |
3185 | but not about inline functions or static consts |
3186 | since defining those in header files is normal practice. */ | |
4291d9c8 | 3187 | if (warn_unused |
7062b881 PB |
3188 | && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl)) |
3189 | || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl))) | |
0c20aabf | 3190 | && ! DECL_IN_SYSTEM_HEADER (decl) |
216d5cdd | 3191 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
3192 | && ! TREE_PUBLIC (decl) |
3193 | && ! TREE_USED (decl) | |
f843649d | 3194 | && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl)) |
4291d9c8 RS |
3195 | /* The TREE_USED bit for file-scope decls |
3196 | is kept in the identifier, to handle multiple | |
3197 | external decls in different scopes. */ | |
3198 | && ! TREE_USED (DECL_NAME (decl))) | |
3199 | warning_with_decl (decl, "`%s' defined but not used"); | |
3200 | ||
3201 | #ifdef SDB_DEBUGGING_INFO | |
3202 | /* The COFF linker can move initialized global vars to the end. | |
3203 | And that can screw up the symbol ordering. | |
3204 | By putting the symbols in that order to begin with, | |
3205 | we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */ | |
3206 | if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL | |
3207 | && TREE_PUBLIC (decl) && DECL_INITIAL (decl) | |
7efad3f7 | 3208 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
3209 | && DECL_RTL (decl) != 0) |
3210 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
3211 | ||
3212 | /* Output COFF information for non-global | |
0f41302f | 3213 | file-scope initialized variables. */ |
4291d9c8 RS |
3214 | if (write_symbols == SDB_DEBUG |
3215 | && TREE_CODE (decl) == VAR_DECL | |
3216 | && DECL_INITIAL (decl) | |
7efad3f7 | 3217 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
3218 | && DECL_RTL (decl) != 0 |
3219 | && GET_CODE (DECL_RTL (decl)) == MEM) | |
3220 | TIMEVAR (symout_time, sdbout_toplevel_data (decl)); | |
3221 | #endif /* SDB_DEBUGGING_INFO */ | |
3222 | #ifdef DWARF_DEBUGGING_INFO | |
6dc42e49 | 3223 | /* Output DWARF information for file-scope tentative data object |
4291d9c8 RS |
3224 | declarations, file-scope (extern) function declarations (which |
3225 | had no corresponding body) and file-scope tagged type declarations | |
3226 | and definitions which have not yet been forced out. */ | |
3227 | ||
3228 | if (write_symbols == DWARF_DEBUG | |
3229 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
3230 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1)); | |
9a666dda JM |
3231 | #endif |
3232 | #ifdef DWARF2_DEBUGGING_INFO | |
3233 | /* Output DWARF2 information for file-scope tentative data object | |
3234 | declarations, file-scope (extern) function declarations (which | |
3235 | had no corresponding body) and file-scope tagged type declarations | |
3236 | and definitions which have not yet been forced out. */ | |
3237 | ||
3238 | if (write_symbols == DWARF2_DEBUG | |
3239 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
88dad228 | 3240 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
4291d9c8 RS |
3241 | #endif |
3242 | } | |
3243 | } | |
3244 | ||
4b8af8d9 JM |
3245 | /* Write out any pending weak symbol declarations. */ |
3246 | ||
3247 | weak_finish (); | |
3248 | ||
4291d9c8 | 3249 | /* Do dbx symbols */ |
f246a305 RS |
3250 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
3251 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
3252 | TIMEVAR (symout_time, |
3253 | { | |
3254 | dbxout_finish (asm_out_file, main_input_filename); | |
3255 | }); | |
3256 | #endif | |
3257 | ||
3258 | #ifdef DWARF_DEBUGGING_INFO | |
3259 | if (write_symbols == DWARF_DEBUG) | |
3260 | TIMEVAR (symout_time, | |
3261 | { | |
3262 | dwarfout_finish (); | |
3263 | }); | |
3264 | #endif | |
3265 | ||
0021b564 JM |
3266 | #ifdef DWARF2_UNWIND_INFO |
3267 | if (dwarf2out_do_frame ()) | |
3268 | dwarf2out_frame_finish (); | |
3269 | #endif | |
3270 | ||
9a666dda JM |
3271 | #ifdef DWARF2_DEBUGGING_INFO |
3272 | if (write_symbols == DWARF2_DEBUG) | |
3273 | TIMEVAR (symout_time, | |
3274 | { | |
3275 | dwarf2out_finish (); | |
3276 | }); | |
3277 | #endif | |
3278 | ||
4291d9c8 RS |
3279 | /* Output some stuff at end of file if nec. */ |
3280 | ||
b93a436e | 3281 | end_final (dump_base_name); |
032713aa NC |
3282 | |
3283 | if (branch_prob_dump) | |
3284 | open_dump_file (".bp", NULL); | |
3285 | ||
3286 | TIMEVAR (dump_time, end_branch_prob (rtl_dump_file)); | |
3287 | ||
3288 | if (branch_prob_dump) | |
3289 | close_dump_file (NULL, NULL_RTX); | |
3290 | ||
4291d9c8 | 3291 | #ifdef ASM_FILE_END |
b93a436e | 3292 | ASM_FILE_END (asm_out_file); |
4291d9c8 RS |
3293 | #endif |
3294 | ||
ed396e68 | 3295 | |
4291d9c8 | 3296 | /* Language-specific end of compilation actions. */ |
1fe65c00 | 3297 | finish_syntax: |
4291d9c8 RS |
3298 | lang_finish (); |
3299 | ||
3300 | /* Close the dump files. */ | |
3301 | ||
3302 | if (flag_gen_aux_info) | |
3303 | { | |
3304 | fclose (aux_info_file); | |
3305 | if (errorcount) | |
3306 | unlink (aux_info_file_name); | |
3307 | } | |
3308 | ||
4291d9c8 RS |
3309 | if (combine_dump) |
3310 | { | |
032713aa NC |
3311 | open_dump_file (".combine", NULL); |
3312 | TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file)); | |
3313 | close_dump_file (NULL, NULL_RTX); | |
4291d9c8 RS |
3314 | } |
3315 | ||
4291d9c8 RS |
3316 | /* Close non-debugging input and output files. Take special care to note |
3317 | whether fclose returns an error, since the pages might still be on the | |
3318 | buffer chain while the file is open. */ | |
3319 | ||
e3d1fd32 | 3320 | finish_parse (); |
e56e519d | 3321 | |
1fe65c00 PB |
3322 | if (! flag_syntax_only |
3323 | && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)) | |
4291d9c8 RS |
3324 | fatal_io_error (asm_file_name); |
3325 | ||
735a0e33 UD |
3326 | /* Do whatever is necessary to finish printing the graphs. */ |
3327 | if (graph_dump_format != no_graph) | |
3328 | { | |
3329 | if (jump_opt_dump) | |
3330 | finish_graph_dump_file (dump_base_name, ".jump"); | |
3331 | if (addressof_dump) | |
3332 | finish_graph_dump_file (dump_base_name, ".addressof"); | |
3333 | if (cse_dump) | |
3334 | finish_graph_dump_file (dump_base_name, ".cse"); | |
3335 | if (loop_dump) | |
3336 | finish_graph_dump_file (dump_base_name, ".loop"); | |
3337 | if (cse2_dump) | |
3338 | finish_graph_dump_file (dump_base_name, ".cse2"); | |
3339 | if (branch_prob_dump) | |
3340 | finish_graph_dump_file (dump_base_name, ".bp"); | |
3341 | if (flow_dump) | |
3342 | finish_graph_dump_file (dump_base_name, ".flow"); | |
3343 | if (combine_dump) | |
3344 | finish_graph_dump_file (dump_base_name, ".combine"); | |
3345 | if (regmove_dump) | |
3346 | finish_graph_dump_file (dump_base_name, ".regmove"); | |
3347 | if (sched_dump) | |
3348 | finish_graph_dump_file (dump_base_name, ".sched"); | |
3349 | if (local_reg_dump) | |
3350 | finish_graph_dump_file (dump_base_name, ".lreg"); | |
3351 | if (global_reg_dump) | |
3352 | finish_graph_dump_file (dump_base_name, ".greg"); | |
78327a73 | 3353 | if (flow2_dump) |
e881bb1b | 3354 | finish_graph_dump_file (dump_base_name, ".flow2"); |
735a0e33 UD |
3355 | if (sched2_dump) |
3356 | finish_graph_dump_file (dump_base_name, ".sched2"); | |
3357 | if (jump2_opt_dump) | |
3358 | finish_graph_dump_file (dump_base_name, ".jump2"); | |
3359 | #ifdef DELAY_SLOTS | |
3360 | if (dbr_sched_dump) | |
3361 | finish_graph_dump_file (dump_base_name, ".dbr"); | |
3362 | #endif | |
3363 | if (gcse_dump) | |
3364 | finish_graph_dump_file (dump_base_name, ".gcse"); | |
3365 | #ifdef STACK_REGS | |
3366 | if (stack_reg_dump) | |
3367 | finish_graph_dump_file (dump_base_name, ".stack"); | |
3368 | #endif | |
3369 | #ifdef MACHINE_DEPENDENT_REORG | |
3370 | if (mach_dep_reorg_dump) | |
3371 | finish_graph_dump_file (dump_base_name, ".mach"); | |
3372 | #endif | |
3373 | } | |
3374 | ||
ed396e68 BS |
3375 | /* Free up memory for the benefit of leak detectors. */ |
3376 | free_reg_info (); | |
3377 | ||
4291d9c8 RS |
3378 | /* Print the times. */ |
3379 | ||
3380 | if (! quiet_flag) | |
3381 | { | |
3382 | fprintf (stderr,"\n"); | |
3383 | print_time ("parse", parse_time); | |
ca695ac9 | 3384 | |
b93a436e JL |
3385 | print_time ("integration", integration_time); |
3386 | print_time ("jump", jump_time); | |
3387 | print_time ("cse", cse_time); | |
7506f491 | 3388 | print_time ("gcse", gcse_time); |
b93a436e JL |
3389 | print_time ("loop", loop_time); |
3390 | print_time ("cse2", cse2_time); | |
3391 | print_time ("branch-prob", branch_prob_time); | |
3392 | print_time ("flow", flow_time); | |
3393 | print_time ("combine", combine_time); | |
3394 | print_time ("regmove", regmove_time); | |
3395 | print_time ("sched", sched_time); | |
3396 | print_time ("local-alloc", local_alloc_time); | |
3397 | print_time ("global-alloc", global_alloc_time); | |
e881bb1b | 3398 | print_time ("flow2", flow2_time); |
b93a436e | 3399 | print_time ("sched2", sched2_time); |
bd334356 | 3400 | #ifdef DELAY_SLOTS |
b93a436e | 3401 | print_time ("dbranch", dbr_sched_time); |
bd334356 | 3402 | #endif |
b93a436e JL |
3403 | print_time ("shorten-branch", shorten_branch_time); |
3404 | print_time ("stack-reg", stack_reg_time); | |
3405 | print_time ("final", final_time); | |
3406 | print_time ("varconst", varconst_time); | |
3407 | print_time ("symout", symout_time); | |
3408 | print_time ("dump", dump_time); | |
4291d9c8 RS |
3409 | } |
3410 | } | |
3411 | \f | |
3412 | /* This is called from various places for FUNCTION_DECL, VAR_DECL, | |
3413 | and TYPE_DECL nodes. | |
3414 | ||
3415 | This does nothing for local (non-static) variables. | |
3416 | Otherwise, it sets up the RTL and outputs any assembler code | |
3417 | (label definition, storage allocation and initialization). | |
3418 | ||
3419 | DECL is the declaration. If ASMSPEC is nonzero, it specifies | |
3420 | the assembler symbol name to be used. TOP_LEVEL is nonzero | |
3421 | if this declaration is not within a function. */ | |
3422 | ||
3423 | void | |
3424 | rest_of_decl_compilation (decl, asmspec, top_level, at_end) | |
3425 | tree decl; | |
87e11268 | 3426 | const char *asmspec; |
4291d9c8 RS |
3427 | int top_level; |
3428 | int at_end; | |
3429 | { | |
3430 | /* Declarations of variables, and of functions defined elsewhere. */ | |
3431 | ||
928eb380 RS |
3432 | /* The most obvious approach, to put an #ifndef around where |
3433 | this macro is used, doesn't work since it's inside a macro call. */ | |
3434 | #ifndef ASM_FINISH_DECLARE_OBJECT | |
3435 | #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END) | |
3436 | #endif | |
3437 | ||
4291d9c8 RS |
3438 | /* Forward declarations for nested functions are not "external", |
3439 | but we need to treat them as if they were. */ | |
216d5cdd | 3440 | if (TREE_STATIC (decl) || DECL_EXTERNAL (decl) |
4291d9c8 RS |
3441 | || TREE_CODE (decl) == FUNCTION_DECL) |
3442 | TIMEVAR (varconst_time, | |
3443 | { | |
3444 | make_decl_rtl (decl, asmspec, top_level); | |
9a9a9643 RS |
3445 | /* Initialized extern variable exists to be replaced |
3446 | with its value, or represents something that will be | |
3447 | output in another file. */ | |
6dbf678a | 3448 | if (! (TREE_CODE (decl) == VAR_DECL |
9a9a9643 RS |
3449 | && DECL_EXTERNAL (decl) && TREE_READONLY (decl) |
3450 | && DECL_INITIAL (decl) != 0 | |
5b272d50 | 3451 | && DECL_INITIAL (decl) != error_mark_node)) |
6dbf678a RS |
3452 | /* Don't output anything |
3453 | when a tentative file-scope definition is seen. | |
3454 | But at end of compilation, do output code for them. */ | |
3455 | if (! (! at_end && top_level | |
3456 | && (DECL_INITIAL (decl) == 0 | |
9a9a9643 | 3457 | || DECL_INITIAL (decl) == error_mark_node))) |
8380e2f2 | 3458 | assemble_variable (decl, top_level, at_end, 0); |
b93a436e | 3459 | if (decl == last_assemble_variable_decl) |
5e10b3cc RS |
3460 | { |
3461 | ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl, | |
3462 | top_level, at_end); | |
3463 | } | |
4291d9c8 | 3464 | }); |
216d5cdd | 3465 | else if (DECL_REGISTER (decl) && asmspec != 0) |
4291d9c8 RS |
3466 | { |
3467 | if (decode_reg_name (asmspec) >= 0) | |
3468 | { | |
3469 | DECL_RTL (decl) = 0; | |
3470 | make_decl_rtl (decl, asmspec, top_level); | |
3471 | } | |
3472 | else | |
3473 | error ("invalid register name `%s' for register variable", asmspec); | |
3474 | } | |
f246a305 RS |
3475 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
3476 | else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
3477 | && TREE_CODE (decl) == TYPE_DECL) | |
4291d9c8 RS |
3478 | TIMEVAR (symout_time, dbxout_symbol (decl, 0)); |
3479 | #endif | |
3480 | #ifdef SDB_DEBUGGING_INFO | |
3481 | else if (write_symbols == SDB_DEBUG && top_level | |
3482 | && TREE_CODE (decl) == TYPE_DECL) | |
3483 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
3484 | #endif | |
3485 | } | |
3486 | ||
3487 | /* Called after finishing a record, union or enumeral type. */ | |
3488 | ||
3489 | void | |
3490 | rest_of_type_compilation (type, toplev) | |
114791ea | 3491 | #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO) |
4291d9c8 RS |
3492 | tree type; |
3493 | int toplev; | |
114791ea KG |
3494 | #else |
3495 | tree type ATTRIBUTE_UNUSED; | |
3496 | int toplev ATTRIBUTE_UNUSED; | |
3497 | #endif | |
4291d9c8 | 3498 | { |
f246a305 RS |
3499 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
3500 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
3501 | TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev)); |
3502 | #endif | |
3503 | #ifdef SDB_DEBUGGING_INFO | |
3504 | if (write_symbols == SDB_DEBUG) | |
3505 | TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev)); | |
3506 | #endif | |
3507 | } | |
3508 | ||
3509 | /* This is called from finish_function (within yyparse) | |
3510 | after each top-level definition is parsed. | |
3511 | It is supposed to compile that function or variable | |
3512 | and output the assembler code for it. | |
3513 | After we return, the tree storage is freed. */ | |
3514 | ||
3515 | void | |
3516 | rest_of_compilation (decl) | |
3517 | tree decl; | |
3518 | { | |
3519 | register rtx insns; | |
3520 | int start_time = get_run_time (); | |
3521 | int tem; | |
3522 | /* Nonzero if we have saved the original DECL_INITIAL of the function, | |
3523 | to be restored after we finish compiling the function | |
3524 | (for use when compiling inline calls to this function). */ | |
3525 | tree saved_block_tree = 0; | |
8a958768 RS |
3526 | /* Likewise, for DECL_ARGUMENTS. */ |
3527 | tree saved_arguments = 0; | |
ab40ad2b | 3528 | int failure = 0; |
4291d9c8 RS |
3529 | |
3530 | /* If we are reconsidering an inline function | |
3531 | at the end of compilation, skip the stuff for making it inline. */ | |
3532 | ||
3533 | if (DECL_SAVED_INSNS (decl) == 0) | |
3534 | { | |
956d6950 | 3535 | int inlinable = 0; |
dff01034 | 3536 | const char *lose; |
4291d9c8 RS |
3537 | |
3538 | /* If requested, consider whether to make this function inline. */ | |
9deaf1b1 | 3539 | if (DECL_INLINE (decl) || flag_inline_functions) |
4291d9c8 RS |
3540 | TIMEVAR (integration_time, |
3541 | { | |
3542 | lose = function_cannot_inline_p (decl); | |
caa0eccd | 3543 | if (lose || ! optimize) |
4291d9c8 | 3544 | { |
9deaf1b1 | 3545 | if (warn_inline && DECL_INLINE (decl)) |
4291d9c8 | 3546 | warning_with_decl (decl, lose); |
9548c538 | 3547 | DECL_ABSTRACT_ORIGIN (decl) = 0; |
46dbb914 RS |
3548 | /* Don't really compile an extern inline function. |
3549 | If we can't make it inline, pretend | |
3550 | it was only declared. */ | |
3551 | if (DECL_EXTERNAL (decl)) | |
27937f46 RS |
3552 | { |
3553 | DECL_INITIAL (decl) = 0; | |
3554 | goto exit_rest_of_compilation; | |
3555 | } | |
4291d9c8 RS |
3556 | } |
3557 | else | |
9deaf1b1 RK |
3558 | /* ??? Note that this has the effect of making it look |
3559 | like "inline" was specified for a function if we choose | |
3560 | to inline it. This isn't quite right, but it's | |
3561 | probably not worth the trouble to fix. */ | |
956d6950 | 3562 | inlinable = DECL_INLINE (decl) = 1; |
4291d9c8 RS |
3563 | }); |
3564 | ||
3565 | insns = get_insns (); | |
3566 | ||
3567 | /* Dump the rtl code if we are dumping rtl. */ | |
3568 | ||
3569 | if (rtl_dump) | |
032713aa NC |
3570 | { |
3571 | open_dump_file (".rtl", decl_printable_name (decl, 2)); | |
3572 | ||
3573 | if (DECL_SAVED_INSNS (decl)) | |
3574 | fprintf (rtl_dump_file, ";; (integrable)\n\n"); | |
3575 | ||
3576 | close_dump_file (print_rtl, insns); | |
3577 | } | |
4291d9c8 | 3578 | |
c0da11c4 JM |
3579 | /* If we can, defer compiling inlines until EOF. |
3580 | save_for_inline_copying can be extremely expensive. */ | |
956d6950 | 3581 | if (inlinable && ! decl_function_context (decl)) |
c0da11c4 JM |
3582 | DECL_DEFER_OUTPUT (decl) = 1; |
3583 | ||
4291d9c8 RS |
3584 | /* If function is inline, and we don't yet know whether to |
3585 | compile it by itself, defer decision till end of compilation. | |
3586 | finish_compilation will call rest_of_compilation again | |
16411ea6 | 3587 | for those functions that need to be output. Also defer those |
ec6c615d RK |
3588 | functions that we are supposed to defer. We cannot defer |
3589 | functions containing nested functions since the nested function | |
bbc0e641 JM |
3590 | data is in our non-saved obstack. We cannot defer nested |
3591 | functions for the same reason. */ | |
ec6c615d | 3592 | |
e9a25f70 JL |
3593 | /* If this is a nested inline, remove ADDRESSOF now so we can |
3594 | finish compiling ourselves. Otherwise, wait until EOF. | |
3595 | We have to do this because the purge_addressof transformation | |
3596 | changes the DECL_RTL for many variables, which confuses integrate. */ | |
956d6950 | 3597 | if (inlinable) |
e9a25f70 JL |
3598 | { |
3599 | if (decl_function_context (decl)) | |
3600 | purge_addressof (insns); | |
3601 | else | |
3602 | DECL_DEFER_OUTPUT (decl) = 1; | |
3603 | } | |
3604 | ||
ec6c615d RK |
3605 | if (! current_function_contains_functions |
3606 | && (DECL_DEFER_OUTPUT (decl) | |
9deaf1b1 | 3607 | || (DECL_INLINE (decl) |
ec6c615d RK |
3608 | && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) |
3609 | && ! flag_keep_inline_functions) | |
3610 | || DECL_EXTERNAL (decl))))) | |
4291d9c8 | 3611 | { |
951af26e JM |
3612 | DECL_DEFER_OUTPUT (decl) = 1; |
3613 | ||
a701efba MM |
3614 | /* If -Wreturn-type, we have to do a bit of compilation. |
3615 | However, if we just fall through we will call | |
3616 | save_for_inline_copying() which results in excessive | |
3617 | memory use. Instead, we just want to call | |
3618 | jump_optimize() to figure out whether or not we can fall | |
3619 | off the end of the function; we do the minimum amount of | |
3620 | work necessary to make that safe. And, we set optimize | |
3621 | to zero to keep jump_optimize from working too hard. */ | |
3622 | if (warn_return_type) | |
937522b5 | 3623 | { |
a701efba MM |
3624 | int saved_optimize = optimize; |
3625 | optimize = 0; | |
3626 | find_exception_handler_labels (); | |
14bf4a33 MM |
3627 | jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES, |
3628 | !JUMP_AFTER_REGSCAN); | |
a701efba MM |
3629 | optimize = saved_optimize; |
3630 | } | |
3631 | ||
951af26e | 3632 | #ifdef DWARF_DEBUGGING_INFO |
a701efba MM |
3633 | /* Generate the DWARF info for the "abstract" instance |
3634 | of a function which we may later generate inlined and/or | |
3635 | out-of-line instances of. */ | |
3636 | if (write_symbols == DWARF_DEBUG) | |
3637 | { | |
3638 | set_decl_abstract_flags (decl, 1); | |
3639 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3640 | set_decl_abstract_flags (decl, 0); | |
3641 | } | |
9a666dda JM |
3642 | #endif |
3643 | #ifdef DWARF2_DEBUGGING_INFO | |
a701efba MM |
3644 | /* Generate the DWARF2 info for the "abstract" instance |
3645 | of a function which we may later generate inlined and/or | |
3646 | out-of-line instances of. */ | |
3647 | if (write_symbols == DWARF2_DEBUG) | |
3648 | { | |
3649 | set_decl_abstract_flags (decl, 1); | |
3650 | TIMEVAR (symout_time, dwarf2out_decl (decl)); | |
3651 | set_decl_abstract_flags (decl, 0); | |
937522b5 | 3652 | } |
a701efba MM |
3653 | #endif |
3654 | TIMEVAR (integration_time, save_for_inline_nocopy (decl)); | |
3655 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable; | |
3656 | goto exit_rest_of_compilation; | |
4291d9c8 RS |
3657 | } |
3658 | ||
8a958768 | 3659 | /* If we have to compile the function now, save its rtl and subdecls |
4291d9c8 | 3660 | so that its compilation will not affect what others get. */ |
956d6950 | 3661 | if (inlinable || DECL_DEFER_OUTPUT (decl)) |
4291d9c8 | 3662 | { |
937522b5 RS |
3663 | #ifdef DWARF_DEBUGGING_INFO |
3664 | /* Generate the DWARF info for the "abstract" instance of | |
3665 | a function which we will generate an out-of-line instance | |
3666 | of almost immediately (and which we may also later generate | |
3667 | various inlined instances of). */ | |
3668 | if (write_symbols == DWARF_DEBUG) | |
3669 | { | |
3670 | set_decl_abstract_flags (decl, 1); | |
3671 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3672 | set_decl_abstract_flags (decl, 0); | |
3673 | } | |
9a666dda JM |
3674 | #endif |
3675 | #ifdef DWARF2_DEBUGGING_INFO | |
3676 | /* Generate the DWARF2 info for the "abstract" instance of | |
3677 | a function which we will generate an out-of-line instance | |
3678 | of almost immediately (and which we may also later generate | |
3679 | various inlined instances of). */ | |
3680 | if (write_symbols == DWARF2_DEBUG) | |
3681 | { | |
3682 | set_decl_abstract_flags (decl, 1); | |
88dad228 | 3683 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
9a666dda JM |
3684 | set_decl_abstract_flags (decl, 0); |
3685 | } | |
937522b5 | 3686 | #endif |
4291d9c8 | 3687 | saved_block_tree = DECL_INITIAL (decl); |
8a958768 | 3688 | saved_arguments = DECL_ARGUMENTS (decl); |
4291d9c8 | 3689 | TIMEVAR (integration_time, save_for_inline_copying (decl)); |
956d6950 | 3690 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable; |
4291d9c8 | 3691 | } |
4291d9c8 | 3692 | |
b8471b65 | 3693 | /* If specified extern inline but we aren't inlining it, we are |
1cbe6eb6 JM |
3694 | done. This goes for anything that gets here with DECL_EXTERNAL |
3695 | set, not just things with DECL_INLINE. */ | |
3696 | if (DECL_EXTERNAL (decl)) | |
b8471b65 RK |
3697 | goto exit_rest_of_compilation; |
3698 | } | |
07af9d16 | 3699 | |
951af26e JM |
3700 | if (! DECL_DEFER_OUTPUT (decl)) |
3701 | TREE_ASM_WRITTEN (decl) = 1; | |
4291d9c8 RS |
3702 | |
3703 | /* Now that integrate will no longer see our rtl, we need not distinguish | |
3704 | between the return value of this function and the return value of called | |
3705 | functions. */ | |
3706 | rtx_equal_function_value_matters = 0; | |
3707 | ||
32235b30 RS |
3708 | /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */ |
3709 | if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type) | |
4291d9c8 RS |
3710 | { |
3711 | goto exit_rest_of_compilation; | |
3712 | } | |
3713 | ||
154bba13 TT |
3714 | /* Emit code to get eh context, if needed. */ |
3715 | emit_eh_context (); | |
3716 | ||
4291d9c8 RS |
3717 | #ifdef FINALIZE_PIC |
3718 | /* If we are doing position-independent code generation, now | |
3719 | is the time to output special prologues and epilogues. | |
3720 | We do not want to do this earlier, because it just clutters | |
3721 | up inline functions with meaningless insns. */ | |
3722 | if (flag_pic) | |
3723 | FINALIZE_PIC; | |
3724 | #endif | |
3725 | ||
89418a92 BK |
3726 | /* From now on, allocate rtl in current_obstack, not in saveable_obstack. |
3727 | Note that that may have been done above, in save_for_inline_copying. | |
3728 | The call to resume_temporary_allocation near the end of this function | |
3729 | goes back to the usual state of affairs. This must be done after | |
3730 | we've built up any unwinders for exception handling, and done | |
3731 | the FINALIZE_PIC work, if necessary. */ | |
3732 | ||
3733 | rtl_in_current_obstack (); | |
3d195391 | 3734 | |
4291d9c8 RS |
3735 | insns = get_insns (); |
3736 | ||
3737 | /* Copy any shared structure that should not be shared. */ | |
3738 | ||
3739 | unshare_all_rtl (insns); | |
3740 | ||
c9ec4f99 DM |
3741 | #ifdef SETJMP_VIA_SAVE_AREA |
3742 | /* This must be performed before virutal register instantiation. */ | |
3743 | if (current_function_calls_alloca) | |
3744 | optimize_save_area_alloca (insns); | |
3745 | #endif | |
3746 | ||
4291d9c8 RS |
3747 | /* Instantiate all virtual registers. */ |
3748 | ||
3749 | instantiate_virtual_regs (current_function_decl, get_insns ()); | |
3750 | ||
3751 | /* See if we have allocated stack slots that are not directly addressable. | |
3752 | If so, scan all the insns and create explicit address computation | |
3753 | for all references to such slots. */ | |
3754 | /* fixup_stack_slots (); */ | |
3755 | ||
3d195391 MS |
3756 | /* Find all the EH handlers. */ |
3757 | find_exception_handler_labels (); | |
3758 | ||
cc4e79d8 JL |
3759 | /* Always do one jump optimization pass to ensure that JUMP_LABEL fields |
3760 | are initialized and to compute whether control can drop off the end | |
3761 | of the function. */ | |
3762 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
14bf4a33 MM |
3763 | TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES, |
3764 | JUMP_AFTER_REGSCAN)); | |
4291d9c8 | 3765 | |
32235b30 | 3766 | /* Now is when we stop if -fsyntax-only and -Wreturn-type. */ |
951af26e | 3767 | if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl)) |
32235b30 RS |
3768 | goto exit_rest_of_compilation; |
3769 | ||
4291d9c8 RS |
3770 | /* Dump rtl code after jump, if we are doing that. */ |
3771 | ||
032713aa NC |
3772 | if (jump_opt_dump) |
3773 | dump_rtl (".jump", decl, print_rtl, insns); | |
4291d9c8 RS |
3774 | |
3775 | /* Perform common subexpression elimination. | |
3776 | Nonzero value from `cse_main' means that jumps were simplified | |
3777 | and some code may now be unreachable, so do | |
3778 | jump optimization again. */ | |
3779 | ||
4291d9c8 RS |
3780 | if (optimize > 0) |
3781 | { | |
032713aa NC |
3782 | if (cse_dump) |
3783 | open_dump_file (".cse", decl_printable_name (decl, 2)); | |
3784 | ||
4291d9c8 RS |
3785 | TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1)); |
3786 | ||
3787 | if (flag_thread_jumps) | |
3788 | /* Hacks by tiemann & kenner. */ | |
6f606d63 | 3789 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1)); |
4291d9c8 RS |
3790 | |
3791 | TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), | |
032713aa | 3792 | 0, rtl_dump_file)); |
c6a26dc4 | 3793 | TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ())); |
4291d9c8 | 3794 | |
534bfae4 | 3795 | if (tem || optimize > 1) |
14bf4a33 MM |
3796 | TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, |
3797 | !JUMP_NOOP_MOVES, | |
3798 | !JUMP_AFTER_REGSCAN)); | |
4291d9c8 | 3799 | |
032713aa | 3800 | /* Dump rtl code after cse, if we are doing that. */ |
735a0e33 | 3801 | |
032713aa | 3802 | if (cse_dump) |
735a0e33 UD |
3803 | { |
3804 | close_dump_file (print_rtl, insns); | |
3805 | if (graph_dump_format != no_graph) | |
3806 | print_rtl_graph_with_bb (dump_base_name, ".cse", insns); | |
3807 | } | |
032713aa | 3808 | } |
4291d9c8 | 3809 | |
e9a25f70 JL |
3810 | purge_addressof (insns); |
3811 | reg_scan (insns, max_reg_num (), 1); | |
3812 | ||
3813 | if (addressof_dump) | |
735a0e33 UD |
3814 | { |
3815 | dump_rtl (".addressof", decl, print_rtl, insns); | |
3816 | if (graph_dump_format != no_graph) | |
3817 | print_rtl_graph_with_bb (dump_base_name, ".addressof", insns); | |
3818 | } | |
3819 | ||
7506f491 DE |
3820 | /* Perform global cse. */ |
3821 | ||
3822 | if (optimize > 0 && flag_gcse) | |
3823 | { | |
3824 | if (gcse_dump) | |
3825 | open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl))); | |
735a0e33 | 3826 | |
e78d9500 JL |
3827 | TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file)); |
3828 | ||
3829 | /* If gcse altered any jumps, rerun jump optimizations to clean | |
3830 | things up. */ | |
3831 | if (tem) | |
3832 | { | |
3833 | TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, | |
3834 | !JUMP_NOOP_MOVES, | |
3835 | !JUMP_AFTER_REGSCAN)); | |
3836 | } | |
7506f491 DE |
3837 | |
3838 | if (gcse_dump) | |
735a0e33 UD |
3839 | { |
3840 | close_dump_file (print_rtl, insns); | |
3841 | if (graph_dump_format != no_graph) | |
3842 | print_rtl_graph_with_bb (dump_base_name, ".gcse", insns); | |
3843 | } | |
7506f491 | 3844 | } |
4291d9c8 RS |
3845 | /* Move constant computations out of loops. */ |
3846 | ||
3847 | if (optimize > 0) | |
3848 | { | |
032713aa NC |
3849 | if (loop_dump) |
3850 | open_dump_file (".loop", decl_printable_name (decl, 2)); | |
3851 | ||
3852 | TIMEVAR | |
3853 | (loop_time, | |
3854 | { | |
3855 | if (flag_rerun_loop_opt) | |
4291d9c8 | 3856 | { |
032713aa NC |
3857 | /* We only want to perform unrolling once. */ |
3858 | ||
5accd822 | 3859 | loop_optimize (insns, rtl_dump_file, 0, 0); |
032713aa | 3860 | |
c6a26dc4 JL |
3861 | |
3862 | /* The first call to loop_optimize makes some instructions | |
3863 | trivially dead. We delete those instructions now in the | |
3864 | hope that doing so will make the heuristics in loop work | |
3865 | better and possibly speed up compilation. */ | |
3866 | delete_trivially_dead_insns (insns, max_reg_num ()); | |
3867 | ||
3868 | /* The regscan pass is currently necessary as the alias | |
3869 | analysis code depends on this information. */ | |
032713aa NC |
3870 | reg_scan (insns, max_reg_num (), 1); |
3871 | } | |
5accd822 | 3872 | loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1); |
032713aa | 3873 | }); |
735a0e33 | 3874 | |
032713aa | 3875 | /* Dump rtl code after loop opt, if we are doing that. */ |
735a0e33 | 3876 | |
032713aa | 3877 | if (loop_dump) |
735a0e33 UD |
3878 | { |
3879 | close_dump_file (print_rtl, insns); | |
3880 | if (graph_dump_format != no_graph) | |
3881 | print_rtl_graph_with_bb (dump_base_name, ".loop", insns); | |
3882 | } | |
4291d9c8 RS |
3883 | } |
3884 | ||
032713aa | 3885 | if (optimize > 0) |
c2f006ec | 3886 | { |
032713aa NC |
3887 | if (cse2_dump) |
3888 | open_dump_file (".cse2", decl_printable_name (decl, 2)); | |
735a0e33 | 3889 | |
032713aa NC |
3890 | if (flag_rerun_cse_after_loop) |
3891 | { | |
3892 | /* Running another jump optimization pass before the second | |
3893 | cse pass sometimes simplifies the RTL enough to allow | |
3894 | the second CSE pass to do a better job. Jump_optimize can change | |
3895 | max_reg_num so we must rerun reg_scan afterwards. | |
3896 | ??? Rework to not call reg_scan so often. */ | |
3897 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
14bf4a33 MM |
3898 | TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, |
3899 | !JUMP_NOOP_MOVES, | |
3900 | JUMP_AFTER_REGSCAN)); | |
032713aa NC |
3901 | |
3902 | TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); | |
3903 | TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), | |
3904 | 1, rtl_dump_file)); | |
3905 | if (tem) | |
14bf4a33 MM |
3906 | TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, |
3907 | !JUMP_NOOP_MOVES, | |
3908 | !JUMP_AFTER_REGSCAN)); | |
032713aa | 3909 | } |
0d332add | 3910 | |
032713aa NC |
3911 | if (flag_thread_jumps) |
3912 | { | |
3913 | /* This pass of jump threading straightens out code | |
3914 | that was kinked by loop optimization. */ | |
3915 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
3916 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); | |
3917 | } | |
735a0e33 | 3918 | |
032713aa | 3919 | /* Dump rtl code after cse, if we are doing that. */ |
735a0e33 | 3920 | |
032713aa | 3921 | if (cse2_dump) |
735a0e33 UD |
3922 | { |
3923 | close_dump_file (print_rtl, insns); | |
3924 | if (graph_dump_format != no_graph) | |
3925 | print_rtl_graph_with_bb (dump_base_name, ".cse2", insns); | |
3926 | } | |
032713aa | 3927 | } |
735a0e33 | 3928 | |
0d332add | 3929 | if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) |
032713aa NC |
3930 | { |
3931 | if (branch_prob_dump) | |
3932 | open_dump_file (".bp", decl_printable_name (decl, 2)); | |
735a0e33 | 3933 | |
032713aa NC |
3934 | TIMEVAR |
3935 | (branch_prob_time, | |
3936 | { | |
3937 | branch_prob (insns, rtl_dump_file); | |
3938 | }); | |
735a0e33 | 3939 | |
032713aa | 3940 | if (branch_prob_dump) |
735a0e33 UD |
3941 | { |
3942 | close_dump_file (print_rtl, insns); | |
3943 | if (graph_dump_format != no_graph) | |
3944 | print_rtl_graph_with_bb (dump_base_name, ".bp", insns); | |
3945 | } | |
032713aa | 3946 | } |
735a0e33 | 3947 | |
4291d9c8 RS |
3948 | /* We are no longer anticipating cse in this function, at least. */ |
3949 | ||
3950 | cse_not_expected = 1; | |
3951 | ||
3952 | /* Now we choose between stupid (pcc-like) register allocation | |
3953 | (if we got the -noreg switch and not -opt) | |
3954 | and smart register allocation. */ | |
3955 | ||
bbf9d88c | 3956 | if (optimize > 0) /* Stupid allocation probably won't work */ |
4291d9c8 RS |
3957 | obey_regdecls = 0; /* if optimizations being done. */ |
3958 | ||
3959 | regclass_init (); | |
3960 | ||
3961 | /* Print function header into flow dump now | |
3962 | because doing the flow analysis makes some of the dump. */ | |
3963 | ||
3964 | if (flow_dump) | |
032713aa NC |
3965 | open_dump_file (".flow", decl_printable_name (decl, 2)); |
3966 | ||
4291d9c8 RS |
3967 | if (obey_regdecls) |
3968 | { | |
3969 | TIMEVAR (flow_time, | |
3970 | { | |
3971 | regclass (insns, max_reg_num ()); | |
3972 | stupid_life_analysis (insns, max_reg_num (), | |
032713aa | 3973 | rtl_dump_file); |
4291d9c8 RS |
3974 | }); |
3975 | } | |
3976 | else | |
3977 | { | |
3978 | /* Do control and data flow analysis, | |
3979 | and write some of the results to dump file. */ | |
3980 | ||
5ece9746 JL |
3981 | TIMEVAR |
3982 | (flow_time, | |
3983 | { | |
359da67d | 3984 | find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1); |
5ece9746 JL |
3985 | life_analysis (insns, max_reg_num (), rtl_dump_file); |
3986 | }); | |
3987 | ||
4291d9c8 RS |
3988 | if (warn_uninitialized) |
3989 | { | |
3990 | uninitialized_vars_warning (DECL_INITIAL (decl)); | |
3991 | setjmp_args_warning (); | |
3992 | } | |
3993 | } | |
3994 | ||
3995 | /* Dump rtl after flow analysis. */ | |
3996 | ||
3997 | if (flow_dump) | |
735a0e33 UD |
3998 | { |
3999 | close_dump_file (print_rtl_with_bb, insns); | |
4000 | if (graph_dump_format != no_graph) | |
4001 | print_rtl_graph_with_bb (dump_base_name, ".flow", insns); | |
4002 | } | |
4003 | ||
f1db3576 JL |
4004 | /* The first life analysis pass has finished. From now on we can not |
4005 | generate any new pseudos. */ | |
4006 | no_new_pseudos = 1; | |
4007 | ||
4291d9c8 RS |
4008 | /* If -opt, try combining insns through substitution. */ |
4009 | ||
4010 | if (optimize > 0) | |
032713aa NC |
4011 | { |
4012 | TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); | |
735a0e33 | 4013 | |
032713aa | 4014 | /* Dump rtl code after insn combination. */ |
735a0e33 | 4015 | |
032713aa | 4016 | if (combine_dump) |
735a0e33 UD |
4017 | { |
4018 | dump_rtl (".combine", decl, print_rtl_with_bb, insns); | |
4019 | if (graph_dump_format != no_graph) | |
4020 | print_rtl_graph_with_bb (dump_base_name, ".combine", insns); | |
4021 | } | |
032713aa | 4022 | } |
8c660648 JL |
4023 | |
4024 | /* Register allocation pre-pass, to reduce number of moves | |
4025 | necessary for two-address machines. */ | |
1230327b | 4026 | if (optimize > 0 && (flag_regmove || flag_expensive_optimizations)) |
032713aa NC |
4027 | { |
4028 | if (regmove_dump) | |
4029 | open_dump_file (".regmove", decl_printable_name (decl, 2)); | |
735a0e33 | 4030 | |
032713aa NC |
4031 | TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (), |
4032 | rtl_dump_file)); | |
735a0e33 | 4033 | |
032713aa | 4034 | if (regmove_dump) |
735a0e33 UD |
4035 | { |
4036 | close_dump_file (print_rtl_with_bb, insns); | |
4037 | if (graph_dump_format != no_graph) | |
4038 | print_rtl_graph_with_bb (dump_base_name, ".regmove", insns); | |
4039 | } | |
032713aa | 4040 | } |
8c660648 | 4041 | |
4291d9c8 RS |
4042 | /* Print function header into sched dump now |
4043 | because doing the sched analysis makes some of the dump. */ | |
4044 | ||
4291d9c8 RS |
4045 | if (optimize > 0 && flag_schedule_insns) |
4046 | { | |
032713aa NC |
4047 | if (sched_dump) |
4048 | open_dump_file (".sched", decl_printable_name (decl, 2)); | |
735a0e33 | 4049 | |
4291d9c8 RS |
4050 | /* Do control and data sched analysis, |
4051 | and write some of the results to dump file. */ | |
4052 | ||
032713aa | 4053 | TIMEVAR (sched_time, schedule_insns (rtl_dump_file)); |
735a0e33 | 4054 | |
032713aa | 4055 | /* Dump rtl after instruction scheduling. */ |
735a0e33 | 4056 | |
032713aa | 4057 | if (sched_dump) |
735a0e33 UD |
4058 | { |
4059 | close_dump_file (print_rtl_with_bb, insns); | |
4060 | if (graph_dump_format != no_graph) | |
4061 | print_rtl_graph_with_bb (dump_base_name, ".sched", insns); | |
4062 | } | |
4291d9c8 RS |
4063 | } |
4064 | ||
4291d9c8 RS |
4065 | /* Unless we did stupid register allocation, |
4066 | allocate pseudo-regs that are used only within 1 basic block. */ | |
4067 | ||
4068 | if (!obey_regdecls) | |
4069 | TIMEVAR (local_alloc_time, | |
4070 | { | |
213c4983 | 4071 | recompute_reg_usage (insns, ! optimize_size); |
4291d9c8 RS |
4072 | regclass (insns, max_reg_num ()); |
4073 | local_alloc (); | |
4074 | }); | |
4075 | ||
4076 | /* Dump rtl code after allocating regs within basic blocks. */ | |
4077 | ||
4078 | if (local_reg_dump) | |
032713aa NC |
4079 | { |
4080 | open_dump_file (".lreg", decl_printable_name (decl, 2)); | |
735a0e33 | 4081 | |
032713aa NC |
4082 | TIMEVAR (dump_time, dump_flow_info (rtl_dump_file)); |
4083 | TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file)); | |
735a0e33 | 4084 | |
032713aa | 4085 | close_dump_file (print_rtl_with_bb, insns); |
735a0e33 UD |
4086 | if (graph_dump_format != no_graph) |
4087 | print_rtl_graph_with_bb (dump_base_name, ".lreg", insns); | |
032713aa | 4088 | } |
4291d9c8 RS |
4089 | |
4090 | if (global_reg_dump) | |
032713aa | 4091 | open_dump_file (".greg", decl_printable_name (decl, 2)); |
4291d9c8 RS |
4092 | |
4093 | /* Unless we did stupid register allocation, | |
4094 | allocate remaining pseudo-regs, then do the reload pass | |
4095 | fixing up any insns that are invalid. */ | |
4096 | ||
4097 | TIMEVAR (global_alloc_time, | |
4098 | { | |
4099 | if (!obey_regdecls) | |
032713aa | 4100 | failure = global_alloc (rtl_dump_file); |
4291d9c8 | 4101 | else |
032713aa | 4102 | failure = reload (insns, 0, rtl_dump_file); |
4291d9c8 RS |
4103 | }); |
4104 | ||
4291d9c8 | 4105 | |
ab40ad2b RS |
4106 | if (failure) |
4107 | goto exit_rest_of_compilation; | |
4108 | ||
c8ed219d RK |
4109 | /* Do a very simple CSE pass over just the hard registers. */ |
4110 | if (optimize > 0) | |
4111 | reload_cse_regs (insns); | |
4112 | ||
45c85c4e JL |
4113 | /* If optimizing and we are performing instruction scheduling after |
4114 | reload, then go ahead and split insns now since we are about to | |
4115 | recompute flow information anyway. | |
4116 | ||
4117 | reload_cse_regs may expose more splitting opportunities, expecially | |
4118 | for double-word operations. */ | |
4119 | if (optimize > 0 && flag_schedule_insns_after_reload) | |
4120 | { | |
4121 | rtx insn; | |
4122 | ||
4123 | for (insn = insns; insn; insn = NEXT_INSN (insn)) | |
4124 | { | |
4125 | rtx last; | |
4126 | ||
4127 | if (GET_RTX_CLASS (GET_CODE (insn)) != 'i') | |
4128 | continue; | |
4129 | ||
4130 | last = try_split (PATTERN (insn), insn, 1); | |
4131 | ||
4132 | if (last != insn) | |
4133 | { | |
4134 | PUT_CODE (insn, NOTE); | |
4135 | NOTE_SOURCE_FILE (insn) = 0; | |
4136 | NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED; | |
4137 | } | |
4138 | } | |
4139 | } | |
4140 | ||
e881bb1b RH |
4141 | if (global_reg_dump) |
4142 | { | |
4143 | TIMEVAR (dump_time, dump_global_regs (rtl_dump_file)); | |
4144 | close_dump_file (print_rtl_with_bb, insns); | |
4145 | if (graph_dump_format != no_graph) | |
4146 | print_rtl_graph_with_bb (dump_base_name, ".greg", insns); | |
4147 | } | |
4148 | ||
6764d250 | 4149 | /* Re-create the death notes which were deleted during reload. */ |
e881bb1b RH |
4150 | if (flow2_dump) |
4151 | open_dump_file (".flow2", decl_printable_name (decl, 2)); | |
4152 | ||
6764d250 | 4153 | if (optimize) |
e881bb1b RH |
4154 | { |
4155 | TIMEVAR | |
4156 | (flow2_time, | |
4157 | { | |
359da67d | 4158 | find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1); |
e881bb1b RH |
4159 | life_analysis (insns, max_reg_num (), rtl_dump_file); |
4160 | }); | |
4161 | } | |
6764d250 | 4162 | |
56744d1a JL |
4163 | flow2_completed = 1; |
4164 | ||
bdac5f58 TW |
4165 | /* On some machines, the prologue and epilogue code, or parts thereof, |
4166 | can be represented as RTL. Doing so lets us schedule insns between | |
4167 | it and the rest of the code and also allows delayed branch | |
4168 | scheduling to operate in the epilogue. */ | |
4169 | ||
4170 | thread_prologue_and_epilogue_insns (insns); | |
4171 | ||
e881bb1b | 4172 | if (flow2_dump) |
9ec36da5 | 4173 | { |
9ec36da5 | 4174 | close_dump_file (print_rtl_with_bb, insns); |
735a0e33 | 4175 | if (graph_dump_format != no_graph) |
e881bb1b | 4176 | print_rtl_graph_with_bb (dump_base_name, ".flow2", insns); |
9ec36da5 | 4177 | } |
e881bb1b | 4178 | |
4291d9c8 RS |
4179 | if (optimize > 0 && flag_schedule_insns_after_reload) |
4180 | { | |
4181 | if (sched2_dump) | |
032713aa | 4182 | open_dump_file (".sched2", decl_printable_name (decl, 2)); |
4291d9c8 RS |
4183 | |
4184 | /* Do control and data sched analysis again, | |
4185 | and write some more of the results to dump file. */ | |
4186 | ||
032713aa | 4187 | TIMEVAR (sched2_time, schedule_insns (rtl_dump_file)); |
4291d9c8 RS |
4188 | |
4189 | /* Dump rtl after post-reorder instruction scheduling. */ | |
4190 | ||
4191 | if (sched2_dump) | |
735a0e33 UD |
4192 | { |
4193 | close_dump_file (print_rtl_with_bb, insns); | |
4194 | if (graph_dump_format != no_graph) | |
4195 | print_rtl_graph_with_bb (dump_base_name, ".sched2", insns); | |
4196 | } | |
4291d9c8 RS |
4197 | } |
4198 | ||
4199 | #ifdef LEAF_REGISTERS | |
4200 | leaf_function = 0; | |
4201 | if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) | |
ab40ad2b | 4202 | leaf_function = 1; |
4291d9c8 RS |
4203 | #endif |
4204 | ||
4205 | /* One more attempt to remove jumps to .+1 | |
4206 | left by dead-store-elimination. | |
4207 | Also do cross-jumping this time | |
4208 | and delete no-op move insns. */ | |
4209 | ||
4210 | if (optimize > 0) | |
4211 | { | |
14bf4a33 MM |
4212 | TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP, |
4213 | JUMP_NOOP_MOVES, | |
4214 | !JUMP_AFTER_REGSCAN)); | |
735a0e33 | 4215 | |
032713aa | 4216 | /* Dump rtl code after jump, if we are doing that. */ |
4291d9c8 | 4217 | |
032713aa | 4218 | if (jump2_opt_dump) |
735a0e33 UD |
4219 | { |
4220 | dump_rtl (".jump2", decl, print_rtl_with_bb, insns); | |
4221 | if (graph_dump_format != no_graph) | |
4222 | print_rtl_graph_with_bb (dump_base_name, ".jump2", insns); | |
4223 | } | |
032713aa | 4224 | } |
4291d9c8 | 4225 | |
2c65021a RK |
4226 | /* If a machine dependent reorganization is needed, call it. */ |
4227 | #ifdef MACHINE_DEPENDENT_REORG | |
4228 | MACHINE_DEPENDENT_REORG (insns); | |
032713aa NC |
4229 | |
4230 | if (mach_dep_reorg_dump) | |
735a0e33 UD |
4231 | { |
4232 | dump_rtl (".mach", decl, print_rtl_with_bb, insns); | |
4233 | if (graph_dump_format != no_graph) | |
4234 | print_rtl_graph_with_bb (dump_base_name, ".mach", insns); | |
4235 | } | |
2c65021a RK |
4236 | #endif |
4237 | ||
4291d9c8 | 4238 | /* If a scheduling pass for delayed branches is to be done, |
0f41302f | 4239 | call the scheduling code. */ |
4291d9c8 RS |
4240 | |
4241 | #ifdef DELAY_SLOTS | |
4242 | if (optimize > 0 && flag_delayed_branch) | |
4243 | { | |
bbd2180d JL |
4244 | if (dbr_sched_dump) |
4245 | open_dump_file (".dbr", decl_printable_name (decl, 2)); | |
4246 | ||
01898d58 | 4247 | TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file)); |
735a0e33 | 4248 | |
4291d9c8 | 4249 | if (dbr_sched_dump) |
735a0e33 | 4250 | { |
bbd2180d | 4251 | close_dump_file (print_rtl_with_bb, insns); |
735a0e33 UD |
4252 | if (graph_dump_format != no_graph) |
4253 | print_rtl_graph_with_bb (dump_base_name, ".dbr", insns); | |
4254 | } | |
4291d9c8 RS |
4255 | } |
4256 | #endif | |
4257 | ||
d0c874f6 TG |
4258 | /* Shorten branches. */ |
4259 | TIMEVAR (shorten_branch_time, | |
4260 | { | |
4261 | shorten_branches (get_insns ()); | |
4262 | }); | |
4291d9c8 RS |
4263 | |
4264 | #ifdef STACK_REGS | |
25ba7583 JL |
4265 | if (stack_reg_dump) |
4266 | open_dump_file (".stack", decl_printable_name (decl, 2)); | |
4267 | ||
01898d58 | 4268 | TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file)); |
032713aa | 4269 | |
4291d9c8 | 4270 | if (stack_reg_dump) |
735a0e33 UD |
4271 | { |
4272 | dump_rtl (".stack", decl, print_rtl_with_bb, insns); | |
4273 | if (graph_dump_format != no_graph) | |
4274 | print_rtl_graph_with_bb (dump_base_name, ".stack", insns); | |
4275 | } | |
4291d9c8 RS |
4276 | #endif |
4277 | ||
4278 | /* Now turn the rtl into assembler code. */ | |
4279 | ||
4280 | TIMEVAR (final_time, | |
4281 | { | |
4282 | rtx x; | |
4283 | char *fnname; | |
4284 | ||
4285 | /* Get the function's name, as described by its RTL. | |
4286 | This may be different from the DECL_NAME name used | |
4287 | in the source file. */ | |
4288 | ||
4289 | x = DECL_RTL (decl); | |
4290 | if (GET_CODE (x) != MEM) | |
4291 | abort (); | |
4292 | x = XEXP (x, 0); | |
4293 | if (GET_CODE (x) != SYMBOL_REF) | |
4294 | abort (); | |
4295 | fnname = XSTR (x, 0); | |
4296 | ||
4297 | assemble_start_function (decl, fnname); | |
4298 | final_start_function (insns, asm_out_file, optimize); | |
4299 | final (insns, asm_out_file, optimize, 0); | |
4300 | final_end_function (insns, asm_out_file, optimize); | |
4301 | assemble_end_function (decl, fnname); | |
e5e809f4 JL |
4302 | if (! quiet_flag) |
4303 | fflush (asm_out_file); | |
9ddca353 | 4304 | |
e881bb1b RH |
4305 | /* Release all memory allocated by flow. */ |
4306 | free_basic_block_vars (0); | |
4307 | ||
9ddca353 RK |
4308 | /* Release all memory held by regsets now */ |
4309 | regset_release_memory (); | |
4291d9c8 RS |
4310 | }); |
4311 | ||
4312 | /* Write DBX symbols if requested */ | |
4313 | ||
4314 | /* Note that for those inline functions where we don't initially | |
4315 | know for certain that we will be generating an out-of-line copy, | |
4316 | the first invocation of this routine (rest_of_compilation) will | |
4317 | skip over this code by doing a `goto exit_rest_of_compilation;'. | |
4318 | Later on, finish_compilation will call rest_of_compilation again | |
4319 | for those inline functions that need to have out-of-line copies | |
4320 | generated. During that call, we *will* be routed past here. */ | |
4321 | ||
4322 | #ifdef DBX_DEBUGGING_INFO | |
4323 | if (write_symbols == DBX_DEBUG) | |
4324 | TIMEVAR (symout_time, dbxout_function (decl)); | |
4325 | #endif | |
4326 | ||
4327 | #ifdef DWARF_DEBUGGING_INFO | |
4328 | if (write_symbols == DWARF_DEBUG) | |
4329 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
4330 | #endif | |
4331 | ||
9a666dda JM |
4332 | #ifdef DWARF2_DEBUGGING_INFO |
4333 | if (write_symbols == DWARF2_DEBUG) | |
88dad228 | 4334 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
9a666dda JM |
4335 | #endif |
4336 | ||
4291d9c8 RS |
4337 | exit_rest_of_compilation: |
4338 | ||
e881bb1b | 4339 | free_bb_mem (); |
421382ac | 4340 | |
f246a305 RS |
4341 | /* In case the function was not output, |
4342 | don't leave any temporary anonymous types | |
4343 | queued up for sdb output. */ | |
4344 | #ifdef SDB_DEBUGGING_INFO | |
4345 | if (write_symbols == SDB_DEBUG) | |
37366632 | 4346 | sdbout_types (NULL_TREE); |
f246a305 RS |
4347 | #endif |
4348 | ||
8a958768 RS |
4349 | /* Put back the tree of subblocks and list of arguments |
4350 | from before we copied them. | |
4291d9c8 RS |
4351 | Code generation and the output of debugging info may have modified |
4352 | the copy, but the original is unchanged. */ | |
4353 | ||
4354 | if (saved_block_tree != 0) | |
fb19c456 JM |
4355 | { |
4356 | DECL_INITIAL (decl) = saved_block_tree; | |
4357 | DECL_ARGUMENTS (decl) = saved_arguments; | |
4358 | DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE; | |
4359 | } | |
4291d9c8 RS |
4360 | |
4361 | reload_completed = 0; | |
56744d1a | 4362 | flow2_completed = 0; |
f1db3576 | 4363 | no_new_pseudos = 0; |
4291d9c8 | 4364 | |
32e705c4 MM |
4365 | TIMEVAR (final_time, |
4366 | { | |
4367 | /* Clear out the insn_length contents now that they are no | |
4368 | longer valid. */ | |
4369 | init_insn_lengths (); | |
4291d9c8 | 4370 | |
32e705c4 MM |
4371 | /* Clear out the real_constant_chain before some of the rtx's |
4372 | it runs through become garbage. */ | |
4373 | clear_const_double_mem (); | |
4291d9c8 | 4374 | |
32e705c4 MM |
4375 | /* Cancel the effect of rtl_in_current_obstack. */ |
4376 | resume_temporary_allocation (); | |
adcd38c9 | 4377 | |
32e705c4 MM |
4378 | /* Show no temporary slots allocated. */ |
4379 | init_temp_slots (); | |
4380 | }); | |
adcd38c9 | 4381 | |
c8d86b9a JW |
4382 | /* Make sure volatile mem refs aren't considered valid operands for |
4383 | arithmetic insns. We must call this here if this is a nested inline | |
4384 | function, since the above code leaves us in the init_recog state | |
4385 | (from final.c), and the function context push/pop code does not | |
4386 | save/restore volatile_ok. | |
4387 | ||
4388 | ??? Maybe it isn't necessary for expand_start_function to call this | |
4389 | anymore if we do it here? */ | |
4390 | ||
4391 | init_recog_no_volatile (); | |
4392 | ||
4291d9c8 RS |
4393 | /* The parsing time is all the time spent in yyparse |
4394 | *except* what is spent in this function. */ | |
4395 | ||
4396 | parse_time -= get_run_time () - start_time; | |
735a0e33 UD |
4397 | |
4398 | /* Reset global variables. */ | |
4399 | free_basic_block_vars (0); | |
4291d9c8 RS |
4400 | } |
4401 | \f | |
b8468bc7 NC |
4402 | static void |
4403 | display_help () | |
4404 | { | |
4405 | int undoc; | |
114791ea | 4406 | unsigned long i; |
87e11268 | 4407 | const char * lang; |
b8468bc7 | 4408 | |
40f943dd | 4409 | #ifndef USE_CPPLIB |
b8468bc7 NC |
4410 | printf ("Usage: %s input [switches]\n", progname); |
4411 | printf ("Switches:\n"); | |
40f943dd | 4412 | #endif |
b8468bc7 NC |
4413 | printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"); |
4414 | printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"); | |
4415 | printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n"); | |
4416 | ||
4417 | for (i = NUM_ELEM (f_options); i--;) | |
4418 | { | |
87e11268 | 4419 | const char * description = f_options[i].description; |
b8468bc7 NC |
4420 | |
4421 | if (description != NULL && * description != 0) | |
4422 | printf (" -f%-21s %s\n", | |
4423 | f_options[i].string, description); | |
4424 | } | |
4425 | ||
4426 | printf (" -O[number] Set optimisation level to [number]\n"); | |
4427 | printf (" -Os Optimise for space rather than speed\n"); | |
4428 | printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n"); | |
4429 | printf (" -pedantic-errors Like -pedantic except that errors are produced\n"); | |
4430 | printf (" -w Suppress warnings\n"); | |
4431 | printf (" -W Enable extra warnings\n"); | |
4432 | ||
4433 | for (i = NUM_ELEM (W_options); i--;) | |
4434 | { | |
87e11268 | 4435 | const char * description = W_options[i].description; |
b8468bc7 NC |
4436 | |
4437 | if (description != NULL && * description != 0) | |
4438 | printf (" -W%-21s %s\n", | |
4439 | W_options[i].string, description); | |
4440 | } | |
4441 | ||
4442 | printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n"); | |
4443 | printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"); | |
4444 | printf (" -p Enable function profiling\n"); | |
4445 | #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) | |
4446 | printf (" -a Enable block profiling \n"); | |
4447 | #endif | |
4448 | #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT | |
4449 | printf (" -ax Enable jump profiling \n"); | |
4450 | #endif | |
4451 | printf (" -o <file> Place output into <file> \n"); | |
4452 | printf (" -G <number> Put global and static data smaller than <number>\n"); | |
40f943dd | 4453 | printf (" bytes into a special section (on some targets)\n"); |
b8468bc7 NC |
4454 | |
4455 | for (i = NUM_ELEM (debug_args); i--;) | |
4456 | { | |
4457 | if (debug_args[i].description != NULL) | |
4458 | printf (" -%-22s %s\n", debug_args[i].arg, debug_args[i].description); | |
4459 | } | |
4460 | ||
4461 | printf (" -aux-info <file> Emit declaration info into <file>.X\n"); | |
4462 | printf (" -quiet Do not display functions compiled or elapsed time\n"); | |
4463 | printf (" -version Display the compiler's version\n"); | |
4464 | printf (" -d[letters] Enable dumps from specific passes of the compiler\n"); | |
4465 | printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n"); | |
4466 | #if defined HAIFA || defined INSN_SCHEDULING | |
4467 | printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n"); | |
4468 | #endif | |
4469 | printf (" --help Display this information\n"); | |
4470 | ||
4471 | undoc = 0; | |
4472 | lang = "language"; | |
4473 | ||
4474 | /* Display descriptions of language specific options. | |
4475 | If there is no description, note that there is an undocumented option. | |
4476 | If the description is empty, do not display anything. (This allows | |
4477 | options to be deliberately undocumented, for whatever reason). | |
4478 | If the option string is missing, then this is a marker, indicating | |
630962bf | 4479 | that the description string is in fact the name of a language, whose |
b8468bc7 NC |
4480 | language specific options are to follow. */ |
4481 | ||
4482 | if (NUM_ELEM (documented_lang_options) > 1) | |
4483 | { | |
b8468bc7 NC |
4484 | printf ("\nLanguage specific options:\n"); |
4485 | ||
4486 | for (i = 0; i < NUM_ELEM (documented_lang_options); i++) | |
4487 | { | |
87e11268 KG |
4488 | const char * description = documented_lang_options[i].description; |
4489 | const char * option = documented_lang_options[i].option; | |
b8468bc7 NC |
4490 | |
4491 | if (description == NULL) | |
844642e6 NC |
4492 | { |
4493 | undoc = 1; | |
4494 | ||
4495 | if (extra_warnings) | |
4496 | printf (" %-23.23s [undocumented]\n", option); | |
4497 | } | |
b8468bc7 NC |
4498 | else if (* description == 0) |
4499 | continue; | |
4500 | else if (option == NULL) | |
4501 | { | |
4502 | if (undoc) | |
4503 | printf | |
4504 | ("\nThere are undocumented %s specific options as well.\n", | |
4505 | lang); | |
4506 | undoc = 0; | |
4507 | ||
4508 | printf ("\n Options for %s:\n", description); | |
4509 | ||
4510 | lang = description; | |
4511 | } | |
4512 | else | |
4513 | printf (" %-23.23s %s\n", option, description); | |
4514 | } | |
4515 | } | |
4516 | ||
4517 | if (undoc) | |
4518 | printf ("\nThere are undocumented %s specific options as well.\n", lang); | |
4519 | ||
4520 | if (NUM_ELEM (target_switches) > 1 | |
4521 | #ifdef TARGET_OPTIONS | |
4522 | || NUM_ELEM (target_options) > 1 | |
4523 | #endif | |
4524 | ) | |
4525 | { | |
4526 | int doc = 0; | |
4527 | ||
4528 | undoc = 0; | |
4529 | ||
4530 | printf ("\nTarget specific options:\n"); | |
4531 | ||
4532 | for (i = NUM_ELEM (target_switches); i--;) | |
4533 | { | |
87e11268 KG |
4534 | const char * option = target_switches[i].name; |
4535 | const char * description = target_switches[i].description; | |
b8468bc7 | 4536 | |
844642e6 | 4537 | if (option == NULL || * option == 0) |
b8468bc7 NC |
4538 | continue; |
4539 | else if (description == NULL) | |
844642e6 NC |
4540 | { |
4541 | undoc = 1; | |
4542 | ||
4543 | if (extra_warnings) | |
4544 | printf (" -m%-21.21s [undocumented]\n", option); | |
4545 | } | |
b8468bc7 | 4546 | else if (* description != 0) |
1f50b029 | 4547 | doc += printf (" -m%-21.21s %s\n", option, description); |
b8468bc7 NC |
4548 | } |
4549 | ||
4550 | #ifdef TARGET_OPTIONS | |
4551 | for (i = NUM_ELEM (target_options); i--;) | |
4552 | { | |
87e11268 KG |
4553 | const char * option = target_options[i].prefix; |
4554 | const char * description = target_options[i].description; | |
b8468bc7 | 4555 | |
844642e6 | 4556 | if (option == NULL || * option == 0) |
b8468bc7 NC |
4557 | continue; |
4558 | else if (description == NULL) | |
844642e6 NC |
4559 | { |
4560 | undoc = 1; | |
4561 | ||
4562 | if (extra_warnings) | |
4563 | printf (" -m%-21.21s [undocumented]\n", option); | |
4564 | } | |
b8468bc7 | 4565 | else if (* description != 0) |
1f50b029 | 4566 | doc += printf (" -m%-21.21s %s\n", option, description); |
b8468bc7 NC |
4567 | } |
4568 | #endif | |
4569 | if (undoc) | |
ff59bfe6 JM |
4570 | { |
4571 | if (doc) | |
4572 | printf ("\nThere are undocumented target specific options as well.\n"); | |
4573 | else | |
4574 | printf (" They exist, but they are not documented.\n"); | |
4575 | } | |
b8468bc7 NC |
4576 | } |
4577 | } | |
4578 | ||
4579 | /* Compare the user specified 'option' with the language | |
4580 | specific 'lang_option'. Return true if they match, or | |
4581 | if 'option' is a viable prefix of 'lang_option'. */ | |
4582 | ||
4583 | static int | |
4584 | check_lang_option (option, lang_option) | |
4585 | char * option; | |
4586 | char * lang_option; | |
4587 | { | |
4588 | lang_independent_options * indep_options; | |
4589 | int len; | |
4590 | long k; | |
1f50b029 NC |
4591 | char * space; |
4592 | ||
b8468bc7 NC |
4593 | /* Ignore NULL entries. */ |
4594 | if (option == NULL || lang_option == NULL) | |
4595 | return 0; | |
4596 | ||
1f50b029 NC |
4597 | if ((space = strchr (lang_option, ' ')) != NULL) |
4598 | len = space - lang_option; | |
4599 | else | |
4600 | len = strlen (lang_option); | |
4601 | ||
b8468bc7 NC |
4602 | /* If they do not match to the first n characters then fail. */ |
4603 | if (strncmp (option, lang_option, len) != 0) | |
4604 | return 0; | |
1f50b029 | 4605 | |
b8468bc7 NC |
4606 | /* Do not accept a lang option, if it matches a normal -f or -W |
4607 | option. Chill defines a -fpack, but we want to support | |
4608 | -fpack-struct. */ | |
1f50b029 | 4609 | |
b8468bc7 | 4610 | /* An exact match is OK */ |
79c9824e | 4611 | if ((int) strlen (option) == len) |
b8468bc7 | 4612 | return 1; |
1f50b029 | 4613 | |
b8468bc7 NC |
4614 | /* If it is not an -f or -W option allow the match */ |
4615 | if (option[0] != '-') | |
4616 | return 1; | |
1f50b029 | 4617 | |
b8468bc7 NC |
4618 | switch (option[1]) |
4619 | { | |
4620 | case 'f': indep_options = f_options; break; | |
4621 | case 'W': indep_options = W_options; break; | |
4622 | default: return 1; | |
4623 | } | |
1f50b029 | 4624 | |
b8468bc7 NC |
4625 | /* The option is a -f or -W option. |
4626 | Skip past the prefix and search for the remainder in the | |
4627 | appropriate table of options. */ | |
4628 | option += 2; | |
1f50b029 | 4629 | |
b8468bc7 NC |
4630 | if (option[0] == 'n' && option[1] == 'o' && option[2] == '-') |
4631 | option += 3; | |
1f50b029 | 4632 | |
b8468bc7 NC |
4633 | for (k = NUM_ELEM (indep_options); k--;) |
4634 | { | |
4635 | if (!strcmp (option, indep_options[k].string)) | |
4636 | { | |
4637 | /* The option matched a language independent option, | |
4638 | do not allow the language specific match. */ | |
1f50b029 | 4639 | |
b8468bc7 NC |
4640 | return 0; |
4641 | } | |
4642 | } | |
1f50b029 | 4643 | |
b8468bc7 NC |
4644 | /* The option matches the start of the langauge specific option |
4645 | and it is not an exact match for a language independent option. */ | |
4646 | return 1; | |
4647 | } | |
4648 | \f | |
4291d9c8 RS |
4649 | /* Entry point of cc1/c++. Decode command args, then call compile_file. |
4650 | Exit code is 35 if can't open files, 34 if fatal error, | |
4651 | 33 if had nonfatal errors, else success. */ | |
4652 | ||
4653 | int | |
114791ea | 4654 | main (argc, argv) |
4291d9c8 RS |
4655 | int argc; |
4656 | char **argv; | |
4291d9c8 RS |
4657 | { |
4658 | register int i; | |
4659 | char *filename = 0; | |
4660 | int flag_print_mem = 0; | |
4661 | int version_flag = 0; | |
4662 | char *p; | |
4663 | ||
4664 | /* save in case md file wants to emit args as a comment. */ | |
4665 | save_argc = argc; | |
4666 | save_argv = argv; | |
4667 | ||
4668 | p = argv[0] + strlen (argv[0]); | |
128373ac RK |
4669 | while (p != argv[0] && p[-1] != '/' |
4670 | #ifdef DIR_SEPARATOR | |
4671 | && p[-1] != DIR_SEPARATOR | |
4672 | #endif | |
4673 | ) | |
4674 | --p; | |
4291d9c8 RS |
4675 | progname = p; |
4676 | ||
08ce3276 | 4677 | #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT) |
4291d9c8 RS |
4678 | /* Get rid of any avoidable limit on stack size. */ |
4679 | { | |
4680 | struct rlimit rlim; | |
4681 | ||
0f41302f | 4682 | /* Set the stack limit huge so that alloca does not fail. */ |
4291d9c8 RS |
4683 | getrlimit (RLIMIT_STACK, &rlim); |
4684 | rlim.rlim_cur = rlim.rlim_max; | |
4685 | setrlimit (RLIMIT_STACK, &rlim); | |
4686 | } | |
c85f7c16 | 4687 | #endif |
4291d9c8 | 4688 | |
d9b53430 | 4689 | #ifdef HAVE_LC_MESSAGES |
ab87f8c8 | 4690 | setlocale (LC_MESSAGES, ""); |
d9b53430 | 4691 | #endif |
735396d9 KG |
4692 | (void) bindtextdomain (PACKAGE, localedir); |
4693 | (void) textdomain (PACKAGE); | |
ab87f8c8 | 4694 | |
4291d9c8 RS |
4695 | signal (SIGFPE, float_signal); |
4696 | ||
935d4b07 | 4697 | #ifdef SIGPIPE |
4291d9c8 | 4698 | signal (SIGPIPE, pipe_closed); |
935d4b07 | 4699 | #endif |
4291d9c8 RS |
4700 | |
4701 | decl_printable_name = decl_name; | |
114791ea | 4702 | lang_expand_expr = (lang_expand_expr_t) do_abort; |
4291d9c8 RS |
4703 | |
4704 | /* Initialize whether `char' is signed. */ | |
4705 | flag_signed_char = DEFAULT_SIGNED_CHAR; | |
4706 | #ifdef DEFAULT_SHORT_ENUMS | |
4707 | /* Initialize how much space enums occupy, by default. */ | |
4708 | flag_short_enums = DEFAULT_SHORT_ENUMS; | |
4709 | #endif | |
4710 | ||
b53beeb2 RH |
4711 | /* Perform language-specific options intialization. */ |
4712 | lang_init_options (); | |
4713 | ||
4291d9c8 RS |
4714 | /* Scan to see what optimization level has been specified. That will |
4715 | determine the default value of many flags. */ | |
4716 | for (i = 1; i < argc; i++) | |
4717 | { | |
4718 | if (!strcmp (argv[i], "-O")) | |
4719 | { | |
4720 | optimize = 1; | |
16b6e120 | 4721 | optimize_size = 0; |
4291d9c8 RS |
4722 | } |
4723 | else if (argv[i][0] == '-' && argv[i][1] == 'O') | |
4724 | { | |
c6aded7c | 4725 | /* Handle -Os, -O2, -O3, -O69, ... */ |
4291d9c8 | 4726 | char *p = &argv[i][2]; |
c6aded7c AG |
4727 | |
4728 | if ((p[0] == 's') && (p[1] == 0)) | |
16b6e120 NC |
4729 | { |
4730 | optimize_size = 1; | |
4731 | ||
4732 | /* Optimizing for size forces optimize to be 2. */ | |
4733 | optimize = 2; | |
4734 | } | |
c6aded7c AG |
4735 | else |
4736 | { | |
192babfd TP |
4737 | const int optimize_val = read_integral_parameter (p, p - 2, -1); |
4738 | if (optimize_val != -1) | |
16b6e120 | 4739 | { |
192babfd | 4740 | optimize = optimize_val; |
16b6e120 NC |
4741 | optimize_size = 0; |
4742 | } | |
c6aded7c | 4743 | } |
4291d9c8 RS |
4744 | } |
4745 | } | |
4746 | ||
4747 | obey_regdecls = (optimize == 0); | |
4291d9c8 RS |
4748 | |
4749 | if (optimize >= 1) | |
4750 | { | |
6731a3e3 | 4751 | flag_defer_pop = 1; |
4291d9c8 RS |
4752 | flag_thread_jumps = 1; |
4753 | #ifdef DELAY_SLOTS | |
4754 | flag_delayed_branch = 1; | |
7e89c3a3 RK |
4755 | #endif |
4756 | #ifdef CAN_DEBUG_WITHOUT_FP | |
4757 | flag_omit_frame_pointer = 1; | |
4291d9c8 RS |
4758 | #endif |
4759 | } | |
4760 | ||
4761 | if (optimize >= 2) | |
4762 | { | |
4763 | flag_cse_follow_jumps = 1; | |
8b3686ed | 4764 | flag_cse_skip_blocks = 1; |
7506f491 | 4765 | flag_gcse = 1; |
4291d9c8 RS |
4766 | flag_expensive_optimizations = 1; |
4767 | flag_strength_reduce = 1; | |
4768 | flag_rerun_cse_after_loop = 1; | |
6d6d0fa0 | 4769 | flag_rerun_loop_opt = 1; |
ac266247 | 4770 | flag_caller_saves = 1; |
4ac8e06e | 4771 | flag_force_mem = 1; |
4291d9c8 RS |
4772 | #ifdef INSN_SCHEDULING |
4773 | flag_schedule_insns = 1; | |
4774 | flag_schedule_insns_after_reload = 1; | |
4775 | #endif | |
8c660648 | 4776 | flag_regmove = 1; |
3f9a83a9 | 4777 | flag_strict_aliasing = 1; |
4291d9c8 RS |
4778 | } |
4779 | ||
7e89c3a3 RK |
4780 | if (optimize >= 3) |
4781 | { | |
4782 | flag_inline_functions = 1; | |
4783 | } | |
4784 | ||
c1da383f DE |
4785 | /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can |
4786 | modify it. */ | |
4787 | target_flags = 0; | |
4788 | set_target_switch (""); | |
4789 | ||
4291d9c8 RS |
4790 | #ifdef OPTIMIZATION_OPTIONS |
4791 | /* Allow default optimizations to be specified on a per-machine basis. */ | |
c6aded7c | 4792 | OPTIMIZATION_OPTIONS (optimize, optimize_size); |
4291d9c8 RS |
4793 | #endif |
4794 | ||
4795 | /* Initialize register usage now so switches may override. */ | |
4796 | init_reg_sets (); | |
4797 | ||
4291d9c8 RS |
4798 | for (i = 1; i < argc; i++) |
4799 | { | |
85066503 | 4800 | size_t j; |
b8468bc7 | 4801 | |
b99933c7 RS |
4802 | /* If this is a language-specific option, |
4803 | decode it in a language-specific way. */ | |
b8468bc7 NC |
4804 | for (j = NUM_ELEM (documented_lang_options); j--;) |
4805 | if (check_lang_option (argv[i], documented_lang_options[j].option)) | |
b99933c7 | 4806 | break; |
b8468bc7 | 4807 | |
114791ea | 4808 | if (j != (size_t)-1) |
a0d85b75 DB |
4809 | { |
4810 | /* If the option is valid for *some* language, | |
4811 | treat it as valid even if this language doesn't understand it. */ | |
4812 | int strings_processed = lang_decode_option (argc - i, argv + i); | |
40f943dd NC |
4813 | |
4814 | if (!strcmp (argv[i], "--help")) | |
4815 | { | |
4816 | display_help (); | |
4817 | exit (0); | |
4818 | } | |
4819 | ||
a0d85b75 DB |
4820 | if (strings_processed != 0) |
4821 | i += strings_processed - 1; | |
4822 | } | |
b99933c7 | 4823 | else if (argv[i][0] == '-' && argv[i][1] != 0) |
4291d9c8 RS |
4824 | { |
4825 | register char *str = argv[i] + 1; | |
4826 | if (str[0] == 'Y') | |
4827 | str++; | |
4828 | ||
4829 | if (str[0] == 'm') | |
4830 | set_target_switch (&str[1]); | |
4831 | else if (!strcmp (str, "dumpbase")) | |
4832 | { | |
4833 | dump_base_name = argv[++i]; | |
4834 | } | |
4835 | else if (str[0] == 'd') | |
4836 | { | |
4837 | register char *p = &str[1]; | |
4838 | while (*p) | |
4839 | switch (*p++) | |
4840 | { | |
4841 | case 'a': | |
0d332add | 4842 | branch_prob_dump = 1; |
4291d9c8 | 4843 | combine_dump = 1; |
bd334356 | 4844 | #ifdef DELAY_SLOTS |
4291d9c8 | 4845 | dbr_sched_dump = 1; |
bd334356 | 4846 | #endif |
4291d9c8 | 4847 | flow_dump = 1; |
e881bb1b | 4848 | flow2_dump = 1; |
4291d9c8 RS |
4849 | global_reg_dump = 1; |
4850 | jump_opt_dump = 1; | |
e9a25f70 | 4851 | addressof_dump = 1; |
4291d9c8 RS |
4852 | jump2_opt_dump = 1; |
4853 | local_reg_dump = 1; | |
4854 | loop_dump = 1; | |
8c660648 | 4855 | regmove_dump = 1; |
4291d9c8 RS |
4856 | rtl_dump = 1; |
4857 | cse_dump = 1, cse2_dump = 1; | |
7506f491 | 4858 | gcse_dump = 1; |
4291d9c8 RS |
4859 | sched_dump = 1; |
4860 | sched2_dump = 1; | |
032713aa | 4861 | #ifdef STACK_REGS |
4291d9c8 | 4862 | stack_reg_dump = 1; |
032713aa NC |
4863 | #endif |
4864 | #ifdef MACHINE_DEPENDENT_REORG | |
4865 | mach_dep_reorg_dump = 1; | |
4866 | #endif | |
4291d9c8 | 4867 | break; |
f5963e61 JL |
4868 | case 'A': |
4869 | flag_debug_asm = 1; | |
4870 | break; | |
0d332add DE |
4871 | case 'b': |
4872 | branch_prob_dump = 1; | |
4873 | break; | |
4291d9c8 RS |
4874 | case 'c': |
4875 | combine_dump = 1; | |
4876 | break; | |
bd334356 | 4877 | #ifdef DELAY_SLOTS |
4291d9c8 RS |
4878 | case 'd': |
4879 | dbr_sched_dump = 1; | |
4880 | break; | |
bd334356 | 4881 | #endif |
4291d9c8 RS |
4882 | case 'f': |
4883 | flow_dump = 1; | |
4884 | break; | |
f5963e61 JL |
4885 | case 'F': |
4886 | addressof_dump = 1; | |
4887 | break; | |
4291d9c8 RS |
4888 | case 'g': |
4889 | global_reg_dump = 1; | |
7506f491 DE |
4890 | break; |
4891 | case 'G': | |
4892 | gcse_dump = 1; | |
4291d9c8 RS |
4893 | break; |
4894 | case 'j': | |
4895 | jump_opt_dump = 1; | |
4896 | break; | |
4897 | case 'J': | |
4898 | jump2_opt_dump = 1; | |
4899 | break; | |
f5963e61 JL |
4900 | #ifdef STACK_REGS |
4901 | case 'k': | |
4902 | stack_reg_dump = 1; | |
4903 | break; | |
4904 | #endif | |
4291d9c8 RS |
4905 | case 'l': |
4906 | local_reg_dump = 1; | |
4907 | break; | |
4908 | case 'L': | |
4909 | loop_dump = 1; | |
4910 | break; | |
4911 | case 'm': | |
4912 | flag_print_mem = 1; | |
4913 | break; | |
032713aa NC |
4914 | #ifdef MACHINE_DEPENDENT_REORG |
4915 | case 'M': | |
4916 | mach_dep_reorg_dump = 1; | |
4917 | break; | |
4918 | #endif | |
4291d9c8 RS |
4919 | case 'p': |
4920 | flag_print_asm_name = 1; | |
4921 | break; | |
4922 | case 'r': | |
4923 | rtl_dump = 1; | |
4924 | break; | |
f5963e61 JL |
4925 | case 'R': |
4926 | sched2_dump = 1; | |
4927 | break; | |
4291d9c8 RS |
4928 | case 's': |
4929 | cse_dump = 1; | |
4930 | break; | |
f5963e61 JL |
4931 | case 'S': |
4932 | sched_dump = 1; | |
4933 | break; | |
4291d9c8 RS |
4934 | case 't': |
4935 | cse2_dump = 1; | |
4936 | break; | |
8c660648 JL |
4937 | case 'N': |
4938 | regmove_dump = 1; | |
4939 | break; | |
735a0e33 UD |
4940 | case 'v': |
4941 | graph_dump_format = vcg; | |
4942 | break; | |
e881bb1b RH |
4943 | case 'w': |
4944 | flow2_dump = 1; | |
4945 | break; | |
4291d9c8 RS |
4946 | case 'y': |
4947 | set_yydebug (1); | |
4948 | break; | |
4291d9c8 RS |
4949 | case 'x': |
4950 | rtl_dump_and_exit = 1; | |
4951 | break; | |
b5c7059b MM |
4952 | case 'D': /* these are handled by the preprocessor */ |
4953 | case 'I': | |
b5c7059b | 4954 | break; |
032713aa NC |
4955 | default: |
4956 | warning ("unrecognised gcc debugging option: %c", p[-1]); | |
4957 | break; | |
4291d9c8 RS |
4958 | } |
4959 | } | |
4960 | else if (str[0] == 'f') | |
4961 | { | |
4291d9c8 RS |
4962 | register char *p = &str[1]; |
4963 | int found = 0; | |
4964 | ||
4965 | /* Some kind of -f option. | |
4966 | P's value is the option sans `-f'. | |
4967 | Search for it in the table of options. */ | |
4968 | ||
4969 | for (j = 0; | |
4970 | !found && j < sizeof (f_options) / sizeof (f_options[0]); | |
4971 | j++) | |
4972 | { | |
4973 | if (!strcmp (p, f_options[j].string)) | |
4974 | { | |
4975 | *f_options[j].variable = f_options[j].on_value; | |
4976 | /* A goto here would be cleaner, | |
4977 | but breaks the vax pcc. */ | |
4978 | found = 1; | |
4979 | } | |
4980 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
4981 | && ! strcmp (p+3, f_options[j].string)) | |
4982 | { | |
4983 | *f_options[j].variable = ! f_options[j].on_value; | |
4984 | found = 1; | |
4985 | } | |
4986 | } | |
4987 | ||
4988 | if (found) | |
4989 | ; | |
8c660648 JL |
4990 | #ifdef HAIFA |
4991 | #ifdef INSN_SCHEDULING | |
4992 | else if (!strncmp (p, "sched-verbose-",14)) | |
4993 | fix_sched_param("verbose",&p[14]); | |
8c660648 JL |
4994 | #endif |
4995 | #endif /* HAIFA */ | |
4291d9c8 RS |
4996 | else if (!strncmp (p, "fixed-", 6)) |
4997 | fix_register (&p[6], 1, 1); | |
4998 | else if (!strncmp (p, "call-used-", 10)) | |
4999 | fix_register (&p[10], 0, 1); | |
5000 | else if (!strncmp (p, "call-saved-", 11)) | |
5001 | fix_register (&p[11], 0, 0); | |
b99933c7 | 5002 | else |
4291d9c8 RS |
5003 | error ("Invalid option `%s'", argv[i]); |
5004 | } | |
5005 | else if (str[0] == 'O') | |
5006 | { | |
192babfd | 5007 | /* Already been treated above. Do nothing. */ |
4291d9c8 RS |
5008 | } |
5009 | else if (!strcmp (str, "pedantic")) | |
5010 | pedantic = 1; | |
5011 | else if (!strcmp (str, "pedantic-errors")) | |
5012 | flag_pedantic_errors = pedantic = 1; | |
4291d9c8 RS |
5013 | else if (!strcmp (str, "quiet")) |
5014 | quiet_flag = 1; | |
5015 | else if (!strcmp (str, "version")) | |
5016 | version_flag = 1; | |
5017 | else if (!strcmp (str, "w")) | |
5018 | inhibit_warnings = 1; | |
5019 | else if (!strcmp (str, "W")) | |
5020 | { | |
5021 | extra_warnings = 1; | |
fa1a4543 RS |
5022 | /* We save the value of warn_uninitialized, since if they put |
5023 | -Wuninitialized on the command line, we need to generate a | |
5024 | warning about not using it without also specifying -O. */ | |
5025 | if (warn_uninitialized != 1) | |
5026 | warn_uninitialized = 2; | |
4291d9c8 RS |
5027 | } |
5028 | else if (str[0] == 'W') | |
5029 | { | |
4291d9c8 RS |
5030 | register char *p = &str[1]; |
5031 | int found = 0; | |
5032 | ||
5033 | /* Some kind of -W option. | |
5034 | P's value is the option sans `-W'. | |
5035 | Search for it in the table of options. */ | |
5036 | ||
5037 | for (j = 0; | |
5038 | !found && j < sizeof (W_options) / sizeof (W_options[0]); | |
5039 | j++) | |
5040 | { | |
5041 | if (!strcmp (p, W_options[j].string)) | |
5042 | { | |
5043 | *W_options[j].variable = W_options[j].on_value; | |
5044 | /* A goto here would be cleaner, | |
5045 | but breaks the vax pcc. */ | |
5046 | found = 1; | |
5047 | } | |
5048 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
5049 | && ! strcmp (p+3, W_options[j].string)) | |
5050 | { | |
5051 | *W_options[j].variable = ! W_options[j].on_value; | |
5052 | found = 1; | |
5053 | } | |
5054 | } | |
5055 | ||
5056 | if (found) | |
5057 | ; | |
5058 | else if (!strncmp (p, "id-clash-", 9)) | |
5059 | { | |
192babfd TP |
5060 | const int id_clash_val |
5061 | = read_integral_parameter (p + 9, p - 2, -1); | |
5062 | if (id_clash_val != -1) | |
4291d9c8 | 5063 | { |
192babfd TP |
5064 | id_clash_len = id_clash_val; |
5065 | warn_id_clash = 1; | |
4291d9c8 | 5066 | } |
4291d9c8 | 5067 | } |
b51e9c62 RK |
5068 | else if (!strncmp (p, "larger-than-", 12)) |
5069 | { | |
192babfd TP |
5070 | const int larger_than_val |
5071 | = read_integral_parameter (p + 12, p - 2, -1); | |
5072 | if (larger_than_val != -1) | |
b51e9c62 | 5073 | { |
192babfd TP |
5074 | larger_than_size = larger_than_val; |
5075 | warn_larger_than = 1; | |
b51e9c62 | 5076 | } |
b51e9c62 | 5077 | } |
4291d9c8 RS |
5078 | else |
5079 | error ("Invalid option `%s'", argv[i]); | |
5080 | } | |
5081 | else if (!strcmp (str, "p")) | |
ca695ac9 | 5082 | { |
c2d12c8b | 5083 | profile_flag = 1; |
ca695ac9 | 5084 | } |
4291d9c8 RS |
5085 | else if (!strcmp (str, "a")) |
5086 | { | |
5087 | #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
5088 | warning ("`-a' option (basic block profile) not supported"); | |
5089 | #else | |
ec6c615d RK |
5090 | profile_block_flag = (profile_block_flag < 2) ? 1 : 3; |
5091 | #endif | |
5092 | } | |
5093 | else if (!strcmp (str, "ax")) | |
5094 | { | |
5095 | #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
5096 | warning ("`-ax' option (jump profiling) not supported"); | |
5097 | #else | |
5098 | profile_block_flag = (!profile_block_flag | |
5099 | || profile_block_flag == 2) ? 2 : 3; | |
4291d9c8 RS |
5100 | #endif |
5101 | } | |
5102 | else if (str[0] == 'g') | |
5103 | { | |
4291d9c8 | 5104 | unsigned level; |
ff482cef DE |
5105 | /* A lot of code assumes write_symbols == NO_DEBUG if the |
5106 | debugging level is 0 (thus -gstabs1 -gstabs0 would lose track | |
5107 | of what debugging type has been selected). This records the | |
5108 | selected type. It is an error to specify more than one | |
5109 | debugging type. */ | |
5110 | static enum debug_info_type selected_debug_type = NO_DEBUG; | |
5111 | /* Non-zero if debugging format has been explicitly set. | |
5112 | -g and -ggdb don't explicitly set the debugging format so | |
5113 | -gdwarf -g3 is equivalent to -gdwarf3. */ | |
5114 | static int type_explicitly_set_p = 0; | |
ff482cef | 5115 | /* Indexed by enum debug_info_type. */ |
87e11268 | 5116 | static const char *debug_type_names[] = |
b8468bc7 | 5117 | { |
9a666dda | 5118 | "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff" |
ff482cef | 5119 | }; |
4291d9c8 | 5120 | |
192babfd TP |
5121 | /* The maximum admissible debug level value. */ |
5122 | static const unsigned max_debug_level = 3; | |
5123 | ||
ff482cef DE |
5124 | /* Look up STR in the table. */ |
5125 | for (da = debug_args; da->arg; da++) | |
5126 | { | |
192babfd TP |
5127 | const int da_len = strlen (da->arg); |
5128 | ||
5129 | if (! strncmp (str, da->arg, da_len)) | |
ff482cef DE |
5130 | { |
5131 | enum debug_info_type type = da->debug_type; | |
192babfd | 5132 | const char *p = str + da_len; |
9a666dda | 5133 | |
9a666dda JM |
5134 | if (*p && (*p < '0' || *p > '9')) |
5135 | continue; | |
192babfd | 5136 | |
43c2d67a JL |
5137 | /* A debug flag without a level defaults to level 2. |
5138 | Note we do not want to call read_integral_parameter | |
5139 | for that case since it will call atoi which | |
5140 | will return zero. | |
5141 | ||
5142 | ??? We may want to generalize the interface to | |
5143 | read_integral_parameter to better handle this case | |
5144 | if this case shows up often. */ | |
5145 | if (*p) | |
5146 | level = read_integral_parameter (p, 0, | |
5147 | max_debug_level + 1); | |
5148 | else | |
5149 | level = 2; | |
5150 | ||
192babfd | 5151 | if (da_len > 1 && !strncmp (str, "gdwarf", da_len)) |
33e5c8c3 | 5152 | { |
192babfd TP |
5153 | error ("use -gdwarf -g%d for DWARF v1, level %d", |
5154 | level, level); | |
5155 | if (level == 2) | |
5156 | error ("use -gdwarf-2 for DWARF v2"); | |
33e5c8c3 | 5157 | } |
192babfd TP |
5158 | |
5159 | if (level > max_debug_level) | |
9a666dda | 5160 | { |
192babfd TP |
5161 | warning ("ignoring option `%s' due to invalid debug level specification", |
5162 | str - 1); | |
5163 | level = debug_info_level; | |
9a666dda JM |
5164 | } |
5165 | ||
ff482cef | 5166 | if (type == NO_DEBUG) |
fe0986b4 JM |
5167 | { |
5168 | type = PREFERRED_DEBUGGING_TYPE; | |
192babfd | 5169 | if (da_len > 1 && strncmp (str, "ggdb", da_len) == 0) |
fe0986b4 | 5170 | { |
deabc777 | 5171 | #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2) |
fe0986b4 | 5172 | type = DWARF2_DEBUG; |
417b0fa2 JW |
5173 | #else |
5174 | #ifdef DBX_DEBUGGING_INFO | |
fe0986b4 | 5175 | type = DBX_DEBUG; |
417b0fa2 | 5176 | #endif |
fe0986b4 JM |
5177 | #endif |
5178 | } | |
5179 | } | |
ff482cef | 5180 | |
e38eaffd RK |
5181 | if (type == NO_DEBUG) |
5182 | warning ("`-%s' not supported by this configuration of GCC", | |
5183 | str); | |
5184 | ||
ff482cef DE |
5185 | /* Does it conflict with an already selected type? */ |
5186 | if (type_explicitly_set_p | |
5187 | /* -g/-ggdb don't conflict with anything */ | |
5188 | && da->debug_type != NO_DEBUG | |
5189 | && type != selected_debug_type) | |
5190 | warning ("`-%s' ignored, conflicts with `-g%s'", | |
5191 | str, debug_type_names[(int) selected_debug_type]); | |
5192 | else | |
5193 | { | |
5194 | /* If the format has already been set, -g/-ggdb | |
5195 | only change the debug level. */ | |
5196 | if (type_explicitly_set_p | |
5197 | && da->debug_type == NO_DEBUG) | |
5198 | ; /* don't change debugging type */ | |
5199 | else | |
5200 | { | |
5201 | selected_debug_type = type; | |
5202 | type_explicitly_set_p = da->debug_type != NO_DEBUG; | |
5203 | } | |
5204 | write_symbols = (level == 0 | |
5205 | ? NO_DEBUG | |
5206 | : selected_debug_type); | |
5207 | use_gnu_debug_info_extensions = da->use_extensions_p; | |
5208 | debug_info_level = (enum debug_info_level) level; | |
5209 | } | |
5210 | break; | |
5211 | } | |
5212 | } | |
5213 | if (! da->arg) | |
7276e85d RK |
5214 | warning ("`-%s' not supported by this configuration of GCC", |
5215 | str); | |
4291d9c8 RS |
5216 | } |
5217 | else if (!strcmp (str, "o")) | |
5218 | { | |
5219 | asm_file_name = argv[++i]; | |
5220 | } | |
5221 | else if (str[0] == 'G') | |
5222 | { | |
192babfd TP |
5223 | const int g_switch_val = (str[1] != '\0') ? |
5224 | read_integral_parameter(str + 1, 0, -1) : | |
5225 | read_integral_parameter(argv[++i], 0, -1); | |
5226 | ||
5227 | if (g_switch_val != -1) | |
5228 | { | |
5229 | g_switch_set = TRUE; | |
5230 | g_switch_value = g_switch_val; | |
5231 | } | |
5232 | else | |
5233 | { | |
5234 | error("Invalid option `-%s'",str); | |
5235 | } | |
4291d9c8 | 5236 | } |
f246a305 RS |
5237 | else if (!strncmp (str, "aux-info", 8)) |
5238 | { | |
5239 | flag_gen_aux_info = 1; | |
5240 | aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); | |
5241 | } | |
b8468bc7 NC |
5242 | else if (!strcmp (str, "-help")) |
5243 | { | |
5244 | display_help (); | |
5245 | exit (0); | |
5246 | } | |
4291d9c8 RS |
5247 | else |
5248 | error ("Invalid option `%s'", argv[i]); | |
5249 | } | |
5250 | else if (argv[i][0] == '+') | |
b99933c7 | 5251 | error ("Invalid option `%s'", argv[i]); |
4291d9c8 RS |
5252 | else |
5253 | filename = argv[i]; | |
5254 | } | |
5255 | ||
f602c208 RK |
5256 | /* Checker uses the frame pointer. */ |
5257 | if (flag_check_memory_usage) | |
5258 | flag_omit_frame_pointer = 0; | |
5259 | ||
f246a305 RS |
5260 | if (optimize == 0) |
5261 | { | |
a2468e45 BK |
5262 | /* Inlining does not work if not optimizing, |
5263 | so force it not to be done. */ | |
f246a305 RS |
5264 | flag_no_inline = 1; |
5265 | warn_inline = 0; | |
a2468e45 BK |
5266 | |
5267 | /* The c_decode_option and lang_decode_option functions set | |
5268 | this to `2' if -Wall is used, so we can avoid giving out | |
5269 | lots of errors for people who don't realize what -Wall does. */ | |
5270 | if (warn_uninitialized == 1) | |
5271 | warning ("-Wuninitialized is not supported without -O"); | |
f246a305 RS |
5272 | } |
5273 | ||
4291d9c8 RS |
5274 | #ifdef OVERRIDE_OPTIONS |
5275 | /* Some machines may reject certain combinations of options. */ | |
5276 | OVERRIDE_OPTIONS; | |
5277 | #endif | |
5278 | ||
d1485032 JM |
5279 | if (exceptions_via_longjmp == 2) |
5280 | { | |
5281 | #ifdef DWARF2_UNWIND_INFO | |
5282 | exceptions_via_longjmp = ! DWARF2_UNWIND_INFO; | |
5283 | #else | |
5284 | exceptions_via_longjmp = 1; | |
5285 | #endif | |
5286 | } | |
5287 | ||
ec6c615d RK |
5288 | if (profile_block_flag == 3) |
5289 | { | |
5290 | warning ("`-ax' and `-a' are conflicting options. `-a' ignored."); | |
5291 | profile_block_flag = 2; | |
5292 | } | |
5293 | ||
4291d9c8 RS |
5294 | /* Unrolling all loops implies that standard loop unrolling must also |
5295 | be done. */ | |
5296 | if (flag_unroll_all_loops) | |
5297 | flag_unroll_loops = 1; | |
5298 | /* Loop unrolling requires that strength_reduction be on also. Silently | |
5299 | turn on strength reduction here if it isn't already on. Also, the loop | |
5300 | unrolling code assumes that cse will be run after loop, so that must | |
5301 | be turned on also. */ | |
5302 | if (flag_unroll_loops) | |
5303 | { | |
5304 | flag_strength_reduce = 1; | |
5305 | flag_rerun_cse_after_loop = 1; | |
5306 | } | |
5307 | ||
5308 | /* Warn about options that are not supported on this machine. */ | |
5309 | #ifndef INSN_SCHEDULING | |
5310 | if (flag_schedule_insns || flag_schedule_insns_after_reload) | |
5311 | warning ("instruction scheduling not supported on this target machine"); | |
5312 | #endif | |
5313 | #ifndef DELAY_SLOTS | |
5314 | if (flag_delayed_branch) | |
5315 | warning ("this target machine does not have delayed branches"); | |
5316 | #endif | |
5317 | ||
19283265 RH |
5318 | user_label_prefix = USER_LABEL_PREFIX; |
5319 | if (flag_leading_underscore != -1) | |
5320 | { | |
5321 | /* If the default prefix is more complicated than "" or "_", | |
5322 | issue a warning and ignore this option. */ | |
5323 | if (user_label_prefix[0] == 0 || | |
5324 | (user_label_prefix[0] == '_' && user_label_prefix[1] == 0)) | |
5325 | { | |
5326 | user_label_prefix = flag_leading_underscore ? "_" : ""; | |
5327 | } | |
5328 | else | |
5329 | warning ("-f%sleading-underscore not supported on this target machine", | |
5330 | flag_leading_underscore ? "" : "no-"); | |
5331 | } | |
5332 | ||
4291d9c8 RS |
5333 | /* If we are in verbose mode, write out the version and maybe all the |
5334 | option flags in use. */ | |
5335 | if (version_flag) | |
5336 | { | |
3d5cdd42 | 5337 | print_version (stderr, ""); |
4291d9c8 | 5338 | if (! quiet_flag) |
3d5cdd42 | 5339 | print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n"); |
4291d9c8 RS |
5340 | } |
5341 | ||
4291d9c8 RS |
5342 | compile_file (filename); |
5343 | ||
58f4af8e | 5344 | #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX) |
4291d9c8 RS |
5345 | if (flag_print_mem) |
5346 | { | |
5347 | char *lim = (char *) sbrk (0); | |
5348 | ||
ab87f8c8 | 5349 | notice ("Data size %ld.\n", (long) (lim - (char *) &environ)); |
4291d9c8 RS |
5350 | fflush (stderr); |
5351 | ||
e9a25f70 | 5352 | #ifndef __MSDOS__ |
4291d9c8 RS |
5353 | #ifdef USG |
5354 | system ("ps -l 1>&2"); | |
5355 | #else /* not USG */ | |
5356 | system ("ps v"); | |
5357 | #endif /* not USG */ | |
e9a25f70 | 5358 | #endif |
4291d9c8 | 5359 | } |
58f4af8e | 5360 | #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */ |
4291d9c8 RS |
5361 | |
5362 | if (errorcount) | |
5363 | exit (FATAL_EXIT_CODE); | |
5364 | if (sorrycount) | |
5365 | exit (FATAL_EXIT_CODE); | |
5366 | exit (SUCCESS_EXIT_CODE); | |
299846f2 | 5367 | return 0; |
4291d9c8 RS |
5368 | } |
5369 | \f | |
5370 | /* Decode -m switches. */ | |
4291d9c8 RS |
5371 | /* Decode the switch -mNAME. */ |
5372 | ||
114791ea | 5373 | static void |
4291d9c8 | 5374 | set_target_switch (name) |
87e11268 | 5375 | const char *name; |
4291d9c8 | 5376 | { |
85066503 | 5377 | register size_t j; |
ab87f8c8 | 5378 | int valid_target_option = 0; |
4291d9c8 RS |
5379 | |
5380 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
5381 | if (!strcmp (target_switches[j].name, name)) | |
5382 | { | |
5383 | if (target_switches[j].value < 0) | |
5384 | target_flags &= ~-target_switches[j].value; | |
5385 | else | |
5386 | target_flags |= target_switches[j].value; | |
ab87f8c8 | 5387 | valid_target_option = 1; |
4291d9c8 RS |
5388 | } |
5389 | ||
5390 | #ifdef TARGET_OPTIONS | |
ab87f8c8 | 5391 | if (!valid_target_option) |
4291d9c8 RS |
5392 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) |
5393 | { | |
5394 | int len = strlen (target_options[j].prefix); | |
5395 | if (!strncmp (target_options[j].prefix, name, len)) | |
5396 | { | |
5397 | *target_options[j].variable = name + len; | |
ab87f8c8 | 5398 | valid_target_option = 1; |
4291d9c8 RS |
5399 | } |
5400 | } | |
5401 | #endif | |
5402 | ||
ab87f8c8 | 5403 | if (!valid_target_option) |
4291d9c8 RS |
5404 | error ("Invalid option `%s'", name); |
5405 | } | |
5406 | \f | |
3d5cdd42 DE |
5407 | /* Print version information to FILE. |
5408 | Each line begins with INDENT (for the case where FILE is the | |
5409 | assembler output file). */ | |
4291d9c8 | 5410 | |
114791ea | 5411 | static void |
3d5cdd42 DE |
5412 | print_version (file, indent) |
5413 | FILE *file; | |
87e11268 | 5414 | const char *indent; |
4291d9c8 | 5415 | { |
3d5cdd42 | 5416 | #ifndef __VERSION__ |
ab87f8c8 | 5417 | #define __VERSION__ "[?]" |
3d5cdd42 | 5418 | #endif |
ab87f8c8 JL |
5419 | fnotice (file, |
5420 | #ifdef __GNUC__ | |
5421 | "%s%s%s version %s (%s) compiled by GNU C version %s.\n" | |
3d5cdd42 | 5422 | #else |
ab87f8c8 | 5423 | "%s%s%s version %s (%s) compiled by CC.\n" |
3d5cdd42 | 5424 | #endif |
ab87f8c8 JL |
5425 | , indent, *indent != 0 ? " " : "", |
5426 | language_string, version_string, TARGET_NAME, __VERSION__); | |
3d5cdd42 | 5427 | } |
4291d9c8 | 5428 | |
3d5cdd42 | 5429 | /* Print an option value and return the adjusted position in the line. |
309a8875 DE |
5430 | ??? We don't handle error returns from fprintf (disk full); presumably |
5431 | other code will catch a disk full though. */ | |
4291d9c8 | 5432 | |
114791ea | 5433 | static int |
3d5cdd42 DE |
5434 | print_single_switch (file, pos, max, indent, sep, term, type, name) |
5435 | FILE *file; | |
5436 | int pos, max; | |
87e11268 | 5437 | const char *indent, *sep, *term, *type, *name; |
3d5cdd42 | 5438 | { |
309a8875 DE |
5439 | /* The ultrix fprintf returns 0 on success, so compute the result we want |
5440 | here since we need it for the following test. */ | |
5441 | int len = strlen (sep) + strlen (type) + strlen (name); | |
5442 | ||
3d5cdd42 | 5443 | if (pos != 0 |
309a8875 | 5444 | && pos + len > max) |
4291d9c8 | 5445 | { |
3d5cdd42 DE |
5446 | fprintf (file, "%s", term); |
5447 | pos = 0; | |
4291d9c8 | 5448 | } |
3d5cdd42 DE |
5449 | if (pos == 0) |
5450 | { | |
309a8875 DE |
5451 | fprintf (file, "%s", indent); |
5452 | pos = strlen (indent); | |
3d5cdd42 | 5453 | } |
309a8875 DE |
5454 | fprintf (file, "%s%s%s", sep, type, name); |
5455 | pos += len; | |
3d5cdd42 | 5456 | return pos; |
4291d9c8 RS |
5457 | } |
5458 | ||
3d5cdd42 DE |
5459 | /* Print active target switches to FILE. |
5460 | POS is the current cursor position and MAX is the size of a "line". | |
5461 | Each line begins with INDENT and ends with TERM. | |
5462 | Each switch is separated from the next by SEP. */ | |
4291d9c8 | 5463 | |
25074193 | 5464 | static void |
3d5cdd42 DE |
5465 | print_switch_values (file, pos, max, indent, sep, term) |
5466 | FILE *file; | |
5467 | int pos, max; | |
87e11268 | 5468 | const char *indent, *sep, *term; |
4291d9c8 | 5469 | { |
85066503 | 5470 | size_t j; |
3d5cdd42 DE |
5471 | char **p; |
5472 | ||
5473 | /* Print the options as passed. */ | |
4291d9c8 | 5474 | |
3d5cdd42 | 5475 | pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term, |
ab87f8c8 | 5476 | _("options passed: "), ""); |
3d5cdd42 | 5477 | |
520e7ff5 | 5478 | for (p = &save_argv[1]; *p != NULL; p++) |
3d5cdd42 DE |
5479 | if (**p == '-') |
5480 | { | |
5481 | /* Ignore these. */ | |
520e7ff5 DE |
5482 | if (strcmp (*p, "-o") == 0) |
5483 | { | |
5484 | if (p[1] != NULL) | |
5485 | p++; | |
5486 | continue; | |
5487 | } | |
3d5cdd42 DE |
5488 | if (strcmp (*p, "-quiet") == 0) |
5489 | continue; | |
5490 | if (strcmp (*p, "-version") == 0) | |
5491 | continue; | |
5492 | if ((*p)[1] == 'd') | |
5493 | continue; | |
5494 | ||
5495 | pos = print_single_switch (file, pos, max, indent, sep, term, *p, ""); | |
5496 | } | |
5497 | if (pos > 0) | |
5498 | fprintf (file, "%s", term); | |
5499 | ||
5500 | /* Print the -f and -m options that have been enabled. | |
5501 | We don't handle language specific options but printing argv | |
5502 | should suffice. */ | |
5503 | ||
5504 | pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term, | |
ab87f8c8 | 5505 | _("options enabled: "), ""); |
4291d9c8 RS |
5506 | |
5507 | for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) | |
5508 | if (*f_options[j].variable == f_options[j].on_value) | |
3d5cdd42 DE |
5509 | pos = print_single_switch (file, pos, max, indent, sep, term, |
5510 | "-f", f_options[j].string); | |
4291d9c8 | 5511 | |
3d5cdd42 | 5512 | /* Print target specific options. */ |
4291d9c8 RS |
5513 | |
5514 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
5515 | if (target_switches[j].name[0] != '\0' | |
5516 | && target_switches[j].value > 0 | |
5517 | && ((target_switches[j].value & target_flags) | |
5518 | == target_switches[j].value)) | |
3d5cdd42 DE |
5519 | { |
5520 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
5521 | "-m", target_switches[j].name); | |
3d5cdd42 DE |
5522 | } |
5523 | ||
5524 | #ifdef TARGET_OPTIONS | |
5525 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
5526 | if (*target_options[j].variable != NULL) | |
5527 | { | |
5528 | char prefix[256]; | |
5529 | sprintf (prefix, "-m%s", target_options[j].prefix); | |
5530 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
5531 | prefix, *target_options[j].variable); | |
5532 | } | |
5533 | #endif | |
4291d9c8 | 5534 | |
3d5cdd42 | 5535 | fprintf (file, "%s", term); |
4291d9c8 | 5536 | } |
9a666dda JM |
5537 | |
5538 | /* Record the beginning of a new source file, named FILENAME. */ | |
5539 | ||
5540 | void | |
5541 | debug_start_source_file (filename) | |
54ea1de9 | 5542 | register char *filename ATTRIBUTE_UNUSED; |
9a666dda JM |
5543 | { |
5544 | #ifdef DBX_DEBUGGING_INFO | |
5545 | if (write_symbols == DBX_DEBUG) | |
5546 | dbxout_start_new_source_file (filename); | |
5547 | #endif | |
5548 | #ifdef DWARF_DEBUGGING_INFO | |
5549 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
5550 | && write_symbols == DWARF_DEBUG) | |
5551 | dwarfout_start_new_source_file (filename); | |
5552 | #endif /* DWARF_DEBUGGING_INFO */ | |
5553 | #ifdef DWARF2_DEBUGGING_INFO | |
5554 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
5555 | && write_symbols == DWARF2_DEBUG) | |
5556 | dwarf2out_start_source_file (filename); | |
5557 | #endif /* DWARF2_DEBUGGING_INFO */ | |
cc694a81 DE |
5558 | #ifdef SDB_DEBUGGING_INFO |
5559 | if (write_symbols == SDB_DEBUG) | |
5560 | sdbout_start_new_source_file (filename); | |
5561 | #endif | |
9a666dda JM |
5562 | } |
5563 | ||
5564 | /* Record the resumption of a source file. LINENO is the line number in | |
5565 | the source file we are returning to. */ | |
5566 | ||
5567 | void | |
5568 | debug_end_source_file (lineno) | |
c84e2712 | 5569 | register unsigned lineno ATTRIBUTE_UNUSED; |
9a666dda JM |
5570 | { |
5571 | #ifdef DBX_DEBUGGING_INFO | |
5572 | if (write_symbols == DBX_DEBUG) | |
5573 | dbxout_resume_previous_source_file (); | |
5574 | #endif | |
5575 | #ifdef DWARF_DEBUGGING_INFO | |
5576 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
5577 | && write_symbols == DWARF_DEBUG) | |
5578 | dwarfout_resume_previous_source_file (lineno); | |
5579 | #endif /* DWARF_DEBUGGING_INFO */ | |
5580 | #ifdef DWARF2_DEBUGGING_INFO | |
5581 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
5582 | && write_symbols == DWARF2_DEBUG) | |
5583 | dwarf2out_end_source_file (); | |
5584 | #endif /* DWARF2_DEBUGGING_INFO */ | |
cc694a81 DE |
5585 | #ifdef SDB_DEBUGGING_INFO |
5586 | if (write_symbols == SDB_DEBUG) | |
5587 | sdbout_resume_previous_source_file (); | |
5588 | #endif | |
9a666dda JM |
5589 | } |
5590 | ||
5591 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
5592 | the tail part of the directive line, i.e. the part which is past the | |
5593 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
5594 | ||
5595 | void | |
5596 | debug_define (lineno, buffer) | |
91813b28 KG |
5597 | register unsigned lineno ATTRIBUTE_UNUSED; |
5598 | register char *buffer ATTRIBUTE_UNUSED; | |
9a666dda JM |
5599 | { |
5600 | #ifdef DWARF_DEBUGGING_INFO | |
5601 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
5602 | && write_symbols == DWARF_DEBUG) | |
5603 | dwarfout_define (lineno, buffer); | |
5604 | #endif /* DWARF_DEBUGGING_INFO */ | |
5605 | #ifdef DWARF2_DEBUGGING_INFO | |
5606 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
5607 | && write_symbols == DWARF2_DEBUG) | |
5608 | dwarf2out_define (lineno, buffer); | |
5609 | #endif /* DWARF2_DEBUGGING_INFO */ | |
5610 | } | |
5611 | ||
5612 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
5613 | the tail part of the directive line, i.e. the part which is past the | |
5614 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
5615 | ||
5616 | void | |
5617 | debug_undef (lineno, buffer) | |
91813b28 KG |
5618 | register unsigned lineno ATTRIBUTE_UNUSED; |
5619 | register char *buffer ATTRIBUTE_UNUSED; | |
9a666dda JM |
5620 | { |
5621 | #ifdef DWARF_DEBUGGING_INFO | |
5622 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
5623 | && write_symbols == DWARF_DEBUG) | |
5624 | dwarfout_undef (lineno, buffer); | |
5625 | #endif /* DWARF_DEBUGGING_INFO */ | |
5626 | #ifdef DWARF2_DEBUGGING_INFO | |
5627 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
5628 | && write_symbols == DWARF2_DEBUG) | |
5629 | dwarf2out_undef (lineno, buffer); | |
5630 | #endif /* DWARF2_DEBUGGING_INFO */ | |
5631 | } |