Annotation of gcc/toplev.c, revision 1.1.1.16

1.1       root        1: /* Top level of GNU C compiler
1.1.1.14  root        2:    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
1.1       root        3: 
                      4: This file is part of GNU CC.
                      5: 
1.1.1.14  root        6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 1, or (at your option)
                      9: any later version.
                     10: 
1.1       root       11: GNU CC is distributed in the hope that it will be useful,
1.1.1.14  root       12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
1.1       root       19: 
                     20: 
                     21: /* This is the top level of cc1.
                     22:    It parses command args, opens files, invokes the various passes
                     23:    in the proper order, and counts the time used by each.
                     24:    Error messages and low-level interface to malloc also handled here.  */
                     25: 
                     26: #include "config.h"
                     27: #include <stdio.h>
                     28: #include <signal.h>
1.1.1.10  root       29: #include <setjmp.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
1.1.1.16! root       35: #undef FLOAT
1.1.1.2   root       36: #include <sys/param.h>
1.1.1.16! root       37: /* This is for hpux.  It is a real screw.  They should change hpux.  */
        !            38: #undef FLOAT
1.1.1.2   root       39: #include <sys/times.h>
                     40: #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
                     41: #else
                     42: #ifndef VMS
1.1       root       43: #include <sys/time.h>
                     44: #include <sys/resource.h>
1.1.1.2   root       45: #endif
                     46: #endif
                     47: 
1.1.1.16! root       48: #include "input.h"
1.1       root       49: #include "tree.h"
                     50: #include "c-tree.h"
                     51: #include "rtl.h"
1.1.1.2   root       52: #include "flags.h"
1.1       root       53: 
                     54: extern int yydebug;
                     55: 
                     56: extern FILE *finput;
                     57: 
1.1.1.11  root       58: extern int reload_completed;
1.1.1.12  root       59: extern int rtx_equal_function_value_matters;
1.1.1.11  root       60: 
1.1       root       61: extern void init_lex ();
                     62: extern void init_decl_processing ();
                     63: extern void init_tree ();
                     64: extern void init_rtl ();
                     65: extern void init_optabs ();
1.1.1.2   root       66: extern void init_reg_sets ();
1.1       root       67: extern void dump_flow_info ();
                     68: extern void dump_local_alloc ();
                     69: 
1.1.1.2   root       70: void rest_of_decl_compilation ();
                     71: void error ();
                     72: void error_with_file_and_line ();
1.1.1.16! root       73: void fancy_abort ();
1.1.1.2   root       74: void set_target_switch ();
1.1.1.16! root       75: void print_target_switch_defaults ();
1.1.1.2   root       76: 
1.1       root       77: /* Bit flags that specify the machine subtype we are compiling for.
                     78:    Bits are tested using macros TARGET_... defined in the tm-...h file
                     79:    and set by `-m...' switches.  */
                     80: 
                     81: int target_flags;
                     82: 
1.1.1.2   root       83: /* Name of current original source file (what was input to cpp).
                     84:    This comes from each #-command in the actual input.  */
1.1       root       85: 
1.1.1.2   root       86: char *input_filename;
                     87: 
                     88: /* Name of top-level original source file (what was input to cpp).
1.1.1.8   root       89:    This comes from the #-command at the beginning of the actual input.
                     90:    If there isn't any there, then this is the cc1 input file name.  */
1.1.1.2   root       91: 
                     92: char *main_input_filename;
1.1       root       93: 
                     94: /* Current line number in real source file.  */
                     95: 
1.1.1.16! root       96: int lineno;
        !            97: 
        !            98: /* Stack of currently pending input files.  */
        !            99: 
        !           100: struct file_stack *input_file_stack;
        !           101: 
        !           102: /* Incremented on each change to input_file_stack.  */
        !           103: int input_file_stack_tick;
1.1       root      104: 
                    105: /* FUNCTION_DECL for function now being parsed or compiled.  */
                    106: 
                    107: extern tree current_function_decl;
                    108: 
                    109: /* Name to use as base of names for dump output files.  */
                    110: 
                    111: char *dump_base_name;
                    112: 
                    113: /* Flags saying which kinds of debugging dump have been requested.  */
                    114: 
                    115: int rtl_dump = 0;
                    116: int rtl_dump_and_exit = 0;
                    117: int jump_opt_dump = 0;
                    118: int cse_dump = 0;
                    119: int loop_dump = 0;
                    120: int flow_dump = 0;
                    121: int combine_dump = 0;
                    122: int local_reg_dump = 0;
                    123: int global_reg_dump = 0;
1.1.1.2   root      124: int jump2_opt_dump = 0;
1.1.1.16! root      125: int dbr_sched_dump = 0;
1.1       root      126: 
                    127: /* 1 => write gdb debugging output (using symout.c).  -g
1.1.1.6   root      128:    2 => write dbx debugging output (using dbxout.c).  -G
                    129:    3 => write sdb debugging output (using sdbout.c).  -g.  */
1.1       root      130: 
1.1.1.4   root      131: enum debugger write_symbols = NO_DEBUG;
1.1       root      132: 
1.1.1.6   root      133: /* Nonzero means can use our own extensions to DBX format.
                    134:    Relevant only with write_symbols == DBX_DEBUG.  */
                    135: 
                    136: int use_gdb_dbx_extensions;
                    137: 
1.1       root      138: /* Nonzero means do optimizations.  -opt.  */
                    139: 
                    140: int optimize = 0;
                    141: 
1.1.1.16! root      142: /* Nonzero means `char' should be signed.  */
        !           143: 
        !           144: int flag_signed_char;
        !           145: 
        !           146: /* Nonzero means give an enum type only as many bytes as it needs.  */
        !           147: 
        !           148: int flag_short_enums;
        !           149: 
1.1.1.14  root      150: /* Nonzero for -fcaller-saves: allocate values in regs that need to
                    151:    be saved across function calls, if that produces overall better code.
                    152:    Optional now, so people can test it.  */
                    153: 
                    154: #ifdef DEFAULT_CALLER_SAVES
                    155: int flag_caller_saves = 1;
                    156: #else
                    157: int flag_caller_saves = 0;
                    158: #endif
                    159: 
                    160: /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
                    161: 
                    162: int flag_pcc_struct_return = 0;
                    163: 
1.1.1.2   root      164: /* Nonzero for -fforce-mem: load memory value into a register
1.1       root      165:    before arithmetic on it.  This makes better cse but slower compilation.  */
                    166: 
1.1.1.2   root      167: int flag_force_mem = 0;
1.1       root      168: 
1.1.1.2   root      169: /* Nonzero for -fforce-addr: load memory address into a register before
1.1       root      170:    reference to memory.  This makes better cse but slower compilation.  */
                    171: 
1.1.1.2   root      172: int flag_force_addr = 0;
                    173: 
                    174: /* Nonzero for -fdefer-pop: don't pop args after each function call;
                    175:    instead save them up to pop many calls' args with one insns.  */
                    176: 
                    177: int flag_defer_pop = 1;
                    178: 
                    179: /* Nonzero for -ffloat-store: don't allocate floats and doubles
                    180:    in extended-precision registers.  */
                    181: 
                    182: int flag_float_store = 0;
                    183: 
                    184: /* Nonzero for -fcombine-regs:
                    185:    allow instruction combiner to combine an insn
                    186:    that just copies one reg to another.  */
                    187: 
                    188: int flag_combine_regs = 0;
                    189: 
1.1.1.9   root      190: /* Nonzero enables strength-reduction in loop.c.  */
                    191: 
                    192: int flag_strength_reduce = 0;
                    193: 
1.1.1.2   root      194: /* Nonzero for -fwritable-strings:
                    195:    store string constants in data segment and don't uniquize them.  */
                    196: 
                    197: int flag_writable_strings = 0;
                    198: 
                    199: /* Nonzero means don't put addresses of constant functions in registers.
                    200:    Used for compiling the Unix kernel, where strange substitutions are
                    201:    done on the assembly output.  */
                    202: 
                    203: int flag_no_function_cse = 0;
                    204: 
                    205: /* Nonzero for -fomit-frame-pointer:
                    206:    don't make a frame pointer in simple functions that don't require one.  */
                    207: 
                    208: int flag_omit_frame_pointer = 0;
                    209: 
                    210: /* Nonzero to inhibit use of define_optimization peephole opts.  */
                    211: 
                    212: int flag_no_peephole = 0;
                    213: 
                    214: /* Nonzero means all references through pointers are volatile.  */
                    215: 
                    216: int flag_volatile;
1.1       root      217: 
1.1.1.16! root      218: /* Nonzero means just do syntax checking; don't output anything.  */
        !           219: 
        !           220: int flag_syntax_only = 0;
        !           221: 
1.1       root      222: /* Nonzero means do stupid register allocation.  -noreg.
1.1.1.2   root      223:    This and `optimize' are controlled by different switches in cc1,
1.1       root      224:    but normally cc controls them both with the -O switch.  */
                    225: 
                    226: int obey_regdecls = 0;
                    227: 
                    228: /* Don't print functions as they are compiled and don't print
                    229:    times taken by the various passes.  -quiet.  */
                    230: 
                    231: int quiet_flag = 0;
                    232: 
                    233: /* Don't print warning messages.  -w.  */
                    234: 
                    235: int inhibit_warnings = 0;
                    236: 
1.1.1.2   root      237: /* Do print extra warnings (such as for uninitialized variables).  -W.  */
                    238: 
                    239: int extra_warnings = 0;
                    240: 
1.1.1.9   root      241: /* Nonzero to warn about unused local variables.  */
                    242: 
                    243: int warn_unused;
                    244: 
1.1.1.15  root      245: /* Nonzero means warn about all declarations which shadow others.   */
                    246: 
                    247: int warn_shadow;
                    248: 
                    249: /* Warn if a switch on an enum fails to have a case for every enum value.  */
                    250: 
                    251: int warn_switch;
                    252: 
                    253: /* Nonzero means warn about any identifiers that match in the first N
                    254:    characters.  The value N is in `id_clash_len'.  */
                    255: 
                    256: int warn_id_clash;
                    257: int id_clash_len;
                    258: 
1.1       root      259: /* Number of error messages and warning messages so far.  */
                    260: 
                    261: int errorcount = 0;
                    262: int warningcount = 0;
1.1.1.7   root      263: int sorrycount = 0;
1.1       root      264: 
1.1.1.16! root      265: /* Name of program invoked, sans directories.  */
        !           266: 
        !           267: char *progname;
        !           268: 
1.1.1.2   root      269: /* Nonzero if generating code to do profiling.  */
                    270: 
                    271: int profile_flag = 0;
                    272: 
1.1.1.14  root      273: /* Nonzero if generating code to do profiling on a line-by-line basis.  */
                    274: 
                    275: int profile_block_flag;
                    276: 
1.1       root      277: /* Nonzero for -pedantic switch: warn about anything
1.1.1.7   root      278:    that standard spec forbids.  */
1.1       root      279: 
                    280: int pedantic = 0;
                    281: 
1.1.1.2   root      282: /* Nonzero for -finline-functions: ok to inline functions that look like
                    283:    good inline candidates.  */
                    284: 
                    285: int flag_inline_functions;
                    286: 
                    287: /* Nonzero for -fkeep-inline-functions: even if we make a function
                    288:    go inline everywhere, keep its defintion around for debugging
                    289:    purposes.  */
                    290: 
                    291: int flag_keep_inline_functions;
                    292: 
1.1.1.12  root      293: /* Nonzero means make the text shared if supported.  */
                    294: 
                    295: int flag_shared_data;
                    296: 
1.1.1.16! root      297: /* Nonzero means schedule into delayed branch slots if supported.  */
        !           298: 
        !           299: int flag_delayed_branch;
        !           300: 
        !           301: /* Copy of arguments to main.  */
        !           302: int save_argc;
        !           303: char **save_argv;
        !           304: 
1.1       root      305: /* Name for output file of assembly code, specified with -o.  */
                    306: 
                    307: char *asm_file_name;
                    308: 
                    309: /* Name for output file of GDB symbol segment, specified with -symout.  */
                    310: 
                    311: char *sym_file_name;
                    312: 
1.1.1.12  root      313: /* Table of language-independent -f options.
                    314:    STRING is the option name.  VARIABLE is the address of the variable.
                    315:    ON_VALUE is the value to store in VARIABLE
                    316:     if `-fSTRING' is seen as an option.
                    317:    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
                    318: 
                    319: struct { char *string; int *variable; int on_value;} f_options[] =
                    320: {
                    321:   {"float-store", &flag_float_store, 1},
                    322:   {"volatile", &flag_volatile, 1},
                    323:   {"defer-pop", &flag_defer_pop, 1},
                    324:   {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
                    325:   {"strength-reduce", &flag_strength_reduce, 1},
                    326:   {"writable-strings", &flag_writable_strings, 1},
                    327:   {"peephole", &flag_no_peephole, 0},
                    328:   {"force-mem", &flag_force_mem, 1},
                    329:   {"force-addr", &flag_force_addr, 1},
                    330:   {"combine-regs", &flag_combine_regs, 1},
                    331:   {"function-cse", &flag_no_function_cse, 0},
                    332:   {"inline-functions", &flag_inline_functions, 1},
                    333:   {"keep-inline-functions", &flag_keep_inline_functions, 1},
                    334:   {"syntax-only", &flag_syntax_only, 1},
1.1.1.14  root      335:   {"shared-data", &flag_shared_data, 1},
                    336:   {"caller-saves", &flag_caller_saves, 1},
1.1.1.16! root      337:   {"pcc-struct-return", &flag_pcc_struct_return, 1},
        !           338:   {"delayed-branch", &flag_delayed_branch, 1}
1.1.1.12  root      339: };
                    340: 
1.1       root      341: /* Output files for assembler code (real compiler output)
                    342:    and debugging dumps.  */
                    343: 
                    344: FILE *asm_out_file;
                    345: FILE *rtl_dump_file;
                    346: FILE *jump_opt_dump_file;
                    347: FILE *cse_dump_file;
                    348: FILE *loop_dump_file;
                    349: FILE *flow_dump_file;
                    350: FILE *combine_dump_file;
                    351: FILE *local_reg_dump_file;
                    352: FILE *global_reg_dump_file;
1.1.1.2   root      353: FILE *jump2_opt_dump_file;
1.1.1.16! root      354: FILE *dbr_sched_dump_file;
1.1       root      355: 
                    356: /* Time accumulators, to count the total time spent in various passes.  */
                    357: 
                    358: int parse_time;
                    359: int varconst_time;
1.1.1.2   root      360: int integration_time;
1.1       root      361: int jump_time;
                    362: int cse_time;
                    363: int loop_time;
                    364: int flow_time;
                    365: int combine_time;
                    366: int local_alloc_time;
                    367: int global_alloc_time;
1.1.1.16! root      368: int dbr_sched_time;
1.1       root      369: int final_time;
                    370: int symout_time;
                    371: int dump_time;
                    372: 
                    373: /* Return time used so far, in microseconds.  */
                    374: 
1.1.1.2   root      375: int
1.1       root      376: gettime ()
                    377: {
1.1.1.2   root      378: #ifdef USG
                    379:   struct tms tms;
                    380: #else
                    381: #ifndef VMS
1.1       root      382:   struct rusage rusage;
1.1.1.2   root      383: #else /* VMS */
                    384:   struct
                    385:     {
                    386:       int proc_user_time;
                    387:       int proc_system_time;
                    388:       int child_user_time;
                    389:       int child_system_time;
                    390:     } vms_times;
                    391: #endif
                    392: #endif
                    393: 
1.1       root      394:   if (quiet_flag)
                    395:     return 0;
1.1.1.2   root      396: 
                    397: #ifdef USG
                    398:   times (&tms);
                    399:   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
                    400: #else
                    401: #ifndef VMS
1.1       root      402:   getrusage (0, &rusage);
                    403:   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
                    404:          + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1.1.1.2   root      405: #else /* VMS */
                    406:   times (&vms_times);
                    407:   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
                    408: #endif
                    409: #endif
1.1       root      410: }
                    411: 
                    412: #define TIMEVAR(VAR, BODY)    \
1.1.1.3   root      413: do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
1.1       root      414: 
1.1.1.2   root      415: void
1.1       root      416: print_time (str, total)
                    417:      char *str;
                    418:      int total;
                    419: {
1.1.1.2   root      420:   fprintf (stderr,
                    421:           "time in %s: %d.%06d\n",
                    422:           str, total / 1000000, total % 1000000);
1.1       root      423: }
                    424: 
                    425: /* Count an error or warning.  Return 1 if the message should be printed.  */
                    426: 
                    427: int
                    428: count_error (warningp)
                    429:      int warningp;
                    430: {
                    431:   if (warningp && inhibit_warnings)
                    432:     return 0;
                    433: 
                    434:   if (warningp)
                    435:     warningcount++;
                    436:   else
                    437:     errorcount++;
                    438: 
                    439:   return 1;
                    440: }
                    441: 
                    442: /* Print a fatal error message.  NAME is the text.
                    443:    Also include a system error message based on `errno'.  */
                    444: 
1.1.1.2   root      445: void
1.1       root      446: pfatal_with_name (name)
1.1.1.2   root      447:      char *name;
1.1       root      448: {
1.1.1.16! root      449:   fprintf (stderr, "%s: ", progname);
1.1       root      450:   perror (name);
                    451:   exit (35);
                    452: }
                    453: 
                    454: void
1.1.1.2   root      455: fatal_io_error (name)
                    456:      char *name;
                    457: {
1.1.1.16! root      458:   fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1.1.1.2   root      459:   exit (35);
                    460: }
                    461: 
                    462: void
1.1.1.7   root      463: fatal (s, v)
1.1       root      464:      char *s;
1.1.1.16! root      465:      int v;
1.1       root      466: {
1.1.1.7   root      467:   error (s, v);
1.1       root      468:   exit (34);
                    469: }
1.1.1.16! root      470: 
        !           471: /* Called from insn-extract to give a better error message when we
        !           472:    don't have an insn to match what we are looking for, rather
        !           473:    than just calling abort().  */
        !           474: 
        !           475: void
        !           476: fatal_insn_not_found (insn)
        !           477:      rtx insn;
        !           478: {
        !           479:   error ("The following insn was not recognizable:", 0);
        !           480:   debug_rtx (insn);
        !           481:   abort ();
        !           482: }
1.1.1.8   root      483: 
                    484: static int need_error_newline;
                    485: 
                    486: /* Function of last error message;
                    487:    more generally, function such that if next error message is in it
                    488:    then we don't have to mention the function name.  */
                    489: static tree last_error_function = NULL;
1.1       root      490: 
1.1.1.16! root      491: /* Used to detect when input_file_stack has changed since last described.  */
        !           492: static int last_error_tick;
        !           493: 
1.1       root      494: /* Called when the start of a function definition is parsed,
                    495:    this function prints on stderr the name of the function.  */
                    496: 
                    497: void
                    498: announce_function (decl)
                    499:      tree decl;
                    500: {
                    501:   if (! quiet_flag)
                    502:     {
1.1.1.16! root      503:       fprintf (stderr, " %s", DECL_PRINT_NAME (decl));
1.1       root      504:       fflush (stderr);
1.1.1.9   root      505:       need_error_newline = 1;
                    506:       last_error_function = current_function_decl;
1.1       root      507:     }
                    508: }
1.1.1.8   root      509: 
1.1.1.2   root      510: /* Prints out, if necessary, the name of the current function
                    511:    which caused an error.  Called from all error and warning functions.  */
                    512: 
1.1.1.16! root      513: void
1.1.1.9   root      514: report_error_function (file)
                    515:      char *file;
1.1.1.2   root      516: {
1.1.1.16! root      517:   struct file_stack *p;
        !           518: 
1.1.1.8   root      519:   if (need_error_newline)
                    520:     {
                    521:       fprintf (stderr, "\n");
                    522:       need_error_newline = 0;
                    523:     }
1.1.1.2   root      524: 
                    525:   if (last_error_function != current_function_decl)
                    526:     {
1.1.1.9   root      527:       if (file)
                    528:        fprintf (stderr, "%s: ", file);
                    529: 
1.1.1.2   root      530:       if (current_function_decl == NULL)
1.1.1.8   root      531:        fprintf (stderr, "At top level:\n");
1.1.1.16! root      532:       else if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
        !           533:        fprintf (stderr, "In method %s:\n",
        !           534:                 DECL_PRINT_NAME (current_function_decl));
1.1.1.2   root      535:       else
1.1.1.8   root      536:        fprintf (stderr, "In function %s:\n",
1.1.1.16! root      537:                 DECL_PRINT_NAME (current_function_decl));
1.1.1.8   root      538: 
1.1.1.2   root      539:       last_error_function = current_function_decl;
                    540:     }
1.1.1.16! root      541:   if (input_file_stack && input_file_stack->next != 0
        !           542:       && input_file_stack_tick != last_error_tick)
        !           543:     {
        !           544:       fprintf (stderr, "In file included");
        !           545:       for (p = input_file_stack->next; p; p = p->next)
        !           546:        {
        !           547:          fprintf (stderr, " from %s:%d", p->name, p->line);
        !           548:          if (p->next)
        !           549:            fprintf (stderr, ",");
        !           550:        }
        !           551:       fprintf (stderr, ":\n");
        !           552:       last_error_tick = input_file_stack_tick;
        !           553:     }
1.1.1.2   root      554: }
1.1       root      555: 
                    556: /* Report an error at the current line number.
                    557:    S and V are a string and an arg for `printf'.  */
                    558: 
                    559: void
1.1.1.7   root      560: error (s, v, v2)
1.1       root      561:      char *s;
                    562:      int v;                    /* @@also used as pointer */
1.1.1.7   root      563:      int v2;                   /* @@also used as pointer */
1.1       root      564: {
1.1.1.7   root      565:   error_with_file_and_line (input_filename, lineno, s, v, v2);
1.1       root      566: }
                    567: 
1.1.1.2   root      568: /* Report an error at line LINE of file FILE.
1.1       root      569:    S and V are a string and an arg for `printf'.  */
                    570: 
1.1.1.2   root      571: void
1.1.1.7   root      572: error_with_file_and_line (file, line, s, v, v2)
1.1.1.2   root      573:      char *file;
1.1       root      574:      int line;
                    575:      char *s;
                    576:      int v;
1.1.1.7   root      577:      int v2;
1.1       root      578: {
                    579:   count_error (0);
                    580: 
1.1.1.9   root      581:   report_error_function (file);
1.1.1.2   root      582: 
                    583:   if (file)
                    584:     fprintf (stderr, "%s:%d: ", file, line);
                    585:   else
1.1.1.16! root      586:     fprintf (stderr, "%s: ", progname);
1.1.1.7   root      587:   fprintf (stderr, s, v, v2);
1.1       root      588:   fprintf (stderr, "\n");
                    589: }
                    590: 
1.1.1.2   root      591: /* Report an error at the declaration DECL.
1.1.1.12  root      592:    S and V are a string and an arg which uses %s to substitute the declaration name.  */
1.1       root      593: 
                    594: void
1.1.1.12  root      595: error_with_decl (decl, s, v)
1.1.1.2   root      596:      tree decl;
1.1       root      597:      char *s;
1.1.1.12  root      598:      int v;
1.1       root      599: {
1.1.1.2   root      600:   count_error (0);
                    601: 
1.1.1.9   root      602:   report_error_function (DECL_SOURCE_FILE (decl));
1.1.1.2   root      603: 
                    604:   fprintf (stderr, "%s:%d: ",
                    605:           DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
                    606: 
1.1.1.16! root      607:   if (DECL_PRINT_NAME (decl))
        !           608:     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
        !           609:   else if (DECL_NAME (decl))
1.1.1.12  root      610:     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
1.1.1.2   root      611:   else
1.1.1.12  root      612:     fprintf (stderr, s, "((anonymous))", v);
1.1.1.2   root      613:   fprintf (stderr, "\n");
1.1       root      614: }
                    615: 
1.1.1.11  root      616: /* Report an error at the line number of the insn INSN.
                    617:    S and V are a string and an arg for `printf'.
                    618:    This is used only when INSN is an `asm' with operands,
1.1.1.15  root      619:    and each ASM_OPERANDS records its own source file and line.  */
1.1.1.11  root      620: 
                    621: void
                    622: error_for_asm (insn, s, v, v2)
                    623:      rtx insn;
                    624:      char *s;
                    625:      int v;                    /* @@also used as pointer */
                    626:      int v2;                   /* @@also used as pointer */
                    627: {
1.1.1.12  root      628:   rtx temp;
                    629:   char *filename;
                    630:   int line;
1.1.1.15  root      631:   rtx body = PATTERN (insn);
                    632:   rtx asmop;
1.1.1.12  root      633: 
1.1.1.15  root      634:   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
                    635:   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
                    636:     asmop = SET_SRC (body);
                    637:   else if (GET_CODE (body) == ASM_OPERANDS)
                    638:     asmop = body;
                    639:   else if (GET_CODE (body) == PARALLEL
                    640:           && GET_CODE (XVECEXP (body, 0, 0)) == SET)
                    641:     asmop = SET_SRC (XVECEXP (body, 0, 0));
                    642:   else if (GET_CODE (body) == PARALLEL
                    643:           && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
                    644:     asmop = XVECEXP (body, 0, 0);
                    645: 
                    646:   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
                    647:   line = ASM_OPERANDS_SOURCE_LINE (asmop);
1.1.1.16! root      648: 
1.1.1.12  root      649:   error_with_file_and_line (filename, line, s, v, v2);
1.1.1.11  root      650: }
                    651: 
1.1       root      652: /* Report a warning at line LINE.
                    653:    S and V are a string and an arg for `printf'.  */
                    654: 
1.1.1.2   root      655: void
1.1.1.11  root      656: warning_with_file_and_line (file, line, s, v, v2)
                    657:      char *file;
1.1       root      658:      int line;
                    659:      char *s;
                    660:      int v;
1.1.1.7   root      661:      int v2;
1.1       root      662: {
                    663:   if (count_error (1) == 0)
                    664:     return;
                    665: 
1.1.1.11  root      666:   report_error_function (file);
1.1.1.2   root      667: 
1.1.1.11  root      668:   if (file)
                    669:     fprintf (stderr, "%s:%d: ", file, line);
1.1.1.2   root      670:   else
1.1.1.16! root      671:     fprintf (stderr, "%s: ", progname);
1.1       root      672: 
                    673:   fprintf (stderr, "warning: ");
1.1.1.7   root      674:   fprintf (stderr, s, v, v2);
1.1       root      675:   fprintf (stderr, "\n");
                    676: }
1.1.1.2   root      677: 
                    678: /* Report a warning at the current line number.
                    679:    S and V are a string and an arg for `printf'.  */
                    680: 
                    681: void
1.1.1.7   root      682: warning (s, v, v2)
1.1.1.2   root      683:      char *s;
                    684:      int v;                    /* @@also used as pointer */
1.1.1.7   root      685:      int v2;
1.1.1.2   root      686: {
1.1.1.11  root      687:   warning_with_file_and_line (input_filename, lineno, s, v, v2);
1.1.1.2   root      688: }
                    689: 
                    690: /* Report a warning at the declaration DECL.
1.1.1.16! root      691:    S is string which uses %s to substitute the declaration name.
        !           692:    V is a second parameter that S can refer to.  */
1.1.1.2   root      693: 
                    694: void
1.1.1.12  root      695: warning_with_decl (decl, s, v)
1.1.1.2   root      696:      tree decl;
                    697:      char *s;
1.1.1.12  root      698:      int v;
1.1.1.2   root      699: {
                    700:   if (count_error (1) == 0)
                    701:     return;
                    702: 
1.1.1.9   root      703:   report_error_function (DECL_SOURCE_FILE (decl));
1.1.1.2   root      704: 
                    705:   fprintf (stderr, "%s:%d: ",
                    706:           DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
                    707: 
                    708:   fprintf (stderr, "warning: ");
1.1.1.16! root      709:   if (DECL_PRINT_NAME (decl))
        !           710:     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
        !           711:   else if (DECL_NAME (decl))
1.1.1.12  root      712:     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
1.1.1.2   root      713:   else
1.1.1.12  root      714:     fprintf (stderr, s, "((anonymous))", v);
1.1.1.2   root      715:   fprintf (stderr, "\n");
                    716: }
1.1.1.7   root      717: 
                    718: /* Apologize for not implementing some feature.
                    719:    S, V, and V2 are a string and args for `printf'.  */
                    720: 
                    721: void
                    722: sorry (s, v, v2)
                    723:      char *s;
                    724:      int v, v2;
                    725: {
                    726:   sorrycount++;
                    727:   if (input_filename)
                    728:     fprintf (stderr, "%s:%d: ", input_filename, lineno);
                    729:   else
1.1.1.16! root      730:     fprintf (stderr, "%s: ", progname);
1.1.1.7   root      731: 
                    732:   fprintf (stderr, "sorry, not implemented: ");
                    733:   fprintf (stderr, s, v, v2);
                    734:   fprintf (stderr, "\n");
                    735: }
                    736: 
                    737: /* Apologize for not implementing some feature, then quit.
                    738:    S, V, and V2 are a string and args for `printf'.  */
                    739: 
                    740: void
                    741: really_sorry (s, v, v2)
                    742:      char *s;
                    743:      int v, v2;
                    744: {
                    745:   if (input_filename)
                    746:     fprintf (stderr, "%s:%d: ", input_filename, lineno);
                    747:   else
                    748:     fprintf (stderr, "c++: ");
                    749: 
                    750:   fprintf (stderr, "sorry, not implemented: ");
                    751:   fprintf (stderr, s, v, v2);
                    752:   fatal (" (fatal)\n");
                    753: }
1.1       root      754: 
1.1.1.16! root      755: /* More 'friendly' abort that prints the line and file.
        !           756:    config.h can #define abort fancy_abort if you like that sort of thing.  */
        !           757: 
        !           758: void
        !           759: fancy_abort ()
        !           760: {
        !           761:   fatal ("Internal gcc abort.");
        !           762: }
        !           763: 
1.1       root      764: /* When `malloc.c' is compiled with `rcheck' defined,
                    765:    it calls this function to report clobberage.  */
                    766: 
1.1.1.2   root      767: void
1.1       root      768: botch (s)
                    769: {
                    770:   abort ();
                    771: }
                    772: 
                    773: /* Same as `malloc' but report error if no memory available.  */
                    774: 
1.1.1.2   root      775: int
1.1       root      776: xmalloc (size)
                    777:      unsigned size;
                    778: {
                    779:   register int value = (int) malloc (size);
                    780:   if (value == 0)
                    781:     fatal ("Virtual memory exhausted.");
                    782:   return value;
                    783: }
                    784: 
                    785: /* Same as `realloc' but report error if no memory available.  */
                    786: 
                    787: int
                    788: xrealloc (ptr, size)
                    789:      char *ptr;
                    790:      int size;
                    791: {
                    792:   int result = realloc (ptr, size);
                    793:   if (!result)
1.1.1.2   root      794:     fatal ("Virtual memory exhausted.");
1.1       root      795:   return result;
                    796: }
                    797: 
                    798: /* Return the logarithm of X, base 2, considering X unsigned,
                    799:    if X is a power of 2.  Otherwise, returns -1.  */
                    800: 
                    801: int
                    802: exact_log2 (x)
                    803:      register unsigned int x;
                    804: {
                    805:   register int log = 0;
                    806:   for (log = 0; log < HOST_BITS_PER_INT; log++)
                    807:     if (x == (1 << log))
                    808:       return log;
                    809:   return -1;
                    810: }
                    811: 
                    812: /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
                    813:    If X is 0, return -1.  */
                    814: 
                    815: int
                    816: floor_log2 (x)
                    817:      register unsigned int x;
                    818: {
                    819:   register int log = 0;
                    820:   for (log = 0; log < HOST_BITS_PER_INT; log++)
                    821:     if ((x & ((-1) << log)) == 0)
                    822:       return log - 1;
                    823:   return HOST_BITS_PER_INT - 1;
                    824: }
1.1.1.10  root      825: 
                    826: int float_handled;
                    827: jmp_buf float_handler;
                    828: 
                    829: /* Specify where to longjmp to when a floating arithmetic error happens.
                    830:    If HANDLER is 0, it means don't handle the errors any more.  */
                    831: 
                    832: void
                    833: set_float_handler (handler)
                    834:      jmp_buf handler;
                    835: {
                    836:   float_handled = (handler != 0);
                    837:   if (handler)
                    838:     bcopy (handler, float_handler, sizeof (float_handler));
                    839: }
                    840: 
                    841: /* Signals actually come here.  */
                    842: 
                    843: static void
                    844: float_signal ()
                    845: {
                    846:   if (float_handled == 0)
                    847:     abort ();
                    848:   warning ("floating overflow in constant folding");
                    849:   float_handled = 0;
                    850:   longjmp (float_handler, 1);
                    851: }
1.1.1.13  root      852: 
                    853: /* Handler for SIGPIPE.  */
                    854: 
                    855: static void
                    856: pipe_closed ()
                    857: {
                    858:   fatal ("output pipe has been closed");
                    859: }
1.1       root      860: 
                    861: /* Compile an entire file of output from cpp, named NAME.
                    862:    Write a file of assembly output and various debugging dumps.  */
                    863: 
                    864: static void
                    865: compile_file (name)
                    866:      char *name;
                    867: {
                    868:   tree globals;
                    869:   int start_time;
1.1.1.9   root      870:   int dump_base_name_length;
                    871: 
                    872:   int name_specified = name != 0;
                    873: 
                    874:   if (dump_base_name == 0)
                    875:     dump_base_name = name ? name : "gccdump";
                    876:   dump_base_name_length = strlen (dump_base_name);
1.1       root      877: 
                    878:   parse_time = 0;
                    879:   varconst_time = 0;
1.1.1.2   root      880:   integration_time = 0;
1.1       root      881:   jump_time = 0;
                    882:   cse_time = 0;
                    883:   loop_time = 0;
                    884:   flow_time = 0;
                    885:   combine_time = 0;
                    886:   local_alloc_time = 0;
                    887:   global_alloc_time = 0;
1.1.1.16! root      888:   dbr_sched_time = 0;
1.1       root      889:   final_time = 0;
                    890:   symout_time = 0;
1.1.1.2   root      891:   dump_time = 0;
1.1       root      892: 
                    893:   /* Open input file.  */
                    894: 
1.1.1.9   root      895:   if (name == 0 || !strcmp (name, "-"))
                    896:     {
                    897:       finput = stdin;
                    898:       name = "stdin";
                    899:     }
                    900:   else
                    901:     finput = fopen (name, "r");
1.1       root      902:   if (finput == 0)
                    903:     pfatal_with_name (name);
                    904: 
                    905:   /* Initialize data in various passes.  */
                    906: 
                    907:   init_tree ();
                    908:   init_lex ();
                    909:   init_rtl ();
1.1.1.2   root      910:   init_emit_once ();
1.1       root      911:   init_decl_processing ();
                    912:   init_optabs ();
                    913: 
                    914:   /* If rtl dump desired, open the output file.  */
                    915:   if (rtl_dump)
                    916:     {
                    917:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    918:       strcpy (dumpname, dump_base_name);
                    919:       strcat (dumpname, ".rtl");
                    920:       rtl_dump_file = fopen (dumpname, "w");
                    921:       if (rtl_dump_file == 0)
                    922:        pfatal_with_name (dumpname);
                    923:     }
                    924: 
                    925:   /* If jump_opt dump desired, open the output file.  */
                    926:   if (jump_opt_dump)
                    927:     {
                    928:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    929:       strcpy (dumpname, dump_base_name);
                    930:       strcat (dumpname, ".jump");
                    931:       jump_opt_dump_file = fopen (dumpname, "w");
                    932:       if (jump_opt_dump_file == 0)
                    933:        pfatal_with_name (dumpname);
                    934:     }
                    935: 
                    936:   /* If cse dump desired, open the output file.  */
                    937:   if (cse_dump)
                    938:     {
                    939:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    940:       strcpy (dumpname, dump_base_name);
                    941:       strcat (dumpname, ".cse");
                    942:       cse_dump_file = fopen (dumpname, "w");
                    943:       if (cse_dump_file == 0)
                    944:        pfatal_with_name (dumpname);
                    945:     }
                    946: 
                    947:   /* If loop dump desired, open the output file.  */
                    948:   if (loop_dump)
                    949:     {
                    950:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    951:       strcpy (dumpname, dump_base_name);
                    952:       strcat (dumpname, ".loop");
                    953:       loop_dump_file = fopen (dumpname, "w");
                    954:       if (loop_dump_file == 0)
                    955:        pfatal_with_name (dumpname);
                    956:     }
                    957: 
                    958:   /* If flow dump desired, open the output file.  */
                    959:   if (flow_dump)
                    960:     {
                    961:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    962:       strcpy (dumpname, dump_base_name);
                    963:       strcat (dumpname, ".flow");
                    964:       flow_dump_file = fopen (dumpname, "w");
                    965:       if (flow_dump_file == 0)
                    966:        pfatal_with_name (dumpname);
                    967:     }
                    968: 
                    969:   /* If combine dump desired, open the output file.  */
                    970:   if (combine_dump)
                    971:     {
                    972:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
                    973:       strcpy (dumpname, dump_base_name);
                    974:       strcat (dumpname, ".combine");
                    975:       combine_dump_file = fopen (dumpname, "w");
                    976:       if (combine_dump_file == 0)
                    977:        pfatal_with_name (dumpname);
                    978:     }
                    979: 
                    980:   /* If local_reg dump desired, open the output file.  */
                    981:   if (local_reg_dump)
                    982:     {
                    983:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    984:       strcpy (dumpname, dump_base_name);
                    985:       strcat (dumpname, ".lreg");
                    986:       local_reg_dump_file = fopen (dumpname, "w");
                    987:       if (local_reg_dump_file == 0)
                    988:        pfatal_with_name (dumpname);
                    989:     }
                    990: 
                    991:   /* If global_reg dump desired, open the output file.  */
                    992:   if (global_reg_dump)
                    993:     {
                    994:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                    995:       strcpy (dumpname, dump_base_name);
                    996:       strcat (dumpname, ".greg");
                    997:       global_reg_dump_file = fopen (dumpname, "w");
                    998:       if (global_reg_dump_file == 0)
                    999:        pfatal_with_name (dumpname);
                   1000:     }
                   1001: 
1.1.1.2   root     1002:   /* If jump2_opt dump desired, open the output file.  */
                   1003:   if (jump2_opt_dump)
                   1004:     {
                   1005:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
                   1006:       strcpy (dumpname, dump_base_name);
                   1007:       strcat (dumpname, ".jump2");
                   1008:       jump2_opt_dump_file = fopen (dumpname, "w");
                   1009:       if (jump2_opt_dump_file == 0)
                   1010:        pfatal_with_name (dumpname);
                   1011:     }
                   1012: 
1.1.1.16! root     1013:   /* If dbr_sched dump desired, open the output file.  */
        !          1014:   if (dbr_sched_dump)
        !          1015:     {
        !          1016:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
        !          1017:       strcpy (dumpname, dump_base_name);
        !          1018:       strcat (dumpname, ".dbr");
        !          1019:       dbr_sched_dump_file = fopen (dumpname, "w");
        !          1020:       if (dbr_sched_dump_file == 0)
        !          1021:        pfatal_with_name (dumpname);
        !          1022:     }
        !          1023: 
1.1       root     1024:   /* Open assembler code output file.  */
1.1.1.16! root     1025: 
1.1.1.9   root     1026:   if (! name_specified && asm_file_name == 0)
                   1027:     asm_out_file = stdout;
                   1028:   else
                   1029:     {
                   1030:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
                   1031:       int len = strlen (dump_base_name);
                   1032:       strcpy (dumpname, dump_base_name);
                   1033:       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
                   1034:        dumpname[len - 2] = 0;
                   1035:       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
                   1036:        dumpname[len - 2] = 0;
                   1037:       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
                   1038:        dumpname[len - 3] = 0;
                   1039:       strcat (dumpname, ".s");
                   1040:       if (asm_file_name == 0)
                   1041:        {
                   1042:          asm_file_name = (char *) malloc (strlen (dumpname) + 1);
                   1043:          strcpy (asm_file_name, dumpname);
                   1044:        }
                   1045:       if (!strcmp (asm_file_name, "-"))
                   1046:        asm_out_file = stdout;
                   1047:       else
                   1048:        asm_out_file = fopen (asm_file_name, "w");
                   1049:       if (asm_out_file == 0)
                   1050:        pfatal_with_name (asm_file_name);
                   1051:     }
1.1       root     1052: 
                   1053:   input_filename = name;
                   1054: 
                   1055:   /* the beginning of the file is a new line; check for # */
                   1056:   /* With luck, we discover the real source file's name from that
                   1057:      and put it in input_filename.  */
1.1.1.4   root     1058:   ungetc (check_newline (), finput);
                   1059: 
1.1.1.8   root     1060:   /* If the input doesn't start with a #line, use the input name
                   1061:      as the official input file name.  */
                   1062:   if (main_input_filename == 0)
                   1063:     main_input_filename = name;
                   1064: 
1.1.1.16! root     1065:   /* Put an entry on the input file stack for the main input file.  */
        !          1066:   input_file_stack
        !          1067:     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
        !          1068:   input_file_stack->next = 0;
        !          1069:   input_file_stack->name = input_filename;
        !          1070: 
1.1.1.4   root     1071:   ASM_FILE_START (asm_out_file);
1.1       root     1072: 
1.1.1.12  root     1073:   /* Output something to inform GDB that this compilation was by GCC.  */
                   1074: #ifndef ASM_IDENTIFY_GCC
                   1075:   fprintf (asm_out_file, "gcc_compiled.:\n");
                   1076: #else
                   1077:   ASM_IDENTIFY_GCC (asm_out_file);
                   1078: #endif
                   1079: 
1.1       root     1080:   /* If GDB symbol table desired, open the GDB symbol output file.  */
1.1.1.4   root     1081:   if (write_symbols == GDB_DEBUG)
1.1       root     1082:     {
                   1083:       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1.1.1.2   root     1084:       int len = strlen (dump_base_name);
1.1       root     1085:       strcpy (dumpname, dump_base_name);
1.1.1.2   root     1086:       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
                   1087:        dumpname[len - 2] = 0;
1.1.1.7   root     1088:       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
                   1089:        dumpname[len - 2] = 0;
1.1.1.2   root     1090:       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
                   1091:        dumpname[len - 3] = 0;
1.1       root     1092:       strcat (dumpname, ".sym");
                   1093:       if (sym_file_name == 0)
                   1094:        sym_file_name = dumpname;
1.1.1.4   root     1095:       symout_init (sym_file_name, asm_out_file, main_input_filename);
1.1       root     1096:     }
                   1097: 
                   1098:   /* If dbx symbol table desired, initialize writing it
                   1099:      and output the predefined types.  */
1.1.1.4   root     1100: #ifdef DBX_DEBUGGING_INFO
                   1101:   if (write_symbols == DBX_DEBUG)
1.1.1.2   root     1102:     dbxout_init (asm_out_file, main_input_filename);
1.1.1.4   root     1103: #endif
                   1104: #ifdef SDB_DEBUGGING_INFO
                   1105:   if (write_symbols == SDB_DEBUG)
                   1106:     sdbout_init (asm_out_file, main_input_filename);
                   1107: #endif
1.1       root     1108: 
                   1109:   /* Initialize yet another pass.  */
                   1110: 
1.1.1.2   root     1111:   init_final (main_input_filename);
1.1       root     1112: 
                   1113:   start_time = gettime ();
                   1114: 
                   1115:   /* Call the parser, which parses the entire file
                   1116:      (calling rest_of_compilation for each function).  */
                   1117: 
                   1118:   yyparse ();
                   1119: 
                   1120:   /* Compilation is now finished except for writing
                   1121:      what's left of the symbol table output.  */
                   1122: 
                   1123:   parse_time += gettime () - start_time;
                   1124: 
1.1.1.16! root     1125:   parse_time -= integration_time;
1.1.1.2   root     1126:   parse_time -= varconst_time;
                   1127: 
1.1       root     1128:   globals = getdecls ();
                   1129: 
1.1.1.2   root     1130:   /* Really define vars that have had only a tentative definition.
                   1131:      Really output inline functions that must actually be callable
                   1132:      and have not been output so far.  */
                   1133: 
                   1134:   {
                   1135:     tree decl;
                   1136:     for (decl = globals; decl; decl = TREE_CHAIN (decl))
                   1137:       {
                   1138:        if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
                   1139:            && ! TREE_ASM_WRITTEN (decl))
1.1.1.16! root     1140:          {
        !          1141:            /* Don't write out static consts, unless we needed
        !          1142:               to take their address for some reason.  */
        !          1143:            if (! TREE_READONLY (decl)
        !          1144:                || TREE_PUBLIC (decl)
        !          1145:                || TREE_ADDRESSABLE (decl))
        !          1146:              rest_of_decl_compilation (decl, 0, 1, 1);
        !          1147:            /* Otherwise maybe mention them just for the debugger.  */
        !          1148: #ifdef DBX_DEBUGGING_INFO
        !          1149:            else if (DECL_INITIAL (decl) && write_symbols == DBX_DEBUG)
        !          1150:              TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
        !          1151: #endif
        !          1152: #ifdef SDB_DEBUGGING_INFO
        !          1153:            else if (DECL_INITIAL (decl) && write_symbols == SDB_DEBUG)
        !          1154:              TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
        !          1155: #endif
        !          1156:          }
1.1.1.2   root     1157:        if (TREE_CODE (decl) == FUNCTION_DECL
                   1158:            && ! TREE_ASM_WRITTEN (decl)
                   1159:            && DECL_INITIAL (decl) != 0
1.1.1.16! root     1160:            && TREE_ADDRESSABLE (decl)
        !          1161:            && ! TREE_EXTERNAL (decl))
1.1.1.2   root     1162:          output_inline_function (decl);
1.1.1.15  root     1163: 
                   1164:        /* Warn about any function declared static but not defined.  */
1.1.1.13  root     1165:        if (warn_unused
                   1166:            && TREE_CODE (decl) == FUNCTION_DECL
                   1167:            && DECL_INITIAL (decl) == 0
                   1168:            && TREE_EXTERNAL (decl)
                   1169:            && ! TREE_PUBLIC (decl))
                   1170:          warning_with_decl (decl, "`%s' declared but never defined");
1.1.1.15  root     1171:        /* Warn about statics fns or vars defined but not used,
                   1172:           but not about inline functions
                   1173:           since unused inline statics is normal practice.  */
                   1174:        if (warn_unused
                   1175:            && (TREE_CODE (decl) == FUNCTION_DECL
                   1176:                || TREE_CODE (decl) == VAR_DECL)
                   1177:            && ! TREE_EXTERNAL (decl)
                   1178:            && ! TREE_PUBLIC (decl)
                   1179:            && ! TREE_USED (decl)
                   1180:            && ! TREE_INLINE (decl))
                   1181:          warning_with_decl (decl, "`%s' defined but not used");
1.1.1.2   root     1182:       }
                   1183:   }
                   1184: 
1.1       root     1185:   /* Do dbx symbols */
1.1.1.4   root     1186: #ifdef DBX_DEBUGGING_INFO
                   1187:   if (write_symbols == DBX_DEBUG)
1.1       root     1188:     TIMEVAR (symout_time,
                   1189:             {
                   1190:               dbxout_tags (gettags ());
                   1191:               dbxout_types (get_permanent_types ());
                   1192:             });
1.1.1.4   root     1193: #endif
                   1194: 
                   1195: #ifdef SDB_DEBUGGING_INFO
                   1196:   if (write_symbols == SDB_DEBUG)
                   1197:     TIMEVAR (symout_time,
                   1198:             {
                   1199:               sdbout_tags (gettags ());
                   1200:               sdbout_types (get_permanent_types ());
                   1201:             });
                   1202: #endif
1.1       root     1203: 
                   1204:   /* Do gdb symbols */
1.1.1.4   root     1205:   if (write_symbols == GDB_DEBUG)
1.1       root     1206:     TIMEVAR (symout_time,
                   1207:             {
                   1208:               struct stat statbuf;
                   1209:               fstat (fileno (finput), &statbuf);
                   1210:               symout_types (get_permanent_types ());
                   1211:               symout_top_blocks (globals, gettags ());
                   1212:               symout_finish (name, statbuf.st_ctime);
                   1213:             });
                   1214: 
1.1.1.14  root     1215:   /* Output some stuff at end of file if nec.  */
                   1216: 
                   1217:   end_final (main_input_filename);
                   1218: 
1.1.1.16! root     1219: #ifdef ASM_FILE_END
        !          1220:   ASM_FILE_END (asm_out_file);
        !          1221: #endif
        !          1222: 
1.1.1.2   root     1223:   /* Close the dump files.  */
1.1       root     1224: 
                   1225:   if (rtl_dump)
                   1226:     fclose (rtl_dump_file);
                   1227: 
                   1228:   if (jump_opt_dump)
                   1229:     fclose (jump_opt_dump_file);
                   1230: 
                   1231:   if (cse_dump)
                   1232:     fclose (cse_dump_file);
                   1233: 
                   1234:   if (loop_dump)
                   1235:     fclose (loop_dump_file);
                   1236: 
                   1237:   if (flow_dump)
                   1238:     fclose (flow_dump_file);
                   1239: 
                   1240:   if (combine_dump)
                   1241:     {
                   1242:       dump_combine_total_stats (combine_dump_file);
                   1243:       fclose (combine_dump_file);
                   1244:     }
                   1245: 
                   1246:   if (local_reg_dump)
                   1247:     fclose (local_reg_dump_file);
                   1248: 
                   1249:   if (global_reg_dump)
                   1250:     fclose (global_reg_dump_file);
                   1251: 
1.1.1.2   root     1252:   if (jump2_opt_dump)
                   1253:     fclose (jump2_opt_dump_file);
                   1254: 
1.1.1.16! root     1255:   if (dbr_sched_dump)
        !          1256:     fclose (dbr_sched_dump_file);
        !          1257: 
        !          1258:   /* Close non-debugging input and output files.  Take special care to note
        !          1259:      whether fclose returns an error, since the pages might still be on the
        !          1260:      buffer chain while the file is open.  */
1.1.1.2   root     1261: 
                   1262:   fclose (finput);
1.1.1.16! root     1263:   if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
1.1.1.2   root     1264:     fatal_io_error (asm_file_name);
                   1265: 
1.1       root     1266:   /* Print the times.  */
                   1267: 
                   1268:   if (! quiet_flag)
                   1269:     {
1.1.1.2   root     1270:       fprintf (stderr,"\n");
1.1       root     1271:       print_time ("parse", parse_time);
1.1.1.2   root     1272:       print_time ("integration", integration_time);
1.1       root     1273:       print_time ("jump", jump_time);
                   1274:       print_time ("cse", cse_time);
                   1275:       print_time ("loop", loop_time);
                   1276:       print_time ("flow", flow_time);
                   1277:       print_time ("combine", combine_time);
                   1278:       print_time ("local-alloc", local_alloc_time);
                   1279:       print_time ("global-alloc", global_alloc_time);
1.1.1.16! root     1280:       print_time ("dbranch", dbr_sched_time);
1.1       root     1281:       print_time ("final", final_time);
                   1282:       print_time ("varconst", varconst_time);
                   1283:       print_time ("symout", symout_time);
                   1284:       print_time ("dump", dump_time);
                   1285:     }
                   1286: }
                   1287: 
1.1.1.2   root     1288: /* This is called from finish_decl (within yyparse)
                   1289:    for each declaration of a function or variable.
                   1290:    This does nothing for automatic variables.
                   1291:    Otherwise, it sets up the RTL and outputs any assembler code
                   1292:    (label definition, storage allocation and initialization).
                   1293: 
                   1294:    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
                   1295:    the assembler symbol name to be used.  TOP_LEVEL is nonzero
                   1296:    if this declaration is not within a function.  */
                   1297: 
                   1298: void
                   1299: rest_of_decl_compilation (decl, asmspec, top_level, at_end)
                   1300:      tree decl;
1.1.1.16! root     1301:      char *asmspec;
1.1.1.2   root     1302:      int top_level;
                   1303:      int at_end;
                   1304: {
                   1305:   /* Declarations of variables, and of functions defined elsewhere.  */
                   1306: 
                   1307:   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
                   1308:     TIMEVAR (varconst_time,
                   1309:             {
1.1.1.12  root     1310:               make_decl_rtl (decl, asmspec, top_level);
                   1311:               /* Don't output anything
                   1312:                  when a tentative file-scope definition is seen.
                   1313:                  But at end of compilation, do output code for them.  */
                   1314:               if (! (! at_end && top_level
                   1315:                      && (DECL_INITIAL (decl) == 0
                   1316:                          || DECL_INITIAL (decl) == error_mark_node)))
                   1317:                 assemble_variable (decl, top_level, write_symbols, at_end);
1.1.1.2   root     1318:             });
1.1.1.16! root     1319:   else if (TREE_REGDECL (decl) && asmspec != 0)
        !          1320:     {
        !          1321:       if (decode_reg_name (asmspec) >= 0)
        !          1322:        {
        !          1323:          DECL_RTL (decl) = 0;
        !          1324:          make_decl_rtl (decl, asmspec, top_level);
        !          1325:        }
        !          1326:       else
        !          1327:        error ("invalid register name `%s' for register variable", asmspec);
        !          1328:     }
1.1.1.4   root     1329: #ifdef DBX_DEBUGGING_INFO
                   1330:   else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
1.1.1.3   root     1331:     TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
1.1.1.4   root     1332: #endif
                   1333: #ifdef SDB_DEBUGGING_INFO
                   1334:   else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
                   1335:     TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
                   1336: #endif
1.1.1.2   root     1337: 
                   1338:   if (top_level)
                   1339:     {
1.1.1.4   root     1340:       if (write_symbols == GDB_DEBUG)
1.1.1.2   root     1341:        {
                   1342:          TIMEVAR (symout_time,
                   1343:                   {
                   1344:                     /* The initizations make types when they contain
                   1345:                        string constants.  The types are on the temporary
                   1346:                        obstack, so output them now before they go away.  */
                   1347:                     symout_types (get_temporary_types ());
                   1348:                   });
                   1349:        }
                   1350:       else
                   1351:        /* Clean out the temporary type list, since the types will go away.  */
                   1352:        get_temporary_types ();
                   1353:     }
                   1354: }
                   1355: 
1.1       root     1356: /* This is called from finish_function (within yyparse)
1.1.1.2   root     1357:    after each top-level definition is parsed.
1.1       root     1358:    It is supposed to compile that function or variable
                   1359:    and output the assembler code for it.
                   1360:    After we return, the tree storage is freed.  */
                   1361: 
                   1362: void
1.1.1.2   root     1363: rest_of_compilation (decl)
1.1       root     1364:      tree decl;
                   1365: {
                   1366:   register rtx insns;
                   1367:   int start_time = gettime ();
                   1368:   int tem;
                   1369: 
1.1.1.2   root     1370:   /* If we are reconsidering an inline function
                   1371:      at the end of compilation, skip the stuff for making it inline.  */
1.1       root     1372: 
1.1.1.2   root     1373:   if (DECL_SAVED_INSNS (decl) == 0)
1.1       root     1374:     {
                   1375: 
1.1.1.2   root     1376:       /* If requested, consider whether to make this function inline.  */
                   1377:       if (flag_inline_functions || TREE_INLINE (decl))
                   1378:        {
                   1379:          TIMEVAR (integration_time,
                   1380:                   {
                   1381:                     int specd = TREE_INLINE (decl);
                   1382:                     char *lose = function_cannot_inline_p (decl);
                   1383:                     if (lose != 0 && specd)
                   1384:                       warning_with_decl (decl, lose);
                   1385:                     if (lose == 0)
                   1386:                       save_for_inline (decl);
                   1387:                     else
                   1388:                       TREE_INLINE (decl) = 0;
                   1389:                   });
                   1390:        }
1.1       root     1391: 
1.1.1.2   root     1392:       insns = get_insns ();
1.1       root     1393: 
                   1394:       /* Dump the rtl code if we are dumping rtl.  */
                   1395: 
                   1396:       if (rtl_dump)
                   1397:        TIMEVAR (dump_time,
                   1398:                 {
                   1399:                   fprintf (rtl_dump_file, "\n;; Function %s\n\n",
                   1400:                            IDENTIFIER_POINTER (DECL_NAME (decl)));
1.1.1.2   root     1401:                   if (DECL_SAVED_INSNS (decl))
                   1402:                     fprintf (rtl_dump_file, ";; (integrable)\n\n");
1.1       root     1403:                   print_rtl (rtl_dump_file, insns);
                   1404:                   fflush (rtl_dump_file);
                   1405:                 });
                   1406: 
1.1.1.2   root     1407:       /* If function is inline, and we don't yet know whether to
                   1408:         compile it by itself, defer decision till end of compilation.
                   1409:         finish_compilation will call rest_of_compilation again
                   1410:         for those functions that need to be output.  */
                   1411: 
1.1.1.16! root     1412:       if (((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
        !          1413:            && ! flag_keep_inline_functions)
        !          1414:           || TREE_EXTERNAL (decl))
        !          1415:          && TREE_INLINE (decl))
1.1       root     1416:        goto exit_rest_of_compilation;
1.1.1.2   root     1417:     }
1.1       root     1418: 
1.1.1.16! root     1419:   if (rtl_dump_and_exit || flag_syntax_only)
        !          1420:     {
        !          1421:       get_temporary_types ();
        !          1422:       goto exit_rest_of_compilation;
        !          1423:     }
1.1       root     1424: 
1.1.1.2   root     1425:   TREE_ASM_WRITTEN (decl) = 1;
1.1       root     1426: 
1.1.1.2   root     1427:   insns = get_insns ();
1.1       root     1428: 
1.1.1.2   root     1429:   /* Copy any shared structure that should not be shared.  */
1.1       root     1430: 
1.1.1.2   root     1431:   unshare_all_rtl (insns);
1.1       root     1432: 
1.1.1.2   root     1433:   /* See if we have allocated stack slots that are not directly addressable.
                   1434:      If so, scan all the insns and create explicit address computation
                   1435:      for all references to such slots.  */
                   1436: /*   fixup_stack_slots (); */
1.1       root     1437: 
1.1.1.2   root     1438:   /* Do jump optimization the first time, if -opt.
                   1439:      Also do it if -W, but in that case it doesn't change the rtl code,
                   1440:      it only computes whether control can drop off the end of the function.  */
1.1       root     1441: 
1.1.1.13  root     1442:   if (optimize || extra_warnings || warn_return_type
                   1443:       /* If function is `volatile', we should warn if it tries to return.  */
                   1444:       || TREE_THIS_VOLATILE (decl))
1.1.1.2   root     1445:     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1.1       root     1446: 
1.1.1.2   root     1447:   /* Dump rtl code after jump, if we are doing that.  */
1.1       root     1448: 
1.1.1.2   root     1449:   if (jump_opt_dump)
                   1450:     TIMEVAR (dump_time,
                   1451:             {
                   1452:               fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
                   1453:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1454:               print_rtl (jump_opt_dump_file, insns);
                   1455:               fflush (jump_opt_dump_file);
                   1456:             });
1.1       root     1457: 
1.1.1.2   root     1458:   /* Perform common subexpression elimination.
                   1459:      Nonzero value from `cse_main' means that jumps were simplified
                   1460:      and some code may now be unreachable, so do
                   1461:      jump optimization again.  */
1.1       root     1462: 
1.1.1.2   root     1463:   if (optimize)
                   1464:     {
                   1465:       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
1.1       root     1466: 
1.1.1.2   root     1467:       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
1.1       root     1468: 
1.1.1.2   root     1469:       if (tem)
                   1470:        TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
                   1471:     }
1.1       root     1472: 
1.1.1.2   root     1473:   /* Dump rtl code after cse, if we are doing that.  */
1.1       root     1474: 
1.1.1.2   root     1475:   if (cse_dump)
                   1476:     TIMEVAR (dump_time,
                   1477:             {
                   1478:               fprintf (cse_dump_file, "\n;; Function %s\n\n",
                   1479:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1480:               print_rtl (cse_dump_file, insns);
                   1481:               fflush (cse_dump_file);
                   1482:             });
1.1       root     1483: 
1.1.1.2   root     1484:   if (loop_dump)
                   1485:     TIMEVAR (dump_time,
                   1486:             {
                   1487:               fprintf (loop_dump_file, "\n;; Function %s\n\n",
                   1488:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1489:             });
1.1       root     1490: 
1.1.1.2   root     1491:   /* Move constant computations out of loops.  */
1.1       root     1492: 
1.1.1.2   root     1493:   if (optimize)
                   1494:     {
                   1495:       TIMEVAR (loop_time,
                   1496:               {
                   1497:                 reg_scan (insns, max_reg_num (), 1);
1.1.1.9   root     1498:                 loop_optimize (insns, loop_dump ? loop_dump_file : 0);
1.1.1.2   root     1499:               });
                   1500:     }
1.1       root     1501: 
1.1.1.2   root     1502:   /* Dump rtl code after loop opt, if we are doing that.  */
1.1       root     1503: 
1.1.1.2   root     1504:   if (loop_dump)
                   1505:     TIMEVAR (dump_time,
                   1506:             {
                   1507:               print_rtl (loop_dump_file, insns);
                   1508:               fflush (loop_dump_file);
                   1509:             });
1.1       root     1510: 
1.1.1.2   root     1511:   /* Now we choose between stupid (pcc-like) register allocation
                   1512:      (if we got the -noreg switch and not -opt)
                   1513:      and smart register allocation.  */
1.1       root     1514: 
1.1.1.2   root     1515:   if (optimize)                /* Stupid allocation probably won't work */
                   1516:     obey_regdecls = 0; /* if optimizations being done.  */
1.1       root     1517: 
1.1.1.2   root     1518:   regclass_init ();
1.1       root     1519: 
1.1.1.2   root     1520:   /* Print function header into flow dump now
                   1521:      because doing the flow analysis makes some of the dump.  */
1.1       root     1522: 
1.1.1.2   root     1523:   if (flow_dump)
                   1524:     TIMEVAR (dump_time,
                   1525:             {
                   1526:               fprintf (flow_dump_file, "\n;; Function %s\n\n",
                   1527:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1528:             });
                   1529: 
                   1530:   if (obey_regdecls)
                   1531:     {
                   1532:       TIMEVAR (flow_time,
                   1533:               {
                   1534:                 regclass (insns, max_reg_num ());
                   1535:                 stupid_life_analysis (insns, max_reg_num (),
                   1536:                                       flow_dump_file);
                   1537:               });
                   1538:     }
                   1539:   else
                   1540:     {
                   1541:       /* Do control and data flow analysis,
                   1542:         and write some of the results to dump file.  */
1.1       root     1543: 
1.1.1.2   root     1544:       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
                   1545:                                         flow_dump_file));
                   1546:       if (extra_warnings)
                   1547:        uninitialized_vars_warning (DECL_INITIAL (decl));
                   1548:     }
1.1       root     1549: 
1.1.1.2   root     1550:   /* Dump rtl after flow analysis.  */
1.1       root     1551: 
1.1.1.2   root     1552:   if (flow_dump)
                   1553:     TIMEVAR (dump_time,
                   1554:             {
                   1555:               print_rtl (flow_dump_file, insns);
                   1556:               fflush (flow_dump_file);
                   1557:             });
1.1       root     1558: 
1.1.1.2   root     1559:   /* If -opt, try combining insns through substitution.  */
1.1       root     1560: 
1.1.1.2   root     1561:   if (optimize)
                   1562:     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
1.1       root     1563: 
1.1.1.2   root     1564:   /* Dump rtl code after insn combination.  */
1.1       root     1565: 
1.1.1.2   root     1566:   if (combine_dump)
                   1567:     TIMEVAR (dump_time,
                   1568:             {
                   1569:               fprintf (combine_dump_file, "\n;; Function %s\n\n",
                   1570:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1571:               dump_combine_stats (combine_dump_file);
                   1572:               print_rtl (combine_dump_file, insns);
                   1573:               fflush (combine_dump_file);
                   1574:             });
1.1       root     1575: 
1.1.1.2   root     1576:   /* Unless we did stupid register allocation,
                   1577:      allocate pseudo-regs that are used only within 1 basic block.  */
1.1       root     1578: 
1.1.1.2   root     1579:   if (!obey_regdecls)
                   1580:     TIMEVAR (local_alloc_time,
                   1581:             {
                   1582:               regclass (insns, max_reg_num ());
                   1583:               local_alloc ();
                   1584:             });
1.1       root     1585: 
1.1.1.2   root     1586:   /* Dump rtl code after allocating regs within basic blocks.  */
1.1       root     1587: 
1.1.1.2   root     1588:   if (local_reg_dump)
                   1589:     TIMEVAR (dump_time,
                   1590:             {
                   1591:               fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
                   1592:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1593:               dump_flow_info (local_reg_dump_file);
                   1594:               dump_local_alloc (local_reg_dump_file);
                   1595:               print_rtl (local_reg_dump_file, insns);
                   1596:               fflush (local_reg_dump_file);
                   1597:             });
1.1       root     1598: 
1.1.1.2   root     1599:   if (global_reg_dump)
                   1600:     TIMEVAR (dump_time,
                   1601:             fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
                   1602:                      IDENTIFIER_POINTER (DECL_NAME (decl))));
                   1603: 
                   1604:   /* Unless we did stupid register allocation,
                   1605:      allocate remaining pseudo-regs, then do the reload pass
                   1606:      fixing up any insns that are invalid.  */
                   1607: 
                   1608:   TIMEVAR (global_alloc_time,
                   1609:           {
                   1610:             if (!obey_regdecls)
                   1611:               global_alloc (global_reg_dump ? global_reg_dump_file : 0);
                   1612:             else
                   1613:               reload (insns, 0,
                   1614:                       global_reg_dump ? global_reg_dump_file : 0);
                   1615:           });
                   1616: 
                   1617:   if (global_reg_dump)
                   1618:     TIMEVAR (dump_time,
                   1619:             {
                   1620:               dump_global_regs (global_reg_dump_file);
                   1621:               print_rtl (global_reg_dump_file, insns);
                   1622:               fflush (global_reg_dump_file);
                   1623:             });
1.1       root     1624: 
1.1.1.12  root     1625:   rtx_equal_function_value_matters = 1;
1.1.1.11  root     1626:   reload_completed = 1;
                   1627: 
1.1.1.2   root     1628:   /* One more attempt to remove jumps to .+1
                   1629:      left by dead-store-elimination.
                   1630:      Also do cross-jumping this time
                   1631:      and delete no-op move insns.  */
1.1       root     1632: 
1.1.1.2   root     1633:   if (optimize)
                   1634:     {
                   1635:       TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
                   1636:     }
1.1       root     1637: 
1.1.1.2   root     1638:   /* Dump rtl code after jump, if we are doing that.  */
                   1639: 
                   1640:   if (jump2_opt_dump)
                   1641:     TIMEVAR (dump_time,
                   1642:             {
                   1643:               fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
                   1644:                        IDENTIFIER_POINTER (DECL_NAME (decl)));
                   1645:               print_rtl (jump2_opt_dump_file, insns);
                   1646:               fflush (jump2_opt_dump_file);
                   1647:             });
                   1648: 
1.1.1.16! root     1649:   /* If a scheduling pass for delayed branches is to be done,
        !          1650:      call the scheduling code. */
        !          1651: 
        !          1652: #ifdef HAVE_DELAYED_BRANCH
        !          1653:   if (optimize && flag_delayed_branch)
        !          1654:     {
        !          1655:       TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
        !          1656:       if (dbr_sched_dump)
        !          1657:        {
        !          1658:          TIMEVAR (dump_time,
        !          1659:                 {
        !          1660:                   fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
        !          1661:                            IDENTIFIER_POINTER (DECL_NAME (decl)));
        !          1662:                   print_rtl (dbr_sched_dump_file, insns);
        !          1663:                   fflush (dbr_sched_dump_file);
        !          1664:                 });
        !          1665:        }
        !          1666:     }
        !          1667: #endif
        !          1668: 
1.1.1.2   root     1669:   /* Now turn the rtl into assembler code.  */
                   1670: 
                   1671:   TIMEVAR (final_time,
                   1672:           {
                   1673:             assemble_function (decl);
                   1674:             final_start_function (insns, asm_out_file,
                   1675:                                   write_symbols, optimize);
                   1676:             final (insns, asm_out_file,
1.1.1.9   root     1677:                    write_symbols, optimize, 0);
1.1.1.2   root     1678:             final_end_function (insns, asm_out_file,
                   1679:                                 write_symbols, optimize);
                   1680:             fflush (asm_out_file);
                   1681:           });
1.1       root     1682: 
1.1.1.2   root     1683:   /* Write GDB symbols if requested */
1.1       root     1684: 
1.1.1.4   root     1685:   if (write_symbols == GDB_DEBUG)
1.1.1.2   root     1686:     {
                   1687:       TIMEVAR (symout_time,
                   1688:               {
                   1689:                 symout_types (get_permanent_types ());
                   1690:                 symout_types (get_temporary_types ());
                   1691: 
                   1692:                 DECL_BLOCK_SYMTAB_ADDRESS (decl)
                   1693:                   = symout_function (DECL_INITIAL (decl),
                   1694:                                      DECL_ARGUMENTS (decl), 0);
1.1.1.6   root     1695:                 symout_function_end ();
1.1.1.2   root     1696:               });
1.1       root     1697:     }
1.1.1.2   root     1698:   else
                   1699:     get_temporary_types ();
                   1700: 
                   1701:   /* Write DBX symbols if requested */
                   1702: 
1.1.1.4   root     1703: #ifdef DBX_DEBUGGING_INFO
                   1704:   if (write_symbols == DBX_DEBUG)
1.1.1.2   root     1705:     TIMEVAR (symout_time, dbxout_function (decl));
1.1.1.4   root     1706: #endif
1.1       root     1707: 
                   1708:  exit_rest_of_compilation:
                   1709: 
1.1.1.12  root     1710:   rtx_equal_function_value_matters = 0;
1.1.1.11  root     1711:   reload_completed = 0;
                   1712: 
1.1.1.8   root     1713:   /* Clear out the real_constant_chain before some of the rtx's
                   1714:      it runs through become garbage.  */
                   1715: 
                   1716:   clear_const_double_mem ();
                   1717: 
1.1       root     1718:   /* The parsing time is all the time spent in yyparse
                   1719:      *except* what is spent in this function.  */
                   1720: 
                   1721:   parse_time -= gettime () - start_time;
                   1722: }
                   1723: 
                   1724: /* Entry point of cc1.  Decode command args, then call compile_file.
1.1.1.2   root     1725:    Exit code is 35 if can't open files, 34 if fatal error,
                   1726:    33 if had nonfatal errors, else success.  */
1.1       root     1727: 
                   1728: int
                   1729: main (argc, argv, envp)
                   1730:      int argc;
                   1731:      char **argv;
                   1732:      char **envp;
                   1733: {
                   1734:   register int i;
1.1.1.2   root     1735:   char *filename = 0;
                   1736:   int print_mem_flag = 0;
1.1.1.16! root     1737:   char *p;
        !          1738: 
        !          1739:   /* save in case md file wants to emit args as a comment.  */
        !          1740:   save_argc = argc;
        !          1741:   save_argv = argv;
        !          1742: 
        !          1743:   p = argv[0] + strlen (argv[0]);
        !          1744:   while (p != argv[0] && p[-1] != '/') --p;
        !          1745:   progname = p;
1.1.1.2   root     1746: 
                   1747: #ifdef RLIMIT_STACK
                   1748:   /* Get rid of any avoidable limit on stack size.  */
                   1749:   {
                   1750:     struct rlimit rlim;
                   1751: 
                   1752:     /* Set the stack limit huge so that alloca does not fail. */
                   1753:     getrlimit (RLIMIT_STACK, &rlim);
                   1754:     rlim.rlim_cur = rlim.rlim_max;
                   1755:     setrlimit (RLIMIT_STACK, &rlim);
                   1756:   }
                   1757: #endif /* RLIMIT_STACK */
                   1758: 
1.1.1.10  root     1759:   signal (SIGFPE, float_signal);
                   1760: 
1.1.1.13  root     1761:   signal (SIGPIPE, pipe_closed);
                   1762: 
1.1.1.2   root     1763:   /* Initialize whether `char' is signed.  */
                   1764:   flag_signed_char = DEFAULT_SIGNED_CHAR;
1.1.1.16! root     1765: #ifdef DEFAULT_SHORT_ENUMS
        !          1766:   /* Initialize how much space enums occupy, by default.  */
        !          1767:   flag_short_enums = DEFAULT_SHORT_ENUMS;
        !          1768: #endif
1.1.1.2   root     1769: 
1.1.1.4   root     1770:   /* This is zeroed by -O.  */
                   1771:   obey_regdecls = 1;
                   1772: 
                   1773:   /* Initialize register usage now so switches may override.  */
1.1.1.2   root     1774:   init_reg_sets ();
1.1       root     1775: 
                   1776:   target_flags = 0;
                   1777:   set_target_switch ("");
                   1778: 
                   1779:   for (i = 1; i < argc; i++)
1.1.1.13  root     1780:     if (argv[i][0] == '-' && argv[i][1] != 0)
1.1       root     1781:       {
                   1782:        register char *str = argv[i] + 1;
                   1783:        if (str[0] == 'Y')
                   1784:          str++;
                   1785: 
                   1786:        if (str[0] == 'm')
                   1787:          set_target_switch (&str[1]);
                   1788:        else if (!strcmp (str, "dumpbase"))
                   1789:          {
                   1790:            dump_base_name = argv[++i];
                   1791:          }
                   1792:        else if (str[0] == 'd')
                   1793:          {
                   1794:            register char *p = &str[1];
                   1795:            while (*p)
                   1796:              switch (*p++)
                   1797:                {
                   1798:                case 'c':
                   1799:                  combine_dump = 1;
                   1800:                  break;
1.1.1.16! root     1801:                case 'd':
        !          1802:                  dbr_sched_dump = 1;
        !          1803:                  break;
1.1       root     1804:                case 'f':
                   1805:                  flow_dump = 1;
                   1806:                  break;
                   1807:                case 'g':
                   1808:                  global_reg_dump = 1;
                   1809:                  break;
                   1810:                case 'j':
                   1811:                  jump_opt_dump = 1;
                   1812:                  break;
1.1.1.2   root     1813:                case 'J':
                   1814:                  jump2_opt_dump = 1;
                   1815:                  break;
1.1       root     1816:                case 'l':
                   1817:                  local_reg_dump = 1;
                   1818:                  break;
                   1819:                case 'L':
                   1820:                  loop_dump = 1;
                   1821:                  break;
1.1.1.2   root     1822:                case 'm':
                   1823:                  print_mem_flag = 1;
                   1824:                  break;
1.1       root     1825:                case 'r':
                   1826:                  rtl_dump = 1;
                   1827:                  break;
                   1828:                case 's':
                   1829:                  cse_dump = 1;
                   1830:                  break;
                   1831:                case 'y':
                   1832:                  yydebug = 1;
                   1833:                  break;
                   1834:                }
                   1835:          }
1.1.1.2   root     1836:        else if (str[0] == 'f')
                   1837:          {
1.1.1.12  root     1838:            int j;
1.1.1.2   root     1839:            register char *p = &str[1];
1.1.1.12  root     1840:            int found = 0;
                   1841: 
                   1842:            /* Some kind of -f option.
                   1843:               P's value is the option sans `-f'.
                   1844:               Search for it in the table of options.  */
                   1845: 
                   1846:            for (j = 0;
                   1847:                 !found && j < sizeof (f_options) / sizeof (f_options[0]);
                   1848:                 j++)
                   1849:              {
                   1850:                if (!strcmp (p, f_options[j].string))
                   1851:                  {
                   1852:                    *f_options[j].variable = f_options[j].on_value;
                   1853:                    /* A goto here would be cleaner,
                   1854:                       but breaks the vax pcc.  */
                   1855:                    found = 1;
                   1856:                  }
1.1.1.13  root     1857:                if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
1.1.1.12  root     1858:                    && ! strcmp (p+3, f_options[j].string))
                   1859:                  {
                   1860:                    *f_options[j].variable = ! f_options[j].on_value;
                   1861:                    found = 1;
                   1862:                  }
                   1863:              }
                   1864: 
                   1865:            if (found)
                   1866:              ;
1.1.1.2   root     1867:            else if (!strncmp (p, "fixed-", 6))
                   1868:              fix_register (&p[6], 1, 1);
                   1869:            else if (!strncmp (p, "call-used-", 10))
                   1870:              fix_register (&p[10], 0, 1);
                   1871:            else if (!strncmp (p, "call-saved-", 11))
                   1872:              fix_register (&p[11], 0, 0);
1.1.1.7   root     1873:            else if (! lang_decode_option (argv[i]))
1.1.1.16! root     1874:              error ("Invalid option `%s'", argv[i]);
1.1.1.2   root     1875:          }
1.1       root     1876:        else if (!strcmp (str, "noreg"))
1.1.1.4   root     1877:          ;
1.1.1.2   root     1878:        else if (!strcmp (str, "opt"))
1.1.1.4   root     1879:          optimize = 1, obey_regdecls = 0;
                   1880:        else if (!strcmp (str, "O"))
                   1881:          optimize = 1, obey_regdecls = 0;
1.1.1.2   root     1882:        else if (!strcmp (str, "pedantic"))
                   1883:          pedantic = 1;
1.1.1.7   root     1884:        else if (lang_decode_option (argv[i]))
                   1885:          ;
1.1.1.2   root     1886:        else if (!strcmp (str, "quiet"))
                   1887:          quiet_flag = 1;
                   1888:        else if (!strcmp (str, "version"))
                   1889:          {
1.1.1.7   root     1890:            extern char *version_string, *language_string;
1.1.1.12  root     1891:            fprintf (stderr, "%s version %s", language_string, version_string);
1.1.1.2   root     1892: #ifdef TARGET_VERSION
                   1893:            TARGET_VERSION;
                   1894: #endif
                   1895: #ifdef __GNUC__
                   1896: #ifndef __VERSION__
                   1897: #define __VERSION__ "[unknown]"
                   1898: #endif
1.1.1.12  root     1899:            fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
1.1.1.2   root     1900: #else
1.1.1.12  root     1901:            fprintf (stderr, " compiled by CC.\n");
1.1.1.2   root     1902: #endif
1.1.1.16! root     1903:            print_target_switch_defaults ();
1.1.1.2   root     1904:          }
1.1       root     1905:        else if (!strcmp (str, "w"))
                   1906:          inhibit_warnings = 1;
1.1.1.2   root     1907:        else if (!strcmp (str, "W"))
                   1908:          extra_warnings = 1;
1.1.1.9   root     1909:        else if (!strcmp (str, "Wunused"))
                   1910:          warn_unused = 1;
1.1.1.15  root     1911:        else if (!strcmp (str, "Wshadow"))
                   1912:          warn_shadow = 1;
                   1913:        else if (!strcmp (str, "Wswitch"))
                   1914:          warn_switch = 1;
                   1915:        else if (!strncmp (str, "Wid-clash-", 10))
                   1916:          {
                   1917:            char *endp = str + 10;
                   1918: 
                   1919:            while (*endp)
                   1920:              {
                   1921:                if (*endp >= '0' && *endp <= '9')
                   1922:                  endp++;
                   1923:                else
                   1924:                  error ("Invalid option `%s'", argv[i]);
                   1925:              }
                   1926:            warn_id_clash = 1;
                   1927:            id_clash_len = atoi (str + 10);
                   1928:          }
1.1.1.2   root     1929:        else if (!strcmp (str, "p"))
                   1930:          profile_flag = 1;
1.1.1.14  root     1931:        else if (!strcmp (str, "a"))
                   1932:          {
                   1933: #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
                   1934:            warning ("`-a' option (basic block profile) not supported");
                   1935: #else
                   1936:            profile_block_flag = 1;
                   1937: #endif
                   1938:          }
1.1.1.4   root     1939:        else if (!strcmp (str, "gg"))
                   1940:          write_symbols = GDB_DEBUG;
                   1941: #ifdef DBX_DEBUGGING_INFO
1.1.1.16! root     1942:        else if (!strcmp (str, "g0"))
1.1.1.4   root     1943:          write_symbols = DBX_DEBUG;
1.1.1.16! root     1944:        else if (!strcmp (str, "G0"))
1.1.1.4   root     1945:          write_symbols = DBX_DEBUG;
1.1.1.16! root     1946:        else if (!strcmp (str, "g"))
        !          1947:          {
        !          1948:            write_symbols = DBX_DEBUG;
        !          1949:            use_gdb_dbx_extensions = 1;
        !          1950:          }
        !          1951:        else if (!strcmp (str, "G"))
        !          1952:          {
        !          1953:            write_symbols = DBX_DEBUG;
        !          1954:            use_gdb_dbx_extensions = 1;
        !          1955:          }
1.1.1.4   root     1956: #endif
                   1957: #ifdef SDB_DEBUGGING_INFO
                   1958:        else if (!strcmp (str, "g"))
                   1959:          write_symbols = SDB_DEBUG;
                   1960:        else if (!strcmp (str, "G"))
                   1961:          write_symbols = SDB_DEBUG;
1.1.1.16! root     1962:        else if (!strcmp (str, "g0"))
        !          1963:          write_symbols = SDB_DEBUG;
        !          1964:        else if (!strcmp (str, "G0"))
        !          1965:          write_symbols = SDB_DEBUG;
1.1.1.4   root     1966: #endif
1.1       root     1967:        else if (!strcmp (str, "symout"))
                   1968:          {
1.1.1.4   root     1969:            if (write_symbols == NO_DEBUG)
                   1970:              write_symbols = GDB_DEBUG;
1.1       root     1971:            sym_file_name = argv[++i];
                   1972:          }
                   1973:        else if (!strcmp (str, "o"))
                   1974:          {
                   1975:            asm_file_name = argv[++i];
                   1976:          }
                   1977:        else
1.1.1.7   root     1978:          error ("Invalid option `%s'", argv[i]);
1.1       root     1979:       }
                   1980:     else
                   1981:       filename = argv[i];
                   1982: 
1.1.1.2   root     1983: #ifdef OVERRIDE_OPTIONS
                   1984:   /* Some machines may reject certain combinations of options.  */
                   1985:   OVERRIDE_OPTIONS;
                   1986: #endif
                   1987: 
1.1.1.4   root     1988:   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
                   1989:   init_reg_sets_1 ();
                   1990: 
1.1       root     1991:   compile_file (filename);
                   1992: 
1.1.1.2   root     1993: #ifndef USG
                   1994: #ifndef VMS
                   1995:   if (print_mem_flag)
                   1996:     {
                   1997:       extern char **environ;
1.1.1.16! root     1998:       char *lim = (char *) sbrk (0);
        !          1999: 
1.1.1.2   root     2000:       fprintf (stderr, "Data size %d.\n",
                   2001:               (int) lim - (int) &environ);
                   2002:       fflush (stderr);
                   2003: 
                   2004:       system ("ps v");
                   2005:     }
                   2006: #endif /* not VMS */
                   2007: #endif /* not USG */
                   2008: 
1.1       root     2009:   if (errorcount)
1.1.1.2   root     2010:     exit (FATAL_EXIT_CODE);
1.1.1.7   root     2011:   if (sorrycount)
                   2012:     exit (FATAL_EXIT_CODE);
1.1.1.2   root     2013:   exit (SUCCESS_EXIT_CODE);
                   2014:   return 34;
1.1       root     2015: }
                   2016: 
                   2017: /* Decode -m switches.  */
                   2018: 
                   2019: /* Here is a table, controlled by the tm-...h file, listing each -m switch
                   2020:    and which bits in `target_switches' it should set or clear.
                   2021:    If VALUE is positive, it is bits to set.
                   2022:    If VALUE is negative, -VALUE is bits to clear.
                   2023:    (The sign bit is not used so there is no confusion.)  */
                   2024: 
                   2025: struct {char *name; int value;} target_switches []
                   2026:   = TARGET_SWITCHES;
                   2027: 
                   2028: /* Decode the switch -mNAME.  */
                   2029: 
1.1.1.2   root     2030: void
1.1       root     2031: set_target_switch (name)
                   2032:      char *name;
                   2033: {
1.1.1.2   root     2034:   register int j;
1.1       root     2035:   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
                   2036:     if (!strcmp (target_switches[j].name, name))
                   2037:       {
                   2038:        if (target_switches[j].value < 0)
                   2039:          target_flags &= ~-target_switches[j].value;
                   2040:        else
                   2041:          target_flags |= target_switches[j].value;
1.1.1.7   root     2042:        return;
1.1       root     2043:       }
1.1.1.7   root     2044:   error ("Invalid option `%s'", name);
1.1       root     2045: }
1.1.1.16! root     2046: 
        !          2047: /* Print default target switches for -version.  */
        !          2048: 
        !          2049: void
        !          2050: print_target_switch_defaults ()
        !          2051: {
        !          2052:   register int j;
        !          2053:   register int mask = TARGET_DEFAULT;
        !          2054:   fprintf (stderr, "default target switches:");
        !          2055:   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
        !          2056:     if (target_switches[j].name[0] != '\0'
        !          2057:        && target_switches[j].value > 0
        !          2058:        && (target_switches[j].value & mask) == target_switches[j].value)
        !          2059: 
        !          2060:       fprintf (stderr, " -m%s", target_switches[j].name);
        !          2061: 
        !          2062:   fprintf (stderr, "\n");
        !          2063: }

unix.superglobalmegacorp.com

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