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"
30 #include "target-globals.h"
34 #include "hard-reg-set.h"
45 #include "insn-codes.h"
52 #include "bb-reorder.h"
53 #include "lower-subreg.h"
57 struct target_globals default_target_globals
= {
58 &default_target_flag_state
,
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
,
69 &default_target_ira_int
,
70 &default_target_builtins
,
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
);
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
118 optimization_current_node
= optimization_default_node
;
119 cl_optimization_restore
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
));
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
);
150 XDELETE (bb_reorder
);
151 XDELETE (lower_subreg
);