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
00046
00047 unsigned HOST_WIDE_INT g_switch_value;
00048 bool g_switch_set;
00049
00050
00051 bool exit_after_options;
00052
00053
00054 bool extra_warnings;
00055
00056
00057
00058
00059 bool warn_larger_than;
00060 HOST_WIDE_INT larger_than_size;
00061
00062
00063
00064 int warn_strict_aliasing;
00065
00066
00067 static bool maybe_warn_unused_parameter;
00068
00069
00070
00071
00072 enum debug_info_type write_symbols = NO_DEBUG;
00073
00074
00075
00076 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
00077
00078
00079
00080
00081 bool use_gnu_debug_info_extensions;
00082
00083
00084 enum symbol_visibility default_visibility = VISIBILITY_DEFAULT;
00085
00086
00087 struct visibility_flags visibility_options;
00088
00089
00090 static unsigned int columns = 80;
00091
00092
00093 static const char undocumented_msg[] = N_("This switch lacks documentation");
00094
00095
00096
00097 static bool profile_arc_flag_set, flag_profile_values_set;
00098 static bool flag_unroll_loops_set, flag_tracer_set;
00099 static bool flag_value_profile_transformations_set;
00100 bool flag_speculative_prefetching_set;
00101 static bool flag_peel_loops_set, flag_branch_probabilities_set;
00102
00103
00104 const char **in_fnames;
00105 unsigned num_in_fnames;
00106
00107 static size_t find_opt (const char *, int);
00108 static int common_handle_option (size_t scode, const char *arg, int value);
00109 static void handle_param (const char *);
00110 static void set_Wextra (int);
00111 static unsigned int handle_option (const char **argv, unsigned int lang_mask);
00112 static char *write_langs (unsigned int lang_mask);
00113 static void complain_wrong_lang (const char *, const struct cl_option *,
00114 unsigned int lang_mask);
00115 static void handle_options (unsigned int, const char **, unsigned int);
00116 static void wrap_help (const char *help, const char *item, unsigned int);
00117 static void print_help (void);
00118 static void print_param_help (void);
00119 static void print_filtered_help (unsigned int flag);
00120 static unsigned int print_switch (const char *text, unsigned int indent);
00121 static void set_debug_level (enum debug_info_type type, int extended,
00122 const char *arg);
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 static size_t
00149 find_opt (const char *input, int lang_mask)
00150 {
00151 size_t mn, mx, md, opt_len;
00152 size_t match_wrong_lang;
00153 int comp;
00154
00155 mn = 0;
00156 mx = cl_options_count;
00157
00158
00159
00160 while (mx - mn > 1)
00161 {
00162 md = (mn + mx) / 2;
00163 opt_len = cl_options[md].opt_len;
00164 comp = strncmp (input, cl_options[md].opt_text + 1, opt_len);
00165
00166 if (comp < 0)
00167 mx = md;
00168 else
00169 mn = md;
00170 }
00171
00172
00173
00174 match_wrong_lang = cl_options_count;
00175
00176
00177
00178
00179 do
00180 {
00181 const struct cl_option *opt = &cl_options[mn];
00182
00183
00184
00185 if (!strncmp (input, opt->opt_text + 1, opt->opt_len)
00186 && (input[opt->opt_len] == '\0' || (opt->flags & CL_JOINED)))
00187 {
00188
00189 if (opt->flags & lang_mask)
00190 return mn;
00191
00192
00193
00194 if (match_wrong_lang == cl_options_count)
00195 match_wrong_lang = mn;
00196 }
00197
00198
00199
00200 mn = opt->back_chain;
00201 }
00202 while (mn != cl_options_count);
00203
00204
00205 return match_wrong_lang;
00206 }
00207
00208
00209
00210 static int
00211 integral_argument (const char *arg)
00212 {
00213 const char *p = arg;
00214
00215 while (*p && ISDIGIT (*p))
00216 p++;
00217
00218 if (*p == '\0')
00219 return atoi (arg);
00220
00221 return -1;
00222 }
00223
00224
00225 static char *
00226 write_langs (unsigned int mask)
00227 {
00228 unsigned int n = 0, len = 0;
00229 const char *lang_name;
00230 char *result;
00231
00232 for (n = 0; (lang_name = lang_names[n]) != 0; n++)
00233 if (mask & (1U << n))
00234 len += strlen (lang_name) + 1;
00235
00236 result = xmalloc (len);
00237 len = 0;
00238 for (n = 0; (lang_name = lang_names[n]) != 0; n++)
00239 if (mask & (1U << n))
00240 {
00241 if (len)
00242 result[len++] = '/';
00243 strcpy (result + len, lang_name);
00244 len += strlen (lang_name);
00245 }
00246
00247 result[len] = 0;
00248
00249 return result;
00250 }
00251
00252
00253 static void
00254 complain_wrong_lang (const char *text, const struct cl_option *option,
00255 unsigned int lang_mask)
00256 {
00257 char *ok_langs, *bad_lang;
00258
00259 ok_langs = write_langs (option->flags);
00260 bad_lang = write_langs (lang_mask);
00261
00262
00263 warning ("command line option \"%s\" is valid for %s but not for %s",
00264 text, ok_langs, bad_lang);
00265
00266 free (ok_langs);
00267 free (bad_lang);
00268 }
00269
00270
00271
00272 static unsigned int
00273 handle_option (const char **argv, unsigned int lang_mask)
00274 {
00275 size_t opt_index;
00276 const char *opt, *arg = 0;
00277 char *dup = 0;
00278 int value = 1;
00279 unsigned int result = 0;
00280 const struct cl_option *option;
00281
00282 opt = argv[0];
00283
00284
00285 if ((opt[1] == 'W' || opt[1] == 'f')
00286 && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
00287 {
00288 size_t len = strlen (opt) - 3;
00289
00290 dup = xmalloc (len + 1);
00291 dup[0] = '-';
00292 dup[1] = opt[1];
00293 memcpy (dup + 2, opt + 5, len - 2 + 1);
00294 opt = dup;
00295 value = 0;
00296 }
00297
00298 opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
00299 if (opt_index == cl_options_count)
00300 goto done;
00301
00302 option = &cl_options[opt_index];
00303
00304
00305
00306 if (!value && (option->flags & CL_REJECT_NEGATIVE))
00307 goto done;
00308
00309
00310 result = 1;
00311
00312
00313 if (option->flags & CL_JOINED)
00314 {
00315
00316
00317
00318 arg = argv[0] + cl_options[opt_index].opt_len + 1;
00319 if (!value)
00320 arg += strlen ("no-");
00321
00322 if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
00323 {
00324 if (option->flags & CL_SEPARATE)
00325 {
00326 arg = argv[1];
00327 result = 2;
00328 }
00329 else
00330
00331 arg = NULL;
00332 }
00333 }
00334 else if (option->flags & CL_SEPARATE)
00335 {
00336 arg = argv[1];
00337 result = 2;
00338 }
00339
00340
00341
00342 if (!(option->flags & (lang_mask | CL_COMMON)))
00343 {
00344 complain_wrong_lang (argv[0], option, lang_mask);
00345 goto done;
00346 }
00347
00348 if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
00349 {
00350 if (!lang_hooks.missing_argument (opt, opt_index))
00351 error ("missing argument to \"%s\"", opt);
00352 goto done;
00353 }
00354
00355
00356 if (arg && (option->flags & CL_UINTEGER))
00357 {
00358 value = integral_argument (arg);
00359 if (value == -1)
00360 {
00361 error ("argument to \"%s\" should be a non-negative integer",
00362 option->opt_text);
00363 goto done;
00364 }
00365 }
00366
00367 if (option->flag_var)
00368 {
00369 if (option->has_set_value)
00370 {
00371 if (value)
00372 *option->flag_var = option->set_value;
00373 else
00374 *option->flag_var = !option->set_value;
00375 }
00376 else
00377 *option->flag_var = value;
00378 }
00379
00380 if (option->flags & lang_mask)
00381 if (lang_hooks.handle_option (opt_index, arg, value) == 0)
00382 result = 0;
00383
00384 if (result && (option->flags & CL_COMMON))
00385 if (common_handle_option (opt_index, arg, value) == 0)
00386 result = 0;
00387
00388 done:
00389 if (dup)
00390 free (dup);
00391 return result;
00392 }
00393
00394
00395 static void
00396 add_input_filename (const char *filename)
00397 {
00398 num_in_fnames++;
00399 in_fnames = xrealloc (in_fnames, num_in_fnames * sizeof (in_fnames[0]));
00400 in_fnames[num_in_fnames - 1] = filename;
00401 }
00402
00403
00404
00405
00406 static void
00407 handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
00408 {
00409 unsigned int n, i;
00410
00411 for (i = 1; i < argc; i += n)
00412 {
00413 const char *opt = argv[i];
00414
00415
00416 if (opt[0] != '-' || opt[1] == '\0')
00417 {
00418 if (main_input_filename == NULL)
00419 main_input_filename = opt;
00420 add_input_filename (opt);
00421 n = 1;
00422 continue;
00423 }
00424
00425 n = handle_option (argv + i, lang_mask);
00426
00427 if (!n)
00428 {
00429 n = 1;
00430 error ("unrecognized command line option \"%s\"", opt);
00431 }
00432 }
00433 }
00434
00435
00436
00437 void
00438 decode_options (unsigned int argc, const char **argv)
00439 {
00440 unsigned int i, lang_mask;
00441
00442
00443 lang_mask = lang_hooks.init_options (argc, argv);
00444
00445 lang_hooks.initialize_diagnostics (global_dc);
00446
00447
00448
00449 for (i = 1; i < argc; i++)
00450 {
00451 if (!strcmp (argv[i], "-O"))
00452 {
00453 optimize = 1;
00454 optimize_size = 0;
00455 }
00456 else if (argv[i][0] == '-' && argv[i][1] == 'O')
00457 {
00458
00459 const char *p = &argv[i][2];
00460
00461 if ((p[0] == 's') && (p[1] == 0))
00462 {
00463 optimize_size = 1;
00464
00465
00466 optimize = 2;
00467 }
00468 else
00469 {
00470 const int optimize_val = read_integral_parameter (p, p - 2, -1);
00471 if (optimize_val != -1)
00472 {
00473 optimize = optimize_val;
00474 optimize_size = 0;
00475 }
00476 }
00477 }
00478 }
00479
00480 if (!optimize)
00481 {
00482 flag_merge_constants = 0;
00483 }
00484
00485 if (optimize >= 1)
00486 {
00487 flag_defer_pop = 1;
00488 #ifdef DELAY_SLOTS
00489 flag_delayed_branch = 1;
00490 #endif
00491 #ifdef CAN_DEBUG_WITHOUT_FP
00492 flag_omit_frame_pointer = 1;
00493 #endif
00494 flag_guess_branch_prob = 1;
00495 flag_cprop_registers = 1;
00496 flag_loop_optimize = 1;
00497 flag_if_conversion = 1;
00498 flag_if_conversion2 = 1;
00499 flag_tree_ccp = 1;
00500 flag_tree_dce = 1;
00501 flag_tree_dom = 1;
00502 flag_tree_dse = 1;
00503 flag_tree_ter = 1;
00504 flag_tree_live_range_split = 1;
00505 flag_tree_sra = 1;
00506 flag_tree_copyrename = 1;
00507 flag_tree_fre = 1;
00508
00509 if (!optimize_size)
00510 {
00511
00512
00513
00514
00515 flag_tree_ch = 1;
00516 }
00517 }
00518
00519 if (optimize >= 2)
00520 {
00521 flag_thread_jumps = 1;
00522 flag_crossjumping = 1;
00523 flag_optimize_sibling_calls = 1;
00524 flag_cse_follow_jumps = 1;
00525 flag_cse_skip_blocks = 1;
00526 flag_gcse = 1;
00527 flag_expensive_optimizations = 1;
00528 flag_strength_reduce = 1;
00529 flag_rerun_cse_after_loop = 1;
00530 flag_rerun_loop_opt = 1;
00531 flag_caller_saves = 1;
00532 flag_force_mem = 1;
00533 flag_peephole2 = 1;
00534 #ifdef INSN_SCHEDULING
00535 flag_schedule_insns = 1;
00536 flag_schedule_insns_after_reload = 1;
00537 #endif
00538 flag_regmove = 1;
00539 flag_strict_aliasing = 1;
00540 flag_delete_null_pointer_checks = 1;
00541 flag_reorder_blocks = 1;
00542 flag_reorder_functions = 1;
00543 flag_unit_at_a_time = 1;
00544
00545 if (!optimize_size)
00546 {
00547
00548 flag_tree_pre = 1;
00549 }
00550 }
00551
00552 if (optimize >= 3)
00553 {
00554 flag_inline_functions = 1;
00555 flag_unswitch_loops = 1;
00556 flag_gcse_after_reload = 1;
00557 }
00558
00559 if (optimize < 2 || optimize_size)
00560 {
00561 align_loops = 1;
00562 align_jumps = 1;
00563 align_labels = 1;
00564 align_functions = 1;
00565
00566
00567
00568
00569
00570
00571
00572
00573 flag_reorder_blocks = 0;
00574 flag_reorder_blocks_and_partition = 0;
00575 }
00576
00577 if (optimize_size)
00578 {
00579
00580 set_param_value ("max-inline-insns-single", 5);
00581 set_param_value ("max-inline-insns-auto", 5);
00582 flag_inline_functions = 1;
00583
00584
00585 set_param_value ("min-crossjump-insns", 1);
00586 }
00587
00588
00589 flag_signed_char = DEFAULT_SIGNED_CHAR;
00590
00591
00592 flag_short_enums = 2;
00593
00594
00595
00596 target_flags = 0;
00597 set_target_switch ("");
00598
00599
00600
00601 #ifdef TARGET_UNWIND_INFO
00602 flag_unwind_tables = TARGET_UNWIND_INFO;
00603 #endif
00604
00605 #ifdef OPTIMIZATION_OPTIONS
00606
00607 OPTIMIZATION_OPTIONS (optimize, optimize_size);
00608 #endif
00609
00610 handle_options (argc, argv, lang_mask);
00611
00612 if (flag_pie)
00613 flag_pic = flag_pie;
00614 if (flag_pic && !flag_pie)
00615 flag_shlib = 1;
00616
00617 if (flag_no_inline == 2)
00618 flag_no_inline = 0;
00619 else
00620 flag_really_no_inline = flag_no_inline;
00621
00622
00623
00624
00625
00626
00627 if (optimize == 0)
00628 {
00629
00630
00631 flag_no_inline = 1;
00632 warn_inline = 0;
00633
00634
00635
00636
00637 if (warn_uninitialized == 1)
00638 warning ("-Wuninitialized is not supported without -O");
00639 }
00640
00641 if (flag_really_no_inline == 2)
00642 flag_really_no_inline = flag_no_inline;
00643
00644
00645
00646
00647
00648
00649 if (flag_exceptions && flag_reorder_blocks_and_partition)
00650 {
00651 warning
00652 ("-freorder-blocks-and-partition does not work with exceptions");
00653 flag_reorder_blocks_and_partition = 0;
00654 flag_reorder_blocks = 1;
00655 }
00656
00657
00658
00659
00660
00661
00662 if (flag_reorder_blocks_and_partition && write_symbols == DWARF2_DEBUG)
00663 {
00664 warning
00665 ("-freorder-blocks-and-partition does not work with -g (currently)");
00666 flag_reorder_blocks_and_partition = 0;
00667 flag_reorder_blocks = 1;
00668 }
00669 }
00670
00671
00672
00673
00674
00675
00676 static int
00677 common_handle_option (size_t scode, const char *arg, int value)
00678 {
00679 enum opt_code code = (enum opt_code) scode;
00680
00681 switch (code)
00682 {
00683 case OPT__help:
00684 print_help ();
00685 exit_after_options = true;
00686 break;
00687
00688 case OPT__param:
00689 handle_param (arg);
00690 break;
00691
00692 case OPT__target_help:
00693 display_target_options ();
00694 exit_after_options = true;
00695 break;
00696
00697 case OPT__version:
00698 print_version (stderr, "");
00699 exit_after_options = true;
00700 break;
00701
00702 case OPT_G:
00703 g_switch_value = value;
00704 g_switch_set = true;
00705 break;
00706
00707 case OPT_O:
00708 case OPT_Os:
00709
00710 break;
00711
00712 case OPT_W:
00713
00714 set_Wextra (value);
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_Wunused:
00732 set_Wunused (value);
00733 break;
00734
00735 case OPT_aux_info:
00736 case OPT_aux_info_:
00737 aux_info_file_name = arg;
00738 flag_gen_aux_info = 1;
00739 break;
00740
00741 case OPT_auxbase:
00742 aux_base_name = arg;
00743 break;
00744
00745 case OPT_auxbase_strip:
00746 {
00747 char *tmp = xstrdup (arg);
00748 strip_off_ending (tmp, strlen (tmp));
00749 if (tmp[0])
00750 aux_base_name = tmp;
00751 }
00752 break;
00753
00754 case OPT_d:
00755 decode_d_option (arg);
00756 break;
00757
00758 case OPT_dumpbase:
00759 dump_base_name = arg;
00760 break;
00761
00762 case OPT_falign_functions_:
00763 align_functions = value;
00764 break;
00765
00766 case OPT_falign_jumps_:
00767 align_jumps = value;
00768 break;
00769
00770 case OPT_falign_labels_:
00771 align_labels = value;
00772 break;
00773
00774 case OPT_falign_loops_:
00775 align_loops = value;
00776 break;
00777
00778 case OPT_fbranch_probabilities:
00779 flag_branch_probabilities_set = true;
00780 break;
00781
00782 case OPT_fcall_used_:
00783 fix_register (arg, 0, 1);
00784 break;
00785
00786 case OPT_fcall_saved_:
00787 fix_register (arg, 0, 0);
00788 break;
00789
00790 case OPT_fdiagnostics_show_location_:
00791 if (!strcmp (arg, "once"))
00792 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
00793 else if (!strcmp (arg, "every-line"))
00794 diagnostic_prefixing_rule (global_dc)
00795 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
00796 else
00797 return 0;
00798 break;
00799
00800 case OPT_fdump_:
00801 if (!dump_switch_p (arg))
00802 return 0;
00803 break;
00804
00805 case OPT_ffast_math:
00806 set_fast_math_flags (value);
00807 break;
00808
00809 case OPT_ffixed_:
00810 fix_register (arg, 1, 1);
00811 break;
00812
00813 case OPT_finline_limit_:
00814 case OPT_finline_limit_eq:
00815 set_param_value ("max-inline-insns-single", value / 2);
00816 set_param_value ("max-inline-insns-auto", value / 2);
00817 break;
00818
00819 case OPT_fmessage_length_:
00820 pp_set_line_maximum_length (global_dc->printer, value);
00821 break;
00822
00823 case OPT_fpack_struct_:
00824 if (value <= 0 || (value & (value - 1)) || value > 16)
00825 error("structure alignment must be a small power of two, not %d", value);
00826 else
00827 {
00828 initial_max_fld_align = value;
00829 maximum_field_alignment = value * BITS_PER_UNIT;
00830 }
00831 break;
00832
00833 case OPT_fpeel_loops:
00834 flag_peel_loops_set = true;
00835 break;
00836
00837 case OPT_fprofile_arcs:
00838 profile_arc_flag_set = true;
00839 break;
00840
00841 case OPT_fprofile_use:
00842 if (!flag_branch_probabilities_set)
00843 flag_branch_probabilities = value;
00844 if (!flag_profile_values_set)
00845 flag_profile_values = value;
00846 if (!flag_unroll_loops_set)
00847 flag_unroll_loops = value;
00848 if (!flag_peel_loops_set)
00849 flag_peel_loops = value;
00850 if (!flag_tracer_set)
00851 flag_tracer = value;
00852 if (!flag_value_profile_transformations_set)
00853 flag_value_profile_transformations = value;
00854 #ifdef HAVE_prefetch
00855 if (0 && !flag_speculative_prefetching_set)
00856 flag_speculative_prefetching = value;
00857 #endif
00858 break;
00859
00860 case OPT_fprofile_generate:
00861 if (!profile_arc_flag_set)
00862 profile_arc_flag = value;
00863 if (!flag_profile_values_set)
00864 flag_profile_values = value;
00865 if (!flag_value_profile_transformations_set)
00866 flag_value_profile_transformations = value;
00867 if (!flag_unroll_loops_set)
00868 flag_unroll_loops = value;
00869 #ifdef HAVE_prefetch
00870 if (0 && !flag_speculative_prefetching_set)
00871 flag_speculative_prefetching = value;
00872 #endif
00873 break;
00874
00875 case OPT_fprofile_values:
00876 flag_profile_values_set = true;
00877 break;
00878
00879 case OPT_fvisibility_:
00880 {
00881 if (!strcmp(arg, "default"))
00882 default_visibility = VISIBILITY_DEFAULT;
00883 else if (!strcmp(arg, "internal"))
00884 default_visibility = VISIBILITY_INTERNAL;
00885 else if (!strcmp(arg, "hidden"))
00886 default_visibility = VISIBILITY_HIDDEN;
00887 else if (!strcmp(arg, "protected"))
00888 default_visibility = VISIBILITY_PROTECTED;
00889 else
00890 error ("unrecognised visibility value \"%s\"", arg);
00891 }
00892 break;
00893
00894 case OPT_fvpt:
00895 flag_value_profile_transformations_set = true;
00896 break;
00897
00898 case OPT_fspeculative_prefetching:
00899 flag_speculative_prefetching_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 ("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_m:
01008 set_target_switch (arg);
01009 break;
01010
01011 case OPT_o:
01012 asm_file_name = arg;
01013 break;
01014
01015 case OPT_pedantic_errors:
01016 flag_pedantic_errors = pedantic = 1;
01017 break;
01018
01019 #ifdef KEY
01020 case OPT_spinfile:
01021 flag_spin_file = 1;
01022 spin_file_name = arg;
01023 break;
01024 #endif
01025
01026 default:
01027
01028
01029 if (cl_options[scode].flag_var)
01030 break;
01031
01032 abort ();
01033 }
01034
01035 return 1;
01036 }
01037
01038
01039 static void
01040 handle_param (const char *carg)
01041 {
01042 char *equal, *arg;
01043 int value;
01044
01045 arg = xstrdup (carg);
01046 equal = strchr (arg, '=');
01047 if (!equal)
01048 error ("%s: --param arguments should be of the form NAME=VALUE", arg);
01049 else
01050 {
01051 value = integral_argument (equal + 1);
01052 if (value == -1)
01053 error ("invalid --param value %qs", equal + 1);
01054 else
01055 {
01056 *equal = '\0';
01057 set_param_value (arg, value);
01058 }
01059 }
01060
01061 free (arg);
01062 }
01063
01064
01065 static void
01066 set_Wextra (int setting)
01067 {
01068 extra_warnings = setting;
01069 warn_unused_value = setting;
01070 warn_unused_parameter = (setting && maybe_warn_unused_parameter);
01071
01072
01073
01074
01075 if (setting == 0)
01076 warn_uninitialized = 0;
01077 else if (warn_uninitialized != 1)
01078 warn_uninitialized = 2;
01079 }
01080
01081
01082 void
01083 set_Wunused (int setting)
01084 {
01085 warn_unused_function = setting;
01086 warn_unused_label = setting;
01087
01088
01089
01090
01091
01092 maybe_warn_unused_parameter = setting;
01093 warn_unused_parameter = (setting && extra_warnings);
01094 warn_unused_variable = setting;
01095 warn_unused_value = setting;
01096 }
01097
01098
01099
01100 void
01101 set_fast_math_flags (int set)
01102 {
01103 flag_trapping_math = !set;
01104 flag_unsafe_math_optimizations = set;
01105 flag_finite_math_only = set;
01106 flag_errno_math = !set;
01107 if (set)
01108 {
01109 flag_signaling_nans = 0;
01110 flag_rounding_math = 0;
01111 flag_cx_limited_range = 1;
01112 }
01113 }
01114
01115
01116 bool
01117 fast_math_flags_set_p (void)
01118 {
01119 return (!flag_trapping_math
01120 && flag_unsafe_math_optimizations
01121 && flag_finite_math_only
01122 && !flag_errno_math);
01123 }
01124
01125
01126
01127 static void
01128 set_debug_level (enum debug_info_type type, int extended, const char *arg)
01129 {
01130 static bool type_explicit;
01131
01132 use_gnu_debug_info_extensions = extended;
01133
01134 if (type == NO_DEBUG)
01135 {
01136 if (write_symbols == NO_DEBUG)
01137 {
01138 write_symbols = PREFERRED_DEBUGGING_TYPE;
01139
01140 if (extended == 2)
01141 {
01142 #ifdef DWARF2_DEBUGGING_INFO
01143 write_symbols = DWARF2_DEBUG;
01144 #elif defined DBX_DEBUGGING_INFO
01145 write_symbols = DBX_DEBUG;
01146 #endif
01147 }
01148
01149 if (write_symbols == NO_DEBUG)
01150 warning ("target system does not support debug output");
01151 }
01152 }
01153 else
01154 {
01155
01156 if (type_explicit && write_symbols != NO_DEBUG && type != write_symbols)
01157 error ("debug format \"%s\" conflicts with prior selection",
01158 debug_type_names[type]);
01159 write_symbols = type;
01160 type_explicit = true;
01161 }
01162
01163
01164 if (*arg == '\0')
01165 {
01166 if (!debug_info_level)
01167 debug_info_level = 2;
01168 }
01169 else
01170 {
01171 debug_info_level = integral_argument (arg);
01172 if (debug_info_level == (unsigned int) -1)
01173 error ("unrecognised debug output level \"%s\"", arg);
01174 else if (debug_info_level > 3)
01175 error ("debug output level %s is too high", arg);
01176 }
01177 }
01178
01179
01180 static void
01181 print_help (void)
01182 {
01183 size_t i;
01184 const char *p;
01185
01186 GET_ENVIRONMENT (p, "COLUMNS");
01187 if (p)
01188 {
01189 int value = atoi (p);
01190 if (value > 0)
01191 columns = value;
01192 }
01193
01194 puts (_("The following options are language-independent:\n"));
01195
01196 print_filtered_help (CL_COMMON);
01197 print_param_help ();
01198
01199 for (i = 0; lang_names[i]; i++)
01200 {
01201 printf (_("The %s front end recognizes the following options:\n\n"),
01202 lang_names[i]);
01203 print_filtered_help (1U << i);
01204 }
01205
01206 display_target_options ();
01207 }
01208
01209
01210 static void
01211 print_param_help (void)
01212 {
01213 size_t i;
01214
01215 puts (_("The --param option recognizes the following as parameters:\n"));
01216
01217 for (i = 0; i < LAST_PARAM; i++)
01218 {
01219 const char *help = compiler_params[i].help;
01220 const char *param = compiler_params[i].option;
01221
01222 if (help == NULL || *help == '\0')
01223 help = undocumented_msg;
01224
01225
01226 help = _(help);
01227
01228 wrap_help (help, param, strlen (param));
01229 }
01230
01231 putchar ('\n');
01232 }
01233
01234
01235 static void
01236 print_filtered_help (unsigned int flag)
01237 {
01238 unsigned int i, len, filter, indent = 0;
01239 bool duplicates = false;
01240 const char *help, *opt, *tab;
01241 static char *printed;
01242
01243 if (flag == CL_COMMON)
01244 {
01245 filter = flag;
01246 if (!printed)
01247 printed = xmalloc (cl_options_count);
01248 memset (printed, 0, cl_options_count);
01249 }
01250 else
01251 {
01252
01253 filter = flag | CL_COMMON;
01254
01255 for (i = 0; i < cl_options_count; i++)
01256 {
01257 if ((cl_options[i].flags & filter) != flag)
01258 continue;
01259
01260
01261 if (cl_options[i].flags & CL_UNDOCUMENTED)
01262 continue;
01263
01264
01265
01266 if (printed[i])
01267 {
01268 duplicates = true;
01269 indent = print_switch (cl_options[i].opt_text, indent);
01270 }
01271 }
01272
01273 if (duplicates)
01274 {
01275 putchar ('\n');
01276 putchar ('\n');
01277 }
01278 }
01279
01280 for (i = 0; i < cl_options_count; i++)
01281 {
01282 if ((cl_options[i].flags & filter) != flag)
01283 continue;
01284
01285
01286 if (cl_options[i].flags & CL_UNDOCUMENTED)
01287 continue;
01288
01289
01290 if (printed[i])
01291 continue;
01292
01293 printed[i] = true;
01294
01295 help = cl_options[i].help;
01296 if (!help)
01297 help = undocumented_msg;
01298
01299
01300 help = _(help);
01301
01302 tab = strchr (help, '\t');
01303 if (tab)
01304 {
01305 len = tab - help;
01306 opt = help;
01307 help = tab + 1;
01308 }
01309 else
01310 {
01311 opt = cl_options[i].opt_text;
01312 len = strlen (opt);
01313 }
01314
01315 wrap_help (help, opt, len);
01316 }
01317
01318 putchar ('\n');
01319 }
01320
01321
01322
01323 static unsigned int
01324 print_switch (const char *text, unsigned int indent)
01325 {
01326 unsigned int len = strlen (text) + 1;
01327
01328 if (indent)
01329 {
01330 putchar (',');
01331 if (indent + len > columns)
01332 {
01333 putchar ('\n');
01334 putchar (' ');
01335 indent = 1;
01336 }
01337 }
01338 else
01339 putchar (' ');
01340
01341 putchar (' ');
01342 fputs (text, stdout);
01343
01344 return indent + len + 1;
01345 }
01346
01347
01348
01349 static void
01350 wrap_help (const char *help, const char *item, unsigned int item_width)
01351 {
01352 unsigned int col_width = 27;
01353 unsigned int remaining, room, len;
01354
01355 remaining = strlen (help);
01356
01357 do
01358 {
01359 room = columns - 3 - MAX (col_width, item_width);
01360 if (room > columns)
01361 room = 0;
01362 len = remaining;
01363
01364 if (room < len)
01365 {
01366 unsigned int i;
01367
01368 for (i = 0; help[i]; i++)
01369 {
01370 if (i >= room && len != remaining)
01371 break;
01372 if (help[i] == ' ')
01373 len = i;
01374 else if ((help[i] == '-' || help[i] == '/')
01375 && help[i + 1] != ' '
01376 && i > 0 && ISALPHA (help[i - 1]))
01377 len = i + 1;
01378 }
01379 }
01380
01381 printf( " %-*.*s %.*s\n", col_width, item_width, item, len, help);
01382 item_width = 0;
01383 while (help[len] == ' ')
01384 len++;
01385 help += len;
01386 remaining -= len;
01387 }
01388 while (remaining);
01389 }