OSDN Git Service

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