Patch to create builtin bzero

Richard Henderson rth@cygnus.com
Fri Mar 24 15:49:00 GMT 2000


On Fri, Mar 24, 2000 at 03:23:23PM -0500, Kaveh R. Ghazi wrote:
> +2000-03-24  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
> +
> +	* builtins.c (expand_builtin_bzero): New function.
> +	(expand_builtin): Handle bzero.

This patch is needed on targets where size_t > int.


r~


        * builtins.c (expand_builtin_bzero): Convert `length' argument
        to sizetype.

Index: builtins.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/builtins.c,v
retrieving revision 1.40
diff -c -p -d -r1.40 builtins.c
*** builtins.c	2000/03/24 20:20:56	1.40
--- builtins.c	2000/03/24 23:42:42
*************** expand_builtin_bzero (exp)
*** 1582,1614 ****
       tree exp;
  {
    tree arglist = TREE_OPERAND (exp, 1);
  
    if (arglist == 0
        /* Arg could be non-pointer if user redeclared this fcn wrong.  */
!       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
        || TREE_CHAIN (arglist) == 0
!       || (TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist))))
  	  != INTEGER_TYPE))
!     return 0;
!   else
!     {
!       tree newarglist;
!       rtx result;
  
!       /* New argument list transforming bzero(x, y) -> memset(x, 0, y).  */
!       newarglist = build_tree_list (NULL_TREE, TREE_VALUE (arglist));
!       chainon (newarglist, build_tree_list (NULL_TREE, integer_zero_node));
!       chainon (newarglist,
! 	       build_tree_list (NULL_TREE, TREE_VALUE (TREE_CHAIN (arglist))));
!       TREE_OPERAND (exp, 1) = newarglist;
  
!       result = expand_builtin_memset(exp);
        
!       /* Always restore the original arguments.  */
!       TREE_OPERAND (exp, 1) = arglist;
  
!       return result;
!     }
  }
  
  #ifdef HAVE_cmpstrsi
--- 1582,1612 ----
       tree exp;
  {
    tree arglist = TREE_OPERAND (exp, 1);
+   tree dest, size, newarglist;
+   rtx result;
  
    if (arglist == 0
        /* Arg could be non-pointer if user redeclared this fcn wrong.  */
!       || TREE_CODE (TREE_TYPE (dest = TREE_VALUE (arglist))) != POINTER_TYPE
        || TREE_CHAIN (arglist) == 0
!       || (TREE_CODE (TREE_TYPE (size = TREE_VALUE (TREE_CHAIN (arglist))))
  	  != INTEGER_TYPE))
!     return NULL_RTX;
  
!   /* New argument list transforming bzero(ptr x, int y) to
!      memset(ptr x, int 0, size_t y).  */
!   
!   newarglist = build_tree_list (NULL_TREE, convert (sizetype, size));
!   newarglist = tree_cons (NULL_TREE, integer_zero_node, newarglist);
!   newarglist = tree_cons (NULL_TREE, dest, newarglist);
  
!   TREE_OPERAND (exp, 1) = newarglist;
!   result = expand_builtin_memset(exp);
        
!   /* Always restore the original arguments.  */
!   TREE_OPERAND (exp, 1) = arglist;
  
!   return result;
  }
  
  #ifdef HAVE_cmpstrsi


More information about the Gcc-patches mailing list