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