* config/visium/visium.c (visium_gimplify_va_arg): Emit a big-endian
[official-gcc.git] / gcc / ipa-prop.h
blob4eeae882f5f36d3c99acf6d3cb8fb2b345a726c0
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 /* Information about zero/non-zero bits. */
147 struct GTY(()) ipa_bits
149 /* The propagated value. */
150 widest_int value;
151 /* Mask corresponding to the value.
152 Similar to ccp_lattice_t, if xth bit of mask is 0,
153 implies xth bit of value is constant. */
154 widest_int mask;
155 /* True if jump function is known. */
156 bool known;
159 /* Info about value ranges. */
160 struct GTY(()) ipa_vr
162 /* The data fields below are valid only if known is true. */
163 bool known;
164 enum value_range_type type;
165 wide_int min;
166 wide_int max;
169 /* A jump function for a callsite represents the values passed as actual
170 arguments of the callsite. See enum jump_func_type for the various
171 types of jump functions supported. */
172 struct GTY (()) ipa_jump_func
174 /* Aggregate contants description. See struct ipa_agg_jump_function and its
175 description. */
176 struct ipa_agg_jump_function agg;
178 /* Information about zero/non-zero bits. */
179 struct ipa_bits bits;
181 /* Information about value range. */
182 bool vr_known;
183 value_range m_vr;
185 enum jump_func_type type;
186 /* Represents a value of a jump function. pass_through is used only in jump
187 function context. constant represents the actual constant in constant jump
188 functions and member_cst holds constant c++ member functions. */
189 union jump_func_value
191 struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
192 struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
193 struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
194 } GTY ((desc ("%1.type"))) value;
198 /* Return the constant stored in a constant jump functin JFUNC. */
200 static inline tree
201 ipa_get_jf_constant (struct ipa_jump_func *jfunc)
203 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
204 return jfunc->value.constant.value;
207 static inline struct ipa_cst_ref_desc *
208 ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
210 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
211 return jfunc->value.constant.rdesc;
214 /* Return the operand of a pass through jmp function JFUNC. */
216 static inline tree
217 ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
219 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
220 return jfunc->value.pass_through.operand;
223 /* Return the number of the caller's formal parameter that a pass through jump
224 function JFUNC refers to. */
226 static inline int
227 ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
229 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
230 return jfunc->value.pass_through.formal_id;
233 /* Return operation of a pass through jump function JFUNC. */
235 static inline enum tree_code
236 ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
238 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
239 return jfunc->value.pass_through.operation;
242 /* Return the agg_preserved flag of a pass through jump function JFUNC. */
244 static inline bool
245 ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
247 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
248 return jfunc->value.pass_through.agg_preserved;
251 /* Return true if pass through jump function JFUNC preserves type
252 information. */
254 static inline bool
255 ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
257 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
258 return jfunc->value.pass_through.agg_preserved;
261 /* Return the offset of an ancestor jump function JFUNC. */
263 static inline HOST_WIDE_INT
264 ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
266 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
267 return jfunc->value.ancestor.offset;
270 /* Return the number of the caller's formal parameter that an ancestor jump
271 function JFUNC refers to. */
273 static inline int
274 ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
276 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
277 return jfunc->value.ancestor.formal_id;
280 /* Return the agg_preserved flag of an ancestor jump function JFUNC. */
282 static inline bool
283 ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
285 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
286 return jfunc->value.ancestor.agg_preserved;
289 /* Return true if ancestor jump function JFUNC presrves type information. */
291 static inline bool
292 ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
294 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
295 return jfunc->value.ancestor.agg_preserved;
298 /* Summary describing a single formal parameter. */
300 struct ipa_param_descriptor
302 /* In analysis and modification phase, this is the PARAM_DECL of this
303 parameter, in IPA LTO phase, this is the type of the the described
304 parameter or NULL if not known. Do not read this field directly but
305 through ipa_get_param and ipa_get_type as appropriate. */
306 tree decl_or_type;
307 /* If all uses of the parameter are described by ipa-prop structures, this
308 says how many there are. If any use could not be described by means of
309 ipa-prop structures, this is IPA_UNDESCRIBED_USE. */
310 int controlled_uses;
311 unsigned int move_cost : 31;
312 /* The parameter is used. */
313 unsigned used : 1;
316 /* ipa_node_params stores information related to formal parameters of functions
317 and some other information for interprocedural passes that operate on
318 parameters (such as ipa-cp). */
320 struct ipa_node_params
322 ~ipa_node_params ();
324 /* Information about individual formal parameters that are gathered when
325 summaries are generated. */
326 vec<ipa_param_descriptor> descriptors;
327 /* Pointer to an array of structures describing individual formal
328 parameters. */
329 struct ipcp_param_lattices *lattices;
330 /* Only for versioned nodes this field would not be NULL,
331 it points to the node that IPA cp cloned from. */
332 struct cgraph_node *ipcp_orig_node;
333 /* If this node is an ipa-cp clone, these are the known constants that
334 describe what it has been specialized for. */
335 vec<tree> known_csts;
336 /* If this node is an ipa-cp clone, these are the known polymorphic contexts
337 that describe what it has been specialized for. */
338 vec<ipa_polymorphic_call_context> known_contexts;
339 /* Whether the param uses analysis and jump function computation has already
340 been performed. */
341 unsigned analysis_done : 1;
342 /* Whether the function is enqueued in ipa-cp propagation stack. */
343 unsigned node_enqueued : 1;
344 /* Whether we should create a specialized version based on values that are
345 known to be constant in all contexts. */
346 unsigned do_clone_for_all_contexts : 1;
347 /* Set if this is an IPA-CP clone for all contexts. */
348 unsigned is_all_contexts_clone : 1;
349 /* Node has been completely replaced by clones and will be removed after
350 ipa-cp is finished. */
351 unsigned node_dead : 1;
352 /* Node is involved in a recursion, potentionally indirect. */
353 unsigned node_within_scc : 1;
354 /* Node is calling a private function called only once. */
355 unsigned node_calling_single_call : 1;
356 /* False when there is something makes versioning impossible. */
357 unsigned versionable : 1;
360 /* Intermediate information that we get from alias analysis about a particular
361 parameter in a particular basic_block. When a parameter or the memory it
362 references is marked modified, we use that information in all dominated
363 blocks without consulting alias analysis oracle. */
365 struct ipa_param_aa_status
367 /* Set when this structure contains meaningful information. If not, the
368 structure describing a dominating BB should be used instead. */
369 bool valid;
371 /* Whether we have seen something which might have modified the data in
372 question. PARM is for the parameter itself, REF is for data it points to
373 but using the alias type of individual accesses and PT is the same thing
374 but for computing aggregate pass-through functions using a very inclusive
375 ao_ref. */
376 bool parm_modified, ref_modified, pt_modified;
379 /* Information related to a given BB that used only when looking at function
380 body. */
382 struct ipa_bb_info
384 /* Call graph edges going out of this BB. */
385 vec<cgraph_edge *> cg_edges;
386 /* Alias analysis statuses of each formal parameter at this bb. */
387 vec<ipa_param_aa_status> param_aa_statuses;
390 /* Structure with global information that is only used when looking at function
391 body. */
393 struct ipa_func_body_info
395 /* The node that is being analyzed. */
396 cgraph_node *node;
398 /* Its info. */
399 struct ipa_node_params *info;
401 /* Information about individual BBs. */
402 vec<ipa_bb_info> bb_infos;
404 /* Number of parameters. */
405 int param_count;
407 /* Number of statements already walked by when analyzing this function. */
408 unsigned int aa_walked;
411 /* ipa_node_params access functions. Please use these to access fields that
412 are or will be shared among various passes. */
414 /* Return the number of formal parameters. */
416 static inline int
417 ipa_get_param_count (struct ipa_node_params *info)
419 return info->descriptors.length ();
422 /* Return the declaration of Ith formal parameter of the function corresponding
423 to INFO. Note there is no setter function as this array is built just once
424 using ipa_initialize_node_params. This function should not be called in
425 WPA. */
427 static inline tree
428 ipa_get_param (struct ipa_node_params *info, int i)
430 gcc_checking_assert (!flag_wpa);
431 tree t = info->descriptors[i].decl_or_type;
432 gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
433 return t;
436 /* Return the type of Ith formal parameter of the function corresponding
437 to INFO if it is known or NULL if not. */
439 static inline tree
440 ipa_get_type (struct ipa_node_params *info, int i)
442 tree t = info->descriptors[i].decl_or_type;
443 if (!t)
444 return NULL;
445 if (TYPE_P (t))
446 return t;
447 gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
448 return TREE_TYPE (t);
451 /* Return the move cost of Ith formal parameter of the function corresponding
452 to INFO. */
454 static inline int
455 ipa_get_param_move_cost (struct ipa_node_params *info, int i)
457 return info->descriptors[i].move_cost;
460 /* Set the used flag corresponding to the Ith formal parameter of the function
461 associated with INFO to VAL. */
463 static inline void
464 ipa_set_param_used (struct ipa_node_params *info, int i, bool val)
466 info->descriptors[i].used = val;
469 /* Return how many uses described by ipa-prop a parameter has or
470 IPA_UNDESCRIBED_USE if there is a use that is not described by these
471 structures. */
472 static inline int
473 ipa_get_controlled_uses (struct ipa_node_params *info, int i)
475 /* FIXME: introducing speuclation causes out of bounds access here. */
476 if (info->descriptors.length () > (unsigned)i)
477 return info->descriptors[i].controlled_uses;
478 return IPA_UNDESCRIBED_USE;
481 /* Set the controlled counter of a given parameter. */
483 static inline void
484 ipa_set_controlled_uses (struct ipa_node_params *info, int i, int val)
486 info->descriptors[i].controlled_uses = val;
489 /* Return the used flag corresponding to the Ith formal parameter of the
490 function associated with INFO. */
492 static inline bool
493 ipa_is_param_used (struct ipa_node_params *info, int i)
495 return info->descriptors[i].used;
498 /* Information about replacements done in aggregates for a given node (each
499 node has its linked list). */
500 struct GTY(()) ipa_agg_replacement_value
502 /* Next item in the linked list. */
503 struct ipa_agg_replacement_value *next;
504 /* Offset within the aggregate. */
505 HOST_WIDE_INT offset;
506 /* The constant value. */
507 tree value;
508 /* The paramter index. */
509 int index;
510 /* Whether the value was passed by reference. */
511 bool by_ref;
514 /* Structure holding information for the transformation phase of IPA-CP. */
516 struct GTY(()) ipcp_transformation_summary
518 /* Linked list of known aggregate values. */
519 ipa_agg_replacement_value *agg_values;
520 /* Known bits information. */
521 vec<ipa_bits, va_gc> *bits;
522 /* Value range information. */
523 vec<ipa_vr, va_gc> *m_vr;
526 void ipa_set_node_agg_value_chain (struct cgraph_node *node,
527 struct ipa_agg_replacement_value *aggvals);
528 void ipcp_grow_transformations_if_necessary (void);
530 /* ipa_edge_args stores information related to a callsite and particularly its
531 arguments. It can be accessed by the IPA_EDGE_REF macro. */
532 struct GTY(()) ipa_edge_args
534 /* Vector of the callsite's jump function of each parameter. */
535 vec<ipa_jump_func, va_gc> *jump_functions;
536 vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
539 /* ipa_edge_args access functions. Please use these to access fields that
540 are or will be shared among various passes. */
542 /* Return the number of actual arguments. */
544 static inline int
545 ipa_get_cs_argument_count (struct ipa_edge_args *args)
547 return vec_safe_length (args->jump_functions);
550 /* Returns a pointer to the jump function for the ith argument. Please note
551 there is no setter function as jump functions are all set up in
552 ipa_compute_jump_functions. */
554 static inline struct ipa_jump_func *
555 ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
557 return &(*args->jump_functions)[i];
560 /* Returns a pointer to the polymorphic call context for the ith argument.
561 NULL if contexts are not computed. */
562 static inline struct ipa_polymorphic_call_context *
563 ipa_get_ith_polymorhic_call_context (struct ipa_edge_args *args, int i)
565 if (!args->polymorphic_call_contexts)
566 return NULL;
567 return &(*args->polymorphic_call_contexts)[i];
570 /* Function summary for ipa_node_params. */
571 class ipa_node_params_t: public function_summary <ipa_node_params *>
573 public:
574 ipa_node_params_t (symbol_table *table):
575 function_summary<ipa_node_params *> (table) { }
577 /* Hook that is called by summary when a node is duplicated. */
578 virtual void duplicate (cgraph_node *node,
579 cgraph_node *node2,
580 ipa_node_params *data,
581 ipa_node_params *data2);
584 /* Function summary where the parameter infos are actually stored. */
585 extern ipa_node_params_t *ipa_node_params_sum;
586 /* Vector of IPA-CP transformation data for each clone. */
587 extern GTY(()) vec<ipcp_transformation_summary, va_gc> *ipcp_transformations;
588 /* Vector where the parameter infos are actually stored. */
589 extern GTY(()) vec<ipa_edge_args, va_gc> *ipa_edge_args_vector;
591 /* Return the associated parameter/argument info corresponding to the given
592 node/edge. */
593 #define IPA_NODE_REF(NODE) (ipa_node_params_sum->get (NODE))
594 #define IPA_EDGE_REF(EDGE) (&(*ipa_edge_args_vector)[(EDGE)->uid])
595 /* This macro checks validity of index returned by
596 ipa_get_param_decl_index function. */
597 #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
599 /* Creating and freeing ipa_node_params and ipa_edge_args. */
600 void ipa_create_all_node_params (void);
601 void ipa_create_all_edge_args (void);
602 void ipa_free_edge_args_substructures (struct ipa_edge_args *);
603 void ipa_free_all_node_params (void);
604 void ipa_free_all_edge_args (void);
605 void ipa_free_all_structures_after_ipa_cp (void);
606 void ipa_free_all_structures_after_iinln (void);
608 void ipa_register_cgraph_hooks (void);
609 int count_formal_params (tree fndecl);
611 /* This function ensures the array of node param infos is big enough to
612 accommodate a structure for all nodes and reallocates it if not. */
614 static inline void
615 ipa_check_create_node_params (void)
617 if (!ipa_node_params_sum)
618 ipa_node_params_sum = new ipa_node_params_t (symtab);
621 /* This function ensures the array of edge arguments infos is big enough to
622 accommodate a structure for all edges and reallocates it if not. */
624 static inline void
625 ipa_check_create_edge_args (void)
627 if (vec_safe_length (ipa_edge_args_vector)
628 <= (unsigned) symtab->edges_max_uid)
629 vec_safe_grow_cleared (ipa_edge_args_vector, symtab->edges_max_uid + 1);
632 /* Returns true if the array of edge infos is large enough to accommodate an
633 info for EDGE. The main purpose of this function is that debug dumping
634 function can check info availability without causing reallocations. */
636 static inline bool
637 ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
639 return ((unsigned) edge->uid < vec_safe_length (ipa_edge_args_vector));
642 static inline ipcp_transformation_summary *
643 ipcp_get_transformation_summary (cgraph_node *node)
645 if ((unsigned) node->uid >= vec_safe_length (ipcp_transformations))
646 return NULL;
647 return &(*ipcp_transformations)[node->uid];
650 /* Return the aggregate replacements for NODE, if there are any. */
652 static inline struct ipa_agg_replacement_value *
653 ipa_get_agg_replacements_for_node (cgraph_node *node)
655 ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node);
656 return ts ? ts->agg_values : NULL;
659 /* Function formal parameters related computations. */
660 void ipa_initialize_node_params (struct cgraph_node *node);
661 bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
662 vec<cgraph_edge *> *new_edges);
664 /* Indirect edge and binfo processing. */
665 tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
666 vec<tree> ,
667 vec<ipa_polymorphic_call_context>,
668 vec<ipa_agg_jump_function_p>,
669 bool *);
670 struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
671 bool speculative = false);
672 tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
674 /* Functions related to both. */
675 void ipa_analyze_node (struct cgraph_node *);
677 /* Aggregate jump function related functions. */
678 tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *agg, tree scalar,
679 HOST_WIDE_INT offset, bool by_ref,
680 bool *from_global_constant = NULL);
681 bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
682 vec<ipa_param_descriptor> descriptors,
683 gimple *stmt, tree op, int *index_p,
684 HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p,
685 bool *by_ref, bool *guaranteed_unmodified = NULL);
687 /* Debugging interface. */
688 void ipa_print_node_params (FILE *, struct cgraph_node *node);
689 void ipa_print_all_params (FILE *);
690 void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
691 void ipa_print_all_jump_functions (FILE * f);
692 void ipcp_verify_propagated_values (void);
694 template <typename value>
695 class ipcp_value;
697 extern object_allocator<ipcp_value<tree> > ipcp_cst_values_pool;
698 extern object_allocator<ipcp_value<ipa_polymorphic_call_context> >
699 ipcp_poly_ctx_values_pool;
701 template <typename valtype>
702 class ipcp_value_source;
704 extern object_allocator<ipcp_value_source<tree> > ipcp_sources_pool;
706 class ipcp_agg_lattice;
708 extern object_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool;
710 /* Operation to be performed for the parameter in ipa_parm_adjustment
711 below. */
712 enum ipa_parm_op {
713 IPA_PARM_OP_NONE,
715 /* This describes a brand new parameter.
717 The field `type' should be set to the new type, `arg_prefix'
718 should be set to the string prefix for the new DECL_NAME, and
719 `new_decl' will ultimately hold the newly created argument. */
720 IPA_PARM_OP_NEW,
722 /* This new parameter is an unmodified parameter at index base_index. */
723 IPA_PARM_OP_COPY,
725 /* This adjustment describes a parameter that is about to be removed
726 completely. Most users will probably need to book keep those so that they
727 don't leave behinfd any non default def ssa names belonging to them. */
728 IPA_PARM_OP_REMOVE
731 /* Structure to describe transformations of formal parameters and actual
732 arguments. Each instance describes one new parameter and they are meant to
733 be stored in a vector. Additionally, most users will probably want to store
734 adjustments about parameters that are being removed altogether so that SSA
735 names belonging to them can be replaced by SSA names of an artificial
736 variable. */
737 struct ipa_parm_adjustment
739 /* The original PARM_DECL itself, helpful for processing of the body of the
740 function itself. Intended for traversing function bodies.
741 ipa_modify_formal_parameters, ipa_modify_call_arguments and
742 ipa_combine_adjustments ignore this and use base_index.
743 ipa_modify_formal_parameters actually sets this. */
744 tree base;
746 /* Type of the new parameter. However, if by_ref is true, the real type will
747 be a pointer to this type. */
748 tree type;
750 /* Alias refrerence type to be used in MEM_REFs when adjusting caller
751 arguments. */
752 tree alias_ptr_type;
754 /* The new declaration when creating/replacing a parameter. Created
755 by ipa_modify_formal_parameters, useful for functions modifying
756 the body accordingly. For brand new arguments, this is the newly
757 created argument. */
758 tree new_decl;
760 /* New declaration of a substitute variable that we may use to replace all
761 non-default-def ssa names when a parm decl is going away. */
762 tree new_ssa_base;
764 /* If non-NULL and the original parameter is to be removed (copy_param below
765 is NULL), this is going to be its nonlocalized vars value. */
766 tree nonlocal_value;
768 /* This holds the prefix to be used for the new DECL_NAME. */
769 const char *arg_prefix;
771 /* Offset into the original parameter (for the cases when the new parameter
772 is a component of an original one). */
773 HOST_WIDE_INT offset;
775 /* Zero based index of the original parameter this one is based on. */
776 int base_index;
778 /* Whether this parameter is a new parameter, a copy of an old one,
779 or one about to be removed. */
780 enum ipa_parm_op op;
782 /* Storage order of the original parameter (for the cases when the new
783 parameter is a component of an original one). */
784 unsigned reverse : 1;
786 /* The parameter is to be passed by reference. */
787 unsigned by_ref : 1;
790 typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
792 vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
793 vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
794 void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
795 void ipa_modify_call_arguments (struct cgraph_edge *, gcall *,
796 ipa_parm_adjustment_vec);
797 ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
798 ipa_parm_adjustment_vec);
799 void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
800 void ipa_dump_agg_replacement_values (FILE *f,
801 struct ipa_agg_replacement_value *av);
802 void ipa_prop_write_jump_functions (void);
803 void ipa_prop_read_jump_functions (void);
804 void ipcp_write_transformation_summaries (void);
805 void ipcp_read_transformation_summaries (void);
806 void ipa_update_after_lto_read (void);
807 int ipa_get_param_decl_index (struct ipa_node_params *, tree);
808 tree ipa_value_from_jfunc (struct ipa_node_params *info,
809 struct ipa_jump_func *jfunc);
810 unsigned int ipcp_transform_function (struct cgraph_node *node);
811 ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
812 cgraph_edge *,
813 int,
814 ipa_jump_func *);
815 void ipa_dump_param (FILE *, struct ipa_node_params *info, int i);
816 bool ipa_modify_expr (tree *, bool, ipa_parm_adjustment_vec);
817 ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *,
818 ipa_parm_adjustment_vec,
819 bool);
820 void ipa_release_body_info (struct ipa_func_body_info *);
822 /* From tree-sra.c: */
823 tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, bool, tree,
824 gimple_stmt_iterator *, bool);
826 /* In ipa-cp.c */
827 void ipa_cp_c_finalize (void);
829 #endif /* IPA_PROP_H */