diff gcc/target-globals.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 561a7518be6b
children 84e7813d76e9
line wrap: on
line diff
--- a/gcc/target-globals.c	Sun Aug 21 07:07:55 2011 +0900
+++ b/gcc/target-globals.c	Fri Oct 27 22:46:09 2017 +0900
@@ -1,5 +1,5 @@
 /* Target-dependent globals.
-   Copyright (C) 2010  Free Software Foundation, Inc.
+   Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -20,32 +20,33 @@
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
+#include "backend.h"
+#include "rtl.h"
+#include "tree.h"
+#include "expmed.h"
+#include "optabs-query.h"
 #include "insn-config.h"
-#include "machmode.h"
-#include "ggc.h"
+#include "regs.h"
+#include "memmodel.h"
+#include "ira.h"
+#include "ira-int.h"
 #include "toplev.h"
 #include "target-globals.h"
 #include "flags.h"
-#include "regs.h"
-#include "rtl.h"
-#include "hard-reg-set.h"
 #include "reload.h"
-#include "expmed.h"
-#include "expr.h"
-#include "optabs.h"
 #include "libfuncs.h"
 #include "cfgloop.h"
-#include "ira-int.h"
 #include "builtins.h"
 #include "gcse.h"
 #include "bb-reorder.h"
+#include "lower-subreg.h"
 
 #if SWITCHABLE_TARGET
 struct target_globals default_target_globals = {
   &default_target_flag_state,
   &default_target_regs,
   &default_target_rtl,
+  &default_target_recog,
   &default_target_hard_regs,
   &default_target_reload,
   &default_target_expmed,
@@ -56,33 +57,87 @@
   &default_target_ira_int,
   &default_target_builtins,
   &default_target_gcse,
-  &default_target_bb_reorder
+  &default_target_bb_reorder,
+  &default_target_lower_subreg
 };
 
 struct target_globals *
 save_target_globals (void)
 {
-  struct target_globals *g;
-
-  g = ggc_alloc_target_globals ();
+  struct target_globals *g = ggc_cleared_alloc <target_globals> ();
   g->flag_state = XCNEW (struct target_flag_state);
   g->regs = XCNEW (struct target_regs);
-  g->rtl = ggc_alloc_cleared_target_rtl ();
+  g->rtl = ggc_cleared_alloc<target_rtl> ();
+  g->recog = XCNEW (struct target_recog);
   g->hard_regs = XCNEW (struct target_hard_regs);
   g->reload = XCNEW (struct target_reload);
   g->expmed = XCNEW (struct target_expmed);
   g->optabs = XCNEW (struct target_optabs);
-  g->libfuncs = ggc_alloc_cleared_target_libfuncs ();
+  g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
   g->cfgloop = XCNEW (struct target_cfgloop);
   g->ira = XCNEW (struct target_ira);
   g->ira_int = XCNEW (struct target_ira_int);
   g->builtins = XCNEW (struct target_builtins);
   g->gcse = XCNEW (struct target_gcse);
   g->bb_reorder = XCNEW (struct target_bb_reorder);
+  g->lower_subreg = XCNEW (struct target_lower_subreg);
   restore_target_globals (g);
   init_reg_sets ();
   target_reinit ();
   return g;
 }
 
+/* Like save_target_globals() above, but set *this_target_optabs
+   correctly when a previous function has changed
+   *this_target_optabs.  */
+
+struct target_globals *
+save_target_globals_default_opts ()
+{
+  struct target_globals *globals;
+
+  if (optimization_current_node != optimization_default_node)
+    {
+      tree opts = optimization_current_node;
+      /* Temporarily switch to the default optimization node, so that
+	 *this_target_optabs is set to the default, not reflecting
+	 whatever a previous function used for the optimize
+	 attribute.  */
+      optimization_current_node = optimization_default_node;
+      cl_optimization_restore
+	(&global_options,
+	 TREE_OPTIMIZATION (optimization_default_node));
+      globals = save_target_globals ();
+      optimization_current_node = opts;
+      cl_optimization_restore (&global_options,
+			       TREE_OPTIMIZATION (opts));
+      return globals;
+    }
+  return save_target_globals ();
+}
+
+target_globals::~target_globals ()
+{
+  /* default_target_globals points to static data so shouldn't be freed.  */
+  if (this != &default_target_globals)
+    {
+      ira_int->~target_ira_int ();
+      hard_regs->finalize ();
+      XDELETE (flag_state);
+      XDELETE (regs);
+      XDELETE (recog);
+      XDELETE (hard_regs);
+      XDELETE (reload);
+      XDELETE (expmed);
+      XDELETE (optabs);
+      XDELETE (cfgloop);
+      XDELETE (ira);
+      XDELETE (ira_int);
+      XDELETE (builtins);
+      XDELETE (gcse);
+      XDELETE (bb_reorder);
+      XDELETE (lower_subreg);
+    }
+}
+
 #endif