+
+ if (enabled)
+ handle_generated_option (opts, opts_set, default_opt->opt_index,
+ default_opt->arg, default_opt->value,
+ lang_mask, DK_UNSPECIFIED, loc,
+ handlers, dc);
+ else if (default_opt->arg == NULL
+ && !(option->flags & CL_REJECT_NEGATIVE))
+ handle_generated_option (opts, opts_set, default_opt->opt_index,
+ default_opt->arg, !default_opt->value,
+ lang_mask, DK_UNSPECIFIED, loc,
+ handlers, dc);
+}
+
+/* As indicated by the optimization level LEVEL (-Os if SIZE is set,
+ -Ofast if FAST is set), apply the options in array DEFAULT_OPTS to
+ OPTS and OPTS_SET, diagnostic context DC, location LOC, with
+ language mask LANG_MASK and option handlers HANDLERS. */
+
+static void
+maybe_default_options (struct gcc_options *opts,
+ struct gcc_options *opts_set,
+ const struct default_options *default_opts,
+ int level, bool size, bool fast,
+ unsigned int lang_mask,
+ const struct cl_option_handlers *handlers,
+ location_t loc,
+ diagnostic_context *dc)
+{
+ size_t i;
+
+ for (i = 0; default_opts[i].levels != OPT_LEVELS_NONE; i++)
+ maybe_default_option (opts, opts_set, &default_opts[i],
+ level, size, fast, lang_mask, handlers, loc, dc);
+}
+
+/* Table of options enabled by default at different levels. */
+
+static const struct default_options default_options_table[] =
+ {
+ /* -O1 optimizations. */
+ { OPT_LEVELS_1_PLUS, OPT_fdefer_pop, NULL, 1 },
+#ifdef DELAY_SLOTS
+ { OPT_LEVELS_1_PLUS, OPT_fdelayed_branch, NULL, 1 },
+#endif
+ { OPT_LEVELS_1_PLUS, OPT_fguess_branch_probability, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fcprop_registers, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fforward_propagate, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fif_conversion, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fif_conversion2, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fsplit_wide_types, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_ccp, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_bit_ccp, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_dce, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_dominator_opts, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_dse, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_ter, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_sra, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_copyrename, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_fre, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_copy_prop, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_sink, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_ftree_ch, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fcombine_stack_adjustments, NULL, 1 },
+
+ /* -O2 optimizations. */
+ { OPT_LEVELS_2_PLUS, OPT_finline_small_functions, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_findirect_inlining, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fpartial_inlining, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fthread_jumps, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fcrossjumping, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_foptimize_sibling_calls, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fcse_follow_jumps, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fgcse, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fexpensive_optimizations, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_frerun_cse_after_loop, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fcaller_saves, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fpeephole2, NULL, 1 },
+#ifdef INSN_SCHEDULING
+ /* Only run the pre-regalloc scheduling pass if optimizing for speed. */
+ { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fschedule_insns, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
+#endif
+ { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_ftree_builtin_call_dce, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_ftree_pre, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_ftree_switch_conversion, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fipa_cp, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fipa_sra, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_falign_loops, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_falign_jumps, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_falign_labels, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_falign_functions, NULL, 1 },
+
+ /* -O3 optimizations. */
+ { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
+ /* Inlining of functions reducing size is a good idea with -Os
+ regardless of them being declared inline. */
+ { OPT_LEVELS_3_PLUS_AND_SIZE, OPT_finline_functions, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_funswitch_loops, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_fgcse_after_reload, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_ftree_vectorize, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_fipa_cp_clone, NULL, 1 },
+
+ /* -Ofast adds optimizations to -O3. */
+ { OPT_LEVELS_FAST, OPT_ffast_math, NULL, 1 },
+
+ { OPT_LEVELS_NONE, 0, NULL, 0 }
+ };
+
+/* Default the options in OPTS and OPTS_SET based on the optimization
+ settings in DECODED_OPTIONS and DECODED_OPTIONS_COUNT. */
+static void
+default_options_optimization (struct gcc_options *opts,
+ struct gcc_options *opts_set,
+ struct cl_decoded_option *decoded_options,
+ unsigned int decoded_options_count,
+ location_t loc,
+ unsigned int lang_mask,
+ const struct cl_option_handlers *handlers,
+ diagnostic_context *dc)
+{
+ unsigned int i;
+ int opt2;
+ int ofast = 0;