1*38fd1498Szrj /* Manipulation of formal and actual parameters of functions and function 2*38fd1498Szrj calls. 3*38fd1498Szrj Copyright (C) 2017-2018 Free Software Foundation, Inc. 4*38fd1498Szrj 5*38fd1498Szrj This file is part of GCC. 6*38fd1498Szrj 7*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under 8*38fd1498Szrj the terms of the GNU General Public License as published by the Free 9*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later 10*38fd1498Szrj version. 11*38fd1498Szrj 12*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or 14*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15*38fd1498Szrj for more details. 16*38fd1498Szrj 17*38fd1498Szrj You should have received a copy of the GNU General Public License 18*38fd1498Szrj along with GCC; see the file COPYING3. If not see 19*38fd1498Szrj <http://www.gnu.org/licenses/>. */ 20*38fd1498Szrj 21*38fd1498Szrj #ifndef IPA_PARAM_MANIPULATION_H 22*38fd1498Szrj #define IPA_PARAM_MANIPULATION_H 23*38fd1498Szrj 24*38fd1498Szrj /* Operation to be performed for the parameter in ipa_parm_adjustment 25*38fd1498Szrj below. */ 26*38fd1498Szrj enum ipa_parm_op { 27*38fd1498Szrj IPA_PARM_OP_NONE, 28*38fd1498Szrj 29*38fd1498Szrj /* This describes a brand new parameter. 30*38fd1498Szrj 31*38fd1498Szrj The field `type' should be set to the new type, `arg_prefix' 32*38fd1498Szrj should be set to the string prefix for the new DECL_NAME, and 33*38fd1498Szrj `new_decl' will ultimately hold the newly created argument. */ 34*38fd1498Szrj IPA_PARM_OP_NEW, 35*38fd1498Szrj 36*38fd1498Szrj /* This new parameter is an unmodified parameter at index base_index. */ 37*38fd1498Szrj IPA_PARM_OP_COPY, 38*38fd1498Szrj 39*38fd1498Szrj /* This adjustment describes a parameter that is about to be removed 40*38fd1498Szrj completely. Most users will probably need to book keep those so that they 41*38fd1498Szrj don't leave behinfd any non default def ssa names belonging to them. */ 42*38fd1498Szrj IPA_PARM_OP_REMOVE 43*38fd1498Szrj }; 44*38fd1498Szrj 45*38fd1498Szrj /* Structure to describe transformations of formal parameters and actual 46*38fd1498Szrj arguments. Each instance describes one new parameter and they are meant to 47*38fd1498Szrj be stored in a vector. Additionally, most users will probably want to store 48*38fd1498Szrj adjustments about parameters that are being removed altogether so that SSA 49*38fd1498Szrj names belonging to them can be replaced by SSA names of an artificial 50*38fd1498Szrj variable. */ 51*38fd1498Szrj struct ipa_parm_adjustment 52*38fd1498Szrj { 53*38fd1498Szrj /* The original PARM_DECL itself, helpful for processing of the body of the 54*38fd1498Szrj function itself. Intended for traversing function bodies. 55*38fd1498Szrj ipa_modify_formal_parameters, ipa_modify_call_arguments and 56*38fd1498Szrj ipa_combine_adjustments ignore this and use base_index. 57*38fd1498Szrj ipa_modify_formal_parameters actually sets this. */ 58*38fd1498Szrj tree base; 59*38fd1498Szrj 60*38fd1498Szrj /* Type of the new parameter. However, if by_ref is true, the real type will 61*38fd1498Szrj be a pointer to this type. */ 62*38fd1498Szrj tree type; 63*38fd1498Szrj 64*38fd1498Szrj /* Alias refrerence type to be used in MEM_REFs when adjusting caller 65*38fd1498Szrj arguments. */ 66*38fd1498Szrj tree alias_ptr_type; 67*38fd1498Szrj 68*38fd1498Szrj /* The new declaration when creating/replacing a parameter. Created 69*38fd1498Szrj by ipa_modify_formal_parameters, useful for functions modifying 70*38fd1498Szrj the body accordingly. For brand new arguments, this is the newly 71*38fd1498Szrj created argument. */ 72*38fd1498Szrj tree new_decl; 73*38fd1498Szrj 74*38fd1498Szrj /* New declaration of a substitute variable that we may use to replace all 75*38fd1498Szrj non-default-def ssa names when a parm decl is going away. */ 76*38fd1498Szrj tree new_ssa_base; 77*38fd1498Szrj 78*38fd1498Szrj /* If non-NULL and the original parameter is to be removed (copy_param below 79*38fd1498Szrj is NULL), this is going to be its nonlocalized vars value. */ 80*38fd1498Szrj tree nonlocal_value; 81*38fd1498Szrj 82*38fd1498Szrj /* This holds the prefix to be used for the new DECL_NAME. */ 83*38fd1498Szrj const char *arg_prefix; 84*38fd1498Szrj 85*38fd1498Szrj /* Offset into the original parameter (for the cases when the new parameter 86*38fd1498Szrj is a component of an original one). */ 87*38fd1498Szrj poly_int64_pod offset; 88*38fd1498Szrj 89*38fd1498Szrj /* Zero based index of the original parameter this one is based on. */ 90*38fd1498Szrj int base_index; 91*38fd1498Szrj 92*38fd1498Szrj /* Whether this parameter is a new parameter, a copy of an old one, 93*38fd1498Szrj or one about to be removed. */ 94*38fd1498Szrj enum ipa_parm_op op; 95*38fd1498Szrj 96*38fd1498Szrj /* Storage order of the original parameter (for the cases when the new 97*38fd1498Szrj parameter is a component of an original one). */ 98*38fd1498Szrj unsigned reverse : 1; 99*38fd1498Szrj 100*38fd1498Szrj /* The parameter is to be passed by reference. */ 101*38fd1498Szrj unsigned by_ref : 1; 102*38fd1498Szrj }; 103*38fd1498Szrj 104*38fd1498Szrj typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec; 105*38fd1498Szrj 106*38fd1498Szrj vec<tree> ipa_get_vector_of_formal_parms (tree fndecl); 107*38fd1498Szrj vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype); 108*38fd1498Szrj void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec); 109*38fd1498Szrj void ipa_modify_call_arguments (struct cgraph_edge *, gcall *, 110*38fd1498Szrj ipa_parm_adjustment_vec); 111*38fd1498Szrj ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec, 112*38fd1498Szrj ipa_parm_adjustment_vec); 113*38fd1498Szrj void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree); 114*38fd1498Szrj 115*38fd1498Szrj bool ipa_modify_expr (tree *, bool, ipa_parm_adjustment_vec); 116*38fd1498Szrj ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *, 117*38fd1498Szrj ipa_parm_adjustment_vec, 118*38fd1498Szrj bool); 119*38fd1498Szrj 120*38fd1498Szrj #endif /* IPA_PARAM_MANIPULATION_H */ 121