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