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