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