]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/target-globals.c
use templates instead of gengtype for typed allocation functions
[thirdparty/gcc.git] / gcc / target-globals.c
CommitLineData
821d4118 1/* Target-dependent globals.
3aea1f79 2 Copyright (C) 2010-2014 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"
25#include "machmode.h"
41a8aa41 26#include "tree.h"
821d4118 27#include "ggc.h"
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"
2770cb33 36#include "expr.h"
37#include "optabs.h"
d0f03375 38#include "libfuncs.h"
e8aa5a28 39#include "cfgloop.h"
a1e0509e 40#include "ira-int.h"
c6a6cdaa 41#include "lra-int.h"
3b9c3a16 42#include "builtins.h"
049d15fc 43#include "gcse.h"
22d65d2c 44#include "bb-reorder.h"
c7944dce 45#include "lower-subreg.h"
821d4118 46
47#if SWITCHABLE_TARGET
48struct target_globals default_target_globals = {
c3460481 49 &default_target_flag_state,
679bcc8d 50 &default_target_regs,
6d0eb0c4 51 &default_target_rtl,
5f00384a 52 &default_target_hard_regs,
6ebe4c69 53 &default_target_reload,
2770cb33 54 &default_target_expmed,
d0f03375 55 &default_target_optabs,
e8aa5a28 56 &default_target_libfuncs,
a1e0509e 57 &default_target_cfgloop,
58 &default_target_ira,
3b9c3a16 59 &default_target_ira_int,
c6a6cdaa 60 &default_target_lra_int,
049d15fc 61 &default_target_builtins,
22d65d2c 62 &default_target_gcse,
c7944dce 63 &default_target_bb_reorder,
64 &default_target_lower_subreg
821d4118 65};
66
67struct target_globals *
68save_target_globals (void)
69{
70 struct target_globals *g;
6c427a80 71 struct target_globals_extra {
72 struct target_globals g;
73 struct target_flag_state flag_state;
74 struct target_optabs optabs;
75 struct target_cfgloop cfgloop;
76 struct target_builtins builtins;
77 struct target_gcse gcse;
78 struct target_bb_reorder bb_reorder;
79 struct target_lower_subreg lower_subreg;
80 } *p;
81 p = (struct target_globals_extra *)
ea7d8c7a 82 ggc_internal_cleared_alloc (sizeof (struct target_globals_extra));
6c427a80 83 g = (struct target_globals *) p;
84 g->flag_state = &p->flag_state;
ea7d8c7a 85 g->regs = ggc_internal_cleared_alloc (sizeof (struct target_regs));
25a27413 86 g->rtl = ggc_cleared_alloc<target_rtl> ();
6c427a80 87 g->hard_regs
ea7d8c7a 88 = ggc_internal_cleared_alloc (sizeof (struct target_hard_regs));
89 g->reload = ggc_internal_cleared_alloc (sizeof (struct target_reload));
90 g->expmed = ggc_internal_cleared_alloc (sizeof (struct target_expmed));
6c427a80 91 g->optabs = &p->optabs;
25a27413 92 g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
6c427a80 93 g->cfgloop = &p->cfgloop;
ea7d8c7a 94 g->ira = ggc_internal_cleared_alloc (sizeof (struct target_ira));
95 g->ira_int = ggc_internal_cleared_alloc (sizeof (struct target_ira_int));
96 g->lra_int = ggc_internal_cleared_alloc (sizeof (struct target_lra_int));
6c427a80 97 g->builtins = &p->builtins;
98 g->gcse = &p->gcse;
99 g->bb_reorder = &p->bb_reorder;
100 g->lower_subreg = &p->lower_subreg;
821d4118 101 restore_target_globals (g);
03a75ccf 102 init_reg_sets ();
821d4118 103 target_reinit ();
104 return g;
105}
106
08c7d04b 107/* Like save_target_globals() above, but set *this_target_optabs
108 correctly when a previous function has changed
109 *this_target_optabs. */
110
111struct target_globals *
112save_target_globals_default_opts ()
113{
114 struct target_globals *globals;
115
116 if (optimization_current_node != optimization_default_node)
117 {
118 tree opts = optimization_current_node;
119 /* Temporarily switch to the default optimization node, so that
120 *this_target_optabs is set to the default, not reflecting
121 whatever a previous function used for the optimize
122 attribute. */
123 optimization_current_node = optimization_default_node;
124 cl_optimization_restore
125 (&global_options,
126 TREE_OPTIMIZATION (optimization_default_node));
127 globals = save_target_globals ();
128 optimization_current_node = opts;
129 cl_optimization_restore (&global_options,
130 TREE_OPTIMIZATION (opts));
131 return globals;
132 }
133 return save_target_globals ();
134}
135
821d4118 136#endif