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"
29 #include "target-globals.h"
33 #include "hard-reg-set.h"
44 #include "insn-codes.h"
51 #include "bb-reorder.h"
52 #include "lower-subreg.h"
56 struct target_globals default_target_globals
= {
57 &default_target_flag_state
,
60 &default_target_recog
,
61 &default_target_hard_regs
,
62 &default_target_reload
,
63 &default_target_expmed
,
64 &default_target_optabs
,
65 &default_target_libfuncs
,
66 &default_target_cfgloop
,
68 &default_target_ira_int
,
69 &default_target_builtins
,
71 &default_target_bb_reorder
,
72 &default_target_lower_subreg
75 struct target_globals
*
76 save_target_globals (void)
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
);
81 g
->rtl
= ggc_cleared_alloc
<target_rtl
> ();
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
);
87 g
->libfuncs
= ggc_cleared_alloc
<target_libfuncs
> ();
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
);
95 restore_target_globals (g
);
101 /* Like save_target_globals() above, but set *this_target_optabs
102 correctly when a previous function has changed
103 *this_target_optabs. */
105 struct target_globals
*
106 save_target_globals_default_opts ()
108 struct target_globals
*globals
;
110 if (optimization_current_node
!= optimization_default_node
)
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
117 optimization_current_node
= optimization_default_node
;
118 cl_optimization_restore
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
));
127 return save_target_globals ();
130 target_globals::~target_globals ()
132 /* default_target_globals points to static data so shouldn't be freed. */
133 if (this != &default_target_globals
)
135 ira_int
->~target_ira_int ();
136 hard_regs
->finalize ();
137 XDELETE (flag_state
);
149 XDELETE (bb_reorder
);
150 XDELETE (lower_subreg
);