aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-prop.h
diff options
context:
space:
mode:
authorMartin Jambor <jamborm@gcc.gnu.org>2008-04-30 12:01:59 +0200
committerMartin Jambor <jamborm@gcc.gnu.org>2008-04-30 12:01:59 +0200
commitdcd416e3ac292bbbc299721a38d1a2086aaf10ba (patch)
treeff058a8b1bda87ec158e8494ef3b7c7ac7a42b4a /gcc/ipa-prop.h
parentd79967325b69cd30814a5d69dba300a1b000281e (diff)
downloadgcc-dcd416e3ac292bbbc299721a38d1a2086aaf10ba.zip
gcc-dcd416e3ac292bbbc299721a38d1a2086aaf10ba.tar.gz
gcc-dcd416e3ac292bbbc299721a38d1a2086aaf10ba.tar.bz2
ipa-cp.c (ipcp_init_stage): Calls ipa_set_called_with_variable_arg instead of setting number of formal...
2008-04-30 Martin Jambor <mjambor@suse.cz> * ipa-cp.c (ipcp_init_stage): Calls ipa_set_called_with_variable_arg instead of setting number of formal parameters to zero. (ipcp_init_stage): Do not set the number of actual parameters to zero either. (ipcp_propagate_stage): Explicitly skipping all calls to nodes which are called with variable number of arguments. (ipcp_insert_stage): Explicitely skipping all nodes which are called with variable number of arguments. (ipcp_callsite_param_print): Skipps callsites to nodes with varaible number of parameters. * ipa-prop.h (struct ipa_node_params): Added flag called_with_var_arguments (ipa_set_param_count): Added. Changed sole setter to use it. (ipa_get_param_count): Added. All readers of param_count converted to use it instead. (ipa_set_called_with_variable_arg): Added. (ipa_is_called_with_var_arguments): Added. (ipa_get_ith_param): Added. All readers of param_decls converted to use it instead. (ipa_set_cs_argument_count): Added, sole writer to argument_count changed to use it. (ipa_get_cs_argument_count): Added, all readers of argument_count changed to cal it. (ipa_get_ith_jump_func): Added. Accessors of jump values changed to use it. * ipa-prop.h (struct ipcp_formal): Renamed to ipcp_lattice (struct ipcp_lattice): Renamed cval_type to type (struct ipa_node_params): ipcp_cval renamed to ipcp_lattices * ipa-cp.c (ipcp_cval_get_cvalue): Changed return value to tree (ipcp_cval_set_cvalue): Changed type of parameter value to tree (ipcp_insert_stage): Changed the type of variable cvalue to tree (ipcp_replace_map_create): Changed the type of parameter cvalue to tree (build_const_val): Changed the type of parameter cvalue to tree (ipcp_propagate_const): Changed the type of parameter cvalue to tree (ipcp_method_cval_set_cvalue_type): Renamed parameter cval_type1 to type * ipa-prop.h (struct ipcp_formal): Replaced cvalue with tree called constant * ipa-prop.c (ipa_methodlist_init): Renamed to ipa_init_func_list (ipa_methodlist_not_empty): Removed, the sole user now checks directly (ipa_add_method): Renamed to ipa_push_func_to_list (ipa_remove_method): Renamed to ipa_pop_func_from_list (ipa_callsite_param_count): Removed. (ipa_callsite_param_count_set): Removed. (ipa_callsite_param): Removed. (ipa_callsite_callee): Removed. (ipa_callsite_compute_param): Renamed to ipa_compute_jump_functions (ipa_callsite_compute_count): Renamed to ipa_count_arguments (ipa_method_formal_count): Removed. (ipa_method_formal_count_set): Removed. (ipa_method_get_tree): Removed. (ipa_method_tree_map_create): Removed. (ipa_method_compute_tree_map): Renamed to ipa_create_param_decls_array (ipa_create_param_decls_array): Creates the array itself (ipa_create_param_decls_array): Temporary variable info instead of a few dereferences. (ipa_method_formal_compute_count): Renamed to ipa_count_formal_params (ipa_method_compute_modify): Renamed to ipa_detect_param_modifications (get_type): Removed. (ipa_jf_get_info_type): Removed. (ipa_node_create): Renamed to ipa_create_node_params (ipa_free): Renamed to ipa_free_all_node_params (ipa_nodes_create): Renamed to ipa_create_all_node_params (ipa_edges_create): Renamed to ipa_create_all_edge_args (ipa_edges_free): Renamed to ipa_free_all_edge_args (ipa_nodes_free): Integrated into ipa_free_all_node_params and removed (ipa_free_all_node_params): Deallocation to jump_functions moved to ipa_free_all_edge_args (ipa_method_tree_print): Renamed to ipa_print_all_tree_maps (ipa_method_modify_print): Renamed to ipa_print_all_params_modified (ipa_create_methodlist_node): Removed. (ipa_methodlist_method): Removed. (ipa_methodlist_method_set): Removed. (ipa_methodlist_next_method): Removed. (ipa_methodlist_next_method_set): Removed. (ipa_method_is_modified): Removed. (ipa_method_modify_create): Removed. (ipa_method_modify_init): Temporary variable info instead of a few dereferences. (ipa_detect_param_modifications): Temporary variable info instead of a few dereferences. (ipa_compute_jump_functions): Temporary variable info instead of a few dereferences. (ipa_method_modify_set): Removed. (ipa_method_tree_map): Renamed to ipa_get_param_decl_index (ipa_get_param_decl_index): Now accepts struct ipa_node_params rather than craph_node as the first parameter. (ipa_method_modify_stmt): Renamed to ipa_check_stmt_modifications (ipa_method_modify_init): Removed. (ipa_compute_jump_functions): Added a temp variable instead of repeatadly dereferencing the cgraph_edge.aux pointer (ipa_callsite_param_set_type): Removed. (ipa_compute_jump_functions): i renamed to index and moved to an inner block (ipa_callsite_param_set_info_type_formal): Removed. (ipa_callsite_param_set_info_type): Removed. (ipa_callsite_param_map_create): Removed. (ipa_callsite_tree): Removed. (ipa_callsite_caller): Removed. (ipa_pop_func_from_list): return_method removed to return_func * ipa-prop.h (enum cvalue_type): Renamed to ipa_lattice_type, prefixed all values with IPA_. Changed all users. (enum jump_func_type): Rnamed UNKNOWN_IPATYPE to IPA_UNKNOWN, CONST_IPATYPE to IPA_CONST, CONST_IPATYPE_REF to IPA_CONST_REF and FORMAL_IPATYPE IPA_PASS_THROUGH. (union parameter_info): Renamed to jump_func_value. (union jump_func_value): Renamed value to constant (struct ipa_jump_func): Renamed info_type to value (struct ipa_node): Renamed to ipa_node_params (struct ipa_node_params): Renamed ipa_arg_num to param_count (struct ipa_node_params): Renamed ipa_param_tree to param_decls (struct ipa_node_params): Renamed ipa_mod to modified_flags (struct ipa_edge): Renamed to ipa_edge_args (struct ipa_edge_args): Renamed ipa_param_num to argument_count (struct ipa_edge_args): Renamed ipa_param_map to jump_functions (struct ipa_methodlist): Renamed to ipa_func_list (struct ipa_func_list): method_p renamed to node, next_method renamed to next (ipa_methodlist_p): Removed, switched all users to struct pointer (IS_VALID_TREE_MAP_INDEX): Renamed to IS_VALID_JUMP_FUNC_INDEX From-SVN: r134818
Diffstat (limited to 'gcc/ipa-prop.h')
-rw-r--r--gcc/ipa-prop.h255
1 files changed, 158 insertions, 97 deletions
diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h
index 3731dc9..3be7502 100644
--- a/gcc/ipa-prop.h
+++ b/gcc/ipa-prop.h
@@ -30,43 +30,42 @@ along with GCC; see the file COPYING3. If not see
Formal - the caller's formal parameter is passed as an actual argument.
Constant - a constant is passed as an actual argument.
Unknown - neither of the above.
- Integer and real constants are represented as CONST_IPATYPE and Fortran
- constants are represented as CONST_IPATYPE_REF. */
+ Integer and real constants are represented as IPA_CONST and Fortran
+ constants are represented as IPA_CONST_REF. */
enum jump_func_type
{
- UNKNOWN_IPATYPE,
- CONST_IPATYPE,
- CONST_IPATYPE_REF,
- FORMAL_IPATYPE
+ IPA_UNKNOWN,
+ IPA_CONST,
+ IPA_CONST_REF,
+ IPA_PASS_THROUGH
};
-/* All formal parameters in the program have a cval computed by
- the interprocedural stage of IPCP.
- There are three main values of cval :
+/* All formal parameters in the program have a lattice associated with it
+ computed by the interprocedural stage of IPCP.
+ There are three main values of the lattice:
TOP - unknown.
BOTTOM - non constant.
CONSTANT_TYPE - constant value.
Cval of formal f will have a constant value if all callsites to this
function have the same constant value passed to f.
- Integer and real constants are represented as CONST_IPATYPE and Fortran
- constants are represented as CONST_IPATYPE_REF. */
-enum cvalue_type
-{
- BOTTOM,
- CONST_VALUE,
- CONST_VALUE_REF,
- TOP
+ Integer and real constants are represented as IPA_CONST and Fortran
+ constants are represented as IPA_CONST_REF. */
+enum ipa_lattice_type
+{
+ IPA_BOTTOM,
+ IPA_CONST_VALUE,
+ IPA_CONST_VALUE_REF,
+ IPA_TOP
};
-/* Represents the value of either jump function or cval.
+/* Represents a value of a jump function.
value represents a constant.
formal_id is used only in jump function context and represents
- pass-through parameter (the formal of caller is passed
- as argument). */
-union parameter_info
+ pass-through parameter (the formal of caller is passed as argument). */
+union jump_func_value
{
unsigned int formal_id;
- tree value;
+ tree constant;
};
/* A jump function for a callsite represents the values passed as actual
@@ -75,16 +74,16 @@ union parameter_info
struct ipa_jump_func
{
enum jump_func_type type;
- union parameter_info info_type;
+ union jump_func_value value;
};
/* All formal parameters in the program have a cval computed by
- the interprocedural stage of IPCP. See enum cvalue_type for
- the various types of cvals supported */
-struct ipcp_formal
+ the interprocedural stage of IPCP. See enum ipa_lattice_type for
+ the various types of lattices supported */
+struct ipcp_lattice
{
- enum cvalue_type cval_type;
- union parameter_info cvalue;
+ enum ipa_lattice_type type;
+ tree constant;
};
/* Represent which DECL tree (or reference to such tree)
@@ -102,103 +101,165 @@ struct ipa_replace_map
};
/* Return the field in cgraph_node/cgraph_edge struct that points
- to ipa_node/ipa_edge struct. */
-#define IPA_NODE_REF(MT) ((struct ipa_node *)(MT)->aux)
-#define IPA_EDGE_REF(EDGE) ((struct ipa_edge *)(EDGE)->aux)
+ to ipa_node_params/ipa_edge_args struct. */
+#define IPA_NODE_REF(MT) ((struct ipa_node_params *)(MT)->aux)
+#define IPA_EDGE_REF(EDGE) ((struct ipa_edge_args *)(EDGE)->aux)
/* This macro checks validity of index returned by
- ipa_method_tree_map function. */
-#define IS_VALID_TREE_MAP_INDEX(I) ((I) != -1)
+ ipa_get_param_decl_index function. */
+#define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
-/* ipa_node stores information related to a method and
- its formal parameters. It is pointed to by a field in the
- method's corresponding cgraph_node.
+/* ipa_node_params stores information related to formal parameters of functions
+ and some other information for interprocedural passes that operate on
+ parameters (such as ipa-cp). */
- ipa_edge stores information related to a callsite and
- its arguments. It is pointed to by a field in the
- callsite's corresponding cgraph_edge. */
-struct ipa_node
+struct ipa_node_params
{
- /* Number of formal parameters of this method. When set to 0,
- this method's parameters would not be analyzed by the different
+ /* Number of formal parameters of this function. When set to 0,
+ this functions's parameters would not be analyzed by the different
stages of IPA CP. */
- int ipa_arg_num;
- /* Array of cvals. */
- struct ipcp_formal *ipcp_cval;
+ int param_count;
+ /* Array of lattices. */
+ struct ipcp_lattice *ipcp_lattices;
/* Mapping each parameter to its PARM_DECL tree. */
- tree *ipa_param_tree;
- /* Indicating which parameter is modified in its method. */
- bool *ipa_mod;
+ tree *param_decls;
+ /* Indicating which parameter is modified in its function. */
+ bool *modified_flags;
/* Only for versioned nodes this field would not be NULL,
it points to the node that IPA cp cloned from. */
struct cgraph_node *ipcp_orig_node;
- /* Meaningful only for original methods. Expresses the
+ /* Meaningful only for original functions. Expresses the
ratio between the direct calls and sum of all invocations of
this function (given by profiling info). It is used to calculate
the profiling information of the original function and the versioned
one. */
gcov_type count_scale;
+
+ /* Whether this fynction is called with variable number of actual
+ arguments. */
+ unsigned called_with_var_arguments : 1;
};
-struct ipa_edge
+/* ipa_node_params access functions. Please use these to access fields that
+ are or will be shared among various passes. */
+
+/* Set the number of formal parameters. */
+static inline void
+ipa_set_param_count (struct ipa_node_params *info, int count)
+{
+ info->param_count = count;
+}
+
+/* Return the number of formal parameters. */
+static inline int
+ipa_get_param_count (struct ipa_node_params *info)
+{
+ return info->param_count;
+}
+
+/* Returns the declaration of ith param of the corresponding node. Note there
+ is no setter function as this array is built just once using
+ ipa_create_param_decls_array. */
+static inline tree
+ipa_get_ith_param (struct ipa_node_params *info, int i)
+{
+ return info->param_decls[i];
+}
+
+/* Returns the modification flag corresponding o the ith paramterer. Note
+ there is no setter method as the goal is to set all flags when building the
+ array in ipa_detect_param_modifications. */
+static inline bool
+ipa_is_ith_param_modified (struct ipa_node_params *info, int i)
+{
+ return info->modified_flags[i];
+}
+
+/* Flag this node as having callers with variable number of arguments. */
+static inline void
+ipa_set_called_with_variable_arg (struct ipa_node_params *info)
+{
+ info->called_with_var_arguments = 1;
+}
+
+/* Have we detected this node was called with variable number of arguments? */
+static inline bool
+ipa_is_called_with_var_arguments (struct ipa_node_params *info)
+{
+ return info->called_with_var_arguments;
+}
+
+
+
+/* ipa_edge_args stores information related to a callsite and particularly
+ its arguments. It is pointed to by a field in the
+ callsite's corresponding cgraph_edge. */
+struct ipa_edge_args
{
/* Number of actual arguments in this callsite. When set to 0,
this callsite's parameters would not be analyzed by the different
stages of IPA CP. */
- int ipa_param_num;
+ int argument_count;
/* Array of the callsite's jump function of each parameter. */
- struct ipa_jump_func *ipa_param_map;
+ struct ipa_jump_func *jump_functions;
};
-/* A methodlist element (referred to also as methodlist node). It is used
- to create a temporary worklist used in
- the propagation stage of IPCP. (can be used for more IPA
- optimizations) */
-struct ipa_methodlist
+/* ipa_edge_args access functions. Please use these to access fields that
+ are or will be shared among various passes. */
+
+/* Set the number of actual arguments. */
+static inline void
+ipa_set_cs_argument_count (struct ipa_edge_args *args, int count)
{
- struct cgraph_node *method_p;
- struct ipa_methodlist *next_method;
+ args->argument_count = count;
+}
+
+/* Return the number of actual arguments. */
+static inline int
+ipa_get_cs_argument_count (struct ipa_edge_args *args)
+{
+ return args->argument_count;
+}
+
+/* Returns a pointer to the jump function for the ith argument. Please note
+ there is no setter function as jump functions are all set up in
+ ipa_compute_jump_functions. */
+static inline struct ipa_jump_func *
+ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
+{
+ return &args->jump_functions[i];
+}
+
+/* A function list element. It is used to create a temporary worklist used in
+ the propagation stage of IPCP. (can be used for more IPA optimizations) */
+struct ipa_func_list
+{
+ struct cgraph_node *node;
+ struct ipa_func_list *next;
};
-/* A pointer to a methodlist element. */
-typedef struct ipa_methodlist *ipa_methodlist_p;
-
-/* ipa_methodlist interface. */
-ipa_methodlist_p ipa_methodlist_init (void);
-bool ipa_methodlist_not_empty (ipa_methodlist_p);
-void ipa_add_method (ipa_methodlist_p *, struct cgraph_node *);
-struct cgraph_node *ipa_remove_method (ipa_methodlist_p *);
-
-/* ipa_callsite interface. */
-int ipa_callsite_param_count (struct cgraph_edge *);
-void ipa_callsite_param_count_set (struct cgraph_edge *, int);
-struct ipa_jump_func *ipa_callsite_param (struct cgraph_edge *, int);
-struct cgraph_node *ipa_callsite_callee (struct cgraph_edge *);
-void ipa_callsite_compute_param (struct cgraph_edge *);
-void ipa_callsite_compute_count (struct cgraph_edge *);
-
-/* ipa_method interface. */
-int ipa_method_formal_count (struct cgraph_node *);
-void ipa_method_formal_count_set (struct cgraph_node *, int);
-tree ipa_method_get_tree (struct cgraph_node *, int);
-void ipa_method_compute_tree_map (struct cgraph_node *);
-void ipa_method_formal_compute_count (struct cgraph_node *);
-void ipa_method_compute_modify (struct cgraph_node *);
-
-/* jump function interface. */
-enum jump_func_type get_type (struct ipa_jump_func *);
-union parameter_info *ipa_jf_get_info_type (struct ipa_jump_func *);
-
-/* ipa_node and ipa_edge interfaces. */
-void ipa_node_create (struct cgraph_node *);
-void ipa_free (void);
-void ipa_nodes_create (void);
-void ipa_edges_create (void);
-void ipa_edges_free (void);
-void ipa_nodes_free (void);
+/* ipa_func_list interface. */
+struct ipa_func_list *ipa_init_func_list (void);
+void ipa_push_func_to_list (struct ipa_func_list **, struct cgraph_node *);
+struct cgraph_node *ipa_pop_func_from_list (struct ipa_func_list **);
+
+/* Callsite related calculations. */
+void ipa_compute_jump_functions (struct cgraph_edge *);
+void ipa_count_arguments (struct cgraph_edge *);
+
+/* Function parameters related computations. */
+void ipa_count_formal_params (struct cgraph_node *);
+void ipa_create_param_decls_array (struct cgraph_node *);
+void ipa_detect_param_modifications (struct cgraph_node *);
+/* Creating and freeing ipa_node_params and ipa_edge_args. */
+void ipa_create_node_params (struct cgraph_node *);
+void ipa_free_all_node_params (void);
+void ipa_create_all_node_params (void);
+void ipa_create_all_edge_args (void);
+void ipa_free_all_edge_args (void);
/* Debugging interface. */
-void ipa_method_tree_print (FILE *);
-void ipa_method_modify_print (FILE *);
+void ipa_print_all_tree_maps (FILE *);
+void ipa_print_all_params_modified (FILE *);
#endif /* IPA_PROP_H */