home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / gcc-2.3.3-src.lha / GNU / src / amiga / gcc-2.3.3 / toplev.c < prev    next >
C/C++ Source or Header  |  1994-02-06  |  92KB  |  3,424 lines

  1. /* Top level of GNU C compiler
  2.    Copyright (C) 1987, 1988, 1989, 1992 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 2, 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 <sys/types.h>
  28. #include <stdio.h>
  29. #include <signal.h>
  30. #include <setjmp.h>
  31.  
  32. #include <sys/stat.h>
  33.  
  34. #ifdef USG
  35. #undef FLOAT
  36. #include <sys/param.h>
  37. /* This is for hpux.  It is a real screw.  They should change hpux.  */
  38. #undef FLOAT
  39. #include <sys/times.h>
  40. #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
  41. #undef FFS  /* Some systems define this in param.h.  */
  42. #else
  43. #ifndef VMS
  44. #include <sys/time.h>
  45. #include <sys/resource.h>
  46. #endif
  47. #endif
  48.  
  49. #include "input.h"
  50. #include "tree.h"
  51. /* #include "c-tree.h" */
  52. #include "rtl.h"
  53. #include "flags.h"
  54. #include "insn-attr.h"
  55.  
  56. #ifdef XCOFF_DEBUGGING_INFO
  57. #include "xcoffout.h"
  58. #endif
  59.  
  60. #ifdef VMS
  61. /* The extra parameters substantially improve the I/O performance.  */
  62. static FILE *
  63. VMS_fopen (fname, type)
  64.      char * fname;
  65.      char * type;
  66. {
  67.   if (strcmp (type, "w") == 0)
  68.     return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil");
  69.   return fopen (fname, type, "mbc=16");
  70. }
  71. #define fopen VMS_fopen
  72. #endif
  73.  
  74. #ifndef DEFAULT_GDB_EXTENSIONS
  75. #define DEFAULT_GDB_EXTENSIONS 1
  76. #endif
  77.  
  78. extern int rtx_equal_function_value_matters;
  79.  
  80. #if ! (defined (VMS) || defined (OS2))
  81. extern char **environ;
  82. #endif
  83. extern char *version_string, *language_string;
  84.  
  85. extern void init_lex ();
  86. extern void init_decl_processing ();
  87. extern void init_obstacks ();
  88. extern void init_tree_codes ();
  89. extern void init_rtl ();
  90. extern void init_optabs ();
  91. extern void init_stmt ();
  92. extern void init_reg_sets ();
  93. extern void dump_flow_info ();
  94. extern void dump_sched_info ();
  95. extern void dump_local_alloc ();
  96.  
  97. void rest_of_decl_compilation ();
  98. void error ();
  99. void error_with_file_and_line ();
  100. void fancy_abort ();
  101. #ifndef abort
  102. void abort ();
  103. #endif
  104. void set_target_switch ();
  105. static void print_switch_values ();
  106. static char *decl_name ();
  107.  
  108. /* Name of program invoked, sans directories.  */
  109.  
  110. char *progname;
  111.  
  112. /* Copy of arguments to main.  */
  113. int save_argc;
  114. char **save_argv;
  115.  
  116. /* Name of current original source file (what was input to cpp).
  117.    This comes from each #-command in the actual input.  */
  118.  
  119. char *input_filename;
  120.  
  121. /* Name of top-level original source file (what was input to cpp).
  122.    This comes from the #-command at the beginning of the actual input.
  123.    If there isn't any there, then this is the cc1 input file name.  */
  124.  
  125. char *main_input_filename;
  126.  
  127. /* Stream for reading from the input file.  */
  128.  
  129. FILE *finput;
  130.  
  131. /* Current line number in real source file.  */
  132.  
  133. int lineno;
  134.  
  135. /* Stack of currently pending input files.  */
  136.  
  137. struct file_stack *input_file_stack;
  138.  
  139. /* Incremented on each change to input_file_stack.  */
  140. int input_file_stack_tick;
  141.  
  142. /* FUNCTION_DECL for function now being parsed or compiled.  */
  143.  
  144. extern tree current_function_decl;
  145.  
  146. /* Name to use as base of names for dump output files.  */
  147.  
  148. char *dump_base_name;
  149.  
  150. /* Bit flags that specify the machine subtype we are compiling for.
  151.    Bits are tested using macros TARGET_... defined in the tm.h file
  152.    and set by `-m...' switches.  Must be defined in rtlanal.c.  */
  153.  
  154. extern int target_flags;
  155.  
  156. /* Flags saying which kinds of debugging dump have been requested.  */
  157.  
  158. int rtl_dump = 0;
  159. int rtl_dump_and_exit = 0;
  160. int jump_opt_dump = 0;
  161. int cse_dump = 0;
  162. int loop_dump = 0;
  163. int cse2_dump = 0;
  164. int flow_dump = 0;
  165. int combine_dump = 0;
  166. int sched_dump = 0;
  167. int local_reg_dump = 0;
  168. int global_reg_dump = 0;
  169. int sched2_dump = 0;
  170. int jump2_opt_dump = 0;
  171. int dbr_sched_dump = 0;
  172. int flag_print_asm_name = 0;
  173. int stack_reg_dump = 0;
  174.  
  175. /* Name for output file of assembly code, specified with -o.  */
  176.  
  177. char *asm_file_name;
  178.  
  179. /* Value of the -G xx switch, and whether it was passed or not.  */
  180. int g_switch_value;
  181. int g_switch_set;
  182.  
  183. /* Type(s) of debugging information we are producing (if any).
  184.    See flags.h for the definitions of the different possible
  185.    types of debugging information.  */
  186. enum debug_info_type write_symbols = NO_DEBUG;
  187.  
  188. /* Level of debugging information we are producing.  See flags.h
  189.    for the definitions of the different possible levels.  */
  190. enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
  191.  
  192. /* Nonzero means use GNU-only extensions in the generated symbolic
  193.    debugging information.  */
  194. /* Currently, this only has an effect when write_symbols is set to
  195.    DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG.  */
  196. int use_gnu_debug_info_extensions = 0;
  197.  
  198. /* Nonzero means do optimizations.  -O.
  199.    Particular numeric values stand for particular amounts of optimization;
  200.    thus, -O2 stores 2 here.  However, the optimizations beyond the basic
  201.    ones are not controlled directly by this variable.  Instead, they are
  202.    controlled by individual `flag_...' variables that are defaulted
  203.    based on this variable.  */
  204.  
  205. int optimize = 0;
  206.  
  207. /* Number of error messages and warning messages so far.  */
  208.  
  209. int errorcount = 0;
  210. int warningcount = 0;
  211. int sorrycount = 0;
  212.  
  213. /* Pointer to function to compute the name to use to print a declaration.  */
  214.  
  215. char *(*decl_printable_name) ();
  216.  
  217. /* Pointer to function to compute rtl for a language-specific tree code.  */
  218.  
  219. struct rtx_def *(*lang_expand_expr) ();
  220.  
  221. /* Nonzero if generating code to do profiling.  */
  222.  
  223. int profile_flag = 0;
  224.  
  225. /* Nonzero if generating code to do profiling on a line-by-line basis.  */
  226.  
  227. int profile_block_flag;
  228.  
  229. /* Nonzero for -pedantic switch: warn about anything
  230.    that standard spec forbids.  */
  231.  
  232. int pedantic = 0;
  233.  
  234. /* Temporarily suppress certain warnings.
  235.    This is set while reading code from a system header file.  */
  236.  
  237. int in_system_header = 0;
  238.  
  239. /* Nonzero means do stupid register allocation.
  240.    Currently, this is 1 if `optimize' is 0.  */
  241.  
  242. int obey_regdecls = 0;
  243.  
  244. /* Don't print functions as they are compiled and don't print
  245.    times taken by the various passes.  -quiet.  */
  246.  
  247. int quiet_flag = 0;
  248.  
  249. /* -f flags.  */
  250.  
  251. /* Nonzero means `char' should be signed.  */
  252.  
  253. int flag_signed_char;
  254.  
  255. /* Nonzero means give an enum type only as many bytes as it needs.  */
  256.  
  257. int flag_short_enums;
  258.  
  259. /* Nonzero for -fcaller-saves: allocate values in regs that need to
  260.    be saved across function calls, if that produces overall better code.
  261.    Optional now, so people can test it.  */
  262.  
  263. #ifdef DEFAULT_CALLER_SAVES
  264. int flag_caller_saves = 1;
  265. #else
  266. int flag_caller_saves = 0;
  267. #endif
  268.  
  269. /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
  270.  
  271. int flag_pcc_struct_return = 0;
  272.  
  273. /* Nonzero for -fforce-mem: load memory value into a register
  274.    before arithmetic on it.  This makes better cse but slower compilation.  */
  275.  
  276. int flag_force_mem = 0;
  277.  
  278. /* Nonzero for -fforce-addr: load memory address into a register before
  279.    reference to memory.  This makes better cse but slower compilation.  */
  280.  
  281. int flag_force_addr = 0;
  282.  
  283. /* Nonzero for -fdefer-pop: don't pop args after each function call;
  284.    instead save them up to pop many calls' args with one insns.  */
  285.  
  286. int flag_defer_pop = 1;
  287.  
  288. /* Nonzero for -ffloat-store: don't allocate floats and doubles
  289.    in extended-precision registers.  */
  290.  
  291. int flag_float_store = 0;
  292.  
  293. /* Nonzero for -fcse-follow-jumps:
  294.    have cse follow jumps to do a more extensive job.  */
  295.  
  296. int flag_cse_follow_jumps;
  297.  
  298. /* Nonzero for -fcse-skip-blocks:
  299.    have cse follow a branch around a block.  */
  300. int flag_cse_skip_blocks;
  301.  
  302. /* Nonzero for -fexpensive-optimizations:
  303.    perform miscellaneous relatively-expensive optimizations.  */
  304. int flag_expensive_optimizations;
  305.  
  306. /* Nonzero for -fthread-jumps:
  307.    have jump optimize output of loop.  */
  308.  
  309. int flag_thread_jumps;
  310.  
  311. /* Nonzero enables strength-reduction in loop.c.  */
  312.  
  313. int flag_strength_reduce = 0;
  314.  
  315. /* Nonzero enables loop unrolling in unroll.c.  Only loops for which the
  316.    number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
  317.    UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
  318.    unrolled.  */
  319.  
  320. int flag_unroll_loops;
  321.  
  322. /* Nonzero enables loop unrolling in unroll.c.  All loops are unrolled.
  323.    This is generally not a win.  */
  324.  
  325. int flag_unroll_all_loops;
  326.  
  327. /* Nonzero for -fwritable-strings:
  328.    store string constants in data segment and don't uniquize them.  */
  329.  
  330. int flag_writable_strings = 0;
  331.  
  332. /* Nonzero means don't put addresses of constant functions in registers.
  333.    Used for compiling the Unix kernel, where strange substitutions are
  334.    done on the assembly output.  */
  335.  
  336. int flag_no_function_cse = 0;
  337.  
  338. /* Nonzero for -fomit-frame-pointer:
  339.    don't make a frame pointer in simple functions that don't require one.  */
  340.  
  341. int flag_omit_frame_pointer = 0;
  342.  
  343. /* Nonzero to inhibit use of define_optimization peephole opts.  */
  344.  
  345. int flag_no_peephole = 0;
  346.  
  347. /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
  348.    operations in the interest of optimization.  For example it allows
  349.    GCC to assume arguments to sqrt are nonnegative numbers, allowing
  350.    faster code for sqrt to be generated. */
  351.  
  352. int flag_fast_math = 0;
  353.  
  354. /* Nonzero means all references through pointers are volatile.  */
  355.  
  356. int flag_volatile;
  357.  
  358. /* Nonzero means just do syntax checking; don't output anything.  */
  359.  
  360. int flag_syntax_only = 0;
  361.  
  362. /* Nonzero means to rerun cse after loop optimization.  This increases
  363.    compilation time about 20% and picks up a few more common expressions.  */
  364.  
  365. static int flag_rerun_cse_after_loop;
  366.  
  367. /* Nonzero for -finline-functions: ok to inline functions that look like
  368.    good inline candidates.  */
  369.  
  370. int flag_inline_functions;
  371.  
  372. /* Nonzero for -fkeep-inline-functions: even if we make a function
  373.    go inline everywhere, keep its defintion around for debugging
  374.    purposes.  */
  375.  
  376. int flag_keep_inline_functions;
  377.  
  378. /* Nonzero means that functions declared `inline' will be treated
  379.    as `static'.  Prevents generation of zillions of copies of unused
  380.    static inline functions; instead, `inlines' are written out
  381.    only when actually used.  Used in conjunction with -g.  Also
  382.    does the right thing with #pragma interface.  */
  383.  
  384. int flag_no_inline;
  385.  
  386. /* Nonzero means we should be saving declaration info into a .X file.  */
  387.  
  388. int flag_gen_aux_info = 0;
  389.  
  390. /* Specified name of aux-info file.  */
  391.  
  392. static char *aux_info_file_name;
  393.  
  394. /* Nonzero means make the text shared if supported.  */
  395.  
  396. int flag_shared_data;
  397.  
  398. /* Nonzero means schedule into delayed branch slots if supported.  */
  399.  
  400. int flag_delayed_branch;
  401.  
  402. /* Nonzero if we are compiling pure (sharable) code.
  403.    Value is 1 if we are doing reasonable (i.e. simple
  404.    offset into offset table) pic.  Value is 2 if we can
  405.    only perform register offsets.  */
  406.  
  407. int flag_pic;
  408.  
  409. /* Nonzero means place uninitialized global data in the bss section. */
  410.  
  411. int flag_no_common;
  412.  
  413. /* Nonzero means pretend it is OK to examine bits of target floats,
  414.    even if that isn't true.  The resulting code will have incorrect constants,
  415.    but the same series of instructions that the native compiler would make.  */
  416.  
  417. int flag_pretend_float;
  418.  
  419. /* Nonzero means change certain warnings into errors.
  420.    Usually these are warnings about failure to conform to some standard.  */
  421.  
  422. int flag_pedantic_errors = 0;
  423.  
  424. /* flag_schedule_insns means schedule insns within basic blocks (before
  425.    local_alloc).
  426.    flag_schedule_insns_after_reload means schedule insns after
  427.    global_alloc.  */
  428.  
  429. int flag_schedule_insns = 0;
  430. int flag_schedule_insns_after_reload = 0;
  431.  
  432. /* -finhibit-size-directive inhibits output of .size for ELF.
  433.    This is used only for compiling crtstuff.c, 
  434.    and it may be extended to other effects
  435.    needed for crtstuff.c on other systems.  */
  436. int flag_inhibit_size_directive = 0;
  437.  
  438. /* -fverbose-asm causes extra commentary information to be produced in
  439.    the generated assembly code (to make it more readable).  This option
  440.    is generally only of use to those who actually need to read the
  441.    generated assembly code (perhaps while debugging the compiler itself).  */
  442.  
  443. int flag_verbose_asm = 0;
  444.  
  445. /* -fgnu-linker specifies use of the GNU linker for initializations.
  446.    (Or, more generally, a linker that handles initializations.)
  447.    -fno-gnu-linker says that collect2 will be used.  */
  448. #ifdef USE_COLLECT2
  449. int flag_gnu_linker = 0;
  450. #else
  451. int flag_gnu_linker = 1;
  452. #endif
  453.  
  454. /* Table of language-independent -f options.
  455.    STRING is the option name.  VARIABLE is the address of the variable.
  456.    ON_VALUE is the value to store in VARIABLE
  457.     if `-fSTRING' is seen as an option.
  458.    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
  459.  
  460. struct { char *string; int *variable; int on_value;} f_options[] =
  461. {
  462.   {"float-store", &flag_float_store, 1},
  463.   {"volatile", &flag_volatile, 1},
  464.   {"defer-pop", &flag_defer_pop, 1},
  465.   {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
  466.   {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
  467.   {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
  468.   {"expensive-optimizations", &flag_expensive_optimizations, 1},
  469.   {"thread-jumps", &flag_thread_jumps, 1},
  470.   {"strength-reduce", &flag_strength_reduce, 1},
  471.   {"unroll-loops", &flag_unroll_loops, 1},
  472.   {"unroll-all-loops", &flag_unroll_all_loops, 1},
  473.   {"writable-strings", &flag_writable_strings, 1},
  474.   {"peephole", &flag_no_peephole, 0},
  475.   {"large-baserel", &flag_pic, 4},
  476.   {"force-mem", &flag_force_mem, 1},
  477.   {"force-addr", &flag_force_addr, 1},
  478.   {"function-cse", &flag_no_function_cse, 0},
  479.   {"inline-functions", &flag_inline_functions, 1},
  480.   {"keep-inline-functions", &flag_keep_inline_functions, 1},
  481.   {"inline", &flag_no_inline, 0},
  482.   {"syntax-only", &flag_syntax_only, 1},
  483.   {"shared-data", &flag_shared_data, 1},
  484.   {"caller-saves", &flag_caller_saves, 1},
  485.   {"pcc-struct-return", &flag_pcc_struct_return, 1},
  486.   {"delayed-branch", &flag_delayed_branch, 1},
  487.   {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
  488.   {"pretend-float", &flag_pretend_float, 1},
  489.   {"schedule-insns", &flag_schedule_insns, 1},
  490.   {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
  491.   {"pic", &flag_pic, 1},
  492.   {"PIC", &flag_pic, 2},
  493.   {"baserel", &flag_pic, 3},
  494.   {"fast-math", &flag_fast_math, 1},
  495.   {"common", &flag_no_common, 0},
  496.   {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
  497.   {"verbose-asm", &flag_verbose_asm, 1},
  498.   {"gnu-linker", &flag_gnu_linker, 1}
  499. };
  500.  
  501. /* Table of language-specific options.  */
  502.  
  503. char *lang_options[] =
  504. {
  505.   "-ftraditional",
  506.   "-traditional",
  507.   "-fnotraditional",
  508.   "-fno-traditional",
  509.   "-fsigned-char",
  510.   "-funsigned-char",
  511.   "-fno-signed-char",
  512.   "-fno-unsigned-char",
  513.   "-fsigned-bitfields",
  514.   "-funsigned-bitfields",
  515.   "-fno-signed-bitfields",
  516.   "-fno-unsigned-bitfields",
  517.   "-fshort-enums",
  518.   "-fno-short-enums",
  519.   "-fcond-mismatch",
  520.   "-fno-cond-mismatch",
  521.   "-fshort-double",
  522.   "-fno-short-double",
  523.   "-fasm",
  524.   "-fno-asm",
  525.   "-fbuiltin",
  526.   "-fno-builtin",
  527.   "-fno-ident",
  528.   "-fident",
  529.   "-ansi",
  530.   "-Wimplicit",
  531.   "-Wno-implicit",
  532.   "-Wwrite-strings",
  533.   "-Wno-write-strings",
  534.   "-Wcast-qual",
  535.   "-Wno-cast-qual",
  536.   "-Wpointer-arith",
  537.   "-Wno-pointer-arith",
  538.   "-Wstrict-prototypes",
  539.   "-Wno-strict-prototypes",
  540.   "-Wmissing-prototypes",
  541.   "-Wno-missing-prototypes",
  542.   "-Wredundant-decls",
  543.   "-Wno-redundant-decls",
  544.   "-Wnested-externs",
  545.   "-Wno-nested-externs",
  546.   "-Wtraditional",
  547.   "-Wno-traditional",
  548.   "-Wformat",
  549.   "-Wno-format",
  550.   "-Wchar-subscripts",
  551.   "-Wno-char-subscripts",
  552.   "-Wconversion",
  553.   "-Wno-conversion",
  554.   "-Wparentheses",
  555.   "-Wno-parentheses",
  556.   "-Wcomment",
  557.   "-Wno-comment",
  558.   "-Wcomments",
  559.   "-Wno-comments",
  560.   "-Wtrigraphs",
  561.   "-Wno-trigraphs",
  562.   "-Wimport",
  563.   "-Wno-import",
  564.   "-Wall",
  565.  
  566.   /* These are for C++.  */
  567.   "-+e0",            /* gcc.c tacks the `-' on the front.  */
  568.   "-+e1",
  569.   "-+e2",
  570.   "-fsave-memoized",
  571.   "-fno-save-memoized",
  572.   "-fSOS",
  573.   "-fno-SOS",
  574.   "-fcadillac",
  575.   "-fno-cadillac",
  576.   "-fgc",
  577.   "-fno-gc",
  578.   "-flabels-ok",
  579.   "-fno-labels-ok",
  580.   "-fstats",
  581.   "-fno-stats",
  582.   "-fthis-is-variable",
  583.   "-fno-this-is-variable",
  584.   "-fstrict-prototype",
  585.   "-fno-strict-prototype",
  586.   "-fall-virtual",
  587.   "-fno-all-virtual",
  588.   "-fmemoize-lookups",
  589.   "-fno-memoize-lookups",
  590.   "-felide-constructors",
  591.   "-fno-elide-constructors",
  592.   "-finline-debug",
  593.   "-fno-inline-debug",
  594.   "-fhandle-exceptions",
  595.   "-fno-handle-exceptions",
  596.   "-fansi-exceptions",
  597.   "-fno-ansi-exceptions",
  598.   "-fspring-exceptions",
  599.   "-fno-spring-exceptions",
  600.   "-fdefault-inline",
  601.   "-fno-default-inline",
  602.   "-fenum-int-equiv",
  603.   "-fno-enum-int-equiv",
  604.   "-fdossier",
  605.   "-fno-dossier",
  606.   "-fxref",
  607.   "-fno-xref",
  608.   "-fnonnull-objects",
  609.   "-fno-nonnull-objects",
  610.  
  611.   "-Wreturn-type",
  612.   "-Wno-return-type",
  613.   "-Woverloaded-virtual",
  614.   "-Wno-overloaded-virtual",
  615.   "-Wenum-clash",
  616.   "-Wno-enum-clash",
  617.  
  618.   /* these are for obj c */
  619.   "-lang-objc",
  620.   "-gen-decls",
  621.   "-Wselector",
  622.   "-Wno-selector",
  623.   0
  624. };
  625.  
  626. /* Options controlling warnings */
  627.  
  628. /* Don't print warning messages.  -w.  */
  629.  
  630. int inhibit_warnings = 0;
  631.  
  632. /* Print various extra warnings.  -W.  */
  633.  
  634. int extra_warnings = 0;
  635.  
  636. /* Treat warnings as errors.  -Werror.  */
  637.  
  638. int warnings_are_errors = 0;
  639.  
  640. /* Nonzero to warn about unused local variables.  */
  641.  
  642. int warn_unused;
  643.  
  644. /* Nonzero to warn about variables used before they are initialized.  */
  645.  
  646. int warn_uninitialized;
  647.  
  648. /* Nonzero means warn about all declarations which shadow others.   */
  649.  
  650. int warn_shadow;
  651.  
  652. /* Warn if a switch on an enum fails to have a case for every enum value.  */
  653.  
  654. int warn_switch;
  655.  
  656. /* Nonzero means warn about function definitions that default the return type
  657.    or that use a null return and have a return-type other than void.  */
  658.  
  659. int warn_return_type;
  660.  
  661. /* Nonzero means warn about pointer casts that increase the required
  662.    alignment of the target type (and might therefore lead to a crash
  663.    due to a misaligned access).  */
  664.  
  665. int warn_cast_align;
  666.  
  667. /* Nonzero means warn about any identifiers that match in the first N
  668.    characters.  The value N is in `id_clash_len'.  */
  669.  
  670. int warn_id_clash;
  671. int id_clash_len;
  672.  
  673. /* Nonzero means warn if inline function is too large.  */
  674.  
  675. int warn_inline;
  676.  
  677. /* Warn if a function returns an aggregate,
  678.    since there are often incompatible calling conventions for doing this.  */
  679.  
  680. int warn_aggregate_return;
  681.  
  682. /* Likewise for -W.  */
  683.  
  684. struct { char *string; int *variable; int on_value;} W_options[] =
  685. {
  686.   {"unused", &warn_unused, 1},
  687.   {"error", &warnings_are_errors, 1},
  688.   {"shadow", &warn_shadow, 1},
  689.   {"switch", &warn_switch, 1},
  690.   {"aggregate-return", &warn_aggregate_return, 1},
  691.   {"cast-align", &warn_cast_align, 1},
  692.   {"uninitialized", &warn_uninitialized, 1},
  693.   {"inline", &warn_inline, 1}
  694. };
  695.  
  696. /* Output files for assembler code (real compiler output)
  697.    and debugging dumps.  */
  698.  
  699. FILE *asm_out_file;
  700. FILE *aux_info_file;
  701. FILE *rtl_dump_file;
  702. FILE *jump_opt_dump_file;
  703. FILE *cse_dump_file;
  704. FILE *loop_dump_file;
  705. FILE *cse2_dump_file;
  706. FILE *flow_dump_file;
  707. FILE *combine_dump_file;
  708. FILE *sched_dump_file;
  709. FILE *local_reg_dump_file;
  710. FILE *global_reg_dump_file;
  711. FILE *sched2_dump_file;
  712. FILE *jump2_opt_dump_file;
  713. FILE *dbr_sched_dump_file;
  714. FILE *stack_reg_dump_file;
  715.  
  716. /* Time accumulators, to count the total time spent in various passes.  */
  717.  
  718. int parse_time;
  719. int varconst_time;
  720. int integration_time;
  721. int jump_time;
  722. int cse_time;
  723. int loop_time;
  724. int cse2_time;
  725. int flow_time;
  726. int combine_time;
  727. int sched_time;
  728. int local_alloc_time;
  729. int global_alloc_time;
  730. int sched2_time;
  731. int dbr_sched_time;
  732. int shorten_branch_time;
  733. int stack_reg_time;
  734. int final_time;
  735. int symout_time;
  736. int dump_time;
  737.  
  738. /* Return time used so far, in microseconds.  */
  739.  
  740. int
  741. get_run_time ()
  742. {
  743. #ifdef USG
  744.   struct tms tms;
  745. #else
  746. #ifndef VMS
  747.   struct rusage rusage;
  748. #else /* VMS */
  749.   struct
  750.     {
  751.       int proc_user_time;
  752.       int proc_system_time;
  753.       int child_user_time;
  754.       int child_system_time;
  755.     } vms_times;
  756. #endif
  757. #endif
  758.  
  759.   if (quiet_flag)
  760.     return 0;
  761.  
  762. #ifdef USG
  763.   times (&tms);
  764.   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
  765. #else
  766. #ifndef VMS
  767.   getrusage (0, &rusage);
  768.   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
  769.       + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
  770. #else /* VMS */
  771.   times (&vms_times);
  772.   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  773. #endif
  774. #endif
  775. }
  776.  
  777. #define TIMEVAR(VAR, BODY)    \
  778. do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
  779.  
  780. void
  781. print_time (str, total)
  782.      char *str;
  783.      int total;
  784. {
  785.   fprintf (stderr,
  786.        "time in %s: %d.%06d\n",
  787.        str, total / 1000000, total % 1000000);
  788. }
  789.  
  790. /* Count an error or warning.  Return 1 if the message should be printed.  */
  791.  
  792. int
  793. count_error (warningp)
  794.      int warningp;
  795. {
  796.   if (warningp && inhibit_warnings)
  797.     return 0;
  798.  
  799.   if (warningp && !warnings_are_errors)
  800.     warningcount++;
  801.   else
  802.     {
  803.       static int warning_message = 0;
  804.  
  805.       if (warningp && !warning_message)
  806.     {
  807.       fprintf (stderr, "%s: warnings being treated as errors\n", progname);
  808.       warning_message = 1;
  809.     }
  810.       errorcount++;
  811.     }
  812.  
  813.   return 1;
  814. }
  815.  
  816. /* Print a fatal error message.  NAME is the text.
  817.    Also include a system error message based on `errno'.  */
  818.  
  819. void
  820. pfatal_with_name (name)
  821.      char *name;
  822. {
  823.   fprintf (stderr, "%s: ", progname);
  824.   perror (name);
  825.   exit (35);
  826. }
  827.  
  828. void
  829. fatal_io_error (name)
  830.      char *name;
  831. {
  832.   fprintf (stderr, "%s: %s: I/O error\n", progname, name);
  833.   exit (35);
  834. }
  835.  
  836. void
  837. fatal (s, v)
  838.      char *s;
  839.      int v;
  840. {
  841.   error (s, v);
  842.   exit (34);
  843. }
  844.  
  845. /* Called to give a better error message when we don't have an insn to match
  846.    what we are looking for or if the insn's constraints aren't satisfied,
  847.    rather than just calling abort().  */
  848.  
  849. void
  850. fatal_insn_not_found (insn)
  851.      rtx insn;
  852. {
  853.   if (INSN_CODE (insn) < 0)
  854.     error ("internal error--unrecognizable insn:", 0);
  855.   else
  856.     error ("internal error--insn does not satisfy its constraints:", 0);
  857.   debug_rtx (insn);
  858.   if (asm_out_file)
  859.     fflush (asm_out_file);
  860.   if (aux_info_file)
  861.     fflush (aux_info_file);
  862.   if (rtl_dump_file)
  863.     fflush (rtl_dump_file);
  864.   if (jump_opt_dump_file)
  865.     fflush (jump_opt_dump_file);
  866.   if (cse_dump_file)
  867.     fflush (cse_dump_file);
  868.   if (loop_dump_file)
  869.     fflush (loop_dump_file);
  870.   if (cse2_dump_file)
  871.     fflush (cse2_dump_file);
  872.   if (flow_dump_file)
  873.     fflush (flow_dump_file);
  874.   if (combine_dump_file)
  875.     fflush (combine_dump_file);
  876.   if (sched_dump_file)
  877.     fflush (sched_dump_file);
  878.   if (local_reg_dump_file)
  879.     fflush (local_reg_dump_file);
  880.   if (global_reg_dump_file)
  881.     fflush (global_reg_dump_file);
  882.   if (sched2_dump_file)
  883.     fflush (sched2_dump_file);
  884.   if (jump2_opt_dump_file)
  885.     fflush (jump2_opt_dump_file);
  886.   if (dbr_sched_dump_file)
  887.     fflush (dbr_sched_dump_file);
  888.   if (stack_reg_dump_file)
  889.     fflush (stack_reg_dump_file);
  890.   abort ();
  891. }
  892.  
  893. /* This is the default decl_printable_name function.  */
  894.  
  895. static char *
  896. decl_name (decl, kind)
  897.      tree decl;
  898.      char **kind;
  899. {
  900.   return IDENTIFIER_POINTER (DECL_NAME (decl));
  901. }
  902.  
  903. static int need_error_newline;
  904.  
  905. /* Function of last error message;
  906.    more generally, function such that if next error message is in it
  907.    then we don't have to mention the function name.  */
  908. static tree last_error_function = NULL;
  909.  
  910. /* Used to detect when input_file_stack has changed since last described.  */
  911. static int last_error_tick;
  912.  
  913. /* Called when the start of a function definition is parsed,
  914.    this function prints on stderr the name of the function.  */
  915.  
  916. void
  917. announce_function (decl)
  918.      tree decl;
  919. {
  920.   if (! quiet_flag)
  921.     {
  922.       char *junk;
  923.       if (rtl_dump_and_exit)
  924.     fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
  925.       else
  926.     fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk));
  927.       fflush (stderr);
  928.       need_error_newline = 1;
  929.       last_error_function = current_function_decl;
  930.     }
  931. }
  932.  
  933. /* Prints out, if necessary, the name of the current function
  934.    which caused an error.  Called from all error and warning functions.  */
  935.  
  936. void
  937. report_error_function (file)
  938.      char *file;
  939. {
  940.   struct file_stack *p;
  941.  
  942.   if (need_error_newline)
  943.     {
  944.       fprintf (stderr, "\n");
  945.       need_error_newline = 0;
  946.     }
  947.  
  948.   if (last_error_function != current_function_decl)
  949.     {
  950.       char *kind = "function";
  951.       if (current_function_decl != 0
  952.       && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
  953.     kind = "method";
  954.  
  955.       if (file)
  956.     fprintf (stderr, "%s: ", file);
  957.  
  958.       if (current_function_decl == NULL)
  959.     fprintf (stderr, "At top level:\n");
  960.       else
  961.     {
  962.       char *name = (*decl_printable_name) (current_function_decl, &kind);
  963.       fprintf (stderr, "In %s `%s':\n", kind, name);
  964.     }
  965.  
  966.       last_error_function = current_function_decl;
  967.     }
  968.   if (input_file_stack && input_file_stack->next != 0
  969.       && input_file_stack_tick != last_error_tick)
  970.     {
  971.       fprintf (stderr, "In file included");
  972.       for (p = input_file_stack->next; p; p = p->next)
  973.     {
  974.       fprintf (stderr, " from %s:%d", p->name, p->line);
  975.       if (p->next)
  976.         fprintf (stderr, ",");
  977.     }
  978.       fprintf (stderr, ":\n");
  979.       last_error_tick = input_file_stack_tick;
  980.     }
  981. }
  982.  
  983. /* Report an error at the current line number.
  984.    S is a string and V and V2 are args for `printf'.  We use HOST_WIDE_INT
  985.    as the type for these args assuming it is wide enough to hold a
  986.    pointer.  This isn't terribly portable, but is the best we can do
  987.    without vprintf universally available.  */
  988.  
  989. void
  990. error (s, v, v2)
  991.      char *s;
  992.      HOST_WIDE_INT v;        /* Also used as pointer */
  993.      HOST_WIDE_INT v2;        /* Also used as pointer */
  994. {
  995.   error_with_file_and_line (input_filename, lineno, s, v, v2);
  996. }
  997.  
  998. /* Report an error at line LINE of file FILE.
  999.    S and V are a string and an arg for `printf'.  */
  1000.  
  1001. void
  1002. error_with_file_and_line (file, line, s, v, v2)
  1003.      char *file;
  1004.      int line;
  1005.      char *s;
  1006.      HOST_WIDE_INT v;
  1007.      HOST_WIDE_INT v2;
  1008. {
  1009.   count_error (0);
  1010.  
  1011.   report_error_function (file);
  1012.  
  1013.   if (file)
  1014.     fprintf (stderr, "%s:%d: ", file, line);
  1015.   else
  1016.     fprintf (stderr, "%s: ", progname);
  1017.   fprintf (stderr, s, v, v2);
  1018.   fprintf (stderr, "\n");
  1019. }
  1020.  
  1021. /* Report an error at the declaration DECL.
  1022.    S and V are a string and an arg which uses %s to substitute
  1023.    the declaration name.  */
  1024.  
  1025. void
  1026. error_with_decl (decl, s, v)
  1027.      tree decl;
  1028.      char *s;
  1029.      HOST_WIDE_INT v;
  1030. {
  1031.   char *junk;
  1032.   count_error (0);
  1033.  
  1034.   report_error_function (DECL_SOURCE_FILE (decl));
  1035.  
  1036.   fprintf (stderr, "%s:%d: ",
  1037.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  1038.  
  1039.   if (DECL_NAME (decl))
  1040.     fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
  1041.   else
  1042.     fprintf (stderr, s, "((anonymous))", v);
  1043.   fprintf (stderr, "\n");
  1044. }
  1045.  
  1046. /* Report an error at the line number of the insn INSN.
  1047.    S and V are a string and an arg for `printf'.
  1048.    This is used only when INSN is an `asm' with operands,
  1049.    and each ASM_OPERANDS records its own source file and line.  */
  1050.  
  1051. void
  1052. error_for_asm (insn, s, v, v2)
  1053.      rtx insn;
  1054.      char *s;
  1055.      HOST_WIDE_INT v;        /* Also used as pointer */
  1056.      HOST_WIDE_INT v2;        /* Also used as pointer */
  1057. {
  1058.   char *filename;
  1059.   int line;
  1060.   rtx body = PATTERN (insn);
  1061.   rtx asmop;
  1062.  
  1063.   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
  1064.   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
  1065.     asmop = SET_SRC (body);
  1066.   else if (GET_CODE (body) == ASM_OPERANDS)
  1067.     asmop = body;
  1068.   else if (GET_CODE (body) == PARALLEL
  1069.        && GET_CODE (XVECEXP (body, 0, 0)) == SET)
  1070.     asmop = SET_SRC (XVECEXP (body, 0, 0));
  1071.   else if (GET_CODE (body) == PARALLEL
  1072.        && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
  1073.     asmop = XVECEXP (body, 0, 0);
  1074.  
  1075.   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
  1076.   line = ASM_OPERANDS_SOURCE_LINE (asmop);
  1077.  
  1078.   error_with_file_and_line (filename, line, s, v, v2);
  1079. }
  1080.  
  1081. /* Report a warning at line LINE.
  1082.    S and V are a string and an arg for `printf'.  */
  1083.  
  1084. void
  1085. warning_with_file_and_line (file, line, s, v, v2, v3)
  1086.      char *file;
  1087.      int line;
  1088.      char *s;
  1089.      HOST_WIDE_INT v, v2, v3;
  1090. {
  1091.   if (count_error (1) == 0)
  1092.     return;
  1093.  
  1094.   report_error_function (file);
  1095.  
  1096.   if (file)
  1097.     fprintf (stderr, "%s:%d: ", file, line);
  1098.   else
  1099.     fprintf (stderr, "%s: ", progname);
  1100.  
  1101.   fprintf (stderr, "warning: ");
  1102.   fprintf (stderr, s, v, v2, v3);
  1103.   fprintf (stderr, "\n");
  1104. }
  1105.  
  1106. /* Report a warning at the current line number.
  1107.    S and V are a string and an arg for `printf'.  */
  1108.  
  1109. void
  1110. warning (s, v, v2, v3)
  1111.      char *s;
  1112.      HOST_WIDE_INT v, v2, v3;    /* Also used as pointer */
  1113. {
  1114.   warning_with_file_and_line (input_filename, lineno, s, v, v2, v3);
  1115. }
  1116.  
  1117. /* Report a warning at the declaration DECL.
  1118.    S is string which uses %s to substitute the declaration name.
  1119.    V is a second parameter that S can refer to.  */
  1120.  
  1121. void
  1122. warning_with_decl (decl, s, v)
  1123.      tree decl;
  1124.      char *s;
  1125.      HOST_WIDE_INT v;
  1126. {
  1127.   char *junk;
  1128.  
  1129.   if (count_error (1) == 0)
  1130.     return;
  1131.  
  1132.   report_error_function (DECL_SOURCE_FILE (decl));
  1133.  
  1134.   fprintf (stderr, "%s:%d: ",
  1135.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  1136.  
  1137.   fprintf (stderr, "warning: ");
  1138.   if (DECL_NAME (decl))
  1139.     fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v);
  1140.   else
  1141.     fprintf (stderr, s, "((anonymous))", v);
  1142.   fprintf (stderr, "\n");
  1143. }
  1144.  
  1145. /* Report a warning at the line number of the insn INSN.
  1146.    S and V are a string and an arg for `printf'.
  1147.    This is used only when INSN is an `asm' with operands,
  1148.    and each ASM_OPERANDS records its own source file and line.  */
  1149.  
  1150. void
  1151. warning_for_asm (insn, s, v, v2)
  1152.      rtx insn;
  1153.      char *s;
  1154.      HOST_WIDE_INT v;        /* Also used as pointer */
  1155.      HOST_WIDE_INT v2;        /* Also used as pointer */
  1156. {
  1157.   char *filename;
  1158.   int line;
  1159.   rtx body = PATTERN (insn);
  1160.   rtx asmop;
  1161.  
  1162.   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
  1163.   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
  1164.     asmop = SET_SRC (body);
  1165.   else if (GET_CODE (body) == ASM_OPERANDS)
  1166.     asmop = body;
  1167.   else if (GET_CODE (body) == PARALLEL
  1168.        && GET_CODE (XVECEXP (body, 0, 0)) == SET)
  1169.     asmop = SET_SRC (XVECEXP (body, 0, 0));
  1170.   else if (GET_CODE (body) == PARALLEL
  1171.        && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
  1172.     asmop = XVECEXP (body, 0, 0);
  1173.  
  1174.   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
  1175.   line = ASM_OPERANDS_SOURCE_LINE (asmop);
  1176.  
  1177.   warning_with_file_and_line (filename, line, s, v, v2);
  1178. }
  1179.  
  1180. /* These functions issue either warnings or errors depending on
  1181.    -pedantic-errors.  */
  1182.  
  1183. void
  1184. pedwarn (s, v, v2)
  1185.      char *s;
  1186.      HOST_WIDE_INT v;        /* Also used as pointer */
  1187.      HOST_WIDE_INT v2;
  1188. {
  1189.   if (flag_pedantic_errors)
  1190.     error (s, v, v2);
  1191.   else
  1192.     warning (s, v, v2);
  1193. }
  1194.  
  1195. void
  1196. pedwarn_with_decl (decl, s, v)
  1197.      tree decl;
  1198.      char *s;
  1199.      HOST_WIDE_INT v;
  1200. {
  1201.   if (flag_pedantic_errors)
  1202.     error_with_decl (decl, s, v);
  1203.   else
  1204.     warning_with_decl (decl, s, v);
  1205. }
  1206.  
  1207. void
  1208. pedwarn_with_file_and_line (file, line, s, v, v2)
  1209.      char *file;
  1210.      int line;
  1211.      char *s;
  1212.      HOST_WIDE_INT v;
  1213.      HOST_WIDE_INT v2;
  1214. {
  1215.   if (flag_pedantic_errors)
  1216.     error_with_file_and_line (file, line, s, v, v2);
  1217.   else
  1218.     warning_with_file_and_line (file, line, s, v, v2);
  1219. }
  1220.  
  1221. /* Apologize for not implementing some feature.
  1222.    S, V, and V2 are a string and args for `printf'.  */
  1223.  
  1224. void
  1225. sorry (s, v, v2)
  1226.      char *s;
  1227.      HOST_WIDE_INT v, v2;
  1228. {
  1229.   sorrycount++;
  1230.   if (input_filename)
  1231.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  1232.   else
  1233.     fprintf (stderr, "%s: ", progname);
  1234.  
  1235.   fprintf (stderr, "sorry, not implemented: ");
  1236.   fprintf (stderr, s, v, v2);
  1237.   fprintf (stderr, "\n");
  1238. }
  1239.  
  1240. /* Apologize for not implementing some feature, then quit.
  1241.    S, V, and V2 are a string and args for `printf'.  */
  1242.  
  1243. void
  1244. really_sorry (s, v, v2)
  1245.      char *s;
  1246.      HOST_WIDE_INT v, v2;
  1247. {
  1248.   if (input_filename)
  1249.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  1250.   else
  1251.     fprintf (stderr, "c++: ");
  1252.  
  1253.   fprintf (stderr, "sorry, not implemented: ");
  1254.   fprintf (stderr, s, v, v2);
  1255.   fatal (" (fatal)\n");
  1256. }
  1257.  
  1258. /* More 'friendly' abort that prints the line and file.
  1259.    config.h can #define abort fancy_abort if you like that sort of thing.
  1260.  
  1261.    I don't think this is actually a good idea.
  1262.    Other sorts of crashes will look a certain way.
  1263.    It is a good thing if crashes from calling abort look the same way.
  1264.      -- RMS  */
  1265.  
  1266. void
  1267. fancy_abort ()
  1268. {
  1269.   fatal ("internal gcc abort");
  1270. }
  1271.  
  1272. /* This calls abort and is used to avoid problems when abort if a macro.
  1273.    It is used when we need to pass the address of abort.  */
  1274.  
  1275. void
  1276. do_abort ()
  1277. {
  1278.   abort ();
  1279. }
  1280.  
  1281. /* When `malloc.c' is compiled with `rcheck' defined,
  1282.    it calls this function to report clobberage.  */
  1283.  
  1284. void
  1285. botch (s)
  1286. {
  1287.   abort ();
  1288. }
  1289.  
  1290. /* Same as `malloc' but report error if no memory available.  */
  1291.  
  1292. char *
  1293. xmalloc (size)
  1294.      unsigned size;
  1295. {
  1296.   register char *value = (char *) malloc (size);
  1297.   if (value == 0)
  1298.     fatal ("virtual memory exhausted");
  1299.   return value;
  1300. }
  1301.  
  1302. /* Same as `realloc' but report error if no memory available.  */
  1303.  
  1304. char *
  1305. xrealloc (ptr, size)
  1306.      char *ptr;
  1307.      int size;
  1308. {
  1309.   char *result = (char *) realloc (ptr, size);
  1310.   if (!result)
  1311.     fatal ("virtual memory exhausted");
  1312.   return result;
  1313. }
  1314.  
  1315. /* Return the logarithm of X, base 2, considering X unsigned,
  1316.    if X is a power of 2.  Otherwise, returns -1.
  1317.  
  1318.    This should be used via the `exact_log2' macro.  */
  1319.  
  1320. int
  1321. exact_log2_wide (x)
  1322.      register unsigned HOST_WIDE_INT x;
  1323. {
  1324.   register int log = 0;
  1325.   /* Test for 0 or a power of 2.  */
  1326.   if (x == 0 || x != (x & -x))
  1327.     return -1;
  1328.   while ((x >>= 1) != 0)
  1329.     log++;
  1330.   return log;
  1331. }
  1332.  
  1333. /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
  1334.    If X is 0, return -1.
  1335.  
  1336.    This should be used via the floor_log2 macro.  */
  1337.  
  1338. int
  1339. floor_log2_wide (x)
  1340.      register unsigned HOST_WIDE_INT x;
  1341. {
  1342.   register int log = -1;
  1343.   while (x != 0)
  1344.     log++,
  1345.     x >>= 1;
  1346.   return log;
  1347. }
  1348.  
  1349. int float_handled;
  1350. jmp_buf float_handler;
  1351.  
  1352. /* Specify where to longjmp to when a floating arithmetic error happens.
  1353.    If HANDLER is 0, it means don't handle the errors any more.  */
  1354.  
  1355. void
  1356. set_float_handler (handler)
  1357.      jmp_buf handler;
  1358. {
  1359.   float_handled = (handler != 0);
  1360.   if (handler)
  1361.     bcopy (handler, float_handler, sizeof (float_handler));
  1362. }
  1363.  
  1364. /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
  1365.    error happens, pushing the previous specification into OLD_HANDLER.
  1366.    Return an indication of whether there was a previous handler in effect.  */
  1367.  
  1368. int
  1369. push_float_handler (handler, old_handler)
  1370.      jmp_buf handler, old_handler;
  1371. {
  1372.   int was_handled = float_handled;
  1373.  
  1374.   float_handled = 1;
  1375.   if (was_handled)
  1376.     bcopy (float_handler, old_handler, sizeof (float_handler));
  1377.   bcopy (handler, float_handler, sizeof (float_handler));
  1378.   return was_handled;
  1379. }
  1380.  
  1381. /* Restore the previous specification of whether and where to longjmp to
  1382.    when a floating arithmetic error happens.  */
  1383.  
  1384. void
  1385. pop_float_handler (handled, handler)
  1386.      int handled;
  1387.      jmp_buf handler;
  1388. {
  1389.   float_handled = handled;
  1390.   if (handled)
  1391.     bcopy (handler, float_handler, sizeof (float_handler));
  1392. }
  1393.  
  1394. /* Signals actually come here.  */
  1395.  
  1396. static void
  1397. float_signal (signo)
  1398.      /* If this is missing, some compilers complain.  */
  1399.      int signo;
  1400. {
  1401.   if (float_handled == 0)
  1402.     abort ();
  1403. #if defined (USG) || defined (hpux)
  1404.   signal (SIGFPE, float_signal);  /* re-enable the signal catcher */
  1405. #endif
  1406.   float_handled = 0;
  1407.   signal (SIGFPE, float_signal);
  1408.   longjmp (float_handler, 1);
  1409. }
  1410.  
  1411. /* Handler for SIGPIPE.  */
  1412.  
  1413. static void
  1414. pipe_closed (signo)
  1415.      /* If this is missing, some compilers complain.  */
  1416.      int signo;
  1417. {
  1418.   fatal ("output pipe has been closed");
  1419. }
  1420.  
  1421. /* Strip off a legitimate source ending from the input string NAME of
  1422.    length LEN. */
  1423.  
  1424. void
  1425. strip_off_ending (name, len)
  1426.      char *name;
  1427.      int len;
  1428. {
  1429.   if (len > 2 && ! strcmp (".c", name + len - 2))
  1430.     name[len - 2] = 0;
  1431.   else if (len > 2 && ! strcmp (".m", name + len - 2))
  1432.     name[len - 2] = 0;
  1433.   else if (len > 2 && ! strcmp (".i", name + len - 2))
  1434.     name[len - 2] = 0;
  1435.   else if (len > 3 && ! strcmp (".ii", name + len - 3))
  1436.     name[len - 3] = 0;
  1437.   else if (len > 3 && ! strcmp (".co", name + len - 3))
  1438.     name[len - 3] = 0;
  1439.   else if (len > 3 && ! strcmp (".cc", name + len - 3))
  1440.     name[len - 3] = 0;
  1441.   else if (len > 2 && ! strcmp (".C", name + len - 2))
  1442.     name[len - 2] = 0;
  1443.   else if (len > 4 && ! strcmp (".cxx", name + len - 4))
  1444.     name[len - 4] = 0;
  1445.   else if (len > 2 && ! strcmp (".f", name + len - 2))
  1446.     name[len - 2] = 0;
  1447.   else if (len > 4 && ! strcmp (".ada", name + len - 4))
  1448.     name[len - 4] = 0;
  1449. }
  1450.  
  1451. /* Output a file name in the form wanted by System V.  */
  1452.  
  1453. void
  1454. output_file_directive (asm_file, input_name)
  1455.      FILE *asm_file;
  1456.      char *input_name;
  1457. {
  1458. #ifdef FILE_NAME_NONDIRECTORY
  1459.   char *na = FILE_NAME_NONDIRECTORY (input_name);
  1460. #else
  1461.   int len = strlen (input_name);
  1462.   char *na = input_name + len;
  1463.  
  1464.   /* NA gets INPUT_NAME sans directory names.  */
  1465.   while (na > input_name)
  1466.     {
  1467.       if (na[-1] == '/')
  1468.     break;
  1469.       na--;
  1470.     }
  1471. #endif
  1472.  
  1473. #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
  1474.   ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
  1475. #else
  1476. #ifdef ASM_OUTPUT_SOURCE_FILENAME
  1477.   ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
  1478. #else
  1479.   fprintf (asm_file, "\t.file\t\"%s\"\n", na);
  1480. #endif
  1481. #endif
  1482. }
  1483.  
  1484. /* Compile an entire file of output from cpp, named NAME.
  1485.    Write a file of assembly output and various debugging dumps.  */
  1486.  
  1487. static void
  1488. compile_file (name)
  1489.      char *name;
  1490. {
  1491.   tree globals;
  1492.   int start_time;
  1493.   int dump_base_name_length;
  1494.  
  1495.   int name_specified = name != 0;
  1496.  
  1497.   if (dump_base_name == 0)
  1498.     dump_base_name = name ? name : "gccdump";
  1499.   dump_base_name_length = strlen (dump_base_name);
  1500.  
  1501.   parse_time = 0;
  1502.   varconst_time = 0;
  1503.   integration_time = 0;
  1504.   jump_time = 0;
  1505.   cse_time = 0;
  1506.   loop_time = 0;
  1507.   cse2_time = 0;
  1508.   flow_time = 0;
  1509.   combine_time = 0;
  1510.   sched_time = 0;
  1511.   local_alloc_time = 0;
  1512.   global_alloc_time = 0;
  1513.   sched2_time = 0;
  1514.   dbr_sched_time = 0;
  1515.   shorten_branch_time = 0;
  1516.   stack_reg_time = 0;
  1517.   final_time = 0;
  1518.   symout_time = 0;
  1519.   dump_time = 0;
  1520.  
  1521.   /* Open input file.  */
  1522.  
  1523.   if (name == 0 || !strcmp (name, "-"))
  1524.     {
  1525.       finput = stdin;
  1526.       name = "stdin";
  1527.     }
  1528.   else
  1529.     finput = fopen (name, "r");
  1530.   if (finput == 0)
  1531.     pfatal_with_name (name);
  1532.  
  1533. #ifdef IO_BUFFER_SIZE
  1534.   setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
  1535. #endif
  1536.  
  1537.   /* Initialize data in various passes.  */
  1538.  
  1539.   init_obstacks ();
  1540.   init_tree_codes ();
  1541.   init_lex ();
  1542.   init_rtl ();
  1543.   init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
  1544.           || debug_info_level == DINFO_LEVEL_VERBOSE);
  1545.   init_decl_processing ();
  1546.   init_optabs ();
  1547.   init_stmt ();
  1548.   init_expmed ();
  1549.   init_expr_once ();
  1550.   init_loop ();
  1551.   init_reload ();
  1552.  
  1553.   if (flag_caller_saves)
  1554.     init_caller_save ();
  1555.  
  1556.   /* If auxiliary info generation is desired, open the output file.
  1557.      This goes in the same directory as the source file--unlike
  1558.      all the other output files.  */
  1559.   if (flag_gen_aux_info)
  1560.     {
  1561.       aux_info_file = fopen (aux_info_file_name, "w");
  1562.       if (aux_info_file == 0)
  1563.     pfatal_with_name (aux_info_file_name);
  1564.     }
  1565.  
  1566.   /* If rtl dump desired, open the output file.  */
  1567.   if (rtl_dump)
  1568.     {
  1569.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1570.       strcpy (dumpname, dump_base_name);
  1571.       strcat (dumpname, ".rtl");
  1572.       rtl_dump_file = fopen (dumpname, "w");
  1573.       if (rtl_dump_file == 0)
  1574.     pfatal_with_name (dumpname);
  1575.     }
  1576.  
  1577.   /* If jump_opt dump desired, open the output file.  */
  1578.   if (jump_opt_dump)
  1579.     {
  1580.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1581.       strcpy (dumpname, dump_base_name);
  1582.       strcat (dumpname, ".jump");
  1583.       jump_opt_dump_file = fopen (dumpname, "w");
  1584.       if (jump_opt_dump_file == 0)
  1585.     pfatal_with_name (dumpname);
  1586.     }
  1587.  
  1588.   /* If cse dump desired, open the output file.  */
  1589.   if (cse_dump)
  1590.     {
  1591.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1592.       strcpy (dumpname, dump_base_name);
  1593.       strcat (dumpname, ".cse");
  1594.       cse_dump_file = fopen (dumpname, "w");
  1595.       if (cse_dump_file == 0)
  1596.     pfatal_with_name (dumpname);
  1597.     }
  1598.  
  1599.   /* If loop dump desired, open the output file.  */
  1600.   if (loop_dump)
  1601.     {
  1602.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1603.       strcpy (dumpname, dump_base_name);
  1604.       strcat (dumpname, ".loop");
  1605.       loop_dump_file = fopen (dumpname, "w");
  1606.       if (loop_dump_file == 0)
  1607.     pfatal_with_name (dumpname);
  1608.     }
  1609.  
  1610.   /* If cse2 dump desired, open the output file.  */
  1611.   if (cse2_dump)
  1612.     {
  1613.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1614.       strcpy (dumpname, dump_base_name);
  1615.       strcat (dumpname, ".cse2");
  1616.       cse2_dump_file = fopen (dumpname, "w");
  1617.       if (cse2_dump_file == 0)
  1618.     pfatal_with_name (dumpname);
  1619.     }
  1620.  
  1621.   /* If flow dump desired, open the output file.  */
  1622.   if (flow_dump)
  1623.     {
  1624.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1625.       strcpy (dumpname, dump_base_name);
  1626.       strcat (dumpname, ".flow");
  1627.       flow_dump_file = fopen (dumpname, "w");
  1628.       if (flow_dump_file == 0)
  1629.     pfatal_with_name (dumpname);
  1630.     }
  1631.  
  1632.   /* If combine dump desired, open the output file.  */
  1633.   if (combine_dump)
  1634.     {
  1635.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  1636.       strcpy (dumpname, dump_base_name);
  1637.       strcat (dumpname, ".combine");
  1638.       combine_dump_file = fopen (dumpname, "w");
  1639.       if (combine_dump_file == 0)
  1640.     pfatal_with_name (dumpname);
  1641.     }
  1642.  
  1643.   /* If scheduling dump desired, open the output file.  */
  1644.   if (sched_dump)
  1645.     {
  1646.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1647.       strcpy (dumpname, dump_base_name);
  1648.       strcat (dumpname, ".sched");
  1649.       sched_dump_file = fopen (dumpname, "w");
  1650.       if (sched_dump_file == 0)
  1651.     pfatal_with_name (dumpname);
  1652.     }
  1653.  
  1654.   /* If local_reg dump desired, open the output file.  */
  1655.   if (local_reg_dump)
  1656.     {
  1657.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1658.       strcpy (dumpname, dump_base_name);
  1659.       strcat (dumpname, ".lreg");
  1660.       local_reg_dump_file = fopen (dumpname, "w");
  1661.       if (local_reg_dump_file == 0)
  1662.     pfatal_with_name (dumpname);
  1663.     }
  1664.  
  1665.   /* If global_reg dump desired, open the output file.  */
  1666.   if (global_reg_dump)
  1667.     {
  1668.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1669.       strcpy (dumpname, dump_base_name);
  1670.       strcat (dumpname, ".greg");
  1671.       global_reg_dump_file = fopen (dumpname, "w");
  1672.       if (global_reg_dump_file == 0)
  1673.     pfatal_with_name (dumpname);
  1674.     }
  1675.  
  1676.   /* If 2nd scheduling dump desired, open the output file.  */
  1677.   if (sched2_dump)
  1678.     {
  1679.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 8);
  1680.       strcpy (dumpname, dump_base_name);
  1681.       strcat (dumpname, ".sched2");
  1682.       sched2_dump_file = fopen (dumpname, "w");
  1683.       if (sched2_dump_file == 0)
  1684.     pfatal_with_name (dumpname);
  1685.     }
  1686.  
  1687.   /* If jump2_opt dump desired, open the output file.  */
  1688.   if (jump2_opt_dump)
  1689.     {
  1690.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1691.       strcpy (dumpname, dump_base_name);
  1692.       strcat (dumpname, ".jump2");
  1693.       jump2_opt_dump_file = fopen (dumpname, "w");
  1694.       if (jump2_opt_dump_file == 0)
  1695.     pfatal_with_name (dumpname);
  1696.     }
  1697.  
  1698.   /* If dbr_sched dump desired, open the output file.  */
  1699.   if (dbr_sched_dump)
  1700.     {
  1701.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1702.       strcpy (dumpname, dump_base_name);
  1703.       strcat (dumpname, ".dbr");
  1704.       dbr_sched_dump_file = fopen (dumpname, "w");
  1705.       if (dbr_sched_dump_file == 0)
  1706.     pfatal_with_name (dumpname);
  1707.     }
  1708.  
  1709. #ifdef STACK_REGS
  1710.  
  1711.   /* If stack_reg dump desired, open the output file.  */
  1712.   if (stack_reg_dump)
  1713.     {
  1714.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  1715.       strcpy (dumpname, dump_base_name);
  1716.       strcat (dumpname, ".stack");
  1717.       stack_reg_dump_file = fopen (dumpname, "w");
  1718.       if (stack_reg_dump_file == 0)
  1719.     pfatal_with_name (dumpname);
  1720.     }
  1721.  
  1722. #endif
  1723.  
  1724.   /* Open assembler code output file.  */
  1725.  
  1726.   if (! name_specified && asm_file_name == 0)
  1727.     asm_out_file = stdout;
  1728.   else
  1729.     {
  1730.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1731.       int len = strlen (dump_base_name);
  1732.       strcpy (dumpname, dump_base_name);
  1733.       strip_off_ending (dumpname, len);
  1734.       strcat (dumpname, ".s");
  1735.       if (asm_file_name == 0)
  1736.     {
  1737.       asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
  1738.       strcpy (asm_file_name, dumpname);
  1739.     }
  1740.       if (!strcmp (asm_file_name, "-"))
  1741.     asm_out_file = stdout;
  1742.       else
  1743.     asm_out_file = fopen (asm_file_name, "w");
  1744.       if (asm_out_file == 0)
  1745.     pfatal_with_name (asm_file_name);
  1746.     }
  1747.  
  1748. #ifdef IO_BUFFER_SIZE
  1749.   setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
  1750.        _IOFBF, IO_BUFFER_SIZE);
  1751. #endif
  1752.  
  1753.   input_filename = name;
  1754.  
  1755.   /* Perform language-specific initialization.
  1756.      This may set main_input_filename.  */
  1757.   lang_init ();
  1758.  
  1759.   /* If the input doesn't start with a #line, use the input name
  1760.      as the official input file name.  */
  1761.   if (main_input_filename == 0)
  1762.     main_input_filename = name;
  1763.  
  1764.   /* Put an entry on the input file stack for the main input file.  */
  1765.   input_file_stack
  1766.     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  1767.   input_file_stack->next = 0;
  1768.   input_file_stack->name = input_filename;
  1769.  
  1770.   ASM_FILE_START (asm_out_file);
  1771.  
  1772.   /* Output something to inform GDB that this compilation was by GCC.  */
  1773. #ifndef ASM_IDENTIFY_GCC
  1774.   fprintf (asm_out_file, "gcc2_compiled.:\n");
  1775. #else
  1776.   ASM_IDENTIFY_GCC (asm_out_file);
  1777. #endif
  1778.   /* Don't let the first function fall at the same address
  1779.      as gcc_compiled., if profiling.  */
  1780.   if (profile_flag || profile_block_flag)
  1781.     assemble_zeros (UNITS_PER_WORD);
  1782.  
  1783.   /* If dbx symbol table desired, initialize writing it
  1784.      and output the predefined types.  */
  1785. #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
  1786.   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
  1787.     TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
  1788.                        getdecls ()));
  1789. #endif
  1790. #ifdef SDB_DEBUGGING_INFO
  1791.   if (write_symbols == SDB_DEBUG)
  1792.     TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
  1793.                        getdecls ()));
  1794. #endif
  1795. #ifdef DWARF_DEBUGGING_INFO
  1796.   if (write_symbols == DWARF_DEBUG)
  1797.     TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
  1798. #endif
  1799.  
  1800.   /* Initialize yet another pass.  */
  1801.  
  1802.   init_final (main_input_filename);
  1803.  
  1804.   start_time = get_run_time ();
  1805.  
  1806.   /* Call the parser, which parses the entire file
  1807.      (calling rest_of_compilation for each function).  */
  1808.  
  1809.   if (yyparse () != 0)
  1810.     if (errorcount == 0)
  1811.       fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
  1812.  
  1813.   /* Compilation is now finished except for writing
  1814.      what's left of the symbol table output.  */
  1815.  
  1816.   parse_time += get_run_time () - start_time;
  1817.  
  1818.   parse_time -= integration_time;
  1819.   parse_time -= varconst_time;
  1820.  
  1821.   globals = getdecls ();
  1822.  
  1823.   /* Really define vars that have had only a tentative definition.
  1824.      Really output inline functions that must actually be callable
  1825.      and have not been output so far.  */
  1826.  
  1827.   {
  1828.     int len = list_length (globals);
  1829.     tree *vec = (tree *) alloca (sizeof (tree) * len);
  1830.     int i;
  1831.     tree decl;
  1832.  
  1833.     /* Process the decls in reverse order--earliest first.
  1834.        Put them into VEC from back to front, then take out from front.  */
  1835.  
  1836.     for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
  1837.       vec[len - i - 1] = decl;
  1838.  
  1839.     for (i = 0; i < len; i++)
  1840.       {
  1841.     decl = vec[i];
  1842.     if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
  1843.         && ! TREE_ASM_WRITTEN (decl))
  1844.       {
  1845.         /* Don't write out static consts, unless we used them.
  1846.            (This used to write them out only if the address was
  1847.            taken, but that was wrong; if the variable was simply
  1848.            referred to, it still needs to exist or else it will
  1849.            be undefined in the linker.)  */
  1850.         if (! TREE_READONLY (decl)
  1851.         || TREE_PUBLIC (decl)
  1852.         || TREE_USED (decl)
  1853.         || TREE_ADDRESSABLE (decl)
  1854.         || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
  1855.           rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
  1856.         else
  1857.           /* Cancel the RTL for this decl so that, if debugging info
  1858.          output for global variables is still to come,
  1859.          this one will be omitted.  */
  1860.           DECL_RTL (decl) = NULL;
  1861.       }
  1862.  
  1863.     if (TREE_CODE (decl) == FUNCTION_DECL
  1864.         && ! TREE_ASM_WRITTEN (decl)
  1865.         && DECL_INITIAL (decl) != 0
  1866.         && (TREE_ADDRESSABLE (decl)
  1867.         || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl)))
  1868.         && ! DECL_EXTERNAL (decl))
  1869.       output_inline_function (decl);
  1870.  
  1871.     /* Warn about any function
  1872.        declared static but not defined.
  1873.        We don't warn about variables,
  1874.        because many programs have static variables
  1875.        that exist only to get some text into the object file.  */
  1876.     if ((warn_unused
  1877.          || TREE_USED (decl)
  1878.          || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))))
  1879.         && TREE_CODE (decl) == FUNCTION_DECL
  1880.         && DECL_INITIAL (decl) == 0
  1881.         && DECL_EXTERNAL (decl)
  1882.         && ! TREE_PUBLIC (decl))
  1883.       warning_with_decl (decl, "`%s' declared `static' but never defined");
  1884.     /* Warn about static fns or vars defined but not used,
  1885.        but not about inline functions
  1886.        since unused inline statics is normal practice.  */
  1887.     if (warn_unused
  1888.         && (TREE_CODE (decl) == FUNCTION_DECL
  1889.         || TREE_CODE (decl) == VAR_DECL)
  1890.         && ! DECL_IN_SYSTEM_HEADER (decl)
  1891.         && ! DECL_EXTERNAL (decl)
  1892.         && ! TREE_PUBLIC (decl)
  1893.         && ! TREE_USED (decl)
  1894.         && ! DECL_INLINE (decl)
  1895.         /* The TREE_USED bit for file-scope decls
  1896.            is kept in the identifier, to handle multiple
  1897.            external decls in different scopes.  */
  1898.         && ! TREE_USED (DECL_NAME (decl)))
  1899.       warning_with_decl (decl, "`%s' defined but not used");
  1900.  
  1901. #ifdef SDB_DEBUGGING_INFO
  1902.     /* The COFF linker can move initialized global vars to the end.
  1903.        And that can screw up the symbol ordering.
  1904.        By putting the symbols in that order to begin with,
  1905.        we avoid a problem.  mcsun!unido!fauern!tumuc!pes@uunet.uu.net.  */
  1906.     if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
  1907.         && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
  1908.         && DECL_RTL (decl) != 0)
  1909.       TIMEVAR (symout_time, sdbout_symbol (decl, 0));
  1910.  
  1911.     /* Output COFF information for non-global
  1912.        file-scope initialized variables. */
  1913.     if (write_symbols == SDB_DEBUG
  1914.         && TREE_CODE (decl) == VAR_DECL
  1915.         && DECL_INITIAL (decl)
  1916.         && DECL_RTL (decl) != 0
  1917.         && GET_CODE (DECL_RTL (decl)) == MEM)
  1918.       TIMEVAR (symout_time, sdbout_toplevel_data (decl));
  1919. #endif /* SDB_DEBUGGING_INFO */
  1920. #ifdef DWARF_DEBUGGING_INFO
  1921.     /* Output DWARF information for file-scope tentative data object
  1922.        declarations, file-scope (extern) function declarations (which
  1923.        had no corresponding body) and file-scope tagged type declarations
  1924.        and definitions which have not yet been forced out.  */
  1925.  
  1926.     if (write_symbols == DWARF_DEBUG
  1927.         && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
  1928.       TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
  1929. #endif
  1930.       }
  1931.   }
  1932.  
  1933.   /* Do dbx symbols */
  1934. #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
  1935.   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
  1936.     TIMEVAR (symout_time,
  1937.          {
  1938.            dbxout_finish (asm_out_file, main_input_filename);
  1939.          });
  1940. #endif
  1941.  
  1942. #ifdef DWARF_DEBUGGING_INFO
  1943.   if (write_symbols == DWARF_DEBUG)
  1944.     TIMEVAR (symout_time,
  1945.          {
  1946.            dwarfout_finish ();
  1947.          });
  1948. #endif
  1949.  
  1950.   /* Output some stuff at end of file if nec.  */
  1951.  
  1952.   end_final (main_input_filename);
  1953.  
  1954. #ifdef ASM_FILE_END
  1955.   ASM_FILE_END (asm_out_file);
  1956. #endif
  1957.  
  1958.  after_finish_compilation:
  1959.  
  1960.   /* Language-specific end of compilation actions.  */
  1961.  
  1962.   lang_finish ();
  1963.  
  1964.   /* Close the dump files.  */
  1965.  
  1966.   if (flag_gen_aux_info)
  1967.     {
  1968.       fclose (aux_info_file);
  1969.       if (errorcount)
  1970.     unlink (aux_info_file_name);
  1971.     }
  1972.  
  1973.   if (rtl_dump)
  1974.     fclose (rtl_dump_file);
  1975.  
  1976.   if (jump_opt_dump)
  1977.     fclose (jump_opt_dump_file);
  1978.  
  1979.   if (cse_dump)
  1980.     fclose (cse_dump_file);
  1981.  
  1982.   if (loop_dump)
  1983.     fclose (loop_dump_file);
  1984.  
  1985.   if (cse2_dump)
  1986.     fclose (cse2_dump_file);
  1987.  
  1988.   if (flow_dump)
  1989.     fclose (flow_dump_file);
  1990.  
  1991.   if (combine_dump)
  1992.     {
  1993.       dump_combine_total_stats (combine_dump_file);
  1994.       fclose (combine_dump_file);
  1995.     }
  1996.  
  1997.   if (sched_dump)
  1998.     fclose (sched_dump_file);
  1999.  
  2000.   if (local_reg_dump)
  2001.     fclose (local_reg_dump_file);
  2002.  
  2003.   if (global_reg_dump)
  2004.     fclose (global_reg_dump_file);
  2005.  
  2006.   if (sched2_dump)
  2007.     fclose (sched2_dump_file);
  2008.  
  2009.   if (jump2_opt_dump)
  2010.     fclose (jump2_opt_dump_file);
  2011.  
  2012.   if (dbr_sched_dump)
  2013.     fclose (dbr_sched_dump_file);
  2014.  
  2015. #ifdef STACK_REGS
  2016.   if (stack_reg_dump)
  2017.     fclose (stack_reg_dump_file);
  2018. #endif
  2019.  
  2020.   /* Close non-debugging input and output files.  Take special care to note
  2021.      whether fclose returns an error, since the pages might still be on the
  2022.      buffer chain while the file is open.  */
  2023.  
  2024.   fclose (finput);
  2025.   if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
  2026.     fatal_io_error (asm_file_name);
  2027.  
  2028.   /* Print the times.  */
  2029.  
  2030.   if (! quiet_flag)
  2031.     {
  2032.       fprintf (stderr,"\n");
  2033.       print_time ("parse", parse_time);
  2034.       print_time ("integration", integration_time);
  2035.       print_time ("jump", jump_time);
  2036.       print_time ("cse", cse_time);
  2037.       print_time ("loop", loop_time);
  2038.       print_time ("cse2", cse2_time);
  2039.       print_time ("flow", flow_time);
  2040.       print_time ("combine", combine_time);
  2041.       print_time ("sched", sched_time);
  2042.       print_time ("local-alloc", local_alloc_time);
  2043.       print_time ("global-alloc", global_alloc_time);
  2044.       print_time ("sched2", sched2_time);
  2045.       print_time ("dbranch", dbr_sched_time);
  2046.       print_time ("shorten-branch", shorten_branch_time);
  2047.       print_time ("stack-reg", stack_reg_time);
  2048.       print_time ("final", final_time);
  2049.       print_time ("varconst", varconst_time);
  2050.       print_time ("symout", symout_time);
  2051.       print_time ("dump", dump_time);
  2052.     }
  2053. }
  2054.  
  2055. /* This is called from various places for FUNCTION_DECL, VAR_DECL,
  2056.    and TYPE_DECL nodes.
  2057.  
  2058.    This does nothing for local (non-static) variables.
  2059.    Otherwise, it sets up the RTL and outputs any assembler code
  2060.    (label definition, storage allocation and initialization).
  2061.  
  2062.    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
  2063.    the assembler symbol name to be used.  TOP_LEVEL is nonzero
  2064.    if this declaration is not within a function.  */
  2065.  
  2066. void
  2067. rest_of_decl_compilation (decl, asmspec, top_level, at_end)
  2068.      tree decl;
  2069.      char *asmspec;
  2070.      int top_level;
  2071.      int at_end;
  2072. {
  2073.   /* Declarations of variables, and of functions defined elsewhere.  */
  2074.  
  2075.   /* Forward declarations for nested functions are not "external",
  2076.      but we need to treat them as if they were.  */
  2077.   if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
  2078.       || TREE_CODE (decl) == FUNCTION_DECL)
  2079.     TIMEVAR (varconst_time,
  2080.          {
  2081.            make_decl_rtl (decl, asmspec, top_level);
  2082.            /* For a user-invisible decl that should be replaced
  2083.           by its value when used, don't output anything.  */
  2084.            if (! (TREE_CODE (decl) == VAR_DECL
  2085.               && DECL_IGNORED_P (decl) && TREE_READONLY (decl)
  2086.               && DECL_INITIAL (decl) != 0))
  2087.          /* Don't output anything
  2088.             when a tentative file-scope definition is seen.
  2089.             But at end of compilation, do output code for them.  */
  2090.          if (! (! at_end && top_level
  2091.             && (DECL_INITIAL (decl) == 0
  2092.                 || DECL_INITIAL (decl) == error_mark_node
  2093.                 || DECL_IGNORED_P (decl))))
  2094.            assemble_variable (decl, top_level, at_end);
  2095.          });
  2096.   else if (DECL_REGISTER (decl) && asmspec != 0)
  2097.     {
  2098.       if (decode_reg_name (asmspec) >= 0)
  2099.     {
  2100.       DECL_RTL (decl) = 0;
  2101.       make_decl_rtl (decl, asmspec, top_level);
  2102.     }
  2103.       else
  2104.     error ("invalid register name `%s' for register variable", asmspec);
  2105.     }
  2106. #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
  2107.   else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
  2108.        && TREE_CODE (decl) == TYPE_DECL)
  2109.     TIMEVAR (symout_time, dbxout_symbol (decl, 0));
  2110. #endif
  2111. #ifdef SDB_DEBUGGING_INFO
  2112.   else if (write_symbols == SDB_DEBUG && top_level
  2113.        && TREE_CODE (decl) == TYPE_DECL)
  2114.     TIMEVAR (symout_time, sdbout_symbol (decl, 0));
  2115. #endif
  2116. }
  2117.  
  2118. /* Called after finishing a record, union or enumeral type.  */
  2119.  
  2120. void
  2121. rest_of_type_compilation (type, toplev)
  2122.      tree type;
  2123.      int toplev;
  2124. {
  2125. #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
  2126.   if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
  2127.     TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
  2128. #endif
  2129. #ifdef SDB_DEBUGGING_INFO
  2130.   if (write_symbols == SDB_DEBUG)
  2131.     TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
  2132. #endif
  2133. }
  2134.  
  2135. /* This is called from finish_function (within yyparse)
  2136.    after each top-level definition is parsed.
  2137.    It is supposed to compile that function or variable
  2138.    and output the assembler code for it.
  2139.    After we return, the tree storage is freed.  */
  2140.  
  2141. void
  2142. rest_of_compilation (decl)
  2143.      tree decl;
  2144. {
  2145.   register rtx insns;
  2146.   int start_time = get_run_time ();
  2147.   int tem;
  2148.   /* Nonzero if we have saved the original DECL_INITIAL of the function,
  2149.      to be restored after we finish compiling the function
  2150.      (for use when compiling inline calls to this function).  */
  2151.   tree saved_block_tree = 0;
  2152.   /* Likewise, for DECL_ARGUMENTS.  */
  2153.   tree saved_arguments = 0;
  2154.   int failure = 0;
  2155.  
  2156.   /* If we are reconsidering an inline function
  2157.      at the end of compilation, skip the stuff for making it inline.  */
  2158.  
  2159.   if (DECL_SAVED_INSNS (decl) == 0)
  2160.     {
  2161.       int specd = DECL_INLINE (decl);
  2162.       char *lose;
  2163.  
  2164.       /* If requested, consider whether to make this function inline.  */
  2165.       if (specd || flag_inline_functions)
  2166.     TIMEVAR (integration_time,
  2167.          {
  2168.            lose = function_cannot_inline_p (decl);
  2169.            if (lose)
  2170.              {
  2171.                if (warn_inline && specd)
  2172.              warning_with_decl (decl, lose);
  2173.                DECL_INLINE (decl) = 0;
  2174.              }
  2175.            else
  2176.              DECL_INLINE (decl) = 1;
  2177.          });
  2178.  
  2179.       insns = get_insns ();
  2180.  
  2181.       /* Dump the rtl code if we are dumping rtl.  */
  2182.  
  2183.       if (rtl_dump)
  2184.     TIMEVAR (dump_time,
  2185.          {
  2186.            fprintf (rtl_dump_file, "\n;; Function %s\n\n",
  2187.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  2188.            if (DECL_SAVED_INSNS (decl))
  2189.              fprintf (rtl_dump_file, ";; (integrable)\n\n");
  2190.            print_rtl (rtl_dump_file, insns);
  2191.            fflush (rtl_dump_file);
  2192.          });
  2193.  
  2194.       /* If function is inline, and we don't yet know whether to
  2195.      compile it by itself, defer decision till end of compilation.
  2196.      finish_compilation will call rest_of_compilation again
  2197.      for those functions that need to be output.  */
  2198.  
  2199.       if (DECL_INLINE (decl)
  2200.       && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
  2201.            && ! flag_keep_inline_functions)
  2202.           || DECL_EXTERNAL (decl)))
  2203.     {
  2204. #ifdef DWARF_DEBUGGING_INFO
  2205.       /* Generate the DWARF info for the "abstract" instance
  2206.          of a function which we may later generate inlined and/or
  2207.          out-of-line instances of.  */
  2208.       if (write_symbols == DWARF_DEBUG)
  2209.         {
  2210.           set_decl_abstract_flags (decl, 1);
  2211.           TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
  2212.           set_decl_abstract_flags (decl, 0);
  2213.         }
  2214. #endif
  2215.       TIMEVAR (integration_time, save_for_inline_nocopy (decl));
  2216.       goto exit_rest_of_compilation;
  2217.     }
  2218.  
  2219.       /* If we have to compile the function now, save its rtl and subdecls
  2220.      so that its compilation will not affect what others get.  */
  2221.       if (DECL_INLINE (decl))
  2222.     {
  2223. #ifdef DWARF_DEBUGGING_INFO
  2224.       /* Generate the DWARF info for the "abstract" instance of
  2225.          a function which we will generate an out-of-line instance
  2226.          of almost immediately (and which we may also later generate
  2227.          various inlined instances of).  */
  2228.       if (write_symbols == DWARF_DEBUG)
  2229.         {
  2230.           set_decl_abstract_flags (decl, 1);
  2231.           TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
  2232.           set_decl_abstract_flags (decl, 0);
  2233.         }
  2234. #endif
  2235.       saved_block_tree = DECL_INITIAL (decl);
  2236.       saved_arguments = DECL_ARGUMENTS (decl);
  2237.       TIMEVAR (integration_time, save_for_inline_copying (decl));
  2238.     }
  2239.     }
  2240.  
  2241.   TREE_ASM_WRITTEN (decl) = 1;
  2242.  
  2243.   /* Now that integrate will no longer see our rtl, we need not distinguish
  2244.      between the return value of this function and the return value of called
  2245.      functions.  */
  2246.   rtx_equal_function_value_matters = 0;
  2247.  
  2248.   /* Don't return yet if -Wreturn-type; we need to do jump_optimize.  */
  2249.   if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
  2250.     {
  2251.       goto exit_rest_of_compilation;
  2252.     }
  2253.  
  2254.   /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
  2255.      Note that that may have been done above, in save_for_inline_copying.
  2256.      The call to resume_temporary_allocation near the end of this function
  2257.      goes back to the usual state of affairs.  */
  2258.  
  2259.   rtl_in_current_obstack ();
  2260.  
  2261. #ifdef FINALIZE_PIC
  2262.   /* If we are doing position-independent code generation, now
  2263.      is the time to output special prologues and epilogues.
  2264.      We do not want to do this earlier, because it just clutters
  2265.      up inline functions with meaningless insns.  */
  2266.   if (flag_pic)
  2267.     FINALIZE_PIC;
  2268. #endif
  2269.  
  2270.   insns = get_insns ();
  2271.  
  2272.   /* Copy any shared structure that should not be shared.  */
  2273.  
  2274.   unshare_all_rtl (insns);
  2275.  
  2276.   /* Instantiate all virtual registers.  */
  2277.  
  2278.   instantiate_virtual_regs (current_function_decl, get_insns ());
  2279.  
  2280.   /* See if we have allocated stack slots that are not directly addressable.
  2281.      If so, scan all the insns and create explicit address computation
  2282.      for all references to such slots.  */
  2283. /*   fixup_stack_slots (); */
  2284.  
  2285.   /* Do jump optimization the first time, if -opt.
  2286.      Also do it if -W, but in that case it doesn't change the rtl code,
  2287.      it only computes whether control can drop off the end of the function.  */
  2288.  
  2289.   if (optimize > 0 || extra_warnings || warn_return_type
  2290.       /* If function is `volatile', we should warn if it tries to return.  */
  2291.       || TREE_THIS_VOLATILE (decl))
  2292.     {
  2293.       TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
  2294.       TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
  2295.     }
  2296.  
  2297.   /* Now is when we stop if -fsyntax-only and -Wreturn-type.  */
  2298.   if (rtl_dump_and_exit || flag_syntax_only)
  2299.     goto exit_rest_of_compilation;
  2300.  
  2301.   /* Dump rtl code after jump, if we are doing that.  */
  2302.  
  2303.   if (jump_opt_dump)
  2304.     TIMEVAR (dump_time,
  2305.          {
  2306.            fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
  2307.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2308.            print_rtl (jump_opt_dump_file, insns);
  2309.            fflush (jump_opt_dump_file);
  2310.          });
  2311.  
  2312.   /* Perform common subexpression elimination.
  2313.      Nonzero value from `cse_main' means that jumps were simplified
  2314.      and some code may now be unreachable, so do
  2315.      jump optimization again.  */
  2316.  
  2317.   if (cse_dump)
  2318.     TIMEVAR (dump_time,
  2319.          {
  2320.            fprintf (cse_dump_file, "\n;; Function %s\n\n",
  2321.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2322.          });
  2323.  
  2324.   if (optimize > 0)
  2325.     {
  2326.       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
  2327.  
  2328.       if (flag_thread_jumps)
  2329.     /* Hacks by tiemann & kenner.  */
  2330.     TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
  2331.  
  2332.       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
  2333.                      0, cse_dump_file));
  2334.       TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
  2335.  
  2336.       if (tem)
  2337.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
  2338.     }
  2339.  
  2340.   /* Dump rtl code after cse, if we are doing that.  */
  2341.  
  2342.   if (cse_dump)
  2343.     TIMEVAR (dump_time,
  2344.          {
  2345.            print_rtl (cse_dump_file, insns);
  2346.            fflush (cse_dump_file);
  2347.          });
  2348.  
  2349.   if (loop_dump)
  2350.     TIMEVAR (dump_time,
  2351.          {
  2352.            fprintf (loop_dump_file, "\n;; Function %s\n\n",
  2353.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2354.          });
  2355.  
  2356.   /* Move constant computations out of loops.  */
  2357.  
  2358.   if (optimize > 0)
  2359.     {
  2360.       TIMEVAR (loop_time,
  2361.            {
  2362.          loop_optimize (insns, loop_dump_file);
  2363.            });
  2364.     }
  2365.  
  2366.   /* Dump rtl code after loop opt, if we are doing that.  */
  2367.  
  2368.   if (loop_dump)
  2369.     TIMEVAR (dump_time,
  2370.          {
  2371.            print_rtl (loop_dump_file, insns);
  2372.            fflush (loop_dump_file);
  2373.          });
  2374.  
  2375.   if (cse2_dump)
  2376.     TIMEVAR (dump_time,
  2377.          {
  2378.            fprintf (cse2_dump_file, "\n;; Function %s\n\n",
  2379.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2380.          });
  2381.  
  2382.   if (optimize > 0 && flag_rerun_cse_after_loop)
  2383.     {
  2384.       TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
  2385.  
  2386.       TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
  2387.                       1, cse2_dump_file));
  2388.       if (tem)
  2389.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
  2390.     }
  2391.  
  2392.   if (optimize > 0 && flag_thread_jumps)
  2393.     /* This pass of jump threading straightens out code
  2394.        that was kinked by loop optimization.  */
  2395.     TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
  2396.  
  2397.   /* Dump rtl code after cse, if we are doing that.  */
  2398.  
  2399.   if (cse2_dump)
  2400.     TIMEVAR (dump_time,
  2401.          {
  2402.            print_rtl (cse2_dump_file, insns);
  2403.            fflush (cse2_dump_file);
  2404.          });
  2405.  
  2406.   /* We are no longer anticipating cse in this function, at least.  */
  2407.  
  2408.   cse_not_expected = 1;
  2409.  
  2410.   /* Now we choose between stupid (pcc-like) register allocation
  2411.      (if we got the -noreg switch and not -opt)
  2412.      and smart register allocation.  */
  2413.  
  2414.   if (optimize > 0)            /* Stupid allocation probably won't work */
  2415.     obey_regdecls = 0;        /* if optimizations being done.  */
  2416.  
  2417.   regclass_init ();
  2418.  
  2419.   /* Print function header into flow dump now
  2420.      because doing the flow analysis makes some of the dump.  */
  2421.  
  2422.   if (flow_dump)
  2423.     TIMEVAR (dump_time,
  2424.          {
  2425.            fprintf (flow_dump_file, "\n;; Function %s\n\n",
  2426.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2427.          });
  2428.  
  2429.   if (obey_regdecls)
  2430.     {
  2431.       TIMEVAR (flow_time,
  2432.            {
  2433.          regclass (insns, max_reg_num ());
  2434.          stupid_life_analysis (insns, max_reg_num (),
  2435.                        flow_dump_file);
  2436.            });
  2437.     }
  2438.   else
  2439.     {
  2440.       /* Do control and data flow analysis,
  2441.      and write some of the results to dump file.  */
  2442.  
  2443.       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
  2444.                      flow_dump_file));
  2445.       if (warn_uninitialized)
  2446.     {
  2447.       uninitialized_vars_warning (DECL_INITIAL (decl));
  2448.       setjmp_args_warning ();
  2449.     }
  2450.     }
  2451.  
  2452.   /* Dump rtl after flow analysis.  */
  2453.  
  2454.   if (flow_dump)
  2455.     TIMEVAR (dump_time,
  2456.          {
  2457.            print_rtl (flow_dump_file, insns);
  2458.            fflush (flow_dump_file);
  2459.          });
  2460.  
  2461.   /* If -opt, try combining insns through substitution.  */
  2462.  
  2463.   if (optimize > 0)
  2464.     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
  2465.  
  2466.   /* Dump rtl code after insn combination.  */
  2467.  
  2468.   if (combine_dump)
  2469.     TIMEVAR (dump_time,
  2470.          {
  2471.            fprintf (combine_dump_file, "\n;; Function %s\n\n",
  2472.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2473.            dump_combine_stats (combine_dump_file);
  2474.            print_rtl (combine_dump_file, insns);
  2475.            fflush (combine_dump_file);
  2476.          });
  2477.  
  2478.   /* Print function header into sched dump now
  2479.      because doing the sched analysis makes some of the dump.  */
  2480.  
  2481.   if (sched_dump)
  2482.     TIMEVAR (dump_time,
  2483.          {
  2484.            fprintf (sched_dump_file, "\n;; Function %s\n\n",
  2485.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2486.          });
  2487.  
  2488.   if (optimize > 0 && flag_schedule_insns)
  2489.     {
  2490.       /* Do control and data sched analysis,
  2491.      and write some of the results to dump file.  */
  2492.  
  2493.       TIMEVAR (sched_time, schedule_insns (sched_dump_file));
  2494.     }
  2495.  
  2496.   /* Dump rtl after instruction scheduling.  */
  2497.  
  2498.   if (sched_dump)
  2499.     TIMEVAR (dump_time,
  2500.          {
  2501.            print_rtl (sched_dump_file, insns);
  2502.            fflush (sched_dump_file);
  2503.          });
  2504.  
  2505.   /* Unless we did stupid register allocation,
  2506.      allocate pseudo-regs that are used only within 1 basic block.  */
  2507.  
  2508.   if (!obey_regdecls)
  2509.     TIMEVAR (local_alloc_time,
  2510.          {
  2511.            regclass (insns, max_reg_num ());
  2512.            local_alloc ();
  2513.          });
  2514.  
  2515.   /* Dump rtl code after allocating regs within basic blocks.  */
  2516.  
  2517.   if (local_reg_dump)
  2518.     TIMEVAR (dump_time,
  2519.          {
  2520.            fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
  2521.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2522.            dump_flow_info (local_reg_dump_file);
  2523.            dump_local_alloc (local_reg_dump_file);
  2524.            print_rtl (local_reg_dump_file, insns);
  2525.            fflush (local_reg_dump_file);
  2526.          });
  2527.  
  2528.   if (global_reg_dump)
  2529.     TIMEVAR (dump_time,
  2530.          fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
  2531.               IDENTIFIER_POINTER (DECL_NAME (decl))));
  2532.  
  2533.   /* Unless we did stupid register allocation,
  2534.      allocate remaining pseudo-regs, then do the reload pass
  2535.      fixing up any insns that are invalid.  */
  2536.  
  2537.   TIMEVAR (global_alloc_time,
  2538.        {
  2539.          if (!obey_regdecls)
  2540.            failure = global_alloc (global_reg_dump_file);
  2541.          else
  2542.            failure = reload (insns, 0, global_reg_dump_file);
  2543.        });
  2544.  
  2545.   if (global_reg_dump)
  2546.     TIMEVAR (dump_time,
  2547.          {
  2548.            dump_global_regs (global_reg_dump_file);
  2549.            print_rtl (global_reg_dump_file, insns);
  2550.            fflush (global_reg_dump_file);
  2551.          });
  2552.  
  2553.   if (failure)
  2554.     goto exit_rest_of_compilation;
  2555.  
  2556.   reload_completed = 1;
  2557.  
  2558.   /* On some machines, the prologue and epilogue code, or parts thereof,
  2559.      can be represented as RTL.  Doing so lets us schedule insns between
  2560.      it and the rest of the code and also allows delayed branch
  2561.      scheduling to operate in the epilogue.  */
  2562.  
  2563.   thread_prologue_and_epilogue_insns (insns);
  2564.  
  2565.   if (optimize > 0 && flag_schedule_insns_after_reload)
  2566.     {
  2567.       if (sched2_dump)
  2568.     TIMEVAR (dump_time,
  2569.          {
  2570.            fprintf (sched2_dump_file, "\n;; Function %s\n\n",
  2571.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  2572.          });
  2573.  
  2574.       /* Do control and data sched analysis again,
  2575.      and write some more of the results to dump file.  */
  2576.  
  2577.       TIMEVAR (sched2_time, schedule_insns (sched2_dump_file));
  2578.  
  2579.       /* Dump rtl after post-reorder instruction scheduling.  */
  2580.  
  2581.       if (sched2_dump)
  2582.     TIMEVAR (dump_time,
  2583.          {
  2584.            print_rtl (sched2_dump_file, insns);
  2585.            fflush (sched2_dump_file);
  2586.          });
  2587.     }
  2588.  
  2589. #ifdef LEAF_REGISTERS
  2590.   leaf_function = 0;
  2591.   if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
  2592.     leaf_function = 1;
  2593. #endif
  2594.  
  2595.   /* One more attempt to remove jumps to .+1
  2596.      left by dead-store-elimination.
  2597.      Also do cross-jumping this time
  2598.      and delete no-op move insns.  */
  2599.  
  2600.   if (optimize > 0)
  2601.     {
  2602.       TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
  2603.     }
  2604.  
  2605.   /* Dump rtl code after jump, if we are doing that.  */
  2606.  
  2607.   if (jump2_opt_dump)
  2608.     TIMEVAR (dump_time,
  2609.          {
  2610.            fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
  2611.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2612.            print_rtl (jump2_opt_dump_file, insns);
  2613.            fflush (jump2_opt_dump_file);
  2614.          });
  2615.  
  2616.   /* If a scheduling pass for delayed branches is to be done,
  2617.      call the scheduling code. */
  2618.  
  2619. #ifdef DELAY_SLOTS
  2620.   if (optimize > 0 && flag_delayed_branch)
  2621.     {
  2622.       TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
  2623.       if (dbr_sched_dump)
  2624.     {
  2625.       TIMEVAR (dump_time,
  2626.          {
  2627.            fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
  2628.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  2629.            print_rtl (dbr_sched_dump_file, insns);
  2630.            fflush (dbr_sched_dump_file);
  2631.          });
  2632.     }
  2633.     }
  2634. #endif
  2635.  
  2636.   if (optimize > 0)
  2637.     /* Shorten branches.  */
  2638.     TIMEVAR (shorten_branch_time,
  2639.          {
  2640.            shorten_branches (get_insns ());
  2641.          });
  2642.  
  2643. #ifdef STACK_REGS
  2644.   TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
  2645.   if (stack_reg_dump)
  2646.     {
  2647.       TIMEVAR (dump_time,
  2648.            {
  2649.          fprintf (stack_reg_dump_file, "\n;; Function %s\n\n",
  2650.               IDENTIFIER_POINTER (DECL_NAME (decl)));
  2651.          print_rtl (stack_reg_dump_file, insns);
  2652.          fflush (stack_reg_dump_file);
  2653.            });
  2654.     }
  2655. #endif
  2656.  
  2657.   /* Now turn the rtl into assembler code.  */
  2658.  
  2659.   TIMEVAR (final_time,
  2660.        {
  2661.          rtx x;
  2662.          char *fnname;
  2663.  
  2664.          /* Get the function's name, as described by its RTL.
  2665.         This may be different from the DECL_NAME name used
  2666.         in the source file.  */
  2667.  
  2668.          x = DECL_RTL (decl);
  2669.          if (GET_CODE (x) != MEM)
  2670.            abort ();
  2671.          x = XEXP (x, 0);
  2672.          if (GET_CODE (x) != SYMBOL_REF)
  2673.            abort ();
  2674.          fnname = XSTR (x, 0);
  2675.  
  2676.          assemble_start_function (decl, fnname);
  2677.          final_start_function (insns, asm_out_file, optimize);
  2678.          final (insns, asm_out_file, optimize, 0);
  2679.          final_end_function (insns, asm_out_file, optimize);
  2680.          assemble_end_function (decl, fnname);
  2681.          fflush (asm_out_file);
  2682.        });
  2683.  
  2684.   /* Write DBX symbols if requested */
  2685.  
  2686.   /* Note that for those inline functions where we don't initially
  2687.      know for certain that we will be generating an out-of-line copy,
  2688.      the first invocation of this routine (rest_of_compilation) will
  2689.      skip over this code by doing a `goto exit_rest_of_compilation;'.
  2690.      Later on, finish_compilation will call rest_of_compilation again
  2691.      for those inline functions that need to have out-of-line copies
  2692.      generated.  During that call, we *will* be routed past here.  */
  2693.  
  2694. #ifdef DBX_DEBUGGING_INFO
  2695.   if (write_symbols == DBX_DEBUG)
  2696.     TIMEVAR (symout_time, dbxout_function (decl));
  2697. #endif
  2698.  
  2699. #ifdef DWARF_DEBUGGING_INFO
  2700.   if (write_symbols == DWARF_DEBUG)
  2701.     TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
  2702. #endif
  2703.  
  2704.  exit_rest_of_compilation:
  2705.  
  2706.   /* In case the function was not output,
  2707.      don't leave any temporary anonymous types
  2708.      queued up for sdb output.  */
  2709. #ifdef SDB_DEBUGGING_INFO
  2710.   if (write_symbols == SDB_DEBUG)
  2711.     sdbout_types (NULL_TREE);
  2712. #endif
  2713.  
  2714.   /* Put back the tree of subblocks and list of arguments
  2715.      from before we copied them.
  2716.      Code generation and the output of debugging info may have modified
  2717.      the copy, but the original is unchanged.  */
  2718.  
  2719.   if (saved_block_tree != 0)
  2720.     DECL_INITIAL (decl) = saved_block_tree;
  2721.   if (saved_arguments != 0)
  2722.     DECL_ARGUMENTS (decl) = saved_arguments;
  2723.  
  2724.   reload_completed = 0;
  2725.  
  2726.   /* Clear out the real_constant_chain before some of the rtx's
  2727.      it runs through become garbage.  */
  2728.  
  2729.   clear_const_double_mem ();
  2730.  
  2731.   /* Cancel the effect of rtl_in_current_obstack.  */
  2732.  
  2733.   resume_temporary_allocation ();
  2734.  
  2735.   /* The parsing time is all the time spent in yyparse
  2736.      *except* what is spent in this function.  */
  2737.  
  2738.   parse_time -= get_run_time () - start_time;
  2739. }
  2740.  
  2741. /* Entry point of cc1/c++.  Decode command args, then call compile_file.
  2742.    Exit code is 35 if can't open files, 34 if fatal error,
  2743.    33 if had nonfatal errors, else success.  */
  2744.  
  2745. int
  2746. main (argc, argv, envp)
  2747.      int argc;
  2748.      char **argv;
  2749.      char **envp;
  2750. {
  2751.   register int i;
  2752.   char *filename = 0;
  2753.   int flag_print_mem = 0;
  2754.   int version_flag = 0;
  2755.   char *p;
  2756.  
  2757.   /* save in case md file wants to emit args as a comment.  */
  2758.   save_argc = argc;
  2759.   save_argv = argv;
  2760.  
  2761.   p = argv[0] + strlen (argv[0]);
  2762.   while (p != argv[0] && p[-1] != '/') --p;
  2763.   progname = p;
  2764.  
  2765. #ifdef RLIMIT_STACK
  2766.   /* Get rid of any avoidable limit on stack size.  */
  2767.   {
  2768.     struct rlimit rlim;
  2769.  
  2770.     /* Set the stack limit huge so that alloca does not fail. */
  2771.     getrlimit (RLIMIT_STACK, &rlim);
  2772.     rlim.rlim_cur = rlim.rlim_max;
  2773.     setrlimit (RLIMIT_STACK, &rlim);
  2774.   }
  2775. #endif /* RLIMIT_STACK */
  2776.  
  2777.   signal (SIGFPE, float_signal);
  2778.  
  2779.   signal (SIGPIPE, pipe_closed);
  2780.  
  2781.   decl_printable_name = decl_name;
  2782.   lang_expand_expr = (struct rtx_def *(*)()) do_abort;
  2783.  
  2784.   /* Initialize whether `char' is signed.  */
  2785.   flag_signed_char = DEFAULT_SIGNED_CHAR;
  2786. #ifdef DEFAULT_SHORT_ENUMS
  2787.   /* Initialize how much space enums occupy, by default.  */
  2788.   flag_short_enums = DEFAULT_SHORT_ENUMS;
  2789. #endif
  2790.  
  2791.   /* Scan to see what optimization level has been specified.  That will
  2792.      determine the default value of many flags.  */
  2793.   for (i = 1; i < argc; i++)
  2794.     {
  2795.       if (!strcmp (argv[i], "-O"))
  2796.     {
  2797.       optimize = 1;
  2798.     }
  2799.       else if (argv[i][0] == '-' && argv[i][1] == 'O')
  2800.     {
  2801.       /* Handle -O2, -O3, -O69, ...  */
  2802.       char *p = &argv[i][2];
  2803.       int c;
  2804.  
  2805.       while (c = *p++)
  2806.         if (! (c >= '0' && c <= '9'))
  2807.           break;
  2808.       if (c == 0)
  2809.         optimize = atoi (&argv[i][2]);
  2810.     }
  2811.     }
  2812.  
  2813.   obey_regdecls = (optimize == 0);
  2814.   if (optimize == 0)
  2815.     {
  2816.       flag_no_inline = 1;
  2817.       warn_inline = 0;
  2818.     }
  2819.  
  2820.   if (optimize >= 1)
  2821.     {
  2822.       flag_thread_jumps = 1;
  2823. #ifdef DELAY_SLOTS
  2824.       flag_delayed_branch = 1;
  2825. #endif
  2826.     }
  2827.  
  2828.   if (optimize >= 2)
  2829.     {
  2830.       flag_cse_follow_jumps = 1;
  2831.       flag_cse_skip_blocks = 1;
  2832.       flag_expensive_optimizations = 1;
  2833.       flag_strength_reduce = 1;
  2834.       flag_rerun_cse_after_loop = 1;
  2835.       flag_caller_saves = 1;
  2836. #ifdef INSN_SCHEDULING
  2837.       flag_schedule_insns = 1;
  2838.       flag_schedule_insns_after_reload = 1;
  2839. #endif
  2840.     }
  2841.  
  2842. #ifdef OPTIMIZATION_OPTIONS
  2843.   /* Allow default optimizations to be specified on a per-machine basis.  */
  2844.   OPTIMIZATION_OPTIONS (optimize);
  2845. #endif
  2846.  
  2847.   /* Initialize register usage now so switches may override.  */
  2848.   init_reg_sets ();
  2849.  
  2850.   target_flags = 0;
  2851.   set_target_switch ("");
  2852.  
  2853.   for (i = 1; i < argc; i++)
  2854.     {
  2855.       int j;
  2856.       /* If this is a language-specific option,
  2857.      decode it in a language-specific way.  */
  2858.       for (j = 0; lang_options[j] != 0; j++)
  2859.     if (!strncmp (argv[i], lang_options[j],
  2860.               strlen (lang_options[j])))
  2861.       break;
  2862.       if (lang_options[j] != 0)
  2863.     /* If the option is valid for *some* language,
  2864.        treat it as valid even if this language doesn't understand it.  */
  2865.     lang_decode_option (argv[i]);
  2866.       else if (argv[i][0] == '-' && argv[i][1] != 0)
  2867.     {
  2868.       register char *str = argv[i] + 1;
  2869.       if (str[0] == 'Y')
  2870.         str++;
  2871.  
  2872.       if (str[0] == 'm')
  2873.         set_target_switch (&str[1]);
  2874.       else if (!strcmp (str, "dumpbase"))
  2875.         {
  2876.           dump_base_name = argv[++i];
  2877.         }
  2878.       else if (str[0] == 'd')
  2879.         {
  2880.           register char *p = &str[1];
  2881.           while (*p)
  2882.         switch (*p++)
  2883.           {
  2884.            case 'a':
  2885.              combine_dump = 1;
  2886.              dbr_sched_dump = 1;
  2887.              flow_dump = 1;
  2888.              global_reg_dump = 1;
  2889.              jump_opt_dump = 1;
  2890.              jump2_opt_dump = 1;
  2891.              local_reg_dump = 1;
  2892.              loop_dump = 1;
  2893.              rtl_dump = 1;
  2894.              cse_dump = 1, cse2_dump = 1;
  2895.              sched_dump = 1;
  2896.              sched2_dump = 1;
  2897.             stack_reg_dump = 1;
  2898.             break;
  2899.           case 'k':
  2900.             stack_reg_dump = 1;
  2901.             break;
  2902.           case 'c':
  2903.             combine_dump = 1;
  2904.             break;
  2905.           case 'd':
  2906.             dbr_sched_dump = 1;
  2907.             break;
  2908.           case 'f':
  2909.             flow_dump = 1;
  2910.             break;
  2911.           case 'g':
  2912.             global_reg_dump = 1;
  2913.             break;
  2914.           case 'j':
  2915.             jump_opt_dump = 1;
  2916.             break;
  2917.           case 'J':
  2918.             jump2_opt_dump = 1;
  2919.             break;
  2920.           case 'l':
  2921.             local_reg_dump = 1;
  2922.             break;
  2923.           case 'L':
  2924.             loop_dump = 1;
  2925.             break;
  2926.           case 'm':
  2927.             flag_print_mem = 1;
  2928.             break;
  2929.           case 'p':
  2930.             flag_print_asm_name = 1;
  2931.             break;
  2932.           case 'r':
  2933.             rtl_dump = 1;
  2934.             break;
  2935.           case 's':
  2936.             cse_dump = 1;
  2937.             break;
  2938.           case 't':
  2939.             cse2_dump = 1;
  2940.             break;
  2941.           case 'S':
  2942.             sched_dump = 1;
  2943.             break;
  2944.           case 'R':
  2945.             sched2_dump = 1;
  2946.             break;
  2947.           case 'y':
  2948.             set_yydebug (1);
  2949.             break;
  2950.  
  2951.           case 'x':
  2952.             rtl_dump_and_exit = 1;
  2953.             break;
  2954.           }
  2955.         }
  2956.       else if (str[0] == 'f')
  2957.         {
  2958.           register char *p = &str[1];
  2959.           int found = 0;
  2960.  
  2961.           /* Some kind of -f option.
  2962.          P's value is the option sans `-f'.
  2963.          Search for it in the table of options.  */
  2964.  
  2965.           for (j = 0;
  2966.            !found && j < sizeof (f_options) / sizeof (f_options[0]);
  2967.            j++)
  2968.         {
  2969.           if (!strcmp (p, f_options[j].string))
  2970.             {
  2971.               *f_options[j].variable = f_options[j].on_value;
  2972.               /* A goto here would be cleaner,
  2973.              but breaks the vax pcc.  */
  2974.               found = 1;
  2975.             }
  2976.           if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
  2977.               && ! strcmp (p+3, f_options[j].string))
  2978.             {
  2979.               *f_options[j].variable = ! f_options[j].on_value;
  2980.               found = 1;
  2981.             }
  2982.         }
  2983.  
  2984.           if (found)
  2985.         ;
  2986.           else if (!strncmp (p, "fixed-", 6))
  2987.         fix_register (&p[6], 1, 1);
  2988.           else if (!strncmp (p, "call-used-", 10))
  2989.         fix_register (&p[10], 0, 1);
  2990.           else if (!strncmp (p, "call-saved-", 11))
  2991.         fix_register (&p[11], 0, 0);
  2992.           else
  2993.         error ("Invalid option `%s'", argv[i]);
  2994.         }
  2995.       else if (str[0] == 'O')
  2996.         {
  2997.           register char *p = str+1;
  2998.           while (*p && *p >= '0' && *p <= '9')
  2999.         p++;
  3000.           if (*p == '\0')
  3001.         ;
  3002.           else
  3003.         error ("Invalid option `%s'", argv[i]);
  3004.         }
  3005.       else if (!strcmp (str, "pedantic"))
  3006.         pedantic = 1;
  3007.       else if (!strcmp (str, "pedantic-errors"))
  3008.         flag_pedantic_errors = pedantic = 1;
  3009.       else if (!strcmp (str, "quiet"))
  3010.         quiet_flag = 1;
  3011.       else if (!strcmp (str, "version"))
  3012.         version_flag = 1;
  3013.       else if (!strcmp (str, "w"))
  3014.         inhibit_warnings = 1;
  3015.       else if (!strcmp (str, "W"))
  3016.         {
  3017.           extra_warnings = 1;
  3018.           warn_uninitialized = 1;
  3019.         }
  3020.       else if (str[0] == 'W')
  3021.         {
  3022.           register char *p = &str[1];
  3023.           int found = 0;
  3024.  
  3025.           /* Some kind of -W option.
  3026.          P's value is the option sans `-W'.
  3027.          Search for it in the table of options.  */
  3028.  
  3029.           for (j = 0;
  3030.            !found && j < sizeof (W_options) / sizeof (W_options[0]);
  3031.            j++)
  3032.         {
  3033.           if (!strcmp (p, W_options[j].string))
  3034.             {
  3035.               *W_options[j].variable = W_options[j].on_value;
  3036.               /* A goto here would be cleaner,
  3037.              but breaks the vax pcc.  */
  3038.               found = 1;
  3039.             }
  3040.           if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
  3041.               && ! strcmp (p+3, W_options[j].string))
  3042.             {
  3043.               *W_options[j].variable = ! W_options[j].on_value;
  3044.               found = 1;
  3045.             }
  3046.         }
  3047.  
  3048.           if (found)
  3049.         ;
  3050.           else if (!strncmp (p, "id-clash-", 9))
  3051.         {
  3052.           char *endp = p + 9;
  3053.  
  3054.           while (*endp)
  3055.             {
  3056.               if (*endp >= '0' && *endp <= '9')
  3057.             endp++;
  3058.               else
  3059.             {
  3060.               error ("Invalid option `%s'", argv[i]);
  3061.               goto id_clash_lose;
  3062.             }
  3063.             }
  3064.           warn_id_clash = 1;
  3065.           id_clash_len = atoi (str + 10);
  3066.         id_clash_lose: ;
  3067.         }
  3068.           else
  3069.         error ("Invalid option `%s'", argv[i]);
  3070.         }
  3071.       else if (!strcmp (str, "p"))
  3072.         profile_flag = 1;
  3073.       else if (!strcmp (str, "a"))
  3074.         {
  3075. #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
  3076.           warning ("`-a' option (basic block profile) not supported");
  3077. #else
  3078.           profile_block_flag = 1;
  3079. #endif
  3080.         }
  3081.       else if (str[0] == 'g')
  3082.         {
  3083.           char *p = str + 1;
  3084.           char *q;
  3085.           unsigned len;
  3086.           unsigned level;
  3087.  
  3088.           while (*p && (*p < '0' || *p > '9'))
  3089.         p++;
  3090.           len = p - str;
  3091.           q = p;
  3092.           while (*q && (*q >= '0' && *q <= '9'))
  3093.         q++;
  3094.           if (*p)
  3095.         level = atoi (p);
  3096.           else
  3097.         level = 2;    /* default debugging info level */
  3098.           if (*q || level > 3)
  3099.         {
  3100.           warning ("invalid debug level specification in option: `-%s'",
  3101.                str);
  3102.           warning ("no debugging information will be generated");
  3103.           level = 0;
  3104.         }
  3105.  
  3106.           /* If more than one debugging type is supported,
  3107.          you must define PREFERRED_DEBUGGING_TYPE
  3108.          to choose a format in a system-dependent way.  */
  3109.           /* This is one long line cause VAXC can't handle a \-newline.  */
  3110. #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
  3111. #ifdef PREFERRED_DEBUGGING_TYPE
  3112.           if (!strncmp (str, "ggdb", len))
  3113.         write_symbols = PREFERRED_DEBUGGING_TYPE;
  3114. #else /* no PREFERRED_DEBUGGING_TYPE */
  3115. You Lose!  You must define PREFERRED_DEBUGGING_TYPE!
  3116. #endif /* no PREFERRED_DEBUGGING_TYPE */
  3117. #endif /* More than one debugger format enabled.  */
  3118. #ifdef DBX_DEBUGGING_INFO
  3119.           if (write_symbols != NO_DEBUG)
  3120.         ;
  3121.           else if (!strncmp (str, "ggdb", len))
  3122.         write_symbols = DBX_DEBUG;
  3123.           else if (!strncmp (str, "gstabs", len))
  3124.         write_symbols = DBX_DEBUG;
  3125.           else if (!strncmp (str, "gstabs+", len))
  3126.         write_symbols = DBX_DEBUG;
  3127.  
  3128.           /* Always enable extensions for -ggdb or -gstabs+, 
  3129.          always disable for -gstabs.
  3130.          For plain -g, use system-specific default.  */
  3131.           if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len)
  3132.           && len >= 2)
  3133.         use_gnu_debug_info_extensions = 1;
  3134.           else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len)
  3135.                && len >= 7)
  3136.         use_gnu_debug_info_extensions = 1;
  3137.           else if (write_symbols == DBX_DEBUG
  3138.                && !strncmp (str, "gstabs", len) && len >= 2)
  3139.         use_gnu_debug_info_extensions = 0;
  3140.           else
  3141.         use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
  3142. #endif /* DBX_DEBUGGING_INFO */
  3143. #ifdef DWARF_DEBUGGING_INFO
  3144.           if (write_symbols != NO_DEBUG)
  3145.         ;
  3146.           else if (!strncmp (str, "g", len))
  3147.         write_symbols = DWARF_DEBUG;
  3148.           else if (!strncmp (str, "ggdb", len))
  3149.         write_symbols = DWARF_DEBUG;
  3150.           else if (!strncmp (str, "gdwarf", len))
  3151.         write_symbols = DWARF_DEBUG;
  3152.  
  3153.           /* Always enable extensions for -ggdb or -gdwarf+, 
  3154.          always disable for -gdwarf.
  3155.          For plain -g, use system-specific default.  */
  3156.           if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len)
  3157.           && len >= 2)
  3158.         use_gnu_debug_info_extensions = 1;
  3159.           else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+"))
  3160.         use_gnu_debug_info_extensions = 1;
  3161.           else if (write_symbols == DWARF_DEBUG
  3162.                && !strncmp (str, "gdwarf", len) && len >= 2)
  3163.         use_gnu_debug_info_extensions = 0;
  3164.           else
  3165.         use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
  3166. #endif
  3167. #ifdef SDB_DEBUGGING_INFO
  3168.           if (write_symbols != NO_DEBUG)
  3169.         ;
  3170.           else if (!strncmp (str, "g", len))
  3171.         write_symbols = SDB_DEBUG;
  3172.           else if (!strncmp (str, "gdb", len))
  3173.         write_symbols = SDB_DEBUG;
  3174.           else if (!strncmp (str, "gcoff", len))
  3175.         write_symbols = SDB_DEBUG;
  3176. #endif /* SDB_DEBUGGING_INFO */
  3177. #ifdef XCOFF_DEBUGGING_INFO
  3178.           if (write_symbols != NO_DEBUG)
  3179.         ;
  3180.           else if (!strncmp (str, "g", len))
  3181.         write_symbols = XCOFF_DEBUG;
  3182.           else if (!strncmp (str, "ggdb", len))
  3183.         write_symbols = XCOFF_DEBUG;
  3184.           else if (!strncmp (str, "gxcoff", len))
  3185.         write_symbols = XCOFF_DEBUG;
  3186.  
  3187.           /* Always enable extensions for -ggdb or -gxcoff+,
  3188.          always disable for -gxcoff.
  3189.          For plain -g, use system-specific default.  */
  3190.           if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len)
  3191.           && len >= 2)
  3192.         use_gnu_debug_info_extensions = 1;
  3193.           else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+"))
  3194.         use_gnu_debug_info_extensions = 1;
  3195.           else if (write_symbols == XCOFF_DEBUG
  3196.                && !strncmp (str, "gxcoff", len) && len >= 2)
  3197.         use_gnu_debug_info_extensions = 0;
  3198.           else
  3199.         use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS;
  3200. #endif          
  3201.           if (write_symbols == NO_DEBUG)
  3202.         warning ("`-%s' option not supported on this version of GCC", str);
  3203.           else if (level == 0)
  3204.         write_symbols = NO_DEBUG;
  3205.           else
  3206.         debug_info_level = (enum debug_info_level) level;
  3207.         }
  3208.       else if (!strcmp (str, "o"))
  3209.         {
  3210.           asm_file_name = argv[++i];
  3211.         }
  3212.       else if (str[0] == 'G')
  3213.         {
  3214.           g_switch_set = TRUE;
  3215.           g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
  3216.         }
  3217.       else if (!strncmp (str, "aux-info", 8))
  3218.         {
  3219.           flag_gen_aux_info = 1;
  3220.           aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
  3221.         }
  3222.       else
  3223.         error ("Invalid option `%s'", argv[i]);
  3224.     }
  3225.       else if (argv[i][0] == '+')
  3226.     error ("Invalid option `%s'", argv[i]);
  3227.       else
  3228.     filename = argv[i];
  3229.     }
  3230.  
  3231.   /* Inlining does not work if not optimizing,
  3232.      so force it not to be done.  */
  3233.   if (optimize == 0)
  3234.     {
  3235.       flag_no_inline = 1;
  3236.       warn_inline = 0;
  3237.     }
  3238.  
  3239. #ifdef OVERRIDE_OPTIONS
  3240.   /* Some machines may reject certain combinations of options.  */
  3241.   OVERRIDE_OPTIONS;
  3242. #endif
  3243.  
  3244.   /* Unrolling all loops implies that standard loop unrolling must also
  3245.      be done.  */
  3246.   if (flag_unroll_all_loops)
  3247.     flag_unroll_loops = 1;
  3248.   /* Loop unrolling requires that strength_reduction be on also.  Silently
  3249.      turn on strength reduction here if it isn't already on.  Also, the loop
  3250.      unrolling code assumes that cse will be run after loop, so that must
  3251.      be turned on also.  */
  3252.   if (flag_unroll_loops)
  3253.     {
  3254.       flag_strength_reduce = 1;
  3255.       flag_rerun_cse_after_loop = 1;
  3256.     }
  3257.  
  3258.   /* Warn about options that are not supported on this machine.  */
  3259. #ifndef INSN_SCHEDULING
  3260.   if (flag_schedule_insns || flag_schedule_insns_after_reload)
  3261.     warning ("instruction scheduling not supported on this target machine");
  3262. #endif
  3263. #ifndef DELAY_SLOTS
  3264.   if (flag_delayed_branch)
  3265.     warning ("this target machine does not have delayed branches");
  3266. #endif
  3267.  
  3268.   /* If we are in verbose mode, write out the version and maybe all the
  3269.      option flags in use.  */
  3270.   if (version_flag)
  3271.     {
  3272.       fprintf (stderr, "%s version %s", language_string, version_string);
  3273. #ifdef TARGET_VERSION
  3274.       TARGET_VERSION;
  3275. #endif
  3276. #ifdef __GNUC__
  3277. #ifndef __VERSION__
  3278. #define __VERSION__ "[unknown]"
  3279. #endif
  3280.       fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
  3281. #else
  3282.       fprintf (stderr, " compiled by CC.\n");
  3283. #endif
  3284.       if (! quiet_flag)
  3285.     print_switch_values ();
  3286.     }
  3287.  
  3288.   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
  3289.   init_reg_sets_1 ();
  3290.  
  3291.   compile_file (filename);
  3292.  
  3293. #ifndef OS2
  3294. #ifndef VMS
  3295. #ifndef amigados
  3296.   if (flag_print_mem)
  3297.     {
  3298.       char *lim = (char *) sbrk (0);
  3299.  
  3300.       fprintf (stderr, "Data size %d.\n",
  3301.            lim - (char *) &environ);
  3302.       fflush (stderr);
  3303.  
  3304. #ifdef USG
  3305.       system ("ps -l 1>&2");
  3306. #else /* not USG */
  3307.       system ("ps v");
  3308. #endif /* not USG */
  3309.     }
  3310. #endif /* not amigados */
  3311. #endif /* not VMS */
  3312. #endif /* not OS2 */
  3313.  
  3314.   if (errorcount)
  3315.     exit (FATAL_EXIT_CODE);
  3316.   if (sorrycount)
  3317.     exit (FATAL_EXIT_CODE);
  3318.   exit (SUCCESS_EXIT_CODE);
  3319.   return 34;
  3320. }
  3321.  
  3322. /* Decode -m switches.  */
  3323.  
  3324. /* Here is a table, controlled by the tm.h file, listing each -m switch
  3325.    and which bits in `target_switches' it should set or clear.
  3326.    If VALUE is positive, it is bits to set.
  3327.    If VALUE is negative, -VALUE is bits to clear.
  3328.    (The sign bit is not used so there is no confusion.)  */
  3329.  
  3330. struct {char *name; int value;} target_switches []
  3331.   = TARGET_SWITCHES;
  3332.  
  3333. /* This table is similar, but allows the switch to have a value.  */
  3334.  
  3335. #ifdef TARGET_OPTIONS
  3336. struct {char *prefix; char ** variable;} target_options []
  3337.   = TARGET_OPTIONS;
  3338. #endif
  3339.  
  3340. /* Decode the switch -mNAME.  */
  3341.  
  3342. void
  3343. set_target_switch (name)
  3344.      char *name;
  3345. {
  3346.   register int j;
  3347.   int valid = 0;
  3348.  
  3349.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  3350.     if (!strcmp (target_switches[j].name, name))
  3351.       {
  3352.     if (target_switches[j].value < 0)
  3353.       target_flags &= ~-target_switches[j].value;
  3354.     else
  3355.       target_flags |= target_switches[j].value;
  3356.     valid = 1;
  3357.       }
  3358.  
  3359. #ifdef TARGET_OPTIONS
  3360.   if (!valid)
  3361.     for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
  3362.       {
  3363.     int len = strlen (target_options[j].prefix);
  3364.     if (!strncmp (target_options[j].prefix, name, len))
  3365.       {
  3366.         *target_options[j].variable = name + len;
  3367.         valid = 1;
  3368.       }
  3369.       }
  3370. #endif
  3371.  
  3372.   if (!valid)
  3373.     error ("Invalid option `%s'", name);
  3374. }
  3375.  
  3376. /* Variable used for communication between the following two routines.  */
  3377.  
  3378. static int line_position;
  3379.  
  3380. /* Print an option value and adjust the position in the line.  */
  3381.  
  3382. static void
  3383. print_single_switch (type, name)
  3384.      char *type, *name;
  3385. {
  3386.   fprintf (stderr, " %s%s", type, name);
  3387.  
  3388.   line_position += strlen (type) + strlen (name) + 1;
  3389.  
  3390.   if (line_position > 65)
  3391.     {
  3392.       fprintf (stderr, "\n\t");
  3393.       line_position = 8;
  3394.     }
  3395. }
  3396.      
  3397. /* Print default target switches for -version.  */
  3398.  
  3399. static void
  3400. print_switch_values ()
  3401. {
  3402.   register int j;
  3403.  
  3404.   fprintf (stderr, "enabled:");
  3405.   line_position = 8;
  3406.  
  3407.   for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
  3408.     if (*f_options[j].variable == f_options[j].on_value)
  3409.       print_single_switch ("-f", f_options[j].string);
  3410.  
  3411.   for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++)
  3412.     if (*W_options[j].variable == W_options[j].on_value)
  3413.       print_single_switch ("-W", W_options[j].string);
  3414.  
  3415.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  3416.     if (target_switches[j].name[0] != '\0'
  3417.     && target_switches[j].value > 0
  3418.     && ((target_switches[j].value & target_flags)
  3419.         == target_switches[j].value))
  3420.       print_single_switch ("-m", target_switches[j].name);
  3421.  
  3422.   fprintf (stderr, "\n");
  3423. }
  3424.