1 |
38 |
julius |
/* Interprocedural analyses.
|
2 |
|
|
Copyright (C) 2005, 2007 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is part of GCC.
|
5 |
|
|
|
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
|
8 |
|
|
Software Foundation; either version 3, or (at your option) any later
|
9 |
|
|
version.
|
10 |
|
|
|
11 |
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
12 |
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
13 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
14 |
|
|
for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with GCC; see the file COPYING3. If not see
|
18 |
|
|
<http://www.gnu.org/licenses/>. */
|
19 |
|
|
|
20 |
|
|
#ifndef IPA_PROP_H
|
21 |
|
|
#define IPA_PROP_H
|
22 |
|
|
|
23 |
|
|
#include "tree.h"
|
24 |
|
|
|
25 |
|
|
/* The following definitions and interfaces are used by
|
26 |
|
|
interprocedural analyses. */
|
27 |
|
|
|
28 |
|
|
/* A jump function for a callsite represents the values passed as actual
|
29 |
|
|
arguments of the callsite. There are three main types of values :
|
30 |
|
|
Formal - the caller's formal parameter is passed as an actual argument.
|
31 |
|
|
Constant - a constant is passed as a an actual argument.
|
32 |
|
|
Unknown - neither of the above.
|
33 |
|
|
Integer and real constants are represented as CONST_IPATYPE and Fortran
|
34 |
|
|
constants are represented as CONST_IPATYPE_REF. */
|
35 |
|
|
enum jump_func_type
|
36 |
|
|
{
|
37 |
|
|
UNKNOWN_IPATYPE,
|
38 |
|
|
CONST_IPATYPE,
|
39 |
|
|
CONST_IPATYPE_REF,
|
40 |
|
|
FORMAL_IPATYPE
|
41 |
|
|
};
|
42 |
|
|
|
43 |
|
|
/* All formal parameters in the program have a cval computed by
|
44 |
|
|
the interprocedural stage of IPCP.
|
45 |
|
|
There are three main values of cval :
|
46 |
|
|
TOP - unknown.
|
47 |
|
|
BOTTOM - non constant.
|
48 |
|
|
CONSTANT_TYPE - constant value.
|
49 |
|
|
Cval of formal f will have a constant value if all callsites to this
|
50 |
|
|
function have the same constant value passed to f.
|
51 |
|
|
Integer and real constants are represented as CONST_IPATYPE and Fortran
|
52 |
|
|
constants are represented as CONST_IPATYPE_REF. */
|
53 |
|
|
enum cvalue_type
|
54 |
|
|
{
|
55 |
|
|
BOTTOM,
|
56 |
|
|
CONST_VALUE,
|
57 |
|
|
CONST_VALUE_REF,
|
58 |
|
|
TOP
|
59 |
|
|
};
|
60 |
|
|
|
61 |
|
|
/* Represents the value of either jump function or cval.
|
62 |
|
|
value represents a constant.
|
63 |
|
|
formal_id is used only in jump function context and represents
|
64 |
|
|
pass-through parameter (the formal of caller is passed
|
65 |
|
|
as argument). */
|
66 |
|
|
union parameter_info
|
67 |
|
|
{
|
68 |
|
|
unsigned int formal_id;
|
69 |
|
|
tree value;
|
70 |
|
|
};
|
71 |
|
|
|
72 |
|
|
/* A jump function for a callsite represents the values passed as actual
|
73 |
|
|
arguments of the callsite. See enum jump_func_type for the various
|
74 |
|
|
types of jump functions supported. */
|
75 |
|
|
struct ipa_jump_func
|
76 |
|
|
{
|
77 |
|
|
enum jump_func_type type;
|
78 |
|
|
union parameter_info info_type;
|
79 |
|
|
};
|
80 |
|
|
|
81 |
|
|
/* All formal parameters in the program have a cval computed by
|
82 |
|
|
the interprocedural stage of IPCP. See enum cvalue_type for
|
83 |
|
|
the various types of cvals supported */
|
84 |
|
|
struct ipcp_formal
|
85 |
|
|
{
|
86 |
|
|
enum cvalue_type cval_type;
|
87 |
|
|
union parameter_info cvalue;
|
88 |
|
|
};
|
89 |
|
|
|
90 |
|
|
/* Represent which DECL tree (or reference to such tree)
|
91 |
|
|
will be replaced by another tree while versioning. */
|
92 |
|
|
struct ipa_replace_map
|
93 |
|
|
{
|
94 |
|
|
/* The tree that will be replaced. */
|
95 |
|
|
tree old_tree;
|
96 |
|
|
/* The new (replacing) tree. */
|
97 |
|
|
tree new_tree;
|
98 |
|
|
/* True when a substitution should be done, false otherwise. */
|
99 |
|
|
bool replace_p;
|
100 |
|
|
/* True when we replace a reference to old_tree. */
|
101 |
|
|
bool ref_p;
|
102 |
|
|
};
|
103 |
|
|
|
104 |
|
|
/* Return the field in cgraph_node/cgraph_edge struct that points
|
105 |
|
|
to ipa_node/ipa_edge struct. */
|
106 |
|
|
#define IPA_NODE_REF(MT) ((struct ipa_node *)(MT)->aux)
|
107 |
|
|
#define IPA_EDGE_REF(EDGE) ((struct ipa_edge *)(EDGE)->aux)
|
108 |
|
|
|
109 |
|
|
/* ipa_node stores information related to a method and
|
110 |
|
|
its formal parameters. It is pointed to by a field in the
|
111 |
|
|
method's corresponding cgraph_node.
|
112 |
|
|
|
113 |
|
|
ipa_edge stores information related to a callsite and
|
114 |
|
|
its arguments. It is pointed to by a field in the
|
115 |
|
|
callsite's corresponding cgraph_edge. */
|
116 |
|
|
struct ipa_node
|
117 |
|
|
{
|
118 |
|
|
/* Number of formal parameters of this method. When set to 0,
|
119 |
|
|
this method's parameters would not be analyzed by the different
|
120 |
|
|
stages of IPA CP. */
|
121 |
|
|
int ipa_arg_num;
|
122 |
|
|
/* Array of cvals. */
|
123 |
|
|
struct ipcp_formal *ipcp_cval;
|
124 |
|
|
/* Mapping each parameter to its PARM_DECL tree. */
|
125 |
|
|
tree *ipa_param_tree;
|
126 |
|
|
/* Indicating which parameter is modified in its method. */
|
127 |
|
|
bool *ipa_mod;
|
128 |
|
|
/* Only for versioned nodes this field would not be NULL,
|
129 |
|
|
it points to the node that IPA cp cloned from. */
|
130 |
|
|
struct cgraph_node *ipcp_orig_node;
|
131 |
|
|
/* Meaningful only for original methods. Expresses the
|
132 |
|
|
ratio between the direct calls and sum of all invocations of
|
133 |
|
|
this function (given by profiling info). It is used to calculate
|
134 |
|
|
the profiling information of the original function and the versioned
|
135 |
|
|
one. */
|
136 |
|
|
gcov_type count_scale;
|
137 |
|
|
};
|
138 |
|
|
|
139 |
|
|
struct ipa_edge
|
140 |
|
|
{
|
141 |
|
|
/* Number of actual arguments in this callsite. When set to 0,
|
142 |
|
|
this callsite's parameters would not be analyzed by the different
|
143 |
|
|
stages of IPA CP. */
|
144 |
|
|
int ipa_param_num;
|
145 |
|
|
/* Array of the callsite's jump function of each parameter. */
|
146 |
|
|
struct ipa_jump_func *ipa_param_map;
|
147 |
|
|
};
|
148 |
|
|
|
149 |
|
|
/* A methodlist element (referred to also as methodlist node). It is used
|
150 |
|
|
to create a temporary worklist used in
|
151 |
|
|
the propagation stage of IPCP. (can be used for more IPA
|
152 |
|
|
optimizations) */
|
153 |
|
|
struct ipa_methodlist
|
154 |
|
|
{
|
155 |
|
|
struct cgraph_node *method_p;
|
156 |
|
|
struct ipa_methodlist *next_method;
|
157 |
|
|
};
|
158 |
|
|
|
159 |
|
|
/* A pointer to a methodlist element. */
|
160 |
|
|
typedef struct ipa_methodlist *ipa_methodlist_p;
|
161 |
|
|
|
162 |
|
|
/* ipa_methodlist interface. */
|
163 |
|
|
ipa_methodlist_p ipa_methodlist_init (void);
|
164 |
|
|
bool ipa_methodlist_not_empty (ipa_methodlist_p);
|
165 |
|
|
void ipa_add_method (ipa_methodlist_p *, struct cgraph_node *);
|
166 |
|
|
struct cgraph_node *ipa_remove_method (ipa_methodlist_p *);
|
167 |
|
|
|
168 |
|
|
/* ipa_callsite interface. */
|
169 |
|
|
int ipa_callsite_param_count (struct cgraph_edge *);
|
170 |
|
|
void ipa_callsite_param_count_set (struct cgraph_edge *, int);
|
171 |
|
|
struct ipa_jump_func *ipa_callsite_param (struct cgraph_edge *, int);
|
172 |
|
|
struct cgraph_node *ipa_callsite_callee (struct cgraph_edge *);
|
173 |
|
|
void ipa_callsite_compute_param (struct cgraph_edge *);
|
174 |
|
|
void ipa_callsite_compute_count (struct cgraph_edge *);
|
175 |
|
|
|
176 |
|
|
/* ipa_method interface. */
|
177 |
|
|
int ipa_method_formal_count (struct cgraph_node *);
|
178 |
|
|
void ipa_method_formal_count_set (struct cgraph_node *, int);
|
179 |
|
|
tree ipa_method_get_tree (struct cgraph_node *, int);
|
180 |
|
|
void ipa_method_compute_tree_map (struct cgraph_node *);
|
181 |
|
|
void ipa_method_formal_compute_count (struct cgraph_node *);
|
182 |
|
|
void ipa_method_compute_modify (struct cgraph_node *);
|
183 |
|
|
|
184 |
|
|
/* jump function interface. */
|
185 |
|
|
enum jump_func_type get_type (struct ipa_jump_func *);
|
186 |
|
|
union parameter_info *ipa_jf_get_info_type (struct ipa_jump_func *);
|
187 |
|
|
|
188 |
|
|
/* ipa_node and ipa_edge interfaces. */
|
189 |
|
|
void ipa_node_create (struct cgraph_node *);
|
190 |
|
|
void ipa_free (void);
|
191 |
|
|
void ipa_nodes_create (void);
|
192 |
|
|
void ipa_edges_create (void);
|
193 |
|
|
void ipa_edges_free (void);
|
194 |
|
|
void ipa_nodes_free (void);
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
/* Debugging interface. */
|
198 |
|
|
void ipa_method_tree_print (FILE *);
|
199 |
|
|
void ipa_method_modify_print (FILE *);
|
200 |
|
|
|
201 |
|
|
unsigned int ipcp_driver (void);
|
202 |
|
|
|
203 |
|
|
#endif /* IPA_PROP_H */
|