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