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