Annotation of gcc/toplev.c, revision 1.1.1.20

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

unix.superglobalmegacorp.com

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