1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
  
     | 
    
      /* Target-dependent globals.
   Copyright (C) 2010-2024 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "expmed.h"
#include "optabs-query.h"
#include "insn-config.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 "reload.h"
#include "libfuncs.h"
#include "cfgloop.h"
#include "builtins.h"
#include "gcse.h"
#include "bb-reorder.h"
#include "lower-subreg.h"
#include "function-abi.h"
#include "tm_p.h"
#if SWITCHABLE_TARGET
class target_globals default_target_globals = {
  &default_target_flag_state,
  &default_target_regs,
  &default_target_rtl,
  &default_target_recog,
  &default_target_hard_regs,
  &default_target_function_abi_info,
  &default_target_reload,
  &default_target_expmed,
  &default_target_optabs,
  &default_target_libfuncs,
  &default_target_cfgloop,
  &default_target_ira,
  &default_target_ira_int,
  &default_target_builtins,
  &default_target_gcse,
  &default_target_bb_reorder,
  &default_target_lower_subreg,
  &default_target_constraints
};
class target_globals *
save_target_globals (void)
{
  class target_globals *g = ggc_cleared_alloc <target_globals> ();
  g->flag_state = XCNEW (class target_flag_state);
  g->regs = XCNEW (struct target_regs);
  g->rtl = ggc_cleared_alloc<target_rtl> ();
  g->recog = XCNEW (struct target_recog);
  g->hard_regs = XCNEW (struct target_hard_regs);
  g->function_abi_info = XCNEW (struct target_function_abi_info);
  g->reload = XCNEW (struct target_reload);
  g->expmed = XCNEW (struct target_expmed);
  g->optabs = XCNEW (struct target_optabs);
  g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
  g->cfgloop = XCNEW (struct target_cfgloop);
  g->ira = XCNEW (struct target_ira);
  g->ira_int = XCNEW (class 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);
  g->constraints = XCNEW (target_constraints);
  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.  */
class target_globals *
save_target_globals_default_opts ()
{
  class 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, &global_options_set,
	 TREE_OPTIMIZATION (optimization_default_node));
      globals = save_target_globals ();
      optimization_current_node = opts;
      cl_optimization_restore (&global_options, &global_options_set,
			       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 (function_abi_info);
      XDELETE (reload);
      XDELETE (expmed);
      XDELETE (optabs);
      XDELETE (cfgloop);
      XDELETE (ira);
      XDELETE (ira_int);
      XDELETE (builtins);
      XDELETE (gcse);
      XDELETE (bb_reorder);
      XDELETE (lower_subreg);
      XDELETE (constraints);
    }
}
#endif
 
     |