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