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