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