2016-06-16 Hristian Kirtchev <kirtchev@adacore.com>
[official-gcc.git] / gcc / ipa-prop.h
blobe32d078edb3502d06fa02b7f205c0b55cb113b02
1 /* Interprocedural analyses.
2 Copyright (C) 2005-2016 Free Software Foundation, Inc.
4 This file is part of GCC.
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.
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.
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/>. */
20 #ifndef IPA_PROP_H
21 #define IPA_PROP_H
23 /* The following definitions and interfaces are used by
24 interprocedural analyses or parameters. */
26 #define IPA_UNDESCRIBED_USE -1
28 /* ipa-prop.c stuff (ipa-cp, indirect inlining): */
30 /* A jump function for a callsite represents the values passed as actual
31 arguments of the callsite. They were originally proposed in a paper called
32 "Interprocedural Constant Propagation", by David Callahan, Keith D Cooper,
33 Ken Kennedy, Linda Torczon in Comp86, pg 152-161. There are three main
34 types of values :
36 Pass-through - the caller's formal parameter is passed as an actual
37 argument, possibly one simple operation performed on it.
38 Constant - a constant (is_gimple_ip_invariant)is passed as an actual
39 argument.
40 Unknown - neither of the above.
42 IPA_JF_ANCESTOR is a special pass-through jump function, which means that
43 the result is an address of a part of the object pointed to by the formal
44 parameter to which the function refers. It is mainly intended to represent
45 getting addresses of ancestor fields in C++
46 (e.g. &this_1(D)->D.1766.D.1756). Note that if the original pointer is
47 NULL, ancestor jump function must behave like a simple pass-through.
49 Other pass-through functions can either simply pass on an unchanged formal
50 parameter or can apply one simple binary operation to it (such jump
51 functions are called polynomial).
53 Jump functions are computed in ipa-prop.c by function
54 update_call_notes_after_inlining. Some information can be lost and jump
55 functions degraded accordingly when inlining, see
56 update_call_notes_after_inlining in the same file. */
58 enum jump_func_type
60 IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */
61 IPA_JF_CONST, /* represented by field costant */
62 IPA_JF_PASS_THROUGH, /* represented by field pass_through */
63 IPA_JF_ANCESTOR /* represented by field ancestor */
66 struct ipa_cst_ref_desc;
68 /* Structure holding data required to describe a constant jump function. */
69 struct GTY(()) ipa_constant_data
71 /* THe value of the constant. */
72 tree value;
73 /* Pointer to the structure that describes the reference. */
74 struct ipa_cst_ref_desc GTY((skip)) *rdesc;
77 /* Structure holding data required to describe a pass-through jump function. */
79 struct GTY(()) ipa_pass_through_data
81 /* If an operation is to be performed on the original parameter, this is the
82 second (constant) operand. */
83 tree operand;
84 /* Number of the caller's formal parameter being passed. */
85 int formal_id;
86 /* Operation that is performed on the argument before it is passed on.
87 NOP_EXPR means no operation. Otherwise oper must be a simple binary
88 arithmetic operation where the caller's parameter is the first operand and
89 operand field from this structure is the second one. */
90 enum tree_code operation;
91 /* When the passed value is a pointer, it is set to true only when we are
92 certain that no write to the object it points to has occurred since the
93 caller functions started execution, except for changes noted in the
94 aggregate part of the jump function (see description of
95 ipa_agg_jump_function). The flag is used only when the operation is
96 NOP_EXPR. */
97 unsigned agg_preserved : 1;
100 /* Structure holding data required to describe an ancestor pass-through
101 jump function. */
103 struct GTY(()) ipa_ancestor_jf_data
105 /* Offset of the field representing the ancestor. */
106 HOST_WIDE_INT offset;
107 /* Number of the caller's formal parameter being passed. */
108 int formal_id;
109 /* Flag with the same meaning like agg_preserve in ipa_pass_through_data. */
110 unsigned agg_preserved : 1;
113 /* An element in an aggegate part of a jump function describing a known value
114 at a given offset. When it is part of a pass-through jump function with
115 agg_preserved set or an ancestor jump function with agg_preserved set, all
116 unlisted positions are assumed to be preserved but the value can be a type
117 node, which means that the particular piece (starting at offset and having
118 the size of the type) is clobbered with an unknown value. When
119 agg_preserved is false or the type of the containing jump function is
120 different, all unlisted parts are assumed to be unknown and all values must
121 fulfill is_gimple_ip_invariant. */
123 struct GTY(()) ipa_agg_jf_item
125 /* The offset at which the known value is located within the aggregate. */
126 HOST_WIDE_INT offset;
128 /* The known constant or type if this is a clobber. */
129 tree value;
133 /* Aggregate jump function - i.e. description of contents of aggregates passed
134 either by reference or value. */
136 struct GTY(()) ipa_agg_jump_function
138 /* Description of the individual items. */
139 vec<ipa_agg_jf_item, va_gc> *items;
140 /* True if the data was passed by reference (as opposed to by value). */
141 bool by_ref;
144 typedef struct ipa_agg_jump_function *ipa_agg_jump_function_p;
146 /* Info about pointer alignments. */
147 struct GTY(()) ipa_alignment
149 /* The data fields below are valid only if known is true. */
150 bool known;
151 /* See ptr_info_def and get_pointer_alignment_1 for description of these
152 two. */
153 unsigned align;
154 unsigned misalign;
157 /* A jump function for a callsite represents the values passed as actual
158 arguments of the callsite. See enum jump_func_type for the various
159 types of jump functions supported. */
160 struct GTY (()) ipa_jump_func
162 /* Aggregate contants description. See struct ipa_agg_jump_function and its
163 description. */
164 struct ipa_agg_jump_function agg;
166 /* Information about alignment of pointers. */
167 struct ipa_alignment alignment;
169 enum jump_func_type type;
170 /* Represents a value of a jump function. pass_through is used only in jump
171 function context. constant represents the actual constant in constant jump
172 functions and member_cst holds constant c++ member functions. */
173 union jump_func_value
175 struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
176 struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
177 struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
178 } GTY ((desc ("%1.type"))) value;
182 /* Return the constant stored in a constant jump functin JFUNC. */
184 static inline tree
185 ipa_get_jf_constant (struct ipa_jump_func *jfunc)
187 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
188 return jfunc->value.constant.value;
191 static inline struct ipa_cst_ref_desc *
192 ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
194 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
195 return jfunc->value.constant.rdesc;
198 /* Return the operand of a pass through jmp function JFUNC. */
200 static inline tree
201 ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
203 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
204 return jfunc->value.pass_through.operand;
207 /* Return the number of the caller's formal parameter that a pass through jump
208 function JFUNC refers to. */
210 static inline int
211 ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
213 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
214 return jfunc->value.pass_through.formal_id;
217 /* Return operation of a pass through jump function JFUNC. */
219 static inline enum tree_code
220 ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
222 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
223 return jfunc->value.pass_through.operation;
226 /* Return the agg_preserved flag of a pass through jump function JFUNC. */
228 static inline bool
229 ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
231 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
232 return jfunc->value.pass_through.agg_preserved;
235 /* Return true if pass through jump function JFUNC preserves type
236 information. */
238 static inline bool
239 ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
241 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
242 return jfunc->value.pass_through.agg_preserved;
245 /* Return the offset of an ancestor jump function JFUNC. */
247 static inline HOST_WIDE_INT
248 ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
250 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
251 return jfunc->value.ancestor.offset;
254 /* Return the number of the caller's formal parameter that an ancestor jump
255 function JFUNC refers to. */
257 static inline int
258 ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
260 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
261 return jfunc->value.ancestor.formal_id;
264 /* Return the agg_preserved flag of an ancestor jump function JFUNC. */
266 static inline bool
267 ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
269 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
270 return jfunc->value.ancestor.agg_preserved;
273 /* Return true if ancestor jump function JFUNC presrves type information. */
275 static inline bool
276 ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
278 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
279 return jfunc->value.ancestor.agg_preserved;
282 /* Summary describing a single formal parameter. */
284 struct ipa_param_descriptor
286 /* PARAM_DECL of this parameter. */
287 tree decl;
288 /* If all uses of the parameter are described by ipa-prop structures, this
289 says how many there are. If any use could not be described by means of
290 ipa-prop structures, this is IPA_UNDESCRIBED_USE. */
291 int controlled_uses;
292 unsigned int move_cost : 31;
293 /* The parameter is used. */
294 unsigned used : 1;
297 /* ipa_node_params stores information related to formal parameters of functions
298 and some other information for interprocedural passes that operate on
299 parameters (such as ipa-cp). */
301 struct ipa_node_params
303 ~ipa_node_params ();
305 /* Information about individual formal parameters that are gathered when
306 summaries are generated. */
307 vec<ipa_param_descriptor> descriptors;
308 /* Pointer to an array of structures describing individual formal
309 parameters. */
310 struct ipcp_param_lattices *lattices;
311 /* Only for versioned nodes this field would not be NULL,
312 it points to the node that IPA cp cloned from. */
313 struct cgraph_node *ipcp_orig_node;
314 /* If this node is an ipa-cp clone, these are the known constants that
315 describe what it has been specialized for. */
316 vec<tree> known_csts;
317 /* If this node is an ipa-cp clone, these are the known polymorphic contexts
318 that describe what it has been specialized for. */
319 vec<ipa_polymorphic_call_context> known_contexts;
320 /* Whether the param uses analysis and jump function computation has already
321 been performed. */
322 unsigned analysis_done : 1;
323 /* Whether the function is enqueued in ipa-cp propagation stack. */
324 unsigned node_enqueued : 1;
325 /* Whether we should create a specialized version based on values that are
326 known to be constant in all contexts. */
327 unsigned do_clone_for_all_contexts : 1;
328 /* Set if this is an IPA-CP clone for all contexts. */
329 unsigned is_all_contexts_clone : 1;
330 /* Node has been completely replaced by clones and will be removed after
331 ipa-cp is finished. */
332 unsigned node_dead : 1;
333 /* Node is involved in a recursion, potentionally indirect. */
334 unsigned node_within_scc : 1;
335 /* Node is calling a private function called only once. */
336 unsigned node_calling_single_call : 1;
337 /* False when there is something makes versioning impossible. */
338 unsigned versionable : 1;
341 /* Intermediate information that we get from alias analysis about a particular
342 parameter in a particular basic_block. When a parameter or the memory it
343 references is marked modified, we use that information in all dominated
344 blocks without consulting alias analysis oracle. */
346 struct ipa_param_aa_status
348 /* Set when this structure contains meaningful information. If not, the
349 structure describing a dominating BB should be used instead. */
350 bool valid;
352 /* Whether we have seen something which might have modified the data in
353 question. PARM is for the parameter itself, REF is for data it points to
354 but using the alias type of individual accesses and PT is the same thing
355 but for computing aggregate pass-through functions using a very inclusive
356 ao_ref. */
357 bool parm_modified, ref_modified, pt_modified;
360 /* Information related to a given BB that used only when looking at function
361 body. */
363 struct ipa_bb_info
365 /* Call graph edges going out of this BB. */
366 vec<cgraph_edge *> cg_edges;
367 /* Alias analysis statuses of each formal parameter at this bb. */
368 vec<ipa_param_aa_status> param_aa_statuses;
371 /* Structure with global information that is only used when looking at function
372 body. */
374 struct ipa_func_body_info
376 /* The node that is being analyzed. */
377 cgraph_node *node;
379 /* Its info. */
380 struct ipa_node_params *info;
382 /* Information about individual BBs. */
383 vec<ipa_bb_info> bb_infos;
385 /* Number of parameters. */
386 int param_count;
388 /* Number of statements already walked by when analyzing this function. */
389 unsigned int aa_walked;
392 /* ipa_node_params access functions. Please use these to access fields that
393 are or will be shared among various passes. */
395 /* Return the number of formal parameters. */
397 static inline int
398 ipa_get_param_count (struct ipa_node_params *info)
400 return info->descriptors.length ();
403 /* Return the declaration of Ith formal parameter of the function corresponding
404 to INFO. Note there is no setter function as this array is built just once
405 using ipa_initialize_node_params. */
407 static inline tree
408 ipa_get_param (struct ipa_node_params *info, int i)
410 gcc_checking_assert (!flag_wpa);
411 return info->descriptors[i].decl;
414 /* Return the move cost of Ith formal parameter of the function corresponding
415 to INFO. */
417 static inline int
418 ipa_get_param_move_cost (struct ipa_node_params *info, int i)
420 return info->descriptors[i].move_cost;
423 /* Set the used flag corresponding to the Ith formal parameter of the function
424 associated with INFO to VAL. */
426 static inline void
427 ipa_set_param_used (struct ipa_node_params *info, int i, bool val)
429 info->descriptors[i].used = val;
432 /* Return how many uses described by ipa-prop a parameter has or
433 IPA_UNDESCRIBED_USE if there is a use that is not described by these
434 structures. */
435 static inline int
436 ipa_get_controlled_uses (struct ipa_node_params *info, int i)
438 /* FIXME: introducing speuclation causes out of bounds access here. */
439 if (info->descriptors.length () > (unsigned)i)
440 return info->descriptors[i].controlled_uses;
441 return IPA_UNDESCRIBED_USE;
444 /* Set the controlled counter of a given parameter. */
446 static inline void
447 ipa_set_controlled_uses (struct ipa_node_params *info, int i, int val)
449 info->descriptors[i].controlled_uses = val;
452 /* Return the used flag corresponding to the Ith formal parameter of the
453 function associated with INFO. */
455 static inline bool
456 ipa_is_param_used (struct ipa_node_params *info, int i)
458 return info->descriptors[i].used;
461 /* Information about replacements done in aggregates for a given node (each
462 node has its linked list). */
463 struct GTY(()) ipa_agg_replacement_value
465 /* Next item in the linked list. */
466 struct ipa_agg_replacement_value *next;
467 /* Offset within the aggregate. */
468 HOST_WIDE_INT offset;
469 /* The constant value. */
470 tree value;
471 /* The paramter index. */
472 int index;
473 /* Whether the value was passed by reference. */
474 bool by_ref;
477 /* Structure holding information for the transformation phase of IPA-CP. */
479 struct GTY(()) ipcp_transformation_summary
481 /* Linked list of known aggregate values. */
482 ipa_agg_replacement_value *agg_values;
483 /* Alignment information for pointers. */
484 vec<ipa_alignment, va_gc> *alignments;
487 void ipa_set_node_agg_value_chain (struct cgraph_node *node,
488 struct ipa_agg_replacement_value *aggvals);
489 void ipcp_grow_transformations_if_necessary (void);
491 /* ipa_edge_args stores information related to a callsite and particularly its
492 arguments. It can be accessed by the IPA_EDGE_REF macro. */
493 struct GTY(()) ipa_edge_args
495 /* Vector of the callsite's jump function of each parameter. */
496 vec<ipa_jump_func, va_gc> *jump_functions;
497 vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
500 /* ipa_edge_args access functions. Please use these to access fields that
501 are or will be shared among various passes. */
503 /* Return the number of actual arguments. */
505 static inline int
506 ipa_get_cs_argument_count (struct ipa_edge_args *args)
508 return vec_safe_length (args->jump_functions);
511 /* Returns a pointer to the jump function for the ith argument. Please note
512 there is no setter function as jump functions are all set up in
513 ipa_compute_jump_functions. */
515 static inline struct ipa_jump_func *
516 ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
518 return &(*args->jump_functions)[i];
521 /* Returns a pointer to the polymorphic call context for the ith argument.
522 NULL if contexts are not computed. */
523 static inline struct ipa_polymorphic_call_context *
524 ipa_get_ith_polymorhic_call_context (struct ipa_edge_args *args, int i)
526 if (!args->polymorphic_call_contexts)
527 return NULL;
528 return &(*args->polymorphic_call_contexts)[i];
531 /* Function summary for ipa_node_params. */
532 class ipa_node_params_t: public function_summary <ipa_node_params *>
534 public:
535 ipa_node_params_t (symbol_table *table):
536 function_summary<ipa_node_params *> (table) { }
538 /* Hook that is called by summary when a node is duplicated. */
539 virtual void duplicate (cgraph_node *node,
540 cgraph_node *node2,
541 ipa_node_params *data,
542 ipa_node_params *data2);
545 /* Function summary where the parameter infos are actually stored. */
546 extern ipa_node_params_t *ipa_node_params_sum;
547 /* Vector of IPA-CP transformation data for each clone. */
548 extern GTY(()) vec<ipcp_transformation_summary, va_gc> *ipcp_transformations;
549 /* Vector where the parameter infos are actually stored. */
550 extern GTY(()) vec<ipa_edge_args, va_gc> *ipa_edge_args_vector;
552 /* Return the associated parameter/argument info corresponding to the given
553 node/edge. */
554 #define IPA_NODE_REF(NODE) (ipa_node_params_sum->get (NODE))
555 #define IPA_EDGE_REF(EDGE) (&(*ipa_edge_args_vector)[(EDGE)->uid])
556 /* This macro checks validity of index returned by
557 ipa_get_param_decl_index function. */
558 #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
560 /* Creating and freeing ipa_node_params and ipa_edge_args. */
561 void ipa_create_all_node_params (void);
562 void ipa_create_all_edge_args (void);
563 void ipa_free_edge_args_substructures (struct ipa_edge_args *);
564 void ipa_free_all_node_params (void);
565 void ipa_free_all_edge_args (void);
566 void ipa_free_all_structures_after_ipa_cp (void);
567 void ipa_free_all_structures_after_iinln (void);
569 void ipa_register_cgraph_hooks (void);
570 int count_formal_params (tree fndecl);
572 /* This function ensures the array of node param infos is big enough to
573 accommodate a structure for all nodes and reallocates it if not. */
575 static inline void
576 ipa_check_create_node_params (void)
578 if (!ipa_node_params_sum)
579 ipa_node_params_sum = new ipa_node_params_t (symtab);
582 /* This function ensures the array of edge arguments infos is big enough to
583 accommodate a structure for all edges and reallocates it if not. */
585 static inline void
586 ipa_check_create_edge_args (void)
588 if (vec_safe_length (ipa_edge_args_vector)
589 <= (unsigned) symtab->edges_max_uid)
590 vec_safe_grow_cleared (ipa_edge_args_vector, symtab->edges_max_uid + 1);
593 /* Returns true if the array of edge infos is large enough to accommodate an
594 info for EDGE. The main purpose of this function is that debug dumping
595 function can check info availability without causing reallocations. */
597 static inline bool
598 ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
600 return ((unsigned) edge->uid < vec_safe_length (ipa_edge_args_vector));
603 static inline ipcp_transformation_summary *
604 ipcp_get_transformation_summary (cgraph_node *node)
606 if ((unsigned) node->uid >= vec_safe_length (ipcp_transformations))
607 return NULL;
608 return &(*ipcp_transformations)[node->uid];
611 /* Return the aggregate replacements for NODE, if there are any. */
613 static inline struct ipa_agg_replacement_value *
614 ipa_get_agg_replacements_for_node (cgraph_node *node)
616 ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node);
617 return ts ? ts->agg_values : NULL;
620 /* Function formal parameters related computations. */
621 void ipa_initialize_node_params (struct cgraph_node *node);
622 bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
623 vec<cgraph_edge *> *new_edges);
625 /* Indirect edge and binfo processing. */
626 tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
627 vec<tree> ,
628 vec<ipa_polymorphic_call_context>,
629 vec<ipa_agg_jump_function_p>,
630 bool *);
631 struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
632 bool speculative = false);
633 tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
635 /* Functions related to both. */
636 void ipa_analyze_node (struct cgraph_node *);
638 /* Aggregate jump function related functions. */
639 tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *agg, tree scalar,
640 HOST_WIDE_INT offset, bool by_ref,
641 bool *from_global_constant = NULL);
642 bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
643 vec<ipa_param_descriptor> descriptors,
644 gimple *stmt, tree op, int *index_p,
645 HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p,
646 bool *by_ref, bool *guaranteed_unmodified = NULL);
648 /* Debugging interface. */
649 void ipa_print_node_params (FILE *, struct cgraph_node *node);
650 void ipa_print_all_params (FILE *);
651 void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
652 void ipa_print_all_jump_functions (FILE * f);
653 void ipcp_verify_propagated_values (void);
655 template <typename value>
656 class ipcp_value;
658 extern object_allocator<ipcp_value<tree> > ipcp_cst_values_pool;
659 extern object_allocator<ipcp_value<ipa_polymorphic_call_context> >
660 ipcp_poly_ctx_values_pool;
662 template <typename valtype>
663 class ipcp_value_source;
665 extern object_allocator<ipcp_value_source<tree> > ipcp_sources_pool;
667 class ipcp_agg_lattice;
669 extern object_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool;
671 /* Operation to be performed for the parameter in ipa_parm_adjustment
672 below. */
673 enum ipa_parm_op {
674 IPA_PARM_OP_NONE,
676 /* This describes a brand new parameter.
678 The field `type' should be set to the new type, `arg_prefix'
679 should be set to the string prefix for the new DECL_NAME, and
680 `new_decl' will ultimately hold the newly created argument. */
681 IPA_PARM_OP_NEW,
683 /* This new parameter is an unmodified parameter at index base_index. */
684 IPA_PARM_OP_COPY,
686 /* This adjustment describes a parameter that is about to be removed
687 completely. Most users will probably need to book keep those so that they
688 don't leave behinfd any non default def ssa names belonging to them. */
689 IPA_PARM_OP_REMOVE
692 /* Structure to describe transformations of formal parameters and actual
693 arguments. Each instance describes one new parameter and they are meant to
694 be stored in a vector. Additionally, most users will probably want to store
695 adjustments about parameters that are being removed altogether so that SSA
696 names belonging to them can be replaced by SSA names of an artificial
697 variable. */
698 struct ipa_parm_adjustment
700 /* The original PARM_DECL itself, helpful for processing of the body of the
701 function itself. Intended for traversing function bodies.
702 ipa_modify_formal_parameters, ipa_modify_call_arguments and
703 ipa_combine_adjustments ignore this and use base_index.
704 ipa_modify_formal_parameters actually sets this. */
705 tree base;
707 /* Type of the new parameter. However, if by_ref is true, the real type will
708 be a pointer to this type. */
709 tree type;
711 /* Alias refrerence type to be used in MEM_REFs when adjusting caller
712 arguments. */
713 tree alias_ptr_type;
715 /* The new declaration when creating/replacing a parameter. Created
716 by ipa_modify_formal_parameters, useful for functions modifying
717 the body accordingly. For brand new arguments, this is the newly
718 created argument. */
719 tree new_decl;
721 /* New declaration of a substitute variable that we may use to replace all
722 non-default-def ssa names when a parm decl is going away. */
723 tree new_ssa_base;
725 /* If non-NULL and the original parameter is to be removed (copy_param below
726 is NULL), this is going to be its nonlocalized vars value. */
727 tree nonlocal_value;
729 /* This holds the prefix to be used for the new DECL_NAME. */
730 const char *arg_prefix;
732 /* Offset into the original parameter (for the cases when the new parameter
733 is a component of an original one). */
734 HOST_WIDE_INT offset;
736 /* Zero based index of the original parameter this one is based on. */
737 int base_index;
739 /* Whether this parameter is a new parameter, a copy of an old one,
740 or one about to be removed. */
741 enum ipa_parm_op op;
743 /* Storage order of the original parameter (for the cases when the new
744 parameter is a component of an original one). */
745 unsigned reverse : 1;
747 /* The parameter is to be passed by reference. */
748 unsigned by_ref : 1;
751 typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
753 vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
754 vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
755 void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
756 void ipa_modify_call_arguments (struct cgraph_edge *, gcall *,
757 ipa_parm_adjustment_vec);
758 ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
759 ipa_parm_adjustment_vec);
760 void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
761 void ipa_dump_agg_replacement_values (FILE *f,
762 struct ipa_agg_replacement_value *av);
763 void ipa_prop_write_jump_functions (void);
764 void ipa_prop_read_jump_functions (void);
765 void ipcp_write_transformation_summaries (void);
766 void ipcp_read_transformation_summaries (void);
767 void ipa_update_after_lto_read (void);
768 int ipa_get_param_decl_index (struct ipa_node_params *, tree);
769 tree ipa_value_from_jfunc (struct ipa_node_params *info,
770 struct ipa_jump_func *jfunc);
771 unsigned int ipcp_transform_function (struct cgraph_node *node);
772 ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
773 cgraph_edge *,
774 int,
775 ipa_jump_func *);
776 void ipa_dump_param (FILE *, struct ipa_node_params *info, int i);
777 bool ipa_modify_expr (tree *, bool, ipa_parm_adjustment_vec);
778 ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *,
779 ipa_parm_adjustment_vec,
780 bool);
781 void ipa_release_body_info (struct ipa_func_body_info *);
783 /* From tree-sra.c: */
784 tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, bool, tree,
785 gimple_stmt_iterator *, bool);
787 /* In ipa-cp.c */
788 void ipa_cp_c_finalize (void);
790 #endif /* IPA_PROP_H */