GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
for more details.
You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA. */
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
/* This is the top level of cc1/c++.
It parses command args, opens files, invokes the various passes
location_t input_location;
-struct line_maps line_table;
-
-/* Nonzero if it is unsafe to create any new pseudo registers. */
-int no_new_pseudos;
+struct line_maps *line_table;
/* Stack of currently pending input files. */
const char *aux_base_name;
-/* 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. Must be defined in rtlanal.c. */
-
-extern int target_flags;
-
/* A mask of target_flags that includes bit X if X was set or cleared
on the command line. */
int align_labels_max_skip;
int align_functions_log;
-/* Like align_functions_log above, but used by front-ends to force the
- minimum function alignment. Zero means no alignment is forced. */
-int force_align_functions_log;
-
typedef struct
{
const char *const string;
fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
fflush (stderr);
pp_needs_newline (global_dc->printer) = true;
- diagnostic_set_last_function (global_dc);
+ diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
}
}
if (input_name == NULL)
input_name = "<stdin>";
+ else
+ input_name = remap_debug_filename (input_name);
len = strlen (input_name);
na = input_name + len;
string is patterned after the ones produced by native SVR4 compilers. */
#ifdef IDENT_ASM_OP
if (!flag_no_ident)
- fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
- IDENT_ASM_OP, version_string);
+ {
+ const char *pkg_version = "(GNU) ";
+
+ if (strcmp ("(GCC) ", pkgversion_string))
+ pkg_version = pkgversion_string;
+ fprintf (asm_out_file, "%s\"GCC: %s%s\"\n",
+ IDENT_ASM_OP, pkg_version, version_string);
+ }
#endif
/* This must be at the end. Some target ports emit end of file directives
{
static const char fmt1[] =
#ifdef __GNUC__
- N_("%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n")
+ N_("%s%s%s %sversion %s (%s)\n%s\tcompiled by GNU C version %s, ")
#else
- N_("%s%s%s version %s (%s) compiled by CC.\n")
+ N_("%s%s%s %sversion %s (%s) compiled by CC, ")
#endif
;
static const char fmt2[] =
+ N_("GMP version %s, MPFR version %s.\n");
+ static const char fmt3[] =
+ N_("warning: %s header version %s differs from library version %s.\n");
+ static const char fmt4[] =
N_("%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n");
#ifndef __VERSION__
#define __VERSION__ "[?]"
fprintf (file,
file == stderr ? _(fmt1) : fmt1,
indent, *indent != 0 ? " " : "",
- lang_hooks.name, version_string, TARGET_NAME,
+ lang_hooks.name, pkgversion_string, version_string, TARGET_NAME,
indent, __VERSION__);
+
+ /* We need to stringify the GMP macro values. Ugh, gmp_version has
+ two string formats, "i.j.k" and "i.j" when k is zero. */
+#define GCC_GMP_STRINGIFY_VERSION3(X) #X
+#define GCC_GMP_STRINGIFY_VERSION2(X) GCC_GMP_STRINGIFY_VERSION3(X)
+#if __GNU_MP_VERSION_PATCHLEVEL == 0
+#define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
+ GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR)
+#else
+#define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
+ GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR) "." \
+ GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_PATCHLEVEL)
+#endif
fprintf (file,
file == stderr ? _(fmt2) : fmt2,
+ GCC_GMP_STRINGIFY_VERSION, MPFR_VERSION_STRING);
+ if (strcmp (GCC_GMP_STRINGIFY_VERSION, gmp_version))
+ fprintf (file,
+ file == stderr ? _(fmt3) : fmt3,
+ "GMP", GCC_GMP_STRINGIFY_VERSION, gmp_version);
+ if (strcmp (MPFR_VERSION_STRING, mpfr_get_version ()))
+ fprintf (file,
+ file == stderr ? _(fmt3) : fmt3,
+ "MPFR", MPFR_VERSION_STRING, mpfr_get_version ());
+ fprintf (file,
+ file == stderr ? _(fmt4) : fmt4,
indent, *indent != 0 ? " " : "",
PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
}
return true;
}
+/* A helper function; used as the reallocator function for cpp's line
+ table. */
+static void *
+realloc_for_line_map (void *ptr, size_t len)
+{
+ return ggc_realloc (ptr, len);
+}
+
/* Initialization of the front end environment, before command line
options are parsed. Signal handlers, internationalization etc.
ARGV0 is main's argv[0]. */
table. */
init_ggc ();
init_stringpool ();
- linemap_init (&line_table);
+ line_table = GGC_NEW (struct line_maps);
+ linemap_init (line_table);
+ line_table->reallocator = realloc_for_line_map;
init_ttree ();
/* Initialize register usage now so switches may override. */
return true;
}
+/* Default the align_* variables to 1 if they're still unset, and
+ set up the align_*_log variables. */
+static void
+init_alignments (void)
+{
+ if (align_loops <= 0)
+ align_loops = 1;
+ if (align_loops_max_skip > align_loops)
+ align_loops_max_skip = align_loops - 1;
+ align_loops_log = floor_log2 (align_loops * 2 - 1);
+ if (align_jumps <= 0)
+ align_jumps = 1;
+ if (align_jumps_max_skip > align_jumps)
+ align_jumps_max_skip = align_jumps - 1;
+ align_jumps_log = floor_log2 (align_jumps * 2 - 1);
+ if (align_labels <= 0)
+ align_labels = 1;
+ align_labels_log = floor_log2 (align_labels * 2 - 1);
+ if (align_labels_max_skip > align_labels)
+ align_labels_max_skip = align_labels - 1;
+ if (align_functions <= 0)
+ align_functions = 1;
+ align_functions_log = floor_log2 (align_functions * 2 - 1);
+}
+
/* Process the options that have been parsed. */
static void
process_options (void)
else
aux_base_name = "gccaux";
- /* Set up the align_*_log variables, defaulting them to 1 if they
- were still unset. */
- if (align_loops <= 0) align_loops = 1;
- if (align_loops_max_skip > align_loops || !align_loops)
- align_loops_max_skip = align_loops - 1;
- align_loops_log = floor_log2 (align_loops * 2 - 1);
- if (align_jumps <= 0) align_jumps = 1;
- if (align_jumps_max_skip > align_jumps || !align_jumps)
- align_jumps_max_skip = align_jumps - 1;
- align_jumps_log = floor_log2 (align_jumps * 2 - 1);
- if (align_labels <= 0) align_labels = 1;
- align_labels_log = floor_log2 (align_labels * 2 - 1);
- if (align_labels_max_skip > align_labels || !align_labels)
- align_labels_max_skip = align_labels - 1;
- if (align_functions <= 0) align_functions = 1;
- align_functions_log = floor_log2 (align_functions * 2 - 1);
-
/* Unrolling all loops implies that standard loop unrolling must also
be done. */
if (flag_unroll_all_loops)
if (flag_asynchronous_unwind_tables)
flag_unwind_tables = 1;
- /* Disable unit-at-a-time mode for frontends not supporting callgraph
- interface. */
- if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
- flag_unit_at_a_time = 0;
-
if (!flag_unit_at_a_time)
flag_section_anchors = 0;
if (debug_info_level < DINFO_LEVEL_NORMAL
|| debug_hooks->var_location == do_nothing_debug_hooks.var_location)
{
- if (flag_var_tracking == 1)
+ if (flag_var_tracking == 1
+ || flag_var_tracking_uninit == 1)
{
if (debug_info_level < DINFO_LEVEL_NORMAL)
warning (0, "variable tracking requested, but useless unless "
"by this debug format");
}
flag_var_tracking = 0;
+ flag_var_tracking_uninit = 0;
}
if (flag_rename_registers == AUTODETECT_VALUE)
if (flag_var_tracking == AUTODETECT_VALUE)
flag_var_tracking = optimize >= 1;
+ if (flag_tree_cselim == AUTODETECT_VALUE)
+#ifdef HAVE_conditional_move
+ flag_tree_cselim = 1;
+#else
+ flag_tree_cselim = 0;
+#endif
+
+ /* If the user specifically requested variable tracking with tagging
+ uninitialized variables, we need to turn on variable tracking.
+ (We already determined above that variable tracking is feasible.) */
+ if (flag_var_tracking_uninit)
+ flag_var_tracking = 1;
+
/* If auxiliary info generation is desired, open the output file.
This goes in the same directory as the source file--unlike
all the other output files. */
}
}
-/* Initialize the compiler back end. */
+/* This function can be called multiple times to reinitialize the compiler
+ back end when register classes or instruction sets have changed,
+ before each function. */
+static void
+backend_init_target (void)
+{
+ /* Initialize alignment variables. */
+ init_alignments ();
+
+ /* This reinitializes hard_frame_pointer, and calls init_reg_modes_target()
+ to initialize reg_raw_mode[]. */
+ init_emit_regs ();
+
+ /* This invokes target hooks to set fixed_reg[] etc, which is
+ mode-dependent. */
+ init_regs ();
+
+ /* This depends on stack_pointer_rtx. */
+ init_fake_stack_mems ();
+
+ /* Sets static_base_value[HARD_FRAME_POINTER_REGNUM], which is
+ mode-dependent. */
+ init_alias_target ();
+
+ /* Depends on HARD_FRAME_POINTER_REGNUM. */
+ init_reload ();
+
+ /* The following initialization functions need to generate rtl, so
+ provide a dummy function context for them. */
+ init_dummy_function_start ();
+
+ /* rtx_cost is mode-dependent, so cached values need to be recomputed
+ on a mode change. */
+ init_expmed ();
+
+ /* We may need to recompute regno_save_code[] and regno_restore_code[]
+ after a mode change as well. */
+ if (flag_caller_saves)
+ init_caller_save ();
+ expand_dummy_function_end ();
+}
+
+/* Initialize the compiler back end. This function is called only once,
+ when starting the compiler. */
static void
backend_init (void)
{
|| flag_test_coverage);
init_rtlanal ();
- init_regs ();
- init_fake_stack_mems ();
- init_alias_once ();
init_inline_once ();
- init_reload ();
init_varasm_once ();
+ save_register_info ();
+
+ /* Initialize the target-specific back end pieces. */
+ backend_init_target ();
+}
+
+/* Initialize things that are both lang-dependent and target-dependent.
+ This function can be called more than once if target parameters change. */
+static void
+lang_dependent_init_target (void)
+{
+ /* This creates various _DECL nodes, so needs to be called after the
+ front end is initialized. It also depends on the HAVE_xxx macros
+ generated from the target machine description. */
+ init_optabs ();
/* The following initialization functions need to generate rtl, so
provide a dummy function context for them. */
init_dummy_function_start ();
- init_expmed ();
- if (flag_caller_saves)
- init_caller_save ();
+
+ /* Do the target-specific parts of expr initialization. */
+ init_expr_target ();
+
+ /* Although the actions of init_set_costs are language-independent,
+ it uses optabs, so we cannot call it from backend_init. */
+ init_set_costs ();
+
expand_dummy_function_end ();
}
init_asm_output (name);
- /* These create various _DECL nodes, so need to be called after the
+ /* This creates various _DECL nodes, so needs to be called after the
front end is initialized. */
init_eh ();
- init_optabs ();
-
- /* The following initialization functions need to generate rtl, so
- provide a dummy function context for them. */
- init_dummy_function_start ();
- init_expr_once ();
- /* Although the actions of init_set_costs are language-independent,
- it uses optabs, so we cannot call it from backend_init. */
- init_set_costs ();
-
- expand_dummy_function_end ();
+ /* Do the target-specific parts of the initialization. */
+ lang_dependent_init_target ();
/* If dbx symbol table desired, initialize writing it and output the
predefined types. */
return 1;
}
+
+/* Reinitialize everything when target parameters, such as register usage,
+ have changed. */
+void
+target_reinit (void)
+{
+ /* Reinitialize RTL backend. */
+ backend_init_target ();
+
+ /* Reinitialize lang-dependent parts. */
+ lang_dependent_init_target ();
+}
+
void
dump_memory_report (bool final)
{
if (mem_report)
dump_memory_report (true);
- /* Free up memory for the benefit of leak detectors. */
- free_reg_info ();
-
/* Language-specific end of compilation actions. */
lang_hooks.finish ();
}