summaryrefslogtreecommitdiff
path: root/gcc/target-globals.c
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2014-09-09 12:12:06 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2014-09-09 12:12:06 +0000
commit1942d1a9e17406469aef7d38e927dd7a14f5b376 (patch)
treed22a546f0e257dd3a005547ab16d0d91106212a3 /gcc/target-globals.c
parentcb3037199c8e3ca9f7982ec3a0024f8ab007cfbb (diff)
bb-reorder.h (default_target_bb_reorder): Remove redundant GTY.
gcc/ * bb-reorder.h (default_target_bb_reorder): Remove redundant GTY. * builtins.h (default_target_builtins): Likewise. * gcse.h (default_target_gcse): Likewise. * target-globals.h (target_globals): Add a destructor. Convert void-pointer fields back to their real type and change from GTY((atomic)) to GTY((skip)). (restore_target_globals): Remove casts accordingly. * target-globals.c (save_target_globals): Use XCNEW rather than ggc_internal_cleared_alloc to allocate non-GC structures. Use ggc_cleared_alloc to allocate the target_globals structure itself. (target_globals::~target_globals): Define. From-SVN: r215063
Diffstat (limited to 'gcc/target-globals.c')
-rw-r--r--gcc/target-globals.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/gcc/target-globals.c b/gcc/target-globals.c
index ac661623fc6..5a9843f6bb9 100644
--- a/gcc/target-globals.c
+++ b/gcc/target-globals.c
@@ -67,37 +67,23 @@ struct target_globals default_target_globals = {
struct target_globals *
save_target_globals (void)
{
- struct target_globals *g;
- struct target_globals_extra {
- struct target_globals g;
- struct target_flag_state flag_state;
- struct target_optabs optabs;
- struct target_cfgloop cfgloop;
- struct target_builtins builtins;
- struct target_gcse gcse;
- struct target_bb_reorder bb_reorder;
- struct target_lower_subreg lower_subreg;
- } *p;
- p = (struct target_globals_extra *)
- ggc_internal_cleared_alloc (sizeof (struct target_globals_extra));
- g = (struct target_globals *) p;
- g->flag_state = &p->flag_state;
- g->regs = ggc_internal_cleared_alloc (sizeof (struct target_regs));
+ struct target_globals *g = ggc_cleared_alloc <target_globals> ();
+ g->flag_state = XCNEW (struct target_flag_state);
+ g->regs = XCNEW (struct target_regs);
g->rtl = ggc_cleared_alloc<target_rtl> ();
- g->recog = ggc_internal_cleared_alloc (sizeof (struct target_recog));
- g->hard_regs
- = ggc_internal_cleared_alloc (sizeof (struct target_hard_regs));
- g->reload = ggc_internal_cleared_alloc (sizeof (struct target_reload));
- g->expmed = ggc_internal_cleared_alloc (sizeof (struct target_expmed));
- g->optabs = &p->optabs;
+ g->recog = XCNEW (struct target_recog);
+ g->hard_regs = XCNEW (struct target_hard_regs);
+ g->reload = XCNEW (struct target_reload);
+ g->expmed = XCNEW (struct target_expmed);
+ g->optabs = XCNEW (struct target_optabs);
g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
- g->cfgloop = &p->cfgloop;
- g->ira = ggc_internal_cleared_alloc (sizeof (struct target_ira));
- g->ira_int = ggc_internal_cleared_alloc (sizeof (struct target_ira_int));
- g->builtins = &p->builtins;
- g->gcse = &p->gcse;
- g->bb_reorder = &p->bb_reorder;
- g->lower_subreg = &p->lower_subreg;
+ g->cfgloop = XCNEW (struct target_cfgloop);
+ g->ira = XCNEW (struct target_ira);
+ g->ira_int = XCNEW (struct target_ira_int);
+ g->builtins = XCNEW (struct target_builtins);
+ g->gcse = XCNEW (struct target_gcse);
+ g->bb_reorder = XCNEW (struct target_bb_reorder);
+ g->lower_subreg = XCNEW (struct target_lower_subreg);
restore_target_globals (g);
init_reg_sets ();
target_reinit ();
@@ -133,4 +119,26 @@ save_target_globals_default_opts ()
return save_target_globals ();
}
+target_globals::~target_globals ()
+{
+ /* default_target_globals points to static data so shouldn't be freed. */
+ if (this != &default_target_globals)
+ {
+ XDELETE (flag_state);
+ XDELETE (regs);
+ XDELETE (recog);
+ XDELETE (hard_regs);
+ XDELETE (reload);
+ XDELETE (expmed);
+ XDELETE (optabs);
+ XDELETE (cfgloop);
+ XDELETE (ira);
+ XDELETE (ira_int);
+ XDELETE (builtins);
+ XDELETE (gcse);
+ XDELETE (bb_reorder);
+ XDELETE (lower_subreg);
+ }
+}
+
#endif