aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2000-03-24 20:20:56 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2000-03-24 20:20:56 +0000
commite3a709be4d65ffbaa50949f94039f7ab7686e4f5 (patch)
treed8a9016e5e8a7f8532c10a24cd7aaaad58cd2200 /gcc/builtins.c
parent3424984446d90b366bddbce3dedb9235f8af280b (diff)
downloadgcc-e3a709be4d65ffbaa50949f94039f7ab7686e4f5.zip
gcc-e3a709be4d65ffbaa50949f94039f7ab7686e4f5.tar.gz
gcc-e3a709be4d65ffbaa50949f94039f7ab7686e4f5.tar.bz2
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
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 5486552..285f4a0 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -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. */