home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / g__src3 / toplev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-23  |  55.0 KB  |  2,173 lines

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