/* Length of line when printing switch values. */
#define MAX_LINE 75
-/* Copy of argument vector to toplev_main. */
-static const char **save_argv;
+/* Decoded options, and number of such options. */
+static struct cl_decoded_option *save_decoded_options;
+static unsigned int save_decoded_options_count;
/* 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 none. */
const char * current_function_func_begin_label;
-/* Nonzero means to collect statistics which might be expensive
- and to print them when we are done. */
-int flag_detailed_statistics = 0;
-
/* A random sequence of characters, unless overridden by user. */
static const char *flag_random_seed;
/* -f flags. */
-/* Nonzero means `char' should be signed. */
-
-int flag_signed_char;
-
-/* Nonzero means give an enum type only as many bytes as it needs. A value
- of 2 means it has not yet been initialized. */
-
-int flag_short_enums;
-
-/* Nonzero if structures and unions should be returned in memory.
-
- This should only be defined if compatibility with another compiler or
- with an ABI is needed, because it results in slower code. */
-
-#ifndef DEFAULT_PCC_STRUCT_RETURN
-#define DEFAULT_PCC_STRUCT_RETURN 1
-#endif
-
-/* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
-
-int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
-
/* 0 means straightforward implementation of complex divide acceptable.
1 means wide ranges of inputs must work for complex divide.
2 means C99-like requirements for complex multiply and divide. */
enum ira_algorithm flag_ira_algorithm = IRA_ALGORITHM_CB;
enum ira_region flag_ira_region = IRA_REGION_MIXED;
-/* Set the default value for -fira-verbose. */
-
-unsigned int flag_ira_verbose = 5;
-
/* Set the default for excess precision. */
enum excess_precision flag_excess_precision_cmdline = EXCESS_PRECISION_DEFAULT;
-enum excess_precision flag_excess_precision = EXCESS_PRECISION_DEFAULT;
/* Nonzero means change certain warnings into errors.
Usually these are warnings about failure to conform to some standard. */
bool user_defined_section_attribute = false;
-/* Values of the -falign-* flags: how much to align labels in code.
- 0 means `use default', 1 means `don't align'.
- For each variable, there is an _log variant which is the power
- of two not less than the variable, for .align output. */
-
-int align_loops_log;
-int align_loops_max_skip;
-int align_jumps_log;
-int align_jumps_max_skip;
-int align_labels_log;
-int align_labels_max_skip;
-int align_functions_log;
+struct target_flag_state default_target_flag_state;
+#if SWITCHABLE_TARGET
+struct target_flag_state *this_target_flag_state = &default_target_flag_state;
+#else
+#define this_target_flag_state (&default_target_flag_state)
+#endif
typedef struct
{
FILE *asm_out_file;
FILE *aux_info_file;
+FILE *stack_usage_file = NULL;
FILE *dump_file = NULL;
const char *dump_file_name;
return old;
}
-/* Decode the string P as an integral parameter.
- If the string is indeed an integer return its numeric value else
- issue an Invalid Option error for the option PNAME and return DEFVAL.
- If PNAME is zero just return DEFVAL, do not call error. */
-
-int
-read_integral_parameter (const char *p, const char *pname, const int defval)
-{
- const char *endp = p;
-
- while (*endp)
- {
- if (ISDIGIT (*endp))
- endp++;
- else
- break;
- }
-
- if (*endp != 0)
- {
- if (pname != 0)
- error ("invalid option argument %qs", pname);
- return defval;
- }
-
- return atoi (p);
-}
-
#if GCC_VERSION < 3004
-/* The functions floor_log2 and exact_log2 are defined as inline
- functions in toplev.h if GCC_VERSION >= 3004. The definitions here
- are used for older versions of gcc. */
+/* The functions clz_hwi, ctz_hwi, ffs_hwi, floor_log2 and exact_log2
+ are defined as inline functions in toplev.h if GCC_VERSION >= 3004.
+ The definitions here are used for older versions of gcc. */
/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
If X is 0, return -1. */
return floor_log2 (x);
}
+/* Given X, an unsigned number, return the number of least significant bits
+ that are zero. When X == 0, the result is the word size. */
+
+int
+ctz_hwi (unsigned HOST_WIDE_INT x)
+{
+ return x ? floor_log2 (x & -x) : HOST_BITS_PER_WIDE_INT;
+}
+
+/* Similarly for most significant bits. */
+
+int
+clz_hwi (unsigned HOST_WIDE_INT x)
+{
+ return HOST_BITS_PER_WIDE_INT - 1 - floor_log2(x);
+}
+
+/* Similar to ctz_hwi, except that the least significant bit is numbered
+ starting from 1, and X == 0 yields 0. */
+
+int
+ffs_hwi (unsigned HOST_WIDE_INT x)
+{
+ return 1 + floor_log2 (x & -x);
+}
+
#endif /* GCC_VERSION < 3004 */
/* Handler for fatal signals, such as SIGSEGV. These are transformed
#endif
}
-/* Output a file name in the form wanted by System V. */
-
-void
-output_file_directive (FILE *asm_file, const char *input_name)
-{
- int len;
- const char *na;
-
- if (input_name == NULL)
- input_name = "<stdin>";
- else
- input_name = remap_debug_filename (input_name);
-
- len = strlen (input_name);
- na = input_name + len;
-
- /* NA gets INPUT_NAME sans directory names. */
- while (na > input_name)
- {
- if (IS_DIR_SEPARATOR (na[-1]))
- break;
- na--;
- }
-
-#ifdef ASM_OUTPUT_SOURCE_FILENAME
- ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
-#else
- fprintf (asm_file, "\t.file\t");
- output_quoted_string (asm_file, na);
- putc ('\n', asm_file);
-#endif
-}
-
/* A subroutine of wrapup_global_declarations. We've come to the end of
the compilation unit. All deferred variables should be undeferred,
and all incomplete decls should be finalized. */
{
struct varpool_node *node;
bool needed = true;
- node = varpool_node (decl);
+ node = varpool_get_node (decl);
- if (node->finalized)
+ if (!node && flag_ltrans)
+ needed = false;
+ else if (node && node->finalized)
needed = false;
- else if (node->alias)
+ else if (node && node->alias)
needed = false;
else if (!cgraph_global_info_ready
&& (TREE_USED (decl)
|| TREE_USED (DECL_ASSEMBLER_NAME (decl))))
/* needed */;
- else if (node->needed)
+ else if (node && node->needed)
/* needed */;
else if (DECL_COMDAT (decl))
needed = false;
if (seen_error ())
return;
- /* Ensure that emulated TLS control vars are finalized and build
- a static constructor for them, when it is required. */
- if (!targetm.have_tls)
- emutls_finish ();
-
varpool_assemble_pending_decls ();
finish_aliases_2 ();
{
int pos = 0;
size_t j;
- const char **p;
/* Fill in the -frandom-seed option, if the user didn't pass it, so
that it can be printed below. This helps reproducibility. */
pos = print_single_switch (print_fn, pos,
SWITCH_TYPE_DESCRIPTIVE, _("options passed: "));
- for (p = &save_argv[1]; *p != NULL; p++)
+ for (j = 1; j < save_decoded_options_count; j++)
{
- if (**p == '-')
+ switch (save_decoded_options[j].opt_index)
{
+ case OPT_o:
+ case OPT_d:
+ case OPT_dumpbase:
+ case OPT_dumpdir:
+ case OPT_auxbase:
+ case OPT_quiet:
+ case OPT_version:
/* Ignore these. */
- if (strcmp (*p, "-o") == 0
- || strcmp (*p, "-dumpbase") == 0
- || strcmp (*p, "-dumpdir") == 0
- || strcmp (*p, "-auxbase") == 0)
- {
- if (p[1] != NULL)
- p++;
- continue;
- }
-
- if (strcmp (*p, "-quiet") == 0
- || strcmp (*p, "-version") == 0)
- continue;
-
- if ((*p)[1] == 'd')
- continue;
+ continue;
}
- pos = print_single_switch (print_fn, pos, SWITCH_TYPE_PASSED, *p);
+ pos = print_single_switch (print_fn, pos, SWITCH_TYPE_PASSED,
+ save_decoded_options[j].orig_option_with_args_text);
}
if (pos > 0)
static void *
realloc_for_line_map (void *ptr, size_t len)
{
- return ggc_realloc (ptr, len);
+ return GGC_RESIZEVAR (void, ptr, len);
}
/* A helper function: used as the allocator function for
static void *
alloc_for_identifier_to_locale (size_t len)
{
- return ggc_alloc (len);
+ return ggc_alloc_atomic (len);
+}
+
+/* Output stack usage information. */
+void
+output_stack_usage (void)
+{
+ static bool warning_issued = false;
+ enum stack_usage_kind_type { STATIC = 0, DYNAMIC, DYNAMIC_BOUNDED };
+ const char *stack_usage_kind_str[] = {
+ "static",
+ "dynamic",
+ "dynamic,bounded"
+ };
+ HOST_WIDE_INT stack_usage = current_function_static_stack_size;
+ enum stack_usage_kind_type stack_usage_kind;
+ expanded_location loc;
+ const char *raw_id, *id;
+
+ if (stack_usage < 0)
+ {
+ if (!warning_issued)
+ {
+ warning (0, "-fstack-usage not supported for this target");
+ warning_issued = true;
+ }
+ return;
+ }
+
+ stack_usage_kind = STATIC;
+
+ /* Add the maximum amount of space pushed onto the stack. */
+ if (current_function_pushed_stack_size > 0)
+ {
+ stack_usage += current_function_pushed_stack_size;
+ stack_usage_kind = DYNAMIC_BOUNDED;
+ }
+
+ /* Now on to the tricky part: dynamic stack allocation. */
+ if (current_function_allocates_dynamic_stack_space)
+ {
+ if (current_function_has_unbounded_dynamic_stack_size)
+ stack_usage_kind = DYNAMIC;
+ else
+ stack_usage_kind = DYNAMIC_BOUNDED;
+
+ /* Add the size even in the unbounded case, this can't hurt. */
+ stack_usage += current_function_dynamic_stack_size;
+ }
+
+ loc = expand_location (DECL_SOURCE_LOCATION (current_function_decl));
+
+ /* Strip the scope prefix if any. */
+ raw_id = lang_hooks.decl_printable_name (current_function_decl, 2);
+ id = strrchr (raw_id, '.');
+ if (id)
+ id++;
+ else
+ id = raw_id;
+
+ fprintf (stack_usage_file,
+ "%s:%d:%d:%s\t"HOST_WIDE_INT_PRINT_DEC"\t%s\n",
+ lbasename (loc.file),
+ loc.line,
+ loc.column,
+ id,
+ stack_usage,
+ stack_usage_kind_str[stack_usage_kind]);
+}
+
+/* Open an auxiliary output file. */
+static FILE *
+open_auxiliary_file (const char *ext)
+{
+ char *filename;
+ FILE *file;
+
+ filename = concat (aux_base_name, ".", ext, NULL);
+ file = fopen (filename, "w");
+ if (!file)
+ fatal_error ("can't open %s for writing: %m", filename);
+ free (filename);
+ return file;
}
/* Initialization of the front end environment, before command line
table. */
init_ggc ();
init_stringpool ();
- line_table = GGC_NEW (struct line_maps);
+ line_table = ggc_alloc_line_maps ();
linemap_init (line_table);
line_table->reallocator = realloc_for_line_map;
init_ttree ();
so we can correctly initialize debug output. */
no_backend = lang_hooks.post_options (&main_input_filename);
-#ifdef OVERRIDE_OPTIONS
/* Some machines may reject certain combinations of options. */
- OVERRIDE_OPTIONS;
-#endif
+ targetm.target_option.override ();
/* Avoid any informative notes in the second run of -fcompare-debug. */
if (flag_compare_debug)
}
#ifndef HAVE_prefetch
- if (flag_prefetch_loop_arrays)
+ if (flag_prefetch_loop_arrays > 0)
{
warning (0, "-fprefetch-loop-arrays not supported for this target");
flag_prefetch_loop_arrays = 0;
}
#else
- if (flag_prefetch_loop_arrays && !HAVE_prefetch)
+ if (flag_prefetch_loop_arrays > 0 && !HAVE_prefetch)
{
warning (0, "-fprefetch-loop-arrays not supported for this target (try -march switches)");
flag_prefetch_loop_arrays = 0;
/* This combination of options isn't handled for i386 targets and doesn't
make much sense anyway, so don't allow it. */
- if (flag_prefetch_loop_arrays && optimize_size)
+ if (flag_prefetch_loop_arrays > 0 && optimize_size)
{
warning (0, "-fprefetch-loop-arrays is not supported with -Os");
flag_prefetch_loop_arrays = 0;
init_asm_output (name);
+ /* If stack usage information is desired, open the output file. */
+ if (flag_stack_usage)
+ stack_usage_file = open_auxiliary_file ("su");
+
/* This creates various _DECL nodes, so needs to be called after the
front end is initialized. */
init_eh ();
unlink_if_ordinary (asm_file_name);
}
+ if (stack_usage_file)
+ fclose (stack_usage_file);
+
statistics_fini ();
finish_optimization_passes ();
{
expandargv (&argc, &argv);
- save_argv = CONST_CAST2 (const char **, char **, argv);
-
/* Initialization of GCC's environment, and diagnostics. */
general_init (argv[0]);
/* Parse the options and do minimal processing; basically just
enough to default flags appropriately. */
- decode_options (argc, CONST_CAST2 (const char **, char **, argv));
+ decode_options (argc, CONST_CAST2 (const char **, char **, argv),
+ &save_decoded_options, &save_decoded_options_count);
init_local_tick ();