2015-09-25 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / target-globals.c
blob54b8517d3696c512d8acdd7ed460e045c0710092
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 "backend.h"
24 #include "insn-config.h"
25 #include "alias.h"
26 #include "tree.h"
27 #include "toplev.h"
28 #include "target-globals.h"
29 #include "flags.h"
30 #include "rtl.h"
31 #include "regs.h"
32 #include "reload.h"
33 #include "expmed.h"
34 #include "dojump.h"
35 #include "explow.h"
36 #include "calls.h"
37 #include "emit-rtl.h"
38 #include "varasm.h"
39 #include "stmt.h"
40 #include "expr.h"
41 #include "insn-codes.h"
42 #include "optabs-query.h"
43 #include "libfuncs.h"
44 #include "cfgloop.h"
45 #include "ira.h"
46 #include "alloc-pool.h"
47 #include "ira-int.h"
48 #include "builtins.h"
49 #include "gcse.h"
50 #include "bb-reorder.h"
51 #include "lower-subreg.h"
53 #if SWITCHABLE_TARGET
54 struct target_globals default_target_globals = {
55 &default_target_flag_state,
56 &default_target_regs,
57 &default_target_rtl,
58 &default_target_recog,
59 &default_target_hard_regs,
60 &default_target_reload,
61 &default_target_expmed,
62 &default_target_optabs,
63 &default_target_libfuncs,
64 &default_target_cfgloop,
65 &default_target_ira,
66 &default_target_ira_int,
67 &default_target_builtins,
68 &default_target_gcse,
69 &default_target_bb_reorder,
70 &default_target_lower_subreg
73 struct target_globals *
74 save_target_globals (void)
76 struct target_globals *g = ggc_cleared_alloc <target_globals> ();
77 g->flag_state = XCNEW (struct target_flag_state);
78 g->regs = XCNEW (struct target_regs);
79 g->rtl = ggc_cleared_alloc<target_rtl> ();
80 g->recog = XCNEW (struct target_recog);
81 g->hard_regs = XCNEW (struct target_hard_regs);
82 g->reload = XCNEW (struct target_reload);
83 g->expmed = XCNEW (struct target_expmed);
84 g->optabs = XCNEW (struct target_optabs);
85 g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
86 g->cfgloop = XCNEW (struct target_cfgloop);
87 g->ira = XCNEW (struct target_ira);
88 g->ira_int = XCNEW (struct target_ira_int);
89 g->builtins = XCNEW (struct target_builtins);
90 g->gcse = XCNEW (struct target_gcse);
91 g->bb_reorder = XCNEW (struct target_bb_reorder);
92 g->lower_subreg = XCNEW (struct target_lower_subreg);
93 restore_target_globals (g);
94 init_reg_sets ();
95 target_reinit ();
96 return g;
99 /* Like save_target_globals() above, but set *this_target_optabs
100 correctly when a previous function has changed
101 *this_target_optabs. */
103 struct target_globals *
104 save_target_globals_default_opts ()
106 struct target_globals *globals;
108 if (optimization_current_node != optimization_default_node)
110 tree opts = optimization_current_node;
111 /* Temporarily switch to the default optimization node, so that
112 *this_target_optabs is set to the default, not reflecting
113 whatever a previous function used for the optimize
114 attribute. */
115 optimization_current_node = optimization_default_node;
116 cl_optimization_restore
117 (&global_options,
118 TREE_OPTIMIZATION (optimization_default_node));
119 globals = save_target_globals ();
120 optimization_current_node = opts;
121 cl_optimization_restore (&global_options,
122 TREE_OPTIMIZATION (opts));
123 return globals;
125 return save_target_globals ();
128 target_globals::~target_globals ()
130 /* default_target_globals points to static data so shouldn't be freed. */
131 if (this != &default_target_globals)
133 ira_int->~target_ira_int ();
134 hard_regs->finalize ();
135 XDELETE (flag_state);
136 XDELETE (regs);
137 XDELETE (recog);
138 XDELETE (hard_regs);
139 XDELETE (reload);
140 XDELETE (expmed);
141 XDELETE (optabs);
142 XDELETE (cfgloop);
143 XDELETE (ira);
144 XDELETE (ira_int);
145 XDELETE (builtins);
146 XDELETE (gcse);
147 XDELETE (bb_reorder);
148 XDELETE (lower_subreg);
152 #endif