]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/target-globals.c
[testsuite] Add missing dg-require-effective-target label_values
[thirdparty/gcc.git] / gcc / target-globals.c
CommitLineData
821d4118 1/* Target-dependent globals.
fbd26352 2 Copyright (C) 2010-2019 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"
9ef16211 23#include "backend.h"
7c29e30e 24#include "rtl.h"
25#include "tree.h"
7c29e30e 26#include "expmed.h"
27#include "optabs-query.h"
821d4118 28#include "insn-config.h"
7c29e30e 29#include "regs.h"
ad7b10a2 30#include "memmodel.h"
7c29e30e 31#include "ira.h"
32#include "ira-int.h"
821d4118 33#include "toplev.h"
34#include "target-globals.h"
35#include "flags.h"
5f00384a 36#include "reload.h"
d0f03375 37#include "libfuncs.h"
e8aa5a28 38#include "cfgloop.h"
3b9c3a16 39#include "builtins.h"
049d15fc 40#include "gcse.h"
22d65d2c 41#include "bb-reorder.h"
c7944dce 42#include "lower-subreg.h"
821d4118 43
44#if SWITCHABLE_TARGET
45struct target_globals default_target_globals = {
c3460481 46 &default_target_flag_state,
679bcc8d 47 &default_target_regs,
6d0eb0c4 48 &default_target_rtl,
d2b854bc 49 &default_target_recog,
5f00384a 50 &default_target_hard_regs,
6ebe4c69 51 &default_target_reload,
2770cb33 52 &default_target_expmed,
d0f03375 53 &default_target_optabs,
e8aa5a28 54 &default_target_libfuncs,
a1e0509e 55 &default_target_cfgloop,
56 &default_target_ira,
3b9c3a16 57 &default_target_ira_int,
049d15fc 58 &default_target_builtins,
22d65d2c 59 &default_target_gcse,
c7944dce 60 &default_target_bb_reorder,
61 &default_target_lower_subreg
821d4118 62};
63
64struct target_globals *
65save_target_globals (void)
66{
f6de51be 67 struct target_globals *g = ggc_cleared_alloc <target_globals> ();
68 g->flag_state = XCNEW (struct target_flag_state);
69 g->regs = XCNEW (struct target_regs);
25a27413 70 g->rtl = ggc_cleared_alloc<target_rtl> ();
f6de51be 71 g->recog = XCNEW (struct target_recog);
72 g->hard_regs = XCNEW (struct target_hard_regs);
73 g->reload = XCNEW (struct target_reload);
74 g->expmed = XCNEW (struct target_expmed);
75 g->optabs = XCNEW (struct target_optabs);
25a27413 76 g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
f6de51be 77 g->cfgloop = XCNEW (struct target_cfgloop);
78 g->ira = XCNEW (struct target_ira);
79 g->ira_int = XCNEW (struct target_ira_int);
80 g->builtins = XCNEW (struct target_builtins);
81 g->gcse = XCNEW (struct target_gcse);
82 g->bb_reorder = XCNEW (struct target_bb_reorder);
83 g->lower_subreg = XCNEW (struct target_lower_subreg);
821d4118 84 restore_target_globals (g);
03a75ccf 85 init_reg_sets ();
821d4118 86 target_reinit ();
87 return g;
88}
89
08c7d04b 90/* Like save_target_globals() above, but set *this_target_optabs
91 correctly when a previous function has changed
92 *this_target_optabs. */
93
94struct target_globals *
95save_target_globals_default_opts ()
96{
97 struct target_globals *globals;
98
99 if (optimization_current_node != optimization_default_node)
100 {
101 tree opts = optimization_current_node;
102 /* Temporarily switch to the default optimization node, so that
103 *this_target_optabs is set to the default, not reflecting
104 whatever a previous function used for the optimize
105 attribute. */
106 optimization_current_node = optimization_default_node;
107 cl_optimization_restore
108 (&global_options,
109 TREE_OPTIMIZATION (optimization_default_node));
110 globals = save_target_globals ();
111 optimization_current_node = opts;
112 cl_optimization_restore (&global_options,
113 TREE_OPTIMIZATION (opts));
114 return globals;
115 }
116 return save_target_globals ();
117}
118
f6de51be 119target_globals::~target_globals ()
120{
121 /* default_target_globals points to static data so shouldn't be freed. */
122 if (this != &default_target_globals)
123 {
bce266bd 124 ira_int->~target_ira_int ();
18d9a614 125 hard_regs->finalize ();
f6de51be 126 XDELETE (flag_state);
127 XDELETE (regs);
128 XDELETE (recog);
129 XDELETE (hard_regs);
130 XDELETE (reload);
131 XDELETE (expmed);
132 XDELETE (optabs);
133 XDELETE (cfgloop);
134 XDELETE (ira);
135 XDELETE (ira_int);
136 XDELETE (builtins);
137 XDELETE (gcse);
138 XDELETE (bb_reorder);
139 XDELETE (lower_subreg);
140 }
141}
142
821d4118 143#endif