Annotation of gcc/toplev.c, revision 1.1.1.6

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

unix.superglobalmegacorp.com

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