comparison gcc/ipa-prop.h @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
comparison
equal deleted inserted replaced
130:e108057fa461 132:d34655255c78
1 /* Interprocedural analyses. 1 /* Interprocedural analyses.
2 Copyright (C) 2005-2017 Free Software Foundation, Inc. 2 Copyright (C) 2005-2018 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 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 7 the terms of the GNU General Public License as published by the Free
158 158
159 struct GTY(()) ipa_vr 159 struct GTY(()) ipa_vr
160 { 160 {
161 /* The data fields below are valid only if known is true. */ 161 /* The data fields below are valid only if known is true. */
162 bool known; 162 bool known;
163 enum value_range_type type; 163 enum value_range_kind type;
164 wide_int min; 164 wide_int min;
165 wide_int max; 165 wide_int max;
166 }; 166 };
167 167
168 /* A jump function for a callsite represents the values passed as actual 168 /* A jump function for a callsite represents the values passed as actual
462 to INFO if it is known or NULL if not. */ 462 to INFO if it is known or NULL if not. */
463 463
464 static inline tree 464 static inline tree
465 ipa_get_type (struct ipa_node_params *info, int i) 465 ipa_get_type (struct ipa_node_params *info, int i)
466 { 466 {
467 gcc_checking_assert (info->descriptors); 467 if (vec_safe_length (info->descriptors) <= (unsigned) i)
468 return NULL;
468 tree t = (*info->descriptors)[i].decl_or_type; 469 tree t = (*info->descriptors)[i].decl_or_type;
469 if (!t) 470 if (!t)
470 return NULL; 471 return NULL;
471 if (TYPE_P (t)) 472 if (TYPE_P (t))
472 return t; 473 return t;
541 bool by_ref; 542 bool by_ref;
542 }; 543 };
543 544
544 /* Structure holding information for the transformation phase of IPA-CP. */ 545 /* Structure holding information for the transformation phase of IPA-CP. */
545 546
546 struct GTY(()) ipcp_transformation_summary 547 struct GTY(()) ipcp_transformation
547 { 548 {
548 /* Linked list of known aggregate values. */ 549 /* Linked list of known aggregate values. */
549 ipa_agg_replacement_value *agg_values; 550 ipa_agg_replacement_value *agg_values;
550 /* Known bits information. */ 551 /* Known bits information. */
551 vec<ipa_bits *, va_gc> *bits; 552 vec<ipa_bits *, va_gc> *bits;
553 vec<ipa_vr, va_gc> *m_vr; 554 vec<ipa_vr, va_gc> *m_vr;
554 }; 555 };
555 556
556 void ipa_set_node_agg_value_chain (struct cgraph_node *node, 557 void ipa_set_node_agg_value_chain (struct cgraph_node *node,
557 struct ipa_agg_replacement_value *aggvals); 558 struct ipa_agg_replacement_value *aggvals);
558 void ipcp_grow_transformations_if_necessary (void); 559 void ipcp_transformation_initialize (void);
559 560
560 /* ipa_edge_args stores information related to a callsite and particularly its 561 /* ipa_edge_args stores information related to a callsite and particularly its
561 arguments. It can be accessed by the IPA_EDGE_REF macro. */ 562 arguments. It can be accessed by the IPA_EDGE_REF macro. */
562 563
563 class GTY((for_user)) ipa_edge_args 564 class GTY((for_user)) ipa_edge_args
646 /* Function summary where the parameter infos are actually stored. */ 647 /* Function summary where the parameter infos are actually stored. */
647 extern GTY(()) ipa_node_params_t * ipa_node_params_sum; 648 extern GTY(()) ipa_node_params_t * ipa_node_params_sum;
648 /* Call summary to store information about edges such as jump functions. */ 649 /* Call summary to store information about edges such as jump functions. */
649 extern GTY(()) ipa_edge_args_sum_t *ipa_edge_args_sum; 650 extern GTY(()) ipa_edge_args_sum_t *ipa_edge_args_sum;
650 651
651 /* Vector of IPA-CP transformation data for each clone. */ 652 /* Function summary for IPA-CP transformation. */
652 extern GTY(()) vec<ipcp_transformation_summary, va_gc> *ipcp_transformations; 653 class ipcp_transformation_t
654 : public function_summary<ipcp_transformation *>
655 {
656 public:
657 ipcp_transformation_t (symbol_table *table, bool ggc):
658 function_summary<ipcp_transformation *> (table, ggc) {}
659
660 ~ipcp_transformation_t () {}
661
662 static ipcp_transformation_t *create_ggc (symbol_table *symtab)
663 {
664 ipcp_transformation_t *summary
665 = new (ggc_cleared_alloc <ipcp_transformation_t> ())
666 ipcp_transformation_t (symtab, true);
667 return summary;
668 }
669 };
670
671 /* Function summary where the IPA CP transformations are actually stored. */
672 extern GTY(()) function_summary <ipcp_transformation *> *ipcp_transformation_sum;
653 673
654 /* Return the associated parameter/argument info corresponding to the given 674 /* Return the associated parameter/argument info corresponding to the given
655 node/edge. */ 675 node/edge. */
656 #define IPA_NODE_REF(NODE) (ipa_node_params_sum->get (NODE)) 676 #define IPA_NODE_REF(NODE) (ipa_node_params_sum->get_create (NODE))
657 #define IPA_EDGE_REF(EDGE) (ipa_edge_args_sum->get (EDGE)) 677 #define IPA_EDGE_REF(EDGE) (ipa_edge_args_sum->get_create (EDGE))
658 /* This macro checks validity of index returned by 678 /* This macro checks validity of index returned by
659 ipa_get_param_decl_index function. */ 679 ipa_get_param_decl_index function. */
660 #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1) 680 #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
661 681
662 /* Creating and freeing ipa_node_params and ipa_edge_args. */ 682 /* Creating and freeing ipa_node_params and ipa_edge_args. */
663 void ipa_create_all_node_params (void); 683 void ipa_create_all_node_params (void);
664 void ipa_create_all_edge_args (void); 684 void ipa_create_all_edge_args (void);
665 void ipa_check_create_edge_args (void); 685 void ipa_check_create_edge_args (void);
666 void ipa_free_edge_args_substructures (struct ipa_edge_args *);
667 void ipa_free_all_node_params (void); 686 void ipa_free_all_node_params (void);
668 void ipa_free_all_edge_args (void); 687 void ipa_free_all_edge_args (void);
669 void ipa_free_all_structures_after_ipa_cp (void); 688 void ipa_free_all_structures_after_ipa_cp (void);
670 void ipa_free_all_structures_after_iinln (void); 689 void ipa_free_all_structures_after_iinln (void);
671 690
692 ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge) 711 ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
693 { 712 {
694 return ipa_edge_args_sum->exists (edge); 713 return ipa_edge_args_sum->exists (edge);
695 } 714 }
696 715
697 static inline ipcp_transformation_summary * 716 static inline ipcp_transformation *
698 ipcp_get_transformation_summary (cgraph_node *node) 717 ipcp_get_transformation_summary (cgraph_node *node)
699 { 718 {
700 if ((unsigned) node->uid >= vec_safe_length (ipcp_transformations)) 719 if (ipcp_transformation_sum == NULL)
701 return NULL; 720 return NULL;
702 return &(*ipcp_transformations)[node->uid]; 721
722 return ipcp_transformation_sum->get (node);
703 } 723 }
704 724
705 /* Return the aggregate replacements for NODE, if there are any. */ 725 /* Return the aggregate replacements for NODE, if there are any. */
706 726
707 static inline struct ipa_agg_replacement_value * 727 static inline struct ipa_agg_replacement_value *
708 ipa_get_agg_replacements_for_node (cgraph_node *node) 728 ipa_get_agg_replacements_for_node (cgraph_node *node)
709 { 729 {
710 ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); 730 ipcp_transformation *ts = ipcp_get_transformation_summary (node);
711 return ts ? ts->agg_values : NULL; 731 return ts ? ts->agg_values : NULL;
712 } 732 }
713 733
714 /* Function formal parameters related computations. */ 734 /* Function formal parameters related computations. */
715 void ipa_initialize_node_params (struct cgraph_node *node); 735 void ipa_initialize_node_params (struct cgraph_node *node);
763 783
764 class ipcp_agg_lattice; 784 class ipcp_agg_lattice;
765 785
766 extern object_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool; 786 extern object_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool;
767 787
768 /* Operation to be performed for the parameter in ipa_parm_adjustment
769 below. */
770 enum ipa_parm_op {
771 IPA_PARM_OP_NONE,
772
773 /* This describes a brand new parameter.
774
775 The field `type' should be set to the new type, `arg_prefix'
776 should be set to the string prefix for the new DECL_NAME, and
777 `new_decl' will ultimately hold the newly created argument. */
778 IPA_PARM_OP_NEW,
779
780 /* This new parameter is an unmodified parameter at index base_index. */
781 IPA_PARM_OP_COPY,
782
783 /* This adjustment describes a parameter that is about to be removed
784 completely. Most users will probably need to book keep those so that they
785 don't leave behinfd any non default def ssa names belonging to them. */
786 IPA_PARM_OP_REMOVE
787 };
788
789 /* Structure to describe transformations of formal parameters and actual
790 arguments. Each instance describes one new parameter and they are meant to
791 be stored in a vector. Additionally, most users will probably want to store
792 adjustments about parameters that are being removed altogether so that SSA
793 names belonging to them can be replaced by SSA names of an artificial
794 variable. */
795 struct ipa_parm_adjustment
796 {
797 /* The original PARM_DECL itself, helpful for processing of the body of the
798 function itself. Intended for traversing function bodies.
799 ipa_modify_formal_parameters, ipa_modify_call_arguments and
800 ipa_combine_adjustments ignore this and use base_index.
801 ipa_modify_formal_parameters actually sets this. */
802 tree base;
803
804 /* Type of the new parameter. However, if by_ref is true, the real type will
805 be a pointer to this type. */
806 tree type;
807
808 /* Alias refrerence type to be used in MEM_REFs when adjusting caller
809 arguments. */
810 tree alias_ptr_type;
811
812 /* The new declaration when creating/replacing a parameter. Created
813 by ipa_modify_formal_parameters, useful for functions modifying
814 the body accordingly. For brand new arguments, this is the newly
815 created argument. */
816 tree new_decl;
817
818 /* New declaration of a substitute variable that we may use to replace all
819 non-default-def ssa names when a parm decl is going away. */
820 tree new_ssa_base;
821
822 /* If non-NULL and the original parameter is to be removed (copy_param below
823 is NULL), this is going to be its nonlocalized vars value. */
824 tree nonlocal_value;
825
826 /* This holds the prefix to be used for the new DECL_NAME. */
827 const char *arg_prefix;
828
829 /* Offset into the original parameter (for the cases when the new parameter
830 is a component of an original one). */
831 HOST_WIDE_INT offset;
832
833 /* Zero based index of the original parameter this one is based on. */
834 int base_index;
835
836 /* Whether this parameter is a new parameter, a copy of an old one,
837 or one about to be removed. */
838 enum ipa_parm_op op;
839
840 /* Storage order of the original parameter (for the cases when the new
841 parameter is a component of an original one). */
842 unsigned reverse : 1;
843
844 /* The parameter is to be passed by reference. */
845 unsigned by_ref : 1;
846 };
847
848 typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
849
850 vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
851 vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
852 void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
853 void ipa_modify_call_arguments (struct cgraph_edge *, gcall *,
854 ipa_parm_adjustment_vec);
855 ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
856 ipa_parm_adjustment_vec);
857 void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
858 void ipa_dump_agg_replacement_values (FILE *f, 788 void ipa_dump_agg_replacement_values (FILE *f,
859 struct ipa_agg_replacement_value *av); 789 struct ipa_agg_replacement_value *av);
860 void ipa_prop_write_jump_functions (void); 790 void ipa_prop_write_jump_functions (void);
861 void ipa_prop_read_jump_functions (void); 791 void ipa_prop_read_jump_functions (void);
862 void ipcp_write_transformation_summaries (void); 792 void ipcp_write_transformation_summaries (void);
863 void ipcp_read_transformation_summaries (void); 793 void ipcp_read_transformation_summaries (void);
864 int ipa_get_param_decl_index (struct ipa_node_params *, tree); 794 int ipa_get_param_decl_index (struct ipa_node_params *, tree);
865 tree ipa_value_from_jfunc (struct ipa_node_params *info, 795 tree ipa_value_from_jfunc (struct ipa_node_params *info,
866 struct ipa_jump_func *jfunc); 796 struct ipa_jump_func *jfunc, tree type);
867 unsigned int ipcp_transform_function (struct cgraph_node *node); 797 unsigned int ipcp_transform_function (struct cgraph_node *node);
868 ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *, 798 ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
869 cgraph_edge *, 799 cgraph_edge *,
870 int, 800 int,
871 ipa_jump_func *); 801 ipa_jump_func *);
872 void ipa_dump_param (FILE *, struct ipa_node_params *info, int i); 802 void ipa_dump_param (FILE *, struct ipa_node_params *info, int i);
873 bool ipa_modify_expr (tree *, bool, ipa_parm_adjustment_vec);
874 ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *,
875 ipa_parm_adjustment_vec,
876 bool);
877 void ipa_release_body_info (struct ipa_func_body_info *); 803 void ipa_release_body_info (struct ipa_func_body_info *);
878 tree ipa_get_callee_param_type (struct cgraph_edge *e, int i); 804 tree ipa_get_callee_param_type (struct cgraph_edge *e, int i);
879 805
880 /* From tree-sra.c: */ 806 /* From tree-sra.c: */
881 tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, bool, tree, 807 tree build_ref_for_offset (location_t, tree, poly_int64, bool, tree,
882 gimple_stmt_iterator *, bool); 808 gimple_stmt_iterator *, bool);
883 809
884 /* In ipa-cp.c */ 810 /* In ipa-cp.c */
885 void ipa_cp_c_finalize (void); 811 void ipa_cp_c_finalize (void);
886 812