]>
Commit | Line | Data |
---|---|---|
4291d9c8 | 1 | /* Top level of GNU C compiler |
912c4289 | 2 | Copyright (C) 1987, 88, 89, 92-5, 1996 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" | |
e0e2a8da | 27 | #ifdef __STDC__ |
04fe4385 | 28 | #include <stdarg.h> |
e0e2a8da | 29 | #else |
04fe4385 | 30 | #include <varargs.h> |
e0e2a8da | 31 | #endif |
4291d9c8 RS |
32 | #include <stdio.h> |
33 | #include <signal.h> | |
34 | #include <setjmp.h> | |
eb711c86 | 35 | #include <sys/types.h> |
ea9182cd | 36 | #include <ctype.h> |
4291d9c8 RS |
37 | #include <sys/stat.h> |
38 | ||
9580b583 | 39 | #ifndef _WIN32 |
4291d9c8 RS |
40 | #ifdef USG |
41 | #undef FLOAT | |
42 | #include <sys/param.h> | |
43 | /* This is for hpux. It is a real screw. They should change hpux. */ | |
44 | #undef FLOAT | |
45 | #include <sys/times.h> | |
46 | #include <time.h> /* Correct for hpux at least. Is it good on other USG? */ | |
47 | #undef FFS /* Some systems define this in param.h. */ | |
48 | #else | |
49 | #ifndef VMS | |
50 | #include <sys/time.h> | |
51 | #include <sys/resource.h> | |
52 | #endif | |
53 | #endif | |
eb910b5a | 54 | #endif |
4291d9c8 RS |
55 | |
56 | #include "input.h" | |
57 | #include "tree.h" | |
4291d9c8 RS |
58 | #include "rtl.h" |
59 | #include "flags.h" | |
60 | #include "insn-attr.h" | |
d0d4af87 | 61 | #include "defaults.h" |
e14417fa RK |
62 | #include "output.h" |
63 | #include "bytecode.h" | |
64 | #include "bc-emit.h" | |
f246a305 RS |
65 | |
66 | #ifdef XCOFF_DEBUGGING_INFO | |
67 | #include "xcoffout.h" | |
68 | #endif | |
4291d9c8 RS |
69 | \f |
70 | #ifdef VMS | |
71 | /* The extra parameters substantially improve the I/O performance. */ | |
72 | static FILE * | |
37c9f674 | 73 | vms_fopen (fname, type) |
4291d9c8 RS |
74 | char * fname; |
75 | char * type; | |
76 | { | |
37c9f674 RK |
77 | /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two |
78 | fixed arguments, which matches ANSI's specification but not VAXCRTL's | |
79 | pre-ANSI implementation. This hack circumvents the mismatch problem. */ | |
80 | FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen; | |
81 | ||
82 | if (*type == 'w') | |
83 | return (*vmslib_fopen) (fname, type, "mbc=32", | |
84 | "deq=64", "fop=tef", "shr=nil"); | |
85 | else | |
86 | return (*vmslib_fopen) (fname, type, "mbc=32"); | |
4291d9c8 | 87 | } |
37c9f674 RK |
88 | #define fopen vms_fopen |
89 | #endif /* VMS */ | |
4291d9c8 RS |
90 | |
91 | #ifndef DEFAULT_GDB_EXTENSIONS | |
92 | #define DEFAULT_GDB_EXTENSIONS 1 | |
93 | #endif | |
94 | ||
95 | extern int rtx_equal_function_value_matters; | |
96 | ||
72c8bb7f | 97 | #if ! (defined (VMS) || defined (OS2)) |
4291d9c8 | 98 | extern char **environ; |
4d7e336b | 99 | #endif |
4291d9c8 RS |
100 | extern char *version_string, *language_string; |
101 | ||
b0316e35 RS |
102 | /* Carry information from ASM_DECLARE_OBJECT_NAME |
103 | to ASM_FINISH_DECLARE_OBJECT. */ | |
104 | ||
105 | extern int size_directive_output; | |
5e10b3cc | 106 | extern tree last_assemble_variable_decl; |
b0316e35 | 107 | |
4291d9c8 RS |
108 | extern void init_lex (); |
109 | extern void init_decl_processing (); | |
110 | extern void init_obstacks (); | |
111 | extern void init_tree_codes (); | |
112 | extern void init_rtl (); | |
34d0205f | 113 | extern void init_regs (); |
4291d9c8 RS |
114 | extern void init_optabs (); |
115 | extern void init_stmt (); | |
116 | extern void init_reg_sets (); | |
117 | extern void dump_flow_info (); | |
118 | extern void dump_sched_info (); | |
119 | extern void dump_local_alloc (); | |
120 | ||
121 | void rest_of_decl_compilation (); | |
d18225c4 RK |
122 | void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...)); |
123 | void error_with_decl PVPROTO((tree decl, char *s, ...)); | |
124 | void error_for_asm PVPROTO((rtx insn, char *s, ...)); | |
125 | void error PVPROTO((char *s, ...)); | |
126 | void fatal PVPROTO((char *s, ...)); | |
127 | void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...)); | |
128 | void warning_with_decl PVPROTO((tree decl, char *s, ...)); | |
129 | void warning_for_asm PVPROTO((rtx insn, char *s, ...)); | |
130 | void warning PVPROTO((char *s, ...)); | |
131 | void pedwarn PVPROTO((char *s, ...)); | |
132 | void pedwarn_with_decl PVPROTO((tree decl, char *s, ...)); | |
133 | void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...)); | |
134 | void sorry PVPROTO((char *s, ...)); | |
135 | void really_sorry PVPROTO((char *s, ...)); | |
4291d9c8 RS |
136 | void fancy_abort (); |
137 | #ifndef abort | |
138 | void abort (); | |
139 | #endif | |
140 | void set_target_switch (); | |
141 | static void print_switch_values (); | |
142 | static char *decl_name (); | |
143 | ||
efa00f4e RK |
144 | #ifdef __alpha |
145 | extern char *sbrk (); | |
146 | #endif | |
147 | ||
4291d9c8 RS |
148 | /* Name of program invoked, sans directories. */ |
149 | ||
150 | char *progname; | |
151 | ||
152 | /* Copy of arguments to main. */ | |
153 | int save_argc; | |
154 | char **save_argv; | |
155 | \f | |
156 | /* Name of current original source file (what was input to cpp). | |
157 | This comes from each #-command in the actual input. */ | |
158 | ||
159 | char *input_filename; | |
160 | ||
161 | /* Name of top-level original source file (what was input to cpp). | |
162 | This comes from the #-command at the beginning of the actual input. | |
163 | If there isn't any there, then this is the cc1 input file name. */ | |
164 | ||
165 | char *main_input_filename; | |
166 | ||
167 | /* Stream for reading from the input file. */ | |
168 | ||
169 | FILE *finput; | |
170 | ||
171 | /* Current line number in real source file. */ | |
172 | ||
173 | int lineno; | |
174 | ||
175 | /* Stack of currently pending input files. */ | |
176 | ||
177 | struct file_stack *input_file_stack; | |
178 | ||
179 | /* Incremented on each change to input_file_stack. */ | |
180 | int input_file_stack_tick; | |
181 | ||
182 | /* FUNCTION_DECL for function now being parsed or compiled. */ | |
183 | ||
184 | extern tree current_function_decl; | |
185 | ||
186 | /* Name to use as base of names for dump output files. */ | |
187 | ||
188 | char *dump_base_name; | |
189 | ||
190 | /* Bit flags that specify the machine subtype we are compiling for. | |
191 | Bits are tested using macros TARGET_... defined in the tm.h file | |
192 | and set by `-m...' switches. Must be defined in rtlanal.c. */ | |
193 | ||
194 | extern int target_flags; | |
195 | ||
196 | /* Flags saying which kinds of debugging dump have been requested. */ | |
197 | ||
198 | int rtl_dump = 0; | |
199 | int rtl_dump_and_exit = 0; | |
200 | int jump_opt_dump = 0; | |
201 | int cse_dump = 0; | |
202 | int loop_dump = 0; | |
203 | int cse2_dump = 0; | |
204 | int flow_dump = 0; | |
205 | int combine_dump = 0; | |
206 | int sched_dump = 0; | |
207 | int local_reg_dump = 0; | |
208 | int global_reg_dump = 0; | |
209 | int sched2_dump = 0; | |
210 | int jump2_opt_dump = 0; | |
211 | int dbr_sched_dump = 0; | |
212 | int flag_print_asm_name = 0; | |
213 | int stack_reg_dump = 0; | |
214 | ||
215 | /* Name for output file of assembly code, specified with -o. */ | |
216 | ||
217 | char *asm_file_name; | |
218 | ||
219 | /* Value of the -G xx switch, and whether it was passed or not. */ | |
220 | int g_switch_value; | |
221 | int g_switch_set; | |
222 | ||
223 | /* Type(s) of debugging information we are producing (if any). | |
224 | See flags.h for the definitions of the different possible | |
225 | types of debugging information. */ | |
226 | enum debug_info_type write_symbols = NO_DEBUG; | |
227 | ||
228 | /* Level of debugging information we are producing. See flags.h | |
229 | for the definitions of the different possible levels. */ | |
230 | enum debug_info_level debug_info_level = DINFO_LEVEL_NONE; | |
231 | ||
a53d0bcc RS |
232 | /* Nonzero means use GNU-only extensions in the generated symbolic |
233 | debugging information. */ | |
234 | /* Currently, this only has an effect when write_symbols is set to | |
235 | DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */ | |
236 | int use_gnu_debug_info_extensions = 0; | |
4291d9c8 RS |
237 | |
238 | /* Nonzero means do optimizations. -O. | |
239 | Particular numeric values stand for particular amounts of optimization; | |
240 | thus, -O2 stores 2 here. However, the optimizations beyond the basic | |
241 | ones are not controlled directly by this variable. Instead, they are | |
242 | controlled by individual `flag_...' variables that are defaulted | |
243 | based on this variable. */ | |
244 | ||
245 | int optimize = 0; | |
246 | ||
247 | /* Number of error messages and warning messages so far. */ | |
248 | ||
249 | int errorcount = 0; | |
250 | int warningcount = 0; | |
251 | int sorrycount = 0; | |
252 | ||
ca695ac9 JB |
253 | /* Flag to output bytecode instead of native assembler */ |
254 | int output_bytecode = 0; | |
255 | ||
4291d9c8 RS |
256 | /* Pointer to function to compute the name to use to print a declaration. */ |
257 | ||
258 | char *(*decl_printable_name) (); | |
259 | ||
260 | /* Pointer to function to compute rtl for a language-specific tree code. */ | |
261 | ||
262 | struct rtx_def *(*lang_expand_expr) (); | |
263 | ||
2b599527 RS |
264 | /* Pointer to function to finish handling an incomplete decl at the |
265 | end of compilation. */ | |
266 | ||
267 | void (*incomplete_decl_finalize_hook) () = 0; | |
268 | ||
61d6b1cc MS |
269 | /* Pointer to function for interim exception handling implementation. |
270 | This interface will change, and it is only here until a better interface | |
271 | replaces it. */ | |
272 | ||
273 | void (*interim_eh_hook) PROTO((tree)); | |
274 | ||
4291d9c8 RS |
275 | /* Nonzero if generating code to do profiling. */ |
276 | ||
277 | int profile_flag = 0; | |
278 | ||
279 | /* Nonzero if generating code to do profiling on a line-by-line basis. */ | |
280 | ||
281 | int profile_block_flag; | |
282 | ||
283 | /* Nonzero for -pedantic switch: warn about anything | |
284 | that standard spec forbids. */ | |
285 | ||
286 | int pedantic = 0; | |
287 | ||
288 | /* Temporarily suppress certain warnings. | |
289 | This is set while reading code from a system header file. */ | |
290 | ||
291 | int in_system_header = 0; | |
292 | ||
293 | /* Nonzero means do stupid register allocation. | |
294 | Currently, this is 1 if `optimize' is 0. */ | |
295 | ||
296 | int obey_regdecls = 0; | |
297 | ||
298 | /* Don't print functions as they are compiled and don't print | |
299 | times taken by the various passes. -quiet. */ | |
300 | ||
301 | int quiet_flag = 0; | |
302 | \f | |
303 | /* -f flags. */ | |
304 | ||
305 | /* Nonzero means `char' should be signed. */ | |
306 | ||
307 | int flag_signed_char; | |
308 | ||
309 | /* Nonzero means give an enum type only as many bytes as it needs. */ | |
310 | ||
311 | int flag_short_enums; | |
312 | ||
313 | /* Nonzero for -fcaller-saves: allocate values in regs that need to | |
314 | be saved across function calls, if that produces overall better code. | |
315 | Optional now, so people can test it. */ | |
316 | ||
317 | #ifdef DEFAULT_CALLER_SAVES | |
318 | int flag_caller_saves = 1; | |
319 | #else | |
320 | int flag_caller_saves = 0; | |
321 | #endif | |
322 | ||
958ec8ca JW |
323 | /* Nonzero if structures and unions should be returned in memory. |
324 | ||
325 | This should only be defined if compatibility with another compiler or | |
326 | with an ABI is needed, because it results in slower code. */ | |
327 | ||
328 | #ifndef DEFAULT_PCC_STRUCT_RETURN | |
329 | #define DEFAULT_PCC_STRUCT_RETURN 1 | |
330 | #endif | |
331 | ||
4291d9c8 RS |
332 | /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ |
333 | ||
958ec8ca | 334 | int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN; |
4291d9c8 RS |
335 | |
336 | /* Nonzero for -fforce-mem: load memory value into a register | |
337 | before arithmetic on it. This makes better cse but slower compilation. */ | |
338 | ||
339 | int flag_force_mem = 0; | |
340 | ||
341 | /* Nonzero for -fforce-addr: load memory address into a register before | |
342 | reference to memory. This makes better cse but slower compilation. */ | |
343 | ||
344 | int flag_force_addr = 0; | |
345 | ||
346 | /* Nonzero for -fdefer-pop: don't pop args after each function call; | |
347 | instead save them up to pop many calls' args with one insns. */ | |
348 | ||
6731a3e3 | 349 | int flag_defer_pop = 0; |
4291d9c8 RS |
350 | |
351 | /* Nonzero for -ffloat-store: don't allocate floats and doubles | |
352 | in extended-precision registers. */ | |
353 | ||
354 | int flag_float_store = 0; | |
355 | ||
356 | /* Nonzero for -fcse-follow-jumps: | |
357 | have cse follow jumps to do a more extensive job. */ | |
358 | ||
359 | int flag_cse_follow_jumps; | |
360 | ||
8b3686ed RK |
361 | /* Nonzero for -fcse-skip-blocks: |
362 | have cse follow a branch around a block. */ | |
363 | int flag_cse_skip_blocks; | |
364 | ||
4291d9c8 RS |
365 | /* Nonzero for -fexpensive-optimizations: |
366 | perform miscellaneous relatively-expensive optimizations. */ | |
367 | int flag_expensive_optimizations; | |
368 | ||
369 | /* Nonzero for -fthread-jumps: | |
370 | have jump optimize output of loop. */ | |
371 | ||
372 | int flag_thread_jumps; | |
373 | ||
374 | /* Nonzero enables strength-reduction in loop.c. */ | |
375 | ||
376 | int flag_strength_reduce = 0; | |
377 | ||
378 | /* Nonzero enables loop unrolling in unroll.c. Only loops for which the | |
379 | number of iterations can be calculated at compile-time (UNROLL_COMPLETELY, | |
380 | UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are | |
381 | unrolled. */ | |
382 | ||
383 | int flag_unroll_loops; | |
384 | ||
385 | /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled. | |
386 | This is generally not a win. */ | |
387 | ||
388 | int flag_unroll_all_loops; | |
389 | ||
390 | /* Nonzero for -fwritable-strings: | |
391 | store string constants in data segment and don't uniquize them. */ | |
392 | ||
393 | int flag_writable_strings = 0; | |
394 | ||
395 | /* Nonzero means don't put addresses of constant functions in registers. | |
396 | Used for compiling the Unix kernel, where strange substitutions are | |
397 | done on the assembly output. */ | |
398 | ||
399 | int flag_no_function_cse = 0; | |
400 | ||
401 | /* Nonzero for -fomit-frame-pointer: | |
402 | don't make a frame pointer in simple functions that don't require one. */ | |
403 | ||
404 | int flag_omit_frame_pointer = 0; | |
405 | ||
406 | /* Nonzero to inhibit use of define_optimization peephole opts. */ | |
407 | ||
408 | int flag_no_peephole = 0; | |
409 | ||
43855b28 JL |
410 | /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math |
411 | operations in the interest of optimization. For example it allows | |
412 | GCC to assume arguments to sqrt are nonnegative numbers, allowing | |
413 | faster code for sqrt to be generated. */ | |
414 | ||
415 | int flag_fast_math = 0; | |
416 | ||
4291d9c8 RS |
417 | /* Nonzero means all references through pointers are volatile. */ |
418 | ||
419 | int flag_volatile; | |
c6e75897 RS |
420 | |
421 | /* Nonzero means treat all global and extern variables as global. */ | |
422 | ||
38d4d0c2 | 423 | int flag_volatile_global; |
4291d9c8 RS |
424 | |
425 | /* Nonzero means just do syntax checking; don't output anything. */ | |
426 | ||
427 | int flag_syntax_only = 0; | |
428 | ||
429 | /* Nonzero means to rerun cse after loop optimization. This increases | |
430 | compilation time about 20% and picks up a few more common expressions. */ | |
431 | ||
432 | static int flag_rerun_cse_after_loop; | |
433 | ||
434 | /* Nonzero for -finline-functions: ok to inline functions that look like | |
435 | good inline candidates. */ | |
436 | ||
437 | int flag_inline_functions; | |
438 | ||
439 | /* Nonzero for -fkeep-inline-functions: even if we make a function | |
ac2a9454 | 440 | go inline everywhere, keep its definition around for debugging |
4291d9c8 RS |
441 | purposes. */ |
442 | ||
443 | int flag_keep_inline_functions; | |
444 | ||
fadb3bc9 | 445 | /* Nonzero means that functions will not be inlined. */ |
4291d9c8 RS |
446 | |
447 | int flag_no_inline; | |
448 | ||
449 | /* Nonzero means we should be saving declaration info into a .X file. */ | |
450 | ||
451 | int flag_gen_aux_info = 0; | |
452 | ||
f246a305 RS |
453 | /* Specified name of aux-info file. */ |
454 | ||
455 | static char *aux_info_file_name; | |
456 | ||
4291d9c8 RS |
457 | /* Nonzero means make the text shared if supported. */ |
458 | ||
459 | int flag_shared_data; | |
460 | ||
461 | /* Nonzero means schedule into delayed branch slots if supported. */ | |
462 | ||
463 | int flag_delayed_branch; | |
464 | ||
5dab5552 MS |
465 | /* Nonzero means to run cleanups after CALL_EXPRs. */ |
466 | ||
467 | int flag_short_temps; | |
468 | ||
4291d9c8 RS |
469 | /* Nonzero if we are compiling pure (sharable) code. |
470 | Value is 1 if we are doing reasonable (i.e. simple | |
471 | offset into offset table) pic. Value is 2 if we can | |
472 | only perform register offsets. */ | |
473 | ||
474 | int flag_pic; | |
475 | ||
0382002b | 476 | /* Nonzero means place uninitialized global data in the bss section. */ |
4291d9c8 RS |
477 | |
478 | int flag_no_common; | |
479 | ||
480 | /* Nonzero means pretend it is OK to examine bits of target floats, | |
481 | even if that isn't true. The resulting code will have incorrect constants, | |
482 | but the same series of instructions that the native compiler would make. */ | |
483 | ||
484 | int flag_pretend_float; | |
485 | ||
486 | /* Nonzero means change certain warnings into errors. | |
487 | Usually these are warnings about failure to conform to some standard. */ | |
488 | ||
489 | int flag_pedantic_errors = 0; | |
490 | ||
491 | /* flag_schedule_insns means schedule insns within basic blocks (before | |
492 | local_alloc). | |
493 | flag_schedule_insns_after_reload means schedule insns after | |
494 | global_alloc. */ | |
495 | ||
496 | int flag_schedule_insns = 0; | |
497 | int flag_schedule_insns_after_reload = 0; | |
498 | ||
499 | /* -finhibit-size-directive inhibits output of .size for ELF. | |
500 | This is used only for compiling crtstuff.c, | |
501 | and it may be extended to other effects | |
502 | needed for crtstuff.c on other systems. */ | |
503 | int flag_inhibit_size_directive = 0; | |
504 | ||
9a631e8e RS |
505 | /* -fverbose-asm causes extra commentary information to be produced in |
506 | the generated assembly code (to make it more readable). This option | |
507 | is generally only of use to those who actually need to read the | |
508 | generated assembly code (perhaps while debugging the compiler itself). */ | |
509 | ||
510 | int flag_verbose_asm = 0; | |
511 | ||
4291d9c8 | 512 | /* -fgnu-linker specifies use of the GNU linker for initializations. |
d68c507d RS |
513 | (Or, more generally, a linker that handles initializations.) |
514 | -fno-gnu-linker says that collect2 will be used. */ | |
515 | #ifdef USE_COLLECT2 | |
516 | int flag_gnu_linker = 0; | |
517 | #else | |
4291d9c8 | 518 | int flag_gnu_linker = 1; |
d68c507d | 519 | #endif |
4291d9c8 | 520 | |
566cdc73 MM |
521 | /* Tag all structures with __attribute__(packed) */ |
522 | int flag_pack_struct = 0; | |
523 | ||
4291d9c8 RS |
524 | /* Table of language-independent -f options. |
525 | STRING is the option name. VARIABLE is the address of the variable. | |
526 | ON_VALUE is the value to store in VARIABLE | |
527 | if `-fSTRING' is seen as an option. | |
528 | (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ | |
529 | ||
530 | struct { char *string; int *variable; int on_value;} f_options[] = | |
531 | { | |
532 | {"float-store", &flag_float_store, 1}, | |
533 | {"volatile", &flag_volatile, 1}, | |
38d4d0c2 | 534 | {"volatile-global", &flag_volatile_global, 1}, |
4291d9c8 RS |
535 | {"defer-pop", &flag_defer_pop, 1}, |
536 | {"omit-frame-pointer", &flag_omit_frame_pointer, 1}, | |
537 | {"cse-follow-jumps", &flag_cse_follow_jumps, 1}, | |
8b3686ed | 538 | {"cse-skip-blocks", &flag_cse_skip_blocks, 1}, |
4291d9c8 RS |
539 | {"expensive-optimizations", &flag_expensive_optimizations, 1}, |
540 | {"thread-jumps", &flag_thread_jumps, 1}, | |
541 | {"strength-reduce", &flag_strength_reduce, 1}, | |
542 | {"unroll-loops", &flag_unroll_loops, 1}, | |
543 | {"unroll-all-loops", &flag_unroll_all_loops, 1}, | |
544 | {"writable-strings", &flag_writable_strings, 1}, | |
545 | {"peephole", &flag_no_peephole, 0}, | |
546 | {"force-mem", &flag_force_mem, 1}, | |
547 | {"force-addr", &flag_force_addr, 1}, | |
548 | {"function-cse", &flag_no_function_cse, 0}, | |
549 | {"inline-functions", &flag_inline_functions, 1}, | |
550 | {"keep-inline-functions", &flag_keep_inline_functions, 1}, | |
551 | {"inline", &flag_no_inline, 0}, | |
552 | {"syntax-only", &flag_syntax_only, 1}, | |
4291d9c8 RS |
553 | {"shared-data", &flag_shared_data, 1}, |
554 | {"caller-saves", &flag_caller_saves, 1}, | |
555 | {"pcc-struct-return", &flag_pcc_struct_return, 1}, | |
958ec8ca | 556 | {"reg-struct-return", &flag_pcc_struct_return, 0}, |
4291d9c8 RS |
557 | {"delayed-branch", &flag_delayed_branch, 1}, |
558 | {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1}, | |
559 | {"pretend-float", &flag_pretend_float, 1}, | |
560 | {"schedule-insns", &flag_schedule_insns, 1}, | |
561 | {"schedule-insns2", &flag_schedule_insns_after_reload, 1}, | |
562 | {"pic", &flag_pic, 1}, | |
563 | {"PIC", &flag_pic, 2}, | |
43855b28 | 564 | {"fast-math", &flag_fast_math, 1}, |
4291d9c8 RS |
565 | {"common", &flag_no_common, 0}, |
566 | {"inhibit-size-directive", &flag_inhibit_size_directive, 1}, | |
9a631e8e | 567 | {"verbose-asm", &flag_verbose_asm, 1}, |
422e2ed3 | 568 | {"gnu-linker", &flag_gnu_linker, 1}, |
566cdc73 | 569 | {"pack-struct", &flag_pack_struct, 1}, |
ca695ac9 | 570 | {"bytecode", &output_bytecode, 1} |
4291d9c8 | 571 | }; |
b99933c7 RS |
572 | |
573 | /* Table of language-specific options. */ | |
574 | ||
575 | char *lang_options[] = | |
576 | { | |
4200c8de | 577 | "-ansi", |
8305445b | 578 | "-fallow-single-precision", |
4200c8de | 579 | |
b99933c7 RS |
580 | "-fsigned-bitfields", |
581 | "-funsigned-bitfields", | |
582 | "-fno-signed-bitfields", | |
583 | "-fno-unsigned-bitfields", | |
4200c8de RK |
584 | "-fsigned-char", |
585 | "-funsigned-char", | |
586 | "-fno-signed-char", | |
587 | "-fno-unsigned-char", | |
588 | ||
589 | "-ftraditional", | |
590 | "-traditional", | |
591 | "-fnotraditional", | |
592 | "-fno-traditional", | |
593 | ||
b99933c7 RS |
594 | "-fasm", |
595 | "-fno-asm", | |
596 | "-fbuiltin", | |
597 | "-fno-builtin", | |
4200c8de RK |
598 | "-fcond-mismatch", |
599 | "-fno-cond-mismatch", | |
c7daad38 | 600 | "-fdollars-in-identifiers", |
57f0a224 | 601 | "-fno-dollars-in-identifiers", |
4200c8de RK |
602 | "-fident", |
603 | "-fno-ident", | |
604 | "-fshort-double", | |
605 | "-fno-short-double", | |
606 | "-fshort-enums", | |
607 | "-fno-short-enums", | |
608 | ||
609 | "-Wall", | |
289871f0 RK |
610 | "-Wbad-function-cast", |
611 | "-Wno-bad-function-cast", | |
b99933c7 RS |
612 | "-Wcast-qual", |
613 | "-Wno-cast-qual", | |
b99933c7 RS |
614 | "-Wchar-subscripts", |
615 | "-Wno-char-subscripts", | |
b99933c7 RS |
616 | "-Wcomment", |
617 | "-Wno-comment", | |
618 | "-Wcomments", | |
619 | "-Wno-comments", | |
4200c8de RK |
620 | "-Wconversion", |
621 | "-Wno-conversion", | |
622 | "-Wformat", | |
623 | "-Wno-format", | |
b99933c7 RS |
624 | "-Wimport", |
625 | "-Wno-import", | |
4200c8de RK |
626 | "-Wimplicit", |
627 | "-Wno-implicit", | |
f41372d4 RS |
628 | "-Wmissing-braces", |
629 | "-Wno-missing-braces", | |
4200c8de RK |
630 | "-Wmissing-declarations", |
631 | "-Wno-missing-declarations", | |
632 | "-Wmissing-prototypes", | |
633 | "-Wno-missing-prototypes", | |
634 | "-Wnested-externs", | |
635 | "-Wno-nested-externs", | |
636 | "-Wparentheses", | |
637 | "-Wno-parentheses", | |
638 | "-Wpointer-arith", | |
639 | "-Wno-pointer-arith", | |
640 | "-Wredundant-decls", | |
641 | "-Wno-redundant-decls", | |
d51f9363 JM |
642 | "-Wsign-compare", |
643 | "-Wno-sign-compare", | |
4200c8de RK |
644 | "-Wstrict-prototypes", |
645 | "-Wno-strict-prototypes", | |
646 | "-Wtraditional", | |
647 | "-Wno-traditional", | |
648 | "-Wtrigraphs", | |
649 | "-Wno-trigraphs", | |
650 | "-Wwrite-strings", | |
651 | "-Wno-write-strings", | |
b99933c7 | 652 | |
65faa6a4 RS |
653 | /* these are for obj c */ |
654 | "-lang-objc", | |
655 | "-gen-decls", | |
f5309ddf TW |
656 | "-fgnu-runtime", |
657 | "-fno-gnu-runtime", | |
658 | "-fnext-runtime", | |
659 | "-fno-next-runtime", | |
65faa6a4 RS |
660 | "-Wselector", |
661 | "-Wno-selector", | |
b800a01b KKT |
662 | "-Wprotocol", |
663 | "-Wno-protocol", | |
a457294f | 664 | |
2a95de17 | 665 | #include "options.h" |
b99933c7 RS |
666 | 0 |
667 | }; | |
4291d9c8 RS |
668 | \f |
669 | /* Options controlling warnings */ | |
670 | ||
671 | /* Don't print warning messages. -w. */ | |
672 | ||
673 | int inhibit_warnings = 0; | |
674 | ||
675 | /* Print various extra warnings. -W. */ | |
676 | ||
677 | int extra_warnings = 0; | |
678 | ||
679 | /* Treat warnings as errors. -Werror. */ | |
680 | ||
681 | int warnings_are_errors = 0; | |
682 | ||
683 | /* Nonzero to warn about unused local variables. */ | |
684 | ||
685 | int warn_unused; | |
686 | ||
687 | /* Nonzero to warn about variables used before they are initialized. */ | |
688 | ||
689 | int warn_uninitialized; | |
690 | ||
691 | /* Nonzero means warn about all declarations which shadow others. */ | |
692 | ||
693 | int warn_shadow; | |
694 | ||
695 | /* Warn if a switch on an enum fails to have a case for every enum value. */ | |
696 | ||
697 | int warn_switch; | |
698 | ||
699 | /* Nonzero means warn about function definitions that default the return type | |
700 | or that use a null return and have a return-type other than void. */ | |
701 | ||
702 | int warn_return_type; | |
703 | ||
704 | /* Nonzero means warn about pointer casts that increase the required | |
705 | alignment of the target type (and might therefore lead to a crash | |
706 | due to a misaligned access). */ | |
707 | ||
708 | int warn_cast_align; | |
709 | ||
710 | /* Nonzero means warn about any identifiers that match in the first N | |
711 | characters. The value N is in `id_clash_len'. */ | |
712 | ||
713 | int warn_id_clash; | |
b51e9c62 RK |
714 | unsigned id_clash_len; |
715 | ||
716 | /* Nonzero means warn about any objects definitions whose size is larger | |
717 | than N bytes. Also want about function definitions whose returned | |
718 | values are larger than N bytes. The value N is in `larger_than_size'. */ | |
719 | ||
720 | int warn_larger_than; | |
721 | unsigned larger_than_size; | |
4291d9c8 RS |
722 | |
723 | /* Nonzero means warn if inline function is too large. */ | |
724 | ||
725 | int warn_inline; | |
726 | ||
727 | /* Warn if a function returns an aggregate, | |
728 | since there are often incompatible calling conventions for doing this. */ | |
729 | ||
730 | int warn_aggregate_return; | |
731 | ||
732 | /* Likewise for -W. */ | |
733 | ||
734 | struct { char *string; int *variable; int on_value;} W_options[] = | |
735 | { | |
736 | {"unused", &warn_unused, 1}, | |
737 | {"error", &warnings_are_errors, 1}, | |
738 | {"shadow", &warn_shadow, 1}, | |
739 | {"switch", &warn_switch, 1}, | |
4291d9c8 RS |
740 | {"aggregate-return", &warn_aggregate_return, 1}, |
741 | {"cast-align", &warn_cast_align, 1}, | |
f246a305 RS |
742 | {"uninitialized", &warn_uninitialized, 1}, |
743 | {"inline", &warn_inline, 1} | |
4291d9c8 RS |
744 | }; |
745 | \f | |
746 | /* Output files for assembler code (real compiler output) | |
747 | and debugging dumps. */ | |
748 | ||
749 | FILE *asm_out_file; | |
750 | FILE *aux_info_file; | |
751 | FILE *rtl_dump_file; | |
752 | FILE *jump_opt_dump_file; | |
753 | FILE *cse_dump_file; | |
754 | FILE *loop_dump_file; | |
755 | FILE *cse2_dump_file; | |
756 | FILE *flow_dump_file; | |
757 | FILE *combine_dump_file; | |
758 | FILE *sched_dump_file; | |
759 | FILE *local_reg_dump_file; | |
760 | FILE *global_reg_dump_file; | |
761 | FILE *sched2_dump_file; | |
762 | FILE *jump2_opt_dump_file; | |
763 | FILE *dbr_sched_dump_file; | |
764 | FILE *stack_reg_dump_file; | |
765 | ||
766 | /* Time accumulators, to count the total time spent in various passes. */ | |
767 | ||
768 | int parse_time; | |
769 | int varconst_time; | |
770 | int integration_time; | |
771 | int jump_time; | |
772 | int cse_time; | |
773 | int loop_time; | |
774 | int cse2_time; | |
775 | int flow_time; | |
776 | int combine_time; | |
777 | int sched_time; | |
778 | int local_alloc_time; | |
779 | int global_alloc_time; | |
780 | int sched2_time; | |
781 | int dbr_sched_time; | |
782 | int shorten_branch_time; | |
783 | int stack_reg_time; | |
784 | int final_time; | |
785 | int symout_time; | |
786 | int dump_time; | |
787 | \f | |
788 | /* Return time used so far, in microseconds. */ | |
789 | ||
790 | int | |
791 | get_run_time () | |
792 | { | |
9580b583 | 793 | #ifndef _WIN32 |
4291d9c8 RS |
794 | #ifdef USG |
795 | struct tms tms; | |
796 | #else | |
797 | #ifndef VMS | |
798 | struct rusage rusage; | |
15f00097 | 799 | #else |
4291d9c8 RS |
800 | struct |
801 | { | |
802 | int proc_user_time; | |
803 | int proc_system_time; | |
804 | int child_user_time; | |
805 | int child_system_time; | |
806 | } vms_times; | |
807 | #endif | |
15f00097 | 808 | #endif |
4291d9c8 RS |
809 | #endif |
810 | ||
811 | if (quiet_flag) | |
812 | return 0; | |
9580b583 | 813 | #ifdef _WIN32 |
15f00097 RK |
814 | if (clock() < 0) |
815 | return 0; | |
816 | else | |
817 | return (clock() * 1000); | |
9580b583 | 818 | #else /* not _WIN32 */ |
4291d9c8 RS |
819 | #ifdef USG |
820 | times (&tms); | |
821 | return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); | |
822 | #else | |
823 | #ifndef VMS | |
824 | getrusage (0, &rusage); | |
825 | return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec | |
826 | + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); | |
827 | #else /* VMS */ | |
828 | times (&vms_times); | |
829 | return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; | |
830 | #endif | |
831 | #endif | |
eb910b5a | 832 | #endif |
4291d9c8 RS |
833 | } |
834 | ||
835 | #define TIMEVAR(VAR, BODY) \ | |
836 | do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0) | |
837 | ||
838 | void | |
839 | print_time (str, total) | |
840 | char *str; | |
841 | int total; | |
842 | { | |
843 | fprintf (stderr, | |
844 | "time in %s: %d.%06d\n", | |
845 | str, total / 1000000, total % 1000000); | |
846 | } | |
847 | ||
848 | /* Count an error or warning. Return 1 if the message should be printed. */ | |
849 | ||
850 | int | |
851 | count_error (warningp) | |
852 | int warningp; | |
853 | { | |
854 | if (warningp && inhibit_warnings) | |
855 | return 0; | |
856 | ||
857 | if (warningp && !warnings_are_errors) | |
858 | warningcount++; | |
859 | else | |
860 | { | |
861 | static int warning_message = 0; | |
862 | ||
863 | if (warningp && !warning_message) | |
864 | { | |
865 | fprintf (stderr, "%s: warnings being treated as errors\n", progname); | |
866 | warning_message = 1; | |
867 | } | |
868 | errorcount++; | |
869 | } | |
870 | ||
871 | return 1; | |
872 | } | |
873 | ||
874 | /* Print a fatal error message. NAME is the text. | |
875 | Also include a system error message based on `errno'. */ | |
876 | ||
877 | void | |
878 | pfatal_with_name (name) | |
879 | char *name; | |
880 | { | |
881 | fprintf (stderr, "%s: ", progname); | |
882 | perror (name); | |
299846f2 | 883 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
884 | } |
885 | ||
886 | void | |
887 | fatal_io_error (name) | |
888 | char *name; | |
889 | { | |
890 | fprintf (stderr, "%s: %s: I/O error\n", progname, name); | |
299846f2 | 891 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
892 | } |
893 | ||
a89b2cc4 MM |
894 | /* Called to give a better error message for a bad insn rather than |
895 | just calling abort(). */ | |
4291d9c8 RS |
896 | |
897 | void | |
a89b2cc4 MM |
898 | fatal_insn (message, insn) |
899 | char *message; | |
4291d9c8 RS |
900 | rtx insn; |
901 | { | |
ca695ac9 JB |
902 | if (!output_bytecode) |
903 | { | |
a89b2cc4 | 904 | error (message); |
ca695ac9 JB |
905 | debug_rtx (insn); |
906 | } | |
4291d9c8 RS |
907 | if (asm_out_file) |
908 | fflush (asm_out_file); | |
909 | if (aux_info_file) | |
910 | fflush (aux_info_file); | |
911 | if (rtl_dump_file) | |
912 | fflush (rtl_dump_file); | |
913 | if (jump_opt_dump_file) | |
914 | fflush (jump_opt_dump_file); | |
915 | if (cse_dump_file) | |
916 | fflush (cse_dump_file); | |
917 | if (loop_dump_file) | |
918 | fflush (loop_dump_file); | |
919 | if (cse2_dump_file) | |
920 | fflush (cse2_dump_file); | |
921 | if (flow_dump_file) | |
922 | fflush (flow_dump_file); | |
923 | if (combine_dump_file) | |
924 | fflush (combine_dump_file); | |
925 | if (sched_dump_file) | |
926 | fflush (sched_dump_file); | |
927 | if (local_reg_dump_file) | |
928 | fflush (local_reg_dump_file); | |
929 | if (global_reg_dump_file) | |
930 | fflush (global_reg_dump_file); | |
931 | if (sched2_dump_file) | |
932 | fflush (sched2_dump_file); | |
933 | if (jump2_opt_dump_file) | |
934 | fflush (jump2_opt_dump_file); | |
935 | if (dbr_sched_dump_file) | |
936 | fflush (dbr_sched_dump_file); | |
937 | if (stack_reg_dump_file) | |
938 | fflush (stack_reg_dump_file); | |
939 | abort (); | |
940 | } | |
941 | ||
a89b2cc4 MM |
942 | /* Called to give a better error message when we don't have an insn to match |
943 | what we are looking for or if the insn's constraints aren't satisfied, | |
944 | rather than just calling abort(). */ | |
945 | ||
946 | void | |
947 | fatal_insn_not_found (insn) | |
948 | rtx insn; | |
949 | { | |
950 | if (INSN_CODE (insn) < 0) | |
951 | fatal_insn ("internal error--unrecognizable insn:", insn); | |
952 | else | |
953 | fatal_insn ("internal error--insn does not satisfy its constraints:", insn); | |
954 | } | |
955 | ||
4291d9c8 RS |
956 | /* This is the default decl_printable_name function. */ |
957 | ||
958 | static char * | |
959 | decl_name (decl, kind) | |
960 | tree decl; | |
961 | char **kind; | |
962 | { | |
963 | return IDENTIFIER_POINTER (DECL_NAME (decl)); | |
964 | } | |
61d6b1cc MS |
965 | |
966 | /* This is the default interim_eh_hook function. */ | |
967 | ||
968 | void | |
969 | interim_eh (finalization) | |
970 | tree finalization; | |
971 | { | |
972 | /* Don't do anything by default. */ | |
973 | } | |
4291d9c8 RS |
974 | \f |
975 | static int need_error_newline; | |
976 | ||
977 | /* Function of last error message; | |
978 | more generally, function such that if next error message is in it | |
979 | then we don't have to mention the function name. */ | |
980 | static tree last_error_function = NULL; | |
981 | ||
982 | /* Used to detect when input_file_stack has changed since last described. */ | |
983 | static int last_error_tick; | |
984 | ||
985 | /* Called when the start of a function definition is parsed, | |
986 | this function prints on stderr the name of the function. */ | |
987 | ||
988 | void | |
989 | announce_function (decl) | |
990 | tree decl; | |
991 | { | |
992 | if (! quiet_flag) | |
993 | { | |
994 | char *junk; | |
995 | if (rtl_dump_and_exit) | |
996 | fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); | |
997 | else | |
998 | fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk)); | |
999 | fflush (stderr); | |
1000 | need_error_newline = 1; | |
1001 | last_error_function = current_function_decl; | |
1002 | } | |
1003 | } | |
1004 | ||
b64e9948 PB |
1005 | /* The default function to print out name of current function that caused |
1006 | an error. */ | |
4291d9c8 RS |
1007 | |
1008 | void | |
b64e9948 | 1009 | default_print_error_function (file) |
4291d9c8 RS |
1010 | char *file; |
1011 | { | |
4291d9c8 RS |
1012 | if (last_error_function != current_function_decl) |
1013 | { | |
1014 | char *kind = "function"; | |
1015 | if (current_function_decl != 0 | |
1016 | && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) | |
1017 | kind = "method"; | |
1018 | ||
1019 | if (file) | |
1020 | fprintf (stderr, "%s: ", file); | |
1021 | ||
1022 | if (current_function_decl == NULL) | |
1023 | fprintf (stderr, "At top level:\n"); | |
1024 | else | |
1025 | { | |
1026 | char *name = (*decl_printable_name) (current_function_decl, &kind); | |
1027 | fprintf (stderr, "In %s `%s':\n", kind, name); | |
1028 | } | |
1029 | ||
1030 | last_error_function = current_function_decl; | |
1031 | } | |
b64e9948 PB |
1032 | } |
1033 | ||
1034 | /* Called by report_error_function to print out function name. | |
1035 | * Default may be overridden by language front-ends. */ | |
1036 | ||
1037 | void (*print_error_function) PROTO((char*)) = default_print_error_function; | |
1038 | ||
1039 | /* Prints out, if necessary, the name of the current function | |
1040 | that caused an error. Called from all error and warning functions. */ | |
1041 | ||
1042 | void | |
1043 | report_error_function (file) | |
1044 | char *file; | |
1045 | { | |
1046 | struct file_stack *p; | |
1047 | ||
1048 | if (need_error_newline) | |
1049 | { | |
1050 | fprintf (stderr, "\n"); | |
1051 | need_error_newline = 0; | |
1052 | } | |
1053 | ||
1054 | (*print_error_function) (file); | |
1055 | ||
4291d9c8 | 1056 | if (input_file_stack && input_file_stack->next != 0 |
2efc92ed RK |
1057 | && input_file_stack_tick != last_error_tick |
1058 | && file == input_filename) | |
4291d9c8 RS |
1059 | { |
1060 | fprintf (stderr, "In file included"); | |
1061 | for (p = input_file_stack->next; p; p = p->next) | |
1062 | { | |
1063 | fprintf (stderr, " from %s:%d", p->name, p->line); | |
1064 | if (p->next) | |
e5301904 | 1065 | fprintf (stderr, ",\n "); |
4291d9c8 RS |
1066 | } |
1067 | fprintf (stderr, ":\n"); | |
1068 | last_error_tick = input_file_stack_tick; | |
1069 | } | |
1070 | } | |
eb711c86 RK |
1071 | \f |
1072 | /* Print a message. */ | |
4291d9c8 | 1073 | |
eb711c86 RK |
1074 | static void |
1075 | vmessage (prefix, s, ap) | |
1076 | char *prefix; | |
4291d9c8 | 1077 | char *s; |
eb711c86 | 1078 | va_list ap; |
4291d9c8 | 1079 | { |
eb711c86 RK |
1080 | if (prefix) |
1081 | fprintf (stderr, "%s: ", prefix); | |
1082 | ||
1083 | #ifdef HAVE_VPRINTF | |
1084 | vfprintf (stderr, s, ap); | |
1085 | #else | |
1086 | { | |
1087 | HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT); | |
1088 | HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT); | |
1089 | HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT); | |
a4326b4d RK |
1090 | HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT); |
1091 | fprintf (stderr, s, v1, v2, v3, v4); | |
eb711c86 RK |
1092 | } |
1093 | #endif | |
4291d9c8 RS |
1094 | } |
1095 | ||
eb711c86 | 1096 | /* Print a message relevant to line LINE of file FILE. */ |
4291d9c8 | 1097 | |
eb711c86 RK |
1098 | static void |
1099 | v_message_with_file_and_line (file, line, prefix, s, ap) | |
4291d9c8 RS |
1100 | char *file; |
1101 | int line; | |
eb711c86 | 1102 | char *prefix; |
4291d9c8 | 1103 | char *s; |
eb711c86 | 1104 | va_list ap; |
4291d9c8 | 1105 | { |
4291d9c8 RS |
1106 | if (file) |
1107 | fprintf (stderr, "%s:%d: ", file, line); | |
1108 | else | |
1109 | fprintf (stderr, "%s: ", progname); | |
d78c6ad5 | 1110 | |
eb711c86 RK |
1111 | vmessage (prefix, s, ap); |
1112 | fputc ('\n', stderr); | |
4291d9c8 RS |
1113 | } |
1114 | ||
eb711c86 | 1115 | /* Print a message relevant to the given DECL. */ |
4291d9c8 | 1116 | |
eb711c86 RK |
1117 | static void |
1118 | v_message_with_decl (decl, prefix, s, ap) | |
4291d9c8 | 1119 | tree decl; |
eb711c86 | 1120 | char *prefix; |
4291d9c8 | 1121 | char *s; |
eb711c86 | 1122 | va_list ap; |
4291d9c8 | 1123 | { |
eb711c86 | 1124 | char *n, *p, *junk; |
4291d9c8 RS |
1125 | |
1126 | fprintf (stderr, "%s:%d: ", | |
1127 | DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); | |
1128 | ||
eb711c86 RK |
1129 | if (prefix) |
1130 | fprintf (stderr, "%s: ", prefix); | |
1131 | ||
1132 | /* Do magic to get around lack of varargs support for insertion | |
1133 | of arguments into existing list. We know that the decl is first; | |
1134 | we ass_u_me that it will be printed with "%s". */ | |
1135 | ||
1136 | for (p = s; *p; ++p) | |
1137 | { | |
1138 | if (*p == '%') | |
1139 | { | |
1140 | if (*(p + 1) == '%') | |
1141 | ++p; | |
1142 | else | |
1143 | break; | |
1144 | } | |
1145 | } | |
1146 | ||
cb039f8a RK |
1147 | if (p > s) /* Print the left-hand substring. */ |
1148 | { | |
1149 | char fmt[sizeof "%.255s"]; | |
1150 | long width = p - s; | |
1151 | ||
1152 | if (width > 255L) width = 255L; /* arbitrary */ | |
1153 | sprintf (fmt, "%%.%lds", width); | |
1154 | fprintf (stderr, fmt, s); | |
1155 | } | |
eb711c86 | 1156 | |
cb039f8a | 1157 | if (*p == '%') /* Print the name. */ |
eb711c86 RK |
1158 | { |
1159 | char *n = (DECL_NAME (decl) | |
1160 | ? (*decl_printable_name) (decl, &junk) | |
1161 | : "((anonymous))"); | |
1162 | fputs (n, stderr); | |
1163 | while (*p) | |
1164 | { | |
1165 | ++p; | |
1166 | if (isalpha (*(p - 1) & 0xFF)) | |
1167 | break; | |
1168 | } | |
1169 | } | |
1170 | ||
cb039f8a | 1171 | if (*p) /* Print the rest of the message. */ |
eb711c86 RK |
1172 | vmessage ((char *)NULL, p, ap); |
1173 | ||
1174 | fputc ('\n', stderr); | |
4291d9c8 RS |
1175 | } |
1176 | ||
eb711c86 | 1177 | /* Figure file and line of the given INSN. */ |
4291d9c8 | 1178 | |
eb711c86 RK |
1179 | static void |
1180 | file_and_line_for_asm (insn, pfile, pline) | |
4291d9c8 | 1181 | rtx insn; |
eb711c86 RK |
1182 | char **pfile; |
1183 | int *pline; | |
4291d9c8 | 1184 | { |
4291d9c8 RS |
1185 | rtx body = PATTERN (insn); |
1186 | rtx asmop; | |
1187 | ||
1188 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ | |
1189 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
1190 | asmop = SET_SRC (body); | |
1191 | else if (GET_CODE (body) == ASM_OPERANDS) | |
1192 | asmop = body; | |
1193 | else if (GET_CODE (body) == PARALLEL | |
1194 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
1195 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
1196 | else if (GET_CODE (body) == PARALLEL | |
1197 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
1198 | asmop = XVECEXP (body, 0, 0); | |
eb711c86 RK |
1199 | else |
1200 | asmop = NULL; | |
1201 | ||
1202 | if (asmop) | |
1203 | { | |
1204 | *pfile = ASM_OPERANDS_SOURCE_FILE (asmop); | |
1205 | *pline = ASM_OPERANDS_SOURCE_LINE (asmop); | |
1206 | } | |
1207 | else | |
1208 | { | |
1209 | *pfile = input_filename; | |
1210 | *pline = lineno; | |
1211 | } | |
1212 | } | |
4291d9c8 | 1213 | |
eb711c86 | 1214 | /* Report an error at line LINE of file FILE. */ |
4291d9c8 | 1215 | |
eb711c86 RK |
1216 | static void |
1217 | v_error_with_file_and_line (file, line, s, ap) | |
1218 | char *file; | |
1219 | int line; | |
1220 | char *s; | |
1221 | va_list ap; | |
1222 | { | |
1223 | count_error (0); | |
1224 | report_error_function (file); | |
1225 | v_message_with_file_and_line (file, line, (char *)NULL, s, ap); | |
d78c6ad5 RK |
1226 | } |
1227 | ||
1228 | void | |
e0e2a8da | 1229 | error_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
d78c6ad5 | 1230 | { |
e0e2a8da | 1231 | #ifndef __STDC__ |
eb711c86 RK |
1232 | char *file; |
1233 | int line; | |
1234 | char *s; | |
e0e2a8da RK |
1235 | #endif |
1236 | va_list ap; | |
1237 | ||
1238 | VA_START (ap, s); | |
eb711c86 | 1239 | |
e0e2a8da | 1240 | #ifndef __STDC__ |
eb711c86 RK |
1241 | file = va_arg (ap, char *); |
1242 | line = va_arg (ap, int); | |
1243 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1244 | #endif |
1245 | ||
eb711c86 RK |
1246 | v_error_with_file_and_line (file, line, s, ap); |
1247 | va_end (ap); | |
4291d9c8 RS |
1248 | } |
1249 | ||
eb711c86 RK |
1250 | /* Report an error at the declaration DECL. |
1251 | S is a format string which uses %s to substitute the declaration | |
1252 | name; subsequent substitutions are a la printf. */ | |
1253 | ||
1254 | static void | |
1255 | v_error_with_decl (decl, s, ap) | |
1256 | tree decl; | |
1257 | char *s; | |
1258 | va_list ap; | |
1259 | { | |
1260 | count_error (0); | |
1261 | report_error_function (DECL_SOURCE_FILE (decl)); | |
1262 | v_message_with_decl (decl, (char *)NULL, s, ap); | |
1263 | } | |
4291d9c8 RS |
1264 | |
1265 | void | |
e0e2a8da | 1266 | error_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1267 | { |
e0e2a8da | 1268 | #ifndef __STDC__ |
eb711c86 RK |
1269 | tree decl; |
1270 | char *s; | |
e0e2a8da RK |
1271 | #endif |
1272 | va_list ap; | |
eb711c86 | 1273 | |
e0e2a8da RK |
1274 | VA_START (ap, s); |
1275 | ||
1276 | #ifndef __STDC__ | |
eb711c86 RK |
1277 | decl = va_arg (ap, tree); |
1278 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1279 | #endif |
1280 | ||
eb711c86 RK |
1281 | v_error_with_decl (decl, s, ap); |
1282 | va_end (ap); | |
1283 | } | |
1284 | ||
1285 | /* Report an error at the line number of the insn INSN. | |
1286 | This is used only when INSN is an `asm' with operands, | |
1287 | and each ASM_OPERANDS records its own source file and line. */ | |
1288 | ||
1289 | static void | |
1290 | v_error_for_asm (insn, s, ap) | |
1291 | rtx insn; | |
4291d9c8 | 1292 | char *s; |
eb711c86 | 1293 | va_list ap; |
4291d9c8 | 1294 | { |
eb711c86 RK |
1295 | char *file; |
1296 | int line; | |
4291d9c8 | 1297 | |
eb711c86 RK |
1298 | count_error (0); |
1299 | file_and_line_for_asm (insn, &file, &line); | |
4291d9c8 | 1300 | report_error_function (file); |
eb711c86 RK |
1301 | v_message_with_file_and_line (file, line, (char *)NULL, s, ap); |
1302 | } | |
4291d9c8 | 1303 | |
eb711c86 | 1304 | void |
e0e2a8da | 1305 | error_for_asm VPROTO((rtx insn, char *s, ...)) |
eb711c86 | 1306 | { |
e0e2a8da | 1307 | #ifndef __STDC__ |
eb711c86 RK |
1308 | rtx insn; |
1309 | char *s; | |
e0e2a8da RK |
1310 | #endif |
1311 | va_list ap; | |
eb711c86 | 1312 | |
e0e2a8da RK |
1313 | VA_START (ap, s); |
1314 | ||
1315 | #ifndef __STDC__ | |
eb711c86 RK |
1316 | insn = va_arg (ap, rtx); |
1317 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1318 | #endif |
1319 | ||
eb711c86 RK |
1320 | v_error_for_asm (insn, s, ap); |
1321 | va_end (ap); | |
4291d9c8 RS |
1322 | } |
1323 | ||
eb711c86 | 1324 | /* Report an error at the current line number. */ |
4291d9c8 | 1325 | |
eb711c86 RK |
1326 | static void |
1327 | verror (s, ap) | |
4291d9c8 | 1328 | char *s; |
eb711c86 | 1329 | va_list ap; |
4291d9c8 | 1330 | { |
eb711c86 | 1331 | v_error_with_file_and_line (input_filename, lineno, s, ap); |
4291d9c8 RS |
1332 | } |
1333 | ||
eb711c86 | 1334 | void |
e0e2a8da | 1335 | error VPROTO((char *s, ...)) |
eb711c86 | 1336 | { |
e0e2a8da | 1337 | #ifndef __STDC__ |
eb711c86 | 1338 | char *s; |
e0e2a8da RK |
1339 | #endif |
1340 | va_list ap; | |
1341 | ||
1342 | VA_START (ap, s); | |
eb711c86 | 1343 | |
e0e2a8da | 1344 | #ifndef __STDC__ |
eb711c86 | 1345 | s = va_arg (ap, char *); |
e0e2a8da RK |
1346 | #endif |
1347 | ||
eb711c86 RK |
1348 | verror (s, ap); |
1349 | va_end (ap); | |
1350 | } | |
1351 | ||
1352 | /* Report a fatal error at the current line number. */ | |
1353 | ||
1354 | static void | |
1355 | vfatal (s, ap) | |
1356 | char *s; | |
1357 | va_list ap; | |
1358 | { | |
1359 | verror (s, ap); | |
299846f2 | 1360 | exit (FATAL_EXIT_CODE); |
eb711c86 | 1361 | } |
4291d9c8 RS |
1362 | |
1363 | void | |
e0e2a8da | 1364 | fatal VPROTO((char *s, ...)) |
eb711c86 | 1365 | { |
e0e2a8da | 1366 | #ifndef __STDC__ |
eb711c86 | 1367 | char *s; |
e0e2a8da RK |
1368 | #endif |
1369 | va_list ap; | |
1370 | ||
1371 | VA_START (ap, s); | |
eb711c86 | 1372 | |
e0e2a8da | 1373 | #ifndef __STDC__ |
eb711c86 | 1374 | s = va_arg (ap, char *); |
e0e2a8da RK |
1375 | #endif |
1376 | ||
eb711c86 RK |
1377 | vfatal (s, ap); |
1378 | va_end (ap); | |
1379 | } | |
1380 | ||
1381 | /* Report a warning at line LINE of file FILE. */ | |
1382 | ||
1383 | static void | |
1384 | v_warning_with_file_and_line (file, line, s, ap) | |
1385 | char *file; | |
1386 | int line; | |
4291d9c8 | 1387 | char *s; |
eb711c86 | 1388 | va_list ap; |
4291d9c8 | 1389 | { |
eb711c86 RK |
1390 | if (count_error (1)) |
1391 | { | |
1392 | report_error_function (file); | |
1393 | v_message_with_file_and_line (file, line, "warning", s, ap); | |
1394 | } | |
1395 | } | |
4291d9c8 | 1396 | |
eb711c86 | 1397 | void |
e0e2a8da | 1398 | warning_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
eb711c86 | 1399 | { |
e0e2a8da | 1400 | #ifndef __STDC__ |
eb711c86 RK |
1401 | char *file; |
1402 | int line; | |
1403 | char *s; | |
e0e2a8da RK |
1404 | #endif |
1405 | va_list ap; | |
1406 | ||
1407 | VA_START (ap, s); | |
eb711c86 | 1408 | |
e0e2a8da | 1409 | #ifndef __STDC__ |
eb711c86 RK |
1410 | file = va_arg (ap, char *); |
1411 | line = va_arg (ap, int); | |
1412 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1413 | #endif |
1414 | ||
eb711c86 RK |
1415 | v_warning_with_file_and_line (file, line, s, ap); |
1416 | va_end (ap); | |
1417 | } | |
4291d9c8 | 1418 | |
eb711c86 RK |
1419 | /* Report a warning at the declaration DECL. |
1420 | S is a format string which uses %s to substitute the declaration | |
1421 | name; subsequent substitutions are a la printf. */ | |
4291d9c8 | 1422 | |
eb711c86 RK |
1423 | static void |
1424 | v_warning_with_decl (decl, s, ap) | |
1425 | tree decl; | |
1426 | char *s; | |
1427 | va_list ap; | |
1428 | { | |
1429 | if (count_error (1)) | |
1430 | { | |
1431 | report_error_function (DECL_SOURCE_FILE (decl)); | |
1432 | v_message_with_decl (decl, "warning", s, ap); | |
1433 | } | |
1434 | } | |
4291d9c8 | 1435 | |
eb711c86 | 1436 | void |
e0e2a8da | 1437 | warning_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1438 | { |
e0e2a8da | 1439 | #ifndef __STDC__ |
eb711c86 RK |
1440 | tree decl; |
1441 | char *s; | |
e0e2a8da RK |
1442 | #endif |
1443 | va_list ap; | |
eb711c86 | 1444 | |
e0e2a8da RK |
1445 | VA_START (ap, s); |
1446 | ||
1447 | #ifndef __STDC__ | |
eb711c86 RK |
1448 | decl = va_arg (ap, tree); |
1449 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1450 | #endif |
1451 | ||
eb711c86 RK |
1452 | v_warning_with_decl (decl, s, ap); |
1453 | va_end (ap); | |
4291d9c8 RS |
1454 | } |
1455 | ||
1456 | /* Report a warning at the line number of the insn INSN. | |
4291d9c8 RS |
1457 | This is used only when INSN is an `asm' with operands, |
1458 | and each ASM_OPERANDS records its own source file and line. */ | |
1459 | ||
eb711c86 RK |
1460 | static void |
1461 | v_warning_for_asm (insn, s, ap) | |
4291d9c8 RS |
1462 | rtx insn; |
1463 | char *s; | |
eb711c86 | 1464 | va_list ap; |
4291d9c8 | 1465 | { |
eb711c86 RK |
1466 | if (count_error (1)) |
1467 | { | |
1468 | char *file; | |
1469 | int line; | |
4291d9c8 | 1470 | |
eb711c86 RK |
1471 | file_and_line_for_asm (insn, &file, &line); |
1472 | report_error_function (file); | |
1473 | v_message_with_file_and_line (file, line, "warning", s, ap); | |
1474 | } | |
1475 | } | |
4291d9c8 | 1476 | |
eb711c86 | 1477 | void |
e0e2a8da | 1478 | warning_for_asm VPROTO((rtx insn, char *s, ...)) |
eb711c86 | 1479 | { |
e0e2a8da | 1480 | #ifndef __STDC__ |
eb711c86 RK |
1481 | rtx insn; |
1482 | char *s; | |
e0e2a8da RK |
1483 | #endif |
1484 | va_list ap; | |
1485 | ||
1486 | VA_START (ap, s); | |
eb711c86 | 1487 | |
e0e2a8da | 1488 | #ifndef __STDC__ |
eb711c86 RK |
1489 | insn = va_arg (ap, rtx); |
1490 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1491 | #endif |
1492 | ||
eb711c86 RK |
1493 | v_warning_for_asm (insn, s, ap); |
1494 | va_end (ap); | |
1495 | } | |
4291d9c8 | 1496 | |
eb711c86 RK |
1497 | /* Report a warning at the current line number. */ |
1498 | ||
1499 | static void | |
1500 | vwarning (s, ap) | |
1501 | char *s; | |
1502 | va_list ap; | |
1503 | { | |
1504 | v_warning_with_file_and_line (input_filename, lineno, s, ap); | |
4291d9c8 | 1505 | } |
eb711c86 RK |
1506 | |
1507 | void | |
e0e2a8da | 1508 | warning VPROTO((char *s, ...)) |
eb711c86 | 1509 | { |
e0e2a8da | 1510 | #ifndef __STDC__ |
eb711c86 | 1511 | char *s; |
e0e2a8da RK |
1512 | #endif |
1513 | va_list ap; | |
1514 | ||
1515 | VA_START (ap, s); | |
eb711c86 | 1516 | |
e0e2a8da | 1517 | #ifndef __STDC__ |
eb711c86 | 1518 | s = va_arg (ap, char *); |
e0e2a8da RK |
1519 | #endif |
1520 | ||
eb711c86 RK |
1521 | vwarning (s, ap); |
1522 | va_end (ap); | |
1523 | } | |
1524 | ||
4291d9c8 RS |
1525 | /* These functions issue either warnings or errors depending on |
1526 | -pedantic-errors. */ | |
1527 | ||
eb711c86 RK |
1528 | static void |
1529 | vpedwarn (s, ap) | |
4291d9c8 | 1530 | char *s; |
eb711c86 | 1531 | va_list ap; |
4291d9c8 RS |
1532 | { |
1533 | if (flag_pedantic_errors) | |
eb711c86 | 1534 | verror (s, ap); |
4291d9c8 | 1535 | else |
eb711c86 | 1536 | vwarning (s, ap); |
4291d9c8 RS |
1537 | } |
1538 | ||
1539 | void | |
e0e2a8da | 1540 | pedwarn VPROTO((char *s, ...)) |
eb711c86 | 1541 | { |
e0e2a8da | 1542 | #ifndef __STDC__ |
eb711c86 | 1543 | char *s; |
e0e2a8da RK |
1544 | #endif |
1545 | va_list ap; | |
1546 | ||
1547 | VA_START (ap, s); | |
eb711c86 | 1548 | |
e0e2a8da | 1549 | #ifndef __STDC__ |
eb711c86 | 1550 | s = va_arg (ap, char *); |
e0e2a8da RK |
1551 | #endif |
1552 | ||
eb711c86 RK |
1553 | vpedwarn (s, ap); |
1554 | va_end (ap); | |
1555 | } | |
1556 | ||
1557 | static void | |
1558 | v_pedwarn_with_decl (decl, s, ap) | |
4291d9c8 RS |
1559 | tree decl; |
1560 | char *s; | |
eb711c86 | 1561 | va_list ap; |
4291d9c8 | 1562 | { |
1554cdf5 DE |
1563 | /* We don't want -pedantic-errors to cause the compilation to fail from |
1564 | "errors" in system header files. Sometimes fixincludes can't fix what's | |
1565 | broken (eg: unsigned char bitfields - fixing it may change the alignment | |
1566 | which will cause programs to mysteriously fail because the C library | |
22d74562 DE |
1567 | or kernel uses the original layout). There's no point in issuing a |
1568 | warning either, it's just unnecessary noise. */ | |
1554cdf5 | 1569 | |
22d74562 DE |
1570 | if (! DECL_IN_SYSTEM_HEADER (decl)) |
1571 | { | |
1572 | if (flag_pedantic_errors) | |
1573 | v_error_with_decl (decl, s, ap); | |
1574 | else | |
1575 | v_warning_with_decl (decl, s, ap); | |
1576 | } | |
4291d9c8 RS |
1577 | } |
1578 | ||
1579 | void | |
e0e2a8da | 1580 | pedwarn_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1581 | { |
e0e2a8da | 1582 | #ifndef __STDC__ |
eb711c86 RK |
1583 | tree decl; |
1584 | char *s; | |
e0e2a8da RK |
1585 | #endif |
1586 | va_list ap; | |
eb711c86 | 1587 | |
e0e2a8da RK |
1588 | VA_START (ap, s); |
1589 | ||
1590 | #ifndef __STDC__ | |
eb711c86 RK |
1591 | decl = va_arg (ap, tree); |
1592 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1593 | #endif |
1594 | ||
eb711c86 RK |
1595 | v_pedwarn_with_decl (decl, s, ap); |
1596 | va_end (ap); | |
1597 | } | |
1598 | ||
1599 | static void | |
1600 | v_pedwarn_with_file_and_line (file, line, s, ap) | |
4291d9c8 RS |
1601 | char *file; |
1602 | int line; | |
1603 | char *s; | |
eb711c86 | 1604 | va_list ap; |
4291d9c8 RS |
1605 | { |
1606 | if (flag_pedantic_errors) | |
eb711c86 | 1607 | v_error_with_file_and_line (file, line, s, ap); |
4291d9c8 | 1608 | else |
eb711c86 | 1609 | v_warning_with_file_and_line (file, line, s, ap); |
4291d9c8 RS |
1610 | } |
1611 | ||
4291d9c8 | 1612 | void |
e0e2a8da | 1613 | pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
eb711c86 | 1614 | { |
e0e2a8da | 1615 | #ifndef __STDC__ |
eb711c86 RK |
1616 | char *file; |
1617 | int line; | |
1618 | char *s; | |
e0e2a8da RK |
1619 | #endif |
1620 | va_list ap; | |
eb711c86 | 1621 | |
e0e2a8da RK |
1622 | VA_START (ap, s); |
1623 | ||
1624 | #ifndef __STDC__ | |
eb711c86 RK |
1625 | file = va_arg (ap, char *); |
1626 | line = va_arg (ap, int); | |
1627 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1628 | #endif |
1629 | ||
eb711c86 RK |
1630 | v_pedwarn_with_file_and_line (file, line, s, ap); |
1631 | va_end (ap); | |
1632 | } | |
1633 | ||
1634 | /* Apologize for not implementing some feature. */ | |
1635 | ||
1636 | static void | |
1637 | vsorry (s, ap) | |
4291d9c8 | 1638 | char *s; |
eb711c86 | 1639 | va_list ap; |
4291d9c8 RS |
1640 | { |
1641 | sorrycount++; | |
1642 | if (input_filename) | |
1643 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1644 | else | |
1645 | fprintf (stderr, "%s: ", progname); | |
eb711c86 RK |
1646 | vmessage ("sorry, not implemented", s, ap); |
1647 | fputc ('\n', stderr); | |
1648 | } | |
4291d9c8 | 1649 | |
eb711c86 | 1650 | void |
e0e2a8da | 1651 | sorry VPROTO((char *s, ...)) |
eb711c86 | 1652 | { |
e0e2a8da | 1653 | #ifndef __STDC__ |
eb711c86 | 1654 | char *s; |
e0e2a8da RK |
1655 | #endif |
1656 | va_list ap; | |
1657 | ||
1658 | VA_START (ap, s); | |
eb711c86 | 1659 | |
e0e2a8da | 1660 | #ifndef __STDC__ |
eb711c86 | 1661 | s = va_arg (ap, char *); |
e0e2a8da RK |
1662 | #endif |
1663 | ||
eb711c86 RK |
1664 | vsorry (s, ap); |
1665 | va_end (ap); | |
4291d9c8 RS |
1666 | } |
1667 | ||
eb711c86 | 1668 | /* Apologize for not implementing some feature, then quit. */ |
4291d9c8 | 1669 | |
eb711c86 RK |
1670 | static void |
1671 | v_really_sorry (s, ap) | |
4291d9c8 | 1672 | char *s; |
eb711c86 | 1673 | va_list ap; |
4291d9c8 | 1674 | { |
eb711c86 | 1675 | sorrycount++; |
4291d9c8 RS |
1676 | if (input_filename) |
1677 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1678 | else | |
c10afc44 | 1679 | fprintf (stderr, "%s: ", progname); |
eb711c86 | 1680 | vmessage ("sorry, not implemented", s, ap); |
4291d9c8 RS |
1681 | fatal (" (fatal)\n"); |
1682 | } | |
eb711c86 RK |
1683 | |
1684 | void | |
e0e2a8da | 1685 | really_sorry VPROTO((char *s, ...)) |
eb711c86 | 1686 | { |
e0e2a8da | 1687 | #ifndef __STDC__ |
eb711c86 | 1688 | char *s; |
e0e2a8da RK |
1689 | #endif |
1690 | va_list ap; | |
1691 | ||
1692 | VA_START (ap, s); | |
eb711c86 | 1693 | |
e0e2a8da | 1694 | #ifndef __STDC__ |
eb711c86 | 1695 | s = va_arg (ap, char *); |
e0e2a8da RK |
1696 | #endif |
1697 | ||
eb711c86 RK |
1698 | v_really_sorry (s, ap); |
1699 | va_end (ap); | |
1700 | } | |
4291d9c8 RS |
1701 | \f |
1702 | /* More 'friendly' abort that prints the line and file. | |
1703 | config.h can #define abort fancy_abort if you like that sort of thing. | |
1704 | ||
1705 | I don't think this is actually a good idea. | |
1706 | Other sorts of crashes will look a certain way. | |
1707 | It is a good thing if crashes from calling abort look the same way. | |
1708 | -- RMS */ | |
1709 | ||
1710 | void | |
1711 | fancy_abort () | |
1712 | { | |
1713 | fatal ("internal gcc abort"); | |
1714 | } | |
1715 | ||
1716 | /* This calls abort and is used to avoid problems when abort if a macro. | |
1717 | It is used when we need to pass the address of abort. */ | |
1718 | ||
1719 | void | |
1720 | do_abort () | |
1721 | { | |
1722 | abort (); | |
1723 | } | |
1724 | ||
1725 | /* When `malloc.c' is compiled with `rcheck' defined, | |
1726 | it calls this function to report clobberage. */ | |
1727 | ||
1728 | void | |
1729 | botch (s) | |
1730 | { | |
1731 | abort (); | |
1732 | } | |
1733 | ||
1734 | /* Same as `malloc' but report error if no memory available. */ | |
1735 | ||
4b980e20 | 1736 | char * |
4291d9c8 RS |
1737 | xmalloc (size) |
1738 | unsigned size; | |
1739 | { | |
4b980e20 | 1740 | register char *value = (char *) malloc (size); |
4291d9c8 RS |
1741 | if (value == 0) |
1742 | fatal ("virtual memory exhausted"); | |
1743 | return value; | |
1744 | } | |
1745 | ||
1746 | /* Same as `realloc' but report error if no memory available. */ | |
1747 | ||
4b980e20 | 1748 | char * |
4291d9c8 RS |
1749 | xrealloc (ptr, size) |
1750 | char *ptr; | |
1751 | int size; | |
1752 | { | |
4b980e20 | 1753 | char *result = (char *) realloc (ptr, size); |
4291d9c8 RS |
1754 | if (!result) |
1755 | fatal ("virtual memory exhausted"); | |
1756 | return result; | |
1757 | } | |
1758 | \f | |
1759 | /* Return the logarithm of X, base 2, considering X unsigned, | |
37366632 RK |
1760 | if X is a power of 2. Otherwise, returns -1. |
1761 | ||
1762 | This should be used via the `exact_log2' macro. */ | |
4291d9c8 RS |
1763 | |
1764 | int | |
37366632 RK |
1765 | exact_log2_wide (x) |
1766 | register unsigned HOST_WIDE_INT x; | |
4291d9c8 RS |
1767 | { |
1768 | register int log = 0; | |
1769 | /* Test for 0 or a power of 2. */ | |
1770 | if (x == 0 || x != (x & -x)) | |
1771 | return -1; | |
1772 | while ((x >>= 1) != 0) | |
1773 | log++; | |
1774 | return log; | |
1775 | } | |
1776 | ||
1777 | /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. | |
37366632 RK |
1778 | If X is 0, return -1. |
1779 | ||
1780 | This should be used via the floor_log2 macro. */ | |
4291d9c8 RS |
1781 | |
1782 | int | |
37366632 RK |
1783 | floor_log2_wide (x) |
1784 | register unsigned HOST_WIDE_INT x; | |
4291d9c8 RS |
1785 | { |
1786 | register int log = -1; | |
1787 | while (x != 0) | |
1788 | log++, | |
1789 | x >>= 1; | |
1790 | return log; | |
1791 | } | |
1792 | ||
1793 | int float_handled; | |
1794 | jmp_buf float_handler; | |
1795 | ||
1796 | /* Specify where to longjmp to when a floating arithmetic error happens. | |
1797 | If HANDLER is 0, it means don't handle the errors any more. */ | |
1798 | ||
1799 | void | |
1800 | set_float_handler (handler) | |
1801 | jmp_buf handler; | |
1802 | { | |
1803 | float_handled = (handler != 0); | |
1804 | if (handler) | |
4c9a05bc | 1805 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); |
4291d9c8 RS |
1806 | } |
1807 | ||
bff4b641 RS |
1808 | /* Specify, in HANDLER, where to longjmp to when a floating arithmetic |
1809 | error happens, pushing the previous specification into OLD_HANDLER. | |
1810 | Return an indication of whether there was a previous handler in effect. */ | |
1811 | ||
1812 | int | |
1813 | push_float_handler (handler, old_handler) | |
dc2b15dc | 1814 | jmp_buf handler, old_handler; |
bff4b641 RS |
1815 | { |
1816 | int was_handled = float_handled; | |
1817 | ||
1818 | float_handled = 1; | |
1819 | if (was_handled) | |
4c9a05bc RK |
1820 | bcopy ((char *) float_handler, (char *) old_handler, |
1821 | sizeof (float_handler)); | |
1822 | ||
1823 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); | |
bff4b641 RS |
1824 | return was_handled; |
1825 | } | |
1826 | ||
1827 | /* Restore the previous specification of whether and where to longjmp to | |
1828 | when a floating arithmetic error happens. */ | |
1829 | ||
1830 | void | |
1831 | pop_float_handler (handled, handler) | |
1832 | int handled; | |
1833 | jmp_buf handler; | |
1834 | { | |
1835 | float_handled = handled; | |
1836 | if (handled) | |
4c9a05bc | 1837 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); |
bff4b641 RS |
1838 | } |
1839 | ||
4291d9c8 RS |
1840 | /* Signals actually come here. */ |
1841 | ||
1842 | static void | |
1843 | float_signal (signo) | |
1844 | /* If this is missing, some compilers complain. */ | |
1845 | int signo; | |
1846 | { | |
1847 | if (float_handled == 0) | |
1848 | abort (); | |
1849 | #if defined (USG) || defined (hpux) | |
1850 | signal (SIGFPE, float_signal); /* re-enable the signal catcher */ | |
1851 | #endif | |
1852 | float_handled = 0; | |
1853 | signal (SIGFPE, float_signal); | |
1854 | longjmp (float_handler, 1); | |
1855 | } | |
1856 | ||
1857 | /* Handler for SIGPIPE. */ | |
1858 | ||
1859 | static void | |
1860 | pipe_closed (signo) | |
1861 | /* If this is missing, some compilers complain. */ | |
1862 | int signo; | |
1863 | { | |
1864 | fatal ("output pipe has been closed"); | |
1865 | } | |
1866 | ||
1867 | /* Strip off a legitimate source ending from the input string NAME of | |
c62bdc79 RK |
1868 | length LEN. Rather than having to know the names used by all of |
1869 | our front ends, we strip off an ending of a period followed by one, | |
1870 | two, or three characters. */ | |
4291d9c8 RS |
1871 | |
1872 | void | |
1873 | strip_off_ending (name, len) | |
1874 | char *name; | |
1875 | int len; | |
1876 | { | |
c62bdc79 RK |
1877 | if (len > 2 && name[len - 2] == '.') |
1878 | name[len - 2] = '\0'; | |
1879 | else if (len > 3 && name[len - 3] == '.') | |
1880 | name[len - 3] = '\0'; | |
1881 | else if (len > 4 && name[len - 4] == '.') | |
1882 | name[len - 4] = '\0'; | |
4291d9c8 RS |
1883 | } |
1884 | ||
7dce5088 PE |
1885 | /* Output a quoted string. */ |
1886 | void | |
1887 | output_quoted_string (asm_file, string) | |
1888 | FILE *asm_file; | |
1889 | char *string; | |
1890 | { | |
1891 | char c; | |
1892 | ||
1893 | putc ('\"', asm_file); | |
1894 | while ((c = *string++) != 0) | |
1895 | { | |
1896 | if (c == '\"' || c == '\\') | |
1897 | putc ('\\', asm_file); | |
1898 | putc (c, asm_file); | |
1899 | } | |
1900 | putc ('\"', asm_file); | |
1901 | } | |
1902 | ||
4291d9c8 RS |
1903 | /* Output a file name in the form wanted by System V. */ |
1904 | ||
1905 | void | |
1906 | output_file_directive (asm_file, input_name) | |
1907 | FILE *asm_file; | |
1908 | char *input_name; | |
1909 | { | |
1910 | int len = strlen (input_name); | |
1911 | char *na = input_name + len; | |
1912 | ||
1913 | /* NA gets INPUT_NAME sans directory names. */ | |
1914 | while (na > input_name) | |
1915 | { | |
1916 | if (na[-1] == '/') | |
1917 | break; | |
1918 | na--; | |
1919 | } | |
1920 | ||
1921 | #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME | |
1922 | ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na); | |
1923 | #else | |
1924 | #ifdef ASM_OUTPUT_SOURCE_FILENAME | |
1925 | ASM_OUTPUT_SOURCE_FILENAME (asm_file, na); | |
1926 | #else | |
7dce5088 PE |
1927 | fprintf (asm_file, "\t.file\t"); |
1928 | output_quoted_string (asm_file, na); | |
1929 | fputc ('\n', asm_file); | |
4291d9c8 RS |
1930 | #endif |
1931 | #endif | |
1932 | } | |
1933 | \f | |
d0d4af87 MS |
1934 | /* Routine to build language identifier for object file. */ |
1935 | static void | |
1936 | output_lang_identify (asm_out_file) | |
1937 | FILE *asm_out_file; | |
1938 | { | |
1939 | int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1; | |
1940 | char *s = (char *) alloca (len); | |
1941 | sprintf (s, "__gnu_compiled_%s", lang_identify ()); | |
1942 | ASM_OUTPUT_LABEL (asm_out_file, s); | |
1943 | } | |
1944 | ||
dfe1a916 DE |
1945 | /* Routine to open a dump file. */ |
1946 | static FILE * | |
1947 | open_dump_file (base_name, suffix) | |
1948 | char *base_name; | |
1949 | char *suffix; | |
1950 | { | |
1951 | FILE *f; | |
1952 | char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1); | |
1953 | ||
1954 | strcpy (dumpname, base_name); | |
1955 | strcat (dumpname, suffix); | |
1956 | f = fopen (dumpname, "w"); | |
1957 | if (f == 0) | |
1958 | pfatal_with_name (dumpname); | |
1959 | return f; | |
1960 | } | |
1961 | ||
4291d9c8 RS |
1962 | /* Compile an entire file of output from cpp, named NAME. |
1963 | Write a file of assembly output and various debugging dumps. */ | |
1964 | ||
1965 | static void | |
1966 | compile_file (name) | |
1967 | char *name; | |
1968 | { | |
1969 | tree globals; | |
1970 | int start_time; | |
4291d9c8 RS |
1971 | |
1972 | int name_specified = name != 0; | |
1973 | ||
1974 | if (dump_base_name == 0) | |
1975 | dump_base_name = name ? name : "gccdump"; | |
4291d9c8 RS |
1976 | |
1977 | parse_time = 0; | |
1978 | varconst_time = 0; | |
1979 | integration_time = 0; | |
1980 | jump_time = 0; | |
1981 | cse_time = 0; | |
1982 | loop_time = 0; | |
1983 | cse2_time = 0; | |
1984 | flow_time = 0; | |
1985 | combine_time = 0; | |
1986 | sched_time = 0; | |
1987 | local_alloc_time = 0; | |
1988 | global_alloc_time = 0; | |
1989 | sched2_time = 0; | |
1990 | dbr_sched_time = 0; | |
1991 | shorten_branch_time = 0; | |
1992 | stack_reg_time = 0; | |
1993 | final_time = 0; | |
1994 | symout_time = 0; | |
1995 | dump_time = 0; | |
1996 | ||
1997 | /* Open input file. */ | |
1998 | ||
1999 | if (name == 0 || !strcmp (name, "-")) | |
2000 | { | |
2001 | finput = stdin; | |
2002 | name = "stdin"; | |
2003 | } | |
2004 | else | |
2005 | finput = fopen (name, "r"); | |
2006 | if (finput == 0) | |
2007 | pfatal_with_name (name); | |
2008 | ||
282ea52a | 2009 | #ifdef IO_BUFFER_SIZE |
d7cedf4b | 2010 | setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); |
282ea52a RS |
2011 | #endif |
2012 | ||
4291d9c8 RS |
2013 | /* Initialize data in various passes. */ |
2014 | ||
2015 | init_obstacks (); | |
2016 | init_tree_codes (); | |
2017 | init_lex (); | |
ca695ac9 JB |
2018 | /* Some of these really don't need to be called when generating bytecode, |
2019 | but the options would have to be parsed first to know that. -bson */ | |
4291d9c8 RS |
2020 | init_rtl (); |
2021 | init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL | |
2022 | || debug_info_level == DINFO_LEVEL_VERBOSE); | |
7f21d440 | 2023 | init_regs (); |
4291d9c8 RS |
2024 | init_decl_processing (); |
2025 | init_optabs (); | |
2026 | init_stmt (); | |
2027 | init_expmed (); | |
4fa52007 | 2028 | init_expr_once (); |
4291d9c8 RS |
2029 | init_loop (); |
2030 | init_reload (); | |
2031 | ||
2032 | if (flag_caller_saves) | |
2033 | init_caller_save (); | |
2034 | ||
f246a305 RS |
2035 | /* If auxiliary info generation is desired, open the output file. |
2036 | This goes in the same directory as the source file--unlike | |
2037 | all the other output files. */ | |
4291d9c8 RS |
2038 | if (flag_gen_aux_info) |
2039 | { | |
4291d9c8 RS |
2040 | aux_info_file = fopen (aux_info_file_name, "w"); |
2041 | if (aux_info_file == 0) | |
2042 | pfatal_with_name (aux_info_file_name); | |
2043 | } | |
2044 | ||
2045 | /* If rtl dump desired, open the output file. */ | |
2046 | if (rtl_dump) | |
dfe1a916 | 2047 | rtl_dump_file = open_dump_file (dump_base_name, ".rtl"); |
4291d9c8 RS |
2048 | |
2049 | /* If jump_opt dump desired, open the output file. */ | |
2050 | if (jump_opt_dump) | |
dfe1a916 | 2051 | jump_opt_dump_file = open_dump_file (dump_base_name, ".jump"); |
4291d9c8 RS |
2052 | |
2053 | /* If cse dump desired, open the output file. */ | |
2054 | if (cse_dump) | |
dfe1a916 | 2055 | cse_dump_file = open_dump_file (dump_base_name, ".cse"); |
4291d9c8 RS |
2056 | |
2057 | /* If loop dump desired, open the output file. */ | |
2058 | if (loop_dump) | |
dfe1a916 | 2059 | loop_dump_file = open_dump_file (dump_base_name, ".loop"); |
4291d9c8 RS |
2060 | |
2061 | /* If cse2 dump desired, open the output file. */ | |
2062 | if (cse2_dump) | |
dfe1a916 | 2063 | cse2_dump_file = open_dump_file (dump_base_name, ".cse2"); |
4291d9c8 RS |
2064 | |
2065 | /* If flow dump desired, open the output file. */ | |
2066 | if (flow_dump) | |
dfe1a916 | 2067 | flow_dump_file = open_dump_file (dump_base_name, ".flow"); |
4291d9c8 RS |
2068 | |
2069 | /* If combine dump desired, open the output file. */ | |
2070 | if (combine_dump) | |
dfe1a916 | 2071 | combine_dump_file = open_dump_file (dump_base_name, ".combine"); |
4291d9c8 RS |
2072 | |
2073 | /* If scheduling dump desired, open the output file. */ | |
2074 | if (sched_dump) | |
dfe1a916 | 2075 | sched_dump_file = open_dump_file (dump_base_name, ".sched"); |
4291d9c8 RS |
2076 | |
2077 | /* If local_reg dump desired, open the output file. */ | |
2078 | if (local_reg_dump) | |
dfe1a916 | 2079 | local_reg_dump_file = open_dump_file (dump_base_name, ".lreg"); |
4291d9c8 RS |
2080 | |
2081 | /* If global_reg dump desired, open the output file. */ | |
2082 | if (global_reg_dump) | |
dfe1a916 | 2083 | global_reg_dump_file = open_dump_file (dump_base_name, ".greg"); |
4291d9c8 RS |
2084 | |
2085 | /* If 2nd scheduling dump desired, open the output file. */ | |
2086 | if (sched2_dump) | |
dfe1a916 | 2087 | sched2_dump_file = open_dump_file (dump_base_name, ".sched2"); |
4291d9c8 RS |
2088 | |
2089 | /* If jump2_opt dump desired, open the output file. */ | |
2090 | if (jump2_opt_dump) | |
dfe1a916 | 2091 | jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2"); |
4291d9c8 RS |
2092 | |
2093 | /* If dbr_sched dump desired, open the output file. */ | |
2094 | if (dbr_sched_dump) | |
dfe1a916 | 2095 | dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr"); |
4291d9c8 RS |
2096 | |
2097 | #ifdef STACK_REGS | |
2098 | ||
2099 | /* If stack_reg dump desired, open the output file. */ | |
2100 | if (stack_reg_dump) | |
dfe1a916 | 2101 | stack_reg_dump_file = open_dump_file (dump_base_name, ".stack"); |
4291d9c8 RS |
2102 | |
2103 | #endif | |
2104 | ||
2105 | /* Open assembler code output file. */ | |
2106 | ||
2107 | if (! name_specified && asm_file_name == 0) | |
2108 | asm_out_file = stdout; | |
2109 | else | |
2110 | { | |
4291d9c8 | 2111 | int len = strlen (dump_base_name); |
dfe1a916 | 2112 | register char *dumpname = (char *) xmalloc (len + 6); |
4291d9c8 RS |
2113 | strcpy (dumpname, dump_base_name); |
2114 | strip_off_ending (dumpname, len); | |
2115 | strcat (dumpname, ".s"); | |
2116 | if (asm_file_name == 0) | |
2117 | { | |
2118 | asm_file_name = (char *) xmalloc (strlen (dumpname) + 1); | |
2119 | strcpy (asm_file_name, dumpname); | |
2120 | } | |
2121 | if (!strcmp (asm_file_name, "-")) | |
2122 | asm_out_file = stdout; | |
2123 | else | |
2124 | asm_out_file = fopen (asm_file_name, "w"); | |
2125 | if (asm_out_file == 0) | |
2126 | pfatal_with_name (asm_file_name); | |
2127 | } | |
2128 | ||
f246a305 | 2129 | #ifdef IO_BUFFER_SIZE |
d7cedf4b RS |
2130 | setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), |
2131 | _IOFBF, IO_BUFFER_SIZE); | |
f246a305 RS |
2132 | #endif |
2133 | ||
4291d9c8 RS |
2134 | input_filename = name; |
2135 | ||
18736654 RK |
2136 | /* Put an entry on the input file stack for the main input file. */ |
2137 | input_file_stack | |
2138 | = (struct file_stack *) xmalloc (sizeof (struct file_stack)); | |
2139 | input_file_stack->next = 0; | |
2140 | input_file_stack->name = input_filename; | |
2141 | ||
4291d9c8 RS |
2142 | /* Perform language-specific initialization. |
2143 | This may set main_input_filename. */ | |
2144 | lang_init (); | |
2145 | ||
2146 | /* If the input doesn't start with a #line, use the input name | |
2147 | as the official input file name. */ | |
2148 | if (main_input_filename == 0) | |
2149 | main_input_filename = name; | |
2150 | ||
ca695ac9 JB |
2151 | if (!output_bytecode) |
2152 | { | |
2153 | ASM_FILE_START (asm_out_file); | |
2154 | } | |
4291d9c8 | 2155 | |
ca695ac9 JB |
2156 | /* Output something to inform GDB that this compilation was by GCC. Also |
2157 | serves to tell GDB file consists of bytecodes. */ | |
2158 | if (output_bytecode) | |
2159 | fprintf (asm_out_file, "bc_gcc2_compiled.:\n"); | |
2160 | else | |
2161 | { | |
4291d9c8 | 2162 | #ifndef ASM_IDENTIFY_GCC |
ca695ac9 | 2163 | fprintf (asm_out_file, "gcc2_compiled.:\n"); |
4291d9c8 | 2164 | #else |
ca695ac9 | 2165 | ASM_IDENTIFY_GCC (asm_out_file); |
4291d9c8 | 2166 | #endif |
ca695ac9 | 2167 | } |
d0d4af87 MS |
2168 | |
2169 | /* Output something to identify which front-end produced this file. */ | |
2170 | #ifdef ASM_IDENTIFY_LANGUAGE | |
2171 | ASM_IDENTIFY_LANGUAGE (asm_out_file); | |
2172 | #endif | |
2173 | ||
ca695ac9 JB |
2174 | if (output_bytecode) |
2175 | { | |
2176 | if (profile_flag || profile_block_flag) | |
2177 | error ("profiling not supported in bytecode compilation"); | |
2178 | } | |
2179 | else | |
2180 | { | |
2181 | /* ??? Note: There used to be a conditional here | |
2182 | to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined. | |
2183 | This was to guarantee separation between gcc_compiled. and | |
2184 | the first function, for the sake of dbx on Suns. | |
2185 | However, having the extra zero here confused the Emacs | |
2186 | code for unexec, and might confuse other programs too. | |
2187 | Therefore, I took out that change. | |
2188 | In future versions we should find another way to solve | |
2189 | that dbx problem. -- rms, 23 May 93. */ | |
2190 | ||
2191 | /* Don't let the first function fall at the same address | |
2192 | as gcc_compiled., if profiling. */ | |
2193 | if (profile_flag || profile_block_flag) | |
2194 | assemble_zeros (UNITS_PER_WORD); | |
2195 | } | |
4291d9c8 RS |
2196 | |
2197 | /* If dbx symbol table desired, initialize writing it | |
2198 | and output the predefined types. */ | |
f246a305 RS |
2199 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2200 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2201 | TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename, |
2202 | getdecls ())); | |
2203 | #endif | |
2204 | #ifdef SDB_DEBUGGING_INFO | |
2205 | if (write_symbols == SDB_DEBUG) | |
2206 | TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename, | |
2207 | getdecls ())); | |
2208 | #endif | |
2209 | #ifdef DWARF_DEBUGGING_INFO | |
2210 | if (write_symbols == DWARF_DEBUG) | |
2211 | TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename)); | |
2212 | #endif | |
2213 | ||
2214 | /* Initialize yet another pass. */ | |
2215 | ||
ca695ac9 JB |
2216 | if (!output_bytecode) |
2217 | init_final (main_input_filename); | |
4291d9c8 RS |
2218 | |
2219 | start_time = get_run_time (); | |
2220 | ||
2221 | /* Call the parser, which parses the entire file | |
2222 | (calling rest_of_compilation for each function). */ | |
2223 | ||
2224 | if (yyparse () != 0) | |
453dfc78 JW |
2225 | { |
2226 | if (errorcount == 0) | |
2227 | fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)"); | |
2228 | ||
2229 | /* In case there were missing closebraces, | |
2230 | get us back to the global binding level. */ | |
2231 | while (! global_bindings_p ()) | |
2232 | poplevel (0, 0, 0); | |
2233 | } | |
4291d9c8 RS |
2234 | |
2235 | /* Compilation is now finished except for writing | |
2236 | what's left of the symbol table output. */ | |
2237 | ||
2238 | parse_time += get_run_time () - start_time; | |
2239 | ||
2240 | parse_time -= integration_time; | |
2241 | parse_time -= varconst_time; | |
2242 | ||
2243 | globals = getdecls (); | |
2244 | ||
2245 | /* Really define vars that have had only a tentative definition. | |
2246 | Really output inline functions that must actually be callable | |
2247 | and have not been output so far. */ | |
2248 | ||
2249 | { | |
2250 | int len = list_length (globals); | |
2251 | tree *vec = (tree *) alloca (sizeof (tree) * len); | |
2252 | int i; | |
2253 | tree decl; | |
2b6c54d6 | 2254 | int reconsider = 1; |
4291d9c8 RS |
2255 | |
2256 | /* Process the decls in reverse order--earliest first. | |
2257 | Put them into VEC from back to front, then take out from front. */ | |
2258 | ||
2259 | for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) | |
2260 | vec[len - i - 1] = decl; | |
2261 | ||
2262 | for (i = 0; i < len; i++) | |
2263 | { | |
2264 | decl = vec[i]; | |
07af9d16 JM |
2265 | |
2266 | /* We're not deferring this any longer. */ | |
2267 | DECL_DEFER_OUTPUT (decl) = 0; | |
2268 | ||
488b1f4f RS |
2269 | if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0 |
2270 | && incomplete_decl_finalize_hook != 0) | |
2b599527 | 2271 | (*incomplete_decl_finalize_hook) (decl); |
2b6c54d6 | 2272 | } |
2b599527 | 2273 | |
2b6c54d6 JM |
2274 | /* Now emit any global variables or functions that we have been putting |
2275 | off. We need to loop in case one of the things emitted here | |
2276 | references another one which comes earlier in the list. */ | |
2277 | while (reconsider) | |
2278 | { | |
2279 | reconsider = 0; | |
2280 | for (i = 0; i < len; i++) | |
4291d9c8 | 2281 | { |
2b6c54d6 JM |
2282 | decl = vec[i]; |
2283 | ||
2284 | if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl)) | |
2285 | continue; | |
2286 | ||
6b2bd61e PB |
2287 | /* Don't write out static consts, unless we still need them. |
2288 | ||
2289 | We also keep static consts if not optimizing (for debugging). | |
2290 | ??? They might be better written into the debug information. | |
2291 | This is possible when using DWARF. | |
2292 | ||
2293 | A language processor that wants static constants to be always | |
2294 | written out (even if it is not used) is responsible for | |
2295 | calling rest_of_decl_compilation itself. E.g. the C front-end | |
2296 | calls rest_of_decl_compilation from finish_decl. | |
2297 | One motivation for this is that is conventional in some | |
2298 | environments to write things like: | |
2299 | static const char rcsid[] = "... version string ..."; | |
2300 | intending to force the string to be in the executable. | |
2301 | ||
2302 | A language processor that would prefer to have unneeded | |
2303 | static constants "optimized away" would just defer writing | |
2304 | them out until here. E.g. C++ does this, because static | |
2305 | constants are often defined in header files. | |
2306 | ||
2307 | ??? A tempting alternative (for both C and C++) would be | |
2308 | to force a constant to be written if and only if it is | |
2309 | defined in a main file, as opposed to an include file. */ | |
2310 | ||
2b6c54d6 JM |
2311 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) |
2312 | && (! TREE_READONLY (decl) | |
2313 | || TREE_PUBLIC (decl) | |
2314 | || !optimize | |
2315 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) | |
2316 | { | |
2317 | reconsider = 1; | |
2318 | rest_of_decl_compilation (decl, NULL_PTR, 1, 1); | |
2319 | } | |
2320 | ||
2321 | if (TREE_CODE (decl) == FUNCTION_DECL | |
2322 | && DECL_INITIAL (decl) != 0 | |
2323 | && DECL_SAVED_INSNS (decl) != 0 | |
2324 | && (flag_keep_inline_functions | |
2325 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) | |
2326 | { | |
2327 | reconsider = 1; | |
2328 | temporary_allocation (); | |
2329 | output_inline_function (decl); | |
2330 | permanent_allocation (1); | |
2331 | } | |
4291d9c8 | 2332 | } |
2b6c54d6 | 2333 | } |
4291d9c8 | 2334 | |
2b6c54d6 JM |
2335 | for (i = 0; i < len; i++) |
2336 | { | |
2337 | decl = vec[i]; | |
2338 | ||
2339 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) | |
2340 | && ! TREE_ASM_WRITTEN (decl)) | |
2341 | /* Cancel the RTL for this decl so that, if debugging info | |
2342 | output for global variables is still to come, | |
2343 | this one will be omitted. */ | |
2344 | DECL_RTL (decl) = NULL; | |
4291d9c8 | 2345 | |
ac266247 RS |
2346 | /* Warn about any function |
2347 | declared static but not defined. | |
2348 | We don't warn about variables, | |
2349 | because many programs have static variables | |
2350 | that exist only to get some text into the object file. */ | |
8c461ea1 JM |
2351 | if (TREE_CODE (decl) == FUNCTION_DECL |
2352 | && (warn_unused | |
2353 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) | |
4291d9c8 | 2354 | && DECL_INITIAL (decl) == 0 |
216d5cdd | 2355 | && DECL_EXTERNAL (decl) |
4291d9c8 | 2356 | && ! TREE_PUBLIC (decl)) |
7d429c41 | 2357 | { |
8c461ea1 | 2358 | pedwarn_with_decl (decl, |
7d429c41 RS |
2359 | "`%s' declared `static' but never defined"); |
2360 | /* This symbol is effectively an "extern" declaration now. */ | |
2361 | TREE_PUBLIC (decl) = 1; | |
2362 | assemble_external (decl); | |
7d429c41 | 2363 | } |
8c461ea1 | 2364 | |
4291d9c8 | 2365 | /* Warn about static fns or vars defined but not used, |
7062b881 PB |
2366 | but not about inline functions or static consts |
2367 | since defining those in header files is normal practice. */ | |
4291d9c8 | 2368 | if (warn_unused |
7062b881 PB |
2369 | && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl)) |
2370 | || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl))) | |
0c20aabf | 2371 | && ! DECL_IN_SYSTEM_HEADER (decl) |
216d5cdd | 2372 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2373 | && ! TREE_PUBLIC (decl) |
2374 | && ! TREE_USED (decl) | |
f843649d | 2375 | && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl)) |
4291d9c8 RS |
2376 | /* The TREE_USED bit for file-scope decls |
2377 | is kept in the identifier, to handle multiple | |
2378 | external decls in different scopes. */ | |
2379 | && ! TREE_USED (DECL_NAME (decl))) | |
2380 | warning_with_decl (decl, "`%s' defined but not used"); | |
2381 | ||
2382 | #ifdef SDB_DEBUGGING_INFO | |
2383 | /* The COFF linker can move initialized global vars to the end. | |
2384 | And that can screw up the symbol ordering. | |
2385 | By putting the symbols in that order to begin with, | |
2386 | we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */ | |
2387 | if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL | |
2388 | && TREE_PUBLIC (decl) && DECL_INITIAL (decl) | |
7efad3f7 | 2389 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2390 | && DECL_RTL (decl) != 0) |
2391 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
2392 | ||
2393 | /* Output COFF information for non-global | |
2394 | file-scope initialized variables. */ | |
2395 | if (write_symbols == SDB_DEBUG | |
2396 | && TREE_CODE (decl) == VAR_DECL | |
2397 | && DECL_INITIAL (decl) | |
7efad3f7 | 2398 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2399 | && DECL_RTL (decl) != 0 |
2400 | && GET_CODE (DECL_RTL (decl)) == MEM) | |
2401 | TIMEVAR (symout_time, sdbout_toplevel_data (decl)); | |
2402 | #endif /* SDB_DEBUGGING_INFO */ | |
2403 | #ifdef DWARF_DEBUGGING_INFO | |
6dc42e49 | 2404 | /* Output DWARF information for file-scope tentative data object |
4291d9c8 RS |
2405 | declarations, file-scope (extern) function declarations (which |
2406 | had no corresponding body) and file-scope tagged type declarations | |
2407 | and definitions which have not yet been forced out. */ | |
2408 | ||
2409 | if (write_symbols == DWARF_DEBUG | |
2410 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
2411 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1)); | |
2412 | #endif | |
2413 | } | |
2414 | } | |
2415 | ||
4b8af8d9 JM |
2416 | /* Write out any pending weak symbol declarations. */ |
2417 | ||
2418 | weak_finish (); | |
2419 | ||
4291d9c8 | 2420 | /* Do dbx symbols */ |
f246a305 RS |
2421 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2422 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2423 | TIMEVAR (symout_time, |
2424 | { | |
2425 | dbxout_finish (asm_out_file, main_input_filename); | |
2426 | }); | |
2427 | #endif | |
2428 | ||
2429 | #ifdef DWARF_DEBUGGING_INFO | |
2430 | if (write_symbols == DWARF_DEBUG) | |
2431 | TIMEVAR (symout_time, | |
2432 | { | |
2433 | dwarfout_finish (); | |
2434 | }); | |
2435 | #endif | |
2436 | ||
2437 | /* Output some stuff at end of file if nec. */ | |
2438 | ||
ca695ac9 JB |
2439 | if (!output_bytecode) |
2440 | { | |
2441 | end_final (main_input_filename); | |
4291d9c8 RS |
2442 | |
2443 | #ifdef ASM_FILE_END | |
ca695ac9 | 2444 | ASM_FILE_END (asm_out_file); |
4291d9c8 | 2445 | #endif |
ca695ac9 | 2446 | } |
4291d9c8 | 2447 | |
4291d9c8 RS |
2448 | /* Language-specific end of compilation actions. */ |
2449 | ||
2450 | lang_finish (); | |
2451 | ||
0207ea82 RK |
2452 | if (output_bytecode) |
2453 | bc_write_file (asm_out_file); | |
2454 | ||
4291d9c8 RS |
2455 | /* Close the dump files. */ |
2456 | ||
2457 | if (flag_gen_aux_info) | |
2458 | { | |
2459 | fclose (aux_info_file); | |
2460 | if (errorcount) | |
2461 | unlink (aux_info_file_name); | |
2462 | } | |
2463 | ||
2464 | if (rtl_dump) | |
2465 | fclose (rtl_dump_file); | |
2466 | ||
2467 | if (jump_opt_dump) | |
2468 | fclose (jump_opt_dump_file); | |
2469 | ||
2470 | if (cse_dump) | |
2471 | fclose (cse_dump_file); | |
2472 | ||
2473 | if (loop_dump) | |
2474 | fclose (loop_dump_file); | |
2475 | ||
2476 | if (cse2_dump) | |
2477 | fclose (cse2_dump_file); | |
2478 | ||
2479 | if (flow_dump) | |
2480 | fclose (flow_dump_file); | |
2481 | ||
2482 | if (combine_dump) | |
2483 | { | |
2484 | dump_combine_total_stats (combine_dump_file); | |
2485 | fclose (combine_dump_file); | |
2486 | } | |
2487 | ||
2488 | if (sched_dump) | |
2489 | fclose (sched_dump_file); | |
2490 | ||
2491 | if (local_reg_dump) | |
2492 | fclose (local_reg_dump_file); | |
2493 | ||
2494 | if (global_reg_dump) | |
2495 | fclose (global_reg_dump_file); | |
2496 | ||
2497 | if (sched2_dump) | |
2498 | fclose (sched2_dump_file); | |
2499 | ||
2500 | if (jump2_opt_dump) | |
2501 | fclose (jump2_opt_dump_file); | |
2502 | ||
2503 | if (dbr_sched_dump) | |
2504 | fclose (dbr_sched_dump_file); | |
2505 | ||
2506 | #ifdef STACK_REGS | |
2507 | if (stack_reg_dump) | |
2508 | fclose (stack_reg_dump_file); | |
2509 | #endif | |
2510 | ||
2511 | /* Close non-debugging input and output files. Take special care to note | |
2512 | whether fclose returns an error, since the pages might still be on the | |
2513 | buffer chain while the file is open. */ | |
2514 | ||
2515 | fclose (finput); | |
2516 | if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0) | |
2517 | fatal_io_error (asm_file_name); | |
2518 | ||
2519 | /* Print the times. */ | |
2520 | ||
2521 | if (! quiet_flag) | |
2522 | { | |
2523 | fprintf (stderr,"\n"); | |
2524 | print_time ("parse", parse_time); | |
ca695ac9 JB |
2525 | |
2526 | if (!output_bytecode) | |
2527 | { | |
2528 | print_time ("integration", integration_time); | |
2529 | print_time ("jump", jump_time); | |
2530 | print_time ("cse", cse_time); | |
2531 | print_time ("loop", loop_time); | |
2532 | print_time ("cse2", cse2_time); | |
2533 | print_time ("flow", flow_time); | |
2534 | print_time ("combine", combine_time); | |
2535 | print_time ("sched", sched_time); | |
2536 | print_time ("local-alloc", local_alloc_time); | |
2537 | print_time ("global-alloc", global_alloc_time); | |
2538 | print_time ("sched2", sched2_time); | |
2539 | print_time ("dbranch", dbr_sched_time); | |
2540 | print_time ("shorten-branch", shorten_branch_time); | |
2541 | print_time ("stack-reg", stack_reg_time); | |
2542 | print_time ("final", final_time); | |
2543 | print_time ("varconst", varconst_time); | |
2544 | print_time ("symout", symout_time); | |
2545 | print_time ("dump", dump_time); | |
2546 | } | |
4291d9c8 RS |
2547 | } |
2548 | } | |
2549 | \f | |
2550 | /* This is called from various places for FUNCTION_DECL, VAR_DECL, | |
2551 | and TYPE_DECL nodes. | |
2552 | ||
2553 | This does nothing for local (non-static) variables. | |
2554 | Otherwise, it sets up the RTL and outputs any assembler code | |
2555 | (label definition, storage allocation and initialization). | |
2556 | ||
2557 | DECL is the declaration. If ASMSPEC is nonzero, it specifies | |
2558 | the assembler symbol name to be used. TOP_LEVEL is nonzero | |
2559 | if this declaration is not within a function. */ | |
2560 | ||
2561 | void | |
2562 | rest_of_decl_compilation (decl, asmspec, top_level, at_end) | |
2563 | tree decl; | |
2564 | char *asmspec; | |
2565 | int top_level; | |
2566 | int at_end; | |
2567 | { | |
2568 | /* Declarations of variables, and of functions defined elsewhere. */ | |
2569 | ||
928eb380 RS |
2570 | /* The most obvious approach, to put an #ifndef around where |
2571 | this macro is used, doesn't work since it's inside a macro call. */ | |
2572 | #ifndef ASM_FINISH_DECLARE_OBJECT | |
2573 | #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END) | |
2574 | #endif | |
2575 | ||
4291d9c8 RS |
2576 | /* Forward declarations for nested functions are not "external", |
2577 | but we need to treat them as if they were. */ | |
216d5cdd | 2578 | if (TREE_STATIC (decl) || DECL_EXTERNAL (decl) |
4291d9c8 RS |
2579 | || TREE_CODE (decl) == FUNCTION_DECL) |
2580 | TIMEVAR (varconst_time, | |
2581 | { | |
2582 | make_decl_rtl (decl, asmspec, top_level); | |
9a9a9643 RS |
2583 | /* Initialized extern variable exists to be replaced |
2584 | with its value, or represents something that will be | |
2585 | output in another file. */ | |
6dbf678a | 2586 | if (! (TREE_CODE (decl) == VAR_DECL |
9a9a9643 RS |
2587 | && DECL_EXTERNAL (decl) && TREE_READONLY (decl) |
2588 | && DECL_INITIAL (decl) != 0 | |
5b272d50 | 2589 | && DECL_INITIAL (decl) != error_mark_node)) |
6dbf678a RS |
2590 | /* Don't output anything |
2591 | when a tentative file-scope definition is seen. | |
2592 | But at end of compilation, do output code for them. */ | |
2593 | if (! (! at_end && top_level | |
2594 | && (DECL_INITIAL (decl) == 0 | |
9a9a9643 | 2595 | || DECL_INITIAL (decl) == error_mark_node))) |
8380e2f2 | 2596 | assemble_variable (decl, top_level, at_end, 0); |
5e10b3cc RS |
2597 | if (decl == last_assemble_variable_decl) |
2598 | { | |
2599 | ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl, | |
2600 | top_level, at_end); | |
2601 | } | |
4291d9c8 | 2602 | }); |
216d5cdd | 2603 | else if (DECL_REGISTER (decl) && asmspec != 0) |
4291d9c8 RS |
2604 | { |
2605 | if (decode_reg_name (asmspec) >= 0) | |
2606 | { | |
2607 | DECL_RTL (decl) = 0; | |
2608 | make_decl_rtl (decl, asmspec, top_level); | |
2609 | } | |
2610 | else | |
2611 | error ("invalid register name `%s' for register variable", asmspec); | |
2612 | } | |
f246a305 RS |
2613 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2614 | else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
2615 | && TREE_CODE (decl) == TYPE_DECL) | |
4291d9c8 RS |
2616 | TIMEVAR (symout_time, dbxout_symbol (decl, 0)); |
2617 | #endif | |
2618 | #ifdef SDB_DEBUGGING_INFO | |
2619 | else if (write_symbols == SDB_DEBUG && top_level | |
2620 | && TREE_CODE (decl) == TYPE_DECL) | |
2621 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
2622 | #endif | |
2623 | } | |
2624 | ||
2625 | /* Called after finishing a record, union or enumeral type. */ | |
2626 | ||
2627 | void | |
2628 | rest_of_type_compilation (type, toplev) | |
2629 | tree type; | |
2630 | int toplev; | |
2631 | { | |
f246a305 RS |
2632 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2633 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2634 | TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev)); |
2635 | #endif | |
2636 | #ifdef SDB_DEBUGGING_INFO | |
2637 | if (write_symbols == SDB_DEBUG) | |
2638 | TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev)); | |
2639 | #endif | |
2640 | } | |
2641 | ||
2642 | /* This is called from finish_function (within yyparse) | |
2643 | after each top-level definition is parsed. | |
2644 | It is supposed to compile that function or variable | |
2645 | and output the assembler code for it. | |
2646 | After we return, the tree storage is freed. */ | |
2647 | ||
2648 | void | |
2649 | rest_of_compilation (decl) | |
2650 | tree decl; | |
2651 | { | |
2652 | register rtx insns; | |
2653 | int start_time = get_run_time (); | |
2654 | int tem; | |
2655 | /* Nonzero if we have saved the original DECL_INITIAL of the function, | |
2656 | to be restored after we finish compiling the function | |
2657 | (for use when compiling inline calls to this function). */ | |
2658 | tree saved_block_tree = 0; | |
8a958768 RS |
2659 | /* Likewise, for DECL_ARGUMENTS. */ |
2660 | tree saved_arguments = 0; | |
ab40ad2b | 2661 | int failure = 0; |
4291d9c8 | 2662 | |
ca695ac9 JB |
2663 | if (output_bytecode) |
2664 | return; | |
2665 | ||
4291d9c8 RS |
2666 | /* If we are reconsidering an inline function |
2667 | at the end of compilation, skip the stuff for making it inline. */ | |
2668 | ||
2669 | if (DECL_SAVED_INSNS (decl) == 0) | |
2670 | { | |
9deaf1b1 | 2671 | int inlineable = 0; |
4291d9c8 RS |
2672 | char *lose; |
2673 | ||
2674 | /* If requested, consider whether to make this function inline. */ | |
9deaf1b1 | 2675 | if (DECL_INLINE (decl) || flag_inline_functions) |
4291d9c8 RS |
2676 | TIMEVAR (integration_time, |
2677 | { | |
2678 | lose = function_cannot_inline_p (decl); | |
caa0eccd | 2679 | if (lose || ! optimize) |
4291d9c8 | 2680 | { |
9deaf1b1 | 2681 | if (warn_inline && DECL_INLINE (decl)) |
4291d9c8 | 2682 | warning_with_decl (decl, lose); |
9548c538 | 2683 | DECL_ABSTRACT_ORIGIN (decl) = 0; |
46dbb914 RS |
2684 | /* Don't really compile an extern inline function. |
2685 | If we can't make it inline, pretend | |
2686 | it was only declared. */ | |
2687 | if (DECL_EXTERNAL (decl)) | |
27937f46 RS |
2688 | { |
2689 | DECL_INITIAL (decl) = 0; | |
2690 | goto exit_rest_of_compilation; | |
2691 | } | |
4291d9c8 RS |
2692 | } |
2693 | else | |
9deaf1b1 RK |
2694 | /* ??? Note that this has the effect of making it look |
2695 | like "inline" was specified for a function if we choose | |
2696 | to inline it. This isn't quite right, but it's | |
2697 | probably not worth the trouble to fix. */ | |
2698 | inlineable = DECL_INLINE (decl) = 1; | |
4291d9c8 RS |
2699 | }); |
2700 | ||
2701 | insns = get_insns (); | |
2702 | ||
2703 | /* Dump the rtl code if we are dumping rtl. */ | |
2704 | ||
2705 | if (rtl_dump) | |
2706 | TIMEVAR (dump_time, | |
2707 | { | |
2708 | fprintf (rtl_dump_file, "\n;; Function %s\n\n", | |
2709 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2710 | if (DECL_SAVED_INSNS (decl)) | |
2711 | fprintf (rtl_dump_file, ";; (integrable)\n\n"); | |
2712 | print_rtl (rtl_dump_file, insns); | |
2713 | fflush (rtl_dump_file); | |
2714 | }); | |
2715 | ||
2716 | /* If function is inline, and we don't yet know whether to | |
2717 | compile it by itself, defer decision till end of compilation. | |
2718 | finish_compilation will call rest_of_compilation again | |
16411ea6 | 2719 | for those functions that need to be output. Also defer those |
ec6c615d RK |
2720 | functions that we are supposed to defer. We cannot defer |
2721 | functions containing nested functions since the nested function | |
2722 | data is in our non-saved obstack. */ | |
2723 | ||
2724 | if (! current_function_contains_functions | |
2725 | && (DECL_DEFER_OUTPUT (decl) | |
9deaf1b1 | 2726 | || (DECL_INLINE (decl) |
ec6c615d RK |
2727 | && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) |
2728 | && ! flag_keep_inline_functions) | |
2729 | || DECL_EXTERNAL (decl))))) | |
4291d9c8 | 2730 | { |
951af26e JM |
2731 | DECL_DEFER_OUTPUT (decl) = 1; |
2732 | ||
2733 | /* If -Wreturn-type, we have to do a bit of compilation. */ | |
2734 | if (! warn_return_type) | |
937522b5 | 2735 | { |
951af26e JM |
2736 | #ifdef DWARF_DEBUGGING_INFO |
2737 | /* Generate the DWARF info for the "abstract" instance | |
2738 | of a function which we may later generate inlined and/or | |
2739 | out-of-line instances of. */ | |
2740 | if (write_symbols == DWARF_DEBUG) | |
2741 | { | |
2742 | set_decl_abstract_flags (decl, 1); | |
2743 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
2744 | set_decl_abstract_flags (decl, 0); | |
2745 | } | |
2746 | #endif | |
2747 | TIMEVAR (integration_time, save_for_inline_nocopy (decl)); | |
ac02eb62 | 2748 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable; |
951af26e | 2749 | goto exit_rest_of_compilation; |
937522b5 | 2750 | } |
4291d9c8 RS |
2751 | } |
2752 | ||
8a958768 | 2753 | /* If we have to compile the function now, save its rtl and subdecls |
4291d9c8 | 2754 | so that its compilation will not affect what others get. */ |
9deaf1b1 | 2755 | if (inlineable || DECL_DEFER_OUTPUT (decl)) |
4291d9c8 | 2756 | { |
937522b5 RS |
2757 | #ifdef DWARF_DEBUGGING_INFO |
2758 | /* Generate the DWARF info for the "abstract" instance of | |
2759 | a function which we will generate an out-of-line instance | |
2760 | of almost immediately (and which we may also later generate | |
2761 | various inlined instances of). */ | |
2762 | if (write_symbols == DWARF_DEBUG) | |
2763 | { | |
2764 | set_decl_abstract_flags (decl, 1); | |
2765 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
2766 | set_decl_abstract_flags (decl, 0); | |
2767 | } | |
2768 | #endif | |
4291d9c8 | 2769 | saved_block_tree = DECL_INITIAL (decl); |
8a958768 | 2770 | saved_arguments = DECL_ARGUMENTS (decl); |
4291d9c8 | 2771 | TIMEVAR (integration_time, save_for_inline_copying (decl)); |
912c4289 | 2772 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable; |
4291d9c8 | 2773 | } |
4291d9c8 | 2774 | |
b8471b65 RK |
2775 | /* If specified extern inline but we aren't inlining it, we are |
2776 | done. */ | |
9deaf1b1 | 2777 | if (DECL_INLINE (decl) && DECL_EXTERNAL (decl)) |
b8471b65 RK |
2778 | goto exit_rest_of_compilation; |
2779 | } | |
07af9d16 | 2780 | |
951af26e JM |
2781 | if (! DECL_DEFER_OUTPUT (decl)) |
2782 | TREE_ASM_WRITTEN (decl) = 1; | |
4291d9c8 RS |
2783 | |
2784 | /* Now that integrate will no longer see our rtl, we need not distinguish | |
2785 | between the return value of this function and the return value of called | |
2786 | functions. */ | |
2787 | rtx_equal_function_value_matters = 0; | |
2788 | ||
32235b30 RS |
2789 | /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */ |
2790 | if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type) | |
4291d9c8 RS |
2791 | { |
2792 | goto exit_rest_of_compilation; | |
2793 | } | |
2794 | ||
2795 | /* From now on, allocate rtl in current_obstack, not in saveable_obstack. | |
2796 | Note that that may have been done above, in save_for_inline_copying. | |
2797 | The call to resume_temporary_allocation near the end of this function | |
2798 | goes back to the usual state of affairs. */ | |
2799 | ||
2800 | rtl_in_current_obstack (); | |
2801 | ||
2802 | #ifdef FINALIZE_PIC | |
2803 | /* If we are doing position-independent code generation, now | |
2804 | is the time to output special prologues and epilogues. | |
2805 | We do not want to do this earlier, because it just clutters | |
2806 | up inline functions with meaningless insns. */ | |
2807 | if (flag_pic) | |
2808 | FINALIZE_PIC; | |
2809 | #endif | |
2810 | ||
2811 | insns = get_insns (); | |
2812 | ||
2813 | /* Copy any shared structure that should not be shared. */ | |
2814 | ||
2815 | unshare_all_rtl (insns); | |
2816 | ||
2817 | /* Instantiate all virtual registers. */ | |
2818 | ||
2819 | instantiate_virtual_regs (current_function_decl, get_insns ()); | |
2820 | ||
2821 | /* See if we have allocated stack slots that are not directly addressable. | |
2822 | If so, scan all the insns and create explicit address computation | |
2823 | for all references to such slots. */ | |
2824 | /* fixup_stack_slots (); */ | |
2825 | ||
cc4e79d8 JL |
2826 | /* Always do one jump optimization pass to ensure that JUMP_LABEL fields |
2827 | are initialized and to compute whether control can drop off the end | |
2828 | of the function. */ | |
2829 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
2830 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); | |
4291d9c8 | 2831 | |
32235b30 | 2832 | /* Now is when we stop if -fsyntax-only and -Wreturn-type. */ |
951af26e | 2833 | if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl)) |
32235b30 RS |
2834 | goto exit_rest_of_compilation; |
2835 | ||
4291d9c8 RS |
2836 | /* Dump rtl code after jump, if we are doing that. */ |
2837 | ||
2838 | if (jump_opt_dump) | |
2839 | TIMEVAR (dump_time, | |
2840 | { | |
2841 | fprintf (jump_opt_dump_file, "\n;; Function %s\n\n", | |
2842 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2843 | print_rtl (jump_opt_dump_file, insns); | |
2844 | fflush (jump_opt_dump_file); | |
2845 | }); | |
2846 | ||
2847 | /* Perform common subexpression elimination. | |
2848 | Nonzero value from `cse_main' means that jumps were simplified | |
2849 | and some code may now be unreachable, so do | |
2850 | jump optimization again. */ | |
2851 | ||
2852 | if (cse_dump) | |
2853 | TIMEVAR (dump_time, | |
2854 | { | |
2855 | fprintf (cse_dump_file, "\n;; Function %s\n\n", | |
2856 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2857 | }); | |
2858 | ||
2859 | if (optimize > 0) | |
2860 | { | |
2861 | TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1)); | |
2862 | ||
2863 | if (flag_thread_jumps) | |
2864 | /* Hacks by tiemann & kenner. */ | |
6f606d63 | 2865 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1)); |
4291d9c8 RS |
2866 | |
2867 | TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), | |
2868 | 0, cse_dump_file)); | |
2869 | TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ())); | |
2870 | ||
534bfae4 | 2871 | if (tem || optimize > 1) |
4291d9c8 RS |
2872 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); |
2873 | } | |
2874 | ||
2875 | /* Dump rtl code after cse, if we are doing that. */ | |
2876 | ||
2877 | if (cse_dump) | |
2878 | TIMEVAR (dump_time, | |
2879 | { | |
2880 | print_rtl (cse_dump_file, insns); | |
2881 | fflush (cse_dump_file); | |
2882 | }); | |
2883 | ||
2884 | if (loop_dump) | |
2885 | TIMEVAR (dump_time, | |
2886 | { | |
2887 | fprintf (loop_dump_file, "\n;; Function %s\n\n", | |
2888 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2889 | }); | |
2890 | ||
2891 | /* Move constant computations out of loops. */ | |
2892 | ||
2893 | if (optimize > 0) | |
2894 | { | |
2895 | TIMEVAR (loop_time, | |
2896 | { | |
37366632 | 2897 | loop_optimize (insns, loop_dump_file); |
4291d9c8 RS |
2898 | }); |
2899 | } | |
2900 | ||
2901 | /* Dump rtl code after loop opt, if we are doing that. */ | |
2902 | ||
2903 | if (loop_dump) | |
2904 | TIMEVAR (dump_time, | |
2905 | { | |
2906 | print_rtl (loop_dump_file, insns); | |
2907 | fflush (loop_dump_file); | |
2908 | }); | |
2909 | ||
2910 | if (cse2_dump) | |
2911 | TIMEVAR (dump_time, | |
2912 | { | |
2913 | fprintf (cse2_dump_file, "\n;; Function %s\n\n", | |
2914 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2915 | }); | |
2916 | ||
2917 | if (optimize > 0 && flag_rerun_cse_after_loop) | |
2918 | { | |
44333223 JL |
2919 | /* Running another jump optimization pass before the second |
2920 | cse pass sometimes simplifies the RTL enough to allow | |
9e9b48a4 DE |
2921 | the second CSE pass to do a better job. Jump_optimize can change |
2922 | max_reg_num so we must rerun reg_scan afterwards. | |
2923 | ??? Rework to not call reg_scan so often. */ | |
2924 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
44333223 | 2925 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); |
4291d9c8 | 2926 | |
9e9b48a4 | 2927 | TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); |
4291d9c8 RS |
2928 | TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), |
2929 | 1, cse2_dump_file)); | |
2930 | if (tem) | |
2931 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); | |
2932 | } | |
2933 | ||
2934 | if (optimize > 0 && flag_thread_jumps) | |
2935 | /* This pass of jump threading straightens out code | |
2936 | that was kinked by loop optimization. */ | |
2937 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); | |
2938 | ||
2939 | /* Dump rtl code after cse, if we are doing that. */ | |
2940 | ||
2941 | if (cse2_dump) | |
2942 | TIMEVAR (dump_time, | |
2943 | { | |
2944 | print_rtl (cse2_dump_file, insns); | |
2945 | fflush (cse2_dump_file); | |
2946 | }); | |
2947 | ||
2948 | /* We are no longer anticipating cse in this function, at least. */ | |
2949 | ||
2950 | cse_not_expected = 1; | |
2951 | ||
2952 | /* Now we choose between stupid (pcc-like) register allocation | |
2953 | (if we got the -noreg switch and not -opt) | |
2954 | and smart register allocation. */ | |
2955 | ||
2956 | if (optimize > 0) /* Stupid allocation probably won't work */ | |
2957 | obey_regdecls = 0; /* if optimizations being done. */ | |
2958 | ||
2959 | regclass_init (); | |
2960 | ||
2961 | /* Print function header into flow dump now | |
2962 | because doing the flow analysis makes some of the dump. */ | |
2963 | ||
2964 | if (flow_dump) | |
2965 | TIMEVAR (dump_time, | |
2966 | { | |
2967 | fprintf (flow_dump_file, "\n;; Function %s\n\n", | |
2968 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2969 | }); | |
2970 | ||
2971 | if (obey_regdecls) | |
2972 | { | |
2973 | TIMEVAR (flow_time, | |
2974 | { | |
2975 | regclass (insns, max_reg_num ()); | |
2976 | stupid_life_analysis (insns, max_reg_num (), | |
2977 | flow_dump_file); | |
2978 | }); | |
2979 | } | |
2980 | else | |
2981 | { | |
2982 | /* Do control and data flow analysis, | |
2983 | and write some of the results to dump file. */ | |
2984 | ||
2985 | TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (), | |
2986 | flow_dump_file)); | |
2987 | if (warn_uninitialized) | |
2988 | { | |
2989 | uninitialized_vars_warning (DECL_INITIAL (decl)); | |
2990 | setjmp_args_warning (); | |
2991 | } | |
2992 | } | |
2993 | ||
2994 | /* Dump rtl after flow analysis. */ | |
2995 | ||
2996 | if (flow_dump) | |
2997 | TIMEVAR (dump_time, | |
2998 | { | |
2999 | print_rtl (flow_dump_file, insns); | |
3000 | fflush (flow_dump_file); | |
3001 | }); | |
3002 | ||
3003 | /* If -opt, try combining insns through substitution. */ | |
3004 | ||
3005 | if (optimize > 0) | |
3006 | TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); | |
3007 | ||
3008 | /* Dump rtl code after insn combination. */ | |
3009 | ||
3010 | if (combine_dump) | |
3011 | TIMEVAR (dump_time, | |
3012 | { | |
3013 | fprintf (combine_dump_file, "\n;; Function %s\n\n", | |
3014 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
3015 | dump_combine_stats (combine_dump_file); | |
3016 | print_rtl (combine_dump_file, insns); | |
3017 | fflush (combine_dump_file); | |
3018 | }); | |
3019 | ||
3020 | /* Print function header into sched dump now | |
3021 | because doing the sched analysis makes some of the dump. */ | |
3022 | ||
3023 | if (sched_dump) | |
3024 | TIMEVAR (dump_time, | |
3025 | { | |
3026 | fprintf (sched_dump_file, "\n;; Function %s\n\n", | |
3027 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
3028 | }); | |
3029 | ||
3030 | if (optimize > 0 && flag_schedule_insns) | |
3031 | { | |
3032 | /* Do control and data sched analysis, | |
3033 | and write some of the results to dump file. */ | |
3034 | ||
3035 | TIMEVAR (sched_time, schedule_insns (sched_dump_file)); | |
3036 | } | |
3037 | ||
3038 | /* Dump rtl after instruction scheduling. */ | |
3039 | ||
3040 | if (sched_dump) | |
3041 | TIMEVAR (dump_time, | |
3042 | { | |
3043 | print_rtl (sched_dump_file, insns); | |
3044 | fflush (sched_dump_file); | |
3045 | }); | |
3046 | ||
3047 | /* Unless we did stupid register allocation, | |
3048 | allocate pseudo-regs that are used only within 1 basic block. */ | |
3049 | ||
3050 | if (!obey_regdecls) | |
3051 | TIMEVAR (local_alloc_time, | |
3052 | { | |
3053 | regclass (insns, max_reg_num ()); | |
3054 | local_alloc (); | |
3055 | }); | |
3056 | ||
3057 | /* Dump rtl code after allocating regs within basic blocks. */ | |
3058 | ||
3059 | if (local_reg_dump) | |
3060 | TIMEVAR (dump_time, | |
3061 | { | |
3062 | fprintf (local_reg_dump_file, "\n;; Function %s\n\n", | |
3063 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
3064 | dump_flow_info (local_reg_dump_file); | |
3065 | dump_local_alloc (local_reg_dump_file); | |
3066 | print_rtl (local_reg_dump_file, insns); | |
3067 | fflush (local_reg_dump_file); | |
3068 | }); | |
3069 | ||
3070 | if (global_reg_dump) | |
3071 | TIMEVAR (dump_time, | |
3072 | fprintf (global_reg_dump_file, "\n;; Function %s\n\n", | |
3073 | IDENTIFIER_POINTER (DECL_NAME (decl)))); | |
3074 | ||
3075 | /* Unless we did stupid register allocation, | |
3076 | allocate remaining pseudo-regs, then do the reload pass | |
3077 | fixing up any insns that are invalid. */ | |
3078 | ||
3079 | TIMEVAR (global_alloc_time, | |
3080 | { | |
3081 | if (!obey_regdecls) | |
37366632 | 3082 | failure = global_alloc (global_reg_dump_file); |
4291d9c8 | 3083 | else |
37366632 | 3084 | failure = reload (insns, 0, global_reg_dump_file); |
4291d9c8 RS |
3085 | }); |
3086 | ||
3087 | if (global_reg_dump) | |
3088 | TIMEVAR (dump_time, | |
3089 | { | |
3090 | dump_global_regs (global_reg_dump_file); | |
3091 | print_rtl (global_reg_dump_file, insns); | |
3092 | fflush (global_reg_dump_file); | |
3093 | }); | |
3094 | ||
ab40ad2b RS |
3095 | if (failure) |
3096 | goto exit_rest_of_compilation; | |
3097 | ||
4291d9c8 RS |
3098 | reload_completed = 1; |
3099 | ||
bdac5f58 TW |
3100 | /* On some machines, the prologue and epilogue code, or parts thereof, |
3101 | can be represented as RTL. Doing so lets us schedule insns between | |
3102 | it and the rest of the code and also allows delayed branch | |
3103 | scheduling to operate in the epilogue. */ | |
3104 | ||
3105 | thread_prologue_and_epilogue_insns (insns); | |
3106 | ||
4291d9c8 RS |
3107 | if (optimize > 0 && flag_schedule_insns_after_reload) |
3108 | { | |
3109 | if (sched2_dump) | |
3110 | TIMEVAR (dump_time, | |
3111 | { | |
3112 | fprintf (sched2_dump_file, "\n;; Function %s\n\n", | |
3113 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
3114 | }); | |
3115 | ||
3116 | /* Do control and data sched analysis again, | |
3117 | and write some more of the results to dump file. */ | |
3118 | ||
3119 | TIMEVAR (sched2_time, schedule_insns (sched2_dump_file)); | |
3120 | ||
3121 | /* Dump rtl after post-reorder instruction scheduling. */ | |
3122 | ||
3123 | if (sched2_dump) | |
3124 | TIMEVAR (dump_time, | |
3125 | { | |
3126 | print_rtl (sched2_dump_file, insns); | |
3127 | fflush (sched2_dump_file); | |
3128 | }); | |
3129 | } | |
3130 | ||
3131 | #ifdef LEAF_REGISTERS | |
3132 | leaf_function = 0; | |
3133 | if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) | |
ab40ad2b | 3134 | leaf_function = 1; |
4291d9c8 RS |
3135 | #endif |
3136 | ||
3137 | /* One more attempt to remove jumps to .+1 | |
3138 | left by dead-store-elimination. | |
3139 | Also do cross-jumping this time | |
3140 | and delete no-op move insns. */ | |
3141 | ||
3142 | if (optimize > 0) | |
3143 | { | |
3144 | TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0)); | |
3145 | } | |
3146 | ||
3147 | /* Dump rtl code after jump, if we are doing that. */ | |
3148 | ||
3149 | if (jump2_opt_dump) | |
3150 | TIMEVAR (dump_time, | |
3151 | { | |
3152 | fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n", | |
3153 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
3154 | print_rtl (jump2_opt_dump_file, insns); | |
3155 | fflush (jump2_opt_dump_file); | |
3156 | }); | |
3157 | ||
2c65021a RK |
3158 | /* If a machine dependent reorganization is needed, call it. */ |
3159 | #ifdef MACHINE_DEPENDENT_REORG | |
3160 | MACHINE_DEPENDENT_REORG (insns); | |
3161 | #endif | |
3162 | ||
4291d9c8 RS |
3163 | /* If a scheduling pass for delayed branches is to be done, |
3164 | call the scheduling code. */ | |
3165 | ||
3166 | #ifdef DELAY_SLOTS | |
3167 | if (optimize > 0 && flag_delayed_branch) | |
3168 | { | |
3169 | TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file)); | |
3170 | if (dbr_sched_dump) | |
3171 | { | |
3172 | TIMEVAR (dump_time, | |
3173 | { | |
3174 | fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n", | |
3175 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
3176 | print_rtl (dbr_sched_dump_file, insns); | |
3177 | fflush (dbr_sched_dump_file); | |
3178 | }); | |
3179 | } | |
3180 | } | |
3181 | #endif | |
3182 | ||
d0c874f6 TG |
3183 | /* Shorten branches. */ |
3184 | TIMEVAR (shorten_branch_time, | |
3185 | { | |
3186 | shorten_branches (get_insns ()); | |
3187 | }); | |
4291d9c8 RS |
3188 | |
3189 | #ifdef STACK_REGS | |
3190 | TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file)); | |
3191 | if (stack_reg_dump) | |
3192 | { | |
3193 | TIMEVAR (dump_time, | |
3194 | { | |
3195 | fprintf (stack_reg_dump_file, "\n;; Function %s\n\n", | |
3196 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
3197 | print_rtl (stack_reg_dump_file, insns); | |
3198 | fflush (stack_reg_dump_file); | |
3199 | }); | |
3200 | } | |
3201 | #endif | |
3202 | ||
3203 | /* Now turn the rtl into assembler code. */ | |
3204 | ||
3205 | TIMEVAR (final_time, | |
3206 | { | |
3207 | rtx x; | |
3208 | char *fnname; | |
3209 | ||
3210 | /* Get the function's name, as described by its RTL. | |
3211 | This may be different from the DECL_NAME name used | |
3212 | in the source file. */ | |
3213 | ||
3214 | x = DECL_RTL (decl); | |
3215 | if (GET_CODE (x) != MEM) | |
3216 | abort (); | |
3217 | x = XEXP (x, 0); | |
3218 | if (GET_CODE (x) != SYMBOL_REF) | |
3219 | abort (); | |
3220 | fnname = XSTR (x, 0); | |
3221 | ||
3222 | assemble_start_function (decl, fnname); | |
3223 | final_start_function (insns, asm_out_file, optimize); | |
3224 | final (insns, asm_out_file, optimize, 0); | |
3225 | final_end_function (insns, asm_out_file, optimize); | |
3226 | assemble_end_function (decl, fnname); | |
3227 | fflush (asm_out_file); | |
3228 | }); | |
3229 | ||
3230 | /* Write DBX symbols if requested */ | |
3231 | ||
3232 | /* Note that for those inline functions where we don't initially | |
3233 | know for certain that we will be generating an out-of-line copy, | |
3234 | the first invocation of this routine (rest_of_compilation) will | |
3235 | skip over this code by doing a `goto exit_rest_of_compilation;'. | |
3236 | Later on, finish_compilation will call rest_of_compilation again | |
3237 | for those inline functions that need to have out-of-line copies | |
3238 | generated. During that call, we *will* be routed past here. */ | |
3239 | ||
3240 | #ifdef DBX_DEBUGGING_INFO | |
3241 | if (write_symbols == DBX_DEBUG) | |
3242 | TIMEVAR (symout_time, dbxout_function (decl)); | |
3243 | #endif | |
3244 | ||
3245 | #ifdef DWARF_DEBUGGING_INFO | |
3246 | if (write_symbols == DWARF_DEBUG) | |
3247 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3248 | #endif | |
3249 | ||
3250 | exit_rest_of_compilation: | |
3251 | ||
f246a305 RS |
3252 | /* In case the function was not output, |
3253 | don't leave any temporary anonymous types | |
3254 | queued up for sdb output. */ | |
3255 | #ifdef SDB_DEBUGGING_INFO | |
3256 | if (write_symbols == SDB_DEBUG) | |
37366632 | 3257 | sdbout_types (NULL_TREE); |
f246a305 RS |
3258 | #endif |
3259 | ||
8a958768 RS |
3260 | /* Put back the tree of subblocks and list of arguments |
3261 | from before we copied them. | |
4291d9c8 RS |
3262 | Code generation and the output of debugging info may have modified |
3263 | the copy, but the original is unchanged. */ | |
3264 | ||
3265 | if (saved_block_tree != 0) | |
3266 | DECL_INITIAL (decl) = saved_block_tree; | |
8a958768 RS |
3267 | if (saved_arguments != 0) |
3268 | DECL_ARGUMENTS (decl) = saved_arguments; | |
4291d9c8 RS |
3269 | |
3270 | reload_completed = 0; | |
3271 | ||
9fe320d7 RK |
3272 | /* Clear out the insn_length contents now that they are no longer valid. */ |
3273 | init_insn_lengths (); | |
3274 | ||
4291d9c8 RS |
3275 | /* Clear out the real_constant_chain before some of the rtx's |
3276 | it runs through become garbage. */ | |
3277 | ||
3278 | clear_const_double_mem (); | |
3279 | ||
3280 | /* Cancel the effect of rtl_in_current_obstack. */ | |
3281 | ||
3282 | resume_temporary_allocation (); | |
3283 | ||
adcd38c9 RK |
3284 | /* Show no temporary slots allocated. */ |
3285 | ||
3286 | init_temp_slots (); | |
3287 | ||
4291d9c8 RS |
3288 | /* The parsing time is all the time spent in yyparse |
3289 | *except* what is spent in this function. */ | |
3290 | ||
3291 | parse_time -= get_run_time () - start_time; | |
3292 | } | |
3293 | \f | |
3294 | /* Entry point of cc1/c++. Decode command args, then call compile_file. | |
3295 | Exit code is 35 if can't open files, 34 if fatal error, | |
3296 | 33 if had nonfatal errors, else success. */ | |
3297 | ||
3298 | int | |
3299 | main (argc, argv, envp) | |
3300 | int argc; | |
3301 | char **argv; | |
3302 | char **envp; | |
3303 | { | |
3304 | register int i; | |
3305 | char *filename = 0; | |
3306 | int flag_print_mem = 0; | |
3307 | int version_flag = 0; | |
3308 | char *p; | |
3309 | ||
3310 | /* save in case md file wants to emit args as a comment. */ | |
3311 | save_argc = argc; | |
3312 | save_argv = argv; | |
3313 | ||
3314 | p = argv[0] + strlen (argv[0]); | |
128373ac RK |
3315 | while (p != argv[0] && p[-1] != '/' |
3316 | #ifdef DIR_SEPARATOR | |
3317 | && p[-1] != DIR_SEPARATOR | |
3318 | #endif | |
3319 | ) | |
3320 | --p; | |
4291d9c8 RS |
3321 | progname = p; |
3322 | ||
3323 | #ifdef RLIMIT_STACK | |
3324 | /* Get rid of any avoidable limit on stack size. */ | |
3325 | { | |
3326 | struct rlimit rlim; | |
3327 | ||
3328 | /* Set the stack limit huge so that alloca does not fail. */ | |
3329 | getrlimit (RLIMIT_STACK, &rlim); | |
3330 | rlim.rlim_cur = rlim.rlim_max; | |
3331 | setrlimit (RLIMIT_STACK, &rlim); | |
3332 | } | |
3333 | #endif /* RLIMIT_STACK */ | |
3334 | ||
3335 | signal (SIGFPE, float_signal); | |
3336 | ||
935d4b07 | 3337 | #ifdef SIGPIPE |
4291d9c8 | 3338 | signal (SIGPIPE, pipe_closed); |
935d4b07 | 3339 | #endif |
4291d9c8 RS |
3340 | |
3341 | decl_printable_name = decl_name; | |
3342 | lang_expand_expr = (struct rtx_def *(*)()) do_abort; | |
61d6b1cc | 3343 | interim_eh_hook = interim_eh; |
4291d9c8 RS |
3344 | |
3345 | /* Initialize whether `char' is signed. */ | |
3346 | flag_signed_char = DEFAULT_SIGNED_CHAR; | |
3347 | #ifdef DEFAULT_SHORT_ENUMS | |
3348 | /* Initialize how much space enums occupy, by default. */ | |
3349 | flag_short_enums = DEFAULT_SHORT_ENUMS; | |
3350 | #endif | |
3351 | ||
3352 | /* Scan to see what optimization level has been specified. That will | |
3353 | determine the default value of many flags. */ | |
3354 | for (i = 1; i < argc; i++) | |
3355 | { | |
3356 | if (!strcmp (argv[i], "-O")) | |
3357 | { | |
3358 | optimize = 1; | |
3359 | } | |
3360 | else if (argv[i][0] == '-' && argv[i][1] == 'O') | |
3361 | { | |
3362 | /* Handle -O2, -O3, -O69, ... */ | |
3363 | char *p = &argv[i][2]; | |
3364 | int c; | |
3365 | ||
3366 | while (c = *p++) | |
3367 | if (! (c >= '0' && c <= '9')) | |
3368 | break; | |
3369 | if (c == 0) | |
3370 | optimize = atoi (&argv[i][2]); | |
3371 | } | |
3372 | } | |
3373 | ||
3374 | obey_regdecls = (optimize == 0); | |
f246a305 RS |
3375 | if (optimize == 0) |
3376 | { | |
3377 | flag_no_inline = 1; | |
3378 | warn_inline = 0; | |
3379 | } | |
4291d9c8 RS |
3380 | |
3381 | if (optimize >= 1) | |
3382 | { | |
6731a3e3 | 3383 | flag_defer_pop = 1; |
4291d9c8 RS |
3384 | flag_thread_jumps = 1; |
3385 | #ifdef DELAY_SLOTS | |
3386 | flag_delayed_branch = 1; | |
7e89c3a3 RK |
3387 | #endif |
3388 | #ifdef CAN_DEBUG_WITHOUT_FP | |
3389 | flag_omit_frame_pointer = 1; | |
4291d9c8 RS |
3390 | #endif |
3391 | } | |
3392 | ||
3393 | if (optimize >= 2) | |
3394 | { | |
3395 | flag_cse_follow_jumps = 1; | |
8b3686ed | 3396 | flag_cse_skip_blocks = 1; |
4291d9c8 RS |
3397 | flag_expensive_optimizations = 1; |
3398 | flag_strength_reduce = 1; | |
3399 | flag_rerun_cse_after_loop = 1; | |
ac266247 | 3400 | flag_caller_saves = 1; |
4ac8e06e | 3401 | flag_force_mem = 1; |
4291d9c8 RS |
3402 | #ifdef INSN_SCHEDULING |
3403 | flag_schedule_insns = 1; | |
3404 | flag_schedule_insns_after_reload = 1; | |
3405 | #endif | |
3406 | } | |
3407 | ||
7e89c3a3 RK |
3408 | if (optimize >= 3) |
3409 | { | |
3410 | flag_inline_functions = 1; | |
3411 | } | |
3412 | ||
c1da383f DE |
3413 | /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can |
3414 | modify it. */ | |
3415 | target_flags = 0; | |
3416 | set_target_switch (""); | |
3417 | ||
4291d9c8 RS |
3418 | #ifdef OPTIMIZATION_OPTIONS |
3419 | /* Allow default optimizations to be specified on a per-machine basis. */ | |
3420 | OPTIMIZATION_OPTIONS (optimize); | |
3421 | #endif | |
3422 | ||
3423 | /* Initialize register usage now so switches may override. */ | |
3424 | init_reg_sets (); | |
3425 | ||
4291d9c8 RS |
3426 | for (i = 1; i < argc; i++) |
3427 | { | |
b99933c7 RS |
3428 | int j; |
3429 | /* If this is a language-specific option, | |
3430 | decode it in a language-specific way. */ | |
3431 | for (j = 0; lang_options[j] != 0; j++) | |
7e6c0864 RK |
3432 | if (!strncmp (argv[i], lang_options[j], |
3433 | strlen (lang_options[j]))) | |
b99933c7 RS |
3434 | break; |
3435 | if (lang_options[j] != 0) | |
3436 | /* If the option is valid for *some* language, | |
3437 | treat it as valid even if this language doesn't understand it. */ | |
3438 | lang_decode_option (argv[i]); | |
3439 | else if (argv[i][0] == '-' && argv[i][1] != 0) | |
4291d9c8 RS |
3440 | { |
3441 | register char *str = argv[i] + 1; | |
3442 | if (str[0] == 'Y') | |
3443 | str++; | |
3444 | ||
3445 | if (str[0] == 'm') | |
3446 | set_target_switch (&str[1]); | |
3447 | else if (!strcmp (str, "dumpbase")) | |
3448 | { | |
3449 | dump_base_name = argv[++i]; | |
3450 | } | |
3451 | else if (str[0] == 'd') | |
3452 | { | |
3453 | register char *p = &str[1]; | |
3454 | while (*p) | |
3455 | switch (*p++) | |
3456 | { | |
3457 | case 'a': | |
3458 | combine_dump = 1; | |
3459 | dbr_sched_dump = 1; | |
3460 | flow_dump = 1; | |
3461 | global_reg_dump = 1; | |
3462 | jump_opt_dump = 1; | |
3463 | jump2_opt_dump = 1; | |
3464 | local_reg_dump = 1; | |
3465 | loop_dump = 1; | |
3466 | rtl_dump = 1; | |
3467 | cse_dump = 1, cse2_dump = 1; | |
3468 | sched_dump = 1; | |
3469 | sched2_dump = 1; | |
3470 | stack_reg_dump = 1; | |
3471 | break; | |
3472 | case 'k': | |
3473 | stack_reg_dump = 1; | |
3474 | break; | |
3475 | case 'c': | |
3476 | combine_dump = 1; | |
3477 | break; | |
3478 | case 'd': | |
3479 | dbr_sched_dump = 1; | |
3480 | break; | |
3481 | case 'f': | |
3482 | flow_dump = 1; | |
3483 | break; | |
3484 | case 'g': | |
3485 | global_reg_dump = 1; | |
3486 | break; | |
3487 | case 'j': | |
3488 | jump_opt_dump = 1; | |
3489 | break; | |
3490 | case 'J': | |
3491 | jump2_opt_dump = 1; | |
3492 | break; | |
3493 | case 'l': | |
3494 | local_reg_dump = 1; | |
3495 | break; | |
3496 | case 'L': | |
3497 | loop_dump = 1; | |
3498 | break; | |
3499 | case 'm': | |
3500 | flag_print_mem = 1; | |
3501 | break; | |
3502 | case 'p': | |
3503 | flag_print_asm_name = 1; | |
3504 | break; | |
3505 | case 'r': | |
3506 | rtl_dump = 1; | |
3507 | break; | |
3508 | case 's': | |
3509 | cse_dump = 1; | |
3510 | break; | |
3511 | case 't': | |
3512 | cse2_dump = 1; | |
3513 | break; | |
3514 | case 'S': | |
3515 | sched_dump = 1; | |
3516 | break; | |
3517 | case 'R': | |
3518 | sched2_dump = 1; | |
3519 | break; | |
3520 | case 'y': | |
3521 | set_yydebug (1); | |
3522 | break; | |
3523 | ||
3524 | case 'x': | |
3525 | rtl_dump_and_exit = 1; | |
3526 | break; | |
3527 | } | |
3528 | } | |
3529 | else if (str[0] == 'f') | |
3530 | { | |
4291d9c8 RS |
3531 | register char *p = &str[1]; |
3532 | int found = 0; | |
3533 | ||
3534 | /* Some kind of -f option. | |
3535 | P's value is the option sans `-f'. | |
3536 | Search for it in the table of options. */ | |
3537 | ||
3538 | for (j = 0; | |
3539 | !found && j < sizeof (f_options) / sizeof (f_options[0]); | |
3540 | j++) | |
3541 | { | |
3542 | if (!strcmp (p, f_options[j].string)) | |
3543 | { | |
3544 | *f_options[j].variable = f_options[j].on_value; | |
3545 | /* A goto here would be cleaner, | |
3546 | but breaks the vax pcc. */ | |
3547 | found = 1; | |
3548 | } | |
3549 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
3550 | && ! strcmp (p+3, f_options[j].string)) | |
3551 | { | |
3552 | *f_options[j].variable = ! f_options[j].on_value; | |
3553 | found = 1; | |
3554 | } | |
3555 | } | |
3556 | ||
3557 | if (found) | |
3558 | ; | |
3559 | else if (!strncmp (p, "fixed-", 6)) | |
3560 | fix_register (&p[6], 1, 1); | |
3561 | else if (!strncmp (p, "call-used-", 10)) | |
3562 | fix_register (&p[10], 0, 1); | |
3563 | else if (!strncmp (p, "call-saved-", 11)) | |
3564 | fix_register (&p[11], 0, 0); | |
b99933c7 | 3565 | else |
4291d9c8 RS |
3566 | error ("Invalid option `%s'", argv[i]); |
3567 | } | |
3568 | else if (str[0] == 'O') | |
3569 | { | |
3570 | register char *p = str+1; | |
3571 | while (*p && *p >= '0' && *p <= '9') | |
3572 | p++; | |
3573 | if (*p == '\0') | |
3574 | ; | |
3575 | else | |
3576 | error ("Invalid option `%s'", argv[i]); | |
3577 | } | |
3578 | else if (!strcmp (str, "pedantic")) | |
3579 | pedantic = 1; | |
3580 | else if (!strcmp (str, "pedantic-errors")) | |
3581 | flag_pedantic_errors = pedantic = 1; | |
4291d9c8 RS |
3582 | else if (!strcmp (str, "quiet")) |
3583 | quiet_flag = 1; | |
3584 | else if (!strcmp (str, "version")) | |
3585 | version_flag = 1; | |
3586 | else if (!strcmp (str, "w")) | |
3587 | inhibit_warnings = 1; | |
3588 | else if (!strcmp (str, "W")) | |
3589 | { | |
3590 | extra_warnings = 1; | |
fa1a4543 RS |
3591 | /* We save the value of warn_uninitialized, since if they put |
3592 | -Wuninitialized on the command line, we need to generate a | |
3593 | warning about not using it without also specifying -O. */ | |
3594 | if (warn_uninitialized != 1) | |
3595 | warn_uninitialized = 2; | |
4291d9c8 RS |
3596 | } |
3597 | else if (str[0] == 'W') | |
3598 | { | |
4291d9c8 RS |
3599 | register char *p = &str[1]; |
3600 | int found = 0; | |
3601 | ||
3602 | /* Some kind of -W option. | |
3603 | P's value is the option sans `-W'. | |
3604 | Search for it in the table of options. */ | |
3605 | ||
3606 | for (j = 0; | |
3607 | !found && j < sizeof (W_options) / sizeof (W_options[0]); | |
3608 | j++) | |
3609 | { | |
3610 | if (!strcmp (p, W_options[j].string)) | |
3611 | { | |
3612 | *W_options[j].variable = W_options[j].on_value; | |
3613 | /* A goto here would be cleaner, | |
3614 | but breaks the vax pcc. */ | |
3615 | found = 1; | |
3616 | } | |
3617 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
3618 | && ! strcmp (p+3, W_options[j].string)) | |
3619 | { | |
3620 | *W_options[j].variable = ! W_options[j].on_value; | |
3621 | found = 1; | |
3622 | } | |
3623 | } | |
3624 | ||
3625 | if (found) | |
3626 | ; | |
3627 | else if (!strncmp (p, "id-clash-", 9)) | |
3628 | { | |
3629 | char *endp = p + 9; | |
3630 | ||
3631 | while (*endp) | |
3632 | { | |
3633 | if (*endp >= '0' && *endp <= '9') | |
3634 | endp++; | |
3635 | else | |
7085b873 RS |
3636 | { |
3637 | error ("Invalid option `%s'", argv[i]); | |
3638 | goto id_clash_lose; | |
3639 | } | |
4291d9c8 RS |
3640 | } |
3641 | warn_id_clash = 1; | |
3642 | id_clash_len = atoi (str + 10); | |
7085b873 | 3643 | id_clash_lose: ; |
4291d9c8 | 3644 | } |
b51e9c62 RK |
3645 | else if (!strncmp (p, "larger-than-", 12)) |
3646 | { | |
3647 | char *endp = p + 12; | |
3648 | ||
3649 | while (*endp) | |
3650 | { | |
3651 | if (*endp >= '0' && *endp <= '9') | |
3652 | endp++; | |
3653 | else | |
3654 | { | |
3655 | error ("Invalid option `%s'", argv[i]); | |
3656 | goto larger_than_lose; | |
3657 | } | |
3658 | } | |
3659 | warn_larger_than = 1; | |
3660 | larger_than_size = atoi (str + 13); | |
3661 | larger_than_lose: ; | |
3662 | } | |
4291d9c8 RS |
3663 | else |
3664 | error ("Invalid option `%s'", argv[i]); | |
3665 | } | |
3666 | else if (!strcmp (str, "p")) | |
ca695ac9 JB |
3667 | { |
3668 | if (!output_bytecode) | |
3669 | profile_flag = 1; | |
3670 | else | |
3671 | error ("profiling not supported in bytecode compilation"); | |
3672 | } | |
4291d9c8 RS |
3673 | else if (!strcmp (str, "a")) |
3674 | { | |
3675 | #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
3676 | warning ("`-a' option (basic block profile) not supported"); | |
3677 | #else | |
ec6c615d RK |
3678 | profile_block_flag = (profile_block_flag < 2) ? 1 : 3; |
3679 | #endif | |
3680 | } | |
3681 | else if (!strcmp (str, "ax")) | |
3682 | { | |
3683 | #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
3684 | warning ("`-ax' option (jump profiling) not supported"); | |
3685 | #else | |
3686 | profile_block_flag = (!profile_block_flag | |
3687 | || profile_block_flag == 2) ? 2 : 3; | |
4291d9c8 RS |
3688 | #endif |
3689 | } | |
3690 | else if (str[0] == 'g') | |
3691 | { | |
3692 | char *p = str + 1; | |
3693 | char *q; | |
3694 | unsigned len; | |
3695 | unsigned level; | |
3696 | ||
3697 | while (*p && (*p < '0' || *p > '9')) | |
3698 | p++; | |
3699 | len = p - str; | |
3700 | q = p; | |
3701 | while (*q && (*q >= '0' && *q <= '9')) | |
3702 | q++; | |
3703 | if (*p) | |
3704 | level = atoi (p); | |
3705 | else | |
3706 | level = 2; /* default debugging info level */ | |
3707 | if (*q || level > 3) | |
3708 | { | |
3709 | warning ("invalid debug level specification in option: `-%s'", | |
3710 | str); | |
3711 | warning ("no debugging information will be generated"); | |
3712 | level = 0; | |
3713 | } | |
3714 | ||
3715 | /* If more than one debugging type is supported, | |
3716 | you must define PREFERRED_DEBUGGING_TYPE | |
3717 | to choose a format in a system-dependent way. */ | |
4d7e336b RS |
3718 | /* This is one long line cause VAXC can't handle a \-newline. */ |
3719 | #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO)) | |
4291d9c8 RS |
3720 | #ifdef PREFERRED_DEBUGGING_TYPE |
3721 | if (!strncmp (str, "ggdb", len)) | |
3722 | write_symbols = PREFERRED_DEBUGGING_TYPE; | |
3723 | #else /* no PREFERRED_DEBUGGING_TYPE */ | |
3724 | You Lose! You must define PREFERRED_DEBUGGING_TYPE! | |
3725 | #endif /* no PREFERRED_DEBUGGING_TYPE */ | |
3726 | #endif /* More than one debugger format enabled. */ | |
3727 | #ifdef DBX_DEBUGGING_INFO | |
3728 | if (write_symbols != NO_DEBUG) | |
3729 | ; | |
3730 | else if (!strncmp (str, "ggdb", len)) | |
3731 | write_symbols = DBX_DEBUG; | |
3732 | else if (!strncmp (str, "gstabs", len)) | |
3733 | write_symbols = DBX_DEBUG; | |
efa89fb3 RS |
3734 | else if (!strncmp (str, "gstabs+", len)) |
3735 | write_symbols = DBX_DEBUG; | |
4291d9c8 RS |
3736 | |
3737 | /* Always enable extensions for -ggdb or -gstabs+, | |
3738 | always disable for -gstabs. | |
3739 | For plain -g, use system-specific default. */ | |
3740 | if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len) | |
3741 | && len >= 2) | |
a53d0bcc | 3742 | use_gnu_debug_info_extensions = 1; |
166792f0 RS |
3743 | else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len) |
3744 | && len >= 7) | |
a53d0bcc | 3745 | use_gnu_debug_info_extensions = 1; |
4291d9c8 RS |
3746 | else if (write_symbols == DBX_DEBUG |
3747 | && !strncmp (str, "gstabs", len) && len >= 2) | |
a53d0bcc | 3748 | use_gnu_debug_info_extensions = 0; |
4291d9c8 | 3749 | else |
a53d0bcc | 3750 | use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; |
4291d9c8 RS |
3751 | #endif /* DBX_DEBUGGING_INFO */ |
3752 | #ifdef DWARF_DEBUGGING_INFO | |
3753 | if (write_symbols != NO_DEBUG) | |
3754 | ; | |
a53d0bcc RS |
3755 | else if (!strncmp (str, "g", len)) |
3756 | write_symbols = DWARF_DEBUG; | |
4291d9c8 RS |
3757 | else if (!strncmp (str, "ggdb", len)) |
3758 | write_symbols = DWARF_DEBUG; | |
4291d9c8 RS |
3759 | else if (!strncmp (str, "gdwarf", len)) |
3760 | write_symbols = DWARF_DEBUG; | |
a53d0bcc RS |
3761 | |
3762 | /* Always enable extensions for -ggdb or -gdwarf+, | |
3763 | always disable for -gdwarf. | |
3764 | For plain -g, use system-specific default. */ | |
3765 | if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len) | |
3766 | && len >= 2) | |
3767 | use_gnu_debug_info_extensions = 1; | |
3768 | else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+")) | |
3769 | use_gnu_debug_info_extensions = 1; | |
3770 | else if (write_symbols == DWARF_DEBUG | |
3771 | && !strncmp (str, "gdwarf", len) && len >= 2) | |
3772 | use_gnu_debug_info_extensions = 0; | |
3773 | else | |
3774 | use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; | |
4291d9c8 RS |
3775 | #endif |
3776 | #ifdef SDB_DEBUGGING_INFO | |
3777 | if (write_symbols != NO_DEBUG) | |
3778 | ; | |
a53d0bcc RS |
3779 | else if (!strncmp (str, "g", len)) |
3780 | write_symbols = SDB_DEBUG; | |
3781 | else if (!strncmp (str, "gdb", len)) | |
4291d9c8 RS |
3782 | write_symbols = SDB_DEBUG; |
3783 | else if (!strncmp (str, "gcoff", len)) | |
3784 | write_symbols = SDB_DEBUG; | |
3785 | #endif /* SDB_DEBUGGING_INFO */ | |
f246a305 RS |
3786 | #ifdef XCOFF_DEBUGGING_INFO |
3787 | if (write_symbols != NO_DEBUG) | |
3788 | ; | |
a53d0bcc RS |
3789 | else if (!strncmp (str, "g", len)) |
3790 | write_symbols = XCOFF_DEBUG; | |
f246a305 RS |
3791 | else if (!strncmp (str, "ggdb", len)) |
3792 | write_symbols = XCOFF_DEBUG; | |
3793 | else if (!strncmp (str, "gxcoff", len)) | |
3794 | write_symbols = XCOFF_DEBUG; | |
3795 | ||
a53d0bcc | 3796 | /* Always enable extensions for -ggdb or -gxcoff+, |
f246a305 RS |
3797 | always disable for -gxcoff. |
3798 | For plain -g, use system-specific default. */ | |
3799 | if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len) | |
3800 | && len >= 2) | |
a53d0bcc RS |
3801 | use_gnu_debug_info_extensions = 1; |
3802 | else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+")) | |
3803 | use_gnu_debug_info_extensions = 1; | |
a56addeb | 3804 | else if (write_symbols == XCOFF_DEBUG |
f246a305 | 3805 | && !strncmp (str, "gxcoff", len) && len >= 2) |
a53d0bcc | 3806 | use_gnu_debug_info_extensions = 0; |
f246a305 | 3807 | else |
a53d0bcc | 3808 | use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; |
f246a305 | 3809 | #endif |
4291d9c8 | 3810 | if (write_symbols == NO_DEBUG) |
7276e85d RK |
3811 | warning ("`-%s' not supported by this configuration of GCC", |
3812 | str); | |
4291d9c8 RS |
3813 | else if (level == 0) |
3814 | write_symbols = NO_DEBUG; | |
3815 | else | |
d68c507d | 3816 | debug_info_level = (enum debug_info_level) level; |
4291d9c8 RS |
3817 | } |
3818 | else if (!strcmp (str, "o")) | |
3819 | { | |
3820 | asm_file_name = argv[++i]; | |
3821 | } | |
3822 | else if (str[0] == 'G') | |
3823 | { | |
3824 | g_switch_set = TRUE; | |
3825 | g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]); | |
3826 | } | |
f246a305 RS |
3827 | else if (!strncmp (str, "aux-info", 8)) |
3828 | { | |
3829 | flag_gen_aux_info = 1; | |
3830 | aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); | |
3831 | } | |
4291d9c8 RS |
3832 | else |
3833 | error ("Invalid option `%s'", argv[i]); | |
3834 | } | |
3835 | else if (argv[i][0] == '+') | |
b99933c7 | 3836 | error ("Invalid option `%s'", argv[i]); |
4291d9c8 RS |
3837 | else |
3838 | filename = argv[i]; | |
3839 | } | |
3840 | ||
ca695ac9 JB |
3841 | /* Initialize for bytecode output. A good idea to do this as soon as |
3842 | possible after the "-f" options have been parsed. */ | |
3843 | if (output_bytecode) | |
3844 | { | |
3845 | #ifndef TARGET_SUPPORTS_BYTECODE | |
3846 | /* Just die with a fatal error if not supported */ | |
0207ea82 | 3847 | fatal ("-fbytecode not supporter for this target"); |
ca695ac9 JB |
3848 | #else |
3849 | bc_initialize (); | |
3850 | #endif | |
3851 | } | |
3852 | ||
f246a305 RS |
3853 | if (optimize == 0) |
3854 | { | |
a2468e45 BK |
3855 | /* Inlining does not work if not optimizing, |
3856 | so force it not to be done. */ | |
f246a305 RS |
3857 | flag_no_inline = 1; |
3858 | warn_inline = 0; | |
a2468e45 BK |
3859 | |
3860 | /* The c_decode_option and lang_decode_option functions set | |
3861 | this to `2' if -Wall is used, so we can avoid giving out | |
3862 | lots of errors for people who don't realize what -Wall does. */ | |
3863 | if (warn_uninitialized == 1) | |
3864 | warning ("-Wuninitialized is not supported without -O"); | |
f246a305 RS |
3865 | } |
3866 | ||
7877bbb3 RS |
3867 | #if defined(DWARF_DEBUGGING_INFO) |
3868 | if (write_symbols == DWARF_DEBUG | |
3869 | && strcmp (language_string, "GNU C++") == 0) | |
3870 | { | |
635b513f | 3871 | warning ("-g option not supported for C++ on systems using the DWARF debugging format"); |
7877bbb3 RS |
3872 | write_symbols = NO_DEBUG; |
3873 | } | |
3874 | #endif /* defined(DWARF_DEBUGGING_INFO) */ | |
3875 | ||
4291d9c8 RS |
3876 | #ifdef OVERRIDE_OPTIONS |
3877 | /* Some machines may reject certain combinations of options. */ | |
3878 | OVERRIDE_OPTIONS; | |
3879 | #endif | |
3880 | ||
ec6c615d RK |
3881 | if (profile_block_flag == 3) |
3882 | { | |
3883 | warning ("`-ax' and `-a' are conflicting options. `-a' ignored."); | |
3884 | profile_block_flag = 2; | |
3885 | } | |
3886 | ||
4291d9c8 RS |
3887 | /* Unrolling all loops implies that standard loop unrolling must also |
3888 | be done. */ | |
3889 | if (flag_unroll_all_loops) | |
3890 | flag_unroll_loops = 1; | |
3891 | /* Loop unrolling requires that strength_reduction be on also. Silently | |
3892 | turn on strength reduction here if it isn't already on. Also, the loop | |
3893 | unrolling code assumes that cse will be run after loop, so that must | |
3894 | be turned on also. */ | |
3895 | if (flag_unroll_loops) | |
3896 | { | |
3897 | flag_strength_reduce = 1; | |
3898 | flag_rerun_cse_after_loop = 1; | |
3899 | } | |
3900 | ||
3901 | /* Warn about options that are not supported on this machine. */ | |
3902 | #ifndef INSN_SCHEDULING | |
3903 | if (flag_schedule_insns || flag_schedule_insns_after_reload) | |
3904 | warning ("instruction scheduling not supported on this target machine"); | |
3905 | #endif | |
3906 | #ifndef DELAY_SLOTS | |
3907 | if (flag_delayed_branch) | |
3908 | warning ("this target machine does not have delayed branches"); | |
3909 | #endif | |
3910 | ||
3911 | /* If we are in verbose mode, write out the version and maybe all the | |
3912 | option flags in use. */ | |
3913 | if (version_flag) | |
3914 | { | |
3915 | fprintf (stderr, "%s version %s", language_string, version_string); | |
3916 | #ifdef TARGET_VERSION | |
3917 | TARGET_VERSION; | |
3918 | #endif | |
3919 | #ifdef __GNUC__ | |
3920 | #ifndef __VERSION__ | |
3921 | #define __VERSION__ "[unknown]" | |
3922 | #endif | |
3923 | fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__); | |
3924 | #else | |
3925 | fprintf (stderr, " compiled by CC.\n"); | |
3926 | #endif | |
3927 | if (! quiet_flag) | |
3928 | print_switch_values (); | |
3929 | } | |
3930 | ||
4291d9c8 RS |
3931 | compile_file (filename); |
3932 | ||
9580b583 | 3933 | #if !defined(OS2) && !defined(VMS) && !defined(_WIN32) |
4291d9c8 RS |
3934 | if (flag_print_mem) |
3935 | { | |
3936 | char *lim = (char *) sbrk (0); | |
3937 | ||
3938 | fprintf (stderr, "Data size %d.\n", | |
b61b1c91 | 3939 | lim - (char *) &environ); |
4291d9c8 RS |
3940 | fflush (stderr); |
3941 | ||
3942 | #ifdef USG | |
3943 | system ("ps -l 1>&2"); | |
3944 | #else /* not USG */ | |
3945 | system ("ps v"); | |
3946 | #endif /* not USG */ | |
3947 | } | |
9580b583 | 3948 | #endif /* not OS2 and not VMS and not _WIN32 */ |
4291d9c8 RS |
3949 | |
3950 | if (errorcount) | |
3951 | exit (FATAL_EXIT_CODE); | |
3952 | if (sorrycount) | |
3953 | exit (FATAL_EXIT_CODE); | |
3954 | exit (SUCCESS_EXIT_CODE); | |
299846f2 | 3955 | return 0; |
4291d9c8 RS |
3956 | } |
3957 | \f | |
3958 | /* Decode -m switches. */ | |
3959 | ||
3960 | /* Here is a table, controlled by the tm.h file, listing each -m switch | |
3961 | and which bits in `target_switches' it should set or clear. | |
3962 | If VALUE is positive, it is bits to set. | |
3963 | If VALUE is negative, -VALUE is bits to clear. | |
3964 | (The sign bit is not used so there is no confusion.) */ | |
3965 | ||
3966 | struct {char *name; int value;} target_switches [] | |
3967 | = TARGET_SWITCHES; | |
3968 | ||
3969 | /* This table is similar, but allows the switch to have a value. */ | |
3970 | ||
3971 | #ifdef TARGET_OPTIONS | |
3972 | struct {char *prefix; char ** variable;} target_options [] | |
3973 | = TARGET_OPTIONS; | |
3974 | #endif | |
3975 | ||
3976 | /* Decode the switch -mNAME. */ | |
3977 | ||
3978 | void | |
3979 | set_target_switch (name) | |
3980 | char *name; | |
3981 | { | |
3982 | register int j; | |
3983 | int valid = 0; | |
3984 | ||
3985 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
3986 | if (!strcmp (target_switches[j].name, name)) | |
3987 | { | |
3988 | if (target_switches[j].value < 0) | |
3989 | target_flags &= ~-target_switches[j].value; | |
3990 | else | |
3991 | target_flags |= target_switches[j].value; | |
3992 | valid = 1; | |
3993 | } | |
3994 | ||
3995 | #ifdef TARGET_OPTIONS | |
3996 | if (!valid) | |
3997 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
3998 | { | |
3999 | int len = strlen (target_options[j].prefix); | |
4000 | if (!strncmp (target_options[j].prefix, name, len)) | |
4001 | { | |
4002 | *target_options[j].variable = name + len; | |
4003 | valid = 1; | |
4004 | } | |
4005 | } | |
4006 | #endif | |
4007 | ||
4008 | if (!valid) | |
4009 | error ("Invalid option `%s'", name); | |
4010 | } | |
4011 | \f | |
4012 | /* Variable used for communication between the following two routines. */ | |
4013 | ||
4014 | static int line_position; | |
4015 | ||
4016 | /* Print an option value and adjust the position in the line. */ | |
4017 | ||
4018 | static void | |
4019 | print_single_switch (type, name) | |
4020 | char *type, *name; | |
4021 | { | |
4022 | fprintf (stderr, " %s%s", type, name); | |
4023 | ||
4024 | line_position += strlen (type) + strlen (name) + 1; | |
4025 | ||
4026 | if (line_position > 65) | |
4027 | { | |
4028 | fprintf (stderr, "\n\t"); | |
4029 | line_position = 8; | |
4030 | } | |
4031 | } | |
4032 | ||
4033 | /* Print default target switches for -version. */ | |
4034 | ||
4035 | static void | |
4036 | print_switch_values () | |
4037 | { | |
4038 | register int j; | |
4039 | ||
4040 | fprintf (stderr, "enabled:"); | |
4041 | line_position = 8; | |
4042 | ||
4043 | for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) | |
4044 | if (*f_options[j].variable == f_options[j].on_value) | |
4045 | print_single_switch ("-f", f_options[j].string); | |
4046 | ||
4047 | for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++) | |
4048 | if (*W_options[j].variable == W_options[j].on_value) | |
4049 | print_single_switch ("-W", W_options[j].string); | |
4050 | ||
4051 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
4052 | if (target_switches[j].name[0] != '\0' | |
4053 | && target_switches[j].value > 0 | |
4054 | && ((target_switches[j].value & target_flags) | |
4055 | == target_switches[j].value)) | |
4056 | print_single_switch ("-m", target_switches[j].name); | |
4057 | ||
4058 | fprintf (stderr, "\n"); | |
4059 | } |