Annotation of gcc/toplev.c, revision 1.1.1.7

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

unix.superglobalmegacorp.com

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