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