⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toplev.c

📁 这是完整的gcc源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* Top level of GNU C compiler   Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 1, or (at your option)any later version.GNU CC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  *//* This is the top level of cc1.   It parses command args, opens files, invokes the various passes   in the proper order, and counts the time used by each.   Error messages and low-level interface to malloc also handled here.  */#include "config.h"#include <sys/types.h>#include <stdio.h>#include <signal.h>#include <setjmp.h>#include <sys/stat.h>#ifdef USG#undef FLOAT#include <sys/param.h>/* This is for hpux.  It is a real screw.  They should change hpux.  */#undef FLOAT#include <sys/times.h>#include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */#undef FFS  /* Some systems define this in param.h.  */#else#ifndef VMS#include <sys/time.h>#include <sys/resource.h>#endif#endif#include "input.h"#include "tree.h"#include "c-tree.h"#include "rtl.h"#include "flags.h"extern int yydebug;extern FILE *finput;extern int reload_completed;extern int rtx_equal_function_value_matters;extern void init_lex ();extern void init_decl_processing ();extern void init_tree ();extern void init_rtl ();extern void init_optabs ();extern void init_reg_sets ();extern void dump_flow_info ();extern void dump_local_alloc ();void rest_of_decl_compilation ();void error ();void error_with_file_and_line ();void fancy_abort ();void set_target_switch ();void print_target_switch_defaults ();/* Bit flags that specify the machine subtype we are compiling for.   Bits are tested using macros TARGET_... defined in the tm-...h file   and set by `-m...' switches.  */int target_flags;/* Name of current original source file (what was input to cpp).   This comes from each #-command in the actual input.  */char *input_filename;/* Name of top-level original source file (what was input to cpp).   This comes from the #-command at the beginning of the actual input.   If there isn't any there, then this is the cc1 input file name.  */char *main_input_filename;/* Current line number in real source file.  */int lineno;/* Stack of currently pending input files.  */struct file_stack *input_file_stack;/* Incremented on each change to input_file_stack.  */int input_file_stack_tick;/* FUNCTION_DECL for function now being parsed or compiled.  */extern tree current_function_decl;/* Name to use as base of names for dump output files.  */char *dump_base_name;/* Flags saying which kinds of debugging dump have been requested.  */int rtl_dump = 0;int rtl_dump_and_exit = 0;int jump_opt_dump = 0;int cse_dump = 0;int loop_dump = 0;int flow_dump = 0;int combine_dump = 0;int local_reg_dump = 0;int global_reg_dump = 0;int jump2_opt_dump = 0;int dbr_sched_dump = 0;/* 1 => write gdb debugging output (using symout.c).  -g   2 => write dbx debugging output (using dbxout.c).  -G   3 => write sdb debugging output (using sdbout.c).  -g.  */enum debugger write_symbols = NO_DEBUG;/* Nonzero means can use our own extensions to DBX format.   Relevant only with write_symbols == DBX_DEBUG.  */int use_gdb_dbx_extensions;/* Nonzero means do optimizations.  -opt.  */int optimize = 0;/* Nonzero means `char' should be signed.  */int flag_signed_char;/* Nonzero means give an enum type only as many bytes as it needs.  */int flag_short_enums;/* Nonzero for -fcaller-saves: allocate values in regs that need to   be saved across function calls, if that produces overall better code.   Optional now, so people can test it.  */#ifdef DEFAULT_CALLER_SAVESint flag_caller_saves = 1;#elseint flag_caller_saves = 0;#endif/* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */int flag_pcc_struct_return = 0;/* Nonzero for -fforce-mem: load memory value into a register   before arithmetic on it.  This makes better cse but slower compilation.  */int flag_force_mem = 0;/* Nonzero for -fforce-addr: load memory address into a register before   reference to memory.  This makes better cse but slower compilation.  */int flag_force_addr = 0;/* Nonzero for -fdefer-pop: don't pop args after each function call;   instead save them up to pop many calls' args with one insns.  */int flag_defer_pop = 1;/* Nonzero for -ffloat-store: don't allocate floats and doubles   in extended-precision registers.  */int flag_float_store = 0;/* Nonzero for -fcombine-regs:   allow instruction combiner to combine an insn   that just copies one reg to another.  */int flag_combine_regs = 0;/* Nonzero enables strength-reduction in loop.c.  */int flag_strength_reduce = 0;/* Nonzero for -fwritable-strings:   store string constants in data segment and don't uniquize them.  */int flag_writable_strings = 0;/* Nonzero means don't put addresses of constant functions in registers.   Used for compiling the Unix kernel, where strange substitutions are   done on the assembly output.  */int flag_no_function_cse = 0;/* Nonzero for -fomit-frame-pointer:   don't make a frame pointer in simple functions that don't require one.  */int flag_omit_frame_pointer = 0;/* Nonzero to inhibit use of define_optimization peephole opts.  */int flag_no_peephole = 0;/* Nonzero means all references through pointers are volatile.  */int flag_volatile;/* Nonzero means just do syntax checking; don't output anything.  */int flag_syntax_only = 0;/* Nonzero means do stupid register allocation.  -noreg.   This and `optimize' are controlled by different switches in cc1,   but normally cc controls them both with the -O switch.  */int obey_regdecls = 0;/* Don't print functions as they are compiled and don't print   times taken by the various passes.  -quiet.  */int quiet_flag = 0;/* Don't print warning messages.  -w.  */int inhibit_warnings = 0;/* Do print extra warnings (such as for uninitialized variables).  -W.  */int extra_warnings = 0;/* Nonzero to warn about unused local variables.  */int warn_unused;/* Nonzero means warn about all declarations which shadow others.   */int warn_shadow;/* Warn if a switch on an enum fails to have a case for every enum value.  */int warn_switch;/* Nonzero means warn about any identifiers that match in the first N   characters.  The value N is in `id_clash_len'.  */int warn_id_clash;int id_clash_len;/* Number of error messages and warning messages so far.  */int errorcount = 0;int warningcount = 0;int sorrycount = 0;/* Name of program invoked, sans directories.  */char *progname;/* Nonzero if generating code to do profiling.  */int profile_flag = 0;/* Nonzero if generating code to do profiling on a line-by-line basis.  */int profile_block_flag;/* Nonzero for -pedantic switch: warn about anything   that standard spec forbids.  */int pedantic = 0;/* Nonzero for -finline-functions: ok to inline functions that look like   good inline candidates.  */int flag_inline_functions;/* Nonzero for -fkeep-inline-functions: even if we make a function   go inline everywhere, keep its defintion around for debugging   purposes.  */int flag_keep_inline_functions;/* Nonzero means make the text shared if supported.  */int flag_shared_data;/* Nonzero means schedule into delayed branch slots if supported.  */int flag_delayed_branch;/* Copy of arguments to main.  */int save_argc;char **save_argv;/* Name for output file of assembly code, specified with -o.  */char *asm_file_name;/* Name for output file of GDB symbol segment, specified with -symout.  */char *sym_file_name;/* Table of language-independent -f options.   STRING is the option name.  VARIABLE is the address of the variable.   ON_VALUE is the value to store in VARIABLE    if `-fSTRING' is seen as an option.   (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */struct { char *string; int *variable; int on_value;} f_options[] ={  {"float-store", &flag_float_store, 1},  {"volatile", &flag_volatile, 1},  {"defer-pop", &flag_defer_pop, 1},  {"omit-frame-pointer", &flag_omit_frame_pointer, 1},  {"strength-reduce", &flag_strength_reduce, 1},  {"writable-strings", &flag_writable_strings, 1},  {"peephole", &flag_no_peephole, 0},  {"force-mem", &flag_force_mem, 1},  {"force-addr", &flag_force_addr, 1},  {"combine-regs", &flag_combine_regs, 1},  {"function-cse", &flag_no_function_cse, 0},  {"inline-functions", &flag_inline_functions, 1},  {"keep-inline-functions", &flag_keep_inline_functions, 1},  {"syntax-only", &flag_syntax_only, 1},  {"shared-data", &flag_shared_data, 1},  {"caller-saves", &flag_caller_saves, 1},  {"pcc-struct-return", &flag_pcc_struct_return, 1},  {"delayed-branch", &flag_delayed_branch, 1}};/* Output files for assembler code (real compiler output)   and debugging dumps.  */FILE *asm_out_file;FILE *rtl_dump_file;FILE *jump_opt_dump_file;FILE *cse_dump_file;FILE *loop_dump_file;FILE *flow_dump_file;FILE *combine_dump_file;FILE *local_reg_dump_file;FILE *global_reg_dump_file;FILE *jump2_opt_dump_file;FILE *dbr_sched_dump_file;/* Time accumulators, to count the total time spent in various passes.  */int parse_time;int varconst_time;int integration_time;int jump_time;int cse_time;int loop_time;int flow_time;int combine_time;int local_alloc_time;int global_alloc_time;int dbr_sched_time;int final_time;int symout_time;int dump_time;/* Return time used so far, in microseconds.  */intgettime (){#ifdef USG  struct tms tms;#else#ifndef VMS  struct rusage rusage;#else /* VMS */  struct    {      int proc_user_time;      int proc_system_time;      int child_user_time;      int child_system_time;    } vms_times;#endif#endif  if (quiet_flag)    return 0;#ifdef USG  times (&tms);  return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);#else#ifndef VMS  getrusage (0, &rusage);  return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec	  + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);#else /* VMS */  times (&vms_times);  return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;#endif#endif}#define TIMEVAR(VAR, BODY)    \do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)voidprint_time (str, total)     char *str;     int total;{  fprintf (stderr,	   "time in %s: %d.%06d\n",	   str, total / 1000000, total % 1000000);}/* Count an error or warning.  Return 1 if the message should be printed.  */intcount_error (warningp)     int warningp;{  if (warningp && inhibit_warnings)    return 0;  if (warningp)    warningcount++;  else    errorcount++;  return 1;}/* Print a fatal error message.  NAME is the text.   Also include a system error message based on `errno'.  */voidpfatal_with_name (name)     char *name;{  fprintf (stderr, "%s: ", progname);  perror (name);  exit (35);}voidfatal_io_error (name)     char *name;{  fprintf (stderr, "%s: %s: I/O error\n", progname, name);  exit (35);}voidfatal (s, v)     char *s;     int v;{  error (s, v);  exit (34);}/* Called from insn-extract to give a better error message when we   don't have an insn to match what we are looking for, rather   than just calling abort().  */voidfatal_insn_not_found (insn)     rtx insn;{  error ("The following insn was not recognizable:", 0);  debug_rtx (insn);  abort ();}static int need_error_newline;/* Function of last error message;   more generally, function such that if next error message is in it   then we don't have to mention the function name.  */static tree last_error_function = NULL;/* Used to detect when input_file_stack has changed since last described.  */static int last_error_tick;/* Called when the start of a function definition is parsed,   this function prints on stderr the name of the function.  */voidannounce_function (decl)     tree decl;{  if (! quiet_flag)    {      fprintf (stderr, " %s", DECL_PRINT_NAME (decl));      fflush (stderr);      need_error_newline = 1;      last_error_function = current_function_decl;    }}/* Prints out, if necessary, the name of the current function   which caused an error.  Called from all error and warning functions.  */voidreport_error_function (file)     char *file;{  struct file_stack *p;  if (need_error_newline)    {      fprintf (stderr, "\n");      need_error_newline = 0;    }  if (last_error_function != current_function_decl)    {      if (file)	fprintf (stderr, "%s: ", file);      if (current_function_decl == NULL)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -