Commit e3a709be by Kaveh R. Ghazi Committed by Kaveh Ghazi

builtins.c (expand_builtin_bzero): New function.

	* 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
parent 34249844
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
......
......@@ -96,6 +96,7 @@ static rtx expand_builtin_strcmp PARAMS ((tree, rtx));
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));
......@@ -1574,6 +1575,42 @@ expand_builtin_memset (exp)
}
}
/* 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
......@@ -2313,7 +2350,7 @@ expand_builtin (exp, target, subtarget, mode, ignore)
&& (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);
......@@ -2451,6 +2488,12 @@ expand_builtin (exp, target, subtarget, mode, 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. */
......
......@@ -33,6 +33,7 @@ DEF_BUILTIN(BUILT_IN_FREM)
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)
......
......@@ -3462,7 +3462,7 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins)
{
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;
......@@ -3597,6 +3597,12 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins)
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,
......@@ -3639,6 +3645,11 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins)
/* 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);
......@@ -3746,8 +3757,10 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins)
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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment