Implement TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS hook.
[official-gcc.git] / gcc / target-globals.c
blob6edb5827f4cf149416f8cde75af7c863f630e677
1 /* Target-dependent globals.
2 Copyright (C) 2010-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tm.h"
24 #include "insn-config.h"
25 #include "input.h"
26 #include "alias.h"
27 #include "symtab.h"
28 #include "tree.h"
29 #include "toplev.h"
30 #include "target-globals.h"
31 #include "flags.h"
32 #include "regs.h"
33 #include "rtl.h"
34 #include "hard-reg-set.h"
35 #include "reload.h"
36 #include "expmed.h"
37 #include "function.h"
38 #include "dojump.h"
39 #include "explow.h"
40 #include "calls.h"
41 #include "emit-rtl.h"
42 #include "varasm.h"
43 #include "stmt.h"
44 #include "expr.h"
45 #include "insn-codes.h"
46 #include "optabs.h"
47 #include "libfuncs.h"
48 #include "cfgloop.h"
49 #include "ira-int.h"
50 #include "builtins.h"
51 #include "gcse.h"
52 #include "bb-reorder.h"
53 #include "lower-subreg.h"
54 #include "recog.h"
56 #if SWITCHABLE_TARGET
57 struct target_globals default_target_globals = {
58 &default_target_flag_state,
59 &default_target_regs,
60 &default_target_rtl,
61 &default_target_recog,
62 &default_target_hard_regs,
63 &default_target_reload,
64 &default_target_expmed,
65 &default_target_optabs,
66 &default_target_libfuncs,
67 &default_target_cfgloop,
68 &default_target_ira,
69 &default_target_ira_int,
70 &default_target_builtins,
71 &default_target_gcse,
72 &default_target_bb_reorder,
73 &default_target_lower_subreg
76 struct target_globals *
77 save_target_globals (void)
79 struct target_globals *g = ggc_cleared_alloc <target_globals> ();
80 g->flag_state = XCNEW (struct target_flag_state);
81 g->regs = XCNEW (struct target_regs);
82 g->rtl = ggc_cleared_alloc<target_rtl> ();
83 g->recog = XCNEW (struct target_recog);
84 g->hard_regs = XCNEW (struct target_hard_regs);
85 g->reload = XCNEW (struct target_reload);
86 g->expmed = XCNEW (struct target_expmed);
87 g->optabs = XCNEW (struct target_optabs);
88 g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
89 g->cfgloop = XCNEW (struct target_cfgloop);
90 g->ira = XCNEW (struct target_ira);
91 g->ira_int = XCNEW (struct target_ira_int);
92 g->builtins = XCNEW (struct target_builtins);
93 g->gcse = XCNEW (struct target_gcse);
94 g->bb_reorder = XCNEW (struct target_bb_reorder);
95 g->lower_subreg = XCNEW (struct target_lower_subreg);
96 restore_target_globals (g);
97 init_reg_sets ();
98 target_reinit ();
99 return g;
102 /* Like save_target_globals() above, but set *this_target_optabs
103 correctly when a previous function has changed
104 *this_target_optabs. */
106 struct target_globals *
107 save_target_globals_default_opts ()
109 struct target_globals *globals;
111 if (optimization_current_node != optimization_default_node)
113 tree opts = optimization_current_node;
114 /* Temporarily switch to the default optimization node, so that
115 *this_target_optabs is set to the default, not reflecting
116 whatever a previous function used for the optimize
117 attribute. */
118 optimization_current_node = optimization_default_node;
119 cl_optimization_restore
120 (&global_options,
121 TREE_OPTIMIZATION (optimization_default_node));
122 globals = save_target_globals ();
123 optimization_current_node = opts;
124 cl_optimization_restore (&global_options,
125 TREE_OPTIMIZATION (opts));
126 return globals;
128 return save_target_globals ();
131 target_globals::~target_globals ()
133 /* default_target_globals points to static data so shouldn't be freed. */
134 if (this != &default_target_globals)
136 ira_int->~target_ira_int ();
137 hard_regs->finalize ();
138 XDELETE (flag_state);
139 XDELETE (regs);
140 XDELETE (recog);
141 XDELETE (hard_regs);
142 XDELETE (reload);
143 XDELETE (expmed);
144 XDELETE (optabs);
145 XDELETE (cfgloop);
146 XDELETE (ira);
147 XDELETE (ira_int);
148 XDELETE (builtins);
149 XDELETE (gcse);
150 XDELETE (bb_reorder);
151 XDELETE (lower_subreg);
155 #endif