]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/target-globals.c
re PR target/52555 (ICE unrecognizable insn with -ffast-math and __attribute__((optim...
[thirdparty/gcc.git] / gcc / target-globals.c
CommitLineData
3bd36029 1/* Target-dependent globals.
d1e082c2 2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
3bd36029
RS
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"
26#include "ggc.h"
27#include "toplev.h"
28#include "target-globals.h"
29#include "flags.h"
939dcd0d 30#include "regs.h"
5fb0e246 31#include "rtl.h"
6642445b 32#include "hard-reg-set.h"
d474db84 33#include "reload.h"
462f85ce 34#include "expmed.h"
4bcbfa03
RS
35#include "expr.h"
36#include "optabs.h"
3e9c326a 37#include "libfuncs.h"
4391924a 38#include "cfgloop.h"
afcc66c4 39#include "ira-int.h"
55a2c322 40#include "lra-int.h"
fa19795e 41#include "builtins.h"
7c6811fe 42#include "gcse.h"
76ee381a 43#include "bb-reorder.h"
af4ba423 44#include "lower-subreg.h"
3bd36029
RS
45
46#if SWITCHABLE_TARGET
47struct target_globals default_target_globals = {
939dcd0d 48 &default_target_flag_state,
5fb0e246 49 &default_target_regs,
6642445b 50 &default_target_rtl,
d474db84 51 &default_target_hard_regs,
462f85ce 52 &default_target_reload,
4bcbfa03 53 &default_target_expmed,
3e9c326a 54 &default_target_optabs,
4391924a 55 &default_target_libfuncs,
afcc66c4
RS
56 &default_target_cfgloop,
57 &default_target_ira,
fa19795e 58 &default_target_ira_int,
55a2c322 59 &default_target_lra_int,
7c6811fe 60 &default_target_builtins,
76ee381a 61 &default_target_gcse,
af4ba423
KZ
62 &default_target_bb_reorder,
63 &default_target_lower_subreg
3bd36029
RS
64};
65
66struct target_globals *
67save_target_globals (void)
68{
69 struct target_globals *g;
70
71 g = ggc_alloc_target_globals ();
72 g->flag_state = XCNEW (struct target_flag_state);
939dcd0d 73 g->regs = XCNEW (struct target_regs);
5fb0e246 74 g->rtl = ggc_alloc_cleared_target_rtl ();
6642445b 75 g->hard_regs = XCNEW (struct target_hard_regs);
d474db84 76 g->reload = XCNEW (struct target_reload);
462f85ce 77 g->expmed = XCNEW (struct target_expmed);
4bcbfa03 78 g->optabs = XCNEW (struct target_optabs);
3e9c326a 79 g->libfuncs = ggc_alloc_cleared_target_libfuncs ();
4391924a 80 g->cfgloop = XCNEW (struct target_cfgloop);
afcc66c4
RS
81 g->ira = XCNEW (struct target_ira);
82 g->ira_int = XCNEW (struct target_ira_int);
74c4a938 83 g->lra_int = XCNEW (struct target_lra_int);
fa19795e 84 g->builtins = XCNEW (struct target_builtins);
7c6811fe 85 g->gcse = XCNEW (struct target_gcse);
76ee381a 86 g->bb_reorder = XCNEW (struct target_bb_reorder);
af4ba423 87 g->lower_subreg = XCNEW (struct target_lower_subreg);
3bd36029 88 restore_target_globals (g);
77f55879 89 init_reg_sets ();
3bd36029
RS
90 target_reinit ();
91 return g;
92}
93
135204dd
AH
94/* Like save_target_globals() above, but set *this_target_optabs
95 correctly when a previous function has changed
96 *this_target_optabs. */
97
98struct target_globals *
99save_target_globals_default_opts ()
100{
101 struct target_globals *globals;
102
103 if (optimization_current_node != optimization_default_node)
104 {
105 tree opts = optimization_current_node;
106 /* Temporarily switch to the default optimization node, so that
107 *this_target_optabs is set to the default, not reflecting
108 whatever a previous function used for the optimize
109 attribute. */
110 optimization_current_node = optimization_default_node;
111 cl_optimization_restore
112 (&global_options,
113 TREE_OPTIMIZATION (optimization_default_node));
114 globals = save_target_globals ();
115 optimization_current_node = opts;
116 cl_optimization_restore (&global_options,
117 TREE_OPTIMIZATION (opts));
118 return globals;
119 }
120 return save_target_globals ();
121}
122
3bd36029 123#endif