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 #include <unistd.h>
00026
00027
00028
00029
00030
00031 #include "config.h"
00032 #undef FLOAT
00033 #undef FFS
00034 #include "system.h"
00035 #include "coretypes.h"
00036 #include "tm.h"
00037 #include <signal.h>
00038
00039 #ifdef HAVE_SYS_RESOURCE_H
00040 # include <sys/resource.h>
00041 #endif
00042
00043 #ifdef HAVE_SYS_TIMES_H
00044 # include <sys/times.h>
00045 #endif
00046
00047 #include "line-map.h"
00048 #include "input.h"
00049 #include "tree.h"
00050 #include "version.h"
00051 #include "rtl.h"
00052 #include "tm_p.h"
00053 #include "flags.h"
00054 #include "insn-attr.h"
00055 #include "insn-config.h"
00056 #include "insn-flags.h"
00057 #include "hard-reg-set.h"
00058 #include "recog.h"
00059 #include "output.h"
00060 #include "except.h"
00061 #include "function.h"
00062 #include "toplev.h"
00063 #include "expr.h"
00064 #include "basic-block.h"
00065 #include "intl.h"
00066 #include "ggc.h"
00067 #include "graph.h"
00068 #include "regs.h"
00069 #include "timevar.h"
00070 #include "diagnostic.h"
00071 #include "params.h"
00072 #include "reload.h"
00073 #include "dwarf2asm.h"
00074 #include "integrate.h"
00075 #include "real.h"
00076 #include "debug.h"
00077 #include "target.h"
00078 #include "langhooks.h"
00079 #include "cfglayout.h"
00080 #include "cfgloop.h"
00081 #include "hosthooks.h"
00082 #include "cgraph.h"
00083 #include "opts.h"
00084 #include "coverage.h"
00085 #include "value-prof.h"
00086 #include "alloc-pool.h"
00087 #include "tree-mudflap.h"
00088
00089 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
00090 #include "dwarf2out.h"
00091 #endif
00092
00093 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
00094 #include "dbxout.h"
00095 #endif
00096
00097 #ifdef SDB_DEBUGGING_INFO
00098 #include "sdbout.h"
00099 #endif
00100
00101 #ifdef XCOFF_DEBUGGING_INFO
00102 #include "xcoffout.h"
00103
00104 #endif
00105
00106 #ifdef KEY
00107 #define RC_GCC_INTERNAL_ERROR 34
00108 extern void gspin_init (void);
00109 extern void gspin_init_global_trees_list (void);
00110 extern void gspin (tree t);
00111 #endif
00112
00113 static void general_init (const char *);
00114 static void do_compile (void);
00115 static void process_options (void);
00116 static void backend_init (void);
00117 static int lang_dependent_init (const char *);
00118 static void init_asm_output (const char *);
00119 static void finalize (void);
00120
00121 static void crash_signal (int) ATTRIBUTE_NORETURN;
00122 static void setup_core_dumping (void);
00123 static void compile_file (void);
00124
00125 static int print_single_switch (FILE *, int, int, const char *,
00126 const char *, const char *,
00127 const char *, const char *);
00128 static void print_switch_values (FILE *, int, int, const char *,
00129 const char *, const char *);
00130
00131 #ifdef TARG_SL
00132
00133 bool Long_Long_Support = FALSE;
00134
00135
00136 bool Float_Point_Support = FALSE;
00137 #endif
00138
00139
00140 static int set_yydebug;
00141
00142
00143 static bool no_backend;
00144
00145
00146 #define MAX_LINE 75
00147
00148
00149
00150 const char *progname;
00151
00152
00153 static const char **save_argv;
00154
00155
00156
00157
00158
00159 const char *main_input_filename;
00160
00161 #ifndef USE_MAPPED_LOCATION
00162 location_t unknown_location = { NULL, 0 };
00163 #endif
00164
00165
00166
00167 #define AUTODETECT_FLAG_VAR_TRACKING 2
00168
00169
00170
00171 location_t input_location;
00172
00173 struct line_maps line_table;
00174
00175
00176 int no_new_pseudos;
00177
00178
00179
00180 struct file_stack *input_file_stack;
00181
00182
00183 int input_file_stack_tick;
00184
00185
00186
00187 const char *dump_base_name;
00188
00189
00190
00191 const char *aux_base_name;
00192
00193
00194
00195
00196
00197 extern int target_flags;
00198
00199
00200
00201
00202 int target_flags_explicit;
00203
00204
00205
00206 const struct gcc_debug_hooks *debug_hooks;
00207
00208
00209
00210 static const struct gcc_debug_hooks *default_debug_hooks;
00211
00212
00213
00214 int rtl_dump_and_exit;
00215 int flag_print_asm_name;
00216 enum graph_dump_types graph_dump_format;
00217
00218
00219
00220 const char *asm_file_name;
00221
00222 #ifdef KEY
00223
00224 const char *spin_file_name;
00225
00226 int flag_spin_file;
00227 #endif
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 int optimize = 0;
00238
00239
00240
00241
00242
00243
00244 int optimize_size = 0;
00245
00246
00247
00248 tree current_function_decl;
00249
00250
00251
00252 const char * current_function_func_begin_label;
00253
00254
00255
00256
00257 int in_system_header = 0;
00258
00259
00260
00261 int flag_detailed_statistics = 0;
00262
00263
00264 const char *flag_random_seed;
00265
00266
00267
00268
00269 unsigned local_tick;
00270
00271
00272
00273
00274
00275 int flag_signed_char;
00276
00277
00278
00279
00280 int flag_short_enums;
00281
00282
00283
00284
00285
00286
00287 #ifndef DEFAULT_PCC_STRUCT_RETURN
00288 #define DEFAULT_PCC_STRUCT_RETURN 1
00289 #endif
00290
00291
00292
00293 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
00294
00295
00296
00297
00298
00299 int flag_complex_method = 1;
00300
00301
00302
00303
00304 int flag_really_no_inline = 2;
00305
00306
00307
00308 int flag_gen_aux_info = 0;
00309
00310
00311
00312 const char *aux_info_file_name;
00313
00314
00315
00316
00317 int flag_shlib;
00318
00319
00320
00321 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
00322
00323
00324
00325
00326 int flag_pedantic_errors = 0;
00327
00328
00329
00330
00331
00332
00333
00334
00335 int flag_debug_asm = 0;
00336
00337
00338
00339 int flag_dump_rtl_in_asm = 0;
00340
00341
00342
00343
00344
00345
00346
00347
00348 rtx stack_limit_rtx;
00349
00350
00351
00352
00353 int flag_renumber_insns = 1;
00354
00355
00356
00357
00358 int flag_var_tracking = AUTODETECT_FLAG_VAR_TRACKING;
00359
00360
00361
00362
00363 bool user_defined_section_attribute = false;
00364
00365
00366
00367
00368
00369
00370 int align_loops_log;
00371 int align_loops_max_skip;
00372 int align_jumps_log;
00373 int align_jumps_max_skip;
00374 int align_labels_log;
00375 int align_labels_max_skip;
00376 int align_functions_log;
00377
00378
00379
00380 int force_align_functions_log;
00381
00382 typedef struct
00383 {
00384 const char *const string;
00385 int *const variable;
00386 const int on_value;
00387 }
00388 lang_independent_options;
00389
00390
00391 int flag_evaluation_order = 0;
00392
00393
00394 const char *user_label_prefix;
00395
00396 static const param_info lang_independent_params[] = {
00397 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
00398 { OPTION, DEFAULT, MIN, MAX, HELP },
00399 #include "params.def"
00400 #undef DEFPARAM
00401 { NULL, 0, 0, 0, NULL }
00402 };
00403
00404
00405
00406
00407
00408
00409
00410 static const struct
00411 {
00412 const char *const name;
00413 const int value;
00414 const char *const description;
00415 }
00416 target_switches[] = TARGET_SWITCHES;
00417
00418
00419
00420 #ifdef TARGET_OPTIONS
00421 static const struct
00422 {
00423 const char *const prefix;
00424 const char **const variable;
00425 const char *const description;
00426 const char *const value;
00427 }
00428 target_options[] = TARGET_OPTIONS;
00429 #endif
00430
00431
00432
00433
00434 int warn_return_type;
00435
00436
00437
00438
00439 FILE *asm_out_file;
00440 FILE *aux_info_file;
00441 FILE *dump_file = NULL;
00442 const char *dump_file_name;
00443
00444
00445
00446
00447
00448
00449 static const char *src_pwd;
00450
00451
00452
00453
00454
00455
00456 bool
00457 set_src_pwd (const char *pwd)
00458 {
00459 if (src_pwd)
00460 {
00461 if (strcmp (src_pwd, pwd) == 0)
00462 return true;
00463 else
00464 return false;
00465 }
00466
00467 src_pwd = xstrdup (pwd);
00468 return true;
00469 }
00470
00471
00472
00473
00474
00475 const char *
00476 get_src_pwd (void)
00477 {
00478 if (! src_pwd)
00479 {
00480 src_pwd = getpwd ();
00481 if (!src_pwd)
00482 src_pwd = ".";
00483 }
00484
00485 return src_pwd;
00486 }
00487
00488
00489
00490 void
00491 announce_function (tree decl)
00492 {
00493 if (!quiet_flag)
00494 {
00495 if (rtl_dump_and_exit)
00496 verbatim ("%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
00497 else
00498 verbatim (" %s", lang_hooks.decl_printable_name (decl, 2));
00499 fflush (stderr);
00500 pp_needs_newline (global_dc->printer) = true;
00501 diagnostic_set_last_function (global_dc);
00502 }
00503 }
00504
00505
00506
00507
00508 static void
00509 randomize (void)
00510 {
00511 if (!flag_random_seed)
00512 {
00513 unsigned HOST_WIDE_INT value;
00514 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
00515
00516
00517 #ifdef HAVE_GETTIMEOFDAY
00518 {
00519 struct timeval tv;
00520
00521 gettimeofday (&tv, NULL);
00522 local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
00523 }
00524 #else
00525 {
00526 time_t now = time (NULL);
00527
00528 if (now != (time_t)-1)
00529 local_tick = (unsigned) now;
00530 }
00531 #endif
00532 value = local_tick ^ getpid ();
00533
00534 sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
00535 flag_random_seed = random_seed;
00536 }
00537 else if (!local_tick)
00538 local_tick = -1;
00539 }
00540
00541
00542
00543
00544
00545
00546
00547 int
00548 read_integral_parameter (const char *p, const char *pname, const int defval)
00549 {
00550 const char *endp = p;
00551
00552 while (*endp)
00553 {
00554 if (ISDIGIT (*endp))
00555 endp++;
00556 else
00557 break;
00558 }
00559
00560 if (*endp != 0)
00561 {
00562 if (pname != 0)
00563 error ("invalid option argument %qs", pname);
00564 return defval;
00565 }
00566
00567 return atoi (p);
00568 }
00569
00570
00571
00572
00573 int
00574 floor_log2 (unsigned HOST_WIDE_INT x)
00575 {
00576 int t = 0;
00577
00578 if (x == 0)
00579 return -1;
00580
00581 #ifdef CLZ_HWI
00582 t = HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x);
00583 #else
00584 if (HOST_BITS_PER_WIDE_INT > 64)
00585 if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
00586 t += 64;
00587 if (HOST_BITS_PER_WIDE_INT > 32)
00588 if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 32))
00589 t += 32;
00590 if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 16))
00591 t += 16;
00592 if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 8))
00593 t += 8;
00594 if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 4))
00595 t += 4;
00596 if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 2))
00597 t += 2;
00598 if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
00599 t += 1;
00600 #endif
00601
00602 return t;
00603 }
00604
00605
00606
00607
00608 int
00609 exact_log2 (unsigned HOST_WIDE_INT x)
00610 {
00611 if (x != (x & -x))
00612 return -1;
00613 #ifdef CTZ_HWI
00614 return x ? CTZ_HWI (x) : -1;
00615 #else
00616 return floor_log2 (x);
00617 #endif
00618 }
00619
00620
00621
00622
00623
00624 static void
00625 crash_signal (int signo)
00626 {
00627 signal (signo, SIG_DFL);
00628
00629
00630
00631 if (this_is_asm_operands)
00632 {
00633 output_operand_lossage ("unrecoverable error");
00634 #ifdef KEY
00635 fnotice (stderr, "GNU front-end error.\n");
00636 exit (RC_GCC_INTERNAL_ERROR);
00637 #endif
00638 exit (FATAL_EXIT_CODE);
00639 }
00640
00641 internal_error ("%s", strsignal (signo));
00642 }
00643
00644
00645
00646
00647 static void
00648 setup_core_dumping (void)
00649 {
00650 #ifdef SIGABRT
00651 signal (SIGABRT, SIG_DFL);
00652 #endif
00653 #if defined(HAVE_SETRLIMIT)
00654 {
00655 struct rlimit rlim;
00656 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
00657 fatal_error ("getting core file size maximum limit: %m");
00658 rlim.rlim_cur = rlim.rlim_max;
00659 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
00660 fatal_error ("setting core file size limit to maximum: %m");
00661 }
00662 #endif
00663 diagnostic_abort_on_error (global_dc);
00664 }
00665
00666
00667
00668
00669
00670
00671
00672 void
00673 strip_off_ending (char *name, int len)
00674 {
00675 int i;
00676 for (i = 2; i < 6 && len > i; i++)
00677 {
00678 if (name[len - i] == '.')
00679 {
00680 name[len - i] = '\0';
00681 break;
00682 }
00683 }
00684 }
00685
00686
00687
00688 void
00689 output_quoted_string (FILE *asm_file, const char *string)
00690 {
00691 #ifdef OUTPUT_QUOTED_STRING
00692 OUTPUT_QUOTED_STRING (asm_file, string);
00693 #else
00694 char c;
00695
00696 putc ('\"', asm_file);
00697 while ((c = *string++) != 0)
00698 {
00699 if (ISPRINT (c))
00700 {
00701 if (c == '\"' || c == '\\')
00702 putc ('\\', asm_file);
00703 putc (c, asm_file);
00704 }
00705 else
00706 fprintf (asm_file, "\\%03o", (unsigned char) c);
00707 }
00708 putc ('\"', asm_file);
00709 #endif
00710 }
00711
00712
00713
00714 void
00715 output_file_directive (FILE *asm_file, const char *input_name)
00716 {
00717 int len;
00718 const char *na;
00719
00720 if (input_name == NULL)
00721 input_name = "<stdin>";
00722
00723 len = strlen (input_name);
00724 na = input_name + len;
00725
00726
00727 while (na > input_name)
00728 {
00729 if (IS_DIR_SEPARATOR (na[-1]))
00730 break;
00731 na--;
00732 }
00733
00734 #ifdef ASM_OUTPUT_SOURCE_FILENAME
00735 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
00736 #else
00737 fprintf (asm_file, "\t.file\t");
00738 output_quoted_string (asm_file, na);
00739 fputc ('\n', asm_file);
00740 #endif
00741 }
00742
00743
00744
00745
00746
00747 void
00748 wrapup_global_declaration_1 (tree decl)
00749 {
00750
00751
00752 if (DECL_DEFER_OUTPUT (decl) != 0)
00753 DECL_DEFER_OUTPUT (decl) = 0;
00754
00755 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
00756 lang_hooks.finish_incomplete_decl (decl);
00757 }
00758
00759
00760
00761
00762 bool
00763 wrapup_global_declaration_2 (tree decl)
00764 {
00765 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
00766 return false;
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
00794 {
00795 struct cgraph_varpool_node *node;
00796 bool needed = 1;
00797 node = cgraph_varpool_node (decl);
00798
00799 if (flag_unit_at_a_time && node->finalized)
00800 needed = 0;
00801 else if (node->alias)
00802 needed = 0;
00803 else if ((flag_unit_at_a_time && !cgraph_global_info_ready)
00804 && (TREE_USED (decl)
00805 || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
00806 ;
00807 else if (node->needed)
00808 ;
00809 else if (DECL_COMDAT (decl))
00810 needed = 0;
00811 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
00812 && (optimize || !flag_keep_static_consts
00813 || DECL_ARTIFICIAL (decl)))
00814 needed = 0;
00815
00816 if (needed)
00817 {
00818 rest_of_decl_compilation (decl, 1, 1);
00819 return true;
00820 }
00821 }
00822
00823 return false;
00824 }
00825
00826
00827
00828
00829
00830
00831 bool
00832 wrapup_global_declarations (tree *vec, int len)
00833 {
00834 bool reconsider, output_something = false;
00835 int i;
00836
00837 for (i = 0; i < len; i++)
00838 wrapup_global_declaration_1 (vec[i]);
00839
00840
00841
00842
00843 do
00844 {
00845 reconsider = false;
00846 for (i = 0; i < len; i++)
00847 reconsider |= wrapup_global_declaration_2 (vec[i]);
00848 if (reconsider)
00849 output_something = true;
00850 }
00851 while (reconsider);
00852
00853 return output_something;
00854 }
00855
00856
00857
00858
00859 void
00860 check_global_declaration_1 (tree decl)
00861 {
00862
00863
00864
00865 if (TREE_CODE (decl) == FUNCTION_DECL
00866 && DECL_INITIAL (decl) == 0
00867 && DECL_EXTERNAL (decl)
00868 && ! DECL_ARTIFICIAL (decl)
00869 && ! TREE_NO_WARNING (decl)
00870 && ! TREE_PUBLIC (decl)
00871 && (warn_unused_function
00872 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
00873 {
00874 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
00875 pedwarn ("%J%qF used but never defined", decl, decl);
00876 else
00877 warning ("%J%qF declared %<static%> but never defined", decl, decl);
00878
00879 TREE_PUBLIC (decl) = 1;
00880 assemble_external (decl);
00881 }
00882
00883
00884 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
00885
00886
00887 || (warn_unused_variable
00888 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
00889 && ! DECL_IN_SYSTEM_HEADER (decl)
00890 && ! TREE_USED (decl)
00891
00892
00893 && ( DECL_NAME(decl) != NULL && ! TREE_USED (DECL_NAME (decl)))
00894 && ! DECL_EXTERNAL (decl)
00895 && ! TREE_PUBLIC (decl)
00896
00897 && ! TREE_THIS_VOLATILE (decl)
00898
00899 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
00900
00901 && lang_hooks.decls.warn_unused_global (decl))
00902 warning ("%J%qD defined but not used", decl, decl);
00903 }
00904
00905
00906
00907
00908 void
00909 check_global_declarations (tree *vec, int len)
00910 {
00911 int i;
00912
00913 for (i = 0; i < len; i++)
00914 check_global_declaration_1 (vec[i]);
00915 }
00916
00917
00918
00919 void
00920 emit_debug_global_declarations (tree *vec, int len)
00921 {
00922 int i;
00923
00924
00925 if (errorcount != 0 || sorrycount != 0)
00926 return;
00927
00928 timevar_push (TV_SYMOUT);
00929 for (i = 0; i < len; i++)
00930 debug_hooks->global_decl (vec[i]);
00931 timevar_pop (TV_SYMOUT);
00932 }
00933
00934
00935 void
00936 warn_deprecated_use (tree node)
00937 {
00938 if (node == 0 || !warn_deprecated_decl)
00939 return;
00940
00941 if (DECL_P (node))
00942 {
00943 expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
00944 warning ("%qs is deprecated (declared at %s:%d)",
00945 IDENTIFIER_POINTER (DECL_NAME (node)),
00946 xloc.file, xloc.line);
00947 }
00948 else if (TYPE_P (node))
00949 {
00950 const char *what = NULL;
00951 tree decl = TYPE_STUB_DECL (node);
00952
00953 if (TYPE_NAME (node))
00954 {
00955 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
00956 what = IDENTIFIER_POINTER (TYPE_NAME (node));
00957 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
00958 && DECL_NAME (TYPE_NAME (node)))
00959 what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
00960 }
00961
00962 if (decl)
00963 {
00964 expanded_location xloc
00965 = expand_location (DECL_SOURCE_LOCATION (decl));
00966 if (what)
00967 warning ("%qs is deprecated (declared at %s:%d)", what,
00968 xloc.file, xloc.line);
00969 else
00970 warning ("type is deprecated (declared at %s:%d)",
00971 xloc.file, xloc.line);
00972 }
00973 else
00974 {
00975 if (what)
00976 warning ("%qs is deprecated", what);
00977 else
00978 warning ("type is deprecated");
00979 }
00980 }
00981 }
00982
00983
00984
00985
00986
00987 void
00988 #ifdef USE_MAPPED_LOCATION
00989 push_srcloc (location_t fline)
00990 #else
00991 push_srcloc (const char *file, int line)
00992 #endif
00993 {
00994 struct file_stack *fs;
00995
00996 fs = xmalloc (sizeof (struct file_stack));
00997 fs->location = input_location;
00998 fs->next = input_file_stack;
00999 #ifdef USE_MAPPED_LOCATION
01000 input_location = fline;
01001 #else
01002 input_filename = file;
01003 input_line = line;
01004 #endif
01005 input_file_stack = fs;
01006 input_file_stack_tick++;
01007 }
01008
01009
01010
01011
01012
01013 void
01014 pop_srcloc (void)
01015 {
01016 struct file_stack *fs;
01017
01018 fs = input_file_stack;
01019 input_location = fs->location;
01020 input_file_stack = fs->next;
01021 free (fs);
01022 input_file_stack_tick++;
01023 }
01024
01025
01026
01027
01028 static void
01029 compile_file (void)
01030 {
01031
01032
01033 init_cgraph ();
01034 init_final (main_input_filename);
01035 coverage_init (aux_base_name);
01036
01037 timevar_push (TV_PARSE);
01038
01039
01040
01041 lang_hooks.parse_file (set_yydebug);
01042
01043
01044
01045 lang_hooks.clear_binding_stack ();
01046
01047
01048
01049 timevar_pop (TV_PARSE);
01050
01051 if (flag_syntax_only)
01052 return;
01053
01054 lang_hooks.decls.final_write_globals ();
01055 cgraph_varpool_assemble_pending_decls ();
01056 finish_aliases_2 ();
01057
01058
01059
01060
01061 coverage_finish ();
01062
01063
01064 if (flag_mudflap)
01065 mudflap_finish_file ();
01066
01067
01068
01069 weak_finish ();
01070
01071
01072 timevar_push (TV_SYMOUT);
01073
01074 #ifdef DWARF2_UNWIND_INFO
01075 if (dwarf2out_do_frame ())
01076 dwarf2out_frame_finish ();
01077 #endif
01078
01079 (*debug_hooks->finish) (main_input_filename);
01080 timevar_pop (TV_SYMOUT);
01081
01082
01083
01084 dw2_output_indirect_constants ();
01085
01086
01087
01088
01089 process_pending_assemble_externals ();
01090
01091
01092
01093
01094 #ifdef IDENT_ASM_OP
01095 if (!flag_no_ident)
01096 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
01097 IDENT_ASM_OP, version_string);
01098 #endif
01099
01100
01101
01102
01103 targetm.asm_out.file_end ();
01104 }
01105
01106
01107 void
01108 display_target_options (void)
01109 {
01110 int undoc, i;
01111 static bool displayed = false;
01112
01113
01114 if (displayed)
01115 return;
01116
01117 displayed = true;
01118
01119 if (ARRAY_SIZE (target_switches) > 1
01120 #ifdef TARGET_OPTIONS
01121 || ARRAY_SIZE (target_options) > 1
01122 #endif
01123 )
01124 {
01125 int doc = 0;
01126
01127 undoc = 0;
01128
01129 printf (_("\nTarget specific options:\n"));
01130
01131 for (i = ARRAY_SIZE (target_switches); i--;)
01132 {
01133 const char *option = target_switches[i].name;
01134 const char *description = target_switches[i].description;
01135
01136 if (option == NULL || *option == 0)
01137 continue;
01138 else if (description == NULL)
01139 {
01140 undoc = 1;
01141
01142 if (extra_warnings)
01143 printf (_(" -m%-23s [undocumented]\n"), option);
01144 }
01145 else if (*description != 0)
01146 doc += printf (" -m%-23s %s\n", option, _(description));
01147 }
01148
01149 #ifdef TARGET_OPTIONS
01150 for (i = ARRAY_SIZE (target_options); i--;)
01151 {
01152 const char *option = target_options[i].prefix;
01153 const char *description = target_options[i].description;
01154
01155 if (option == NULL || *option == 0)
01156 continue;
01157 else if (description == NULL)
01158 {
01159 undoc = 1;
01160
01161 if (extra_warnings)
01162 printf (_(" -m%-23s [undocumented]\n"), option);
01163 }
01164 else if (*description != 0)
01165 doc += printf (" -m%-23s %s\n", option, _(description));
01166 }
01167 #endif
01168 if (undoc)
01169 {
01170 if (doc)
01171 printf (_("\nThere are undocumented target specific options as well.\n"));
01172 else
01173 printf (_(" They exist, but they are not documented.\n"));
01174 }
01175 }
01176 }
01177
01178
01179
01180 void
01181 decode_d_option (const char *arg)
01182 {
01183 int c;
01184
01185 while (*arg)
01186 switch (c = *arg++)
01187 {
01188 case 'A':
01189 flag_debug_asm = 1;
01190 break;
01191 case 'p':
01192 flag_print_asm_name = 1;
01193 break;
01194 case 'P':
01195 flag_dump_rtl_in_asm = 1;
01196 flag_print_asm_name = 1;
01197 break;
01198 case 'v':
01199 graph_dump_format = vcg;
01200 break;
01201 case 'x':
01202 rtl_dump_and_exit = 1;
01203 break;
01204 case 'y':
01205 set_yydebug = 1;
01206 break;
01207 case 'D':
01208 case 'I':
01209 break;
01210 case 'H':
01211 setup_core_dumping();
01212 break;
01213
01214 case 'a':
01215 default:
01216 if (!enable_rtl_dump_file (c))
01217 warning ("unrecognized gcc debugging option: %c", c);
01218 break;
01219 }
01220 }
01221
01222
01223 const char *const debug_type_names[] =
01224 {
01225 "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
01226 };
01227
01228
01229
01230
01231 void
01232 set_target_switch (const char *name)
01233 {
01234 size_t j;
01235 int valid_target_option = 0;
01236
01237 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
01238 if (!strcmp (target_switches[j].name, name))
01239 {
01240 if (target_switches[j].value < 0)
01241 target_flags &= ~-target_switches[j].value;
01242 else
01243 target_flags |= target_switches[j].value;
01244 if (name[0] != 0)
01245 {
01246 if (target_switches[j].value < 0)
01247 target_flags_explicit |= -target_switches[j].value;
01248 else
01249 target_flags_explicit |= target_switches[j].value;
01250 }
01251 valid_target_option = 1;
01252 }
01253
01254 #ifdef TARGET_OPTIONS
01255 if (!valid_target_option)
01256 for (j = 0; j < ARRAY_SIZE (target_options); j++)
01257 {
01258 int len = strlen (target_options[j].prefix);
01259 if (target_options[j].value)
01260 {
01261 if (!strcmp (target_options[j].prefix, name))
01262 {
01263 *target_options[j].variable = target_options[j].value;
01264 valid_target_option = 1;
01265 }
01266 }
01267 else
01268 {
01269 if (!strncmp (target_options[j].prefix, name, len))
01270 {
01271 *target_options[j].variable = name + len;
01272 valid_target_option = 1;
01273 }
01274 }
01275 }
01276 #endif
01277
01278 if (!valid_target_option)
01279 error ("invalid option %qs", name);
01280 }
01281
01282
01283
01284
01285
01286 void
01287 print_version (FILE *file, const char *indent)
01288 {
01289 #ifndef __VERSION__
01290 #define __VERSION__ "[?]"
01291 #endif
01292 fnotice (file,
01293 #ifdef __GNUC__
01294 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
01295 #else
01296 "%s%s%s version %s (%s) compiled by CC.\n"
01297 #endif
01298 , indent, *indent != 0 ? " " : "",
01299 lang_hooks.name, version_string, TARGET_NAME,
01300 indent, __VERSION__);
01301 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
01302 indent, *indent != 0 ? " " : "",
01303 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
01304 }
01305
01306
01307
01308
01309
01310 static int
01311 print_single_switch (FILE *file, int pos, int max,
01312 const char *indent, const char *sep, const char *term,
01313 const char *type, const char *name)
01314 {
01315
01316
01317 int len = strlen (sep) + strlen (type) + strlen (name);
01318
01319 if (pos != 0
01320 && pos + len > max)
01321 {
01322 fprintf (file, "%s", term);
01323 pos = 0;
01324 }
01325 if (pos == 0)
01326 {
01327 fprintf (file, "%s", indent);
01328 pos = strlen (indent);
01329 }
01330 fprintf (file, "%s%s%s", sep, type, name);
01331 pos += len;
01332 return pos;
01333 }
01334
01335
01336
01337
01338
01339
01340 static void
01341 print_switch_values (FILE *file, int pos, int max,
01342 const char *indent, const char *sep, const char *term)
01343 {
01344 size_t j;
01345 const char **p;
01346
01347
01348
01349 randomize ();
01350
01351
01352 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
01353 _("options passed: "), "");
01354
01355 for (p = &save_argv[1]; *p != NULL; p++)
01356 if (**p == '-')
01357 {
01358
01359 if (strcmp (*p, "-o") == 0)
01360 {
01361 if (p[1] != NULL)
01362 p++;
01363 continue;
01364 }
01365 if (strcmp (*p, "-quiet") == 0)
01366 continue;
01367 if (strcmp (*p, "-version") == 0)
01368 continue;
01369 if ((*p)[1] == 'd')
01370 continue;
01371
01372 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
01373 }
01374 if (pos > 0)
01375 fprintf (file, "%s", term);
01376
01377
01378
01379
01380
01381 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
01382 _("options enabled: "), "");
01383
01384 for (j = 0; j < cl_options_count; j++)
01385 {
01386 if (!cl_options[j].flag_var
01387 || !(cl_options[j].flags & CL_REPORT))
01388 continue;
01389
01390 if (cl_options[j].has_set_value)
01391 {
01392 if (*cl_options[j].flag_var != cl_options[j].set_value)
01393 continue;
01394 }
01395 else
01396 {
01397 if (!*cl_options[j].flag_var)
01398 continue;
01399 }
01400
01401 pos = print_single_switch (file, pos, max, indent, sep, term,
01402 "", cl_options[j].opt_text);
01403 }
01404
01405
01406
01407 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
01408 if (target_switches[j].name[0] != '\0'
01409 && target_switches[j].value > 0
01410 && ((target_switches[j].value & target_flags)
01411 == target_switches[j].value))
01412 {
01413 pos = print_single_switch (file, pos, max, indent, sep, term,
01414 "-m", target_switches[j].name);
01415 }
01416
01417 #ifdef TARGET_OPTIONS
01418 for (j = 0; j < ARRAY_SIZE (target_options); j++)
01419 if (*target_options[j].variable != NULL)
01420 {
01421 char prefix[256];
01422 sprintf (prefix, "-m%s", target_options[j].prefix);
01423 pos = print_single_switch (file, pos, max, indent, sep, term,
01424 prefix, *target_options[j].variable);
01425 }
01426 #endif
01427
01428 fprintf (file, "%s", term);
01429 }
01430
01431 #ifdef KEY
01432
01433 void remove_asm_file (void) {
01434
01435 if (strcmp (asm_file_name, "-") != 0) {
01436 if (fclose (asm_out_file) != 0)
01437 fatal_error ("error closing %s: %m", asm_file_name);
01438 if (unlink (asm_file_name) != 0)
01439 fprintf (stderr, "unable to remove assembly file.\n");
01440 }
01441 }
01442 #endif
01443
01444
01445
01446
01447
01448 static void
01449 init_asm_output (const char *name)
01450 {
01451 #ifdef KEY
01452 if (flag_spin_file) {
01453 asm_file_name = tempnam ("/tmp", "");
01454 if (asm_file_name == NULL)
01455 gcc_assert (0);
01456 }
01457 #endif
01458
01459 if (name == NULL && asm_file_name == 0)
01460 asm_out_file = stdout;
01461 else
01462 {
01463 if (asm_file_name == 0)
01464 {
01465 int len = strlen (dump_base_name);
01466 char *dumpname = xmalloc (len + 6);
01467 memcpy (dumpname, dump_base_name, len + 1);
01468 strip_off_ending (dumpname, len);
01469 strcat (dumpname, ".s");
01470 asm_file_name = dumpname;
01471 }
01472 if (!strcmp (asm_file_name, "-"))
01473 asm_out_file = stdout;
01474 else
01475 asm_out_file = fopen (asm_file_name, "w+b");
01476 if (asm_out_file == 0)
01477 fatal_error ("can%'t open %s for writing: %m", asm_file_name);
01478 }
01479
01480 if (!flag_syntax_only)
01481 {
01482 targetm.asm_out.file_start ();
01483
01484 #ifdef ASM_COMMENT_START
01485 if (flag_verbose_asm)
01486 {
01487
01488 print_version (asm_out_file, ASM_COMMENT_START);
01489 print_switch_values (asm_out_file, 0, MAX_LINE,
01490 ASM_COMMENT_START, " ", "\n");
01491
01492
01493 fprintf (asm_out_file, "\n");
01494 }
01495 #endif
01496 }
01497 }
01498
01499
01500
01501
01502
01503 void *
01504 default_get_pch_validity (size_t *len)
01505 {
01506 #ifdef TARGET_OPTIONS
01507 size_t i;
01508 #endif
01509 char *result, *r;
01510
01511 *len = sizeof (target_flags) + 2;
01512 #ifdef TARGET_OPTIONS
01513 for (i = 0; i < ARRAY_SIZE (target_options); i++)
01514 {
01515 *len += 1;
01516 if (*target_options[i].variable)
01517 *len += strlen (*target_options[i].variable);
01518 }
01519 #endif
01520
01521 result = r = xmalloc (*len);
01522 r[0] = flag_pic;
01523 r[1] = flag_pie;
01524 r += 2;
01525 memcpy (r, &target_flags, sizeof (target_flags));
01526 r += sizeof (target_flags);
01527
01528 #ifdef TARGET_OPTIONS
01529 for (i = 0; i < ARRAY_SIZE (target_options); i++)
01530 {
01531 const char *str = *target_options[i].variable;
01532 size_t l;
01533 if (! str)
01534 str = "";
01535 l = strlen (str) + 1;
01536 memcpy (r, str, l);
01537 r += l;
01538 }
01539 #endif
01540
01541 return result;
01542 }
01543
01544
01545
01546 const char *
01547 default_pch_valid_p (const void *data_p, size_t len)
01548 {
01549 const char *data = (const char *)data_p;
01550 const char *flag_that_differs = NULL;
01551 size_t i;
01552
01553
01554 if (data[0] != flag_pic)
01555 return _("created and used with different settings of -fpic");
01556 if (data[1] != flag_pie)
01557 return _("created and used with different settings of -fpie");
01558 data += 2;
01559
01560
01561 if (memcmp (data, &target_flags, sizeof (target_flags)) != 0)
01562 {
01563 for (i = 0; i < ARRAY_SIZE (target_switches); i++)
01564 {
01565 int bits;
01566 int tf;
01567
01568 memcpy (&tf, data, sizeof (target_flags));
01569
01570 bits = target_switches[i].value;
01571 if (bits < 0)
01572 bits = -bits;
01573 if ((target_flags & bits) != (tf & bits))
01574 {
01575 flag_that_differs = target_switches[i].name;
01576 goto make_message;
01577 }
01578 }
01579 gcc_unreachable ();
01580 }
01581 data += sizeof (target_flags);
01582 len -= sizeof (target_flags);
01583
01584
01585 #ifdef TARGET_OPTIONS
01586 for (i = 0; i < ARRAY_SIZE (target_options); i++)
01587 {
01588 const char *str = *target_options[i].variable;
01589 size_t l;
01590 if (! str)
01591 str = "";
01592 l = strlen (str) + 1;
01593 if (len < l || memcmp (data, str, l) != 0)
01594 {
01595 flag_that_differs = target_options[i].prefix;
01596 goto make_message;
01597 }
01598 data += l;
01599 len -= l;
01600 }
01601 #endif
01602
01603 return NULL;
01604
01605 make_message:
01606 {
01607 char *r;
01608 asprintf (&r, _("created and used with differing settings of '-m%s'"),
01609 flag_that_differs);
01610 if (r == NULL)
01611 return _("out of memory");
01612 return r;
01613 }
01614 }
01615
01616
01617 static bool
01618 default_tree_printer (pretty_printer * pp, text_info *text)
01619 {
01620 tree t;
01621
01622 switch (*text->format_spec)
01623 {
01624 case 'D':
01625 t = va_arg (*text->args_ptr, tree);
01626 if (DECL_DEBUG_EXPR (t) && DECL_DEBUG_EXPR_IS_FROM (t))
01627 t = DECL_DEBUG_EXPR (t);
01628 break;
01629
01630 case 'F':
01631 case 'T':
01632 t = va_arg (*text->args_ptr, tree);
01633 break;
01634
01635 default:
01636 return false;
01637 }
01638
01639 if (DECL_P (t))
01640 {
01641 const char *n = DECL_NAME (t)
01642 ? lang_hooks.decl_printable_name (t, 2)
01643 : "<anonymous>";
01644 pp_string (pp, n);
01645 }
01646 else
01647 dump_generic_node (pp, t, 0, 0, 0);
01648
01649 return true;
01650 }
01651
01652
01653
01654
01655 static void
01656 general_init (const char *argv0)
01657 {
01658 const char *p;
01659
01660 p = argv0 + strlen (argv0);
01661 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
01662 --p;
01663 progname = p;
01664
01665 xmalloc_set_program_name (progname);
01666
01667 hex_init ();
01668
01669
01670 unlock_std_streams ();
01671
01672 gcc_init_libintl ();
01673
01674
01675
01676 diagnostic_initialize (global_dc);
01677
01678
01679 pp_format_decoder (global_dc->printer) = &default_tree_printer;
01680
01681
01682 #ifdef SIGSEGV
01683 signal (SIGSEGV, crash_signal);
01684 #endif
01685 #ifdef SIGILL
01686 signal (SIGILL, crash_signal);
01687 #endif
01688 #ifdef SIGBUS
01689 signal (SIGBUS, crash_signal);
01690 #endif
01691 #ifdef SIGABRT
01692 signal (SIGABRT, crash_signal);
01693 #endif
01694 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
01695 signal (SIGIOT, crash_signal);
01696 #endif
01697 #ifdef SIGFPE
01698 signal (SIGFPE, crash_signal);
01699 #endif
01700
01701
01702 (*host_hooks.extra_signals)();
01703
01704
01705
01706 init_ggc ();
01707 init_stringpool ();
01708 linemap_init (&line_table);
01709 init_ttree ();
01710
01711
01712 init_reg_sets ();
01713
01714
01715 add_params (lang_independent_params, LAST_PARAM);
01716
01717
01718 init_ggc_heuristics();
01719 init_tree_optimization_passes ();
01720 }
01721
01722
01723 static void
01724 process_options (void)
01725 {
01726
01727
01728
01729
01730 no_backend = lang_hooks.post_options (&main_input_filename);
01731 #ifndef USE_MAPPED_LOCATION
01732 input_filename = main_input_filename;
01733 #endif
01734
01735 #ifdef OVERRIDE_OPTIONS
01736
01737 OVERRIDE_OPTIONS;
01738 #endif
01739
01740 if (flag_short_enums == 2)
01741 flag_short_enums = targetm.default_short_enums ();
01742
01743
01744 if (aux_base_name)
01745 ;
01746 else if (main_input_filename)
01747 {
01748 char *name = xstrdup (lbasename (main_input_filename));
01749
01750 strip_off_ending (name, strlen (name));
01751 aux_base_name = name;
01752 }
01753 else
01754 aux_base_name = "gccaux";
01755
01756
01757
01758 if (align_loops <= 0) align_loops = 1;
01759 if (align_loops_max_skip > align_loops || !align_loops)
01760 align_loops_max_skip = align_loops - 1;
01761 align_loops_log = floor_log2 (align_loops * 2 - 1);
01762 if (align_jumps <= 0) align_jumps = 1;
01763 if (align_jumps_max_skip > align_jumps || !align_jumps)
01764 align_jumps_max_skip = align_jumps - 1;
01765 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
01766 if (align_labels <= 0) align_labels = 1;
01767 align_labels_log = floor_log2 (align_labels * 2 - 1);
01768 if (align_labels_max_skip > align_labels || !align_labels)
01769 align_labels_max_skip = align_labels - 1;
01770 if (align_functions <= 0) align_functions = 1;
01771 align_functions_log = floor_log2 (align_functions * 2 - 1);
01772
01773
01774
01775 if (flag_unroll_all_loops)
01776 flag_unroll_loops = 1;
01777
01778
01779 if (flag_unroll_loops || flag_peel_loops)
01780 flag_rerun_cse_after_loop = 1;
01781
01782
01783
01784 if (flag_loop_optimize2)
01785 flag_loop_optimize = 0;
01786
01787
01788 if (flag_move_loop_invariants
01789 || flag_unswitch_loops
01790 || flag_peel_loops
01791 || flag_unroll_loops
01792 || flag_branch_on_count_reg)
01793 flag_loop_optimize2 = 1;
01794
01795 if (flag_non_call_exceptions)
01796 flag_asynchronous_unwind_tables = 1;
01797 if (flag_asynchronous_unwind_tables)
01798 flag_unwind_tables = 1;
01799
01800
01801
01802 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
01803 flag_unit_at_a_time = 0;
01804
01805 if (flag_value_profile_transformations)
01806 flag_profile_values = 1;
01807
01808
01809
01810
01811
01812
01813 if (flag_speculative_prefetching)
01814 {
01815 flag_profile_values = 1;
01816 flag_prefetch_loop_arrays = 0;
01817 }
01818
01819
01820 #ifndef INSN_SCHEDULING
01821 if (flag_schedule_insns || flag_schedule_insns_after_reload)
01822 warning ("instruction scheduling not supported on this target machine");
01823 #endif
01824 #ifndef DELAY_SLOTS
01825 if (flag_delayed_branch)
01826 warning ("this target machine does not have delayed branches");
01827 #endif
01828
01829 if (flag_tree_based_profiling && flag_profile_values)
01830 sorry ("value-based profiling not yet implemented in trees.");
01831
01832 user_label_prefix = USER_LABEL_PREFIX;
01833 if (flag_leading_underscore != -1)
01834 {
01835
01836
01837 if (user_label_prefix[0] == 0 ||
01838 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
01839 {
01840 user_label_prefix = flag_leading_underscore ? "_" : "";
01841 }
01842 else
01843 warning ("-f%sleading-underscore not supported on this target machine",
01844 flag_leading_underscore ? "" : "no-");
01845 }
01846
01847
01848
01849 if (version_flag)
01850 {
01851 print_version (stderr, "");
01852 if (! quiet_flag)
01853 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
01854 }
01855
01856 if (flag_syntax_only)
01857 {
01858 write_symbols = NO_DEBUG;
01859 profile_flag = 0;
01860 }
01861
01862
01863
01864 if (debug_info_level == DINFO_LEVEL_NONE)
01865 write_symbols = NO_DEBUG;
01866
01867
01868
01869 if (PREFERRED_DEBUGGING_TYPE == NO_DEBUG)
01870 default_debug_hooks = &do_nothing_debug_hooks;
01871 #if defined(DBX_DEBUGGING_INFO)
01872 else if (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG)
01873 default_debug_hooks = &dbx_debug_hooks;
01874 #endif
01875 #if defined(XCOFF_DEBUGGING_INFO)
01876 else if (PREFERRED_DEBUGGING_TYPE == XCOFF_DEBUG)
01877 default_debug_hooks = &xcoff_debug_hooks;
01878 #endif
01879 #ifdef SDB_DEBUGGING_INFO
01880 else if (PREFERRED_DEBUGGING_TYPE == SDB_DEBUG)
01881 default_debug_hooks = &sdb_debug_hooks;
01882 #endif
01883 #ifdef DWARF2_DEBUGGING_INFO
01884 else if (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG)
01885 default_debug_hooks = &dwarf2_debug_hooks;
01886 #endif
01887 #ifdef VMS_DEBUGGING_INFO
01888 else if (PREFERRED_DEBUGGING_TYPE == VMS_DEBUG
01889 || PREFERRED_DEBUGGING_TYPE == VMS_AND_DWARF2_DEBUG)
01890 default_debug_hooks = &vmsdbg_debug_hooks;
01891 #endif
01892
01893 debug_hooks = &do_nothing_debug_hooks;
01894 if (write_symbols == NO_DEBUG)
01895 ;
01896 #if defined(DBX_DEBUGGING_INFO)
01897 else if (write_symbols == DBX_DEBUG)
01898 debug_hooks = &dbx_debug_hooks;
01899 #endif
01900 #if defined(XCOFF_DEBUGGING_INFO)
01901 else if (write_symbols == XCOFF_DEBUG)
01902 debug_hooks = &xcoff_debug_hooks;
01903 #endif
01904 #ifdef SDB_DEBUGGING_INFO
01905 else if (write_symbols == SDB_DEBUG)
01906 debug_hooks = &sdb_debug_hooks;
01907 #endif
01908 #ifdef DWARF2_DEBUGGING_INFO
01909 else if (write_symbols == DWARF2_DEBUG)
01910 debug_hooks = &dwarf2_debug_hooks;
01911 #endif
01912 #ifdef VMS_DEBUGGING_INFO
01913 else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
01914 debug_hooks = &vmsdbg_debug_hooks;
01915 #endif
01916 else
01917 error ("target system does not support the \"%s\" debug format",
01918 debug_type_names[write_symbols]);
01919
01920
01921
01922
01923 if (debug_info_level < DINFO_LEVEL_NORMAL
01924 || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
01925 {
01926 if (flag_var_tracking == 1)
01927 {
01928 if (debug_info_level < DINFO_LEVEL_NORMAL)
01929 warning ("variable tracking requested, but useless unless "
01930 "producing debug info");
01931 else
01932 warning ("variable tracking requested, but not supported "
01933 "by this debug format");
01934 }
01935 flag_var_tracking = 0;
01936 }
01937
01938 if (flag_rename_registers == AUTODETECT_FLAG_VAR_TRACKING)
01939 flag_rename_registers = default_debug_hooks->var_location
01940 != do_nothing_debug_hooks.var_location;
01941
01942 if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
01943 flag_var_tracking = optimize >= 1;
01944
01945
01946
01947
01948 if (flag_gen_aux_info)
01949 {
01950 aux_info_file = fopen (aux_info_file_name, "w");
01951 if (aux_info_file == 0)
01952 fatal_error ("can%'t open %s: %m", aux_info_file_name);
01953 }
01954
01955 if (! targetm.have_named_sections)
01956 {
01957 if (flag_function_sections)
01958 {
01959 warning ("-ffunction-sections not supported for this target");
01960 flag_function_sections = 0;
01961 }
01962 if (flag_data_sections)
01963 {
01964 warning ("-fdata-sections not supported for this target");
01965 flag_data_sections = 0;
01966 }
01967 }
01968
01969 if (flag_function_sections && profile_flag)
01970 {
01971 warning ("-ffunction-sections disabled; it makes profiling impossible");
01972 flag_function_sections = 0;
01973 }
01974
01975 #ifndef HAVE_prefetch
01976 if (flag_prefetch_loop_arrays)
01977 {
01978 warning ("-fprefetch-loop-arrays not supported for this target");
01979 flag_prefetch_loop_arrays = 0;
01980 }
01981 if (flag_speculative_prefetching)
01982 {
01983 if (flag_speculative_prefetching_set)
01984 warning ("-fspeculative-prefetching not supported for this target");
01985 flag_speculative_prefetching = 0;
01986 }
01987 #else
01988 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
01989 {
01990 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
01991 flag_prefetch_loop_arrays = 0;
01992 }
01993 if (flag_speculative_prefetching && !HAVE_prefetch)
01994 {
01995 if (flag_speculative_prefetching_set)
01996 warning ("-fspeculative-prefetching not supported for this target (try -march switches)");
01997 flag_speculative_prefetching = 0;
01998 }
01999 #endif
02000
02001
02002
02003 if (flag_prefetch_loop_arrays && optimize_size)
02004 {
02005 warning ("-fprefetch-loop-arrays is not supported with -Os");
02006 flag_prefetch_loop_arrays = 0;
02007 }
02008
02009 #ifndef OBJECT_FORMAT_ELF
02010 if (flag_function_sections && write_symbols != NO_DEBUG)
02011 warning ("-ffunction-sections may affect debugging on some targets");
02012 #endif
02013
02014
02015 if (flag_signaling_nans)
02016 flag_trapping_math = 1;
02017
02018
02019 if (flag_cx_limited_range)
02020 flag_complex_method = 0;
02021 }
02022
02023
02024 static void
02025 backend_init (void)
02026 {
02027 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
02028 || debug_info_level == DINFO_LEVEL_VERBOSE
02029 #ifdef VMS_DEBUGGING_INFO
02030
02031 || debug_info_level > DINFO_LEVEL_NONE
02032 #endif
02033 || flag_test_coverage);
02034
02035 init_rtlanal ();
02036 init_regs ();
02037 init_fake_stack_mems ();
02038 init_alias_once ();
02039 init_loop ();
02040 init_reload ();
02041 init_function_once ();
02042 init_varasm_once ();
02043
02044
02045
02046 init_dummy_function_start ();
02047 init_expmed ();
02048 if (flag_caller_saves)
02049 init_caller_save ();
02050 expand_dummy_function_end ();
02051 }
02052
02053
02054 static int
02055 lang_dependent_init (const char *name)
02056 {
02057 location_t save_loc = input_location;
02058 if (dump_base_name == 0)
02059 dump_base_name = name && name[0] ? name : "gccdump";
02060
02061
02062 #ifdef USE_MAPPED_LOCATION
02063 input_location = BUILTINS_LOCATION;
02064 #else
02065 input_filename = "<built-in>";
02066 input_line = 0;
02067 #endif
02068
02069 #ifdef KEY
02070
02071
02072 if (flag_spin_file) {
02073 gspin_init ();
02074 gspin ((tree) NULL);
02075 }
02076 #endif
02077
02078 if (lang_hooks.init () == 0)
02079 return 0;
02080
02081 #ifdef KEY
02082 if (flag_spin_file) {
02083
02084 gspin_init_global_trees_list ();
02085 }
02086 #endif
02087
02088 input_location = save_loc;
02089
02090 init_asm_output (name);
02091
02092
02093
02094 init_eh ();
02095 init_optabs ();
02096
02097
02098
02099 init_dummy_function_start ();
02100 init_expr_once ();
02101 expand_dummy_function_end ();
02102
02103
02104
02105 timevar_push (TV_SYMOUT);
02106
02107 #ifdef DWARF2_UNWIND_INFO
02108 if (dwarf2out_do_frame ())
02109 dwarf2out_frame_init ();
02110 #endif
02111
02112
02113
02114 (*debug_hooks->init) (name);
02115
02116 timevar_pop (TV_SYMOUT);
02117
02118 return 1;
02119 }
02120
02121
02122
02123 static void
02124 finalize (void)
02125 {
02126
02127 if (flag_gen_aux_info)
02128 {
02129 fclose (aux_info_file);
02130 if (errorcount)
02131 unlink (aux_info_file_name);
02132 }
02133
02134
02135
02136
02137
02138 #ifdef KEY // bug 11256
02139 if (flag_spin_file)
02140 remove_asm_file ();
02141 else
02142 #endif
02143 if (asm_out_file)
02144 {
02145 if (ferror (asm_out_file) != 0)
02146 fatal_error ("error writing to %s: %m", asm_file_name);
02147 if (fclose (asm_out_file) != 0)
02148 fatal_error ("error closing %s: %m", asm_file_name);
02149 }
02150
02151 finish_optimization_passes ();
02152
02153 if (mem_report)
02154 {
02155 ggc_print_statistics ();
02156 stringpool_statistics ();
02157 dump_tree_statistics ();
02158 dump_rtx_statistics ();
02159 dump_varray_statistics ();
02160 dump_alloc_pool_statistics ();
02161 dump_ggc_loc_statistics ();
02162 }
02163
02164
02165 free_reg_info ();
02166
02167
02168 lang_hooks.finish ();
02169 }
02170
02171
02172 static void
02173 do_compile (void)
02174 {
02175
02176
02177 if (time_report || !quiet_flag || flag_detailed_statistics)
02178 timevar_init ();
02179 timevar_start (TV_TOTAL);
02180
02181 process_options ();
02182
02183
02184 if (!errorcount)
02185 {
02186
02187
02188
02189 init_adjust_machine_modes ();
02190
02191
02192 if (!no_backend)
02193 backend_init ();
02194
02195
02196 if (lang_dependent_init (main_input_filename)) {
02197 compile_file ();
02198 }
02199
02200 finalize ();
02201 }
02202
02203
02204 timevar_stop (TV_TOTAL);
02205 timevar_print (stderr);
02206 }
02207
02208
02209
02210
02211
02212
02213
02214 int
02215 toplev_main (unsigned int argc, const char **argv)
02216 {
02217 save_argv = argv;
02218
02219
02220 general_init (argv[0]);
02221
02222
02223
02224 decode_options (argc, argv);
02225
02226 randomize ();
02227
02228
02229 if (!exit_after_options)
02230 do_compile ();
02231
02232 if (errorcount || sorrycount)
02233 return (FATAL_EXIT_CODE);
02234
02235 return (SUCCESS_EXIT_CODE);
02236 }