]> gcc.gnu.org Git - gcc.git/blob - gcc/toplev.c
*** empty log message ***
[gcc.git] / gcc / toplev.c
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
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"
27 #include <sys/types.h>
28 #include <stdio.h>
29 #include <signal.h>
30 #include <setjmp.h>
31
32 #include <sys/stat.h>
33
34 #ifdef USG
35 #undef FLOAT
36 #include <sys/param.h>
37 /* This is for hpux. It is a real screw. They should change hpux. */
38 #undef FLOAT
39 #include <sys/times.h>
40 #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
41 #undef FFS /* Some systems define this in param.h. */
42 #else
43 #ifndef VMS
44 #include <sys/time.h>
45 #include <sys/resource.h>
46 #endif
47 #endif
48
49 #include "input.h"
50 #include "tree.h"
51 /* #include "c-tree.h" */
52 #include "rtl.h"
53 #include "flags.h"
54 #include "insn-attr.h"
55
56 #ifdef XCOFF_DEBUGGING_INFO
57 #include "xcoffout.h"
58 #endif
59 \f
60 #ifdef VMS
61 /* The extra parameters substantially improve the I/O performance. */
62 static FILE *
63 VMS_fopen (fname, type)
64 char * fname;
65 char * type;
66 {
67 if (strcmp (type, "w") == 0)
68 return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil");
69 return fopen (fname, type, "mbc=16");
70 }
71 #define fopen VMS_fopen
72 #endif
73
74 #ifndef DEFAULT_GDB_EXTENSIONS
75 #define DEFAULT_GDB_EXTENSIONS 1
76 #endif
77
78 extern int rtx_equal_function_value_matters;
79
80 extern char **environ;
81 extern char *version_string, *language_string;
82
83 extern void init_lex ();
84 extern void init_decl_processing ();
85 extern void init_obstacks ();
86 extern void init_tree_codes ();
87 extern void init_rtl ();
88 extern void init_optabs ();
89 extern void init_stmt ();
90 extern void init_reg_sets ();
91 extern void dump_flow_info ();
92 extern void dump_sched_info ();
93 extern void dump_local_alloc ();
94
95 void rest_of_decl_compilation ();
96 void error ();
97 void error_with_file_and_line ();
98 void fancy_abort ();
99 #ifndef abort
100 void abort ();
101 #endif
102 void set_target_switch ();
103 static void print_switch_values ();
104 static char *decl_name ();
105
106 /* Name of program invoked, sans directories. */
107
108 char *progname;
109
110 /* Copy of arguments to main. */
111 int save_argc;
112 char **save_argv;
113 \f
114 /* Name of current original source file (what was input to cpp).
115 This comes from each #-command in the actual input. */
116
117 char *input_filename;
118
119 /* Name of top-level original source file (what was input to cpp).
120 This comes from the #-command at the beginning of the actual input.
121 If there isn't any there, then this is the cc1 input file name. */
122
123 char *main_input_filename;
124
125 /* Stream for reading from the input file. */
126
127 FILE *finput;
128
129 /* Current line number in real source file. */
130
131 int lineno;
132
133 /* Stack of currently pending input files. */
134
135 struct file_stack *input_file_stack;
136
137 /* Incremented on each change to input_file_stack. */
138 int input_file_stack_tick;
139
140 /* FUNCTION_DECL for function now being parsed or compiled. */
141
142 extern tree current_function_decl;
143
144 /* Name to use as base of names for dump output files. */
145
146 char *dump_base_name;
147
148 /* Bit flags that specify the machine subtype we are compiling for.
149 Bits are tested using macros TARGET_... defined in the tm.h file
150 and set by `-m...' switches. Must be defined in rtlanal.c. */
151
152 extern int target_flags;
153
154 /* Flags saying which kinds of debugging dump have been requested. */
155
156 int rtl_dump = 0;
157 int rtl_dump_and_exit = 0;
158 int jump_opt_dump = 0;
159 int cse_dump = 0;
160 int loop_dump = 0;
161 int cse2_dump = 0;
162 int flow_dump = 0;
163 int combine_dump = 0;
164 int sched_dump = 0;
165 int local_reg_dump = 0;
166 int global_reg_dump = 0;
167 int sched2_dump = 0;
168 int jump2_opt_dump = 0;
169 int dbr_sched_dump = 0;
170 int flag_print_asm_name = 0;
171 int stack_reg_dump = 0;
172
173 /* Name for output file of assembly code, specified with -o. */
174
175 char *asm_file_name;
176
177 /* Value of the -G xx switch, and whether it was passed or not. */
178 int g_switch_value;
179 int g_switch_set;
180
181 /* Type(s) of debugging information we are producing (if any).
182 See flags.h for the definitions of the different possible
183 types of debugging information. */
184 enum debug_info_type write_symbols = NO_DEBUG;
185
186 /* Level of debugging information we are producing. See flags.h
187 for the definitions of the different possible levels. */
188 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
189
190 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
191 /* Nonzero means can use our own extensions to DBX format.
192 Relevant only when write_symbols == DBX_DEBUG or XCOFF_DEBUG. */
193 int use_gdb_dbx_extensions = 0;
194 #endif
195
196 /* Nonzero means do optimizations. -O.
197 Particular numeric values stand for particular amounts of optimization;
198 thus, -O2 stores 2 here. However, the optimizations beyond the basic
199 ones are not controlled directly by this variable. Instead, they are
200 controlled by individual `flag_...' variables that are defaulted
201 based on this variable. */
202
203 int optimize = 0;
204
205 /* Number of error messages and warning messages so far. */
206
207 int errorcount = 0;
208 int warningcount = 0;
209 int sorrycount = 0;
210
211 /* Pointer to function to compute the name to use to print a declaration. */
212
213 char *(*decl_printable_name) ();
214
215 /* Pointer to function to compute rtl for a language-specific tree code. */
216
217 struct rtx_def *(*lang_expand_expr) ();
218
219 /* Nonzero if generating code to do profiling. */
220
221 int profile_flag = 0;
222
223 /* Nonzero if generating code to do profiling on a line-by-line basis. */
224
225 int profile_block_flag;
226
227 /* Nonzero for -pedantic switch: warn about anything
228 that standard spec forbids. */
229
230 int pedantic = 0;
231
232 /* Temporarily suppress certain warnings.
233 This is set while reading code from a system header file. */
234
235 int in_system_header = 0;
236
237 /* Nonzero means do stupid register allocation.
238 Currently, this is 1 if `optimize' is 0. */
239
240 int obey_regdecls = 0;
241
242 /* Don't print functions as they are compiled and don't print
243 times taken by the various passes. -quiet. */
244
245 int quiet_flag = 0;
246 \f
247 /* -f flags. */
248
249 /* Nonzero means `char' should be signed. */
250
251 int flag_signed_char;
252
253 /* Nonzero means give an enum type only as many bytes as it needs. */
254
255 int flag_short_enums;
256
257 /* Nonzero for -fcaller-saves: allocate values in regs that need to
258 be saved across function calls, if that produces overall better code.
259 Optional now, so people can test it. */
260
261 #ifdef DEFAULT_CALLER_SAVES
262 int flag_caller_saves = 1;
263 #else
264 int flag_caller_saves = 0;
265 #endif
266
267 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
268
269 int flag_pcc_struct_return = 0;
270
271 /* Nonzero for -fforce-mem: load memory value into a register
272 before arithmetic on it. This makes better cse but slower compilation. */
273
274 int flag_force_mem = 0;
275
276 /* Nonzero for -fforce-addr: load memory address into a register before
277 reference to memory. This makes better cse but slower compilation. */
278
279 int flag_force_addr = 0;
280
281 /* Nonzero for -fdefer-pop: don't pop args after each function call;
282 instead save them up to pop many calls' args with one insns. */
283
284 int flag_defer_pop = 1;
285
286 /* Nonzero for -ffloat-store: don't allocate floats and doubles
287 in extended-precision registers. */
288
289 int flag_float_store = 0;
290
291 /* Nonzero for -fcse-follow-jumps:
292 have cse follow jumps to do a more extensive job. */
293
294 int flag_cse_follow_jumps;
295
296 /* Nonzero for -fexpensive-optimizations:
297 perform miscellaneous relatively-expensive optimizations. */
298 int flag_expensive_optimizations;
299
300 /* Nonzero for -fthread-jumps:
301 have jump optimize output of loop. */
302
303 int flag_thread_jumps;
304
305 /* Nonzero enables strength-reduction in loop.c. */
306
307 int flag_strength_reduce = 0;
308
309 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
310 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
311 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
312 unrolled. */
313
314 int flag_unroll_loops;
315
316 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
317 This is generally not a win. */
318
319 int flag_unroll_all_loops;
320
321 /* Nonzero for -fwritable-strings:
322 store string constants in data segment and don't uniquize them. */
323
324 int flag_writable_strings = 0;
325
326 /* Nonzero means don't put addresses of constant functions in registers.
327 Used for compiling the Unix kernel, where strange substitutions are
328 done on the assembly output. */
329
330 int flag_no_function_cse = 0;
331
332 /* Nonzero for -fomit-frame-pointer:
333 don't make a frame pointer in simple functions that don't require one. */
334
335 int flag_omit_frame_pointer = 0;
336
337 /* Nonzero to inhibit use of define_optimization peephole opts. */
338
339 int flag_no_peephole = 0;
340
341 /* Nonzero means all references through pointers are volatile. */
342
343 int flag_volatile;
344
345 /* Nonzero means just do syntax checking; don't output anything. */
346
347 int flag_syntax_only = 0;
348
349 /* Nonzero means to rerun cse after loop optimization. This increases
350 compilation time about 20% and picks up a few more common expressions. */
351
352 static int flag_rerun_cse_after_loop;
353
354 /* Nonzero for -finline-functions: ok to inline functions that look like
355 good inline candidates. */
356
357 int flag_inline_functions;
358
359 /* Nonzero for -fkeep-inline-functions: even if we make a function
360 go inline everywhere, keep its defintion around for debugging
361 purposes. */
362
363 int flag_keep_inline_functions;
364
365 /* Nonzero means that functions declared `inline' will be treated
366 as `static'. Prevents generation of zillions of copies of unused
367 static inline functions; instead, `inlines' are written out
368 only when actually used. Used in conjunction with -g. Also
369 does the right thing with #pragma interface. */
370
371 int flag_no_inline;
372
373 /* Nonzero means we should be saving declaration info into a .X file. */
374
375 int flag_gen_aux_info = 0;
376
377 /* Specified name of aux-info file. */
378
379 static char *aux_info_file_name;
380
381 /* Nonzero means make the text shared if supported. */
382
383 int flag_shared_data;
384
385 /* Nonzero means schedule into delayed branch slots if supported. */
386
387 int flag_delayed_branch;
388
389 /* Nonzero if we are compiling pure (sharable) code.
390 Value is 1 if we are doing reasonable (i.e. simple
391 offset into offset table) pic. Value is 2 if we can
392 only perform register offsets. */
393
394 int flag_pic;
395
396 /* Nonzero means place uninitialized global data in the bss section. */
397
398 int flag_no_common;
399
400 /* Nonzero means pretend it is OK to examine bits of target floats,
401 even if that isn't true. The resulting code will have incorrect constants,
402 but the same series of instructions that the native compiler would make. */
403
404 int flag_pretend_float;
405
406 /* Nonzero means change certain warnings into errors.
407 Usually these are warnings about failure to conform to some standard. */
408
409 int flag_pedantic_errors = 0;
410
411 /* flag_schedule_insns means schedule insns within basic blocks (before
412 local_alloc).
413 flag_schedule_insns_after_reload means schedule insns after
414 global_alloc. */
415
416 int flag_schedule_insns = 0;
417 int flag_schedule_insns_after_reload = 0;
418
419 /* -finhibit-size-directive inhibits output of .size for ELF.
420 This is used only for compiling crtstuff.c,
421 and it may be extended to other effects
422 needed for crtstuff.c on other systems. */
423 int flag_inhibit_size_directive = 0;
424
425 /* -fgnu-linker specifies use of the GNU linker for initializations.
426 -fno-gnu-linker says that collect will be used. */
427 int flag_gnu_linker = 1;
428
429 /* Table of language-independent -f options.
430 STRING is the option name. VARIABLE is the address of the variable.
431 ON_VALUE is the value to store in VARIABLE
432 if `-fSTRING' is seen as an option.
433 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
434
435 struct { char *string; int *variable; int on_value;} f_options[] =
436 {
437 {"float-store", &flag_float_store, 1},
438 {"volatile", &flag_volatile, 1},
439 {"defer-pop", &flag_defer_pop, 1},
440 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
441 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
442 {"expensive-optimizations", &flag_expensive_optimizations, 1},
443 {"thread-jumps", &flag_thread_jumps, 1},
444 {"strength-reduce", &flag_strength_reduce, 1},
445 {"unroll-loops", &flag_unroll_loops, 1},
446 {"unroll-all-loops", &flag_unroll_all_loops, 1},
447 {"writable-strings", &flag_writable_strings, 1},
448 {"peephole", &flag_no_peephole, 0},
449 {"force-mem", &flag_force_mem, 1},
450 {"force-addr", &flag_force_addr, 1},
451 {"function-cse", &flag_no_function_cse, 0},
452 {"inline-functions", &flag_inline_functions, 1},
453 {"keep-inline-functions", &flag_keep_inline_functions, 1},
454 {"inline", &flag_no_inline, 0},
455 {"syntax-only", &flag_syntax_only, 1},
456 {"shared-data", &flag_shared_data, 1},
457 {"caller-saves", &flag_caller_saves, 1},
458 {"pcc-struct-return", &flag_pcc_struct_return, 1},
459 {"delayed-branch", &flag_delayed_branch, 1},
460 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
461 {"pretend-float", &flag_pretend_float, 1},
462 {"schedule-insns", &flag_schedule_insns, 1},
463 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
464 {"pic", &flag_pic, 1},
465 {"PIC", &flag_pic, 2},
466 {"common", &flag_no_common, 0},
467 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
468 {"gnu-linker", &flag_gnu_linker, 1}
469 };
470 \f
471 /* Options controlling warnings */
472
473 /* Don't print warning messages. -w. */
474
475 int inhibit_warnings = 0;
476
477 /* Print various extra warnings. -W. */
478
479 int extra_warnings = 0;
480
481 /* Treat warnings as errors. -Werror. */
482
483 int warnings_are_errors = 0;
484
485 /* Nonzero to warn about unused local variables. */
486
487 int warn_unused;
488
489 /* Nonzero to warn about variables used before they are initialized. */
490
491 int warn_uninitialized;
492
493 /* Nonzero means warn about all declarations which shadow others. */
494
495 int warn_shadow;
496
497 /* Warn if a switch on an enum fails to have a case for every enum value. */
498
499 int warn_switch;
500
501 /* Nonzero means warn about function definitions that default the return type
502 or that use a null return and have a return-type other than void. */
503
504 int warn_return_type;
505
506 /* Nonzero means warn about pointer casts that increase the required
507 alignment of the target type (and might therefore lead to a crash
508 due to a misaligned access). */
509
510 int warn_cast_align;
511
512 /* Nonzero means warn about any identifiers that match in the first N
513 characters. The value N is in `id_clash_len'. */
514
515 int warn_id_clash;
516 int id_clash_len;
517
518 /* Nonzero means warn if inline function is too large. */
519
520 int warn_inline;
521
522 /* Warn if a function returns an aggregate,
523 since there are often incompatible calling conventions for doing this. */
524
525 int warn_aggregate_return;
526
527 /* Likewise for -W. */
528
529 struct { char *string; int *variable; int on_value;} W_options[] =
530 {
531 {"unused", &warn_unused, 1},
532 {"error", &warnings_are_errors, 1},
533 {"shadow", &warn_shadow, 1},
534 {"switch", &warn_switch, 1},
535 {"return-type", &warn_return_type, 1},
536 {"aggregate-return", &warn_aggregate_return, 1},
537 {"cast-align", &warn_cast_align, 1},
538 {"uninitialized", &warn_uninitialized, 1},
539 {"inline", &warn_inline, 1}
540 };
541 \f
542 /* Output files for assembler code (real compiler output)
543 and debugging dumps. */
544
545 FILE *asm_out_file;
546 FILE *aux_info_file;
547 FILE *rtl_dump_file;
548 FILE *jump_opt_dump_file;
549 FILE *cse_dump_file;
550 FILE *loop_dump_file;
551 FILE *cse2_dump_file;
552 FILE *flow_dump_file;
553 FILE *combine_dump_file;
554 FILE *sched_dump_file;
555 FILE *local_reg_dump_file;
556 FILE *global_reg_dump_file;
557 FILE *sched2_dump_file;
558 FILE *jump2_opt_dump_file;
559 FILE *dbr_sched_dump_file;
560 FILE *stack_reg_dump_file;
561
562 /* Time accumulators, to count the total time spent in various passes. */
563
564 int parse_time;
565 int varconst_time;
566 int integration_time;
567 int jump_time;
568 int cse_time;
569 int loop_time;
570 int cse2_time;
571 int flow_time;
572 int combine_time;
573 int sched_time;
574 int local_alloc_time;
575 int global_alloc_time;
576 int sched2_time;
577 int dbr_sched_time;
578 int shorten_branch_time;
579 int stack_reg_time;
580 int final_time;
581 int symout_time;
582 int dump_time;
583 \f
584 /* Return time used so far, in microseconds. */
585
586 int
587 get_run_time ()
588 {
589 #ifdef USG
590 struct tms tms;
591 #else
592 #ifndef VMS
593 struct rusage rusage;
594 #else /* VMS */
595 struct
596 {
597 int proc_user_time;
598 int proc_system_time;
599 int child_user_time;
600 int child_system_time;
601 } vms_times;
602 #endif
603 #endif
604
605 if (quiet_flag)
606 return 0;
607
608 #ifdef USG
609 times (&tms);
610 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
611 #else
612 #ifndef VMS
613 getrusage (0, &rusage);
614 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
615 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
616 #else /* VMS */
617 times (&vms_times);
618 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
619 #endif
620 #endif
621 }
622
623 #define TIMEVAR(VAR, BODY) \
624 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
625
626 void
627 print_time (str, total)
628 char *str;
629 int total;
630 {
631 fprintf (stderr,
632 "time in %s: %d.%06d\n",
633 str, total / 1000000, total % 1000000);
634 }
635
636 /* Count an error or warning. Return 1 if the message should be printed. */
637
638 int
639 count_error (warningp)
640 int warningp;
641 {
642 if (warningp && inhibit_warnings)
643 return 0;
644
645 if (warningp && !warnings_are_errors)
646 warningcount++;
647 else
648 {
649 static int warning_message = 0;
650
651 if (warningp && !warning_message)
652 {
653 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
654 warning_message = 1;
655 }
656 errorcount++;
657 }
658
659 return 1;
660 }
661
662 /* Print a fatal error message. NAME is the text.
663 Also include a system error message based on `errno'. */
664
665 void
666 pfatal_with_name (name)
667 char *name;
668 {
669 fprintf (stderr, "%s: ", progname);
670 perror (name);
671 exit (35);
672 }
673
674 void
675 fatal_io_error (name)
676 char *name;
677 {
678 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
679 exit (35);
680 }
681
682 void
683 fatal (s, v)
684 char *s;
685 int v;
686 {
687 error (s, v);
688 exit (34);
689 }
690
691 /* Called to give a better error message when we don't have an insn to match
692 what we are looking for or if the insn's constraints aren't satisfied,
693 rather than just calling abort(). */
694
695 void
696 fatal_insn_not_found (insn)
697 rtx insn;
698 {
699 if (INSN_CODE (insn) < 0)
700 error ("internal error--unrecognizable insn:", 0);
701 else
702 error ("internal error--insn does not satisfy its constraints:", 0);
703 debug_rtx (insn);
704 if (asm_out_file)
705 fflush (asm_out_file);
706 if (aux_info_file)
707 fflush (aux_info_file);
708 if (rtl_dump_file)
709 fflush (rtl_dump_file);
710 if (jump_opt_dump_file)
711 fflush (jump_opt_dump_file);
712 if (cse_dump_file)
713 fflush (cse_dump_file);
714 if (loop_dump_file)
715 fflush (loop_dump_file);
716 if (cse2_dump_file)
717 fflush (cse2_dump_file);
718 if (flow_dump_file)
719 fflush (flow_dump_file);
720 if (combine_dump_file)
721 fflush (combine_dump_file);
722 if (sched_dump_file)
723 fflush (sched_dump_file);
724 if (local_reg_dump_file)
725 fflush (local_reg_dump_file);
726 if (global_reg_dump_file)
727 fflush (global_reg_dump_file);
728 if (sched2_dump_file)
729 fflush (sched2_dump_file);
730 if (jump2_opt_dump_file)
731 fflush (jump2_opt_dump_file);
732 if (dbr_sched_dump_file)
733 fflush (dbr_sched_dump_file);
734 if (stack_reg_dump_file)
735 fflush (stack_reg_dump_file);
736 abort ();
737 }
738
739 /* This is the default decl_printable_name function. */
740
741 static char *
742 decl_name (decl, kind)
743 tree decl;
744 char **kind;
745 {
746 return IDENTIFIER_POINTER (DECL_NAME (decl));
747 }
748 \f
749 static int need_error_newline;
750
751 /* Function of last error message;
752 more generally, function such that if next error message is in it
753 then we don't have to mention the function name. */
754 static tree last_error_function = NULL;
755
756 /* Used to detect when input_file_stack has changed since last described. */
757 static int last_error_tick;
758
759 /* Called when the start of a function definition is parsed,
760 this function prints on stderr the name of the function. */
761
762 void
763 announce_function (decl)
764 tree decl;
765 {
766 if (! quiet_flag)
767 {
768 char *junk;
769 if (rtl_dump_and_exit)
770 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
771 else
772 fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
773 fflush (stderr);
774 need_error_newline = 1;
775 last_error_function = current_function_decl;
776 }
777 }
778
779 /* Prints out, if necessary, the name of the current function
780 which caused an error. Called from all error and warning functions. */
781
782 void
783 report_error_function (file)
784 char *file;
785 {
786 struct file_stack *p;
787
788 if (need_error_newline)
789 {
790 fprintf (stderr, "\n");
791 need_error_newline = 0;
792 }
793
794 if (last_error_function != current_function_decl)
795 {
796 char *kind = "function";
797 if (current_function_decl != 0
798 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
799 kind = "method";
800
801 if (file)
802 fprintf (stderr, "%s: ", file);
803
804 if (current_function_decl == NULL)
805 fprintf (stderr, "At top level:\n");
806 else
807 {
808 char *name = (*decl_printable_name) (current_function_decl, &kind);
809 fprintf (stderr, "In %s `%s':\n", kind, name);
810 }
811
812 last_error_function = current_function_decl;
813 }
814 if (input_file_stack && input_file_stack->next != 0
815 && input_file_stack_tick != last_error_tick)
816 {
817 fprintf (stderr, "In file included");
818 for (p = input_file_stack->next; p; p = p->next)
819 {
820 fprintf (stderr, " from %s:%d", p->name, p->line);
821 if (p->next)
822 fprintf (stderr, ",");
823 }
824 fprintf (stderr, ":\n");
825 last_error_tick = input_file_stack_tick;
826 }
827 }
828
829 /* Report an error at the current line number.
830 S and V are a string and an arg for `printf'. */
831
832 void
833 error (s, v, v2)
834 char *s;
835 int v; /* @@also used as pointer */
836 int v2; /* @@also used as pointer */
837 {
838 error_with_file_and_line (input_filename, lineno, s, v, v2);
839 }
840
841 /* Report an error at line LINE of file FILE.
842 S and V are a string and an arg for `printf'. */
843
844 void
845 error_with_file_and_line (file, line, s, v, v2)
846 char *file;
847 int line;
848 char *s;
849 int v;
850 int v2;
851 {
852 count_error (0);
853
854 report_error_function (file);
855
856 if (file)
857 fprintf (stderr, "%s:%d: ", file, line);
858 else
859 fprintf (stderr, "%s: ", progname);
860 fprintf (stderr, s, v, v2);
861 fprintf (stderr, "\n");
862 }
863
864 /* Report an error at the declaration DECL.
865 S and V are a string and an arg which uses %s to substitute the declaration name. */
866
867 void
868 error_with_decl (decl, s, v)
869 tree decl;
870 char *s;
871 int v;
872 {
873 char *junk;
874 count_error (0);
875
876 report_error_function (DECL_SOURCE_FILE (decl));
877
878 fprintf (stderr, "%s:%d: ",
879 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
880
881 if (DECL_NAME (decl))
882 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
883 else
884 fprintf (stderr, s, "((anonymous))", v);
885 fprintf (stderr, "\n");
886 }
887
888 /* Report an error at the line number of the insn INSN.
889 S and V are a string and an arg for `printf'.
890 This is used only when INSN is an `asm' with operands,
891 and each ASM_OPERANDS records its own source file and line. */
892
893 void
894 error_for_asm (insn, s, v, v2)
895 rtx insn;
896 char *s;
897 int v; /* @@also used as pointer */
898 int v2; /* @@also used as pointer */
899 {
900 char *filename;
901 int line;
902 rtx body = PATTERN (insn);
903 rtx asmop;
904
905 /* Find the (or one of the) ASM_OPERANDS in the insn. */
906 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
907 asmop = SET_SRC (body);
908 else if (GET_CODE (body) == ASM_OPERANDS)
909 asmop = body;
910 else if (GET_CODE (body) == PARALLEL
911 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
912 asmop = SET_SRC (XVECEXP (body, 0, 0));
913 else if (GET_CODE (body) == PARALLEL
914 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
915 asmop = XVECEXP (body, 0, 0);
916
917 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
918 line = ASM_OPERANDS_SOURCE_LINE (asmop);
919
920 error_with_file_and_line (filename, line, s, v, v2);
921 }
922
923 /* Report a warning at line LINE.
924 S and V are a string and an arg for `printf'. */
925
926 void
927 warning_with_file_and_line (file, line, s, v, v2, v3)
928 char *file;
929 int line;
930 char *s;
931 int v;
932 int v2;
933 int v3;
934 {
935 if (count_error (1) == 0)
936 return;
937
938 report_error_function (file);
939
940 if (file)
941 fprintf (stderr, "%s:%d: ", file, line);
942 else
943 fprintf (stderr, "%s: ", progname);
944
945 fprintf (stderr, "warning: ");
946 fprintf (stderr, s, v, v2, v3);
947 fprintf (stderr, "\n");
948 }
949
950 /* Report a warning at the current line number.
951 S and V are a string and an arg for `printf'. */
952
953 void
954 warning (s, v, v2, v3)
955 char *s;
956 int v; /* @@also used as pointer */
957 int v2;
958 int v3;
959 {
960 warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
961 }
962
963 /* Report a warning at the declaration DECL.
964 S is string which uses %s to substitute the declaration name.
965 V is a second parameter that S can refer to. */
966
967 void
968 warning_with_decl (decl, s, v)
969 tree decl;
970 char *s;
971 int v;
972 {
973 char *junk;
974
975 if (count_error (1) == 0)
976 return;
977
978 report_error_function (DECL_SOURCE_FILE (decl));
979
980 fprintf (stderr, "%s:%d: ",
981 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
982
983 fprintf (stderr, "warning: ");
984 if (DECL_NAME (decl))
985 fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
986 else
987 fprintf (stderr, s, "((anonymous))", v);
988 fprintf (stderr, "\n");
989 }
990
991 /* Report a warning at the line number of the insn INSN.
992 S and V are a string and an arg for `printf'.
993 This is used only when INSN is an `asm' with operands,
994 and each ASM_OPERANDS records its own source file and line. */
995
996 void
997 warning_for_asm (insn, s, v, v2)
998 rtx insn;
999 char *s;
1000 int v; /* @@also used as pointer */
1001 int v2; /* @@also used as pointer */
1002 {
1003 char *filename;
1004 int line;
1005 rtx body = PATTERN (insn);
1006 rtx asmop;
1007
1008 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1009 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1010 asmop = SET_SRC (body);
1011 else if (GET_CODE (body) == ASM_OPERANDS)
1012 asmop = body;
1013 else if (GET_CODE (body) == PARALLEL
1014 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1015 asmop = SET_SRC (XVECEXP (body, 0, 0));
1016 else if (GET_CODE (body) == PARALLEL
1017 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1018 asmop = XVECEXP (body, 0, 0);
1019
1020 filename = ASM_OPERANDS_SOURCE_FILE (asmop);
1021 line = ASM_OPERANDS_SOURCE_LINE (asmop);
1022
1023 warning_with_file_and_line (filename, line, s, v, v2);
1024 }
1025 \f
1026 /* These functions issue either warnings or errors depending on
1027 -pedantic-errors. */
1028
1029 void
1030 pedwarn (s, v, v2)
1031 char *s;
1032 int v; /* @@also used as pointer */
1033 int v2;
1034 {
1035 if (flag_pedantic_errors)
1036 error (s, v, v2);
1037 else
1038 warning (s, v, v2);
1039 }
1040
1041 void
1042 pedwarn_with_decl (decl, s, v)
1043 tree decl;
1044 char *s;
1045 int v;
1046 {
1047 if (flag_pedantic_errors)
1048 error_with_decl (decl, s, v);
1049 else
1050 warning_with_decl (decl, s, v);
1051 }
1052
1053 void
1054 pedwarn_with_file_and_line (file, line, s, v, v2)
1055 char *file;
1056 int line;
1057 char *s;
1058 int v;
1059 int v2;
1060 {
1061 if (flag_pedantic_errors)
1062 error_with_file_and_line (file, line, s, v, v2);
1063 else
1064 warning_with_file_and_line (file, line, s, v, v2);
1065 }
1066
1067 /* Apologize for not implementing some feature.
1068 S, V, and V2 are a string and args for `printf'. */
1069
1070 void
1071 sorry (s, v, v2)
1072 char *s;
1073 int v, v2;
1074 {
1075 sorrycount++;
1076 if (input_filename)
1077 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1078 else
1079 fprintf (stderr, "%s: ", progname);
1080
1081 fprintf (stderr, "sorry, not implemented: ");
1082 fprintf (stderr, s, v, v2);
1083 fprintf (stderr, "\n");
1084 }
1085
1086 /* Apologize for not implementing some feature, then quit.
1087 S, V, and V2 are a string and args for `printf'. */
1088
1089 void
1090 really_sorry (s, v, v2)
1091 char *s;
1092 int v, v2;
1093 {
1094 if (input_filename)
1095 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1096 else
1097 fprintf (stderr, "c++: ");
1098
1099 fprintf (stderr, "sorry, not implemented: ");
1100 fprintf (stderr, s, v, v2);
1101 fatal (" (fatal)\n");
1102 }
1103 \f
1104 /* More 'friendly' abort that prints the line and file.
1105 config.h can #define abort fancy_abort if you like that sort of thing.
1106
1107 I don't think this is actually a good idea.
1108 Other sorts of crashes will look a certain way.
1109 It is a good thing if crashes from calling abort look the same way.
1110 -- RMS */
1111
1112 void
1113 fancy_abort ()
1114 {
1115 fatal ("internal gcc abort");
1116 }
1117
1118 /* This calls abort and is used to avoid problems when abort if a macro.
1119 It is used when we need to pass the address of abort. */
1120
1121 void
1122 do_abort ()
1123 {
1124 abort ();
1125 }
1126
1127 /* When `malloc.c' is compiled with `rcheck' defined,
1128 it calls this function to report clobberage. */
1129
1130 void
1131 botch (s)
1132 {
1133 abort ();
1134 }
1135
1136 /* Same as `malloc' but report error if no memory available. */
1137
1138 int
1139 xmalloc (size)
1140 unsigned size;
1141 {
1142 register int value = (int) malloc (size);
1143 if (value == 0)
1144 fatal ("virtual memory exhausted");
1145 return value;
1146 }
1147
1148 /* Same as `realloc' but report error if no memory available. */
1149
1150 int
1151 xrealloc (ptr, size)
1152 char *ptr;
1153 int size;
1154 {
1155 int result = realloc (ptr, size);
1156 if (!result)
1157 fatal ("virtual memory exhausted");
1158 return result;
1159 }
1160 \f
1161 /* Return the logarithm of X, base 2, considering X unsigned,
1162 if X is a power of 2. Otherwise, returns -1. */
1163
1164 int
1165 exact_log2 (x)
1166 register unsigned int x;
1167 {
1168 register int log = 0;
1169 /* Test for 0 or a power of 2. */
1170 if (x == 0 || x != (x & -x))
1171 return -1;
1172 while ((x >>= 1) != 0)
1173 log++;
1174 return log;
1175 }
1176
1177 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1178 If X is 0, return -1. */
1179
1180 int
1181 floor_log2 (x)
1182 register unsigned int x;
1183 {
1184 register int log = -1;
1185 while (x != 0)
1186 log++,
1187 x >>= 1;
1188 return log;
1189 }
1190
1191 int float_handled;
1192 jmp_buf float_handler;
1193
1194 /* Specify where to longjmp to when a floating arithmetic error happens.
1195 If HANDLER is 0, it means don't handle the errors any more. */
1196
1197 void
1198 set_float_handler (handler)
1199 jmp_buf handler;
1200 {
1201 float_handled = (handler != 0);
1202 if (handler)
1203 bcopy (handler, float_handler, sizeof (float_handler));
1204 }
1205
1206 /* Signals actually come here. */
1207
1208 static void
1209 float_signal (signo)
1210 /* If this is missing, some compilers complain. */
1211 int signo;
1212 {
1213 if (float_handled == 0)
1214 abort ();
1215 #if defined (USG) || defined (hpux)
1216 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1217 #endif
1218 float_handled = 0;
1219 signal (SIGFPE, float_signal);
1220 longjmp (float_handler, 1);
1221 }
1222
1223 /* Handler for SIGPIPE. */
1224
1225 static void
1226 pipe_closed (signo)
1227 /* If this is missing, some compilers complain. */
1228 int signo;
1229 {
1230 fatal ("output pipe has been closed");
1231 }
1232
1233 /* Strip off a legitimate source ending from the input string NAME of
1234 length LEN. */
1235
1236 void
1237 strip_off_ending (name, len)
1238 char *name;
1239 int len;
1240 {
1241 if (len > 2 && ! strcmp (".c", name + len - 2))
1242 name[len - 2] = 0;
1243 else if (len > 2 && ! strcmp (".m", name + len - 2))
1244 name[len - 2] = 0;
1245 else if (len > 2 && ! strcmp (".i", name + len - 2))
1246 name[len - 2] = 0;
1247 else if (len > 3 && ! strcmp (".ii", name + len - 3))
1248 name[len - 3] = 0;
1249 else if (len > 3 && ! strcmp (".co", name + len - 3))
1250 name[len - 3] = 0;
1251 else if (len > 3 && ! strcmp (".cc", name + len - 3))
1252 name[len - 3] = 0;
1253 else if (len > 2 && ! strcmp (".f", name + len - 2))
1254 name[len - 2] = 0;
1255 else if (len > 4 && ! strcmp (".ada", name + len - 4))
1256 name[len - 4] = 0;
1257 }
1258
1259 /* Output a file name in the form wanted by System V. */
1260
1261 void
1262 output_file_directive (asm_file, input_name)
1263 FILE *asm_file;
1264 char *input_name;
1265 {
1266 int len = strlen (input_name);
1267 char *na = input_name + len;
1268
1269 /* NA gets INPUT_NAME sans directory names. */
1270 while (na > input_name)
1271 {
1272 if (na[-1] == '/')
1273 break;
1274 na--;
1275 }
1276
1277 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1278 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1279 #else
1280 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1281 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1282 #else
1283 fprintf (asm_file, "\t.file\t\"%s\"\n", na);
1284 #endif
1285 #endif
1286 }
1287 \f
1288 /* Compile an entire file of output from cpp, named NAME.
1289 Write a file of assembly output and various debugging dumps. */
1290
1291 static void
1292 compile_file (name)
1293 char *name;
1294 {
1295 tree globals;
1296 int start_time;
1297 int dump_base_name_length;
1298
1299 int name_specified = name != 0;
1300
1301 if (dump_base_name == 0)
1302 dump_base_name = name ? name : "gccdump";
1303 dump_base_name_length = strlen (dump_base_name);
1304
1305 parse_time = 0;
1306 varconst_time = 0;
1307 integration_time = 0;
1308 jump_time = 0;
1309 cse_time = 0;
1310 loop_time = 0;
1311 cse2_time = 0;
1312 flow_time = 0;
1313 combine_time = 0;
1314 sched_time = 0;
1315 local_alloc_time = 0;
1316 global_alloc_time = 0;
1317 sched2_time = 0;
1318 dbr_sched_time = 0;
1319 shorten_branch_time = 0;
1320 stack_reg_time = 0;
1321 final_time = 0;
1322 symout_time = 0;
1323 dump_time = 0;
1324
1325 /* Open input file. */
1326
1327 if (name == 0 || !strcmp (name, "-"))
1328 {
1329 finput = stdin;
1330 name = "stdin";
1331 }
1332 else
1333 finput = fopen (name, "r");
1334 if (finput == 0)
1335 pfatal_with_name (name);
1336
1337 /* Initialize data in various passes. */
1338
1339 init_obstacks ();
1340 init_tree_codes ();
1341 init_lex ();
1342 init_rtl ();
1343 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1344 || debug_info_level == DINFO_LEVEL_VERBOSE);
1345 init_decl_processing ();
1346 init_optabs ();
1347 init_stmt ();
1348 init_expmed ();
1349 init_loop ();
1350 init_reload ();
1351
1352 if (flag_caller_saves)
1353 init_caller_save ();
1354
1355 /* If auxiliary info generation is desired, open the output file.
1356 This goes in the same directory as the source file--unlike
1357 all the other output files. */
1358 if (flag_gen_aux_info)
1359 {
1360 aux_info_file = fopen (aux_info_file_name, "w");
1361 if (aux_info_file == 0)
1362 pfatal_with_name (aux_info_file_name);
1363 }
1364
1365 /* If rtl dump desired, open the output file. */
1366 if (rtl_dump)
1367 {
1368 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1369 strcpy (dumpname, dump_base_name);
1370 strcat (dumpname, ".rtl");
1371 rtl_dump_file = fopen (dumpname, "w");
1372 if (rtl_dump_file == 0)
1373 pfatal_with_name (dumpname);
1374 }
1375
1376 /* If jump_opt dump desired, open the output file. */
1377 if (jump_opt_dump)
1378 {
1379 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1380 strcpy (dumpname, dump_base_name);
1381 strcat (dumpname, ".jump");
1382 jump_opt_dump_file = fopen (dumpname, "w");
1383 if (jump_opt_dump_file == 0)
1384 pfatal_with_name (dumpname);
1385 }
1386
1387 /* If cse dump desired, open the output file. */
1388 if (cse_dump)
1389 {
1390 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1391 strcpy (dumpname, dump_base_name);
1392 strcat (dumpname, ".cse");
1393 cse_dump_file = fopen (dumpname, "w");
1394 if (cse_dump_file == 0)
1395 pfatal_with_name (dumpname);
1396 }
1397
1398 /* If loop dump desired, open the output file. */
1399 if (loop_dump)
1400 {
1401 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1402 strcpy (dumpname, dump_base_name);
1403 strcat (dumpname, ".loop");
1404 loop_dump_file = fopen (dumpname, "w");
1405 if (loop_dump_file == 0)
1406 pfatal_with_name (dumpname);
1407 }
1408
1409 /* If cse2 dump desired, open the output file. */
1410 if (cse2_dump)
1411 {
1412 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1413 strcpy (dumpname, dump_base_name);
1414 strcat (dumpname, ".cse2");
1415 cse2_dump_file = fopen (dumpname, "w");
1416 if (cse2_dump_file == 0)
1417 pfatal_with_name (dumpname);
1418 }
1419
1420 /* If flow dump desired, open the output file. */
1421 if (flow_dump)
1422 {
1423 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1424 strcpy (dumpname, dump_base_name);
1425 strcat (dumpname, ".flow");
1426 flow_dump_file = fopen (dumpname, "w");
1427 if (flow_dump_file == 0)
1428 pfatal_with_name (dumpname);
1429 }
1430
1431 /* If combine dump desired, open the output file. */
1432 if (combine_dump)
1433 {
1434 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1435 strcpy (dumpname, dump_base_name);
1436 strcat (dumpname, ".combine");
1437 combine_dump_file = fopen (dumpname, "w");
1438 if (combine_dump_file == 0)
1439 pfatal_with_name (dumpname);
1440 }
1441
1442 /* If scheduling dump desired, open the output file. */
1443 if (sched_dump)
1444 {
1445 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1446 strcpy (dumpname, dump_base_name);
1447 strcat (dumpname, ".sched");
1448 sched_dump_file = fopen (dumpname, "w");
1449 if (sched_dump_file == 0)
1450 pfatal_with_name (dumpname);
1451 }
1452
1453 /* If local_reg dump desired, open the output file. */
1454 if (local_reg_dump)
1455 {
1456 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1457 strcpy (dumpname, dump_base_name);
1458 strcat (dumpname, ".lreg");
1459 local_reg_dump_file = fopen (dumpname, "w");
1460 if (local_reg_dump_file == 0)
1461 pfatal_with_name (dumpname);
1462 }
1463
1464 /* If global_reg dump desired, open the output file. */
1465 if (global_reg_dump)
1466 {
1467 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1468 strcpy (dumpname, dump_base_name);
1469 strcat (dumpname, ".greg");
1470 global_reg_dump_file = fopen (dumpname, "w");
1471 if (global_reg_dump_file == 0)
1472 pfatal_with_name (dumpname);
1473 }
1474
1475 /* If 2nd scheduling dump desired, open the output file. */
1476 if (sched2_dump)
1477 {
1478 register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
1479 strcpy (dumpname, dump_base_name);
1480 strcat (dumpname, ".sched2");
1481 sched2_dump_file = fopen (dumpname, "w");
1482 if (sched2_dump_file == 0)
1483 pfatal_with_name (dumpname);
1484 }
1485
1486 /* If jump2_opt dump desired, open the output file. */
1487 if (jump2_opt_dump)
1488 {
1489 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1490 strcpy (dumpname, dump_base_name);
1491 strcat (dumpname, ".jump2");
1492 jump2_opt_dump_file = fopen (dumpname, "w");
1493 if (jump2_opt_dump_file == 0)
1494 pfatal_with_name (dumpname);
1495 }
1496
1497 /* If dbr_sched dump desired, open the output file. */
1498 if (dbr_sched_dump)
1499 {
1500 register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1501 strcpy (dumpname, dump_base_name);
1502 strcat (dumpname, ".dbr");
1503 dbr_sched_dump_file = fopen (dumpname, "w");
1504 if (dbr_sched_dump_file == 0)
1505 pfatal_with_name (dumpname);
1506 }
1507
1508 #ifdef STACK_REGS
1509
1510 /* If stack_reg dump desired, open the output file. */
1511 if (stack_reg_dump)
1512 {
1513 register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
1514 strcpy (dumpname, dump_base_name);
1515 strcat (dumpname, ".stack");
1516 stack_reg_dump_file = fopen (dumpname, "w");
1517 if (stack_reg_dump_file == 0)
1518 pfatal_with_name (dumpname);
1519 }
1520
1521 #endif
1522
1523 /* Open assembler code output file. */
1524
1525 if (! name_specified && asm_file_name == 0)
1526 asm_out_file = stdout;
1527 else
1528 {
1529 register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1530 int len = strlen (dump_base_name);
1531 strcpy (dumpname, dump_base_name);
1532 strip_off_ending (dumpname, len);
1533 strcat (dumpname, ".s");
1534 if (asm_file_name == 0)
1535 {
1536 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
1537 strcpy (asm_file_name, dumpname);
1538 }
1539 if (!strcmp (asm_file_name, "-"))
1540 asm_out_file = stdout;
1541 else
1542 asm_out_file = fopen (asm_file_name, "w");
1543 if (asm_out_file == 0)
1544 pfatal_with_name (asm_file_name);
1545 }
1546
1547 #ifdef IO_BUFFER_SIZE
1548 setvbuf (asm_out_file, xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
1549 #endif
1550
1551 input_filename = name;
1552
1553 /* Perform language-specific initialization.
1554 This may set main_input_filename. */
1555 lang_init ();
1556
1557 /* If the input doesn't start with a #line, use the input name
1558 as the official input file name. */
1559 if (main_input_filename == 0)
1560 main_input_filename = name;
1561
1562 /* Put an entry on the input file stack for the main input file. */
1563 input_file_stack
1564 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1565 input_file_stack->next = 0;
1566 input_file_stack->name = input_filename;
1567
1568 ASM_FILE_START (asm_out_file);
1569
1570 /* Output something to inform GDB that this compilation was by GCC. */
1571 #ifndef ASM_IDENTIFY_GCC
1572 fprintf (asm_out_file, "gcc2_compiled.:\n");
1573 #else
1574 ASM_IDENTIFY_GCC (asm_out_file);
1575 #endif
1576 /* Don't let the first function fall at the same address
1577 as gcc_compiled., if profiling. */
1578 if (profile_flag || profile_block_flag)
1579 assemble_zeros (UNITS_PER_WORD);
1580
1581 /* If dbx symbol table desired, initialize writing it
1582 and output the predefined types. */
1583 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1584 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1585 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
1586 getdecls ()));
1587 #endif
1588 #ifdef SDB_DEBUGGING_INFO
1589 if (write_symbols == SDB_DEBUG)
1590 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
1591 getdecls ()));
1592 #endif
1593 #ifdef DWARF_DEBUGGING_INFO
1594 if (write_symbols == DWARF_DEBUG)
1595 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
1596 #endif
1597
1598 /* Initialize yet another pass. */
1599
1600 init_final (main_input_filename);
1601
1602 start_time = get_run_time ();
1603
1604 /* Call the parser, which parses the entire file
1605 (calling rest_of_compilation for each function). */
1606
1607 if (yyparse () != 0)
1608 if (errorcount == 0)
1609 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
1610
1611 /* Compilation is now finished except for writing
1612 what's left of the symbol table output. */
1613
1614 parse_time += get_run_time () - start_time;
1615
1616 parse_time -= integration_time;
1617 parse_time -= varconst_time;
1618
1619 globals = getdecls ();
1620
1621 /* Really define vars that have had only a tentative definition.
1622 Really output inline functions that must actually be callable
1623 and have not been output so far. */
1624
1625 {
1626 int len = list_length (globals);
1627 tree *vec = (tree *) alloca (sizeof (tree) * len);
1628 int i;
1629 tree decl;
1630
1631 /* Process the decls in reverse order--earliest first.
1632 Put them into VEC from back to front, then take out from front. */
1633
1634 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
1635 vec[len - i - 1] = decl;
1636
1637 for (i = 0; i < len; i++)
1638 {
1639 decl = vec[i];
1640 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1641 && ! TREE_ASM_WRITTEN (decl))
1642 {
1643 /* Don't write out static consts, unless we used them.
1644 (This used to write them out only if the address was
1645 taken, but that was wrong; if the variable was simply
1646 referred to, it still needs to exist or else it will
1647 be undefined in the linker.) */
1648 if (! TREE_READONLY (decl)
1649 || TREE_PUBLIC (decl)
1650 || TREE_USED (decl)
1651 || TREE_ADDRESSABLE (decl)
1652 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1653 rest_of_decl_compilation (decl, 0, 1, 1);
1654 else
1655 /* Cancel the RTL for this decl so that, if debugging info
1656 output for global variables is still to come,
1657 this one will be omitted. */
1658 DECL_RTL (decl) = NULL;
1659 }
1660
1661 if (TREE_CODE (decl) == FUNCTION_DECL
1662 && ! TREE_ASM_WRITTEN (decl)
1663 && DECL_INITIAL (decl) != 0
1664 && (TREE_ADDRESSABLE (decl)
1665 || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
1666 && ! TREE_EXTERNAL (decl))
1667 output_inline_function (decl);
1668
1669 /* Warn about any function
1670 declared static but not defined.
1671 We don't warn about variables,
1672 because many programs have static variables
1673 that exist only to get some text into the object file. */
1674 if ((warn_unused
1675 || TREE_USED (decl)
1676 || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
1677 && TREE_CODE (decl) == FUNCTION_DECL
1678 && DECL_INITIAL (decl) == 0
1679 && TREE_EXTERNAL (decl)
1680 && ! TREE_PUBLIC (decl))
1681 warning_with_decl (decl, "`%s' declared `static' but never defined");
1682 /* Warn about static fns or vars defined but not used,
1683 but not about inline functions
1684 since unused inline statics is normal practice. */
1685 if (warn_unused
1686 && (TREE_CODE (decl) == FUNCTION_DECL
1687 || TREE_CODE (decl) == VAR_DECL)
1688 && ! TREE_EXTERNAL (decl)
1689 && ! TREE_PUBLIC (decl)
1690 && ! TREE_USED (decl)
1691 && ! TREE_INLINE (decl)
1692 /* The TREE_USED bit for file-scope decls
1693 is kept in the identifier, to handle multiple
1694 external decls in different scopes. */
1695 && ! TREE_USED (DECL_NAME (decl)))
1696 warning_with_decl (decl, "`%s' defined but not used");
1697
1698 #ifdef SDB_DEBUGGING_INFO
1699 /* The COFF linker can move initialized global vars to the end.
1700 And that can screw up the symbol ordering.
1701 By putting the symbols in that order to begin with,
1702 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1703 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1704 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1705 && DECL_RTL (decl) != 0)
1706 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1707
1708 /* Output COFF information for non-global
1709 file-scope initialized variables. */
1710 if (write_symbols == SDB_DEBUG
1711 && TREE_CODE (decl) == VAR_DECL
1712 && DECL_INITIAL (decl)
1713 && DECL_RTL (decl) != 0
1714 && GET_CODE (DECL_RTL (decl)) == MEM)
1715 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
1716 #endif /* SDB_DEBUGGING_INFO */
1717 #ifdef DWARF_DEBUGGING_INFO
1718 /* Output DWARF information for file-scope tenative data object
1719 declarations, file-scope (extern) function declarations (which
1720 had no corresponding body) and file-scope tagged type declarations
1721 and definitions which have not yet been forced out. */
1722
1723 if (write_symbols == DWARF_DEBUG
1724 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1725 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
1726 #endif
1727 }
1728 }
1729
1730 /* Do dbx symbols */
1731 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1732 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1733 TIMEVAR (symout_time,
1734 {
1735 dbxout_finish (asm_out_file, main_input_filename);
1736 });
1737 #endif
1738
1739 #ifdef DWARF_DEBUGGING_INFO
1740 if (write_symbols == DWARF_DEBUG)
1741 TIMEVAR (symout_time,
1742 {
1743 dwarfout_finish ();
1744 });
1745 #endif
1746
1747 /* Output some stuff at end of file if nec. */
1748
1749 end_final (main_input_filename);
1750
1751 #ifdef ASM_FILE_END
1752 ASM_FILE_END (asm_out_file);
1753 #endif
1754
1755 after_finish_compilation:
1756
1757 /* Language-specific end of compilation actions. */
1758
1759 lang_finish ();
1760
1761 /* Close the dump files. */
1762
1763 if (flag_gen_aux_info)
1764 {
1765 fclose (aux_info_file);
1766 if (errorcount)
1767 unlink (aux_info_file_name);
1768 }
1769
1770 if (rtl_dump)
1771 fclose (rtl_dump_file);
1772
1773 if (jump_opt_dump)
1774 fclose (jump_opt_dump_file);
1775
1776 if (cse_dump)
1777 fclose (cse_dump_file);
1778
1779 if (loop_dump)
1780 fclose (loop_dump_file);
1781
1782 if (cse2_dump)
1783 fclose (cse2_dump_file);
1784
1785 if (flow_dump)
1786 fclose (flow_dump_file);
1787
1788 if (combine_dump)
1789 {
1790 dump_combine_total_stats (combine_dump_file);
1791 fclose (combine_dump_file);
1792 }
1793
1794 if (sched_dump)
1795 fclose (sched_dump_file);
1796
1797 if (local_reg_dump)
1798 fclose (local_reg_dump_file);
1799
1800 if (global_reg_dump)
1801 fclose (global_reg_dump_file);
1802
1803 if (sched2_dump)
1804 fclose (sched2_dump_file);
1805
1806 if (jump2_opt_dump)
1807 fclose (jump2_opt_dump_file);
1808
1809 if (dbr_sched_dump)
1810 fclose (dbr_sched_dump_file);
1811
1812 #ifdef STACK_REGS
1813 if (stack_reg_dump)
1814 fclose (stack_reg_dump_file);
1815 #endif
1816
1817 /* Close non-debugging input and output files. Take special care to note
1818 whether fclose returns an error, since the pages might still be on the
1819 buffer chain while the file is open. */
1820
1821 fclose (finput);
1822 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
1823 fatal_io_error (asm_file_name);
1824
1825 /* Print the times. */
1826
1827 if (! quiet_flag)
1828 {
1829 fprintf (stderr,"\n");
1830 print_time ("parse", parse_time);
1831 print_time ("integration", integration_time);
1832 print_time ("jump", jump_time);
1833 print_time ("cse", cse_time);
1834 print_time ("loop", loop_time);
1835 print_time ("cse2", cse2_time);
1836 print_time ("flow", flow_time);
1837 print_time ("combine", combine_time);
1838 print_time ("sched", sched_time);
1839 print_time ("local-alloc", local_alloc_time);
1840 print_time ("global-alloc", global_alloc_time);
1841 print_time ("sched2", sched2_time);
1842 print_time ("dbranch", dbr_sched_time);
1843 print_time ("shorten-branch", shorten_branch_time);
1844 print_time ("stack-reg", stack_reg_time);
1845 print_time ("final", final_time);
1846 print_time ("varconst", varconst_time);
1847 print_time ("symout", symout_time);
1848 print_time ("dump", dump_time);
1849 }
1850 }
1851 \f
1852 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
1853 and TYPE_DECL nodes.
1854
1855 This does nothing for local (non-static) variables.
1856 Otherwise, it sets up the RTL and outputs any assembler code
1857 (label definition, storage allocation and initialization).
1858
1859 DECL is the declaration. If ASMSPEC is nonzero, it specifies
1860 the assembler symbol name to be used. TOP_LEVEL is nonzero
1861 if this declaration is not within a function. */
1862
1863 void
1864 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
1865 tree decl;
1866 char *asmspec;
1867 int top_level;
1868 int at_end;
1869 {
1870 /* Declarations of variables, and of functions defined elsewhere. */
1871
1872 /* Forward declarations for nested functions are not "external",
1873 but we need to treat them as if they were. */
1874 if (TREE_STATIC (decl) || TREE_EXTERNAL (decl)
1875 || TREE_CODE (decl) == FUNCTION_DECL)
1876 TIMEVAR (varconst_time,
1877 {
1878 make_decl_rtl (decl, asmspec, top_level);
1879 /* Don't output anything
1880 when a tentative file-scope definition is seen.
1881 But at end of compilation, do output code for them. */
1882 if (! (! at_end && top_level
1883 && (DECL_INITIAL (decl) == 0
1884 || DECL_INITIAL (decl) == error_mark_node)))
1885 assemble_variable (decl, top_level, at_end);
1886 });
1887 else if (TREE_REGDECL (decl) && asmspec != 0)
1888 {
1889 if (decode_reg_name (asmspec) >= 0)
1890 {
1891 DECL_RTL (decl) = 0;
1892 make_decl_rtl (decl, asmspec, top_level);
1893 }
1894 else
1895 error ("invalid register name `%s' for register variable", asmspec);
1896 }
1897 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1898 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1899 && TREE_CODE (decl) == TYPE_DECL)
1900 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
1901 #endif
1902 #ifdef SDB_DEBUGGING_INFO
1903 else if (write_symbols == SDB_DEBUG && top_level
1904 && TREE_CODE (decl) == TYPE_DECL)
1905 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
1906 #endif
1907 }
1908
1909 /* Called after finishing a record, union or enumeral type. */
1910
1911 void
1912 rest_of_type_compilation (type, toplev)
1913 tree type;
1914 int toplev;
1915 {
1916 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1917 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1918 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
1919 #endif
1920 #ifdef SDB_DEBUGGING_INFO
1921 if (write_symbols == SDB_DEBUG)
1922 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
1923 #endif
1924 }
1925
1926 /* This is called from finish_function (within yyparse)
1927 after each top-level definition is parsed.
1928 It is supposed to compile that function or variable
1929 and output the assembler code for it.
1930 After we return, the tree storage is freed. */
1931
1932 void
1933 rest_of_compilation (decl)
1934 tree decl;
1935 {
1936 register rtx insns;
1937 int start_time = get_run_time ();
1938 int tem;
1939 /* Nonzero if we have saved the original DECL_INITIAL of the function,
1940 to be restored after we finish compiling the function
1941 (for use when compiling inline calls to this function). */
1942 tree saved_block_tree = 0;
1943
1944 /* If we are reconsidering an inline function
1945 at the end of compilation, skip the stuff for making it inline. */
1946
1947 if (DECL_SAVED_INSNS (decl) == 0)
1948 {
1949 int specd = TREE_INLINE (decl);
1950 char *lose;
1951
1952 /* If requested, consider whether to make this function inline. */
1953 if (specd || flag_inline_functions)
1954 TIMEVAR (integration_time,
1955 {
1956 lose = function_cannot_inline_p (decl);
1957 if (lose)
1958 {
1959 if (warn_inline && specd)
1960 warning_with_decl (decl, lose);
1961 TREE_INLINE (decl) = 0;
1962 }
1963 else
1964 TREE_INLINE (decl) = 1;
1965 });
1966
1967 insns = get_insns ();
1968
1969 /* Dump the rtl code if we are dumping rtl. */
1970
1971 if (rtl_dump)
1972 TIMEVAR (dump_time,
1973 {
1974 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1975 IDENTIFIER_POINTER (DECL_NAME (decl)));
1976 if (DECL_SAVED_INSNS (decl))
1977 fprintf (rtl_dump_file, ";; (integrable)\n\n");
1978 print_rtl (rtl_dump_file, insns);
1979 fflush (rtl_dump_file);
1980 });
1981
1982 /* If function is inline, and we don't yet know whether to
1983 compile it by itself, defer decision till end of compilation.
1984 finish_compilation will call rest_of_compilation again
1985 for those functions that need to be output. */
1986
1987 if (TREE_INLINE (decl)
1988 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
1989 && ! flag_keep_inline_functions)
1990 || TREE_EXTERNAL (decl)))
1991 {
1992 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
1993 goto exit_rest_of_compilation;
1994 }
1995
1996 /* If we have to compile the function now, save its rtl
1997 so that its compilation will not affect what others get. */
1998 if (TREE_INLINE (decl))
1999 {
2000 saved_block_tree = DECL_INITIAL (decl);
2001 TIMEVAR (integration_time, save_for_inline_copying (decl));
2002 }
2003 }
2004
2005 /* Suppress warnings for unused static functions
2006 defined (not just declared) in system headers. */
2007 if (in_system_header && TREE_STATIC (decl) && !TREE_INLINE (decl))
2008 TREE_USED (decl) = 1;
2009
2010 TREE_ASM_WRITTEN (decl) = 1;
2011
2012 /* Now that integrate will no longer see our rtl, we need not distinguish
2013 between the return value of this function and the return value of called
2014 functions. */
2015 rtx_equal_function_value_matters = 0;
2016
2017 if (rtl_dump_and_exit || flag_syntax_only)
2018 {
2019 goto exit_rest_of_compilation;
2020 }
2021
2022 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2023 Note that that may have been done above, in save_for_inline_copying.
2024 The call to resume_temporary_allocation near the end of this function
2025 goes back to the usual state of affairs. */
2026
2027 rtl_in_current_obstack ();
2028
2029 #ifdef FINALIZE_PIC
2030 /* If we are doing position-independent code generation, now
2031 is the time to output special prologues and epilogues.
2032 We do not want to do this earlier, because it just clutters
2033 up inline functions with meaningless insns. */
2034 if (flag_pic)
2035 FINALIZE_PIC;
2036 #endif
2037
2038 insns = get_insns ();
2039
2040 /* Copy any shared structure that should not be shared. */
2041
2042 unshare_all_rtl (insns);
2043
2044 /* Instantiate all virtual registers. */
2045
2046 instantiate_virtual_regs (current_function_decl, get_insns ());
2047
2048 /* See if we have allocated stack slots that are not directly addressable.
2049 If so, scan all the insns and create explicit address computation
2050 for all references to such slots. */
2051 /* fixup_stack_slots (); */
2052
2053 /* Do jump optimization the first time, if -opt.
2054 Also do it if -W, but in that case it doesn't change the rtl code,
2055 it only computes whether control can drop off the end of the function. */
2056
2057 if (optimize > 0 || extra_warnings || warn_return_type
2058 /* If function is `volatile', we should warn if it tries to return. */
2059 || TREE_THIS_VOLATILE (decl))
2060 {
2061 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2062 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
2063 }
2064
2065 /* Dump rtl code after jump, if we are doing that. */
2066
2067 if (jump_opt_dump)
2068 TIMEVAR (dump_time,
2069 {
2070 fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
2071 IDENTIFIER_POINTER (DECL_NAME (decl)));
2072 print_rtl (jump_opt_dump_file, insns);
2073 fflush (jump_opt_dump_file);
2074 });
2075
2076 /* Perform common subexpression elimination.
2077 Nonzero value from `cse_main' means that jumps were simplified
2078 and some code may now be unreachable, so do
2079 jump optimization again. */
2080
2081 if (cse_dump)
2082 TIMEVAR (dump_time,
2083 {
2084 fprintf (cse_dump_file, "\n;; Function %s\n\n",
2085 IDENTIFIER_POINTER (DECL_NAME (decl)));
2086 });
2087
2088 if (optimize > 0)
2089 {
2090 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2091
2092 if (flag_thread_jumps)
2093 /* Hacks by tiemann & kenner. */
2094 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2095
2096 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
2097 0, cse_dump_file));
2098 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
2099
2100 if (tem)
2101 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2102 }
2103
2104 /* Dump rtl code after cse, if we are doing that. */
2105
2106 if (cse_dump)
2107 TIMEVAR (dump_time,
2108 {
2109 print_rtl (cse_dump_file, insns);
2110 fflush (cse_dump_file);
2111 });
2112
2113 if (loop_dump)
2114 TIMEVAR (dump_time,
2115 {
2116 fprintf (loop_dump_file, "\n;; Function %s\n\n",
2117 IDENTIFIER_POINTER (DECL_NAME (decl)));
2118 });
2119
2120 /* Move constant computations out of loops. */
2121
2122 if (optimize > 0)
2123 {
2124 TIMEVAR (loop_time,
2125 {
2126 loop_optimize (insns, loop_dump ? loop_dump_file : 0);
2127 });
2128 }
2129
2130 /* Dump rtl code after loop opt, if we are doing that. */
2131
2132 if (loop_dump)
2133 TIMEVAR (dump_time,
2134 {
2135 print_rtl (loop_dump_file, insns);
2136 fflush (loop_dump_file);
2137 });
2138
2139 if (cse2_dump)
2140 TIMEVAR (dump_time,
2141 {
2142 fprintf (cse2_dump_file, "\n;; Function %s\n\n",
2143 IDENTIFIER_POINTER (DECL_NAME (decl)));
2144 });
2145
2146 if (optimize > 0 && flag_rerun_cse_after_loop)
2147 {
2148 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
2149
2150 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
2151 1, cse2_dump_file));
2152 if (tem)
2153 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
2154 }
2155
2156 if (optimize > 0 && flag_thread_jumps)
2157 /* This pass of jump threading straightens out code
2158 that was kinked by loop optimization. */
2159 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
2160
2161 /* Dump rtl code after cse, if we are doing that. */
2162
2163 if (cse2_dump)
2164 TIMEVAR (dump_time,
2165 {
2166 print_rtl (cse2_dump_file, insns);
2167 fflush (cse2_dump_file);
2168 });
2169
2170 /* We are no longer anticipating cse in this function, at least. */
2171
2172 cse_not_expected = 1;
2173
2174 /* Now we choose between stupid (pcc-like) register allocation
2175 (if we got the -noreg switch and not -opt)
2176 and smart register allocation. */
2177
2178 if (optimize > 0) /* Stupid allocation probably won't work */
2179 obey_regdecls = 0; /* if optimizations being done. */
2180
2181 regclass_init ();
2182
2183 /* Print function header into flow dump now
2184 because doing the flow analysis makes some of the dump. */
2185
2186 if (flow_dump)
2187 TIMEVAR (dump_time,
2188 {
2189 fprintf (flow_dump_file, "\n;; Function %s\n\n",
2190 IDENTIFIER_POINTER (DECL_NAME (decl)));
2191 });
2192
2193 if (obey_regdecls)
2194 {
2195 TIMEVAR (flow_time,
2196 {
2197 regclass (insns, max_reg_num ());
2198 stupid_life_analysis (insns, max_reg_num (),
2199 flow_dump_file);
2200 });
2201 }
2202 else
2203 {
2204 /* Do control and data flow analysis,
2205 and write some of the results to dump file. */
2206
2207 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
2208 flow_dump_file));
2209 if (warn_uninitialized)
2210 {
2211 uninitialized_vars_warning (DECL_INITIAL (decl));
2212 setjmp_args_warning ();
2213 }
2214 }
2215
2216 /* Dump rtl after flow analysis. */
2217
2218 if (flow_dump)
2219 TIMEVAR (dump_time,
2220 {
2221 print_rtl (flow_dump_file, insns);
2222 fflush (flow_dump_file);
2223 });
2224
2225 /* If -opt, try combining insns through substitution. */
2226
2227 if (optimize > 0)
2228 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
2229
2230 /* Dump rtl code after insn combination. */
2231
2232 if (combine_dump)
2233 TIMEVAR (dump_time,
2234 {
2235 fprintf (combine_dump_file, "\n;; Function %s\n\n",
2236 IDENTIFIER_POINTER (DECL_NAME (decl)));
2237 dump_combine_stats (combine_dump_file);
2238 print_rtl (combine_dump_file, insns);
2239 fflush (combine_dump_file);
2240 });
2241
2242 /* Print function header into sched dump now
2243 because doing the sched analysis makes some of the dump. */
2244
2245 if (sched_dump)
2246 TIMEVAR (dump_time,
2247 {
2248 fprintf (sched_dump_file, "\n;; Function %s\n\n",
2249 IDENTIFIER_POINTER (DECL_NAME (decl)));
2250 });
2251
2252 if (optimize > 0 && flag_schedule_insns)
2253 {
2254 /* Do control and data sched analysis,
2255 and write some of the results to dump file. */
2256
2257 TIMEVAR (sched_time, schedule_insns (sched_dump_file));
2258 }
2259
2260 /* Dump rtl after instruction scheduling. */
2261
2262 if (sched_dump)
2263 TIMEVAR (dump_time,
2264 {
2265 print_rtl (sched_dump_file, insns);
2266 fflush (sched_dump_file);
2267 });
2268
2269 /* Unless we did stupid register allocation,
2270 allocate pseudo-regs that are used only within 1 basic block. */
2271
2272 if (!obey_regdecls)
2273 TIMEVAR (local_alloc_time,
2274 {
2275 regclass (insns, max_reg_num ());
2276 local_alloc ();
2277 });
2278
2279 /* Dump rtl code after allocating regs within basic blocks. */
2280
2281 if (local_reg_dump)
2282 TIMEVAR (dump_time,
2283 {
2284 fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
2285 IDENTIFIER_POINTER (DECL_NAME (decl)));
2286 dump_flow_info (local_reg_dump_file);
2287 dump_local_alloc (local_reg_dump_file);
2288 print_rtl (local_reg_dump_file, insns);
2289 fflush (local_reg_dump_file);
2290 });
2291
2292 if (global_reg_dump)
2293 TIMEVAR (dump_time,
2294 fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
2295 IDENTIFIER_POINTER (DECL_NAME (decl))));
2296
2297 /* Unless we did stupid register allocation,
2298 allocate remaining pseudo-regs, then do the reload pass
2299 fixing up any insns that are invalid. */
2300
2301 TIMEVAR (global_alloc_time,
2302 {
2303 if (!obey_regdecls)
2304 global_alloc (global_reg_dump ? global_reg_dump_file : 0);
2305 else
2306 reload (insns, 0,
2307 global_reg_dump ? global_reg_dump_file : 0);
2308 });
2309
2310 if (global_reg_dump)
2311 TIMEVAR (dump_time,
2312 {
2313 dump_global_regs (global_reg_dump_file);
2314 print_rtl (global_reg_dump_file, insns);
2315 fflush (global_reg_dump_file);
2316 });
2317
2318 reload_completed = 1;
2319
2320 if (optimize > 0 && flag_schedule_insns_after_reload)
2321 {
2322 if (sched2_dump)
2323 TIMEVAR (dump_time,
2324 {
2325 fprintf (sched2_dump_file, "\n;; Function %s\n\n",
2326 IDENTIFIER_POINTER (DECL_NAME (decl)));
2327 });
2328
2329 /* Do control and data sched analysis again,
2330 and write some more of the results to dump file. */
2331
2332 TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
2333
2334 /* Dump rtl after post-reorder instruction scheduling. */
2335
2336 if (sched2_dump)
2337 TIMEVAR (dump_time,
2338 {
2339 print_rtl (sched2_dump_file, insns);
2340 fflush (sched2_dump_file);
2341 });
2342 }
2343
2344 #ifdef LEAF_REGISTERS
2345 leaf_function = 0;
2346 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
2347 leaf_function = 1;
2348 #endif
2349
2350 /* One more attempt to remove jumps to .+1
2351 left by dead-store-elimination.
2352 Also do cross-jumping this time
2353 and delete no-op move insns. */
2354
2355 if (optimize > 0)
2356 {
2357 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
2358 }
2359
2360 /* Dump rtl code after jump, if we are doing that. */
2361
2362 if (jump2_opt_dump)
2363 TIMEVAR (dump_time,
2364 {
2365 fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
2366 IDENTIFIER_POINTER (DECL_NAME (decl)));
2367 print_rtl (jump2_opt_dump_file, insns);
2368 fflush (jump2_opt_dump_file);
2369 });
2370
2371 /* If a scheduling pass for delayed branches is to be done,
2372 call the scheduling code. */
2373
2374 #ifdef DELAY_SLOTS
2375 if (optimize > 0 && flag_delayed_branch)
2376 {
2377 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
2378 if (dbr_sched_dump)
2379 {
2380 TIMEVAR (dump_time,
2381 {
2382 fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
2383 IDENTIFIER_POINTER (DECL_NAME (decl)));
2384 print_rtl (dbr_sched_dump_file, insns);
2385 fflush (dbr_sched_dump_file);
2386 });
2387 }
2388 }
2389 #endif
2390
2391 if (optimize > 0)
2392 /* Shorten branches. */
2393 TIMEVAR (shorten_branch_time,
2394 {
2395 shorten_branches (get_insns ());
2396 });
2397
2398 #ifdef STACK_REGS
2399 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
2400 if (stack_reg_dump)
2401 {
2402 TIMEVAR (dump_time,
2403 {
2404 fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
2405 IDENTIFIER_POINTER (DECL_NAME (decl)));
2406 print_rtl (stack_reg_dump_file, insns);
2407 fflush (stack_reg_dump_file);
2408 });
2409 }
2410 #endif
2411
2412 /* Now turn the rtl into assembler code. */
2413
2414 TIMEVAR (final_time,
2415 {
2416 rtx x;
2417 char *fnname;
2418
2419 /* Get the function's name, as described by its RTL.
2420 This may be different from the DECL_NAME name used
2421 in the source file. */
2422
2423 x = DECL_RTL (decl);
2424 if (GET_CODE (x) != MEM)
2425 abort ();
2426 x = XEXP (x, 0);
2427 if (GET_CODE (x) != SYMBOL_REF)
2428 abort ();
2429 fnname = XSTR (x, 0);
2430
2431 assemble_start_function (decl, fnname);
2432 final_start_function (insns, asm_out_file, optimize);
2433 final (insns, asm_out_file, optimize, 0);
2434 final_end_function (insns, asm_out_file, optimize);
2435 assemble_end_function (decl, fnname);
2436 fflush (asm_out_file);
2437 });
2438
2439 /* Write DBX symbols if requested */
2440
2441 /* Note that for those inline functions where we don't initially
2442 know for certain that we will be generating an out-of-line copy,
2443 the first invocation of this routine (rest_of_compilation) will
2444 skip over this code by doing a `goto exit_rest_of_compilation;'.
2445 Later on, finish_compilation will call rest_of_compilation again
2446 for those inline functions that need to have out-of-line copies
2447 generated. During that call, we *will* be routed past here. */
2448
2449 #ifdef DBX_DEBUGGING_INFO
2450 if (write_symbols == DBX_DEBUG)
2451 TIMEVAR (symout_time, dbxout_function (decl));
2452 #endif
2453
2454 #ifdef DWARF_DEBUGGING_INFO
2455 if (write_symbols == DWARF_DEBUG)
2456 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
2457 #endif
2458
2459 exit_rest_of_compilation:
2460
2461 /* In case the function was not output,
2462 don't leave any temporary anonymous types
2463 queued up for sdb output. */
2464 #ifdef SDB_DEBUGGING_INFO
2465 if (write_symbols == SDB_DEBUG)
2466 sdbout_types (0);
2467 #endif
2468
2469 /* Put back the tree of subblocks from before we copied it.
2470 Code generation and the output of debugging info may have modified
2471 the copy, but the original is unchanged. */
2472
2473 if (saved_block_tree != 0)
2474 DECL_INITIAL (decl) = saved_block_tree;
2475
2476 reload_completed = 0;
2477
2478 /* Clear out the real_constant_chain before some of the rtx's
2479 it runs through become garbage. */
2480
2481 clear_const_double_mem ();
2482
2483 /* Cancel the effect of rtl_in_current_obstack. */
2484
2485 resume_temporary_allocation ();
2486
2487 /* The parsing time is all the time spent in yyparse
2488 *except* what is spent in this function. */
2489
2490 parse_time -= get_run_time () - start_time;
2491 }
2492 \f
2493 /* Entry point of cc1/c++. Decode command args, then call compile_file.
2494 Exit code is 35 if can't open files, 34 if fatal error,
2495 33 if had nonfatal errors, else success. */
2496
2497 int
2498 main (argc, argv, envp)
2499 int argc;
2500 char **argv;
2501 char **envp;
2502 {
2503 register int i;
2504 char *filename = 0;
2505 int flag_print_mem = 0;
2506 int version_flag = 0;
2507 char *p;
2508
2509 /* save in case md file wants to emit args as a comment. */
2510 save_argc = argc;
2511 save_argv = argv;
2512
2513 p = argv[0] + strlen (argv[0]);
2514 while (p != argv[0] && p[-1] != '/') --p;
2515 progname = p;
2516
2517 #ifdef RLIMIT_STACK
2518 /* Get rid of any avoidable limit on stack size. */
2519 {
2520 struct rlimit rlim;
2521
2522 /* Set the stack limit huge so that alloca does not fail. */
2523 getrlimit (RLIMIT_STACK, &rlim);
2524 rlim.rlim_cur = rlim.rlim_max;
2525 setrlimit (RLIMIT_STACK, &rlim);
2526 }
2527 #endif /* RLIMIT_STACK */
2528
2529 signal (SIGFPE, float_signal);
2530
2531 signal (SIGPIPE, pipe_closed);
2532
2533 decl_printable_name = decl_name;
2534 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
2535
2536 /* Initialize whether `char' is signed. */
2537 flag_signed_char = DEFAULT_SIGNED_CHAR;
2538 #ifdef DEFAULT_SHORT_ENUMS
2539 /* Initialize how much space enums occupy, by default. */
2540 flag_short_enums = DEFAULT_SHORT_ENUMS;
2541 #endif
2542
2543 /* Scan to see what optimization level has been specified. That will
2544 determine the default value of many flags. */
2545 for (i = 1; i < argc; i++)
2546 {
2547 if (!strcmp (argv[i], "-O"))
2548 {
2549 optimize = 1;
2550 }
2551 else if (argv[i][0] == '-' && argv[i][1] == 'O')
2552 {
2553 /* Handle -O2, -O3, -O69, ... */
2554 char *p = &argv[i][2];
2555 int c;
2556
2557 while (c = *p++)
2558 if (! (c >= '0' && c <= '9'))
2559 break;
2560 if (c == 0)
2561 optimize = atoi (&argv[i][2]);
2562 }
2563 }
2564
2565 obey_regdecls = (optimize == 0);
2566 if (optimize == 0)
2567 {
2568 flag_no_inline = 1;
2569 warn_inline = 0;
2570 }
2571
2572 if (optimize >= 1)
2573 {
2574 flag_thread_jumps = 1;
2575 #ifdef DELAY_SLOTS
2576 flag_delayed_branch = 1;
2577 #endif
2578 }
2579
2580 if (optimize >= 2)
2581 {
2582 flag_cse_follow_jumps = 1;
2583 flag_expensive_optimizations = 1;
2584 flag_strength_reduce = 1;
2585 flag_rerun_cse_after_loop = 1;
2586 flag_caller_saves = 1;
2587 #ifdef INSN_SCHEDULING
2588 flag_schedule_insns = 1;
2589 flag_schedule_insns_after_reload = 1;
2590 #endif
2591 }
2592
2593 #ifdef OPTIMIZATION_OPTIONS
2594 /* Allow default optimizations to be specified on a per-machine basis. */
2595 OPTIMIZATION_OPTIONS (optimize);
2596 #endif
2597
2598 /* Initialize register usage now so switches may override. */
2599 init_reg_sets ();
2600
2601 target_flags = 0;
2602 set_target_switch ("");
2603
2604 for (i = 1; i < argc; i++)
2605 {
2606 if (argv[i][0] == '-' && argv[i][1] != 0)
2607 {
2608 register char *str = argv[i] + 1;
2609 if (str[0] == 'Y')
2610 str++;
2611
2612 if (str[0] == 'm')
2613 set_target_switch (&str[1]);
2614 else if (!strcmp (str, "dumpbase"))
2615 {
2616 dump_base_name = argv[++i];
2617 }
2618 else if (str[0] == 'd')
2619 {
2620 register char *p = &str[1];
2621 while (*p)
2622 switch (*p++)
2623 {
2624 case 'a':
2625 combine_dump = 1;
2626 dbr_sched_dump = 1;
2627 flow_dump = 1;
2628 global_reg_dump = 1;
2629 jump_opt_dump = 1;
2630 jump2_opt_dump = 1;
2631 local_reg_dump = 1;
2632 loop_dump = 1;
2633 rtl_dump = 1;
2634 cse_dump = 1, cse2_dump = 1;
2635 sched_dump = 1;
2636 sched2_dump = 1;
2637 stack_reg_dump = 1;
2638 break;
2639 case 'k':
2640 stack_reg_dump = 1;
2641 break;
2642 case 'c':
2643 combine_dump = 1;
2644 break;
2645 case 'd':
2646 dbr_sched_dump = 1;
2647 break;
2648 case 'f':
2649 flow_dump = 1;
2650 break;
2651 case 'g':
2652 global_reg_dump = 1;
2653 break;
2654 case 'j':
2655 jump_opt_dump = 1;
2656 break;
2657 case 'J':
2658 jump2_opt_dump = 1;
2659 break;
2660 case 'l':
2661 local_reg_dump = 1;
2662 break;
2663 case 'L':
2664 loop_dump = 1;
2665 break;
2666 case 'm':
2667 flag_print_mem = 1;
2668 break;
2669 case 'p':
2670 flag_print_asm_name = 1;
2671 break;
2672 case 'r':
2673 rtl_dump = 1;
2674 break;
2675 case 's':
2676 cse_dump = 1;
2677 break;
2678 case 't':
2679 cse2_dump = 1;
2680 break;
2681 case 'S':
2682 sched_dump = 1;
2683 break;
2684 case 'R':
2685 sched2_dump = 1;
2686 break;
2687 case 'y':
2688 set_yydebug (1);
2689 break;
2690
2691 case 'x':
2692 rtl_dump_and_exit = 1;
2693 break;
2694 }
2695 }
2696 else if (str[0] == 'f')
2697 {
2698 int j;
2699 register char *p = &str[1];
2700 int found = 0;
2701
2702 /* Some kind of -f option.
2703 P's value is the option sans `-f'.
2704 Search for it in the table of options. */
2705
2706 for (j = 0;
2707 !found && j < sizeof (f_options) / sizeof (f_options[0]);
2708 j++)
2709 {
2710 if (!strcmp (p, f_options[j].string))
2711 {
2712 *f_options[j].variable = f_options[j].on_value;
2713 /* A goto here would be cleaner,
2714 but breaks the vax pcc. */
2715 found = 1;
2716 }
2717 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2718 && ! strcmp (p+3, f_options[j].string))
2719 {
2720 *f_options[j].variable = ! f_options[j].on_value;
2721 found = 1;
2722 }
2723 }
2724
2725 if (found)
2726 ;
2727 else if (!strncmp (p, "fixed-", 6))
2728 fix_register (&p[6], 1, 1);
2729 else if (!strncmp (p, "call-used-", 10))
2730 fix_register (&p[10], 0, 1);
2731 else if (!strncmp (p, "call-saved-", 11))
2732 fix_register (&p[11], 0, 0);
2733 else if (! lang_decode_option (argv[i]))
2734 error ("Invalid option `%s'", argv[i]);
2735 }
2736 else if (str[0] == 'O')
2737 {
2738 register char *p = str+1;
2739 while (*p && *p >= '0' && *p <= '9')
2740 p++;
2741 if (*p == '\0')
2742 ;
2743 else
2744 error ("Invalid option `%s'", argv[i]);
2745 }
2746 else if (!strcmp (str, "pedantic"))
2747 pedantic = 1;
2748 else if (!strcmp (str, "pedantic-errors"))
2749 flag_pedantic_errors = pedantic = 1;
2750 else if (lang_decode_option (argv[i]))
2751 ;
2752 else if (!strcmp (str, "quiet"))
2753 quiet_flag = 1;
2754 else if (!strcmp (str, "version"))
2755 version_flag = 1;
2756 else if (!strcmp (str, "w"))
2757 inhibit_warnings = 1;
2758 else if (!strcmp (str, "W"))
2759 {
2760 extra_warnings = 1;
2761 warn_uninitialized = 1;
2762 }
2763 else if (str[0] == 'W')
2764 {
2765 int j;
2766 register char *p = &str[1];
2767 int found = 0;
2768
2769 /* Some kind of -W option.
2770 P's value is the option sans `-W'.
2771 Search for it in the table of options. */
2772
2773 for (j = 0;
2774 !found && j < sizeof (W_options) / sizeof (W_options[0]);
2775 j++)
2776 {
2777 if (!strcmp (p, W_options[j].string))
2778 {
2779 *W_options[j].variable = W_options[j].on_value;
2780 /* A goto here would be cleaner,
2781 but breaks the vax pcc. */
2782 found = 1;
2783 }
2784 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
2785 && ! strcmp (p+3, W_options[j].string))
2786 {
2787 *W_options[j].variable = ! W_options[j].on_value;
2788 found = 1;
2789 }
2790 }
2791
2792 if (found)
2793 ;
2794 else if (!strncmp (p, "id-clash-", 9))
2795 {
2796 char *endp = p + 9;
2797
2798 while (*endp)
2799 {
2800 if (*endp >= '0' && *endp <= '9')
2801 endp++;
2802 else
2803 error ("Invalid option `%s'", argv[i]);
2804 }
2805 warn_id_clash = 1;
2806 id_clash_len = atoi (str + 10);
2807 }
2808 else
2809 error ("Invalid option `%s'", argv[i]);
2810 }
2811 else if (!strcmp (str, "p"))
2812 profile_flag = 1;
2813 else if (!strcmp (str, "a"))
2814 {
2815 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
2816 warning ("`-a' option (basic block profile) not supported");
2817 #else
2818 profile_block_flag = 1;
2819 #endif
2820 }
2821 else if (str[0] == 'g')
2822 {
2823 char *p = str + 1;
2824 char *q;
2825 unsigned len;
2826 unsigned level;
2827
2828 while (*p && (*p < '0' || *p > '9'))
2829 p++;
2830 len = p - str;
2831 q = p;
2832 while (*q && (*q >= '0' && *q <= '9'))
2833 q++;
2834 if (*p)
2835 level = atoi (p);
2836 else
2837 level = 2; /* default debugging info level */
2838 if (*q || level > 3)
2839 {
2840 warning ("invalid debug level specification in option: `-%s'",
2841 str);
2842 warning ("no debugging information will be generated");
2843 level = 0;
2844 }
2845
2846 /* If more than one debugging type is supported,
2847 you must define PREFERRED_DEBUGGING_TYPE
2848 to choose a format in a system-dependent way. */
2849 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) \
2850 + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
2851 #ifdef PREFERRED_DEBUGGING_TYPE
2852 if (!strncmp (str, "ggdb", len))
2853 write_symbols = PREFERRED_DEBUGGING_TYPE;
2854 #else /* no PREFERRED_DEBUGGING_TYPE */
2855 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
2856 #endif /* no PREFERRED_DEBUGGING_TYPE */
2857 #endif /* More than one debugger format enabled. */
2858 #ifdef DBX_DEBUGGING_INFO
2859 if (write_symbols != NO_DEBUG)
2860 ;
2861 else if (!strncmp (str, "ggdb", len))
2862 write_symbols = DBX_DEBUG;
2863 else if (!strncmp (str, "gstabs", len))
2864 write_symbols = DBX_DEBUG;
2865
2866 /* Always enable extensions for -ggdb or -gstabs+,
2867 always disable for -gstabs.
2868 For plain -g, use system-specific default. */
2869 if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
2870 && len >= 2)
2871 use_gdb_dbx_extensions = 1;
2872 else if (write_symbols == DBX_DEBUG && !strcmp (str, "gstabs+"))
2873 use_gdb_dbx_extensions = 1;
2874 else if (write_symbols == DBX_DEBUG
2875 && !strncmp (str, "gstabs", len) && len >= 2)
2876 use_gdb_dbx_extensions = 0;
2877 else
2878 use_gdb_dbx_extensions = DEFAULT_GDB_EXTENSIONS;
2879 #endif /* DBX_DEBUGGING_INFO */
2880 #ifdef DWARF_DEBUGGING_INFO
2881 if (write_symbols != NO_DEBUG)
2882 ;
2883 else if (!strncmp (str, "ggdb", len))
2884 write_symbols = DWARF_DEBUG;
2885 /* For orthogonality. */
2886 else if (!strncmp (str, "gdwarf", len))
2887 write_symbols = DWARF_DEBUG;
2888 #endif
2889 #ifdef SDB_DEBUGGING_INFO
2890 if (write_symbols != NO_DEBUG)
2891 ;
2892 else if (!strncmp (str, "ggdb", len))
2893 write_symbols = SDB_DEBUG;
2894 else if (!strncmp (str, "gcoff", len))
2895 write_symbols = SDB_DEBUG;
2896 #endif /* SDB_DEBUGGING_INFO */
2897 #ifdef XCOFF_DEBUGGING_INFO
2898 if (write_symbols != NO_DEBUG)
2899 ;
2900 else if (!strncmp (str, "ggdb", len))
2901 write_symbols = XCOFF_DEBUG;
2902 else if (!strncmp (str, "gxcoff", len))
2903 write_symbols = XCOFF_DEBUG;
2904
2905 /* Always enable extensions for -ggdb,
2906 always disable for -gxcoff.
2907 For plain -g, use system-specific default. */
2908 if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
2909 && len >= 2)
2910 use_gdb_dbx_extensions = 1;
2911 else if (write_symbols == DBX_DEBUG
2912 && !strncmp (str, "gxcoff", len) && len >= 2)
2913 use_gdb_dbx_extensions = 0;
2914 else
2915 use_gdb_dbx_extensions = DEFAULT_GDB_EXTENSIONS;
2916 #endif
2917 if (write_symbols == NO_DEBUG)
2918 warning ("`-%s' option not supported on this version of GCC", str);
2919 else if (level == 0)
2920 write_symbols = NO_DEBUG;
2921 else
2922 debug_info_level = level;
2923 }
2924 else if (!strcmp (str, "o"))
2925 {
2926 asm_file_name = argv[++i];
2927 }
2928 else if (str[0] == 'G')
2929 {
2930 g_switch_set = TRUE;
2931 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
2932 }
2933 else if (!strncmp (str, "aux-info", 8))
2934 {
2935 flag_gen_aux_info = 1;
2936 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
2937 }
2938 else
2939 error ("Invalid option `%s'", argv[i]);
2940 }
2941 else if (argv[i][0] == '+')
2942 {
2943 if (lang_decode_option (argv[i]))
2944 ;
2945 else
2946 error ("Invalid option `%s'", argv[i]);
2947 }
2948 else
2949 filename = argv[i];
2950 }
2951
2952 /* Inlining does not work if not optimizing,
2953 so force it not to be done. */
2954 if (optimize == 0)
2955 {
2956 flag_no_inline = 1;
2957 warn_inline = 0;
2958 }
2959
2960 #ifdef OVERRIDE_OPTIONS
2961 /* Some machines may reject certain combinations of options. */
2962 OVERRIDE_OPTIONS;
2963 #endif
2964
2965 /* Unrolling all loops implies that standard loop unrolling must also
2966 be done. */
2967 if (flag_unroll_all_loops)
2968 flag_unroll_loops = 1;
2969 /* Loop unrolling requires that strength_reduction be on also. Silently
2970 turn on strength reduction here if it isn't already on. Also, the loop
2971 unrolling code assumes that cse will be run after loop, so that must
2972 be turned on also. */
2973 if (flag_unroll_loops)
2974 {
2975 flag_strength_reduce = 1;
2976 flag_rerun_cse_after_loop = 1;
2977 }
2978
2979 /* Warn about options that are not supported on this machine. */
2980 #ifndef INSN_SCHEDULING
2981 if (flag_schedule_insns || flag_schedule_insns_after_reload)
2982 warning ("instruction scheduling not supported on this target machine");
2983 #endif
2984 #ifndef DELAY_SLOTS
2985 if (flag_delayed_branch)
2986 warning ("this target machine does not have delayed branches");
2987 #endif
2988
2989 /* If we are in verbose mode, write out the version and maybe all the
2990 option flags in use. */
2991 if (version_flag)
2992 {
2993 fprintf (stderr, "%s version %s", language_string, version_string);
2994 #ifdef TARGET_VERSION
2995 TARGET_VERSION;
2996 #endif
2997 #ifdef __GNUC__
2998 #ifndef __VERSION__
2999 #define __VERSION__ "[unknown]"
3000 #endif
3001 fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
3002 #else
3003 fprintf (stderr, " compiled by CC.\n");
3004 #endif
3005 if (! quiet_flag)
3006 print_switch_values ();
3007 }
3008
3009 /* Now that register usage is specified, convert it to HARD_REG_SETs. */
3010 init_reg_sets_1 ();
3011
3012 compile_file (filename);
3013
3014 #ifndef VMS
3015 if (flag_print_mem)
3016 {
3017 char *lim = (char *) sbrk (0);
3018
3019 fprintf (stderr, "Data size %d.\n",
3020 (int) lim - (int) &environ);
3021 fflush (stderr);
3022
3023 #ifdef USG
3024 system ("ps -l 1>&2");
3025 #else /* not USG */
3026 system ("ps v");
3027 #endif /* not USG */
3028 }
3029 #endif /* not VMS */
3030
3031 if (errorcount)
3032 exit (FATAL_EXIT_CODE);
3033 if (sorrycount)
3034 exit (FATAL_EXIT_CODE);
3035 exit (SUCCESS_EXIT_CODE);
3036 return 34;
3037 }
3038 \f
3039 /* Decode -m switches. */
3040
3041 /* Here is a table, controlled by the tm.h file, listing each -m switch
3042 and which bits in `target_switches' it should set or clear.
3043 If VALUE is positive, it is bits to set.
3044 If VALUE is negative, -VALUE is bits to clear.
3045 (The sign bit is not used so there is no confusion.) */
3046
3047 struct {char *name; int value;} target_switches []
3048 = TARGET_SWITCHES;
3049
3050 /* This table is similar, but allows the switch to have a value. */
3051
3052 #ifdef TARGET_OPTIONS
3053 struct {char *prefix; char ** variable;} target_options []
3054 = TARGET_OPTIONS;
3055 #endif
3056
3057 /* Decode the switch -mNAME. */
3058
3059 void
3060 set_target_switch (name)
3061 char *name;
3062 {
3063 register int j;
3064 int valid = 0;
3065
3066 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3067 if (!strcmp (target_switches[j].name, name))
3068 {
3069 if (target_switches[j].value < 0)
3070 target_flags &= ~-target_switches[j].value;
3071 else
3072 target_flags |= target_switches[j].value;
3073 valid = 1;
3074 }
3075
3076 #ifdef TARGET_OPTIONS
3077 if (!valid)
3078 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
3079 {
3080 int len = strlen (target_options[j].prefix);
3081 if (!strncmp (target_options[j].prefix, name, len))
3082 {
3083 *target_options[j].variable = name + len;
3084 valid = 1;
3085 }
3086 }
3087 #endif
3088
3089 if (!valid)
3090 error ("Invalid option `%s'", name);
3091 }
3092 \f
3093 /* Variable used for communication between the following two routines. */
3094
3095 static int line_position;
3096
3097 /* Print an option value and adjust the position in the line. */
3098
3099 static void
3100 print_single_switch (type, name)
3101 char *type, *name;
3102 {
3103 fprintf (stderr, " %s%s", type, name);
3104
3105 line_position += strlen (type) + strlen (name) + 1;
3106
3107 if (line_position > 65)
3108 {
3109 fprintf (stderr, "\n\t");
3110 line_position = 8;
3111 }
3112 }
3113
3114 /* Print default target switches for -version. */
3115
3116 static void
3117 print_switch_values ()
3118 {
3119 register int j;
3120
3121 fprintf (stderr, "enabled:");
3122 line_position = 8;
3123
3124 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
3125 if (*f_options[j].variable == f_options[j].on_value)
3126 print_single_switch ("-f", f_options[j].string);
3127
3128 for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
3129 if (*W_options[j].variable == W_options[j].on_value)
3130 print_single_switch ("-W", W_options[j].string);
3131
3132 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
3133 if (target_switches[j].name[0] != '\0'
3134 && target_switches[j].value > 0
3135 && ((target_switches[j].value & target_flags)
3136 == target_switches[j].value))
3137 print_single_switch ("-m", target_switches[j].name);
3138
3139 fprintf (stderr, "\n");
3140 }
This page took 0.173273 seconds and 6 git commands to generate.