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
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
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/>. */
22 #include "coretypes.h"
24 #include "insn-config.h"
28 #include "target-globals.h"
41 #include "insn-codes.h"
42 #include "optabs-query.h"
46 #include "alloc-pool.h"
50 #include "bb-reorder.h"
51 #include "lower-subreg.h"
54 struct target_globals default_target_globals
= {
55 &default_target_flag_state
,
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
,
66 &default_target_ira_int
,
67 &default_target_builtins
,
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
);
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
115 optimization_current_node
= optimization_default_node
;
116 cl_optimization_restore
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
));
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
);
147 XDELETE (bb_reorder
);
148 XDELETE (lower_subreg
);