comparison gcc/ipa-prop.h @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents a06113de4d67
children b7f97abdc517
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
23 #include "tree.h" 23 #include "tree.h"
24 #include "vec.h" 24 #include "vec.h"
25 #include "cgraph.h" 25 #include "cgraph.h"
26 26
27 /* The following definitions and interfaces are used by 27 /* The following definitions and interfaces are used by
28 interprocedural analyses. */ 28 interprocedural analyses or parameters. */
29
30 /* ipa-prop.c stuff (ipa-cp, indirect inlining): */
29 31
30 /* A jump function for a callsite represents the values passed as actual 32 /* A jump function for a callsite represents the values passed as actual
31 arguments of the callsite. There are three main types of values : 33 arguments of the callsite. There are three main types of values :
32 Formal - the caller's formal parameter is passed as an actual argument. 34
33 Constant - a constant is passed as an actual argument. 35 Pass-through - the caller's formal parameter is passed as an actual
34 Unknown - neither of the above. 36 argument, possibly one simple operation performed on it.
35 Integer and real constants are represented as IPA_CONST. 37 Constant - a constant (is_gimple_ip_invariant)is passed as an actual
36 Finally, IPA_CONST_MEMBER_PTR stands for C++ member pointers constants. */ 38 argument.
39 Unknown - neither of the above.
40
41 IPA_JF_CONST_MEMBER_PTR stands for C++ member pointers, other constants are
42 represented with IPA_JF_CONST.
43
44 In addition to "ordinary" pass through functions represented by
45 IPA_JF_PASS_THROUGH, IPA_JF_ANCESTOR represents getting addresses of of
46 ancestor fields in C++ (e.g. &this_1(D)->D.1766.D.1756). */
37 enum jump_func_type 47 enum jump_func_type
38 { 48 {
39 IPA_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */ 49 IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */
40 IPA_CONST, 50 IPA_JF_CONST,
41 IPA_CONST_MEMBER_PTR, 51 IPA_JF_CONST_MEMBER_PTR,
42 IPA_PASS_THROUGH 52 IPA_JF_PASS_THROUGH,
53 IPA_JF_ANCESTOR
43 }; 54 };
44 55
45 /* All formal parameters in the program have a lattice associated with it 56 /* All formal parameters in the program have a lattice associated with it
46 computed by the interprocedural stage of IPCP. 57 computed by the interprocedural stage of IPCP.
47 There are three main values of the lattice: 58 There are three main values of the lattice:
48 IPA_TOP - unknown, 59 IPA_TOP - unknown,
49 IPA_BOTTOM - non constant, 60 IPA_BOTTOM - non constant,
50 IPA_CONST_VALUE - simple scalar constant, 61 IPA_CONST_VALUE - simple scalar constant,
51 Cval of formal f will have a constant value if all callsites to this 62 Cval of formal f will have a constant value if all callsites to this
52 function have the same constant value passed to f. 63 function have the same constant value passed to f.
53 Integer and real constants are represented as IPA_CONST. */ 64 Integer and real constants are represented as IPA_CONST_VALUE. */
54 enum ipa_lattice_type 65 enum ipa_lattice_type
55 { 66 {
56 IPA_BOTTOM, 67 IPA_BOTTOM,
57 IPA_CONST_VALUE, 68 IPA_CONST_VALUE,
58 IPA_TOP 69 IPA_TOP
59 }; 70 };
60 71
72
73 /* Structure holding data required to describe a pass-through jump function. */
74
75 struct GTY(()) ipa_pass_through_data
76 {
77 /* If an operation is to be performed on the original parameter, this is the
78 second (constant) operand. */
79 tree operand;
80 /* Number of the caller's formal parameter being passed. */
81 int formal_id;
82 /* Operation that is performed on the argument before it is passed on.
83 NOP_EXPR means no operation. Otherwise oper must be a simple binary
84 arithmetic operation where the caller's parameter is the first operand and
85 operand field from this structure is the second one. */
86 enum tree_code operation;
87 };
88
89 /* Structure holding data required to describe and ancestor pass throu
90 funkci. */
91
92 struct GTY(()) ipa_ancestor_jf_data
93 {
94 /* Offset of the field representing the ancestor. */
95 HOST_WIDE_INT offset;
96 /* TYpe of the result. */
97 tree type;
98 /* Number of the caller's formal parameter being passed. */
99 int formal_id;
100 };
101
61 /* Structure holding a C++ member pointer constant. Holds a pointer to the 102 /* Structure holding a C++ member pointer constant. Holds a pointer to the
62 method and delta offset. */ 103 method and delta offset. */
63 struct ipa_member_ptr_cst 104 struct GTY(()) ipa_member_ptr_cst
64 { 105 {
65 tree pfn; 106 tree pfn;
66 tree delta; 107 tree delta;
67 };
68
69 /* Represents a value of a jump function. formal_id is used only in jump
70 function context and represents pass-through parameter (the formal parameter
71 of the caller is passed as argument). constant represents the actual
72 constant in constant jump functions and member_cst holds constant c++ member
73 functions. */
74 union jump_func_value
75 {
76 unsigned int formal_id;
77 tree constant;
78 struct ipa_member_ptr_cst member_cst;
79 }; 108 };
80 109
81 /* A jump function for a callsite represents the values passed as actual 110 /* A jump function for a callsite represents the values passed as actual
82 arguments of the callsite. See enum jump_func_type for the various 111 arguments of the callsite. See enum jump_func_type for the various
83 types of jump functions supported. */ 112 types of jump functions supported. */
84 struct ipa_jump_func 113 struct GTY (()) ipa_jump_func
85 { 114 {
86 enum jump_func_type type; 115 enum jump_func_type type;
87 union jump_func_value value; 116 /* Represents a value of a jump function. pass_through is used only in jump
117 function context. constant represents the actual constant in constant jump
118 functions and member_cst holds constant c++ member functions. */
119 union jump_func_value
120 {
121 tree GTY ((tag ("IPA_JF_CONST"))) constant;
122 struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
123 struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
124 struct ipa_member_ptr_cst GTY ((tag ("IPA_JF_CONST_MEMBER_PTR"))) member_cst;
125 } GTY ((desc ("%1.type"))) value;
88 }; 126 };
89 127
90 /* All formal parameters in the program have a cval computed by 128 /* All formal parameters in the program have a cval computed by
91 the interprocedural stage of IPCP. See enum ipa_lattice_type for 129 the interprocedural stage of IPCP. See enum ipa_lattice_type for
92 the various types of lattices supported */ 130 the various types of lattices supported */
94 { 132 {
95 enum ipa_lattice_type type; 133 enum ipa_lattice_type type;
96 tree constant; 134 tree constant;
97 }; 135 };
98 136
99 /* Represent which DECL tree (or reference to such tree)
100 will be replaced by another tree while versioning. */
101 struct ipa_replace_map
102 {
103 /* The tree that will be replaced. */
104 tree old_tree;
105 /* The new (replacing) tree. */
106 tree new_tree;
107 /* True when a substitution should be done, false otherwise. */
108 bool replace_p;
109 /* True when we replace a reference to old_tree. */
110 bool ref_p;
111 };
112
113 /* Each instance of the following structure describes a statement that calls a 137 /* Each instance of the following structure describes a statement that calls a
114 function parameter. Those referring to statements within the same function 138 function parameter. Those referring to statements within the same function
115 are linked in a list. */ 139 are linked in a list. */
116 struct ipa_param_call_note 140 struct ipa_param_call_note
117 { 141 {
142 /* Expected number of executions: calculated in profile.c. */
143 gcov_type count;
118 /* Linked list's next */ 144 /* Linked list's next */
119 struct ipa_param_call_note *next; 145 struct ipa_param_call_note *next;
120 /* Statement that contains the call to the parameter above. */ 146 /* Statement that contains the call to the parameter above. */
121 gimple stmt; 147 gimple stmt;
148 /* When in LTO, we the above stmt will be NULL and we need an uid. */
149 unsigned int lto_stmt_uid;
122 /* Index of the parameter that is called. */ 150 /* Index of the parameter that is called. */
123 unsigned int formal_id; 151 int formal_id;
124 /* Expected number of executions: calculated in profile.c. */
125 gcov_type count;
126 /* Expected frequency of executions within the function. see cgraph_edge in 152 /* Expected frequency of executions within the function. see cgraph_edge in
127 cgraph.h for more on this. */ 153 cgraph.h for more on this. */
128 int frequency; 154 int frequency;
129 /* Depth of loop nest, 1 means no loop nest. */ 155 /* Depth of loop nest, 1 means no loop nest. */
130 int loop_nest; 156 unsigned short int loop_nest;
131 /* Set when we have already found the target to be a compile time constant 157 /* Set when we have already found the target to be a compile time constant
132 and turned this into an edge or when the note was found unusable for some 158 and turned this into an edge or when the note was found unusable for some
133 reason. */ 159 reason. */
134 bool processed; 160 bool processed;
135 }; 161 };
176 unsigned called_with_var_arguments : 1; 202 unsigned called_with_var_arguments : 1;
177 /* Whether the modification analysis has already been performed. */ 203 /* Whether the modification analysis has already been performed. */
178 unsigned modification_analysis_done : 1; 204 unsigned modification_analysis_done : 1;
179 /* Whether the param uses analysis has already been performed. */ 205 /* Whether the param uses analysis has already been performed. */
180 unsigned uses_analysis_done : 1; 206 unsigned uses_analysis_done : 1;
207 /* Whether the function is enqueued in an ipa_func_list. */
208 unsigned node_enqueued : 1;
181 }; 209 };
182 210
183 /* ipa_node_params access functions. Please use these to access fields that 211 /* ipa_node_params access functions. Please use these to access fields that
184 are or will be shared among various passes. */ 212 are or will be shared among various passes. */
185 213
250 278
251 279
252 /* ipa_edge_args stores information related to a callsite and particularly 280 /* ipa_edge_args stores information related to a callsite and particularly
253 its arguments. It is pointed to by a field in the 281 its arguments. It is pointed to by a field in the
254 callsite's corresponding cgraph_edge. */ 282 callsite's corresponding cgraph_edge. */
255 struct ipa_edge_args 283 typedef struct GTY(()) ipa_edge_args
256 { 284 {
257 /* Number of actual arguments in this callsite. When set to 0, 285 /* Number of actual arguments in this callsite. When set to 0,
258 this callsite's parameters would not be analyzed by the different 286 this callsite's parameters would not be analyzed by the different
259 stages of IPA CP. */ 287 stages of IPA CP. */
260 int argument_count; 288 int argument_count;
261 /* Array of the callsite's jump function of each parameter. */ 289 /* Array of the callsite's jump function of each parameter. */
262 struct ipa_jump_func *jump_functions; 290 struct ipa_jump_func GTY ((length ("%h.argument_count"))) *jump_functions;
263 }; 291 } ipa_edge_args_t;
264 292
265 /* ipa_edge_args access functions. Please use these to access fields that 293 /* ipa_edge_args access functions. Please use these to access fields that
266 are or will be shared among various passes. */ 294 are or will be shared among various passes. */
267 295
268 /* Set the number of actual arguments. */ 296 /* Set the number of actual arguments. */
291 return &args->jump_functions[i]; 319 return &args->jump_functions[i];
292 } 320 }
293 321
294 /* Vectors need to have typedefs of structures. */ 322 /* Vectors need to have typedefs of structures. */
295 typedef struct ipa_node_params ipa_node_params_t; 323 typedef struct ipa_node_params ipa_node_params_t;
296 typedef struct ipa_edge_args ipa_edge_args_t;
297 324
298 /* Types of vectors holding the infos. */ 325 /* Types of vectors holding the infos. */
299 DEF_VEC_O (ipa_node_params_t); 326 DEF_VEC_O (ipa_node_params_t);
300 DEF_VEC_ALLOC_O (ipa_node_params_t, heap); 327 DEF_VEC_ALLOC_O (ipa_node_params_t, heap);
301 DEF_VEC_O (ipa_edge_args_t); 328 DEF_VEC_O (ipa_edge_args_t);
302 DEF_VEC_ALLOC_O (ipa_edge_args_t, heap); 329 DEF_VEC_ALLOC_O (ipa_edge_args_t, gc);
303 330
304 /* Vector where the parameter infos are actually stored. */ 331 /* Vector where the parameter infos are actually stored. */
305 extern VEC (ipa_node_params_t, heap) *ipa_node_params_vector; 332 extern VEC (ipa_node_params_t, heap) *ipa_node_params_vector;
306 /* Vector where the parameter infos are actually stored. */ 333 /* Vector where the parameter infos are actually stored. */
307 extern VEC (ipa_edge_args_t, heap) *ipa_edge_args_vector; 334 extern GTY(()) VEC (ipa_edge_args_t, gc) *ipa_edge_args_vector;
308 335
309 /* Return the associated parameter/argument info corresponding to the given 336 /* Return the associated parameter/argument info corresponding to the given
310 node/edge. */ 337 node/edge. */
311 #define IPA_NODE_REF(NODE) (VEC_index (ipa_node_params_t, \ 338 #define IPA_NODE_REF(NODE) (VEC_index (ipa_node_params_t, \
312 ipa_node_params_vector, (NODE)->uid)) 339 ipa_node_params_vector, (NODE)->uid))
348 375
349 static inline void 376 static inline void
350 ipa_check_create_edge_args (void) 377 ipa_check_create_edge_args (void)
351 { 378 {
352 if (!ipa_edge_args_vector) 379 if (!ipa_edge_args_vector)
353 ipa_edge_args_vector = VEC_alloc (ipa_edge_args_t, heap, 380 ipa_edge_args_vector = VEC_alloc (ipa_edge_args_t, gc,
354 cgraph_edge_max_uid); 381 cgraph_edge_max_uid);
355 382
356 if (VEC_length (ipa_edge_args_t, ipa_edge_args_vector) 383 if (VEC_length (ipa_edge_args_t, ipa_edge_args_vector)
357 <= (unsigned) cgraph_edge_max_uid) 384 <= (unsigned) cgraph_edge_max_uid)
358 VEC_safe_grow_cleared (ipa_edge_args_t, heap, ipa_edge_args_vector, 385 VEC_safe_grow_cleared (ipa_edge_args_t, gc, ipa_edge_args_vector,
359 cgraph_edge_max_uid + 1); 386 cgraph_edge_max_uid + 1);
360 } 387 }
361 388
362 /* Returns true if the array of edge infos is large enough to accommodate an 389 /* Returns true if the array of edge infos is large enough to accommodate an
363 info for EDGE. The main purpose of this function is that debug dumping 390 info for EDGE. The main purpose of this function is that debug dumping
378 struct ipa_func_list *next; 405 struct ipa_func_list *next;
379 }; 406 };
380 407
381 /* ipa_func_list interface. */ 408 /* ipa_func_list interface. */
382 struct ipa_func_list *ipa_init_func_list (void); 409 struct ipa_func_list *ipa_init_func_list (void);
383 void ipa_push_func_to_list (struct ipa_func_list **, struct cgraph_node *); 410 void ipa_push_func_to_list_1 (struct ipa_func_list **, struct cgraph_node *,
411 struct ipa_node_params *);
384 struct cgraph_node *ipa_pop_func_from_list (struct ipa_func_list **); 412 struct cgraph_node *ipa_pop_func_from_list (struct ipa_func_list **);
413
414 /* Add cgraph NODE to the worklist WL if it is not already in one. */
415
416 static inline void
417 ipa_push_func_to_list (struct ipa_func_list **wl, struct cgraph_node *node)
418 {
419 struct ipa_node_params *info = IPA_NODE_REF (node);
420
421 if (!info->node_enqueued)
422 ipa_push_func_to_list_1 (wl, node, info);
423 }
385 424
386 /* Callsite related calculations. */ 425 /* Callsite related calculations. */
387 void ipa_compute_jump_functions (struct cgraph_edge *); 426 void ipa_compute_jump_functions (struct cgraph_edge *);
388 void ipa_count_arguments (struct cgraph_edge *); 427 void ipa_count_arguments (struct cgraph_edge *);
389 428
398 void ipa_print_node_params (FILE *, struct cgraph_node *node); 437 void ipa_print_node_params (FILE *, struct cgraph_node *node);
399 void ipa_print_all_params (FILE *); 438 void ipa_print_all_params (FILE *);
400 void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node); 439 void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
401 void ipa_print_all_jump_functions (FILE * f); 440 void ipa_print_all_jump_functions (FILE * f);
402 441
442 /* Structure to describe transformations of formal parameters and actual
443 arguments. Each instance describes one new parameter and they are meant to
444 be stored in a vector. Additionally, most users will probably want to store
445 adjustments about parameters that are being removed altogether so that SSA
446 names belonging to them can be replaced by SSA names of an artificial
447 variable. */
448 struct ipa_parm_adjustment
449 {
450 /* The original PARM_DECL itself, helpful for processing of the body of the
451 function itself. Intended for traversing function bodies.
452 ipa_modify_formal_parameters, ipa_modify_call_arguments and
453 ipa_combine_adjustments ignore this and use base_index.
454 ipa_modify_formal_parameters actually sets this. */
455 tree base;
456
457 /* Type of the new parameter. However, if by_ref is true, the real type will
458 be a pointer to this type. */
459 tree type;
460
461 /* The new declaration when creating/replacing a parameter. Created by
462 ipa_modify_formal_parameters, useful for functions modifying the body
463 accordingly. */
464 tree reduction;
465
466 /* New declaration of a substitute variable that we may use to replace all
467 non-default-def ssa names when a parm decl is going away. */
468 tree new_ssa_base;
469
470 /* If non-NULL and the original parameter is to be removed (copy_param below
471 is NULL), this is going to be its nonlocalized vars value. */
472 tree nonlocal_value;
473
474 /* Offset into the original parameter (for the cases when the new parameter
475 is a component of an original one). */
476 HOST_WIDE_INT offset;
477
478 /* Zero based index of the original parameter this one is based on. (ATM
479 there is no way to insert a new parameter out of the blue because there is
480 no need but if it arises the code can be easily exteded to do so.) */
481 int base_index;
482
483 /* This new parameter is an unmodified parameter at index base_index. */
484 unsigned copy_param : 1;
485
486 /* This adjustment describes a parameter that is about to be removed
487 completely. Most users will probably need to book keep those so that they
488 don't leave behinfd any non default def ssa names belonging to them. */
489 unsigned remove_param : 1;
490
491 /* The parameter is to be passed by reference. */
492 unsigned by_ref : 1;
493 };
494
495 typedef struct ipa_parm_adjustment ipa_parm_adjustment_t;
496 DEF_VEC_O (ipa_parm_adjustment_t);
497 DEF_VEC_ALLOC_O (ipa_parm_adjustment_t, heap);
498
499 typedef VEC (ipa_parm_adjustment_t, heap) *ipa_parm_adjustment_vec;
500
501 VEC(tree, heap) *ipa_get_vector_of_formal_parms (tree fndecl);
502 void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec,
503 const char *);
504 void ipa_modify_call_arguments (struct cgraph_edge *, gimple,
505 ipa_parm_adjustment_vec);
506 ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
507 ipa_parm_adjustment_vec);
508 void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
509
510 void ipa_prop_write_jump_functions (cgraph_node_set set);
511 void ipa_prop_read_jump_functions (void);
512 void ipa_update_after_lto_read (void);
513 void lto_ipa_fixup_call_notes (struct cgraph_node *, gimple *);
514
515 /* From tree-sra.c: */
516 bool build_ref_for_offset (tree *, tree, HOST_WIDE_INT, tree, bool);
517
403 #endif /* IPA_PROP_H */ 518 #endif /* IPA_PROP_H */