OSDN Git Service

* toplev.c (init_asm_output): Add explicit 'b' to mode when
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
index 39b2ddf..2741be5 100644 (file)
@@ -43,6 +43,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "line-map.h"
 #include "input.h"
 #include "tree.h"
+#include "version.h"
 #include "rtl.h"
 #include "tm_p.h"
 #include "flags.h"
@@ -73,6 +74,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "target.h"
 #include "langhooks.h"
 #include "cfglayout.h"
+#include "tree-alias-common.h" 
 #include "cfgloop.h"
 #include "hosthooks.h"
 #include "cgraph.h"
@@ -138,6 +140,10 @@ static const char **save_argv;
 
 const char *main_input_filename;
 
+/* Used to enable -fvar-tracking, -fweb and -frename-registers according
+   to optimize and default_debug_hooks in process_options ().  */
+#define AUTODETECT_FLAG_VAR_TRACKING 2
+
 /* Current position in real source file.  */
 
 location_t input_location;
@@ -177,6 +183,10 @@ int target_flags_explicit;
 
 const struct gcc_debug_hooks *debug_hooks;
 
+/* Debug hooks - target default.  */
+
+static const struct gcc_debug_hooks *default_debug_hooks;
+
 /* Other flags saying which kinds of debugging dump have been requested.  */
 
 int rtl_dump_and_exit;
@@ -211,6 +221,11 @@ tree current_function_decl;
    if none.  */
 tree current_function_func_begin_label;
 
+/* A DECL for the current file-scope context.  When using IMA, this heads a
+   chain of FILE_DECLs; currently only C uses it.  */
+
+tree current_file_decl;
+
 /* Nonzero if doing dwarf2 duplicate elimination.  */
 
 int flag_eliminate_dwarf2_dups = 0;
@@ -250,7 +265,7 @@ int flag_branch_probabilities = 0;
 int flag_reorder_blocks = 0;
 
 /* Nonzero if blocks should be partitioned into hot and cold sections in
-   addition to being reordered. */
+   addition to being reordered.  */
 
 int flag_reorder_blocks_and_partition = 0;
 
@@ -258,8 +273,10 @@ int flag_reorder_blocks_and_partition = 0;
 
 int flag_reorder_functions = 0;
 
-/* Nonzero if registers should be renamed.  */
-
+/* Nonzero if registers should be renamed.  When
+   flag_rename_registers == AUTODETECT_FLAG_VAR_TRACKING it will be set
+   according to optimize and default_debug_hooks in process_options (),
+   but we do not do this yet because it triggers aborts in flow.c.  */
 int flag_rename_registers = 0;
 int flag_cprop_registers = 0;
 
@@ -304,7 +321,8 @@ unsigned local_tick;
 
 int flag_signed_char;
 
-/* Nonzero means give an enum type only as many bytes as it needs.  */
+/* Nonzero means give an enum type only as many bytes as it needs.  A value
+   of 2 means it has not yet been initialized.  */
 
 int flag_short_enums;
 
@@ -485,9 +503,11 @@ int flag_complex_divide_method = 0;
 
 int flag_syntax_only = 0;
 
-/* Nonzero means performs web construction pass.  */
+/* Nonzero means performs web construction pass.  When flag_web ==
+   AUTODETECT_FLAG_VAR_TRACKING it will be set according to optimize
+   and default_debug_hooks in process_options ().  */
 
-int flag_web;
+int flag_web = AUTODETECT_FLAG_VAR_TRACKING;
 
 /* Nonzero means perform loop optimizer.  */
 
@@ -688,6 +708,9 @@ int flag_schedule_speculative_load_dangerous = 0;
 int flag_sched_stalled_insns = 0;
 int flag_sched_stalled_insns_dep = 1;
 
+/* The following flag controls the module scheduling activation.  */
+int flag_modulo_sched = 0;
+
 int flag_single_precision_constant;
 
 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
@@ -776,6 +799,11 @@ int flag_guess_branch_prob = 0;
    For Fortran: defaults to off.  */
 int flag_bounds_check = 0;
 
+/* Mudflap bounds-checking transform.  */
+int flag_mudflap = 0;
+int flag_mudflap_threads = 0;
+int flag_mudflap_ignore_reads = 0;
+
 /* This will attempt to merge constant section constants, if 1 only
    string constants and constants from constant pool, if 2 also constant
    variables.  */
@@ -789,8 +817,49 @@ int flag_renumber_insns = 1;
 /* If nonzero, use the graph coloring register allocator.  */
 int flag_new_regalloc = 0;
 
-/* Nonzero if we perform superblock formation.  */
+/* If nonzero, use tree-based instead of rtl-based profiling.  */
+int flag_tree_based_profiling = 0;
+
+/* Enable SSA-GVN on trees.  */
+int flag_tree_gvn = 0;
+
+/* Enable the SSA-PRE tree optimization.  */
+int flag_tree_pre = 0;
+
+/* Enable points-to analysis on trees.  */
+enum pta_type flag_tree_points_to = PTA_NONE;
+
+/* Enable SSA-CCP on trees.  */
+int flag_tree_ccp = 0;
 
+/* Enable SSA-DCE on trees.  */
+int flag_tree_dce = 0;
+
+/* Enable loop header copying on tree-ssa.  */
+int flag_tree_ch = 0;
+
+/* Enable scalar replacement of aggregates.  */
+int flag_tree_sra = 0;
+
+/* Enable SSA->normal pass memory location coalescing.  */
+int flag_tree_combine_temps = 0;
+
+/* Enable SSA->normal pass expression replacement.  */
+int flag_tree_ter = 0;
+
+/* Enable SSA->normal live range splitting.  */
+int flag_tree_live_range_split = 0;
+
+/* Enable dominator optimizations.  */
+int flag_tree_dom = 0;
+
+/* Enable copy rename optimization.  */
+int flag_tree_copyrename = 0;
+
+/* Enable dead store elimination.  */
+int flag_tree_dse = 0;
+
+/* Nonzero if we perform superblock formation.  */
 int flag_tracer = 0;
 
 /* Nonzero if we perform whole unit at a time compilation.  */
@@ -800,8 +869,6 @@ int flag_unit_at_a_time = 0;
 /* Nonzero if we should track variables.  When
    flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING it will be set according
    to optimize, debug_info_level and debug_hooks in process_options ().  */
-#define AUTODETECT_FLAG_VAR_TRACKING 2
 int flag_var_tracking = AUTODETECT_FLAG_VAR_TRACKING;
 
 /* Values of the -falign-* flags: how much to align labels in code.
@@ -944,6 +1011,7 @@ static const lang_independent_options f_options[] =
   {"sched-stalled-insns-dep", &flag_sched_stalled_insns_dep, 1 },
   {"sched2-use-superblocks", &flag_sched2_use_superblocks, 1 },
   {"sched2-use-traces", &flag_sched2_use_traces, 1 },
+  {"modulo-sched", &flag_modulo_sched, 1 },
   {"branch-count-reg",&flag_branch_on_count_reg, 1 },
   {"pic", &flag_pic, 1 },
   {"PIC", &flag_pic, 2 },
@@ -959,6 +1027,7 @@ static const lang_independent_options f_options[] =
   {"test-coverage", &flag_test_coverage, 1 },
   {"branch-probabilities", &flag_branch_probabilities, 1 },
   {"profile", &profile_flag, 1 },
+  {"tree-based-profiling", &flag_tree_based_profiling, 1 },
   {"reorder-blocks", &flag_reorder_blocks, 1 },
   {"reorder-blocks-and-partition", &flag_reorder_blocks_and_partition, 1},
   {"reorder-functions", &flag_reorder_functions, 1 },
@@ -1003,7 +1072,18 @@ static const lang_independent_options f_options[] =
   { "trapv", &flag_trapv, 1 },
   { "wrapv", &flag_wrapv, 1 },
   { "new-ra", &flag_new_regalloc, 1 },
-  { "var-tracking", &flag_var_tracking, 1}
+  { "var-tracking", &flag_var_tracking, 1},
+  { "tree-gvn", &flag_tree_gvn, 1 },
+  { "tree-pre", &flag_tree_pre, 1 },
+  { "tree-ccp", &flag_tree_ccp, 1 },
+  { "tree-dce", &flag_tree_dce, 1 },
+  { "tree-dominator-opts", &flag_tree_dom, 1 },
+  { "tree-copyrename", &flag_tree_copyrename, 1 },
+  { "tree-dse", &flag_tree_dse, 1 },
+  { "tree-combine-temps", &flag_tree_combine_temps, 1 },
+  { "tree-ter", &flag_tree_ter, 1 },
+  { "tree-lrs", &flag_tree_live_range_split, 1 },
+  { "tree-ch", &flag_tree_ch, 1 }
 };
 
 /* Here is a table, controlled by the tm.h file, listing each -m switch
@@ -1400,18 +1480,6 @@ wrapup_global_declarations (tree *vec, int len)
                  rest_of_decl_compilation (decl, NULL, 1, 1);
                }
            }
-
-         if (TREE_CODE (decl) == FUNCTION_DECL
-             && DECL_INITIAL (decl) != 0
-             && DECL_STRUCT_FUNCTION (decl) != 0
-             && DECL_STRUCT_FUNCTION (decl)->saved_for_inline
-             && (flag_keep_inline_functions
-                 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
-                 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
-           {
-             reconsider = 1;
-             output_inline_function (decl);
-           }
        }
 
       if (reconsider)
@@ -1448,12 +1516,12 @@ check_global_declarations (tree *vec, int len)
         because many programs have static variables
         that exist only to get some text into the object file.  */
       if (TREE_CODE (decl) == FUNCTION_DECL
-         && (warn_unused_function
-             || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
          && DECL_INITIAL (decl) == 0
          && DECL_EXTERNAL (decl)
          && ! DECL_ARTIFICIAL (decl)
-         && ! TREE_PUBLIC (decl))
+         && ! TREE_PUBLIC (decl)
+         && (warn_unused_function
+             || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
        {
          if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
            pedwarn ("%J'%F' used but never defined", decl, decl);
@@ -1624,8 +1692,6 @@ compile_file (void)
 
   dw2_output_indirect_constants ();
 
-  targetm.asm_out.file_end ();
-
   /* Attach a special .ident directive to the end of the file to identify
      the version of GCC which compiled this code.  The format of the .ident
      string is patterned after the ones produced by native SVR4 compilers.  */
@@ -1634,6 +1700,11 @@ compile_file (void)
     fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
             IDENT_ASM_OP, version_string);
 #endif
+
+  /* This must be at the end.  Some target ports emit end of file directives
+     into the assembly file here, and hence we can not output anything to the
+     assembly file after this point.  */
+  targetm.asm_out.file_end ();
 }
 
 /* Display help for target options.  */
@@ -1968,7 +2039,7 @@ init_asm_output (const char *name)
       if (!strcmp (asm_file_name, "-"))
        asm_out_file = stdout;
       else
-       asm_out_file = fopen (asm_file_name, "w+");
+       asm_out_file = fopen (asm_file_name, "w+b");
       if (asm_out_file == 0)
        fatal_error ("can't open %s for writing: %m", asm_file_name);
     }
@@ -2201,6 +2272,7 @@ general_init (const char *argv0)
 
   /* This must be done after add_params but before argument processing.  */
   init_ggc_heuristics();
+  init_tree_optimization_passes ();
 }
 
 /* Process the options that have been parsed.  */
@@ -2219,6 +2291,9 @@ process_options (void)
   OVERRIDE_OPTIONS;
 #endif
 
+  if (flag_short_enums == 2)
+    flag_short_enums = targetm.default_short_enums ();
+
   /* Set aux_base_name if not already set.  */
   if (aux_base_name)
     ;
@@ -2298,6 +2373,11 @@ process_options (void)
     warning ("this target machine does not have delayed branches");
 #endif
 
+  if (flag_tree_based_profiling && flag_test_coverage)
+    sorry ("test-coverage not yet implemented in trees.");
+  if (flag_tree_based_profiling && flag_profile_values)
+    sorry ("value-based profiling not yet implemented in trees.");
+
   user_label_prefix = USER_LABEL_PREFIX;
   if (flag_leading_underscore != -1)
     {
@@ -2335,6 +2415,30 @@ process_options (void)
 
   /* Now we know write_symbols, set up the debug hooks based on it.
      By default we do nothing for debug output.  */
+  if (PREFERRED_DEBUGGING_TYPE == NO_DEBUG)
+    default_debug_hooks = &do_nothing_debug_hooks;
+#if defined(DBX_DEBUGGING_INFO)
+  else if (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG)
+    default_debug_hooks = &dbx_debug_hooks;
+#endif
+#if defined(XCOFF_DEBUGGING_INFO)
+  else if (PREFERRED_DEBUGGING_TYPE == XCOFF_DEBUG)
+    default_debug_hooks = &xcoff_debug_hooks;
+#endif
+#ifdef SDB_DEBUGGING_INFO
+  else if (PREFERRED_DEBUGGING_TYPE == SDB_DEBUG)
+    default_debug_hooks = &sdb_debug_hooks;
+#endif
+#ifdef DWARF2_DEBUGGING_INFO
+  else if (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG)
+    default_debug_hooks = &dwarf2_debug_hooks;
+#endif
+#ifdef VMS_DEBUGGING_INFO
+  else if (PREFERRED_DEBUGGING_TYPE == VMS_DEBUG
+          || PREFERRED_DEBUGGING_TYPE == VMS_AND_DWARF2_DEBUG)
+    default_debug_hooks = &vmsdbg_debug_hooks;
+#endif
+
   if (write_symbols == NO_DEBUG)
     debug_hooks = &do_nothing_debug_hooks;
 #if defined(DBX_DEBUGGING_INFO)
@@ -2362,15 +2466,34 @@ process_options (void)
           debug_type_names[write_symbols]);
 
   /* Now we know which debug output will be used so we can set
-     flag_var_tracking if user has not specified it.  */
-  if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
+     flag_var_tracking, flag_rename_registers and flag_web if the user has
+     not specified them.  */
+  if (debug_info_level < DINFO_LEVEL_NORMAL
+      || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
     {
-      /* User has not specified -f(no-)var-tracking so autodetect it.  */
-      flag_var_tracking
-       = (optimize >= 1 && debug_info_level >= DINFO_LEVEL_NORMAL
-          && debug_hooks->var_location != do_nothing_debug_hooks.var_location);
+      if (flag_var_tracking == 1)
+        {
+         if (debug_info_level < DINFO_LEVEL_NORMAL)
+           warning ("variable tracking requested, but useless unless "
+                    "producing debug info");
+         else
+           warning ("variable tracking requested, but not supported "
+                    "by this debug format");
+       }
+      flag_var_tracking = 0;
     }
 
+  if (flag_rename_registers == AUTODETECT_FLAG_VAR_TRACKING)
+    flag_rename_registers = default_debug_hooks->var_location
+                           != do_nothing_debug_hooks.var_location;
+
+  if (flag_web == AUTODETECT_FLAG_VAR_TRACKING)
+    flag_web = optimize >= 2 && (default_debug_hooks->var_location
+                                != do_nothing_debug_hooks.var_location);
+
+  if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
+    flag_var_tracking = optimize >= 1;
+
   /* If auxiliary info generation is desired, open the output file.
      This goes in the same directory as the source file--unlike
      all the other output files.  */
@@ -2428,9 +2551,9 @@ process_options (void)
     warning ("-ffunction-sections may affect debugging on some targets");
 #endif
 
-    /* The presence of IEEE signaling NaNs, implies all math can trap.  */
-    if (flag_signaling_nans)
-      flag_trapping_math = 1;
+  /* The presence of IEEE signaling NaNs, implies all math can trap.  */
+  if (flag_signaling_nans)
+    flag_trapping_math = 1;
 }
 
 /* Initialize the compiler back end.  */