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]

[lto] Use num_parm_types, nth_parm_types, and nth_parm_type_ptr in split_complex_types.


Hi,

Attached is a patch to use num_parm_types, nth_parm_types, and
nth_parm_type_ptr in split_complex_types.

In the original version of split_complex_types, we look for the first
complex parameter.  Once a complex parameter is found, we start
constructing a new parameter list.

With this patch, we count the number of complex parameters so that we
know how long the resulting parameter list is going to be.  We need to
know the length of the new parameter list because we are planning to
use a TREE_VEC in TYPE_ARG_TYPES.

Tested on x86_64-pc-linux-gnu.  Committed to the LTO branch as
obvious.

Kazu Hirata

2006-07-20  Kazu Hirata  <kazu@codesourcery.com>

	* calls.c (split_complex_types): Use num_parm_types,
	nth_parm_types, and nth_parm_type_ptr.

Index: calls.c
===================================================================
*** calls.c	(revision 115613)
--- calls.c	(working copy)
***************
*** 3167,3211 ****
  static tree
  split_complex_types (tree types)
  {
!   tree p;
  
!   /* Before allocating memory, check for the common case of no complex.  */
!   for (p = types; p; p = TREE_CHAIN (p))
      {
!       tree type = TREE_VALUE (p);
        if (TREE_CODE (type) == COMPLEX_TYPE
  	  && targetm.calls.split_complex_arg (type))
! 	goto found;
      }
-   return types;
  
!  found:
!   types = copy_list (types);
  
!   for (p = types; p; p = TREE_CHAIN (p))
      {
!       tree complex_type = TREE_VALUE (p);
  
!       if (TREE_CODE (complex_type) == COMPLEX_TYPE
! 	  && targetm.calls.split_complex_arg (complex_type))
  	{
! 	  tree next, imag;
! 
! 	  /* Rewrite complex type with component type.  */
! 	  TREE_VALUE (p) = TREE_TYPE (complex_type);
! 	  next = TREE_CHAIN (p);
! 
! 	  /* Add another component type for the imaginary part.  */
! 	  imag = build_tree_list (NULL_TREE, TREE_VALUE (p));
! 	  TREE_CHAIN (p) = imag;
! 	  TREE_CHAIN (imag) = next;
! 
! 	  /* Skip the newly created node.  */
! 	  p = TREE_CHAIN (p);
  	}
      }
  
!   return types;
  }
  
  /* Output a library call to function FUN (a SYMBOL_REF rtx).
--- 3167,3207 ----
  static tree
  split_complex_types (tree types)
  {
!   tree new_types;
!   int num_complex = 0;
!   tree type;
!   int len;
!   int i, j;
  
!   len = num_parm_types (types);
!   for (i = 0; i < len; i++)
      {
!       type = nth_parm_type (types, i);
        if (TREE_CODE (type) == COMPLEX_TYPE
  	  && targetm.calls.split_complex_arg (type))
! 	num_complex++;
      }
  
!   if (num_complex == 0)
!     return types;
  
!   new_types = alloc_parm_types (len + num_complex);
!   for (i = j = 0; i < len; i++, j++)
      {
!       type = nth_parm_type (types, i);
  
!       if (TREE_CODE (type) == COMPLEX_TYPE
! 	  && targetm.calls.split_complex_arg (type))
  	{
! 	  *(nth_parm_type_ptr (new_types, j)) = TREE_TYPE (type);
! 	  j++;
! 	  *(nth_parm_type_ptr (new_types, j)) = TREE_TYPE (type);
  	}
+       else
+ 	*(nth_parm_type_ptr (new_types, j)) = type;
      }
  
!   return new_types;
  }
  
  /* Output a library call to function FUN (a SYMBOL_REF rtx).


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