Annotation of gcc/toplev.c, revision 1.1.1.9

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

unix.superglobalmegacorp.com

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