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]

Patch to create builtin bcmp


	 This patch creates a new builtin bcmp.  It operates by simply
calling builtin memcmp.  This patch depends on
http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00747.html

Bootstrapped on i686-pc-linux-gnu and sparc-sun-solaris2.7, no regressions.
Okay to install?

		--Kaveh


2000-03-21  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* builtins.c (expand_builtin): Handle bcmp.

	* builtins.def: Add BUILT_IN_BCMP.

	* c-common.c (c_common_nodes_and_builtins): Provide builtin
	prototype & function for bcmp.

diff -rup orig/egcs-CVS20000321/gcc/builtins.c egcs-CVS20000321/gcc/builtins.c
--- orig/egcs-CVS20000321/gcc/builtins.c	Tue Mar 21 22:40:20 2000
+++ egcs-CVS20000321/gcc/builtins.c	Tue Mar 21 22:41:59 2000
@@ -2429,7 +2429,7 @@ expand_builtin (exp, target, subtarget, 
       && (fcode == BUILT_IN_SIN || fcode == BUILT_IN_COS
 	  || fcode == BUILT_IN_FSQRT || fcode == BUILT_IN_MEMSET
 	  || fcode == BUILT_IN_MEMCPY || fcode == BUILT_IN_MEMCMP
-	  || fcode == BUILT_IN_BZERO
+	  || fcode == BUILT_IN_BZERO || fcode == BUILT_IN_BCMP
 	  || fcode == BUILT_IN_STRLEN || fcode == BUILT_IN_STRCPY
 	  || fcode == BUILT_IN_STRCMP || fcode == BUILT_IN_STRNCMP
 	  || fcode == BUILT_IN_FFS))
@@ -2590,6 +2590,7 @@ expand_builtin (exp, target, subtarget, 
 	return target;
       break;
       
+    case BUILT_IN_BCMP:
     case BUILT_IN_MEMCMP:
       target = expand_builtin_memcmp (exp, arglist, target);
       if (target)
@@ -2598,6 +2599,7 @@ expand_builtin (exp, target, subtarget, 
 #else
     case BUILT_IN_STRCMP:
     case BUILT_IN_STRNCMP:
+    case BUILT_IN_BCMP:
     case BUILT_IN_MEMCMP:
       break;
 #endif
diff -rup orig/egcs-CVS20000321/gcc/builtins.def egcs-CVS20000321/gcc/builtins.def
--- orig/egcs-CVS20000321/gcc/builtins.def	Tue Mar 21 22:40:20 2000
+++ egcs-CVS20000321/gcc/builtins.def	Tue Mar 21 22:40:47 2000
@@ -34,6 +34,7 @@ DEF_BUILTIN(BUILT_IN_MEMCPY)
 DEF_BUILTIN(BUILT_IN_MEMCMP)
 DEF_BUILTIN(BUILT_IN_MEMSET)
 DEF_BUILTIN(BUILT_IN_BZERO)
+DEF_BUILTIN(BUILT_IN_BCMP)
 DEF_BUILTIN(BUILT_IN_STRCPY)
 DEF_BUILTIN(BUILT_IN_STRCMP)
 DEF_BUILTIN(BUILT_IN_STRNCMP)
diff -rup orig/egcs-CVS20000321/gcc/c-common.c egcs-CVS20000321/gcc/c-common.c
--- orig/egcs-CVS20000321/gcc/c-common.c	Tue Mar 21 22:40:20 2000
+++ egcs-CVS20000321/gcc/c-common.c	Tue Mar 21 22:54:30 2000
@@ -3464,11 +3464,11 @@ c_common_nodes_and_builtins (cplus_mode,
 {
   tree temp;
   tree memcpy_ftype, memset_ftype, strlen_ftype;
-  tree strncmp_ftype, bzero_ftype;
+  tree strncmp_ftype, bzero_ftype, bcmp_ftype;
   tree endlink, int_endlink, double_endlink, unsigned_endlink;
   tree sizetype_endlink;
   tree ptr_ftype, ptr_ftype_unsigned;
-  tree void_ftype_any, void_ftype_int;
+  tree void_ftype_any, void_ftype_int, int_ftype_any;
   tree double_ftype_double, double_ftype_double_double;
   tree float_ftype_float, ldouble_ftype_ldouble;
   tree int_ftype_cptr_cptr_sizet;
@@ -3476,6 +3476,8 @@ c_common_nodes_and_builtins (cplus_mode,
   tree long_ftype_long;
   /* Either char* or void*.  */
   tree traditional_ptr_type_node;
+  /* Either const char* or const void*.  */
+  tree traditional_cptr_type_node;
   tree traditional_len_type_node;
   tree traditional_len_endlink;
   tree va_list_ptr_type_node;
@@ -3508,6 +3510,7 @@ c_common_nodes_and_builtins (cplus_mode,
   /* We realloc here because sizetype could be int or unsigned.  S'ok.  */
   ptr_ftype_sizetype = build_function_type (ptr_type_node, sizetype_endlink);
 
+  int_ftype_any = build_function_type (integer_type_node, NULL_TREE);
   void_ftype_any = build_function_type (void_type_node, NULL_TREE);
   void_ftype = build_function_type (void_type_node, endlink);
   void_ftype_int = build_function_type (void_type_node, int_endlink);
@@ -3585,6 +3588,9 @@ c_common_nodes_and_builtins (cplus_mode,
 
   traditional_ptr_type_node = (flag_traditional && ! cplus_mode
 			       ? string_type_node : ptr_type_node);
+  traditional_cptr_type_node = (flag_traditional && ! cplus_mode
+				? const_string_type_node : const_ptr_type_node);
+  
 
   /* Prototype for memcpy.  */
   memcpy_ftype
@@ -3608,6 +3614,14 @@ c_common_nodes_and_builtins (cplus_mode,
 			   tree_cons (NULL_TREE, traditional_ptr_type_node,
 				      traditional_len_endlink));
 
+  /* Prototype for bcmp.  */
+  bcmp_ftype
+    = build_function_type (integer_type_node,
+			   tree_cons (NULL_TREE, traditional_cptr_type_node,
+				      tree_cons (NULL_TREE,
+						 traditional_cptr_type_node,
+						 traditional_len_endlink)));
+
   builtin_function ("__builtin_constant_p", default_function_type,
 		    BUILT_IN_CONSTANT_P, BUILT_IN_NORMAL, NULL_PTR);
 
@@ -3623,6 +3637,8 @@ c_common_nodes_and_builtins (cplus_mode,
 		    BUILT_IN_NORMAL, NULL_PTR);
   builtin_function ("__builtin_bzero", bzero_ftype, BUILT_IN_BZERO,
 		    BUILT_IN_NORMAL, "bzero");
+  builtin_function ("__builtin_bcmp", bcmp_ftype, BUILT_IN_BCMP,
+		    BUILT_IN_NORMAL, "bcmp");
   /* Define alloca, ffs as builtins.
      Declare _exit just to mark it as volatile.  */
   if (! no_builtins && ! no_nonansi_builtins)
@@ -3648,6 +3664,10 @@ c_common_nodes_and_builtins (cplus_mode,
       temp = builtin_function ("bzero",
 			       cplus_mode ? bzero_ftype : void_ftype_any,
 			       BUILT_IN_BZERO, BUILT_IN_NORMAL, NULL_PTR);
+      DECL_BUILT_IN_NONANSI (temp) = 1;
+      temp = builtin_function ("bcmp",
+			       cplus_mode ? bcmp_ftype : int_ftype_any,
+			       BUILT_IN_BCMP, BUILT_IN_NORMAL, NULL_PTR);
       DECL_BUILT_IN_NONANSI (temp) = 1;
     }
 

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