Annotation of gcc/toplev.c, revision 1.1.1.10

1.1       root        1: /* Top level of GNU C compiler
1.1.1.2   root        2:    Copyright (C) 1987, 1988 Free Software Foundation, Inc.
1.1       root        3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is distributed in the hope that it will be useful,
                      7: but WITHOUT ANY WARRANTY.  No author or distributor
                      8: accepts responsibility to anyone for the consequences of using it
                      9: or for whether it serves any particular purpose or works at all,
                     10: unless he says so in writing.  Refer to the GNU CC General Public
                     11: License for full details.
                     12: 
                     13: Everyone is granted permission to copy, modify and redistribute
                     14: GNU CC, but only under the conditions described in the
                     15: GNU CC General Public License.   A copy of this license is
                     16: supposed to have been given to you along with GNU CC so you
                     17: can know your rights and responsibilities.  It should be in a
                     18: file named COPYING.  Among other things, the copyright notice
                     19: and this notice must be preserved on all copies.  */
                     20: 
                     21: 
                     22: /* This is the top level of cc1.
                     23:    It parses command args, opens files, invokes the various passes
                     24:    in the proper order, and counts the time used by each.
                     25:    Error messages and low-level interface to malloc also handled here.  */
                     26: 
                     27: #include "config.h"
                     28: #include <stdio.h>
                     29: #include <signal.h>
1.1.1.10! root       30: #include <setjmp.h>
1.1.1.2   root       31: 
1.1.1.4   root       32: #include <sys/types.h>
                     33: #include <sys/stat.h>
                     34: 
1.1.1.2   root       35: #ifdef USG
                     36: #include <sys/param.h>
                     37: #include <sys/times.h>
                     38: #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
                     39: #else
                     40: #ifndef VMS
1.1       root       41: #include <sys/time.h>
                     42: #include <sys/resource.h>
1.1.1.2   root       43: #endif
                     44: #endif
                     45: 
1.1       root       46: #include "tree.h"
                     47: #include "c-tree.h"
                     48: #include "rtl.h"
1.1.1.2   root       49: #include "flags.h"
1.1       root       50: 
                     51: extern int yydebug;
                     52: 
                     53: extern FILE *finput;
                     54: 
                     55: extern void init_lex ();
                     56: extern void init_decl_processing ();
                     57: extern void init_tree ();
                     58: extern void init_rtl ();
                     59: extern void init_optabs ();
1.1.1.2   root       60: extern void init_reg_sets ();
1.1       root       61: extern void dump_flow_info ();
                     62: extern void dump_local_alloc ();
                     63: 
1.1.1.2   root       64: void rest_of_decl_compilation ();
                     65: void error ();
                     66: void error_with_file_and_line ();
                     67: void set_target_switch ();
                     68: 
1.1       root       69: /* Bit flags that specify the machine subtype we are compiling for.
                     70:    Bits are tested using macros TARGET_... defined in the tm-...h file
                     71:    and set by `-m...' switches.  */
                     72: 
                     73: int target_flags;
                     74: 
1.1.1.2   root       75: /* Name of current original source file (what was input to cpp).
                     76:    This comes from each #-command in the actual input.  */
1.1       root       77: 
1.1.1.2   root       78: char *input_filename;
                     79: 
                     80: /* Name of top-level original source file (what was input to cpp).
1.1.1.8   root       81:    This comes from the #-command at the beginning of the actual input.
                     82:    If there isn't any there, then this is the cc1 input file name.  */
1.1.1.2   root       83: 
                     84: char *main_input_filename;
1.1       root       85: 
                     86: /* Current line number in real source file.  */
                     87: 
                     88: extern int lineno;
                     89: 
                     90: /* FUNCTION_DECL for function now being parsed or compiled.  */
                     91: 
                     92: extern tree current_function_decl;
                     93: 
                     94: /* Name to use as base of names for dump output files.  */
                     95: 
                     96: char *dump_base_name;
                     97: 
                     98: /* Flags saying which kinds of debugging dump have been requested.  */
                     99: 
                    100: int rtl_dump = 0;
                    101: int rtl_dump_and_exit = 0;
                    102: int jump_opt_dump = 0;
                    103: int cse_dump = 0;
                    104: int loop_dump = 0;
                    105: int flow_dump = 0;
                    106: int combine_dump = 0;
                    107: int local_reg_dump = 0;
                    108: int global_reg_dump = 0;
1.1.1.2   root      109: int jump2_opt_dump = 0;
1.1       root      110: 
                    111: /* 1 => write gdb debugging output (using symout.c).  -g
1.1.1.6   root      112:    2 => write dbx debugging output (using dbxout.c).  -G
                    113:    3 => write sdb debugging output (using sdbout.c).  -g.  */
1.1       root      114: 
1.1.1.4   root      115: enum debugger write_symbols = NO_DEBUG;
1.1       root      116: 
1.1.1.6   root      117: /* Nonzero means can use our own extensions to DBX format.
                    118:    Relevant only with write_symbols == DBX_DEBUG.  */
                    119: 
                    120: int use_gdb_dbx_extensions;
                    121: 
1.1       root      122: /* Nonzero means do optimizations.  -opt.  */
                    123: 
                    124: int optimize = 0;
                    125: 
1.1.1.2   root      126: /* Nonzero for -fforce-mem: load memory value into a register
1.1       root      127:    before arithmetic on it.  This makes better cse but slower compilation.  */
                    128: 
1.1.1.2   root      129: int flag_force_mem = 0;
1.1       root      130: 
1.1.1.2   root      131: /* Nonzero for -fforce-addr: load memory address into a register before
1.1       root      132:    reference to memory.  This makes better cse but slower compilation.  */
                    133: 
1.1.1.2   root      134: int flag_force_addr = 0;
                    135: 
                    136: /* Nonzero for -fdefer-pop: don't pop args after each function call;
                    137:    instead save them up to pop many calls' args with one insns.  */
                    138: 
                    139: int flag_defer_pop = 1;
                    140: 
                    141: /* Nonzero for -ffloat-store: don't allocate floats and doubles
                    142:    in extended-precision registers.  */
                    143: 
                    144: int flag_float_store = 0;
                    145: 
                    146: /* Nonzero for -fcombine-regs:
                    147:    allow instruction combiner to combine an insn
                    148:    that just copies one reg to another.  */
                    149: 
                    150: int flag_combine_regs = 0;
                    151: 
1.1.1.9   root      152: /* Nonzero enables strength-reduction in loop.c.  */
                    153: 
                    154: int flag_strength_reduce = 0;
                    155: 
1.1.1.2   root      156: /* Nonzero for -fwritable-strings:
                    157:    store string constants in data segment and don't uniquize them.  */
                    158: 
                    159: int flag_writable_strings = 0;
                    160: 
                    161: /* Nonzero means don't put addresses of constant functions in registers.
                    162:    Used for compiling the Unix kernel, where strange substitutions are
                    163:    done on the assembly output.  */
                    164: 
                    165: int flag_no_function_cse = 0;
                    166: 
                    167: /* Nonzero for -fomit-frame-pointer:
                    168:    don't make a frame pointer in simple functions that don't require one.  */
                    169: 
                    170: int flag_omit_frame_pointer = 0;
                    171: 
                    172: /* Nonzero to inhibit use of define_optimization peephole opts.  */
                    173: 
                    174: int flag_no_peephole = 0;
                    175: 
                    176: /* Nonzero means all references through pointers are volatile.  */
                    177: 
                    178: int flag_volatile;
1.1       root      179: 
                    180: /* Nonzero means do stupid register allocation.  -noreg.
1.1.1.2   root      181:    This and `optimize' are controlled by different switches in cc1,
1.1       root      182:    but normally cc controls them both with the -O switch.  */
                    183: 
                    184: int obey_regdecls = 0;
                    185: 
                    186: /* Don't print functions as they are compiled and don't print
                    187:    times taken by the various passes.  -quiet.  */
                    188: 
                    189: int quiet_flag = 0;
                    190: 
                    191: /* Don't print warning messages.  -w.  */
                    192: 
                    193: int inhibit_warnings = 0;
                    194: 
1.1.1.2   root      195: /* Do print extra warnings (such as for uninitialized variables).  -W.  */
                    196: 
                    197: int extra_warnings = 0;
                    198: 
1.1.1.9   root      199: /* Nonzero to warn about unused local variables.  */
                    200: 
                    201: int warn_unused;
                    202: 
1.1       root      203: /* Number of error messages and warning messages so far.  */
                    204: 
                    205: int errorcount = 0;
                    206: int warningcount = 0;
1.1.1.7   root      207: int sorrycount = 0;
1.1       root      208: 
1.1.1.2   root      209: /* Nonzero if generating code to do profiling.  */
                    210: 
                    211: int profile_flag = 0;
                    212: 
1.1       root      213: /* Nonzero for -pedantic switch: warn about anything
1.1.1.7   root      214:    that standard spec forbids.  */
1.1       root      215: 
                    216: int pedantic = 0;
                    217: 
1.1.1.2   root      218: /* Nonzero for -finline-functions: ok to inline functions that look like
                    219:    good inline candidates.  */
                    220: 
                    221: int flag_inline_functions;
                    222: 
                    223: /* Nonzero for -fkeep-inline-functions: even if we make a function
                    224:    go inline everywhere, keep its defintion around for debugging
                    225:    purposes.  */
                    226: 
                    227: int flag_keep_inline_functions;
                    228: 
1.1       root      229: /* Name for output file of assembly code, specified with -o.  */
                    230: 
                    231: char *asm_file_name;
                    232: 
                    233: /* Name for output file of GDB symbol segment, specified with -symout.  */
                    234: 
                    235: char *sym_file_name;
                    236: 
                    237: /* Output files for assembler code (real compiler output)
                    238:    and debugging dumps.  */
                    239: 
                    240: FILE *asm_out_file;
                    241: FILE *rtl_dump_file;
                    242: FILE *jump_opt_dump_file;
                    243: FILE *cse_dump_file;
                    244: FILE *loop_dump_file;
                    245: FILE *flow_dump_file;
                    246: FILE *combine_dump_file;
                    247: FILE *local_reg_dump_file;
                    248: FILE *global_reg_dump_file;
1.1.1.2   root      249: FILE *jump2_opt_dump_file;
1.1       root      250: 
                    251: /* Time accumulators, to count the total time spent in various passes.  */
                    252: 
                    253: int parse_time;
                    254: int varconst_time;
1.1.1.2   root      255: int integration_time;
1.1       root      256: int jump_time;
                    257: int cse_time;
                    258: int loop_time;
                    259: int flow_time;
                    260: int combine_time;
                    261: int local_alloc_time;
                    262: int global_alloc_time;
                    263: int final_time;
                    264: int symout_time;
                    265: int dump_time;
                    266: 
                    267: /* Return time used so far, in microseconds.  */
                    268: 
1.1.1.2   root      269: int
1.1       root      270: gettime ()
                    271: {
1.1.1.2   root      272: #ifdef USG
                    273:   struct tms tms;
                    274: #else
                    275: #ifndef VMS
1.1       root      276:   struct rusage rusage;
1.1.1.2   root      277: #else /* VMS */
                    278:   struct
                    279:     {
                    280:       int proc_user_time;
                    281:       int proc_system_time;
                    282:       int child_user_time;
                    283:       int child_system_time;
                    284:     } vms_times;
                    285: #endif
                    286: #endif
                    287: 
1.1       root      288:   if (quiet_flag)
                    289:     return 0;
1.1.1.2   root      290: 
                    291: #ifdef USG
                    292:   times (&tms);
                    293:   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
                    294: #else
                    295: #ifndef VMS
1.1       root      296:   getrusage (0, &rusage);
                    297:   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
                    298:          + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1.1.1.2   root      299: #else /* VMS */
                    300:   times (&vms_times);
                    301:   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
                    302: #endif
                    303: #endif
1.1       root      304: }
                    305: 
                    306: #define TIMEVAR(VAR, BODY)    \
1.1.1.3   root      307: do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
1.1       root      308: 
1.1.1.2   root      309: void
1.1       root      310: print_time (str, total)
                    311:      char *str;
                    312:      int total;
                    313: {
1.1.1.2   root      314:   fprintf (stderr,
                    315:           "time in %s: %d.%06d\n",
                    316:           str, total / 1000000, total % 1000000);
1.1       root      317: }
                    318: 
                    319: /* Count an error or warning.  Return 1 if the message should be printed.  */
                    320: 
                    321: int
                    322: count_error (warningp)
                    323:      int warningp;
                    324: {
                    325:   if (warningp && inhibit_warnings)
                    326:     return 0;
                    327: 
                    328:   if (warningp)
                    329:     warningcount++;
                    330:   else
                    331:     errorcount++;
                    332: 
                    333:   return 1;
                    334: }
                    335: 
                    336: /* Print a fatal error message.  NAME is the text.
                    337:    Also include a system error message based on `errno'.  */
                    338: 
1.1.1.2   root      339: void
1.1       root      340: pfatal_with_name (name)
1.1.1.2   root      341:      char *name;
1.1       root      342: {
                    343:   fprintf (stderr, "cc1: ");
                    344:   perror (name);
                    345:   exit (35);
                    346: }
                    347: 
                    348: void
1.1.1.2   root      349: fatal_io_error (name)
                    350:      char *name;
                    351: {
                    352:   fprintf (stderr, "cc1:%s: I/O error\n", name);
                    353:   exit (35);
                    354: }
                    355: 
                    356: void
1.1.1.7   root      357: fatal (s, v)
1.1       root      358:      char *s;
                    359: {
1.1.1.7   root      360:   error (s, v);
1.1       root      361:   exit (34);
                    362: }
1.1.1.8   root      363: 
                    364: static int need_error_newline;
                    365: 
                    366: /* Function of last error message;
                    367:    more generally, function such that if next error message is in it
                    368:    then we don't have to mention the function name.  */
                    369: static tree last_error_function = NULL;
1.1       root      370: 
                    371: /* Called when the start of a function definition is parsed,
                    372:    this function prints on stderr the name of the function.  */
                    373: 
                    374: void
                    375: announce_function (decl)
                    376:      tree decl;
                    377: {
                    378:   if (! quiet_flag)
                    379:     {
                    380:       fprintf (stderr, " %s", IDENTIFIER_POINTER (DECL_NAME (decl)));
                    381:       fflush (stderr);
1.1.1.9   root      382:       need_error_newline = 1;
                    383:       last_error_function = current_function_decl;
1.1       root      384:     }
                    385: }
1.1.1.8   root      386: 
1.1.1.2   root      387: /* Prints out, if necessary, the name of the current function
                    388:    which caused an error.  Called from all error and warning functions.  */
                    389: 
1.1.1.9   root      390: static void
                    391: report_error_function (file)
                    392:      char *file;
1.1.1.2   root      393: {
1.1.1.8   root      394:   if (need_error_newline)
                    395:     {
                    396:       fprintf (stderr, "\n");
                    397:       need_error_newline = 0;
                    398:     }
1.1.1.2   root      399: 
                    400:   if (last_error_function != current_function_decl)
                    401:     {
1.1.1.9   root      402:       if (file)
                    403:        fprintf (stderr, "%s: ", file);
                    404: 
1.1.1.2   root      405:       if (current_function_decl == NULL)
1.1.1.8   root      406:        fprintf (stderr, "At top level:\n");
1.1.1.2   root      407:       else
1.1.1.8   root      408:        fprintf (stderr, "In function %s:\n",
                    409:                 IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
                    410: 
1.1.1.2   root      411:       last_error_function = current_function_decl;
                    412:     }
                    413: }
1.1       root      414: 
                    415: /* Report an error at the current line number.
                    416:    S and V are a string and an arg for `printf'.  */
                    417: 
                    418: void
1.1.1.7   root      419: error (s, v, v2)
1.1       root      420:      char *s;
                    421:      int v;                    /* @@also used as pointer */
1.1.1.7   root      422:      int v2;                   /* @@also used as pointer */
1.1       root      423: {
1.1.1.7   root      424:   error_with_file_and_line (input_filename, lineno, s, v, v2);
1.1       root      425: }
                    426: 
1.1.1.2   root      427: /* Report an error at line LINE of file FILE.
1.1       root      428:    S and V are a string and an arg for `printf'.  */
                    429: 
1.1.1.2   root      430: void
1.1.1.7   root      431: error_with_file_and_line (file, line, s, v, v2)
1.1.1.2   root      432:      char *file;
1.1       root      433:      int line;
                    434:      char *s;
                    435:      int v;
1.1.1.7   root      436:      int v2;
1.1       root      437: {
                    438:   count_error (0);
                    439: 
1.1.1.9   root      440:   report_error_function (file);
1.1.1.2   root      441: 
                    442:   if (file)
                    443:     fprintf (stderr, "%s:%d: ", file, line);
                    444:   else
                    445:     fprintf (stderr, "cc1: ");
1.1.1.7   root      446:   fprintf (stderr, s, v, v2);
1.1       root      447:   fprintf (stderr, "\n");
                    448: }
                    449: 
1.1.1.2   root      450: /* Report an error at the declaration DECL.
                    451:    S is string which uses %s to substitute the declaration name.  */
1.1       root      452: 
                    453: void
1.1.1.2   root      454: error_with_decl (decl, s)
                    455:      tree decl;
1.1       root      456:      char *s;
                    457: {
1.1.1.2   root      458:   count_error (0);
                    459: 
1.1.1.9   root      460:   report_error_function (DECL_SOURCE_FILE (decl));
1.1.1.2   root      461: 
                    462:   fprintf (stderr, "%s:%d: ",
                    463:           DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
                    464: 
                    465:   if (DECL_NAME (decl))
                    466:     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)));
                    467:   else
                    468:     fprintf (stderr, s, "((anonymous))");
                    469:   fprintf (stderr, "\n");
1.1       root      470: }
                    471: 
                    472: /* Report a warning at line LINE.
                    473:    S and V are a string and an arg for `printf'.  */
                    474: 
1.1.1.2   root      475: void
1.1.1.7   root      476: warning_with_line (line, s, v, v2)
1.1       root      477:      int line;
                    478:      char *s;
                    479:      int v;
1.1.1.7   root      480:      int v2;
1.1       root      481: {
                    482:   if (count_error (1) == 0)
                    483:     return;
                    484: 
1.1.1.9   root      485:   report_error_function (input_filename);
1.1.1.2   root      486: 
                    487:   if (input_filename)
                    488:     fprintf (stderr, "%s:%d: ", input_filename, line);
                    489:   else
                    490:     fprintf (stderr, "cc1: ");
1.1       root      491: 
                    492:   fprintf (stderr, "warning: ");
1.1.1.7   root      493:   fprintf (stderr, s, v, v2);
1.1       root      494:   fprintf (stderr, "\n");
                    495: }
1.1.1.2   root      496: 
                    497: /* Report a warning at the current line number.
                    498:    S and V are a string and an arg for `printf'.  */
                    499: 
                    500: void
1.1.1.7   root      501: warning (s, v, v2)
1.1.1.2   root      502:      char *s;
                    503:      int v;                    /* @@also used as pointer */
1.1.1.7   root      504:      int v2;
1.1.1.2   root      505: {
1.1.1.7   root      506:   warning_with_line (lineno, s, v, v2);
1.1.1.2   root      507: }
                    508: 
                    509: /* Report a warning at the declaration DECL.
                    510:    S is string which uses %s to substitute the declaration name.  */
                    511: 
                    512: void
                    513: warning_with_decl (decl, s)
                    514:      tree decl;
                    515:      char *s;
                    516: {
                    517:   if (count_error (1) == 0)
                    518:     return;
                    519: 
1.1.1.9   root      520:   report_error_function (DECL_SOURCE_FILE (decl));
1.1.1.2   root      521: 
                    522:   fprintf (stderr, "%s:%d: ",
                    523:           DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
                    524: 
                    525:   fprintf (stderr, "warning: ");
                    526:   if (DECL_NAME (decl))
                    527:     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)));
                    528:   else
                    529:     fprintf (stderr, s, "((anonymous))");
                    530:   fprintf (stderr, "\n");
                    531: }
1.1.1.7   root      532: 
                    533: /* Apologize for not implementing some feature.
                    534:    S, V, and V2 are a string and args for `printf'.  */
                    535: 
                    536: void
                    537: sorry (s, v, v2)
                    538:      char *s;
                    539:      int v, v2;
                    540: {
                    541:   sorrycount++;
                    542:   if (input_filename)
                    543:     fprintf (stderr, "%s:%d: ", input_filename, lineno);
                    544:   else
                    545:     fprintf (stderr, "cc1: ");
                    546: 
                    547:   fprintf (stderr, "sorry, not implemented: ");
                    548:   fprintf (stderr, s, v, v2);
                    549:   fprintf (stderr, "\n");
                    550: }
                    551: 
                    552: /* Apologize for not implementing some feature, then quit.
                    553:    S, V, and V2 are a string and args for `printf'.  */
                    554: 
                    555: void
                    556: really_sorry (s, v, v2)
                    557:      char *s;
                    558:      int v, v2;
                    559: {
                    560:   if (input_filename)
                    561:     fprintf (stderr, "%s:%d: ", input_filename, lineno);
                    562:   else
                    563:     fprintf (stderr, "c++: ");
                    564: 
                    565:   fprintf (stderr, "sorry, not implemented: ");
                    566:   fprintf (stderr, s, v, v2);
                    567:   fatal (" (fatal)\n");
                    568: }
1.1       root      569: 
                    570: /* When `malloc.c' is compiled with `rcheck' defined,
                    571:    it calls this function to report clobberage.  */
                    572: 
1.1.1.2   root      573: void
1.1       root      574: botch (s)
                    575: {
                    576:   abort ();
                    577: }
                    578: 
                    579: /* Same as `malloc' but report error if no memory available.  */
                    580: 
1.1.1.2   root      581: int
1.1       root      582: xmalloc (size)
                    583:      unsigned size;
                    584: {
                    585:   register int value = (int) malloc (size);
                    586:   if (value == 0)
                    587:     fatal ("Virtual memory exhausted.");
                    588:   return value;
                    589: }
                    590: 
                    591: /* Same as `realloc' but report error if no memory available.  */
                    592: 
                    593: int
                    594: xrealloc (ptr, size)
                    595:      char *ptr;
                    596:      int size;
                    597: {
                    598:   int result = realloc (ptr, size);
                    599:   if (!result)
1.1.1.2   root      600:     fatal ("Virtual memory exhausted.");
1.1       root      601:   return result;
                    602: }
                    603: 
                    604: /* Return the logarithm of X, base 2, considering X unsigned,
                    605:    if X is a power of 2.  Otherwise, returns -1.  */
                    606: 
                    607: int
                    608: exact_log2 (x)
                    609:      register unsigned int x;
                    610: {
                    611:   register int log = 0;
                    612:   for (log = 0; log < HOST_BITS_PER_INT; log++)
                    613:     if (x == (1 << log))
                    614:       return log;
                    615:   return -1;
                    616: }
                    617: 
                    618: /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
                    619:    If X is 0, return -1.  */
                    620: 
                    621: int
                    622: floor_log2 (x)
                    623:      register unsigned int x;
                    624: {
                    625:   register int log = 0;
                    626:   for (log = 0; log < HOST_BITS_PER_INT; log++)
                    627:     if ((x & ((-1) << log)) == 0)
                    628:       return log - 1;
                    629:   return HOST_BITS_PER_INT - 1;
                    630: }
1.1.1.10! root      631: 
        !           632: int float_handled;
        !           633: jmp_buf float_handler;
        !           634: 
        !           635: /* Specify where to longjmp to when a floating arithmetic error happens.
        !           636:    If HANDLER is 0, it means don't handle the errors any more.  */
        !           637: 
        !           638: void
        !           639: set_float_handler (handler)
        !           640:      jmp_buf handler;
        !           641: {
        !           642:   float_handled = (handler != 0);
        !           643:   if (handler)
        !           644:     bcopy (handler, float_handler, sizeof (float_handler));
        !           645: }
        !           646: 
        !           647: /* Signals actually come here.  */
        !           648: 
        !           649: static void
        !           650: float_signal ()
        !           651: {
        !           652:   if (float_handled == 0)
        !           653:     abort ();
        !           654:   warning ("floating overflow in constant folding");
        !           655:   float_handled = 0;
        !           656:   longjmp (float_handler, 1);
        !           657: }
1.1       root      658: 
                    659: /* Compile an entire file of output from cpp, named NAME.
                    660:    Write a file of assembly output and various debugging dumps.  */
                    661: 
                    662: static void
                    663: compile_file (name)
                    664:      char *name;
                    665: {
                    666:   tree globals;
                    667:   int start_time;
1.1.1.9   root      668:   int dump_base_name_length;
                    669: 
                    670:   int name_specified = name != 0;
                    671: 
                    672:   if (dump_base_name == 0)
                    673:     dump_base_name = name ? name : "gccdump";
                    674:   dump_base_name_length = strlen (dump_base_name);
1.1       root      675: 
                    676:   parse_time = 0;
                    677:   varconst_time = 0;
1.1.1.2   root      678:   integration_time = 0;
1.1       root      679:   jump_time = 0;
                    680:   cse_time = 0;
                    681:   loop_time = 0;
                    682:   flow_time = 0;
                    683:   combine_time = 0;
                    684:   local_alloc_time = 0;
                    685:   global_alloc_time = 0;
                    686:   final_time = 0;
                    687:   symout_time = 0;
1.1.1.2   root      688:   dump_time = 0;
1.1       root      689: 
                    690:   /* Open input file.  */
                    691: 
1.1.1.9   root      692:   if (name == 0 || !strcmp (name, "-"))
                    693:     {
                    694:       finput = stdin;
                    695:       name = "stdin";
                    696:     }
                    697:   else
                    698:     finput = fopen (name, "r");
1.1       root      699:   if (finput == 0)
                    700:     pfatal_with_name (name);
                    701: 
                    702:   /* Initialize data in various passes.  */
                    703: 
                    704:   init_tree ();
                    705:   init_lex ();
                    706:   init_rtl ();
1.1.1.2   root      707:   init_emit_once ();
1.1       root      708:   init_decl_processing ();
                    709:   init_optabs ();
                    710: 
                    711:   /* If rtl dump desired, open the output file.  */
                    712:   if (rtl_dump)
                    713:     {
                    714:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    715:       strcpy (dumpname, dump_base_name);
                    716:       strcat (dumpname, ".rtl");
                    717:       rtl_dump_file = fopen (dumpname, "w");
                    718:       if (rtl_dump_file == 0)
                    719:        pfatal_with_name (dumpname);
                    720:     }
                    721: 
                    722:   /* If jump_opt dump desired, open the output file.  */
                    723:   if (jump_opt_dump)
                    724:     {
                    725:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    726:       strcpy (dumpname, dump_base_name);
                    727:       strcat (dumpname, ".jump");
                    728:       jump_opt_dump_file = fopen (dumpname, "w");
                    729:       if (jump_opt_dump_file == 0)
                    730:        pfatal_with_name (dumpname);
                    731:     }
                    732: 
                    733:   /* If cse dump desired, open the output file.  */
                    734:   if (cse_dump)
                    735:     {
                    736:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    737:       strcpy (dumpname, dump_base_name);
                    738:       strcat (dumpname, ".cse");
                    739:       cse_dump_file = fopen (dumpname, "w");
                    740:       if (cse_dump_file == 0)
                    741:        pfatal_with_name (dumpname);
                    742:     }
                    743: 
                    744:   /* If loop dump desired, open the output file.  */
                    745:   if (loop_dump)
                    746:     {
                    747:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    748:       strcpy (dumpname, dump_base_name);
                    749:       strcat (dumpname, ".loop");
                    750:       loop_dump_file = fopen (dumpname, "w");
                    751:       if (loop_dump_file == 0)
                    752:        pfatal_with_name (dumpname);
                    753:     }
                    754: 
                    755:   /* If flow dump desired, open the output file.  */
                    756:   if (flow_dump)
                    757:     {
                    758:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    759:       strcpy (dumpname, dump_base_name);
                    760:       strcat (dumpname, ".flow");
                    761:       flow_dump_file = fopen (dumpname, "w");
                    762:       if (flow_dump_file == 0)
                    763:        pfatal_with_name (dumpname);
                    764:     }
                    765: 
                    766:   /* If combine dump desired, open the output file.  */
                    767:   if (combine_dump)
                    768:     {
                    769:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
                    770:       strcpy (dumpname, dump_base_name);
                    771:       strcat (dumpname, ".combine");
                    772:       combine_dump_file = fopen (dumpname, "w");
                    773:       if (combine_dump_file == 0)
                    774:        pfatal_with_name (dumpname);
                    775:     }
                    776: 
                    777:   /* If local_reg dump desired, open the output file.  */
                    778:   if (local_reg_dump)
                    779:     {
                    780:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    781:       strcpy (dumpname, dump_base_name);
                    782:       strcat (dumpname, ".lreg");
                    783:       local_reg_dump_file = fopen (dumpname, "w");
                    784:       if (local_reg_dump_file == 0)
                    785:        pfatal_with_name (dumpname);
                    786:     }
                    787: 
                    788:   /* If global_reg dump desired, open the output file.  */
                    789:   if (global_reg_dump)
                    790:     {
                    791:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    792:       strcpy (dumpname, dump_base_name);
                    793:       strcat (dumpname, ".greg");
                    794:       global_reg_dump_file = fopen (dumpname, "w");
                    795:       if (global_reg_dump_file == 0)
                    796:        pfatal_with_name (dumpname);
                    797:     }
                    798: 
1.1.1.2   root      799:   /* If jump2_opt dump desired, open the output file.  */
                    800:   if (jump2_opt_dump)
                    801:     {
                    802:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
                    803:       strcpy (dumpname, dump_base_name);
                    804:       strcat (dumpname, ".jump2");
                    805:       jump2_opt_dump_file = fopen (dumpname, "w");
                    806:       if (jump2_opt_dump_file == 0)
                    807:        pfatal_with_name (dumpname);
                    808:     }
                    809: 
1.1       root      810:   /* Open assembler code output file.  */
                    811:  
1.1.1.9   root      812:   if (! name_specified && asm_file_name == 0)
                    813:     asm_out_file = stdout;
                    814:   else
                    815:     {
                    816:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    817:       int len = strlen (dump_base_name);
                    818:       strcpy (dumpname, dump_base_name);
                    819:       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
                    820:        dumpname[len - 2] = 0;
                    821:       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
                    822:        dumpname[len - 2] = 0;
                    823:       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
                    824:        dumpname[len - 3] = 0;
                    825:       strcat (dumpname, ".s");
                    826:       if (asm_file_name == 0)
                    827:        {
                    828:          asm_file_name = (char *) malloc (strlen (dumpname) + 1);
                    829:          strcpy (asm_file_name, dumpname);
                    830:        }
                    831:       if (!strcmp (asm_file_name, "-"))
                    832:        asm_out_file = stdout;
                    833:       else
                    834:        asm_out_file = fopen (asm_file_name, "w");
                    835:       if (asm_out_file == 0)
                    836:        pfatal_with_name (asm_file_name);
                    837:     }
1.1       root      838: 
                    839:   input_filename = name;
                    840: 
                    841:   /* the beginning of the file is a new line; check for # */
                    842:   /* With luck, we discover the real source file's name from that
                    843:      and put it in input_filename.  */
1.1.1.4   root      844:   ungetc (check_newline (), finput);
                    845: 
1.1.1.8   root      846:   /* If the input doesn't start with a #line, use the input name
                    847:      as the official input file name.  */
                    848:   if (main_input_filename == 0)
                    849:     main_input_filename = name;
                    850: 
1.1.1.4   root      851:   ASM_FILE_START (asm_out_file);
1.1       root      852: 
                    853:   /* If GDB symbol table desired, open the GDB symbol output file.  */
1.1.1.4   root      854:   if (write_symbols == GDB_DEBUG)
1.1       root      855:     {
                    856:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1.1.1.2   root      857:       int len = strlen (dump_base_name);
1.1       root      858:       strcpy (dumpname, dump_base_name);
1.1.1.2   root      859:       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
                    860:        dumpname[len - 2] = 0;
1.1.1.7   root      861:       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
                    862:        dumpname[len - 2] = 0;
1.1.1.2   root      863:       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
                    864:        dumpname[len - 3] = 0;
1.1       root      865:       strcat (dumpname, ".sym");
                    866:       if (sym_file_name == 0)
                    867:        sym_file_name = dumpname;
1.1.1.4   root      868:       symout_init (sym_file_name, asm_out_file, main_input_filename);
1.1       root      869:     }
                    870: 
                    871:   /* If dbx symbol table desired, initialize writing it
                    872:      and output the predefined types.  */
1.1.1.4   root      873: #ifdef DBX_DEBUGGING_INFO
                    874:   if (write_symbols == DBX_DEBUG)
1.1.1.2   root      875:     dbxout_init (asm_out_file, main_input_filename);
1.1.1.4   root      876: #endif
                    877: #ifdef SDB_DEBUGGING_INFO
                    878:   if (write_symbols == SDB_DEBUG)
                    879:     sdbout_init (asm_out_file, main_input_filename);
                    880: #endif
1.1       root      881: 
                    882:   /* Initialize yet another pass.  */
                    883: 
1.1.1.2   root      884:   init_final (main_input_filename);
1.1       root      885: 
                    886:   start_time = gettime ();
                    887: 
                    888:   /* Call the parser, which parses the entire file
                    889:      (calling rest_of_compilation for each function).  */
                    890: 
                    891:   yyparse ();
                    892: 
                    893:   /* Compilation is now finished except for writing
                    894:      what's left of the symbol table output.  */
                    895: 
                    896:   parse_time += gettime () - start_time;
                    897: 
1.1.1.2   root      898:   parse_time -= varconst_time;
                    899: 
1.1       root      900:   globals = getdecls ();
                    901: 
1.1.1.2   root      902:   /* Really define vars that have had only a tentative definition.
                    903:      Really output inline functions that must actually be callable
                    904:      and have not been output so far.  */
                    905: 
                    906:   {
                    907:     tree decl;
                    908:     for (decl = globals; decl; decl = TREE_CHAIN (decl))
                    909:       {
                    910:        if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
                    911:            && ! TREE_ASM_WRITTEN (decl))
                    912:          rest_of_decl_compilation (decl, 0, 1, 1);
                    913:        if (TREE_CODE (decl) == FUNCTION_DECL
                    914:            && ! TREE_ASM_WRITTEN (decl)
                    915:            && DECL_INITIAL (decl) != 0
                    916:            && TREE_ADDRESSABLE (decl))
                    917:          output_inline_function (decl);
                    918:       }
                    919:   }
                    920: 
1.1       root      921:   /* Do dbx symbols */
1.1.1.4   root      922: #ifdef DBX_DEBUGGING_INFO
                    923:   if (write_symbols == DBX_DEBUG)
1.1       root      924:     TIMEVAR (symout_time,
                    925:             {
                    926:               dbxout_tags (gettags ());
                    927:               dbxout_types (get_permanent_types ());
                    928:             });
1.1.1.4   root      929: #endif
                    930: 
                    931: #ifdef SDB_DEBUGGING_INFO
                    932:   if (write_symbols == SDB_DEBUG)
                    933:     TIMEVAR (symout_time,
                    934:             {
                    935:               sdbout_tags (gettags ());
                    936:               sdbout_types (get_permanent_types ());
                    937:             });
                    938: #endif
1.1       root      939: 
                    940:   /* Do gdb symbols */
1.1.1.4   root      941:   if (write_symbols == GDB_DEBUG)
1.1       root      942:     TIMEVAR (symout_time,
                    943:             {
                    944:               struct stat statbuf;
                    945:               fstat (fileno (finput), &statbuf);
                    946:               symout_types (get_permanent_types ());
                    947:               symout_top_blocks (globals, gettags ());
                    948:               symout_finish (name, statbuf.st_ctime);
                    949:             });
                    950: 
1.1.1.2   root      951:   /* Close the dump files.  */
1.1       root      952: 
                    953:   if (rtl_dump)
                    954:     fclose (rtl_dump_file);
                    955: 
                    956:   if (jump_opt_dump)
                    957:     fclose (jump_opt_dump_file);
                    958: 
                    959:   if (cse_dump)
                    960:     fclose (cse_dump_file);
                    961: 
                    962:   if (loop_dump)
                    963:     fclose (loop_dump_file);
                    964: 
                    965:   if (flow_dump)
                    966:     fclose (flow_dump_file);
                    967: 
                    968:   if (combine_dump)
                    969:     {
                    970:       dump_combine_total_stats (combine_dump_file);
                    971:       fclose (combine_dump_file);
                    972:     }
                    973: 
                    974:   if (local_reg_dump)
                    975:     fclose (local_reg_dump_file);
                    976: 
                    977:   if (global_reg_dump)
                    978:     fclose (global_reg_dump_file);
                    979: 
1.1.1.2   root      980:   if (jump2_opt_dump)
                    981:     fclose (jump2_opt_dump_file);
                    982: 
                    983:   /* Close non-debugging input and output files.  */
                    984: 
                    985:   fclose (finput);
                    986:   if (ferror (asm_out_file) != 0)
                    987:     fatal_io_error (asm_file_name);
                    988:   fclose (asm_out_file);
                    989: 
1.1       root      990:   /* Print the times.  */
                    991: 
                    992:   if (! quiet_flag)
                    993:     {
1.1.1.2   root      994:       fprintf (stderr,"\n");
1.1       root      995:       print_time ("parse", parse_time);
1.1.1.2   root      996:       print_time ("integration", integration_time);
1.1       root      997:       print_time ("jump", jump_time);
                    998:       print_time ("cse", cse_time);
                    999:       print_time ("loop", loop_time);
                   1000:       print_time ("flow", flow_time);
                   1001:       print_time ("combine", combine_time);
                   1002:       print_time ("local-alloc", local_alloc_time);
                   1003:       print_time ("global-alloc", global_alloc_time);
                   1004:       print_time ("final", final_time);
                   1005:       print_time ("varconst", varconst_time);
                   1006:       print_time ("symout", symout_time);
                   1007:       print_time ("dump", dump_time);
                   1008:     }
                   1009: }
                   1010: 
1.1.1.2   root     1011: /* This is called from finish_decl (within yyparse)
                   1012:    for each declaration of a function or variable.
                   1013:    This does nothing for automatic variables.
                   1014:    Otherwise, it sets up the RTL and outputs any assembler code
                   1015:    (label definition, storage allocation and initialization).
                   1016: 
                   1017:    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
                   1018:    the assembler symbol name to be used.  TOP_LEVEL is nonzero
                   1019:    if this declaration is not within a function.  */
                   1020: 
                   1021: void
                   1022: rest_of_decl_compilation (decl, asmspec, top_level, at_end)
                   1023:      tree decl;
                   1024:      tree asmspec;
                   1025:      int top_level;
                   1026:      int at_end;
                   1027: {
                   1028:   /* Declarations of variables, and of functions defined elsewhere.  */
                   1029: 
                   1030:   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
                   1031:     TIMEVAR (varconst_time,
                   1032:             {
1.1.1.5   root     1033:               assemble_variable (decl, asmspec, top_level,
                   1034:                                  write_symbols, at_end);
1.1.1.2   root     1035:             });
1.1.1.4   root     1036: #ifdef DBX_DEBUGGING_INFO
                   1037:   else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
1.1.1.3   root     1038:     TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
1.1.1.4   root     1039: #endif
                   1040: #ifdef SDB_DEBUGGING_INFO
                   1041:   else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
                   1042:     TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
                   1043: #endif
1.1.1.2   root     1044: 
                   1045:   if (top_level)
                   1046:     {
1.1.1.4   root     1047:       if (write_symbols == GDB_DEBUG)
1.1.1.2   root     1048:        {
                   1049:          TIMEVAR (symout_time,
                   1050:                   {
                   1051:                     /* The initizations make types when they contain
                   1052:                        string constants.  The types are on the temporary
                   1053:                        obstack, so output them now before they go away.  */
                   1054:                     symout_types (get_temporary_types ());
                   1055:                   });
                   1056:        }
                   1057:       else
                   1058:        /* Clean out the temporary type list, since the types will go away.  */
                   1059:        get_temporary_types ();
                   1060:     }
                   1061: }
                   1062: 
1.1       root     1063: /* This is called from finish_function (within yyparse)
1.1.1.2   root     1064:    after each top-level definition is parsed.
1.1       root     1065:    It is supposed to compile that function or variable
                   1066:    and output the assembler code for it.
                   1067:    After we return, the tree storage is freed.  */
                   1068: 
                   1069: void
1.1.1.2   root     1070: rest_of_compilation (decl)
1.1       root     1071:      tree decl;
                   1072: {
                   1073:   register rtx insns;
                   1074:   int start_time = gettime ();
                   1075:   int tem;
                   1076: 
1.1.1.2   root     1077:   /* If we are reconsidering an inline function
                   1078:      at the end of compilation, skip the stuff for making it inline.  */
1.1       root     1079: 
1.1.1.2   root     1080:   if (DECL_SAVED_INSNS (decl) == 0)
1.1       root     1081:     {
                   1082: 
1.1.1.2   root     1083:       /* If requested, consider whether to make this function inline.  */
                   1084:       if (flag_inline_functions || TREE_INLINE (decl))
                   1085:        {
                   1086:          TIMEVAR (integration_time,
                   1087:                   {
                   1088:                     int specd = TREE_INLINE (decl);
                   1089:                     char *lose = function_cannot_inline_p (decl);
                   1090:                     if (lose != 0 && specd)
                   1091:                       warning_with_decl (decl, lose);
                   1092:                     if (lose == 0)
                   1093:                       save_for_inline (decl);
                   1094:                     else
                   1095:                       TREE_INLINE (decl) = 0;
                   1096:                   });
                   1097:        }
1.1       root     1098: 
1.1.1.2   root     1099:       insns = get_insns ();
1.1       root     1100: 
                   1101:       /* Dump the rtl code if we are dumping rtl.  */
                   1102: 
                   1103:       if (rtl_dump)
                   1104:        TIMEVAR (dump_time,
                   1105:                 {
                   1106:                   fprintf (rtl_dump_file, "\n;; Function %s\n\n",
                   1107:                            IDENTIFIER_POINTER (DECL_NAME (decl)));
1.1.1.2   root     1108:                   if (DECL_SAVED_INSNS (decl))
                   1109:                     fprintf (rtl_dump_file, ";; (integrable)\n\n");
1.1       root     1110:                   print_rtl (rtl_dump_file, insns);
                   1111:                   fflush (rtl_dump_file);
                   1112:                 });
                   1113: 
1.1.1.2   root     1114:       /* If function is inline, and we don't yet know whether to
                   1115:         compile it by itself, defer decision till end of compilation.
                   1116:         finish_compilation will call rest_of_compilation again
                   1117:         for those functions that need to be output.  */
                   1118: 
                   1119:       if (TREE_PUBLIC (decl) == 0
                   1120:          && TREE_INLINE (decl)
                   1121:          && ! flag_keep_inline_functions)
1.1       root     1122:        goto exit_rest_of_compilation;
1.1.1.2   root     1123:     }
1.1       root     1124: 
1.1.1.2   root     1125:   if (rtl_dump_and_exit)
                   1126:     goto exit_rest_of_compilation;
1.1       root     1127: 
1.1.1.2   root     1128:   TREE_ASM_WRITTEN (decl) = 1;
1.1       root     1129: 
1.1.1.2   root     1130:   insns = get_insns ();
1.1       root     1131: 
1.1.1.2   root     1132:   /* Copy any shared structure that should not be shared.  */
1.1       root     1133: 
1.1.1.2   root     1134:   unshare_all_rtl (insns);
1.1       root     1135: 
1.1.1.2   root     1136:   /* See if we have allocated stack slots that are not directly addressable.
                   1137:      If so, scan all the insns and create explicit address computation
                   1138:      for all references to such slots.  */
                   1139: /*   fixup_stack_slots (); */
1.1       root     1140: 
1.1.1.2   root     1141:   /* Do jump optimization the first time, if -opt.
                   1142:      Also do it if -W, but in that case it doesn't change the rtl code,
                   1143:      it only computes whether control can drop off the end of the function.  */
1.1       root     1144: 
1.1.1.2   root     1145:   if (optimize || extra_warnings || warn_return_type)
                   1146:     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1.1       root     1147: 
1.1.1.2   root     1148:   /* Dump rtl code after jump, if we are doing that.  */
1.1       root     1149: 
1.1.1.2   root     1150:   if (jump_opt_dump)
                   1151:     TIMEVAR (dump_time,
                   1152:             {
                   1153:               fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
                   1154:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1155:               print_rtl (jump_opt_dump_file, insns);
                   1156:               fflush (jump_opt_dump_file);
                   1157:             });
1.1       root     1158: 
1.1.1.2   root     1159:   /* Perform common subexpression elimination.
                   1160:      Nonzero value from `cse_main' means that jumps were simplified
                   1161:      and some code may now be unreachable, so do
                   1162:      jump optimization again.  */
1.1       root     1163: 
1.1.1.2   root     1164:   if (optimize)
                   1165:     {
                   1166:       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
1.1       root     1167: 
1.1.1.2   root     1168:       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
1.1       root     1169: 
1.1.1.2   root     1170:       if (tem)
                   1171:        TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
                   1172:     }
1.1       root     1173: 
1.1.1.2   root     1174:   /* Dump rtl code after cse, if we are doing that.  */
1.1       root     1175: 
1.1.1.2   root     1176:   if (cse_dump)
                   1177:     TIMEVAR (dump_time,
                   1178:             {
                   1179:               fprintf (cse_dump_file, "\n;; Function %s\n\n",
                   1180:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1181:               print_rtl (cse_dump_file, insns);
                   1182:               fflush (cse_dump_file);
                   1183:             });
1.1       root     1184: 
1.1.1.2   root     1185:   if (loop_dump)
                   1186:     TIMEVAR (dump_time,
                   1187:             {
                   1188:               fprintf (loop_dump_file, "\n;; Function %s\n\n",
                   1189:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1190:             });
1.1       root     1191: 
1.1.1.2   root     1192:   /* Move constant computations out of loops.  */
1.1       root     1193: 
1.1.1.2   root     1194:   if (optimize)
                   1195:     {
                   1196:       TIMEVAR (loop_time,
                   1197:               {
                   1198:                 reg_scan (insns, max_reg_num (), 1);
1.1.1.9   root     1199:                 loop_optimize (insns, loop_dump ? loop_dump_file : 0);
1.1.1.2   root     1200:               });
                   1201:     }
1.1       root     1202: 
1.1.1.2   root     1203:   /* Dump rtl code after loop opt, if we are doing that.  */
1.1       root     1204: 
1.1.1.2   root     1205:   if (loop_dump)
                   1206:     TIMEVAR (dump_time,
                   1207:             {
                   1208:               print_rtl (loop_dump_file, insns);
                   1209:               fflush (loop_dump_file);
                   1210:             });
1.1       root     1211: 
1.1.1.2   root     1212:   /* Now we choose between stupid (pcc-like) register allocation
                   1213:      (if we got the -noreg switch and not -opt)
                   1214:      and smart register allocation.  */
1.1       root     1215: 
1.1.1.2   root     1216:   if (optimize)                /* Stupid allocation probably won't work */
                   1217:     obey_regdecls = 0; /* if optimizations being done.  */
1.1       root     1218: 
1.1.1.2   root     1219:   regclass_init ();
1.1       root     1220: 
1.1.1.2   root     1221:   /* Print function header into flow dump now
                   1222:      because doing the flow analysis makes some of the dump.  */
1.1       root     1223: 
1.1.1.2   root     1224:   if (flow_dump)
                   1225:     TIMEVAR (dump_time,
                   1226:             {
                   1227:               fprintf (flow_dump_file, "\n;; Function %s\n\n",
                   1228:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1229:             });
                   1230: 
                   1231:   if (obey_regdecls)
                   1232:     {
                   1233:       TIMEVAR (flow_time,
                   1234:               {
                   1235:                 regclass (insns, max_reg_num ());
                   1236:                 stupid_life_analysis (insns, max_reg_num (),
                   1237:                                       flow_dump_file);
                   1238:               });
                   1239:     }
                   1240:   else
                   1241:     {
                   1242:       /* Do control and data flow analysis,
                   1243:         and write some of the results to dump file.  */
1.1       root     1244: 
1.1.1.2   root     1245:       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
                   1246:                                         flow_dump_file));
                   1247:       if (extra_warnings)
                   1248:        uninitialized_vars_warning (DECL_INITIAL (decl));
                   1249:     }
1.1       root     1250: 
1.1.1.2   root     1251:   /* Dump rtl after flow analysis.  */
1.1       root     1252: 
1.1.1.2   root     1253:   if (flow_dump)
                   1254:     TIMEVAR (dump_time,
                   1255:             {
                   1256:               print_rtl (flow_dump_file, insns);
                   1257:               fflush (flow_dump_file);
                   1258:             });
1.1       root     1259: 
1.1.1.2   root     1260:   /* If -opt, try combining insns through substitution.  */
1.1       root     1261: 
1.1.1.2   root     1262:   if (optimize)
                   1263:     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
1.1       root     1264: 
1.1.1.2   root     1265:   /* Dump rtl code after insn combination.  */
1.1       root     1266: 
1.1.1.2   root     1267:   if (combine_dump)
                   1268:     TIMEVAR (dump_time,
                   1269:             {
                   1270:               fprintf (combine_dump_file, "\n;; Function %s\n\n",
                   1271:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1272:               dump_combine_stats (combine_dump_file);
                   1273:               print_rtl (combine_dump_file, insns);
                   1274:               fflush (combine_dump_file);
                   1275:             });
1.1       root     1276: 
1.1.1.2   root     1277:   /* Unless we did stupid register allocation,
                   1278:      allocate pseudo-regs that are used only within 1 basic block.  */
1.1       root     1279: 
1.1.1.2   root     1280:   if (!obey_regdecls)
                   1281:     TIMEVAR (local_alloc_time,
                   1282:             {
                   1283:               regclass (insns, max_reg_num ());
                   1284:               local_alloc ();
                   1285:             });
1.1       root     1286: 
1.1.1.2   root     1287:   /* Dump rtl code after allocating regs within basic blocks.  */
1.1       root     1288: 
1.1.1.2   root     1289:   if (local_reg_dump)
                   1290:     TIMEVAR (dump_time,
                   1291:             {
                   1292:               fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
                   1293:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1294:               dump_flow_info (local_reg_dump_file);
                   1295:               dump_local_alloc (local_reg_dump_file);
                   1296:               print_rtl (local_reg_dump_file, insns);
                   1297:               fflush (local_reg_dump_file);
                   1298:             });
1.1       root     1299: 
1.1.1.2   root     1300:   if (global_reg_dump)
                   1301:     TIMEVAR (dump_time,
                   1302:             fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
                   1303:                      IDENTIFIER_POINTER (DECL_NAME (decl))));
                   1304: 
                   1305:   /* Unless we did stupid register allocation,
                   1306:      allocate remaining pseudo-regs, then do the reload pass
                   1307:      fixing up any insns that are invalid.  */
                   1308: 
                   1309:   TIMEVAR (global_alloc_time,
                   1310:           {
                   1311:             if (!obey_regdecls)
                   1312:               global_alloc (global_reg_dump ? global_reg_dump_file : 0);
                   1313:             else
                   1314:               reload (insns, 0,
                   1315:                       global_reg_dump ? global_reg_dump_file : 0);
                   1316:           });
                   1317: 
                   1318:   if (global_reg_dump)
                   1319:     TIMEVAR (dump_time,
                   1320:             {
                   1321:               dump_global_regs (global_reg_dump_file);
                   1322:               print_rtl (global_reg_dump_file, insns);
                   1323:               fflush (global_reg_dump_file);
                   1324:             });
1.1       root     1325: 
1.1.1.2   root     1326:   /* One more attempt to remove jumps to .+1
                   1327:      left by dead-store-elimination.
                   1328:      Also do cross-jumping this time
                   1329:      and delete no-op move insns.  */
1.1       root     1330: 
1.1.1.2   root     1331:   if (optimize)
                   1332:     {
                   1333:       TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
                   1334:     }
1.1       root     1335: 
1.1.1.2   root     1336:   /* Dump rtl code after jump, if we are doing that.  */
                   1337: 
                   1338:   if (jump2_opt_dump)
                   1339:     TIMEVAR (dump_time,
                   1340:             {
                   1341:               fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
                   1342:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1343:               print_rtl (jump2_opt_dump_file, insns);
                   1344:               fflush (jump2_opt_dump_file);
                   1345:             });
                   1346: 
                   1347:   /* Now turn the rtl into assembler code.  */
                   1348: 
                   1349:   TIMEVAR (final_time,
                   1350:           {
                   1351:             assemble_function (decl);
                   1352:             final_start_function (insns, asm_out_file,
                   1353:                                   write_symbols, optimize);
                   1354:             final (insns, asm_out_file,
1.1.1.9   root     1355:                    write_symbols, optimize, 0);
1.1.1.2   root     1356:             final_end_function (insns, asm_out_file,
                   1357:                                 write_symbols, optimize);
                   1358:             fflush (asm_out_file);
                   1359:           });
1.1       root     1360: 
1.1.1.2   root     1361:   /* Write GDB symbols if requested */
1.1       root     1362: 
1.1.1.4   root     1363:   if (write_symbols == GDB_DEBUG)
1.1.1.2   root     1364:     {
                   1365:       TIMEVAR (symout_time,
                   1366:               {
                   1367:                 symout_types (get_permanent_types ());
                   1368:                 symout_types (get_temporary_types ());
                   1369: 
                   1370:                 DECL_BLOCK_SYMTAB_ADDRESS (decl)
                   1371:                   = symout_function (DECL_INITIAL (decl),
                   1372:                                      DECL_ARGUMENTS (decl), 0);
1.1.1.6   root     1373:                 symout_function_end ();
1.1.1.2   root     1374:               });
1.1       root     1375:     }
1.1.1.2   root     1376:   else
                   1377:     get_temporary_types ();
                   1378: 
                   1379:   /* Write DBX symbols if requested */
                   1380: 
1.1.1.4   root     1381: #ifdef DBX_DEBUGGING_INFO
                   1382:   if (write_symbols == DBX_DEBUG)
1.1.1.2   root     1383:     TIMEVAR (symout_time, dbxout_function (decl));
1.1.1.4   root     1384: #endif
1.1       root     1385: 
                   1386:  exit_rest_of_compilation:
                   1387: 
1.1.1.8   root     1388:   /* Clear out the real_constant_chain before some of the rtx's
                   1389:      it runs through become garbage.  */
                   1390: 
                   1391:   clear_const_double_mem ();
                   1392: 
1.1       root     1393:   /* The parsing time is all the time spent in yyparse
                   1394:      *except* what is spent in this function.  */
                   1395: 
                   1396:   parse_time -= gettime () - start_time;
                   1397: }
                   1398: 
                   1399: /* Entry point of cc1.  Decode command args, then call compile_file.
1.1.1.2   root     1400:    Exit code is 35 if can't open files, 34 if fatal error,
                   1401:    33 if had nonfatal errors, else success.  */
1.1       root     1402: 
                   1403: int
                   1404: main (argc, argv, envp)
                   1405:      int argc;
                   1406:      char **argv;
                   1407:      char **envp;
                   1408: {
                   1409:   register int i;
1.1.1.2   root     1410:   char *filename = 0;
                   1411:   int print_mem_flag = 0;
                   1412: 
                   1413: #ifdef RLIMIT_STACK
                   1414:   /* Get rid of any avoidable limit on stack size.  */
                   1415:   {
                   1416:     struct rlimit rlim;
                   1417: 
                   1418:     /* Set the stack limit huge so that alloca does not fail. */
                   1419:     getrlimit (RLIMIT_STACK, &rlim);
                   1420:     rlim.rlim_cur = rlim.rlim_max;
                   1421:     setrlimit (RLIMIT_STACK, &rlim);
                   1422:   }
                   1423: #endif /* RLIMIT_STACK */
                   1424: 
1.1.1.10! root     1425:   signal (SIGFPE, float_signal);
        !          1426: 
1.1.1.2   root     1427:   /* Initialize whether `char' is signed.  */
                   1428:   flag_signed_char = DEFAULT_SIGNED_CHAR;
                   1429: 
1.1.1.4   root     1430:   /* This is zeroed by -O.  */
                   1431:   obey_regdecls = 1;
                   1432: 
                   1433:   /* Initialize register usage now so switches may override.  */
1.1.1.2   root     1434:   init_reg_sets ();
1.1       root     1435: 
                   1436:   target_flags = 0;
                   1437:   set_target_switch ("");
                   1438: 
                   1439:   for (i = 1; i < argc; i++)
                   1440:     if (argv[i][0] == '-')
                   1441:       {
                   1442:        register char *str = argv[i] + 1;
                   1443:        if (str[0] == 'Y')
                   1444:          str++;
                   1445: 
                   1446:        if (str[0] == 'm')
                   1447:          set_target_switch (&str[1]);
                   1448:        else if (!strcmp (str, "dumpbase"))
                   1449:          {
                   1450:            dump_base_name = argv[++i];
                   1451:          }
                   1452:        else if (str[0] == 'd')
                   1453:          {
                   1454:            register char *p = &str[1];
                   1455:            while (*p)
                   1456:              switch (*p++)
                   1457:                {
                   1458:                case 'c':
                   1459:                  combine_dump = 1;
                   1460:                  break;
                   1461:                case 'f':
                   1462:                  flow_dump = 1;
                   1463:                  break;
                   1464:                case 'g':
                   1465:                  global_reg_dump = 1;
                   1466:                  break;
                   1467:                case 'j':
                   1468:                  jump_opt_dump = 1;
                   1469:                  break;
1.1.1.2   root     1470:                case 'J':
                   1471:                  jump2_opt_dump = 1;
                   1472:                  break;
1.1       root     1473:                case 'l':
                   1474:                  local_reg_dump = 1;
                   1475:                  break;
                   1476:                case 'L':
                   1477:                  loop_dump = 1;
                   1478:                  break;
1.1.1.2   root     1479:                case 'm':
                   1480:                  print_mem_flag = 1;
                   1481:                  break;
1.1       root     1482:                case 'r':
                   1483:                  rtl_dump = 1;
                   1484:                  break;
                   1485:                case 's':
                   1486:                  cse_dump = 1;
                   1487:                  break;
                   1488:                case 'y':
                   1489:                  yydebug = 1;
                   1490:                  break;
                   1491:                }
                   1492:          }
1.1.1.2   root     1493:        else if (str[0] == 'f')
                   1494:          {
                   1495:            register char *p = &str[1];
                   1496:            if (!strcmp (p, "float-store"))
                   1497:              flag_float_store = 1;
                   1498:            else if (!strcmp (p, "volatile"))
                   1499:              flag_volatile = 1;
                   1500:            else if (!strcmp (p, "defer-pop"))
                   1501:              flag_defer_pop = 1;
                   1502:            else if (!strcmp (p, "no-defer-pop"))
                   1503:              flag_defer_pop = 0;
                   1504:            else if (!strcmp (p, "omit-frame-pointer"))
                   1505:              flag_omit_frame_pointer = 1;
                   1506:            else if (!strcmp (p, "no-omit-frame-pointer"))
                   1507:              flag_omit_frame_pointer = 0;
1.1.1.9   root     1508:            else if (!strcmp (p, "strength-reduce"))
                   1509:              flag_strength_reduce = 1;
1.1.1.7   root     1510:            else if (!strcmp (p, "writable-strings"))
                   1511:              flag_writable_strings = 1;
1.1.1.2   root     1512:            else if (!strcmp (p, "no-peephole"))
                   1513:              flag_no_peephole = 1;
                   1514:            else if (!strcmp (p, "force-mem"))
                   1515:              flag_force_mem = 1;
                   1516:            else if (!strcmp (p, "force-addr"))
                   1517:              flag_force_addr = 1;
                   1518:            else if (!strcmp (p, "combine-regs"))
                   1519:              flag_combine_regs = 1;
                   1520:            else if (!strcmp (p, "no-function-cse"))
                   1521:              flag_no_function_cse = 1;
                   1522:            else if (!strncmp (p, "fixed-", 6))
                   1523:              fix_register (&p[6], 1, 1);
                   1524:            else if (!strncmp (p, "call-used-", 10))
                   1525:              fix_register (&p[10], 0, 1);
                   1526:            else if (!strncmp (p, "call-saved-", 11))
                   1527:              fix_register (&p[11], 0, 0);
                   1528:            else if (!strcmp (p, "inline-functions"))
                   1529:              flag_inline_functions = 1;
                   1530:            else if (!strcmp (p, "keep-inline-functions"))
                   1531:              flag_keep_inline_functions = 1;
1.1.1.7   root     1532:            else if (! lang_decode_option (argv[i]))
                   1533:              error ("Invalid option `%s'", argv[i]);         
1.1.1.2   root     1534:          }
1.1       root     1535:        else if (!strcmp (str, "noreg"))
1.1.1.4   root     1536:          ;
1.1.1.2   root     1537:        else if (!strcmp (str, "opt"))
1.1.1.4   root     1538:          optimize = 1, obey_regdecls = 0;
                   1539:        else if (!strcmp (str, "O"))
                   1540:          optimize = 1, obey_regdecls = 0;
1.1.1.2   root     1541:        else if (!strcmp (str, "pedantic"))
                   1542:          pedantic = 1;
1.1.1.7   root     1543:        else if (lang_decode_option (argv[i]))
                   1544:          ;
1.1.1.2   root     1545:        else if (!strcmp (str, "quiet"))
                   1546:          quiet_flag = 1;
                   1547:        else if (!strcmp (str, "version"))
                   1548:          {
1.1.1.7   root     1549:            extern char *version_string, *language_string;
                   1550:            printf ("%s version %s", language_string, version_string);
1.1.1.2   root     1551: #ifdef TARGET_VERSION
                   1552:            TARGET_VERSION;
                   1553: #endif
                   1554: #ifdef __GNUC__
                   1555: #ifndef __VERSION__
                   1556: #define __VERSION__ "[unknown]"
                   1557: #endif
                   1558:            printf (" compiled by GNU C version %s.\n", __VERSION__);
                   1559: #else
                   1560:            printf (" compiled by CC.\n");
                   1561: #endif
                   1562:          }
1.1       root     1563:        else if (!strcmp (str, "w"))
                   1564:          inhibit_warnings = 1;
1.1.1.2   root     1565:        else if (!strcmp (str, "W"))
                   1566:          extra_warnings = 1;
1.1.1.9   root     1567:        else if (!strcmp (str, "Wunused"))
                   1568:          warn_unused = 1;
1.1.1.2   root     1569:        else if (!strcmp (str, "p"))
                   1570:          profile_flag = 1;
1.1.1.4   root     1571:        else if (!strcmp (str, "gg"))
                   1572:          write_symbols = GDB_DEBUG;
                   1573: #ifdef DBX_DEBUGGING_INFO
1.1       root     1574:        else if (!strcmp (str, "g"))
1.1.1.4   root     1575:          write_symbols = DBX_DEBUG;
1.1       root     1576:        else if (!strcmp (str, "G"))
1.1.1.4   root     1577:          write_symbols = DBX_DEBUG;
                   1578: #endif
                   1579: #ifdef SDB_DEBUGGING_INFO
                   1580:        else if (!strcmp (str, "g"))
                   1581:          write_symbols = SDB_DEBUG;
                   1582:        else if (!strcmp (str, "G"))
                   1583:          write_symbols = SDB_DEBUG;
                   1584: #endif
1.1       root     1585:        else if (!strcmp (str, "symout"))
                   1586:          {
1.1.1.4   root     1587:            if (write_symbols == NO_DEBUG)
                   1588:              write_symbols = GDB_DEBUG;
1.1       root     1589:            sym_file_name = argv[++i];
                   1590:          }
                   1591:        else if (!strcmp (str, "o"))
                   1592:          {
                   1593:            asm_file_name = argv[++i];
                   1594:          }
                   1595:        else
1.1.1.7   root     1596:          error ("Invalid option `%s'", argv[i]);
1.1       root     1597:       }
                   1598:     else
                   1599:       filename = argv[i];
                   1600: 
1.1.1.2   root     1601: #ifdef OVERRIDE_OPTIONS
                   1602:   /* Some machines may reject certain combinations of options.  */
                   1603:   OVERRIDE_OPTIONS;
                   1604: #endif
                   1605: 
1.1.1.4   root     1606:   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
                   1607:   init_reg_sets_1 ();
                   1608: 
1.1       root     1609:   compile_file (filename);
                   1610: 
1.1.1.2   root     1611: #ifndef USG
                   1612: #ifndef VMS
                   1613:   if (print_mem_flag)
                   1614:     {
                   1615:       extern char **environ;
                   1616:       caddr_t lim = (caddr_t) sbrk (0);
                   1617:       
                   1618:       fprintf (stderr, "Data size %d.\n",
                   1619:               (int) lim - (int) &environ);
                   1620:       fflush (stderr);
                   1621: 
                   1622:       system ("ps v");
                   1623:     }
                   1624: #endif /* not VMS */
                   1625: #endif /* not USG */
                   1626: 
1.1       root     1627:   if (errorcount)
1.1.1.2   root     1628:     exit (FATAL_EXIT_CODE);
1.1.1.7   root     1629:   if (sorrycount)
                   1630:     exit (FATAL_EXIT_CODE);
1.1.1.2   root     1631:   exit (SUCCESS_EXIT_CODE);
                   1632:   return 34;
1.1       root     1633: }
                   1634: 
                   1635: /* Decode -m switches.  */
                   1636: 
                   1637: /* Here is a table, controlled by the tm-...h file, listing each -m switch
                   1638:    and which bits in `target_switches' it should set or clear.
                   1639:    If VALUE is positive, it is bits to set.
                   1640:    If VALUE is negative, -VALUE is bits to clear.
                   1641:    (The sign bit is not used so there is no confusion.)  */
                   1642: 
                   1643: struct {char *name; int value;} target_switches []
                   1644:   = TARGET_SWITCHES;
                   1645: 
                   1646: /* Decode the switch -mNAME.  */
                   1647: 
1.1.1.2   root     1648: void
1.1       root     1649: set_target_switch (name)
                   1650:      char *name;
                   1651: {
1.1.1.2   root     1652:   register int j;
1.1       root     1653:   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
                   1654:     if (!strcmp (target_switches[j].name, name))
                   1655:       {
                   1656:        if (target_switches[j].value < 0)
                   1657:          target_flags &= ~-target_switches[j].value;
                   1658:        else
                   1659:          target_flags |= target_switches[j].value;
1.1.1.7   root     1660:        return;
1.1       root     1661:       }
1.1.1.7   root     1662:   error ("Invalid option `%s'", name);
1.1       root     1663: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.