xref: /dflybsd-src/contrib/gcc-4.7/gcc/tree-inline.h (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino /* Tree inlining hooks and declarations.
2*e4b17023SJohn Marino    Copyright 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010
3*e4b17023SJohn Marino    Free Software Foundation, Inc.
4*e4b17023SJohn Marino    Contributed by Alexandre Oliva  <aoliva@redhat.com>
5*e4b17023SJohn Marino 
6*e4b17023SJohn Marino This file is part of GCC.
7*e4b17023SJohn Marino 
8*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify
9*e4b17023SJohn Marino it under the terms of the GNU General Public License as published by
10*e4b17023SJohn Marino the Free Software Foundation; either version 3, or (at your option)
11*e4b17023SJohn Marino any later version.
12*e4b17023SJohn Marino 
13*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful,
14*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
15*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*e4b17023SJohn Marino GNU General Public License for more details.
17*e4b17023SJohn Marino 
18*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
19*e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
20*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
21*e4b17023SJohn Marino 
22*e4b17023SJohn Marino #ifndef GCC_TREE_INLINE_H
23*e4b17023SJohn Marino #define GCC_TREE_INLINE_H
24*e4b17023SJohn Marino 
25*e4b17023SJohn Marino #include "vecir.h" /* For VEC(gimple,heap).  */
26*e4b17023SJohn Marino 
27*e4b17023SJohn Marino struct cgraph_edge;
28*e4b17023SJohn Marino 
29*e4b17023SJohn Marino /* Indicate the desired behavior wrt call graph edges.  We can either
30*e4b17023SJohn Marino    duplicate the edge (inlining, cloning), move the edge (versioning,
31*e4b17023SJohn Marino    parallelization), or move the edges of the clones (saving).  */
32*e4b17023SJohn Marino 
33*e4b17023SJohn Marino enum copy_body_cge_which
34*e4b17023SJohn Marino {
35*e4b17023SJohn Marino   CB_CGE_DUPLICATE,
36*e4b17023SJohn Marino   CB_CGE_MOVE,
37*e4b17023SJohn Marino   CB_CGE_MOVE_CLONES
38*e4b17023SJohn Marino };
39*e4b17023SJohn Marino 
40*e4b17023SJohn Marino /* Data required for function body duplication.  */
41*e4b17023SJohn Marino 
42*e4b17023SJohn Marino typedef struct copy_body_data
43*e4b17023SJohn Marino {
44*e4b17023SJohn Marino   /* FUNCTION_DECL for function being inlined, or in general the
45*e4b17023SJohn Marino      source function providing the original trees.  */
46*e4b17023SJohn Marino   tree src_fn;
47*e4b17023SJohn Marino 
48*e4b17023SJohn Marino   /* FUNCTION_DECL for function being inlined into, or in general
49*e4b17023SJohn Marino      the destination function receiving the new trees.  */
50*e4b17023SJohn Marino   tree dst_fn;
51*e4b17023SJohn Marino 
52*e4b17023SJohn Marino   /* Callgraph node of the source function.  */
53*e4b17023SJohn Marino   struct cgraph_node *src_node;
54*e4b17023SJohn Marino 
55*e4b17023SJohn Marino   /* Callgraph node of the destination function.  */
56*e4b17023SJohn Marino   struct cgraph_node *dst_node;
57*e4b17023SJohn Marino 
58*e4b17023SJohn Marino   /* struct function for function being inlined.  Usually this is the same
59*e4b17023SJohn Marino      as DECL_STRUCT_FUNCTION (src_fn), but can be different if saved_cfg
60*e4b17023SJohn Marino      and saved_eh are in use.  */
61*e4b17023SJohn Marino   struct function *src_cfun;
62*e4b17023SJohn Marino 
63*e4b17023SJohn Marino   /* The VAR_DECL for the return value.  */
64*e4b17023SJohn Marino   tree retvar;
65*e4b17023SJohn Marino 
66*e4b17023SJohn Marino   /* The map from local declarations in the inlined function to
67*e4b17023SJohn Marino      equivalents in the function into which it is being inlined.  */
68*e4b17023SJohn Marino   struct pointer_map_t *decl_map;
69*e4b17023SJohn Marino 
70*e4b17023SJohn Marino   /* Create a new decl to replace DECL in the destination function.  */
71*e4b17023SJohn Marino   tree (*copy_decl) (tree, struct copy_body_data *);
72*e4b17023SJohn Marino 
73*e4b17023SJohn Marino   /* Current BLOCK.  */
74*e4b17023SJohn Marino   tree block;
75*e4b17023SJohn Marino 
76*e4b17023SJohn Marino   /* GIMPLE_CALL if va arg parameter packs should be expanded or NULL
77*e4b17023SJohn Marino      is not.  */
78*e4b17023SJohn Marino   gimple gimple_call;
79*e4b17023SJohn Marino 
80*e4b17023SJohn Marino   /* Exception landing pad the inlined call lies in.  */
81*e4b17023SJohn Marino   int eh_lp_nr;
82*e4b17023SJohn Marino 
83*e4b17023SJohn Marino   /* Maps region and landing pad structures from the function being copied
84*e4b17023SJohn Marino      to duplicates created within the function we inline into.  */
85*e4b17023SJohn Marino   struct pointer_map_t *eh_map;
86*e4b17023SJohn Marino 
87*e4b17023SJohn Marino   /* We use the same mechanism do all sorts of different things.  Rather
88*e4b17023SJohn Marino      than enumerating the different cases, we categorize the behavior
89*e4b17023SJohn Marino      in the various situations.  */
90*e4b17023SJohn Marino 
91*e4b17023SJohn Marino   /* What to do with call graph edges.  */
92*e4b17023SJohn Marino   enum copy_body_cge_which transform_call_graph_edges;
93*e4b17023SJohn Marino 
94*e4b17023SJohn Marino   /* True if a new CFG should be created.  False for inlining, true for
95*e4b17023SJohn Marino      everything else.  */
96*e4b17023SJohn Marino   bool transform_new_cfg;
97*e4b17023SJohn Marino 
98*e4b17023SJohn Marino   /* True if RETURN_EXPRs should be transformed to just the contained
99*e4b17023SJohn Marino      MODIFY_EXPR.  The branch semantics of the return will be handled
100*e4b17023SJohn Marino      by manipulating the CFG rather than a statement.  */
101*e4b17023SJohn Marino   bool transform_return_to_modify;
102*e4b17023SJohn Marino 
103*e4b17023SJohn Marino   /* True if this statement will need to be regimplified.  */
104*e4b17023SJohn Marino   bool regimplify;
105*e4b17023SJohn Marino 
106*e4b17023SJohn Marino   /* True if trees should not be unshared.  */
107*e4b17023SJohn Marino   bool do_not_unshare;
108*e4b17023SJohn Marino 
109*e4b17023SJohn Marino   /* > 0 if we are remapping a type currently.  */
110*e4b17023SJohn Marino   int remapping_type_depth;
111*e4b17023SJohn Marino 
112*e4b17023SJohn Marino   /* A function to be called when duplicating BLOCK nodes.  */
113*e4b17023SJohn Marino   void (*transform_lang_insert_block) (tree);
114*e4b17023SJohn Marino 
115*e4b17023SJohn Marino   /* Statements that might be possibly folded.  */
116*e4b17023SJohn Marino   struct pointer_set_t *statements_to_fold;
117*e4b17023SJohn Marino 
118*e4b17023SJohn Marino   /* Entry basic block to currently copied body.  */
119*e4b17023SJohn Marino   struct basic_block_def *entry_bb;
120*e4b17023SJohn Marino 
121*e4b17023SJohn Marino   /* Debug statements that need processing.  */
122*e4b17023SJohn Marino   VEC(gimple,heap) *debug_stmts;
123*e4b17023SJohn Marino 
124*e4b17023SJohn Marino   /* A map from local declarations in the inlined function to
125*e4b17023SJohn Marino      equivalents in the function into which it is being inlined, where
126*e4b17023SJohn Marino      the originals have been mapped to a value rather than to a
127*e4b17023SJohn Marino      variable.  */
128*e4b17023SJohn Marino   struct pointer_map_t *debug_map;
129*e4b17023SJohn Marino } copy_body_data;
130*e4b17023SJohn Marino 
131*e4b17023SJohn Marino /* Weights of constructions for estimate_num_insns.  */
132*e4b17023SJohn Marino 
133*e4b17023SJohn Marino typedef struct eni_weights_d
134*e4b17023SJohn Marino {
135*e4b17023SJohn Marino   /* Cost per call.  */
136*e4b17023SJohn Marino   unsigned call_cost;
137*e4b17023SJohn Marino 
138*e4b17023SJohn Marino   /* Cost per indirect call.  */
139*e4b17023SJohn Marino   unsigned indirect_call_cost;
140*e4b17023SJohn Marino 
141*e4b17023SJohn Marino   /* Cost per call to a target specific builtin */
142*e4b17023SJohn Marino   unsigned target_builtin_call_cost;
143*e4b17023SJohn Marino 
144*e4b17023SJohn Marino   /* Cost of "expensive" div and mod operations.  */
145*e4b17023SJohn Marino   unsigned div_mod_cost;
146*e4b17023SJohn Marino 
147*e4b17023SJohn Marino   /* Cost for omp construct.  */
148*e4b17023SJohn Marino   unsigned omp_cost;
149*e4b17023SJohn Marino 
150*e4b17023SJohn Marino   /* Cost for tm transaction.  */
151*e4b17023SJohn Marino   unsigned tm_cost;
152*e4b17023SJohn Marino 
153*e4b17023SJohn Marino   /* Cost of return.  */
154*e4b17023SJohn Marino   unsigned return_cost;
155*e4b17023SJohn Marino 
156*e4b17023SJohn Marino   /* True when time of statemnt should be estimated.  Thus i.e
157*e4b17023SJohn Marino      cost of switch statement is logarithmic rather than linear in number
158*e4b17023SJohn Marino      of cases.  */
159*e4b17023SJohn Marino   bool time_based;
160*e4b17023SJohn Marino } eni_weights;
161*e4b17023SJohn Marino 
162*e4b17023SJohn Marino /* Weights that estimate_num_insns uses for heuristics in inlining.  */
163*e4b17023SJohn Marino 
164*e4b17023SJohn Marino extern eni_weights eni_inlining_weights;
165*e4b17023SJohn Marino 
166*e4b17023SJohn Marino /* Weights that estimate_num_insns uses to estimate the size of the
167*e4b17023SJohn Marino    produced code.  */
168*e4b17023SJohn Marino 
169*e4b17023SJohn Marino extern eni_weights eni_size_weights;
170*e4b17023SJohn Marino 
171*e4b17023SJohn Marino /* Weights that estimate_num_insns uses to estimate the time necessary
172*e4b17023SJohn Marino    to execute the produced code.  */
173*e4b17023SJohn Marino 
174*e4b17023SJohn Marino extern eni_weights eni_time_weights;
175*e4b17023SJohn Marino 
176*e4b17023SJohn Marino /* Function prototypes.  */
177*e4b17023SJohn Marino 
178*e4b17023SJohn Marino extern tree copy_tree_body_r (tree *, int *, void *);
179*e4b17023SJohn Marino extern void insert_decl_map (copy_body_data *, tree, tree);
180*e4b17023SJohn Marino 
181*e4b17023SJohn Marino unsigned int optimize_inline_calls (tree);
182*e4b17023SJohn Marino tree maybe_inline_call_in_expr (tree);
183*e4b17023SJohn Marino bool tree_inlinable_function_p (tree);
184*e4b17023SJohn Marino tree copy_tree_r (tree *, int *, void *);
185*e4b17023SJohn Marino tree copy_decl_no_change (tree decl, copy_body_data *id);
186*e4b17023SJohn Marino int estimate_move_cost (tree type);
187*e4b17023SJohn Marino int estimate_num_insns (gimple, eni_weights *);
188*e4b17023SJohn Marino int estimate_num_insns_fn (tree, eni_weights *);
189*e4b17023SJohn Marino int count_insns_seq (gimple_seq, eni_weights *);
190*e4b17023SJohn Marino bool tree_versionable_function_p (tree);
191*e4b17023SJohn Marino 
192*e4b17023SJohn Marino extern tree remap_decl (tree decl, copy_body_data *id);
193*e4b17023SJohn Marino extern tree remap_type (tree type, copy_body_data *id);
194*e4b17023SJohn Marino extern gimple_seq copy_gimple_seq_and_replace_locals (gimple_seq seq);
195*e4b17023SJohn Marino 
196*e4b17023SJohn Marino extern HOST_WIDE_INT estimated_stack_frame_size (struct cgraph_node *);
197*e4b17023SJohn Marino 
198*e4b17023SJohn Marino #endif /* GCC_TREE_INLINE_H */
199