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