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