00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "config.h"
00027 #include "system.h"
00028 #include "intl.h"
00029 #include "coretypes.h"
00030 #include "tm.h"
00031 #include "tree.h"
00032 #include "rtl.h"
00033 #include "ggc.h"
00034 #include "output.h"
00035 #include "langhooks.h"
00036 #include "opts.h"
00037 #include "options.h"
00038 #include "flags.h"
00039 #include "toplev.h"
00040 #include "params.h"
00041 #include "diagnostic.h"
00042 #include "tm_p.h"
00043 #include "insn-attr.h"
00044 #include "target.h"
00045 #include "tree-pass.h"
00046
00047
00048 unsigned HOST_WIDE_INT g_switch_value;
00049 bool g_switch_set;
00050
00051
00052 bool exit_after_options;
00053
00054
00055 bool extra_warnings;
00056
00057
00058
00059
00060 bool warn_larger_than;
00061 HOST_WIDE_INT larger_than_size;
00062
00063
00064
00065 int warn_strict_aliasing;
00066
00067
00068
00069 int warn_strict_overflow;
00070
00071
00072 static bool maybe_warn_unused_parameter;
00073
00074
00075
00076
00077 enum debug_info_type write_symbols = NO_DEBUG;
00078
00079
00080
00081 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
00082
00083
00084
00085
00086 bool use_gnu_debug_info_extensions;
00087
00088
00089 enum symbol_visibility default_visibility = VISIBILITY_DEFAULT;
00090
00091
00092
00093
00094 bool no_unit_at_a_time_default;
00095
00096
00097 struct visibility_flags visibility_options;
00098
00099
00100 static unsigned int columns = 80;
00101
00102
00103 static const char undocumented_msg[] = N_("This switch lacks documentation");
00104
00105
00106
00107 static bool profile_arc_flag_set, flag_profile_values_set;
00108 static bool flag_unroll_loops_set, flag_tracer_set;
00109 static bool flag_value_profile_transformations_set;
00110 static bool flag_peel_loops_set, flag_branch_probabilities_set;
00111
00112
00113 const char **in_fnames;
00114 unsigned num_in_fnames;
00115
00116 static int common_handle_option (size_t scode, const char *arg, int value,
00117 unsigned int lang_mask);
00118 static void handle_param (const char *);
00119 static void set_Wextra (int);
00120 static unsigned int handle_option (const char **argv, unsigned int lang_mask);
00121 static char *write_langs (unsigned int lang_mask);
00122 static void complain_wrong_lang (const char *, const struct cl_option *,
00123 unsigned int lang_mask);
00124 static void handle_options (unsigned int, const char **, unsigned int);
00125 static void wrap_help (const char *help, const char *item, unsigned int);
00126 static void print_target_help (void);
00127 static void print_help (void);
00128 static void print_param_help (void);
00129 static void print_filtered_help (unsigned int);
00130 static unsigned int print_switch (const char *text, unsigned int indent);
00131 static void set_debug_level (enum debug_info_type type, int extended,
00132 const char *arg);
00133
00134
00135
00136 static int
00137 integral_argument (const char *arg)
00138 {
00139 const char *p = arg;
00140
00141 while (*p && ISDIGIT (*p))
00142 p++;
00143
00144 if (*p == '\0')
00145 return atoi (arg);
00146
00147 return -1;
00148 }
00149
00150
00151 static char *
00152 write_langs (unsigned int mask)
00153 {
00154 unsigned int n = 0, len = 0;
00155 const char *lang_name;
00156 char *result;
00157
00158 for (n = 0; (lang_name = lang_names[n]) != 0; n++)
00159 if (mask & (1U << n))
00160 len += strlen (lang_name) + 1;
00161
00162 result = XNEWVEC (char, len);
00163 len = 0;
00164 for (n = 0; (lang_name = lang_names[n]) != 0; n++)
00165 if (mask & (1U << n))
00166 {
00167 if (len)
00168 result[len++] = '/';
00169 strcpy (result + len, lang_name);
00170 len += strlen (lang_name);
00171 }
00172
00173 result[len] = 0;
00174
00175 return result;
00176 }
00177
00178
00179 static void
00180 complain_wrong_lang (const char *text, const struct cl_option *option,
00181 unsigned int lang_mask)
00182 {
00183 char *ok_langs, *bad_lang;
00184
00185 ok_langs = write_langs (option->flags);
00186 bad_lang = write_langs (lang_mask);
00187
00188
00189 warning (0, "command line option \"%s\" is valid for %s but not for %s",
00190 text, ok_langs, bad_lang);
00191
00192 free (ok_langs);
00193 free (bad_lang);
00194 }
00195
00196
00197
00198 static unsigned int
00199 handle_option (const char **argv, unsigned int lang_mask)
00200 {
00201 size_t opt_index;
00202 const char *opt, *arg = 0;
00203 char *dup = 0;
00204 int value = 1;
00205 unsigned int result = 0;
00206 const struct cl_option *option;
00207
00208 opt = argv[0];
00209
00210 opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
00211 if (opt_index == cl_options_count
00212 && (opt[1] == 'W' || opt[1] == 'f' || opt[1] == 'm')
00213 && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
00214 {
00215
00216 size_t len = strlen (opt) - 3;
00217
00218 dup = XNEWVEC (char, len + 1);
00219 dup[0] = '-';
00220 dup[1] = opt[1];
00221 memcpy (dup + 2, opt + 5, len - 2 + 1);
00222 opt = dup;
00223 value = 0;
00224 opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
00225 }
00226
00227 if (opt_index == cl_options_count)
00228 goto done;
00229
00230 option = &cl_options[opt_index];
00231
00232
00233
00234 if (!value && (option->flags & CL_REJECT_NEGATIVE))
00235 goto done;
00236
00237
00238 result = 1;
00239
00240
00241 if (option->flags & CL_DISABLED)
00242 {
00243 error ("command line option %qs"
00244 " is not supported by this configuration", opt);
00245 goto done;
00246 }
00247
00248
00249 if (option->flags & CL_JOINED)
00250 {
00251
00252
00253
00254 arg = argv[0] + cl_options[opt_index].opt_len + 1;
00255 if (!value)
00256 arg += strlen ("no-");
00257
00258 if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
00259 {
00260 if (option->flags & CL_SEPARATE)
00261 {
00262 arg = argv[1];
00263 result = 2;
00264 }
00265 else
00266
00267 arg = NULL;
00268 }
00269 }
00270 else if (option->flags & CL_SEPARATE)
00271 {
00272 arg = argv[1];
00273 result = 2;
00274 }
00275
00276
00277
00278 if (!(option->flags & (lang_mask | CL_COMMON | CL_TARGET)))
00279 {
00280 complain_wrong_lang (argv[0], option, lang_mask);
00281 goto done;
00282 }
00283
00284 if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
00285 {
00286 if (!lang_hooks.missing_argument (opt, opt_index))
00287 error ("missing argument to \"%s\"", opt);
00288 goto done;
00289 }
00290
00291
00292 if (arg && (option->flags & CL_UINTEGER))
00293 {
00294 value = integral_argument (arg);
00295 if (value == -1)
00296 {
00297 error ("argument to \"%s\" should be a non-negative integer",
00298 option->opt_text);
00299 goto done;
00300 }
00301 }
00302
00303 if (option->flag_var)
00304 switch (option->var_type)
00305 {
00306 case CLVC_BOOLEAN:
00307 *(int *) option->flag_var = value;
00308 break;
00309
00310 case CLVC_EQUAL:
00311 *(int *) option->flag_var = (value
00312 ? option->var_value
00313 : !option->var_value);
00314 break;
00315
00316 case CLVC_BIT_CLEAR:
00317 case CLVC_BIT_SET:
00318 if ((value != 0) == (option->var_type == CLVC_BIT_SET))
00319 *(int *) option->flag_var |= option->var_value;
00320 else
00321 *(int *) option->flag_var &= ~option->var_value;
00322 if (option->flag_var == &target_flags)
00323 target_flags_explicit |= option->var_value;
00324 break;
00325
00326 case CLVC_STRING:
00327 *(const char **) option->flag_var = arg;
00328 break;
00329 }
00330
00331 if (option->flags & lang_mask)
00332 if (lang_hooks.handle_option (opt_index, arg, value) == 0)
00333 result = 0;
00334
00335 if (result && (option->flags & CL_COMMON))
00336 if (common_handle_option (opt_index, arg, value, lang_mask) == 0)
00337 result = 0;
00338
00339 if (result && (option->flags & CL_TARGET))
00340 if (!targetm.handle_option (opt_index, arg, value))
00341 result = 0;
00342
00343 done:
00344 if (dup)
00345 free (dup);
00346 return result;
00347 }
00348
00349
00350 static void
00351 add_input_filename (const char *filename)
00352 {
00353 num_in_fnames++;
00354 in_fnames = xrealloc (in_fnames, num_in_fnames * sizeof (in_fnames[0]));
00355 in_fnames[num_in_fnames - 1] = filename;
00356 }
00357
00358
00359
00360
00361 static void
00362 handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
00363 {
00364 unsigned int n, i;
00365
00366 for (i = 1; i < argc; i += n)
00367 {
00368 const char *opt = argv[i];
00369
00370
00371 if (opt[0] != '-' || opt[1] == '\0')
00372 {
00373 if (main_input_filename == NULL)
00374 main_input_filename = opt;
00375 add_input_filename (opt);
00376 n = 1;
00377 continue;
00378 }
00379
00380 n = handle_option (argv + i, lang_mask);
00381
00382 if (!n)
00383 {
00384 n = 1;
00385 error ("unrecognized command line option \"%s\"", opt);
00386 }
00387 }
00388 }
00389
00390
00391
00392 void
00393 decode_options (unsigned int argc, const char **argv)
00394 {
00395 unsigned int i, lang_mask;
00396
00397
00398 lang_mask = lang_hooks.init_options (argc, argv);
00399
00400 lang_hooks.initialize_diagnostics (global_dc);
00401
00402
00403
00404 for (i = 1; i < argc; i++)
00405 {
00406 if (!strcmp (argv[i], "-O"))
00407 {
00408 optimize = 1;
00409 optimize_size = 0;
00410 }
00411 else if (argv[i][0] == '-' && argv[i][1] == 'O')
00412 {
00413
00414 const char *p = &argv[i][2];
00415
00416 if ((p[0] == 's') && (p[1] == 0))
00417 {
00418 optimize_size = 1;
00419
00420
00421 optimize = 2;
00422 }
00423 else
00424 {
00425 const int optimize_val = read_integral_parameter (p, p - 2, -1);
00426 if (optimize_val != -1)
00427 {
00428 optimize = optimize_val;
00429 optimize_size = 0;
00430 }
00431 }
00432 }
00433 }
00434
00435 if (!optimize)
00436 {
00437 flag_merge_constants = 0;
00438 }
00439
00440 if (optimize >= 1)
00441 {
00442 flag_defer_pop = 1;
00443 #ifdef DELAY_SLOTS
00444 flag_delayed_branch = 1;
00445 #endif
00446 #ifdef CAN_DEBUG_WITHOUT_FP
00447 flag_omit_frame_pointer = 1;
00448 #endif
00449 flag_guess_branch_prob = 1;
00450 flag_cprop_registers = 1;
00451 flag_if_conversion = 1;
00452 flag_if_conversion2 = 1;
00453 flag_ipa_pure_const = 1;
00454 flag_ipa_reference = 1;
00455 flag_tree_ccp = 1;
00456 flag_tree_dce = 1;
00457 flag_tree_dom = 1;
00458 flag_tree_dse = 1;
00459 flag_tree_ter = 1;
00460 flag_tree_live_range_split = 1;
00461 flag_tree_sra = 1;
00462 flag_tree_copyrename = 1;
00463 flag_tree_fre = 1;
00464 flag_tree_copy_prop = 1;
00465 flag_tree_sink = 1;
00466 flag_tree_salias = 1;
00467 if (!no_unit_at_a_time_default)
00468 flag_unit_at_a_time = 1;
00469
00470 if (!optimize_size)
00471 {
00472
00473
00474
00475
00476 flag_tree_ch = 1;
00477 }
00478 }
00479
00480 if (optimize >= 2)
00481 {
00482 flag_thread_jumps = 1;
00483 flag_crossjumping = 1;
00484 flag_optimize_sibling_calls = 1;
00485 flag_cse_follow_jumps = 1;
00486 flag_cse_skip_blocks = 1;
00487 flag_gcse = 1;
00488 flag_expensive_optimizations = 1;
00489 flag_ipa_type_escape = 1;
00490 flag_rerun_cse_after_loop = 1;
00491 flag_caller_saves = 1;
00492 flag_peephole2 = 1;
00493 #ifdef INSN_SCHEDULING
00494 flag_schedule_insns = 1;
00495 flag_schedule_insns_after_reload = 1;
00496 #endif
00497 flag_regmove = 1;
00498 flag_strict_aliasing = 1;
00499 flag_strict_overflow = 1;
00500 flag_delete_null_pointer_checks = 1;
00501 flag_reorder_blocks = 1;
00502 flag_reorder_functions = 1;
00503 flag_tree_store_ccp = 1;
00504 flag_tree_store_copy_prop = 1;
00505 flag_tree_vrp = 1;
00506
00507 if (!optimize_size)
00508 {
00509
00510 flag_tree_pre = 1;
00511 }
00512 }
00513
00514 if (optimize >= 3)
00515 {
00516 flag_inline_functions = 1;
00517 flag_unswitch_loops = 1;
00518 flag_gcse_after_reload = 1;
00519 }
00520
00521 if (optimize < 2 || optimize_size)
00522 {
00523 align_loops = 1;
00524 align_jumps = 1;
00525 align_labels = 1;
00526 align_functions = 1;
00527
00528
00529
00530
00531
00532
00533
00534
00535 flag_reorder_blocks = 0;
00536 flag_reorder_blocks_and_partition = 0;
00537 }
00538
00539 if (optimize_size)
00540 {
00541
00542 set_param_value ("max-inline-insns-single", 5);
00543 set_param_value ("max-inline-insns-auto", 5);
00544 flag_inline_functions = 1;
00545
00546
00547 set_param_value ("min-crossjump-insns", 1);
00548 }
00549
00550
00551 flag_signed_char = DEFAULT_SIGNED_CHAR;
00552
00553
00554 flag_short_enums = 2;
00555
00556
00557
00558 target_flags = targetm.default_target_flags;
00559
00560
00561 flag_unwind_tables = targetm.unwind_tables_default;
00562
00563 #ifdef OPTIMIZATION_OPTIONS
00564
00565 OPTIMIZATION_OPTIONS (optimize, optimize_size);
00566 #endif
00567
00568 handle_options (argc, argv, lang_mask);
00569
00570 if (flag_pie)
00571 flag_pic = flag_pie;
00572 if (flag_pic && !flag_pie)
00573 flag_shlib = 1;
00574
00575 if (flag_no_inline == 2)
00576 flag_no_inline = 0;
00577 else
00578 flag_really_no_inline = flag_no_inline;
00579
00580
00581
00582
00583
00584
00585 if (optimize == 0)
00586 {
00587
00588
00589 flag_no_inline = 1;
00590 warn_inline = 0;
00591
00592
00593
00594
00595 if (warn_uninitialized == 1)
00596 warning (OPT_Wuninitialized,
00597 "-Wuninitialized is not supported without -O");
00598 }
00599
00600 if (flag_really_no_inline == 2)
00601 flag_really_no_inline = flag_no_inline;
00602
00603
00604
00605
00606
00607
00608
00609 if (flag_exceptions && flag_reorder_blocks_and_partition)
00610 {
00611 inform
00612 ("-freorder-blocks-and-partition does not work with exceptions");
00613 flag_reorder_blocks_and_partition = 0;
00614 flag_reorder_blocks = 1;
00615 }
00616
00617
00618
00619
00620 if (flag_unwind_tables && ! targetm.unwind_tables_default
00621 && flag_reorder_blocks_and_partition)
00622 {
00623 inform ("-freorder-blocks-and-partition does not support unwind info");
00624 flag_reorder_blocks_and_partition = 0;
00625 flag_reorder_blocks = 1;
00626 }
00627
00628
00629
00630
00631
00632 if (flag_reorder_blocks_and_partition
00633 && (!targetm.have_named_sections
00634 || (flag_unwind_tables && targetm.unwind_tables_default)))
00635 {
00636 inform
00637 ("-freorder-blocks-and-partition does not work on this architecture");
00638 flag_reorder_blocks_and_partition = 0;
00639 flag_reorder_blocks = 1;
00640 }
00641 }
00642
00643
00644
00645
00646
00647
00648 static int
00649 common_handle_option (size_t scode, const char *arg, int value,
00650 unsigned int lang_mask)
00651 {
00652 enum opt_code code = (enum opt_code) scode;
00653
00654 switch (code)
00655 {
00656 case OPT__help:
00657 print_help ();
00658 exit_after_options = true;
00659 break;
00660
00661 case OPT__param:
00662 handle_param (arg);
00663 break;
00664
00665 case OPT__target_help:
00666 print_target_help ();
00667 exit_after_options = true;
00668 break;
00669
00670 case OPT__version:
00671 print_version (stderr, "");
00672 exit_after_options = true;
00673 break;
00674
00675 case OPT_G:
00676 g_switch_value = value;
00677 g_switch_set = true;
00678 break;
00679
00680 case OPT_O:
00681 case OPT_Os:
00682
00683 break;
00684
00685 case OPT_W:
00686
00687 set_Wextra (value);
00688 break;
00689
00690 case OPT_Werror_:
00691 {
00692 char *new_option;
00693 int option_index;
00694 new_option = XNEWVEC (char, strlen (arg) + 2);
00695 new_option[0] = 'W';
00696 strcpy (new_option+1, arg);
00697 option_index = find_opt (new_option, lang_mask);
00698 if (option_index == N_OPTS)
00699 {
00700 error ("-Werror=%s: No option -%s", arg, new_option);
00701 }
00702 else
00703 {
00704 int kind = value ? DK_ERROR : DK_WARNING;
00705 diagnostic_classify_diagnostic (global_dc, option_index, kind);
00706
00707
00708 if (cl_options[option_index].var_type == CLVC_BOOLEAN
00709 && cl_options[option_index].flag_var
00710 && kind == DK_ERROR)
00711 *(int *) cl_options[option_index].flag_var = 1;
00712 free (new_option);
00713 }
00714 }
00715 break;
00716
00717 case OPT_Wextra:
00718 set_Wextra (value);
00719 break;
00720
00721 case OPT_Wlarger_than_:
00722 larger_than_size = value;
00723 warn_larger_than = value != -1;
00724 break;
00725
00726 case OPT_Wstrict_aliasing:
00727 case OPT_Wstrict_aliasing_:
00728 warn_strict_aliasing = value;
00729 break;
00730
00731 case OPT_Wstrict_overflow:
00732 warn_strict_overflow = (value
00733 ? (int) WARN_STRICT_OVERFLOW_CONDITIONAL
00734 : 0);
00735 break;
00736
00737 case OPT_Wstrict_overflow_:
00738 warn_strict_overflow = value;
00739 break;
00740
00741 case OPT_Wunused:
00742 set_Wunused (value);
00743 break;
00744
00745 case OPT_aux_info:
00746 case OPT_aux_info_:
00747 aux_info_file_name = arg;
00748 flag_gen_aux_info = 1;
00749 break;
00750
00751 case OPT_auxbase:
00752 aux_base_name = arg;
00753 break;
00754
00755 case OPT_auxbase_strip:
00756 {
00757 char *tmp = xstrdup (arg);
00758 strip_off_ending (tmp, strlen (tmp));
00759 if (tmp[0])
00760 aux_base_name = tmp;
00761 }
00762 break;
00763
00764 case OPT_d:
00765 decode_d_option (arg);
00766 break;
00767
00768 case OPT_dumpbase:
00769 dump_base_name = arg;
00770 break;
00771
00772 case OPT_falign_functions_:
00773 align_functions = value;
00774 break;
00775
00776 case OPT_falign_jumps_:
00777 align_jumps = value;
00778 break;
00779
00780 case OPT_falign_labels_:
00781 align_labels = value;
00782 break;
00783
00784 case OPT_falign_loops_:
00785 align_loops = value;
00786 break;
00787
00788 case OPT_fbranch_probabilities:
00789 flag_branch_probabilities_set = true;
00790 break;
00791
00792 case OPT_fcall_used_:
00793 fix_register (arg, 0, 1);
00794 break;
00795
00796 case OPT_fcall_saved_:
00797 fix_register (arg, 0, 0);
00798 break;
00799
00800 case OPT_fdiagnostics_show_location_:
00801 if (!strcmp (arg, "once"))
00802 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
00803 else if (!strcmp (arg, "every-line"))
00804 diagnostic_prefixing_rule (global_dc)
00805 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
00806 else
00807 return 0;
00808 break;
00809
00810 case OPT_fdiagnostics_show_option:
00811 global_dc->show_option_requested = true;
00812 break;
00813
00814 case OPT_fdump_:
00815 if (!dump_switch_p (arg))
00816 return 0;
00817 break;
00818
00819 case OPT_ffast_math:
00820 set_fast_math_flags (value);
00821 break;
00822
00823 case OPT_ffixed_:
00824 fix_register (arg, 1, 1);
00825 break;
00826
00827 case OPT_finline_limit_:
00828 case OPT_finline_limit_eq:
00829 set_param_value ("max-inline-insns-single", value / 2);
00830 set_param_value ("max-inline-insns-auto", value / 2);
00831 break;
00832
00833 case OPT_fmessage_length_:
00834 pp_set_line_maximum_length (global_dc->printer, value);
00835 break;
00836
00837 case OPT_fpack_struct_:
00838 if (value <= 0 || (value & (value - 1)) || value > 16)
00839 error("structure alignment must be a small power of two, not %d", value);
00840 else
00841 {
00842 initial_max_fld_align = value;
00843 maximum_field_alignment = value * BITS_PER_UNIT;
00844 }
00845 break;
00846
00847 case OPT_fpeel_loops:
00848 flag_peel_loops_set = true;
00849 break;
00850
00851 case OPT_fprofile_arcs:
00852 profile_arc_flag_set = true;
00853 break;
00854
00855 case OPT_fprofile_use:
00856 if (!flag_branch_probabilities_set)
00857 flag_branch_probabilities = value;
00858 if (!flag_profile_values_set)
00859 flag_profile_values = value;
00860 if (!flag_unroll_loops_set)
00861 flag_unroll_loops = value;
00862 if (!flag_peel_loops_set)
00863 flag_peel_loops = value;
00864 if (!flag_tracer_set)
00865 flag_tracer = value;
00866 if (!flag_value_profile_transformations_set)
00867 flag_value_profile_transformations = value;
00868 break;
00869
00870 case OPT_fprofile_generate:
00871 if (!profile_arc_flag_set)
00872 profile_arc_flag = value;
00873 if (!flag_profile_values_set)
00874 flag_profile_values = value;
00875 if (!flag_value_profile_transformations_set)
00876 flag_value_profile_transformations = value;
00877 break;
00878
00879 case OPT_fprofile_values:
00880 flag_profile_values_set = true;
00881 break;
00882
00883 case OPT_fvisibility_:
00884 {
00885 if (!strcmp(arg, "default"))
00886 default_visibility = VISIBILITY_DEFAULT;
00887 else if (!strcmp(arg, "internal"))
00888 default_visibility = VISIBILITY_INTERNAL;
00889 else if (!strcmp(arg, "hidden"))
00890 default_visibility = VISIBILITY_HIDDEN;
00891 else if (!strcmp(arg, "protected"))
00892 default_visibility = VISIBILITY_PROTECTED;
00893 else
00894 error ("unrecognized visibility value \"%s\"", arg);
00895 }
00896 break;
00897
00898 case OPT_fvpt:
00899 flag_value_profile_transformations_set = true;
00900 break;
00901
00902 case OPT_frandom_seed:
00903
00904 if (value)
00905 return 0;
00906 flag_random_seed = NULL;
00907 break;
00908
00909 case OPT_frandom_seed_:
00910 flag_random_seed = arg;
00911 break;
00912
00913 case OPT_fsched_verbose_:
00914 #ifdef INSN_SCHEDULING
00915 fix_sched_param ("verbose", arg);
00916 break;
00917 #else
00918 return 0;
00919 #endif
00920
00921 case OPT_fsched_stalled_insns_:
00922 flag_sched_stalled_insns = value;
00923 if (flag_sched_stalled_insns == 0)
00924 flag_sched_stalled_insns = -1;
00925 break;
00926
00927 case OPT_fsched_stalled_insns_dep_:
00928 flag_sched_stalled_insns_dep = value;
00929 break;
00930
00931 case OPT_fstack_limit:
00932
00933 if (value)
00934 return 0;
00935 stack_limit_rtx = NULL_RTX;
00936 break;
00937
00938 case OPT_fstack_limit_register_:
00939 {
00940 int reg = decode_reg_name (arg);
00941 if (reg < 0)
00942 error ("unrecognized register name \"%s\"", arg);
00943 else
00944 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
00945 }
00946 break;
00947
00948 case OPT_fstack_limit_symbol_:
00949 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (arg));
00950 break;
00951
00952 case OPT_ftree_vectorizer_verbose_:
00953 vect_set_verbosity_level (arg);
00954 break;
00955
00956 case OPT_ftls_model_:
00957 if (!strcmp (arg, "global-dynamic"))
00958 flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
00959 else if (!strcmp (arg, "local-dynamic"))
00960 flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC;
00961 else if (!strcmp (arg, "initial-exec"))
00962 flag_tls_default = TLS_MODEL_INITIAL_EXEC;
00963 else if (!strcmp (arg, "local-exec"))
00964 flag_tls_default = TLS_MODEL_LOCAL_EXEC;
00965 else
00966 warning (0, "unknown tls-model \"%s\"", arg);
00967 break;
00968
00969 case OPT_ftracer:
00970 flag_tracer_set = true;
00971 break;
00972
00973 case OPT_funroll_loops:
00974 flag_unroll_loops_set = true;
00975 break;
00976
00977 case OPT_g:
00978 set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg);
00979 break;
00980
00981 case OPT_gcoff:
00982 set_debug_level (SDB_DEBUG, false, arg);
00983 break;
00984
00985 case OPT_gdwarf_2:
00986 set_debug_level (DWARF2_DEBUG, false, arg);
00987 break;
00988
00989 case OPT_ggdb:
00990 set_debug_level (NO_DEBUG, 2, arg);
00991 break;
00992
00993 case OPT_gstabs:
00994 case OPT_gstabs_:
00995 set_debug_level (DBX_DEBUG, code == OPT_gstabs_, arg);
00996 break;
00997
00998 case OPT_gvms:
00999 set_debug_level (VMS_DEBUG, false, arg);
01000 break;
01001
01002 case OPT_gxcoff:
01003 case OPT_gxcoff_:
01004 set_debug_level (XCOFF_DEBUG, code == OPT_gxcoff_, arg);
01005 break;
01006
01007 case OPT_o:
01008 asm_file_name = arg;
01009 break;
01010
01011 case OPT_pedantic_errors:
01012 flag_pedantic_errors = pedantic = 1;
01013 break;
01014
01015 case OPT_fforce_mem:
01016 warning (0, "-f[no-]force-mem is nop and option will be removed in 4.3");
01017 break;
01018
01019 case OPT_floop_optimize:
01020 case OPT_frerun_loop_opt:
01021 case OPT_fstrength_reduce:
01022
01023 break;
01024
01025 #ifdef KEY
01026 case OPT_spinfile:
01027 flag_spin_file = 1;
01028 spin_file_name = arg;
01029 break;
01030 #endif
01031
01032 default:
01033
01034
01035 gcc_assert (cl_options[scode].flag_var);
01036 break;
01037 }
01038
01039 return 1;
01040 }
01041
01042
01043 static void
01044 handle_param (const char *carg)
01045 {
01046 char *equal, *arg;
01047 int value;
01048
01049 arg = xstrdup (carg);
01050 equal = strchr (arg, '=');
01051 if (!equal)
01052 error ("%s: --param arguments should be of the form NAME=VALUE", arg);
01053 else
01054 {
01055 value = integral_argument (equal + 1);
01056 if (value == -1)
01057 error ("invalid --param value %qs", equal + 1);
01058 else
01059 {
01060 *equal = '\0';
01061 set_param_value (arg, value);
01062 }
01063 }
01064
01065 free (arg);
01066 }
01067
01068
01069 static void
01070 set_Wextra (int setting)
01071 {
01072 extra_warnings = setting;
01073 warn_unused_value = setting;
01074 warn_unused_parameter = (setting && maybe_warn_unused_parameter);
01075
01076
01077
01078
01079 if (setting == 0)
01080 warn_uninitialized = 0;
01081 else if (warn_uninitialized != 1)
01082 warn_uninitialized = 2;
01083 }
01084
01085
01086 void
01087 set_Wunused (int setting)
01088 {
01089 warn_unused_function = setting;
01090 warn_unused_label = setting;
01091
01092
01093
01094
01095
01096 maybe_warn_unused_parameter = setting;
01097 warn_unused_parameter = (setting && extra_warnings);
01098 warn_unused_variable = setting;
01099 warn_unused_value = setting;
01100 }
01101
01102
01103
01104 void
01105 set_fast_math_flags (int set)
01106 {
01107 flag_trapping_math = !set;
01108 flag_unsafe_math_optimizations = set;
01109 flag_finite_math_only = set;
01110 flag_errno_math = !set;
01111 if (set)
01112 {
01113 flag_signaling_nans = 0;
01114 flag_rounding_math = 0;
01115 flag_cx_limited_range = 1;
01116 }
01117 }
01118
01119
01120 bool
01121 fast_math_flags_set_p (void)
01122 {
01123 return (!flag_trapping_math
01124 && flag_unsafe_math_optimizations
01125 && flag_finite_math_only
01126 && !flag_errno_math);
01127 }
01128
01129
01130
01131 static void
01132 set_debug_level (enum debug_info_type type, int extended, const char *arg)
01133 {
01134 static bool type_explicit;
01135
01136 use_gnu_debug_info_extensions = extended;
01137
01138 if (type == NO_DEBUG)
01139 {
01140 if (write_symbols == NO_DEBUG)
01141 {
01142 write_symbols = PREFERRED_DEBUGGING_TYPE;
01143
01144 if (extended == 2)
01145 {
01146 #ifdef DWARF2_DEBUGGING_INFO
01147 write_symbols = DWARF2_DEBUG;
01148 #elif defined DBX_DEBUGGING_INFO
01149 write_symbols = DBX_DEBUG;
01150 #endif
01151 }
01152
01153 if (write_symbols == NO_DEBUG)
01154 warning (0, "target system does not support debug output");
01155 }
01156 }
01157 else
01158 {
01159
01160 if (type_explicit && write_symbols != NO_DEBUG && type != write_symbols)
01161 error ("debug format \"%s\" conflicts with prior selection",
01162 debug_type_names[type]);
01163 write_symbols = type;
01164 type_explicit = true;
01165 }
01166
01167
01168 if (*arg == '\0')
01169 {
01170 if (!debug_info_level)
01171 debug_info_level = 2;
01172 }
01173 else
01174 {
01175 debug_info_level = integral_argument (arg);
01176 if (debug_info_level == (unsigned int) -1)
01177 error ("unrecognised debug output level \"%s\"", arg);
01178 else if (debug_info_level > 3)
01179 error ("debug output level %s is too high", arg);
01180 }
01181 }
01182
01183
01184 static void
01185 print_target_help (void)
01186 {
01187 unsigned int i;
01188 static bool displayed = false;
01189
01190
01191 if (displayed)
01192 return;
01193
01194 displayed = true;
01195 for (i = 0; i < cl_options_count; i++)
01196 if ((cl_options[i].flags & (CL_TARGET | CL_UNDOCUMENTED)) == CL_TARGET)
01197 {
01198 printf (_("\nTarget specific options:\n"));
01199 print_filtered_help (CL_TARGET);
01200 break;
01201 }
01202 }
01203
01204
01205 static void
01206 print_help (void)
01207 {
01208 size_t i;
01209 const char *p;
01210
01211 GET_ENVIRONMENT (p, "COLUMNS");
01212 if (p)
01213 {
01214 int value = atoi (p);
01215 if (value > 0)
01216 columns = value;
01217 }
01218
01219 puts (_("The following options are language-independent:\n"));
01220
01221 print_filtered_help (CL_COMMON);
01222 print_param_help ();
01223
01224 for (i = 0; lang_names[i]; i++)
01225 {
01226 printf (_("The %s front end recognizes the following options:\n\n"),
01227 lang_names[i]);
01228 print_filtered_help (1U << i);
01229 }
01230 print_target_help ();
01231 }
01232
01233
01234 static void
01235 print_param_help (void)
01236 {
01237 size_t i;
01238
01239 puts (_("The --param option recognizes the following as parameters:\n"));
01240
01241 for (i = 0; i < LAST_PARAM; i++)
01242 {
01243 const char *help = compiler_params[i].help;
01244 const char *param = compiler_params[i].option;
01245
01246 if (help == NULL || *help == '\0')
01247 help = undocumented_msg;
01248
01249
01250 help = _(help);
01251
01252 wrap_help (help, param, strlen (param));
01253 }
01254
01255 putchar ('\n');
01256 }
01257
01258
01259 static void
01260 print_filtered_help (unsigned int flag)
01261 {
01262 unsigned int i, len, filter, indent = 0;
01263 bool duplicates = false;
01264 const char *help, *opt, *tab;
01265 static char *printed;
01266
01267 if (flag == CL_COMMON || flag == CL_TARGET)
01268 {
01269 filter = flag;
01270 if (!printed)
01271 printed = xmalloc (cl_options_count);
01272 memset (printed, 0, cl_options_count);
01273 }
01274 else
01275 {
01276
01277 filter = flag | CL_COMMON;
01278
01279 for (i = 0; i < cl_options_count; i++)
01280 {
01281 if ((cl_options[i].flags & filter) != flag)
01282 continue;
01283
01284
01285 if (cl_options[i].flags & CL_UNDOCUMENTED)
01286 continue;
01287
01288
01289
01290 if (printed[i])
01291 {
01292 duplicates = true;
01293 indent = print_switch (cl_options[i].opt_text, indent);
01294 }
01295 }
01296
01297 if (duplicates)
01298 {
01299 putchar ('\n');
01300 putchar ('\n');
01301 }
01302 }
01303
01304 for (i = 0; i < cl_options_count; i++)
01305 {
01306 if ((cl_options[i].flags & filter) != flag)
01307 continue;
01308
01309
01310 if (cl_options[i].flags & CL_UNDOCUMENTED)
01311 continue;
01312
01313
01314 if (printed[i])
01315 continue;
01316
01317 printed[i] = true;
01318
01319 help = cl_options[i].help;
01320 if (!help)
01321 help = undocumented_msg;
01322
01323
01324 help = _(help);
01325
01326 tab = strchr (help, '\t');
01327 if (tab)
01328 {
01329 len = tab - help;
01330 opt = help;
01331 help = tab + 1;
01332 }
01333 else
01334 {
01335 opt = cl_options[i].opt_text;
01336 len = strlen (opt);
01337 }
01338
01339 wrap_help (help, opt, len);
01340 }
01341
01342 putchar ('\n');
01343 }
01344
01345
01346
01347 static unsigned int
01348 print_switch (const char *text, unsigned int indent)
01349 {
01350 unsigned int len = strlen (text) + 1;
01351
01352 if (indent)
01353 {
01354 putchar (',');
01355 if (indent + len > columns)
01356 {
01357 putchar ('\n');
01358 putchar (' ');
01359 indent = 1;
01360 }
01361 }
01362 else
01363 putchar (' ');
01364
01365 putchar (' ');
01366 fputs (text, stdout);
01367
01368 return indent + len + 1;
01369 }
01370
01371
01372
01373 static void
01374 wrap_help (const char *help, const char *item, unsigned int item_width)
01375 {
01376 unsigned int col_width = 27;
01377 unsigned int remaining, room, len;
01378
01379 remaining = strlen (help);
01380
01381 do
01382 {
01383 room = columns - 3 - MAX (col_width, item_width);
01384 if (room > columns)
01385 room = 0;
01386 len = remaining;
01387
01388 if (room < len)
01389 {
01390 unsigned int i;
01391
01392 for (i = 0; help[i]; i++)
01393 {
01394 if (i >= room && len != remaining)
01395 break;
01396 if (help[i] == ' ')
01397 len = i;
01398 else if ((help[i] == '-' || help[i] == '/')
01399 && help[i + 1] != ' '
01400 && i > 0 && ISALPHA (help[i - 1]))
01401 len = i + 1;
01402 }
01403 }
01404
01405 printf( " %-*.*s %.*s\n", col_width, item_width, item, len, help);
01406 item_width = 0;
01407 while (help[len] == ' ')
01408 len++;
01409 help += len;
01410 remaining -= len;
01411 }
01412 while (remaining);
01413 }
01414
01415
01416
01417
01418 int
01419 option_enabled (int opt_idx)
01420 {
01421 const struct cl_option *option = &(cl_options[opt_idx]);
01422 if (option->flag_var)
01423 switch (option->var_type)
01424 {
01425 case CLVC_BOOLEAN:
01426 return *(int *) option->flag_var != 0;
01427
01428 case CLVC_EQUAL:
01429 return *(int *) option->flag_var == option->var_value;
01430
01431 case CLVC_BIT_CLEAR:
01432 return (*(int *) option->flag_var & option->var_value) == 0;
01433
01434 case CLVC_BIT_SET:
01435 return (*(int *) option->flag_var & option->var_value) != 0;
01436
01437 case CLVC_STRING:
01438 break;
01439 }
01440 return -1;
01441 }
01442
01443
01444
01445
01446 bool
01447 get_option_state (int option, struct cl_option_state *state)
01448 {
01449 if (cl_options[option].flag_var == 0)
01450 return false;
01451
01452 switch (cl_options[option].var_type)
01453 {
01454 case CLVC_BOOLEAN:
01455 case CLVC_EQUAL:
01456 state->data = cl_options[option].flag_var;
01457 state->size = sizeof (int);
01458 break;
01459
01460 case CLVC_BIT_CLEAR:
01461 case CLVC_BIT_SET:
01462 state->ch = option_enabled (option);
01463 state->data = &state->ch;
01464 state->size = 1;
01465 break;
01466
01467 case CLVC_STRING:
01468 state->data = *(const char **) cl_options[option].flag_var;
01469 if (state->data == 0)
01470 state->data = "";
01471 state->size = strlen (state->data) + 1;
01472 break;
01473 }
01474 return true;
01475 }