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