This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH tree profiling branch] Support for different constant types in IPCP


Hello,

Attached is code to handle cases in which the constant sent by the 
callsite and the 
formal parameter of the callee are not of the same type. (could happen for 
old C style cases)
Also, some cleanups in the code dealing with building of constants.

Comments are welcome,
Thanks,
Razya

2005-04-03  Razya Ladelsky  <razya@il.ibm.com>

 * ipa_prop.c (ipcp_callsite_compute_param): Add check to make sure the 
constant sent in the 
   callsite and the formal parameter of the callee are of the same type. 
   (build_const_val): Add another parameter, the type of the constant that 
should be built.
   (ipcp_propagate_const, ipcp_replace_map_create): Call build_const_val 
with type parameter.
   (ipcp_method_cval_print): Add support for reference to constants formal 
parameters (as in fortran).
 

Index: ipa_prop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ipa_prop.c,v
retrieving revision 1.1.2.5
diff -c -3 -p -r1.1.2.5 ipa_prop.c
*** ipa_prop.c  21 Mar 2005 09:08:52 -0000      1.1.2.5
--- ipa_prop.c  3 Apr 2005 09:03:20 -0000
*************** ipcp_callsite_compute_param (ipcp_callsi
*** 476,491 ****
        }
        else if (TREE_CODE (TREE_VALUE (arg)) == INTEGER_CST)
        {
!         ipcp_callsite_param_set_type (cs, arg_num, CONST_IPATYPE_INT);
!         ipcp_callsite_param_set_info_type_int (cs, arg_num,
                                             &TREE_INT_CST (TREE_VALUE 
(arg)));
        }
        else if (TREE_CODE (TREE_VALUE (arg)) == REAL_CST)
          {
!           ipcp_callsite_param_set_type (cs, arg_num, 
CONST_IPATYPE_FLOAT);
!         ipcp_callsite_param_set_info_type_float (cs, arg_num,
!                                            TREE_REAL_CST_PTR (TREE_VALUE 
(arg)));
!
        }
        else if (TREE_CODE (TREE_VALUE (arg)) == ADDR_EXPR)
        {
--- 476,503 ----
        }
        else if (TREE_CODE (TREE_VALUE (arg)) == INTEGER_CST)
        {
!           if (TREE_TYPE (TREE_VALUE (arg))
!               != TREE_TYPE (ipcp_method_get_tree (cs->callee, arg_num)))
!             ipcp_callsite_param_set_type (cs, arg_num, UNKNOWN_IPATYPE);
!
!         else
!           {
!             ipcp_callsite_param_set_type (cs, arg_num, 
CONST_IPATYPE_INT);
!             ipcp_callsite_param_set_info_type_int (cs, arg_num,
                                             &TREE_INT_CST (TREE_VALUE 
(arg)));
+           }
        }
        else if (TREE_CODE (TREE_VALUE (arg)) == REAL_CST)
          {
!           if (TREE_TYPE (TREE_VALUE (arg))
!               != TREE_TYPE (ipcp_method_get_tree (cs->callee, arg_num)))
!             ipcp_callsite_param_set_type (cs, arg_num, UNKNOWN_IPATYPE);
!           else
!           {
!             ipcp_callsite_param_set_type (cs, arg_num, 
CONST_IPATYPE_FLOAT);
!             ipcp_callsite_param_set_info_type_float (cs, arg_num,
!                                                      TREE_REAL_CST_PTR 
(TREE_VALUE (arg)));
!           }
        }
        else if (TREE_CODE (TREE_VALUE (arg)) == ADDR_EXPR)
        {
*************** ipcp_callsite_compute_param (ipcp_callsi
*** 494,510 ****
              cst_decl = TREE_OPERAND (TREE_VALUE (arg), 0);
              if (TREE_CODE (DECL_INITIAL (cst_decl)) == INTEGER_CST)
                {
!                 ipcp_callsite_param_set_type (cs, arg_num, 
CONST_IPATYPE_INT_REF);
!                 ipcp_callsite_param_set_info_type_int (cs, arg_num,
!                                                     &TREE_INT_CST 
(DECL_INITIAL (cst_decl)));
                }
              else if (TREE_CODE (DECL_INITIAL (cst_decl)) == REAL_CST)
                {
!                 cst_decl =  TREE_OPERAND (TREE_VALUE (arg), 0);
!                 ipcp_callsite_param_set_type (cs, arg_num, 
CONST_IPATYPE_FLOAT_REF);
!                 ipcp_callsite_param_set_info_type_float (cs, arg_num,
 TREE_REAL_CST_PTR (DECL_INITIAL (cst_decl)));
!               }
              else
                ipcp_callsite_param_set_type (cs, arg_num, 
UNKNOWN_IPATYPE);
            }
--- 506,535 ----
             cst_decl = TREE_OPERAND (TREE_VALUE (arg), 0);
              if (TREE_CODE (DECL_INITIAL (cst_decl)) == INTEGER_CST)
                {
!                   if (TREE_TYPE (DECL_INITIAL (cst_decl))
!                       != TREE_TYPE (TREE_TYPE (ipcp_method_get_tree 
(cs->callee, arg_num))))
!                           ipcp_callsite_param_set_type (cs, arg_num, 
UNKNOWN_IPATYPE);
!
!                   else
!                   {
!                     ipcp_callsite_param_set_type (cs, arg_num, 
CONST_IPATYPE_INT_REF);
!                     ipcp_callsite_param_set_info_type_int (cs, arg_num,
!                                                            &TREE_INT_CST 
(DECL_INITIAL (cst_decl)));
!                   }
                }
              else if (TREE_CODE (DECL_INITIAL (cst_decl)) == REAL_CST)
                {
!                   if (TREE_TYPE (DECL_INITIAL (cst_decl))
!                       != TREE_TYPE (TREE_TYPE (ipcp_method_get_tree 
(cs->callee, arg_num))))
!                   ipcp_callsite_param_set_type (cs, arg_num, 
UNKNOWN_IPATYPE);
!                   else
!                   {
!                     cst_decl =  TREE_OPERAND (TREE_VALUE (arg), 0);
!                     ipcp_callsite_param_set_type (cs, arg_num, 
CONST_IPATYPE_FLOAT_REF);
!                     ipcp_callsite_param_set_info_type_float (cs, 
arg_num,
 TREE_REAL_CST_PTR (DECL_INITIAL (cst_decl)));
!                   }
!                   }
              else
                ipcp_callsite_param_set_type (cs, arg_num, 
UNKNOWN_IPATYPE);
            }
*************** constant_val_insert (tree fn, tree parm1
*** 1027,1041 ****
  }

  static tree
! build_const_val (union info *cvalue, enum Cvalue_type type)
  {
    tree const_val;

    if (type == CONST_VALUE_INT ||  type ==  CONST_VALUE_INT_REF)
!     const_val = build_int_cst_wide (NULL_TREE, cvalue->int_value.low,
!                                   cvalue->int_value.high);
    else if (type == CONST_VALUE_FLOAT || type == CONST_VALUE_FLOAT_REF)
!     const_val = build_real ( float_type_node, cvalue->float_value);
    else
      abort ();
    return const_val;
--- 1052,1066 ----
  }

  static tree
! build_const_val (union info *cvalue, enum Cvalue_type type, tree 
tree_type)
  {
    tree const_val;

    if (type == CONST_VALUE_INT ||  type ==  CONST_VALUE_INT_REF)
!     const_val = build_int_cst_wide (tree_type, cvalue->int_value.low,
!                                     cvalue->int_value.high);
    else if (type == CONST_VALUE_FLOAT || type == CONST_VALUE_FLOAT_REF)
!     const_val = build_real (tree_type, cvalue->float_value);
    else
      abort ();
    return const_val;
*************** ipcp_propagate_const (ipcp_method mt, in
*** 1056,1068 ****
               cgraph_node_name (mt));
    fndecl = mt->decl;
    parm_tree = ipcp_method_get_tree (mt, param);
!   if (type == CONST_VALUE_INT)
!     const_val = build_int_cst_wide (NULL_TREE, cvalue->int_value.low,
!                                   cvalue->int_value.high);
!   else if (type == CONST_VALUE_FLOAT)
!     const_val = build_real ( TREE_TYPE (parm_tree), 
cvalue->float_value);
!   else
!     abort ();
    if (parm_tree != NULL)
      if(fndecl != NULL)
        constant_val_insert (fndecl, parm_tree, const_val);
--- 1081,1087 ----
               cgraph_node_name (mt));
    fndecl = mt->decl;
    parm_tree = ipcp_method_get_tree (mt, param);
!   const_val = build_const_val (cvalue, type, TREE_TYPE (parm_tree));
    if (parm_tree != NULL)
      if(fndecl != NULL)
        constant_val_insert (fndecl, parm_tree, const_val);
*************** ipcp_replace_map_create (enum Cvalue_typ
*** 1196,1202 ****
    gcc_assert (ipcp_type_is_const (type));
    if (type == CONST_VALUE_INT_REF || type == CONST_VALUE_FLOAT_REF)
      {
!       const_val = build_const_val (cvalue, type);
        replace_map->old_tree = parm_tree;
        replace_map->new_tree = const_val;
        replace_map->replace_p = true;
--- 1215,1221 ----
    gcc_assert (ipcp_type_is_const (type));
    if (type == CONST_VALUE_INT_REF || type == CONST_VALUE_FLOAT_REF)
      {
!       const_val = build_const_val (cvalue, type, TREE_TYPE (TREE_TYPE 
(parm_tree)));
        replace_map->old_tree = parm_tree;
        replace_map->new_tree = const_val;
        replace_map->replace_p = true;
*************** ipcp_replace_map_create (enum Cvalue_typ
*** 1204,1210 ****
      }
    else if (TREE_READONLY (parm_tree) && !TREE_ADDRESSABLE (parm_tree))
      {
!       const_val = build_const_val (cvalue, type);
        replace_map->old_tree = parm_tree;
        replace_map->new_tree = const_val;
        replace_map->replace_p = true;
--- 1223,1229 ----
      }
    else if (TREE_READONLY (parm_tree) && !TREE_ADDRESSABLE (parm_tree))
      {
!       const_val = build_const_val (cvalue, type, TREE_TYPE (parm_tree));
        replace_map->old_tree = parm_tree;
        replace_map->new_tree = const_val;
        replace_map->replace_p = true;
*************** ipcp_method_cval_print (FILE *f)
*** 1508,1514 ****
        for(i = 0; i < count; i++)
          {
            if (ipcp_cval_get_cvalue_type (ipcp_method_cval (node, i))
!               == CONST_VALUE_INT)
              {
                fprintf (f, " param [%d]: ", i);
                fprintf (f, "type is CONST_INT ");
--- 1527,1534 ----
        for(i = 0; i < count; i++)
          {
            if (ipcp_cval_get_cvalue_type (ipcp_method_cval (node, i))
!               == CONST_VALUE_INT || ipcp_cval_get_cvalue_type 
(ipcp_method_cval (node, i))
!               == CONST_VALUE_INT_REF)
              {
                fprintf (f, " param [%d]: ", i);
                fprintf (f, "type is CONST_INT ");
*************** ipcp_method_cval_print (FILE *f)
*** 1518,1524 ****
                         cvalue->high, cvalue->low);
              }
            else if (ipcp_cval_get_cvalue_type (ipcp_method_cval (node, 
i))
!               == CONST_VALUE_FLOAT)
            {
              char string[100];
                REAL_VALUE_TYPE d;
--- 1538,1545 ----
                         cvalue->high, cvalue->low);
              }
            else if (ipcp_cval_get_cvalue_type (ipcp_method_cval (node, 
i))
!               == CONST_VALUE_FLOAT || ipcp_cval_get_cvalue_type 
(ipcp_method_cval (node, i))
!               == CONST_VALUE_FLOAT_REF)
            {
              char string[100];
                REAL_VALUE_TYPE d;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]