comparison gcc/target-globals.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 561a7518be6b
children 84e7813d76e9
comparison
equal deleted inserted replaced
15:561a7518be6b 16:04ced10e8804
1 /* Target-dependent globals. 1 /* Target-dependent globals.
2 Copyright (C) 2010 Free Software Foundation, Inc. 2 Copyright (C) 2010-2017 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 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 7 the terms of the GNU General Public License as published by the Free
18 <http://www.gnu.org/licenses/>. */ 18 <http://www.gnu.org/licenses/>. */
19 19
20 #include "config.h" 20 #include "config.h"
21 #include "system.h" 21 #include "system.h"
22 #include "coretypes.h" 22 #include "coretypes.h"
23 #include "tm.h" 23 #include "backend.h"
24 #include "rtl.h"
25 #include "tree.h"
26 #include "expmed.h"
27 #include "optabs-query.h"
24 #include "insn-config.h" 28 #include "insn-config.h"
25 #include "machmode.h" 29 #include "regs.h"
26 #include "ggc.h" 30 #include "memmodel.h"
31 #include "ira.h"
32 #include "ira-int.h"
27 #include "toplev.h" 33 #include "toplev.h"
28 #include "target-globals.h" 34 #include "target-globals.h"
29 #include "flags.h" 35 #include "flags.h"
30 #include "regs.h"
31 #include "rtl.h"
32 #include "hard-reg-set.h"
33 #include "reload.h" 36 #include "reload.h"
34 #include "expmed.h"
35 #include "expr.h"
36 #include "optabs.h"
37 #include "libfuncs.h" 37 #include "libfuncs.h"
38 #include "cfgloop.h" 38 #include "cfgloop.h"
39 #include "ira-int.h"
40 #include "builtins.h" 39 #include "builtins.h"
41 #include "gcse.h" 40 #include "gcse.h"
42 #include "bb-reorder.h" 41 #include "bb-reorder.h"
42 #include "lower-subreg.h"
43 43
44 #if SWITCHABLE_TARGET 44 #if SWITCHABLE_TARGET
45 struct target_globals default_target_globals = { 45 struct target_globals default_target_globals = {
46 &default_target_flag_state, 46 &default_target_flag_state,
47 &default_target_regs, 47 &default_target_regs,
48 &default_target_rtl, 48 &default_target_rtl,
49 &default_target_recog,
49 &default_target_hard_regs, 50 &default_target_hard_regs,
50 &default_target_reload, 51 &default_target_reload,
51 &default_target_expmed, 52 &default_target_expmed,
52 &default_target_optabs, 53 &default_target_optabs,
53 &default_target_libfuncs, 54 &default_target_libfuncs,
54 &default_target_cfgloop, 55 &default_target_cfgloop,
55 &default_target_ira, 56 &default_target_ira,
56 &default_target_ira_int, 57 &default_target_ira_int,
57 &default_target_builtins, 58 &default_target_builtins,
58 &default_target_gcse, 59 &default_target_gcse,
59 &default_target_bb_reorder 60 &default_target_bb_reorder,
61 &default_target_lower_subreg
60 }; 62 };
61 63
62 struct target_globals * 64 struct target_globals *
63 save_target_globals (void) 65 save_target_globals (void)
64 { 66 {
65 struct target_globals *g; 67 struct target_globals *g = ggc_cleared_alloc <target_globals> ();
66
67 g = ggc_alloc_target_globals ();
68 g->flag_state = XCNEW (struct target_flag_state); 68 g->flag_state = XCNEW (struct target_flag_state);
69 g->regs = XCNEW (struct target_regs); 69 g->regs = XCNEW (struct target_regs);
70 g->rtl = ggc_alloc_cleared_target_rtl (); 70 g->rtl = ggc_cleared_alloc<target_rtl> ();
71 g->recog = XCNEW (struct target_recog);
71 g->hard_regs = XCNEW (struct target_hard_regs); 72 g->hard_regs = XCNEW (struct target_hard_regs);
72 g->reload = XCNEW (struct target_reload); 73 g->reload = XCNEW (struct target_reload);
73 g->expmed = XCNEW (struct target_expmed); 74 g->expmed = XCNEW (struct target_expmed);
74 g->optabs = XCNEW (struct target_optabs); 75 g->optabs = XCNEW (struct target_optabs);
75 g->libfuncs = ggc_alloc_cleared_target_libfuncs (); 76 g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
76 g->cfgloop = XCNEW (struct target_cfgloop); 77 g->cfgloop = XCNEW (struct target_cfgloop);
77 g->ira = XCNEW (struct target_ira); 78 g->ira = XCNEW (struct target_ira);
78 g->ira_int = XCNEW (struct target_ira_int); 79 g->ira_int = XCNEW (struct target_ira_int);
79 g->builtins = XCNEW (struct target_builtins); 80 g->builtins = XCNEW (struct target_builtins);
80 g->gcse = XCNEW (struct target_gcse); 81 g->gcse = XCNEW (struct target_gcse);
81 g->bb_reorder = XCNEW (struct target_bb_reorder); 82 g->bb_reorder = XCNEW (struct target_bb_reorder);
83 g->lower_subreg = XCNEW (struct target_lower_subreg);
82 restore_target_globals (g); 84 restore_target_globals (g);
83 init_reg_sets (); 85 init_reg_sets ();
84 target_reinit (); 86 target_reinit ();
85 return g; 87 return g;
86 } 88 }
87 89
90 /* Like save_target_globals() above, but set *this_target_optabs
91 correctly when a previous function has changed
92 *this_target_optabs. */
93
94 struct target_globals *
95 save_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
119 target_globals::~target_globals ()
120 {
121 /* default_target_globals points to static data so shouldn't be freed. */
122 if (this != &default_target_globals)
123 {
124 ira_int->~target_ira_int ();
125 hard_regs->finalize ();
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
88 #endif 143 #endif