OSDN Git Service

patch from Anil Paranjpe to fix H8/300 .ident problem.
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
index 650a260..bdffef7 100644 (file)
@@ -138,6 +138,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 +181,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;
@@ -249,13 +257,19 @@ 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. */
+
+int flag_reorder_blocks_and_partition = 0;
+
 /* Nonzero if functions should be reordered.  */
 
 int flag_reorder_functions = 0;
 
-/* Nonzero if registers should be renamed.  */
-
-int flag_rename_registers = 0;
+/* 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 ().  */
+int flag_rename_registers = AUTODETECT_FLAG_VAR_TRACKING;
 int flag_cprop_registers = 0;
 
 /* Nonzero for -pedantic switch: warn about anything
@@ -480,9 +494,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.  */
 
@@ -795,8 +811,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.
@@ -955,6 +969,7 @@ static const lang_independent_options f_options[] =
   {"branch-probabilities", &flag_branch_probabilities, 1 },
   {"profile", &profile_flag, 1 },
   {"reorder-blocks", &flag_reorder_blocks, 1 },
+  {"reorder-blocks-and-partition", &flag_reorder_blocks_and_partition, 1},
   {"reorder-functions", &flag_reorder_functions, 1 },
   {"rename-registers", &flag_rename_registers, 1 },
   {"cprop-registers", &flag_cprop_registers, 1 },
@@ -1056,7 +1071,12 @@ bool
 set_src_pwd (const char *pwd)
 {
   if (src_pwd)
-    return false;
+    {
+      if (strcmp (src_pwd, pwd) == 0)
+       return true;
+      else
+       return false;
+    }
 
   src_pwd = xstrdup (pwd);
   return true;
@@ -1613,8 +1633,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.  */
@@ -1623,6 +1641,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.  */
@@ -2324,6 +2347,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)
@@ -2351,15 +2398,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.  */