00001 /* Interprocedural analyses. 00002 Copyright (C) 2005 Free Software Foundation, Inc. 00003 00004 This file is part of GCC. 00005 00006 GCC is free software; you can redistribute it and/or modify it under 00007 the terms of the GNU General Public License as published by the Free 00008 Software Foundation; either version 2, or (at your option) any later 00009 version. 00010 00011 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 00012 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00014 for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with GCC; see the file COPYING. If not, write to the Free 00018 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 00019 02110-1301, USA. */ 00020 00021 #ifndef IPA_PROP_H 00022 #define IPA_PROP_H 00023 00024 #include "tree.h" 00025 00026 /* The following definitions and interfaces are used by 00027 interprocedural analyses. */ 00028 00029 /* A jump function for a callsite represents the values passed as actual 00030 arguments of the callsite. There are three main types of values : 00031 Formal - the caller's formal parameter is passed as an actual argument. 00032 Constant - a constant is passed as a an actual argument. 00033 Unknown - neither of the above. 00034 Integer and real constants are represented as CONST_IPATYPE and Fortran 00035 constants are represented as CONST_IPATYPE_REF. */ 00036 enum jump_func_type 00037 { 00038 UNKNOWN_IPATYPE, 00039 CONST_IPATYPE, 00040 CONST_IPATYPE_REF, 00041 FORMAL_IPATYPE 00042 }; 00043 00044 /* All formal parameters in the program have a cval computed by 00045 the interprocedural stage of IPCP. 00046 There are three main values of cval : 00047 TOP - unknown. 00048 BOTTOM - non constant. 00049 CONSTANT_TYPE - constant value. 00050 Cval of formal f will have a constant value if all callsites to this 00051 function have the same constant value passed to f. 00052 Integer and real constants are represented as CONST_IPATYPE and Fortran 00053 constants are represented as CONST_IPATYPE_REF. */ 00054 enum cvalue_type 00055 { 00056 BOTTOM, 00057 CONST_VALUE, 00058 CONST_VALUE_REF, 00059 TOP 00060 }; 00061 00062 /* Represents the value of either jump function or cval. 00063 value represents a constant. 00064 formal_id is used only in jump function context and represents 00065 pass-through parameter (the formal of caller is passed 00066 as argument). */ 00067 union parameter_info 00068 { 00069 unsigned int formal_id; 00070 tree value; 00071 }; 00072 00073 /* A jump function for a callsite represents the values passed as actual 00074 arguments of the callsite. See enum jump_func_type for the various 00075 types of jump functions supported. */ 00076 struct ipa_jump_func 00077 { 00078 enum jump_func_type type; 00079 union parameter_info info_type; 00080 }; 00081 00082 /* All formal parameters in the program have a cval computed by 00083 the interprocedural stage of IPCP. See enum cvalue_type for 00084 the various types of cvals supported */ 00085 struct ipcp_formal 00086 { 00087 enum cvalue_type cval_type; 00088 union parameter_info cvalue; 00089 }; 00090 00091 /* Represent which DECL tree (or reference to such tree) 00092 will be replaced by another tree while versioning. */ 00093 struct ipa_replace_map 00094 { 00095 /* The tree that will be replaced. */ 00096 tree old_tree; 00097 /* The new (replacing) tree. */ 00098 tree new_tree; 00099 /* True when a substitution should be done, false otherwise. */ 00100 bool replace_p; 00101 /* True when we replace a reference to old_tree. */ 00102 bool ref_p; 00103 }; 00104 00105 /* Return the field in cgraph_node/cgraph_edge struct that points 00106 to ipa_node/ipa_edge struct. */ 00107 #define IPA_NODE_REF(MT) ((struct ipa_node *)(MT)->aux) 00108 #define IPA_EDGE_REF(EDGE) ((struct ipa_edge *)(EDGE)->aux) 00109 00110 /* ipa_node stores information related to a method and 00111 its formal parameters. It is pointed to by a field in the 00112 method's corresponding cgraph_node. 00113 00114 ipa_edge stores information related to a callsite and 00115 its arguments. It is pointed to by a field in the 00116 callsite's corresponding cgraph_edge. */ 00117 struct ipa_node 00118 { 00119 /* Number of formal parameters of this method. When set to 0, 00120 this method's parameters would not be analyzed by the different 00121 stages of IPA CP. */ 00122 int ipa_arg_num; 00123 /* Array of cvals. */ 00124 struct ipcp_formal *ipcp_cval; 00125 /* Mapping each parameter to its PARM_DECL tree. */ 00126 tree *ipa_param_tree; 00127 /* Indicating which parameter is modified in its method. */ 00128 bool *ipa_mod; 00129 /* Only for versioned nodes this field would not be NULL, 00130 it points to the node that IPA cp cloned from. */ 00131 struct cgraph_node *ipcp_orig_node; 00132 /* Meaningful only for original methods. Expresses the 00133 ratio between the direct calls and sum of all invocations of 00134 this function (given by profiling info). It is used to calculate 00135 the profiling information of the original function and the versioned 00136 one. */ 00137 gcov_type count_scale; 00138 }; 00139 00140 struct ipa_edge 00141 { 00142 /* Number of actual arguments in this callsite. When set to 0, 00143 this callsite's parameters would not be analyzed by the different 00144 stages of IPA CP. */ 00145 int ipa_param_num; 00146 /* Array of the callsite's jump function of each parameter. */ 00147 struct ipa_jump_func *ipa_param_map; 00148 }; 00149 00150 /* A methodlist element (referred to also as methodlist node). It is used 00151 to create a temporary worklist used in 00152 the propagation stage of IPCP. (can be used for more IPA 00153 optimizations) */ 00154 struct ipa_methodlist 00155 { 00156 struct cgraph_node *method_p; 00157 struct ipa_methodlist *next_method; 00158 }; 00159 00160 /* A pointer to a methodlist element. */ 00161 typedef struct ipa_methodlist *ipa_methodlist_p; 00162 00163 /* ipa_methodlist interface. */ 00164 ipa_methodlist_p ipa_methodlist_init (void); 00165 bool ipa_methodlist_not_empty (ipa_methodlist_p); 00166 void ipa_add_method (ipa_methodlist_p *, struct cgraph_node *); 00167 struct cgraph_node *ipa_remove_method (ipa_methodlist_p *); 00168 00169 /* ipa_callsite interface. */ 00170 int ipa_callsite_param_count (struct cgraph_edge *); 00171 void ipa_callsite_param_count_set (struct cgraph_edge *, int); 00172 struct ipa_jump_func *ipa_callsite_param (struct cgraph_edge *, int); 00173 struct cgraph_node *ipa_callsite_callee (struct cgraph_edge *); 00174 void ipa_callsite_compute_param (struct cgraph_edge *); 00175 void ipa_callsite_compute_count (struct cgraph_edge *); 00176 00177 /* ipa_method interface. */ 00178 int ipa_method_formal_count (struct cgraph_node *); 00179 void ipa_method_formal_count_set (struct cgraph_node *, int); 00180 tree ipa_method_get_tree (struct cgraph_node *, int); 00181 void ipa_method_compute_tree_map (struct cgraph_node *); 00182 void ipa_method_formal_compute_count (struct cgraph_node *); 00183 void ipa_method_compute_modify (struct cgraph_node *); 00184 00185 /* jump function interface. */ 00186 enum jump_func_type get_type (struct ipa_jump_func *); 00187 union parameter_info *ipa_jf_get_info_type (struct ipa_jump_func *); 00188 00189 /* ipa_node and ipa_edge interfaces. */ 00190 void ipa_node_create (struct cgraph_node *); 00191 void ipa_free (void); 00192 void ipa_nodes_create (void); 00193 void ipa_edges_create (void); 00194 void ipa_edges_free (void); 00195 void ipa_nodes_free (void); 00196 00197 00198 /* Debugging interface. */ 00199 void ipa_method_tree_print (FILE *); 00200 void ipa_method_modify_print (FILE *); 00201 00202 unsigned int ipcp_driver (void); 00203 00204 #endif /* IPA_PROP_H */
1.5.6