* builtins.c (expand_builtin_bzero): New function.
(expand_builtin): Handle bzero.
* builtins.def: Add BUILT_IN_BZERO.
* c-common.c (c_common_nodes_and_builtins): Provide builtin
prototype & function for bzero.
From-SVN: r32727
+2000-03-24 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * builtins.c (expand_builtin_bzero): New function.
+ (expand_builtin): Handle bzero.
+
+ * builtins.def: Add BUILT_IN_BZERO.
+
+ * c-common.c (c_common_nodes_and_builtins): Provide builtin
+ prototype & function for bzero.
+
2000-03-23 Michael Meissner <meissner@redhat.com>
* config/alpha/alpha.md (TF floating point insns): Undo 2000-03-21
static rtx expand_builtin_memcpy PARAMS ((tree));
static rtx expand_builtin_strcpy PARAMS ((tree));
static rtx expand_builtin_memset PARAMS ((tree));
+static rtx expand_builtin_bzero PARAMS ((tree));
static rtx expand_builtin_strlen PARAMS ((tree, rtx,
enum machine_mode));
static rtx expand_builtin_alloca PARAMS ((tree, rtx));
}
}
+/* Expand expression EXP, which is a call to the bzero builtin. Return 0
+ if we failed the caller should emit a normal call. */
+static rtx
+expand_builtin_bzero (exp)
+ 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
/* Expand expression EXP, which is a call to the memcmp or the strcmp builtin.
ARGLIST is the argument list for this call. Return 0 if we failed and the
&& (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_BCMP
+ || fcode == BUILT_IN_BCMP || fcode == BUILT_IN_BZERO
|| fcode == BUILT_IN_STRLEN || fcode == BUILT_IN_STRCPY
|| fcode == BUILT_IN_STRCMP || fcode == BUILT_IN_FFS))
return expand_call (exp, target, ignore);
return target;
break;
+ case BUILT_IN_BZERO:
+ target = expand_builtin_bzero (exp);
+ if (target)
+ return target;
+ break;
+
/* These comparison functions need an instruction that returns an actual
index. An ordinary compare that just sets the condition codes
is not enough. */
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)
{
tree temp;
tree memcpy_ftype, memset_ftype, strlen_ftype;
- tree bcmp_ftype;
+ tree bzero_ftype, bcmp_ftype;
tree endlink, int_endlink, double_endlink, unsigned_endlink;
tree sizetype_endlink;
tree ptr_ftype, ptr_ftype_unsigned;
sizetype,
endlink))));
+ /* Prototype for bzero. */
+ bzero_ftype
+ = build_function_type (void_type_node,
+ tree_cons (NULL_TREE, traditional_ptr_type_node,
+ traditional_len_endlink));
+
/* Prototype for bcmp. */
bcmp_ftype
= build_function_type (integer_type_node,
/* Suppress error if redefined as a non-function. */
DECL_BUILT_IN_NONANSI (temp) = 1;
+ /* In C mode, don't conflict with system prototype variations. */
+ 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);
BUILT_IN_NORMAL, "memcpy");
builtin_function ("__builtin_memcmp", int_ftype_cptr_cptr_sizet,
BUILT_IN_MEMCMP, BUILT_IN_NORMAL, "memcmp");
- builtin_function ("__builtin_memset", memset_ftype, BUILT_IN_MEMSET,
- BUILT_IN_NORMAL, "memset");
+ builtin_function ("__builtin_memset", memset_ftype,
+ BUILT_IN_MEMSET, BUILT_IN_NORMAL, "memset");
+ 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");
builtin_function ("__builtin_strcmp", int_ftype_string_string,